From d09b9eb533869edd816c28cd1a9448eebf3f5d54 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:07:36 -0800 Subject: [PATCH] Rename UserList class to UserListWidget (#5473) --- cockatrice/CMakeLists.txt | 2 +- cockatrice/src/client/tabs/tab_account.cpp | 18 ++++++------- cockatrice/src/client/tabs/tab_account.h | 14 +++++----- cockatrice/src/client/tabs/tab_room.cpp | 4 +-- cockatrice/src/client/tabs/tab_room.h | 4 +-- cockatrice/src/client/tabs/tab_server.cpp | 2 +- cockatrice/src/client/tabs/tab_server.h | 2 +- cockatrice/src/client/tabs/tab_supervisor.cpp | 2 +- cockatrice/src/game/games_model.cpp | 2 +- .../src/game/player/player_list_widget.cpp | 2 +- cockatrice/src/server/chat_view/chat_view.h | 2 +- .../src/server/user/user_context_menu.cpp | 2 +- .../{user_list.cpp => user_list_widget.cpp} | 27 ++++++++++--------- .../user/{user_list.h => user_list_widget.h} | 7 +++-- 14 files changed, 48 insertions(+), 42 deletions(-) rename cockatrice/src/server/user/{user_list.cpp => user_list_widget.cpp} (94%) rename cockatrice/src/server/user/{user_list.h => user_list_widget.h} (94%) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 73b835bdd..b1239c4ad 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -159,7 +159,7 @@ set(cockatrice_SOURCES src/server/user/user_context_menu.cpp src/server/user/user_info_connection.cpp src/server/user/user_info_box.cpp - src/server/user/user_list.cpp + src/server/user/user_list_widget.cpp src/client/ui/window_main.cpp src/game/zones/view_zone_widget.cpp src/game/zones/view_zone.cpp diff --git a/cockatrice/src/client/tabs/tab_account.cpp b/cockatrice/src/client/tabs/tab_account.cpp index 4969521f7..602eb2f60 100644 --- a/cockatrice/src/client/tabs/tab_account.cpp +++ b/cockatrice/src/client/tabs/tab_account.cpp @@ -3,7 +3,7 @@ #include "../../deck/custom_line_edit.h" #include "../../server/pending_command.h" #include "../../server/user/user_info_box.h" -#include "../../server/user/user_list.h" +#include "../../server/user/user_list_widget.h" #include "../game_logic/abstract_client.h" #include "../sound_engine.h" #include "pb/event_add_to_list.pb.h" @@ -21,15 +21,15 @@ TabAccount::TabAccount(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &userInfo) : Tab(_tabSupervisor), client(_client) { - allUsersList = new UserList(_tabSupervisor, client, UserList::AllUsersList); - buddyList = new UserList(_tabSupervisor, client, UserList::BuddyList); - ignoreList = new UserList(_tabSupervisor, client, UserList::IgnoreList); + allUsersList = new UserListWidget(_tabSupervisor, client, UserListWidget::AllUsersList); + buddyList = new UserListWidget(_tabSupervisor, client, UserListWidget::BuddyList); + ignoreList = new UserListWidget(_tabSupervisor, client, UserListWidget::IgnoreList); userInfoBox = new UserInfoBox(client, true); userInfoBox->updateInfo(userInfo); - connect(allUsersList, &UserList::openMessageDialog, this, &TabAccount::openMessageDialog); - connect(buddyList, &UserList::openMessageDialog, this, &TabAccount::openMessageDialog); - connect(ignoreList, &UserList::openMessageDialog, this, &TabAccount::openMessageDialog); + connect(allUsersList, &UserListWidget::openMessageDialog, this, &TabAccount::openMessageDialog); + connect(buddyList, &UserListWidget::openMessageDialog, this, &TabAccount::openMessageDialog); + connect(ignoreList, &UserListWidget::openMessageDialog, this, &TabAccount::openMessageDialog); connect(client, &AbstractClient::userJoinedEventReceived, this, &TabAccount::processUserJoinedEvent); connect(client, &AbstractClient::userLeftEventReceived, this, &TabAccount::processUserLeftEvent); @@ -201,7 +201,7 @@ void TabAccount::processAddToListEvent(const Event_AddToList &event) const ServerInfo_User &info = event.user_info(); bool online = allUsersList->getUsers().contains(QString::fromStdString(info.name())); QString list = QString::fromStdString(event.list_name()); - UserList *userList = 0; + UserListWidget *userList = 0; if (list == "buddy") userList = buddyList; else if (list == "ignore") @@ -217,7 +217,7 @@ void TabAccount::processRemoveFromListEvent(const Event_RemoveFromList &event) { QString list = QString::fromStdString(event.list_name()); QString user = QString::fromStdString(event.user_name()); - UserList *userList = 0; + UserListWidget *userList = 0; if (list == "buddy") userList = buddyList; else if (list == "ignore") diff --git a/cockatrice/src/client/tabs/tab_account.h b/cockatrice/src/client/tabs/tab_account.h index c4ae87cb3..203dcd6c3 100644 --- a/cockatrice/src/client/tabs/tab_account.h +++ b/cockatrice/src/client/tabs/tab_account.h @@ -5,7 +5,7 @@ #include "tab.h" class AbstractClient; -class UserList; +class UserListWidget; class UserInfoBox; class LineEditUnfocusable; @@ -37,9 +37,9 @@ private slots: private: AbstractClient *client; - UserList *allUsersList; - UserList *buddyList; - UserList *ignoreList; + UserListWidget *allUsersList; + UserListWidget *buddyList; + UserListWidget *ignoreList; UserInfoBox *userInfoBox; LineEditUnfocusable *addBuddyEdit; LineEditUnfocusable *addIgnoreEdit; @@ -52,15 +52,15 @@ public: { return tr("Account"); } - const UserList *getAllUsersList() const + const UserListWidget *getAllUsersList() const { return allUsersList; } - const UserList *getBuddyList() const + const UserListWidget *getBuddyList() const { return buddyList; } - const UserList *getIgnoreList() const + const UserListWidget *getIgnoreList() const { return ignoreList; } diff --git a/cockatrice/src/client/tabs/tab_room.cpp b/cockatrice/src/client/tabs/tab_room.cpp index a8c7140b9..4f3b26714 100644 --- a/cockatrice/src/client/tabs/tab_room.cpp +++ b/cockatrice/src/client/tabs/tab_room.cpp @@ -6,7 +6,7 @@ #include "../../main.h" #include "../../server/chat_view/chat_view.h" #include "../../server/pending_command.h" -#include "../../server/user/user_list.h" +#include "../../server/user/user_list_widget.h" #include "../../settings/cache_settings.h" #include "get_pb_extension.h" #include "pb/event_join_room.pb.h" @@ -47,7 +47,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, QMap tempMap; tempMap.insert(info.room_id(), gameTypes); gameSelector = new GameSelector(client, tabSupervisor, this, QMap(), tempMap, true, true); - userList = new UserList(tabSupervisor, client, UserList::RoomList); + userList = new UserListWidget(tabSupervisor, client, UserListWidget::RoomList); connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool))); diff --git a/cockatrice/src/client/tabs/tab_room.h b/cockatrice/src/client/tabs/tab_room.h index 32152e933..6039ecc36 100644 --- a/cockatrice/src/client/tabs/tab_room.h +++ b/cockatrice/src/client/tabs/tab_room.h @@ -17,7 +17,7 @@ class Message; } } // namespace google class AbstractClient; -class UserList; +class UserListWidget; class QLabel; class ChatView; class QPushButton; @@ -48,7 +48,7 @@ private: QMap gameTypes; GameSelector *gameSelector; - UserList *userList; + UserListWidget *userList; ChatView *chatView; QLabel *sayLabel; LineEditCompleter *sayEdit; diff --git a/cockatrice/src/client/tabs/tab_server.cpp b/cockatrice/src/client/tabs/tab_server.cpp index 029964d8e..40fa401d2 100644 --- a/cockatrice/src/client/tabs/tab_server.cpp +++ b/cockatrice/src/client/tabs/tab_server.cpp @@ -2,7 +2,7 @@ #include "../../client/game_logic/abstract_client.h" #include "../../server/pending_command.h" -#include "../../server/user/user_list.h" +#include "../../server/user/user_list_widget.h" #include "pb/event_list_rooms.pb.h" #include "pb/event_server_message.pb.h" #include "pb/response_join_room.pb.h" diff --git a/cockatrice/src/client/tabs/tab_server.h b/cockatrice/src/client/tabs/tab_server.h index 890a79cea..51df54397 100644 --- a/cockatrice/src/client/tabs/tab_server.h +++ b/cockatrice/src/client/tabs/tab_server.h @@ -10,7 +10,7 @@ class AbstractClient; class QTextEdit; class QLabel; -class UserList; +class UserListWidget; class QPushButton; class Event_ListRooms; diff --git a/cockatrice/src/client/tabs/tab_supervisor.cpp b/cockatrice/src/client/tabs/tab_supervisor.cpp index d3704661b..0e1e41db5 100644 --- a/cockatrice/src/client/tabs/tab_supervisor.cpp +++ b/cockatrice/src/client/tabs/tab_supervisor.cpp @@ -2,7 +2,7 @@ #include "../../client/game_logic/abstract_client.h" #include "../../main.h" -#include "../../server/user/user_list.h" +#include "../../server/user/user_list_widget.h" #include "../../settings/cache_settings.h" #include "../ui/pixel_map_generator.h" #include "pb/event_game_joined.pb.h" diff --git a/cockatrice/src/game/games_model.cpp b/cockatrice/src/game/games_model.cpp index 4d3104a19..a2b42ee7a 100644 --- a/cockatrice/src/game/games_model.cpp +++ b/cockatrice/src/game/games_model.cpp @@ -2,7 +2,7 @@ #include "../client/tabs/tab_account.h" #include "../client/ui/pixel_map_generator.h" -#include "../server/user/user_list.h" +#include "../server/user/user_list_widget.h" #include "../settings/cache_settings.h" #include "pb/serverinfo_game.pb.h" diff --git a/cockatrice/src/game/player/player_list_widget.cpp b/cockatrice/src/game/player/player_list_widget.cpp index ef63c9dc0..bca98a35b 100644 --- a/cockatrice/src/game/player/player_list_widget.cpp +++ b/cockatrice/src/game/player/player_list_widget.cpp @@ -6,7 +6,7 @@ #include "../../client/tabs/tab_supervisor.h" #include "../../client/ui/pixel_map_generator.h" #include "../../server/user/user_context_menu.h" -#include "../../server/user/user_list.h" +#include "../../server/user/user_list_widget.h" #include "pb/command_kick_from_game.pb.h" #include "pb/serverinfo_playerproperties.pb.h" #include "pb/session_commands.pb.h" diff --git a/cockatrice/src/server/chat_view/chat_view.h b/cockatrice/src/server/chat_view/chat_view.h index c48ef4dfe..cf5437dd4 100644 --- a/cockatrice/src/server/chat_view/chat_view.h +++ b/cockatrice/src/server/chat_view/chat_view.h @@ -2,7 +2,7 @@ #define CHATVIEW_H #include "../../client/tabs/tab_supervisor.h" -#include "../user/user_list.h" +#include "../user/user_list_widget.h" #include "room_message_type.h" #include "user_level.h" #include "user_list_proxy.h" diff --git a/cockatrice/src/server/user/user_context_menu.cpp b/cockatrice/src/server/user/user_context_menu.cpp index 25026801c..8b055af34 100644 --- a/cockatrice/src/server/user/user_context_menu.cpp +++ b/cockatrice/src/server/user/user_context_menu.cpp @@ -18,7 +18,7 @@ #include "pb/response_warn_list.pb.h" #include "pb/session_commands.pb.h" #include "user_info_box.h" -#include "user_list.h" +#include "user_list_widget.h" #include #include diff --git a/cockatrice/src/server/user/user_list.cpp b/cockatrice/src/server/user/user_list_widget.cpp similarity index 94% rename from cockatrice/src/server/user/user_list.cpp rename to cockatrice/src/server/user/user_list_widget.cpp index 98b42362b..80fe67b50 100644 --- a/cockatrice/src/server/user/user_list.cpp +++ b/cockatrice/src/server/user/user_list_widget.cpp @@ -1,4 +1,4 @@ -#include "user_list.h" +#include "user_list_widget.h" #include "../../client/game_logic/abstract_client.h" #include "../../client/tabs/tab_account.h" @@ -323,9 +323,9 @@ bool UserListItemDelegate::editorEvent(QEvent *event, QMouseEvent *const mouseEvent = static_cast(event); if (mouseEvent->button() == Qt::RightButton) { #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - static_cast(parent())->showContextMenu(mouseEvent->globalPosition().toPoint(), index); + static_cast(parent())->showContextMenu(mouseEvent->globalPosition().toPoint(), index); #else - static_cast(parent())->showContextMenu(mouseEvent->globalPos(), index); + static_cast(parent())->showContextMenu(mouseEvent->globalPos(), index); #endif return true; } @@ -370,7 +370,10 @@ bool UserListTWI::operator<(const QTreeWidgetItem &other) const return QString::localeAwareCompare(data(2, Qt::UserRole).toString(), other.data(2, Qt::UserRole).toString()) < 0; } -UserList::UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserListType _type, QWidget *parent) +UserListWidget::UserListWidget(TabSupervisor *_tabSupervisor, + AbstractClient *_client, + UserListType _type, + QWidget *parent) : QGroupBox(parent), tabSupervisor(_tabSupervisor), client(_client), type(_type), onlineCount(0) { itemDelegate = new UserListItemDelegate(this); @@ -395,7 +398,7 @@ UserList::UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserL retranslateUi(); } -void UserList::retranslateUi() +void UserListWidget::retranslateUi() { userContextMenu->retranslateUi(); switch (type) { @@ -415,7 +418,7 @@ void UserList::retranslateUi() updateCount(); } -void UserList::processUserInfo(const ServerInfo_User &user, bool online) +void UserListWidget::processUserInfo(const ServerInfo_User &user, bool online) { const QString userName = QString::fromStdString(user.name()); UserListTWI *item = users.value(userName); @@ -432,7 +435,7 @@ void UserList::processUserInfo(const ServerInfo_User &user, bool online) item->setOnline(online); } -bool UserList::deleteUser(const QString &userName) +bool UserListWidget::deleteUser(const QString &userName) { UserListTWI *twi = users.value(userName); if (twi) { @@ -448,7 +451,7 @@ bool UserList::deleteUser(const QString &userName) return false; } -void UserList::setUserOnline(const QString &userName, bool online) +void UserListWidget::setUserOnline(const QString &userName, bool online) { UserListTWI *twi = users.value(userName); if (!twi) @@ -462,7 +465,7 @@ void UserList::setUserOnline(const QString &userName, bool online) updateCount(); } -void UserList::updateCount() +void UserListWidget::updateCount() { QString str = titleStr; if ((type == BuddyList) || (type == IgnoreList)) @@ -470,12 +473,12 @@ void UserList::updateCount() setTitle(str.arg(userTree->topLevelItemCount())); } -void UserList::userClicked(QTreeWidgetItem *item, int /*column*/) +void UserListWidget::userClicked(QTreeWidgetItem *item, int /*column*/) { emit openMessageDialog(item->data(2, Qt::UserRole).toString(), true); } -void UserList::showContextMenu(const QPoint &pos, const QModelIndex &index) +void UserListWidget::showContextMenu(const QPoint &pos, const QModelIndex &index) { const ServerInfo_User &userInfo = static_cast(userTree->topLevelItem(index.row()))->getUserInfo(); bool online = index.sibling(index.row(), 0).data(Qt::UserRole + 1).toBool(); @@ -484,7 +487,7 @@ void UserList::showContextMenu(const QPoint &pos, const QModelIndex &index) UserLevelFlags(userInfo.user_level()), online); } -void UserList::sortItems() +void UserListWidget::sortItems() { userTree->sortItems(1, Qt::AscendingOrder); } diff --git a/cockatrice/src/server/user/user_list.h b/cockatrice/src/server/user/user_list_widget.h similarity index 94% rename from cockatrice/src/server/user/user_list.h rename to cockatrice/src/server/user/user_list_widget.h index abf52ff52..af9286d3d 100644 --- a/cockatrice/src/server/user/user_list.h +++ b/cockatrice/src/server/user/user_list_widget.h @@ -111,7 +111,7 @@ public: bool operator<(const QTreeWidgetItem &other) const; }; -class UserList : public QGroupBox +class UserListWidget : public QGroupBox { Q_OBJECT public: @@ -144,7 +144,10 @@ signals: void removeIgnore(const QString &userName); public: - UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserListType _type, QWidget *parent = nullptr); + UserListWidget(TabSupervisor *_tabSupervisor, + AbstractClient *_client, + UserListType _type, + QWidget *parent = nullptr); void retranslateUi(); void processUserInfo(const ServerInfo_User &user, bool online); bool deleteUser(const QString &userName);