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

refactor: Rewrite isWidgetActive

This commit is contained in:
Diadlo 2018-12-24 21:25:24 +03:00
parent 4353468647
commit c11b3730c9
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
2 changed files with 9 additions and 20 deletions

View File

@ -186,30 +186,22 @@ void ContentDialogManager::updateGroupStatus(int groupId)
bool ContentDialogManager::isFriendWidgetActive(int friendId) bool ContentDialogManager::isFriendWidgetActive(int friendId)
{ {
return isWidgetActive(friendId, friendList); const auto dialog = friendDialogs.value(friendId);
if (dialog == nullptr) {
return false;
}
return dialog->isFriendWidgetActive(friendId);
} }
bool ContentDialogManager::isGroupWidgetActive(int groupId) bool ContentDialogManager::isGroupWidgetActive(int groupId)
{ {
return isWidgetActive(groupId, groupList); const auto dialog = groupDialogs.value(groupId);
} if (dialog == nullptr) {
/**
* @brief Check, if user dialog is active.
* @param id User Id.
* @param list List with contact info.
* @return True if user dialog is active, false otherwise.
*/
bool ContentDialogManager::isWidgetActive(int id, const QHash<int, ContactInfo>& list)
{
auto iter = list.find(id);
if (iter == list.end()) {
return false; return false;
} }
const auto dialog = std::get<0>(iter.value()); return dialog->isGroupWidgetActive(groupId);
const auto widget = std::get<1>(iter.value());
return dialog->isActiveWidget(widget);
} }
ContentDialog* ContentDialogManager::getFriendDialog(int friendId) const ContentDialog* ContentDialogManager::getFriendDialog(int friendId) const

View File

@ -57,9 +57,6 @@ private slots:
private: private:
ContentDialog* focusDialog(int id, const QHash<int, ContentDialog*>& list); ContentDialog* focusDialog(int id, const QHash<int, ContentDialog*>& list);
bool existsWidget(int id, const QHash<int, ContactInfo>& list); bool existsWidget(int id, const QHash<int, ContactInfo>& list);
void updateStatus(int id, const QHash<int, ContactInfo>& list);
bool isWidgetActive(int id, const QHash<int, ContactInfo>& list);
ContentDialog* getDialog(int id, const QHash<int, ContactInfo>& list) const;
ContentDialog* currentDialog = nullptr; ContentDialog* currentDialog = nullptr;