mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: Remove ContactInfo and it's usage
This commit is contained in:
parent
c11b3730c9
commit
65a5b5121d
|
@ -11,17 +11,6 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
void removeDialog(ContentDialog* dialog, QHash<int, ContactInfo>& infos)
|
||||
{
|
||||
for (auto it = infos.begin(); it != infos.end();) {
|
||||
if (std::get<0>(*it) == dialog) {
|
||||
it = infos.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void removeDialog(ContentDialog* dialog, QHash<int, ContentDialog*>& dialogs)
|
||||
{
|
||||
for (auto it = dialogs.begin(); it != dialogs.end();) {
|
||||
|
@ -73,7 +62,6 @@ FriendWidget* ContentDialogManager::addFriendToDialog(ContentDialog* dialog,
|
|||
}
|
||||
|
||||
friendDialogs[friendId] = dialog;
|
||||
friendList.insert(friendId, std::make_tuple(dialog, friendWidget));
|
||||
return friendWidget;
|
||||
}
|
||||
|
||||
|
@ -89,22 +77,9 @@ GroupWidget* ContentDialogManager::addGroupToDialog(ContentDialog* dialog,
|
|||
}
|
||||
|
||||
groupDialogs[groupId] = dialog;
|
||||
groupList.insert(groupId, std::make_tuple(dialog, groupWidget));
|
||||
return groupWidget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check, if widget is exists.
|
||||
* @param id User Id.
|
||||
* @param list List with contact info.
|
||||
* @return True is widget exists, false otherwise.
|
||||
*/
|
||||
bool ContentDialogManager::existsWidget(int id, const QHash<int, ContactInfo>& list)
|
||||
{
|
||||
auto iter = list.find(id);
|
||||
return iter != list.end();
|
||||
}
|
||||
|
||||
void ContentDialogManager::focusFriend(int friendId)
|
||||
{
|
||||
auto dialog = focusDialog(friendId, friendDialogs);
|
||||
|
@ -243,9 +218,6 @@ void ContentDialogManager::onDialogClose()
|
|||
currentDialog = nullptr;
|
||||
}
|
||||
|
||||
removeDialog(dialog, friendList);
|
||||
removeDialog(dialog, groupList);
|
||||
|
||||
removeDialog(dialog, friendDialogs);
|
||||
removeDialog(dialog, groupDialogs);
|
||||
}
|
|
@ -56,16 +56,12 @@ private slots:
|
|||
|
||||
private:
|
||||
ContentDialog* focusDialog(int id, const QHash<int, ContentDialog*>& list);
|
||||
bool existsWidget(int id, const QHash<int, ContactInfo>& list);
|
||||
|
||||
ContentDialog* currentDialog = nullptr;
|
||||
|
||||
QHash<int, ContentDialog*> friendDialogs;
|
||||
QHash<int, ContentDialog*> groupDialogs;
|
||||
|
||||
QHash<int, ContactInfo> friendList;
|
||||
QHash<int, ContactInfo> groupList;
|
||||
|
||||
static ContentDialogManager* instance;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user