diff --git a/cockatrice/src/client/tabs/tab_account.cpp b/cockatrice/src/client/tabs/tab_account.cpp index 4969521f7..3aecdeb60 100644 --- a/cockatrice/src/client/tabs/tab_account.cpp +++ b/cockatrice/src/client/tabs/tab_account.cpp @@ -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..ea6432fe7 100644 --- a/cockatrice/src/client/tabs/tab_room.cpp +++ b/cockatrice/src/client/tabs/tab_room.cpp @@ -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.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/server/user/user_list.cpp b/cockatrice/src/server/user/user_list.cpp index 98b42362b..52740da91 100644 --- a/cockatrice/src/server/user/user_list.cpp +++ b/cockatrice/src/server/user/user_list.cpp @@ -323,7 +323,7 @@ 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); #endif @@ -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.h index abf52ff52..af9286d3d 100644 --- a/cockatrice/src/server/user/user_list.h +++ b/cockatrice/src/server/user/user_list.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);