mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 03:28:49 -07:00
Rename UserList class to UserListWidget (#5473)
This commit is contained in:
parent
25caae6d0f
commit
d09b9eb533
14 changed files with 48 additions and 42 deletions
|
|
@ -159,7 +159,7 @@ set(cockatrice_SOURCES
|
||||||
src/server/user/user_context_menu.cpp
|
src/server/user/user_context_menu.cpp
|
||||||
src/server/user/user_info_connection.cpp
|
src/server/user/user_info_connection.cpp
|
||||||
src/server/user/user_info_box.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/client/ui/window_main.cpp
|
||||||
src/game/zones/view_zone_widget.cpp
|
src/game/zones/view_zone_widget.cpp
|
||||||
src/game/zones/view_zone.cpp
|
src/game/zones/view_zone.cpp
|
||||||
|
|
|
||||||
|
|
@ -3,7 +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.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"
|
||||||
#include "pb/event_add_to_list.pb.h"
|
#include "pb/event_add_to_list.pb.h"
|
||||||
|
|
@ -21,15 +21,15 @@
|
||||||
TabAccount::TabAccount(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &userInfo)
|
TabAccount::TabAccount(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &userInfo)
|
||||||
: Tab(_tabSupervisor), client(_client)
|
: Tab(_tabSupervisor), client(_client)
|
||||||
{
|
{
|
||||||
allUsersList = new UserList(_tabSupervisor, client, UserList::AllUsersList);
|
allUsersList = new UserListWidget(_tabSupervisor, client, UserListWidget::AllUsersList);
|
||||||
buddyList = new UserList(_tabSupervisor, client, UserList::BuddyList);
|
buddyList = new UserListWidget(_tabSupervisor, client, UserListWidget::BuddyList);
|
||||||
ignoreList = new UserList(_tabSupervisor, client, UserList::IgnoreList);
|
ignoreList = new UserListWidget(_tabSupervisor, client, UserListWidget::IgnoreList);
|
||||||
userInfoBox = new UserInfoBox(client, true);
|
userInfoBox = new UserInfoBox(client, true);
|
||||||
userInfoBox->updateInfo(userInfo);
|
userInfoBox->updateInfo(userInfo);
|
||||||
|
|
||||||
connect(allUsersList, &UserList::openMessageDialog, this, &TabAccount::openMessageDialog);
|
connect(allUsersList, &UserListWidget::openMessageDialog, this, &TabAccount::openMessageDialog);
|
||||||
connect(buddyList, &UserList::openMessageDialog, this, &TabAccount::openMessageDialog);
|
connect(buddyList, &UserListWidget::openMessageDialog, this, &TabAccount::openMessageDialog);
|
||||||
connect(ignoreList, &UserList::openMessageDialog, this, &TabAccount::openMessageDialog);
|
connect(ignoreList, &UserListWidget::openMessageDialog, this, &TabAccount::openMessageDialog);
|
||||||
|
|
||||||
connect(client, &AbstractClient::userJoinedEventReceived, this, &TabAccount::processUserJoinedEvent);
|
connect(client, &AbstractClient::userJoinedEventReceived, this, &TabAccount::processUserJoinedEvent);
|
||||||
connect(client, &AbstractClient::userLeftEventReceived, this, &TabAccount::processUserLeftEvent);
|
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();
|
const ServerInfo_User &info = event.user_info();
|
||||||
bool online = allUsersList->getUsers().contains(QString::fromStdString(info.name()));
|
bool online = allUsersList->getUsers().contains(QString::fromStdString(info.name()));
|
||||||
QString list = QString::fromStdString(event.list_name());
|
QString list = QString::fromStdString(event.list_name());
|
||||||
UserList *userList = 0;
|
UserListWidget *userList = 0;
|
||||||
if (list == "buddy")
|
if (list == "buddy")
|
||||||
userList = buddyList;
|
userList = buddyList;
|
||||||
else if (list == "ignore")
|
else if (list == "ignore")
|
||||||
|
|
@ -217,7 +217,7 @@ void TabAccount::processRemoveFromListEvent(const Event_RemoveFromList &event)
|
||||||
{
|
{
|
||||||
QString list = QString::fromStdString(event.list_name());
|
QString list = QString::fromStdString(event.list_name());
|
||||||
QString user = QString::fromStdString(event.user_name());
|
QString user = QString::fromStdString(event.user_name());
|
||||||
UserList *userList = 0;
|
UserListWidget *userList = 0;
|
||||||
if (list == "buddy")
|
if (list == "buddy")
|
||||||
userList = buddyList;
|
userList = buddyList;
|
||||||
else if (list == "ignore")
|
else if (list == "ignore")
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include "tab.h"
|
#include "tab.h"
|
||||||
|
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
class UserList;
|
class UserListWidget;
|
||||||
class UserInfoBox;
|
class UserInfoBox;
|
||||||
class LineEditUnfocusable;
|
class LineEditUnfocusable;
|
||||||
|
|
||||||
|
|
@ -37,9 +37,9 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
UserList *allUsersList;
|
UserListWidget *allUsersList;
|
||||||
UserList *buddyList;
|
UserListWidget *buddyList;
|
||||||
UserList *ignoreList;
|
UserListWidget *ignoreList;
|
||||||
UserInfoBox *userInfoBox;
|
UserInfoBox *userInfoBox;
|
||||||
LineEditUnfocusable *addBuddyEdit;
|
LineEditUnfocusable *addBuddyEdit;
|
||||||
LineEditUnfocusable *addIgnoreEdit;
|
LineEditUnfocusable *addIgnoreEdit;
|
||||||
|
|
@ -52,15 +52,15 @@ public:
|
||||||
{
|
{
|
||||||
return tr("Account");
|
return tr("Account");
|
||||||
}
|
}
|
||||||
const UserList *getAllUsersList() const
|
const UserListWidget *getAllUsersList() const
|
||||||
{
|
{
|
||||||
return allUsersList;
|
return allUsersList;
|
||||||
}
|
}
|
||||||
const UserList *getBuddyList() const
|
const UserListWidget *getBuddyList() const
|
||||||
{
|
{
|
||||||
return buddyList;
|
return buddyList;
|
||||||
}
|
}
|
||||||
const UserList *getIgnoreList() const
|
const UserListWidget *getIgnoreList() const
|
||||||
{
|
{
|
||||||
return ignoreList;
|
return ignoreList;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include "../../main.h"
|
#include "../../main.h"
|
||||||
#include "../../server/chat_view/chat_view.h"
|
#include "../../server/chat_view/chat_view.h"
|
||||||
#include "../../server/pending_command.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 "../../settings/cache_settings.h"
|
||||||
#include "get_pb_extension.h"
|
#include "get_pb_extension.h"
|
||||||
#include "pb/event_join_room.pb.h"
|
#include "pb/event_join_room.pb.h"
|
||||||
|
|
@ -47,7 +47,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
|
||||||
QMap<int, GameTypeMap> tempMap;
|
QMap<int, GameTypeMap> tempMap;
|
||||||
tempMap.insert(info.room_id(), gameTypes);
|
tempMap.insert(info.room_id(), gameTypes);
|
||||||
gameSelector = new GameSelector(client, tabSupervisor, this, QMap<int, QString>(), tempMap, true, true);
|
gameSelector = new GameSelector(client, tabSupervisor, this, QMap<int, QString>(), 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,
|
connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this,
|
||||||
SIGNAL(openMessageDialog(const QString &, bool)));
|
SIGNAL(openMessageDialog(const QString &, bool)));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class Message;
|
||||||
}
|
}
|
||||||
} // namespace google
|
} // namespace google
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
class UserList;
|
class UserListWidget;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class ChatView;
|
class ChatView;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
|
@ -48,7 +48,7 @@ private:
|
||||||
QMap<int, QString> gameTypes;
|
QMap<int, QString> gameTypes;
|
||||||
|
|
||||||
GameSelector *gameSelector;
|
GameSelector *gameSelector;
|
||||||
UserList *userList;
|
UserListWidget *userList;
|
||||||
ChatView *chatView;
|
ChatView *chatView;
|
||||||
QLabel *sayLabel;
|
QLabel *sayLabel;
|
||||||
LineEditCompleter *sayEdit;
|
LineEditCompleter *sayEdit;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "../../client/game_logic/abstract_client.h"
|
#include "../../client/game_logic/abstract_client.h"
|
||||||
#include "../../server/pending_command.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_list_rooms.pb.h"
|
||||||
#include "pb/event_server_message.pb.h"
|
#include "pb/event_server_message.pb.h"
|
||||||
#include "pb/response_join_room.pb.h"
|
#include "pb/response_join_room.pb.h"
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class UserList;
|
class UserListWidget;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
|
||||||
class Event_ListRooms;
|
class Event_ListRooms;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "../../client/game_logic/abstract_client.h"
|
#include "../../client/game_logic/abstract_client.h"
|
||||||
#include "../../main.h"
|
#include "../../main.h"
|
||||||
#include "../../server/user/user_list.h"
|
#include "../../server/user/user_list_widget.h"
|
||||||
#include "../../settings/cache_settings.h"
|
#include "../../settings/cache_settings.h"
|
||||||
#include "../ui/pixel_map_generator.h"
|
#include "../ui/pixel_map_generator.h"
|
||||||
#include "pb/event_game_joined.pb.h"
|
#include "pb/event_game_joined.pb.h"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "../client/tabs/tab_account.h"
|
#include "../client/tabs/tab_account.h"
|
||||||
#include "../client/ui/pixel_map_generator.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 "../settings/cache_settings.h"
|
||||||
#include "pb/serverinfo_game.pb.h"
|
#include "pb/serverinfo_game.pb.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include "../../client/tabs/tab_supervisor.h"
|
#include "../../client/tabs/tab_supervisor.h"
|
||||||
#include "../../client/ui/pixel_map_generator.h"
|
#include "../../client/ui/pixel_map_generator.h"
|
||||||
#include "../../server/user/user_context_menu.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/command_kick_from_game.pb.h"
|
||||||
#include "pb/serverinfo_playerproperties.pb.h"
|
#include "pb/serverinfo_playerproperties.pb.h"
|
||||||
#include "pb/session_commands.pb.h"
|
#include "pb/session_commands.pb.h"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define CHATVIEW_H
|
#define CHATVIEW_H
|
||||||
|
|
||||||
#include "../../client/tabs/tab_supervisor.h"
|
#include "../../client/tabs/tab_supervisor.h"
|
||||||
#include "../user/user_list.h"
|
#include "../user/user_list_widget.h"
|
||||||
#include "room_message_type.h"
|
#include "room_message_type.h"
|
||||||
#include "user_level.h"
|
#include "user_level.h"
|
||||||
#include "user_list_proxy.h"
|
#include "user_list_proxy.h"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
#include "pb/response_warn_list.pb.h"
|
#include "pb/response_warn_list.pb.h"
|
||||||
#include "pb/session_commands.pb.h"
|
#include "pb/session_commands.pb.h"
|
||||||
#include "user_info_box.h"
|
#include "user_info_box.h"
|
||||||
#include "user_list.h"
|
#include "user_list_widget.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "user_list.h"
|
#include "user_list_widget.h"
|
||||||
|
|
||||||
#include "../../client/game_logic/abstract_client.h"
|
#include "../../client/game_logic/abstract_client.h"
|
||||||
#include "../../client/tabs/tab_account.h"
|
#include "../../client/tabs/tab_account.h"
|
||||||
|
|
@ -323,9 +323,9 @@ bool UserListItemDelegate::editorEvent(QEvent *event,
|
||||||
QMouseEvent *const mouseEvent = static_cast<QMouseEvent *>(event);
|
QMouseEvent *const mouseEvent = static_cast<QMouseEvent *>(event);
|
||||||
if (mouseEvent->button() == Qt::RightButton) {
|
if (mouseEvent->button() == Qt::RightButton) {
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
static_cast<UserList *>(parent())->showContextMenu(mouseEvent->globalPosition().toPoint(), index);
|
static_cast<UserListWidget *>(parent())->showContextMenu(mouseEvent->globalPosition().toPoint(), index);
|
||||||
#else
|
#else
|
||||||
static_cast<UserList *>(parent())->showContextMenu(mouseEvent->globalPos(), index);
|
static_cast<UserListWidget *>(parent())->showContextMenu(mouseEvent->globalPos(), index);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
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;
|
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)
|
: QGroupBox(parent), tabSupervisor(_tabSupervisor), client(_client), type(_type), onlineCount(0)
|
||||||
{
|
{
|
||||||
itemDelegate = new UserListItemDelegate(this);
|
itemDelegate = new UserListItemDelegate(this);
|
||||||
|
|
@ -395,7 +398,7 @@ UserList::UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserL
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserList::retranslateUi()
|
void UserListWidget::retranslateUi()
|
||||||
{
|
{
|
||||||
userContextMenu->retranslateUi();
|
userContextMenu->retranslateUi();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
@ -415,7 +418,7 @@ void UserList::retranslateUi()
|
||||||
updateCount();
|
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());
|
const QString userName = QString::fromStdString(user.name());
|
||||||
UserListTWI *item = users.value(userName);
|
UserListTWI *item = users.value(userName);
|
||||||
|
|
@ -432,7 +435,7 @@ void UserList::processUserInfo(const ServerInfo_User &user, bool online)
|
||||||
item->setOnline(online);
|
item->setOnline(online);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserList::deleteUser(const QString &userName)
|
bool UserListWidget::deleteUser(const QString &userName)
|
||||||
{
|
{
|
||||||
UserListTWI *twi = users.value(userName);
|
UserListTWI *twi = users.value(userName);
|
||||||
if (twi) {
|
if (twi) {
|
||||||
|
|
@ -448,7 +451,7 @@ bool UserList::deleteUser(const QString &userName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserList::setUserOnline(const QString &userName, bool online)
|
void UserListWidget::setUserOnline(const QString &userName, bool online)
|
||||||
{
|
{
|
||||||
UserListTWI *twi = users.value(userName);
|
UserListTWI *twi = users.value(userName);
|
||||||
if (!twi)
|
if (!twi)
|
||||||
|
|
@ -462,7 +465,7 @@ void UserList::setUserOnline(const QString &userName, bool online)
|
||||||
updateCount();
|
updateCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserList::updateCount()
|
void UserListWidget::updateCount()
|
||||||
{
|
{
|
||||||
QString str = titleStr;
|
QString str = titleStr;
|
||||||
if ((type == BuddyList) || (type == IgnoreList))
|
if ((type == BuddyList) || (type == IgnoreList))
|
||||||
|
|
@ -470,12 +473,12 @@ void UserList::updateCount()
|
||||||
setTitle(str.arg(userTree->topLevelItemCount()));
|
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);
|
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<UserListTWI *>(userTree->topLevelItem(index.row()))->getUserInfo();
|
const ServerInfo_User &userInfo = static_cast<UserListTWI *>(userTree->topLevelItem(index.row()))->getUserInfo();
|
||||||
bool online = index.sibling(index.row(), 0).data(Qt::UserRole + 1).toBool();
|
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);
|
UserLevelFlags(userInfo.user_level()), online);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserList::sortItems()
|
void UserListWidget::sortItems()
|
||||||
{
|
{
|
||||||
userTree->sortItems(1, Qt::AscendingOrder);
|
userTree->sortItems(1, Qt::AscendingOrder);
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +111,7 @@ public:
|
||||||
bool operator<(const QTreeWidgetItem &other) const;
|
bool operator<(const QTreeWidgetItem &other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UserList : public QGroupBox
|
class UserListWidget : public QGroupBox
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
@ -144,7 +144,10 @@ signals:
|
||||||
void removeIgnore(const QString &userName);
|
void removeIgnore(const QString &userName);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserListType _type, QWidget *parent = nullptr);
|
UserListWidget(TabSupervisor *_tabSupervisor,
|
||||||
|
AbstractClient *_client,
|
||||||
|
UserListType _type,
|
||||||
|
QWidget *parent = nullptr);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void processUserInfo(const ServerInfo_User &user, bool online);
|
void processUserInfo(const ServerInfo_User &user, bool online);
|
||||||
bool deleteUser(const QString &userName);
|
bool deleteUser(const QString &userName);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue