mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-28 01:23:55 -07:00
Populate TabAccount if reopened (#5483)
This commit is contained in:
parent
80165c28a9
commit
cb64a5eea0
2 changed files with 18 additions and 12 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
#include "../../deck/custom_line_edit.h"
|
#include "../../deck/custom_line_edit.h"
|
||||||
#include "../../server/pending_command.h"
|
#include "../../server/pending_command.h"
|
||||||
#include "../../server/user/user_info_box.h"
|
#include "../../server/user/user_info_box.h"
|
||||||
|
#include "../../server/user/user_list_manager.h"
|
||||||
#include "../../server/user/user_list_widget.h"
|
#include "../../server/user/user_list_widget.h"
|
||||||
#include "../game_logic/abstract_client.h"
|
#include "../game_logic/abstract_client.h"
|
||||||
#include "../sound_engine.h"
|
#include "../sound_engine.h"
|
||||||
|
|
@ -12,6 +13,7 @@
|
||||||
#include "pb/event_user_left.pb.h"
|
#include "pb/event_user_left.pb.h"
|
||||||
#include "pb/response_list_users.pb.h"
|
#include "pb/response_list_users.pb.h"
|
||||||
#include "pb/session_commands.pb.h"
|
#include "pb/session_commands.pb.h"
|
||||||
|
#include "tab_supervisor.h"
|
||||||
#include "trice_limits.h"
|
#include "trice_limits.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
@ -38,6 +40,10 @@ TabAccount::TabAccount(TabSupervisor *_tabSupervisor, AbstractClient *_client, c
|
||||||
connect(client, &AbstractClient::addToListEventReceived, this, &TabAccount::processAddToListEvent);
|
connect(client, &AbstractClient::addToListEventReceived, this, &TabAccount::processAddToListEvent);
|
||||||
connect(client, &AbstractClient::removeFromListEventReceived, this, &TabAccount::processRemoveFromListEvent);
|
connect(client, &AbstractClient::removeFromListEventReceived, this, &TabAccount::processRemoveFromListEvent);
|
||||||
|
|
||||||
|
// Attempt to populate the tab with the cache
|
||||||
|
buddyListReceived(tabSupervisor->getUserListManager()->getBuddyList().values());
|
||||||
|
ignoreListReceived(tabSupervisor->getUserListManager()->getIgnoreList().values());
|
||||||
|
|
||||||
PendingCommand *pend = client->prepareSessionCommand(Command_ListUsers());
|
PendingCommand *pend = client->prepareSessionCommand(Command_ListUsers());
|
||||||
connect(pend, &PendingCommand::finished, this, &TabAccount::processListUsersResponse);
|
connect(pend, &PendingCommand::finished, this, &TabAccount::processListUsersResponse);
|
||||||
client->sendCommand(pend);
|
client->sendCommand(pend);
|
||||||
|
|
@ -181,15 +187,15 @@ void TabAccount::processUserLeftEvent(const Event_UserLeft &event)
|
||||||
|
|
||||||
void TabAccount::buddyListReceived(const QList<ServerInfo_User> &_buddyList)
|
void TabAccount::buddyListReceived(const QList<ServerInfo_User> &_buddyList)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _buddyList.size(); ++i)
|
for (const auto &user : _buddyList)
|
||||||
buddyList->processUserInfo(_buddyList[i], false);
|
buddyList->processUserInfo(user, false);
|
||||||
buddyList->sortItems();
|
buddyList->sortItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabAccount::ignoreListReceived(const QList<ServerInfo_User> &_ignoreList)
|
void TabAccount::ignoreListReceived(const QList<ServerInfo_User> &_ignoreList)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _ignoreList.size(); ++i)
|
for (const auto &user : _ignoreList)
|
||||||
ignoreList->processUserInfo(_ignoreList[i], false);
|
ignoreList->processUserInfo(user, false);
|
||||||
ignoreList->sortItems();
|
ignoreList->sortItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,16 +103,16 @@ void UserListManager::processAddToListEvent(const Event_AddToList &event)
|
||||||
|
|
||||||
const auto &userListType = QString::fromStdString(event.list_name());
|
const auto &userListType = QString::fromStdString(event.list_name());
|
||||||
|
|
||||||
QMap<QString, ServerInfo_User> userMap;
|
QMap<QString, ServerInfo_User> *userMap;
|
||||||
if (userListType == "buddy") {
|
if (userListType == "buddy") {
|
||||||
userMap = buddyUsers;
|
userMap = &buddyUsers;
|
||||||
} else if (userListType == "ignore") {
|
} else if (userListType == "ignore") {
|
||||||
userMap = ignoredUsers;
|
userMap = &ignoredUsers;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
userMap.insert(userName, user);
|
userMap->insert(userName, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserListManager::processRemoveFromListEvent(const Event_RemoveFromList &event)
|
void UserListManager::processRemoveFromListEvent(const Event_RemoveFromList &event)
|
||||||
|
|
@ -120,16 +120,16 @@ void UserListManager::processRemoveFromListEvent(const Event_RemoveFromList &eve
|
||||||
const auto &userListType = QString::fromStdString(event.list_name());
|
const auto &userListType = QString::fromStdString(event.list_name());
|
||||||
const auto &userName = QString::fromStdString(event.user_name());
|
const auto &userName = QString::fromStdString(event.user_name());
|
||||||
|
|
||||||
QMap<QString, ServerInfo_User> userMap;
|
QMap<QString, ServerInfo_User> *userMap;
|
||||||
if (userListType == "buddy") {
|
if (userListType == "buddy") {
|
||||||
userMap = buddyUsers;
|
userMap = &buddyUsers;
|
||||||
} else if (userListType == "ignore") {
|
} else if (userListType == "ignore") {
|
||||||
userMap = ignoredUsers;
|
userMap = &ignoredUsers;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
userMap.remove(userName);
|
userMap->remove(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserListManager::isOwnUserRegistered() const
|
bool UserListManager::isOwnUserRegistered() const
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue