From bc9af0716d9d99aeb4919cb7d5ffa3852985877f Mon Sep 17 00:00:00 2001 From: ZeldaZach Date: Tue, 14 Jan 2025 01:21:35 -0500 Subject: [PATCH] Doesn't work --- cockatrice/src/client/tabs/tab_account.cpp | 16 ++++++++++------ cockatrice/src/client/tabs/tab_account.h | 1 + cockatrice/src/client/user_list_manager.cpp | 5 +---- cockatrice/src/client/user_list_manager.h | 8 ++++---- cockatrice/src/server/user/user_list.h | 12 +++++++++++- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/cockatrice/src/client/tabs/tab_account.cpp b/cockatrice/src/client/tabs/tab_account.cpp index 54058e779..04be44e2e 100644 --- a/cockatrice/src/client/tabs/tab_account.cpp +++ b/cockatrice/src/client/tabs/tab_account.cpp @@ -28,9 +28,13 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, userInfoBox = new UserInfoBox(client, true); userInfoBox->updateInfo(userInfo); - connect(userListManager->getAllUsersList(), &UserList::openMessageDialog, this, &TabUserLists::openMessageDialog); - connect(userListManager->getBuddyList(), &UserList::openMessageDialog, this, &TabUserLists::openMessageDialog); - connect(userListManager->getIgnoreList(), &UserList::openMessageDialog, this, &TabUserLists::openMessageDialog); + allUsersList = new UserList(tabSupervisor, client, UserList::AllUsersList); + buddyList = new UserList(tabSupervisor, client, UserList::BuddyList); + ignoreList = new UserList(tabSupervisor, client, UserList::IgnoreList); + + connect(allUsersList, &UserList::openMessageDialog, this, &TabUserLists::openMessageDialog); + connect(buddyList, &UserList::openMessageDialog, this, &TabUserLists::openMessageDialog); + connect(ignoreList, &UserList::openMessageDialog, this, &TabUserLists::openMessageDialog); PendingCommand *pend = client->prepareSessionCommand(Command_ListUsers()); connect(pend, @@ -41,7 +45,7 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(userInfoBox); - vbox->addWidget(userListManager->getAllUsersList()); + vbox->addWidget(allUsersList); QHBoxLayout *addToBuddyList = new QHBoxLayout; addBuddyEdit = new LineEditUnfocusable; @@ -64,11 +68,11 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, addToIgnoreList->addWidget(addIgnoreButton); QVBoxLayout *buddyPanel = new QVBoxLayout; - buddyPanel->addWidget(userListManager->getBuddyList()); + buddyPanel->addWidget(buddyList); buddyPanel->addLayout(addToBuddyList); QVBoxLayout *ignorePanel = new QVBoxLayout; - ignorePanel->addWidget(userListManager->getIgnoreList()); + ignorePanel->addWidget(ignoreList); ignorePanel->addLayout(addToIgnoreList); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addLayout(buddyPanel); diff --git a/cockatrice/src/client/tabs/tab_account.h b/cockatrice/src/client/tabs/tab_account.h index 47d150b8f..121c6d08e 100644 --- a/cockatrice/src/client/tabs/tab_account.h +++ b/cockatrice/src/client/tabs/tab_account.h @@ -32,6 +32,7 @@ private: UserInfoBox *userInfoBox; LineEditUnfocusable *addBuddyEdit; LineEditUnfocusable *addIgnoreEdit; + UserList *allUsersList, *buddyList, *ignoreList; public: TabUserLists(TabSupervisor *_tabSupervisor, diff --git a/cockatrice/src/client/user_list_manager.cpp b/cockatrice/src/client/user_list_manager.cpp index 5a47d3d03..9a16cdb18 100644 --- a/cockatrice/src/client/user_list_manager.cpp +++ b/cockatrice/src/client/user_list_manager.cpp @@ -14,10 +14,7 @@ #include "trice_limits.h" UserListManager::UserListManager(TabSupervisor *_tabSupervisor, AbstractClient *_client) - : client(_client), tabSupervisor(_tabSupervisor), - allUsersList(new UserList(tabSupervisor, client, UserList::AllUsersList)), - buddyList(new UserList(tabSupervisor, client, UserList::BuddyList)), - ignoreList(new UserList(tabSupervisor, client, UserList::IgnoreList)) + : client(_client), tabSupervisor(_tabSupervisor) { connect(client, &AbstractClient::userJoinedEventReceived, this, &UserListManager::processUserJoinedEvent); connect(client, &AbstractClient::userLeftEventReceived, this, &UserListManager::processUserLeftEvent); diff --git a/cockatrice/src/client/user_list_manager.h b/cockatrice/src/client/user_list_manager.h index 117a61c58..f48c9928f 100644 --- a/cockatrice/src/client/user_list_manager.h +++ b/cockatrice/src/client/user_list_manager.h @@ -23,7 +23,7 @@ class UserListManager : public QWidget private: AbstractClient *client; TabSupervisor *tabSupervisor; - UserList *allUsersList, *buddyList, *ignoreList; + QList allUsersList, buddyList, ignoreList; private slots: void processUserJoinedEvent(const Event_UserJoined &event); @@ -35,15 +35,15 @@ private slots: public: explicit UserListManager(TabSupervisor *_tabSupervisor, AbstractClient *_client); - [[nodiscard]] UserList *getAllUsersList() const + [[nodiscard]] QList getAllUsersList() const { return allUsersList; } - [[nodiscard]] UserList *getBuddyList() const + [[nodiscard]] QList getBuddyList() const { return buddyList; } - [[nodiscard]] UserList *getIgnoreList() const + [[nodiscard]] QList getIgnoreList() const { return ignoreList; } diff --git a/cockatrice/src/server/user/user_list.h b/cockatrice/src/server/user/user_list.h index 23afcd5fc..74f1c8fab 100644 --- a/cockatrice/src/server/user/user_list.h +++ b/cockatrice/src/server/user/user_list.h @@ -5,12 +5,14 @@ #include "user_level.h" #include +#include #include #include #include #include #include +class UserListManager; class QTreeWidget; class ServerInfo_User; class AbstractClient; @@ -131,6 +133,7 @@ private: QTreeWidget *userTree; UserListItemDelegate *itemDelegate; UserContextMenu *userContextMenu; + UserListManager *userListManager; int onlineCount; QString titleStr; void updateCount(); @@ -140,7 +143,14 @@ signals: void openMessageDialog(const QString &userName, bool focus); public: - explicit UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserListType _type, QWidget *parent = nullptr); + explicit UserList(TabSupervisor *_tabSupervisor, + AbstractClient *_client, + UserListType _type, + QWidget *parent = nullptr); + ~UserList() + { + qDebug() << "DESTROYING" << type; + } void retranslateUi(); void processUserInfo(const ServerInfo_User &user, bool online); bool deleteUser(const QString &userName);