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:
parent
b806f9e7e3
commit
9129f256fa
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user