1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor: Rewrite widget exists check

This commit is contained in:
Diadlo 2018-12-24 21:36:51 +03:00
parent b806f9e7e3
commit 9129f256fa
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
3 changed files with 25 additions and 2 deletions

View File

@ -611,6 +611,16 @@ void ContentDialog::activate(GenericChatroomWidget* widget)
updateTitleAndStatusIcon();
}
bool ContentDialog::containsFriend(int friendId) const
{
return friendWidgets.contains(friendId);
}
bool ContentDialog::containsGroup(int groupId) const
{
return groupWidgets.contains(groupId);
}
/**
* @brief Update friend widget name and position.
* @param friendId Friend Id.

View File

@ -77,6 +77,9 @@ public:
void focusFriend(int friendId);
void focusGroup(int groupId);
bool containsFriend(int friendId) const;
bool containsGroup(int groupId) const;
signals:
void friendDialogShown(const Friend* f);
void groupDialogShown(Group* g);

View File

@ -43,12 +43,22 @@ ContentDialog* ContentDialogManager::current()
bool ContentDialogManager::friendWidgetExists(int friendId)
{
return existsWidget(friendId, friendList);
const auto dialog = friendDialogs.value(friendId, nullptr);
if (dialog == nullptr) {
return false;
}
return dialog->containsFriend(friendId);
}
bool ContentDialogManager::groupWidgetExists(int groupId)
{
return existsWidget(groupId, groupList);
const auto dialog = groupDialogs.value(groupId, nullptr);
if (dialog == nullptr) {
return false;
}
return dialog->containsGroup(groupId);
}
FriendWidget* ContentDialogManager::addFriendToDialog(ContentDialog* dialog,