moved the user list context menu to a separate class to avoid redundant code

This commit is contained in:
Max-Wilhelm Bruker 2012-04-07 23:05:45 +02:00
parent ae19d3dc4b
commit f9e0b6fe9e
10 changed files with 251 additions and 250 deletions

View file

@ -63,6 +63,7 @@ SET(cockatrice_SOURCES
src/chatview.cpp
src/userlist.cpp
src/userinfobox.cpp
src/user_context_menu.cpp
src/remotedecklist_treewidget.cpp
src/remotereplaylist_treewidget.cpp
src/deckview.cpp
@ -135,6 +136,7 @@ SET(cockatrice_HEADERS
src/chatview.h
src/userlist.h
src/userinfobox.h
src/user_context_menu.h
src/remotedecklist_treewidget.h
src/remotereplaylist_treewidget.h
src/deckview.h

View file

@ -98,10 +98,9 @@ GamesProxyModel::GamesProxyModel(QObject *parent, ServerInfo_User *_ownUser)
{
setDynamicSortFilter(true);
}
#include <QDebug>
void GamesProxyModel::setUnavailableGamesVisible(bool _unavailableGamesVisible)
{
qDebug() << "setting to" << _unavailableGamesVisible;
unavailableGamesVisible = _unavailableGamesVisible;
invalidateFilter();
}

View file

@ -7,6 +7,7 @@
#include "tab_userlists.h"
#include "userlist.h"
#include "userinfobox.h"
#include "user_context_menu.h"
#include <QMouseEvent>
#include <QAction>
#include <QMenu>
@ -60,7 +61,11 @@ PlayerListWidget::PlayerListWidget(TabSupervisor *_tabSupervisor, AbstractClient
if (tabSupervisor) {
itemDelegate = new PlayerListItemDelegate(this);
setItemDelegate(itemDelegate);
}
userContextMenu = new UserContextMenu(tabSupervisor, this, game);
connect(userContextMenu, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
} else
userContextMenu = 0;
setMinimumHeight(60);
setIconSize(QSize(20, 15));
@ -162,93 +167,12 @@ void PlayerListWidget::setGameStarted(bool _gameStarted, bool resuming)
void PlayerListWidget::showContextMenu(const QPoint &pos, const QModelIndex &index)
{
if (!userContextMenu)
return;
const QString &userName = index.sibling(index.row(), 4).data(Qt::UserRole).toString();
int playerId = index.sibling(index.row(), 4).data(Qt::UserRole + 1).toInt();
ServerInfo_User::UserLevelFlags userLevel = static_cast<ServerInfo_User::UserLevelFlags>(index.sibling(index.row(), 3).data(Qt::UserRole).toInt());
QAction *aUserName = new QAction(userName, this);
aUserName->setEnabled(false);
QAction *aDetails = new QAction(tr("User &details"), this);
QAction *aChat = new QAction(tr("Direct &chat"), this);
QAction *aAddToBuddyList = new QAction(tr("Add to &buddy list"), this);
QAction *aRemoveFromBuddyList = new QAction(tr("Remove from &buddy list"), this);
QAction *aAddToIgnoreList = new QAction(tr("Add to &ignore list"), this);
QAction *aRemoveFromIgnoreList = new QAction(tr("Remove from &ignore list"), this);
QAction *aKick = new QAction(tr("Kick from &game"), this);
QMenu *menu = new QMenu(this);
menu->addAction(aUserName);
menu->addSeparator();
menu->addAction(aDetails);
menu->addAction(aChat);
if ((userLevel & ServerInfo_User::IsRegistered) && (tabSupervisor->getUserLevel() & ServerInfo_User::IsRegistered)) {
menu->addSeparator();
if (tabSupervisor->getUserListsTab()->getBuddyList()->getUsers().contains(userName))
menu->addAction(aRemoveFromBuddyList);
else
menu->addAction(aAddToBuddyList);
if (tabSupervisor->getUserListsTab()->getIgnoreList()->getUsers().contains(userName))
menu->addAction(aRemoveFromIgnoreList);
else
menu->addAction(aAddToIgnoreList);
}
if (game->isHost() || !game->getTabSupervisor()->getAdminLocked()) {
menu->addSeparator();
menu->addAction(aKick);
}
if (userName == QString::fromStdString(game->getTabSupervisor()->getUserInfo()->name())) {
aChat->setEnabled(false);
aAddToBuddyList->setEnabled(false);
aRemoveFromBuddyList->setEnabled(false);
aAddToIgnoreList->setEnabled(false);
aRemoveFromIgnoreList->setEnabled(false);
aKick->setEnabled(false);
}
QAction *actionClicked = menu->exec(pos);
if (actionClicked == aDetails) {
UserInfoBox *infoWidget = new UserInfoBox(client, true, this, Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
infoWidget->updateInfo(userName);
} else if (actionClicked == aChat)
emit openMessageDialog(userName, true);
else if (actionClicked == aAddToBuddyList) {
Command_AddToList cmd;
cmd.set_list("buddy");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aRemoveFromBuddyList) {
Command_RemoveFromList cmd;
cmd.set_list("buddy");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aAddToIgnoreList) {
Command_AddToList cmd;
cmd.set_list("ignore");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aRemoveFromIgnoreList) {
Command_RemoveFromList cmd;
cmd.set_list("ignore");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aKick) {
Command_KickFromGame cmd;
cmd.set_player_id(playerId);
game->sendGameCommand(cmd);
}
delete menu;
delete aUserName;
delete aDetails;
delete aChat;
delete aAddToBuddyList;
delete aRemoveFromBuddyList;
delete aAddToIgnoreList;
delete aRemoveFromIgnoreList;
delete aKick;
userContextMenu->showContextMenu(pos, userName, userLevel, playerId);
}

View file

@ -10,6 +10,7 @@ class ServerInfo_PlayerProperties;
class TabSupervisor;
class AbstractClient;
class TabGame;
class UserContextMenu;
class PlayerListItemDelegate : public QStyledItemDelegate {
public:
@ -31,6 +32,7 @@ private:
TabSupervisor *tabSupervisor;
AbstractClient *client;
TabGame *game;
UserContextMenu *userContextMenu;
QIcon readyIcon, notReadyIcon, concededIcon, playerIcon, spectatorIcon, lockIcon;
bool gameStarted;
signals:

View file

@ -113,6 +113,11 @@ void TabSupervisor::retranslateUi()
}
}
AbstractClient *TabSupervisor::getClient() const
{
return localClients.isEmpty() ? client : localClients.first();
}
int TabSupervisor::myAddTab(Tab *tab)
{
connect(tab, SIGNAL(userEvent(bool)), this, SLOT(tabUserEvent(bool)));
@ -428,8 +433,3 @@ bool TabSupervisor::getAdminLocked() const
return true;
return tabAdmin->getLocked();
}
int TabSupervisor::getUserLevel() const
{
return userInfo->user_level();
}

View file

@ -64,9 +64,9 @@ public:
int getGameCount() const { return gameTabs.size(); }
TabUserLists *getUserListsTab() const { return tabUserLists; }
ServerInfo_User *getUserInfo() const { return userInfo; }
AbstractClient *getClient() const;
const QMap<int, TabRoom *> &getRoomTabs() const { return roomTabs; }
bool getAdminLocked() const;
int getUserLevel() const;
signals:
void setMenu(QMenu *menu);
void localGameEnded();

View file

@ -0,0 +1,183 @@
#include <QAction>
#include <QMenu>
#include "user_context_menu.h"
#include "tab_supervisor.h"
#include "tab_userlists.h"
#include "tab_game.h"
#include "userlist.h"
#include "abstractclient.h"
#include "userinfobox.h"
#include "gameselector.h"
#include "pending_command.h"
#include "pb/commands.pb.h"
#include "pb/session_commands.pb.h"
#include "pb/moderator_commands.pb.h"
#include "pb/command_kick_from_game.pb.h"
#include "pb/response_get_games_of_user.pb.h"
#include "pb/response_get_user_info.pb.h"
UserContextMenu::UserContextMenu(TabSupervisor *_tabSupervisor, QWidget *parent, TabGame *_game)
: QObject(parent), client(_tabSupervisor->getClient()), tabSupervisor(_tabSupervisor), game(_game)
{
aUserName = new QAction(QString(), this);
aUserName->setEnabled(false);
aDetails = new QAction(tr("User &details"), this);
aChat = new QAction(tr("Direct &chat"), this);
aShowGames = new QAction(tr("Show this user's &games"), this);
aAddToBuddyList = new QAction(tr("Add to &buddy list"), this);
aRemoveFromBuddyList = new QAction(tr("Remove from &buddy list"), this);
aAddToIgnoreList = new QAction(tr("Add to &ignore list"), this);
aRemoveFromIgnoreList = new QAction(tr("Remove from &ignore list"), this);
aKick = new QAction(tr("Kick from &game"), this);
aBan = new QAction(tr("Ban from &server"), this);
}
void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer)
{
const Response_GetGamesOfUser &response = resp.GetExtension(Response_GetGamesOfUser::ext);
const Command_GetGamesOfUser &cmd = commandContainer.session_command(0).GetExtension(Command_GetGamesOfUser::ext);
QMap<int, GameTypeMap> gameTypeMap;
QMap<int, QString> roomMap;
const int roomListSize = response.room_list_size();
for (int i = 0; i < roomListSize; ++i) {
const ServerInfo_Room &roomInfo = response.room_list(i);
roomMap.insert(roomInfo.room_id(), QString::fromStdString(roomInfo.name()));
GameTypeMap tempMap;
const int gameTypeListSize = roomInfo.gametype_list_size();
for (int j = 0; j < gameTypeListSize; ++j) {
const ServerInfo_GameType &gameTypeInfo = roomInfo.gametype_list(j);
tempMap.insert(gameTypeInfo.game_type_id(), QString::fromStdString(gameTypeInfo.description()));
}
gameTypeMap.insert(roomInfo.room_id(), tempMap);
}
GameSelector *selector = new GameSelector(client, tabSupervisor, 0, roomMap, gameTypeMap);
const int gameListSize = response.game_list_size();
for (int i = 0; i < gameListSize; ++i)
selector->processGameInfo(response.game_list(i));
selector->setWindowTitle(tr("%1's games").arg(QString::fromStdString(cmd.user_name())));
selector->setAttribute(Qt::WA_DeleteOnClose);
selector->show();
}
void UserContextMenu::banUser_processUserInfoResponse(const Response &r)
{
const Response_GetUserInfo &response = r.GetExtension(Response_GetUserInfo::ext);
// The dialog needs to be non-modal in order to not block the event queue of the client.
BanDialog *dlg = new BanDialog(response.user_info(), static_cast<QWidget *>(parent()));
connect(dlg, SIGNAL(accepted()), this, SLOT(banUser_dialogFinished()));
dlg->show();
}
void UserContextMenu::banUser_dialogFinished()
{
BanDialog *dlg = static_cast<BanDialog *>(sender());
Command_BanFromServer cmd;
cmd.set_user_name(dlg->getBanName().toStdString());
cmd.set_address(dlg->getBanIP().toStdString());
cmd.set_minutes(dlg->getMinutes());
cmd.set_reason(dlg->getReason().toStdString());
cmd.set_visible_reason(dlg->getVisibleReason().toStdString());
client->sendCommand(client->prepareModeratorCommand(cmd));
}
void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName, ServerInfo_User::UserLevelFlags userLevel, int playerId)
{
aUserName->setText(userName);
QMenu *menu = new QMenu(static_cast<QWidget *>(parent()));
menu->addAction(aUserName);
menu->addSeparator();
menu->addAction(aDetails);
menu->addAction(aShowGames);
menu->addAction(aChat);
if ((userLevel & ServerInfo_User::IsRegistered) && (tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsRegistered)) {
menu->addSeparator();
if (tabSupervisor->getUserListsTab()->getBuddyList()->getUsers().contains(userName))
menu->addAction(aRemoveFromBuddyList);
else
menu->addAction(aAddToBuddyList);
if (tabSupervisor->getUserListsTab()->getIgnoreList()->getUsers().contains(userName))
menu->addAction(aRemoveFromIgnoreList);
else
menu->addAction(aAddToIgnoreList);
}
if (game && (game->isHost() || !tabSupervisor->getAdminLocked())) {
menu->addSeparator();
menu->addAction(aKick);
}
if (!tabSupervisor->getAdminLocked()) {
menu->addSeparator();
menu->addAction(aBan);
}
bool anotherUser = userName != QString::fromStdString(tabSupervisor->getUserInfo()->name());
aChat->setEnabled(anotherUser);
aShowGames->setEnabled(anotherUser);
aAddToBuddyList->setEnabled(anotherUser);
aRemoveFromBuddyList->setEnabled(anotherUser);
aAddToIgnoreList->setEnabled(anotherUser);
aRemoveFromIgnoreList->setEnabled(anotherUser);
aKick->setEnabled(anotherUser);
aBan->setEnabled(anotherUser);
QAction *actionClicked = menu->exec(pos);
if (actionClicked == aDetails) {
UserInfoBox *infoWidget = new UserInfoBox(client, true, static_cast<QWidget *>(parent()), Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
infoWidget->updateInfo(userName);
} else if (actionClicked == aChat)
emit openMessageDialog(userName, true);
else if (actionClicked == aShowGames) {
Command_GetGamesOfUser cmd;
cmd.set_user_name(userName.toStdString());
PendingCommand *pend = client->prepareSessionCommand(cmd);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(gamesOfUserReceived(Response, CommandContainer)));
client->sendCommand(pend);
} else if (actionClicked == aAddToBuddyList) {
Command_AddToList cmd;
cmd.set_list("buddy");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aRemoveFromBuddyList) {
Command_RemoveFromList cmd;
cmd.set_list("buddy");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aAddToIgnoreList) {
Command_AddToList cmd;
cmd.set_list("ignore");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aRemoveFromIgnoreList) {
Command_RemoveFromList cmd;
cmd.set_list("ignore");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aKick) {
Command_KickFromGame cmd;
cmd.set_player_id(playerId);
game->sendGameCommand(cmd);
} else if (actionClicked == aBan) {
Command_GetUserInfo cmd;
cmd.set_user_name(userName.toStdString());
PendingCommand *pend = client->prepareSessionCommand(cmd);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response)));
client->sendCommand(pend);
}
delete menu;
}

View file

@ -0,0 +1,41 @@
#ifndef USER_CONTEXT_MENU_H
#define USER_CONTEXT_MENU_H
#include <QObject>
#include "pb/serverinfo_user.pb.h"
class QAction;
class TabSupervisor;
class TabGame;
class QPoint;
class CommandContainer;
class Response;
class AbstractClient;
class UserContextMenu : public QObject {
Q_OBJECT
private:
AbstractClient *client;
TabSupervisor *tabSupervisor;
TabGame *game;
QAction *aUserName;
QAction *aDetails;
QAction *aShowGames;
QAction *aChat;
QAction *aAddToBuddyList, *aRemoveFromBuddyList;
QAction *aAddToIgnoreList, *aRemoveFromIgnoreList;
QAction *aKick;
QAction *aBan;
signals:
void openMessageDialog(const QString &userName, bool focus);
private slots:
void banUser_processUserInfoResponse(const Response &resp);
void banUser_dialogFinished();
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
public:
UserContextMenu(TabSupervisor *_tabSupervisor, QWidget *_parent, TabGame *_game = 0);
void showContextMenu(const QPoint &pos, const QString &userName, ServerInfo_User::UserLevelFlags userLevel, int playerId = -1);
};
#endif

View file

@ -4,6 +4,7 @@
#include "abstractclient.h"
#include "pixmapgenerator.h"
#include "userinfobox.h"
#include "user_context_menu.h"
#include "gameselector.h"
#include <QHeaderView>
#include <QVBoxLayout>
@ -202,6 +203,8 @@ UserList::UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserL
: QGroupBox(parent), tabSupervisor(_tabSupervisor), client(_client), type(_type), onlineCount(0)
{
itemDelegate = new UserListItemDelegate(this);
userContextMenu = new UserContextMenu(tabSupervisor, this);
connect(userContextMenu, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
userTree = new QTreeWidget;
userTree->setColumnCount(3);
@ -307,165 +310,13 @@ void UserList::userClicked(QTreeWidgetItem *item, int /*column*/)
emit openMessageDialog(item->data(2, Qt::UserRole).toString(), true);
}
void UserList::gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer)
{
const Response_GetGamesOfUser &response = resp.GetExtension(Response_GetGamesOfUser::ext);
const Command_GetGamesOfUser &cmd = commandContainer.session_command(0).GetExtension(Command_GetGamesOfUser::ext);
QMap<int, GameTypeMap> gameTypeMap;
QMap<int, QString> roomMap;
const int roomListSize = response.room_list_size();
for (int i = 0; i < roomListSize; ++i) {
const ServerInfo_Room &roomInfo = response.room_list(i);
roomMap.insert(roomInfo.room_id(), QString::fromStdString(roomInfo.name()));
GameTypeMap tempMap;
const int gameTypeListSize = roomInfo.gametype_list_size();
for (int j = 0; j < gameTypeListSize; ++j) {
const ServerInfo_GameType &gameTypeInfo = roomInfo.gametype_list(j);
tempMap.insert(gameTypeInfo.game_type_id(), QString::fromStdString(gameTypeInfo.description()));
}
gameTypeMap.insert(roomInfo.room_id(), tempMap);
}
GameSelector *selector = new GameSelector(client, tabSupervisor, 0, roomMap, gameTypeMap);
const int gameListSize = response.game_list_size();
for (int i = 0; i < gameListSize; ++i)
selector->processGameInfo(response.game_list(i));
selector->setWindowTitle(tr("%1's games").arg(QString::fromStdString(cmd.user_name())));
selector->setAttribute(Qt::WA_DeleteOnClose);
selector->show();
}
void UserList::banUser_processUserInfoResponse(const Response &r)
{
const Response_GetUserInfo &response = r.GetExtension(Response_GetUserInfo::ext);
// The dialog needs to be non-modal in order to not block the event queue of the client.
BanDialog *dlg = new BanDialog(response.user_info(), this);
connect(dlg, SIGNAL(accepted()), this, SLOT(banUser_dialogFinished()));
dlg->show();
}
void UserList::banUser_dialogFinished()
{
BanDialog *dlg = static_cast<BanDialog *>(sender());
Command_BanFromServer cmd;
cmd.set_user_name(dlg->getBanName().toStdString());
cmd.set_address(dlg->getBanIP().toStdString());
cmd.set_minutes(dlg->getMinutes());
cmd.set_reason(dlg->getReason().toStdString());
cmd.set_visible_reason(dlg->getVisibleReason().toStdString());
client->sendCommand(client->prepareModeratorCommand(cmd));
}
void UserList::showContextMenu(const QPoint &pos, const QModelIndex &index)
{
UserListTWI *twi = static_cast<UserListTWI *>(userTree->topLevelItem(index.row()));
const QString &userName = twi->getUserName();
ServerInfo_User::UserLevelFlags userLevel = static_cast<ServerInfo_User::UserLevelFlags>(twi->getUserLevel());
QAction *aUserName = new QAction(userName, this);
aUserName->setEnabled(false);
QAction *aDetails = new QAction(tr("User &details"), this);
QAction *aChat = new QAction(tr("Direct &chat"), this);
QAction *aShowGames = new QAction(tr("Show this user's &games"), this);
QAction *aAddToBuddyList = new QAction(tr("Add to &buddy list"), this);
QAction *aRemoveFromBuddyList = new QAction(tr("Remove from &buddy list"), this);
QAction *aAddToIgnoreList = new QAction(tr("Add to &ignore list"), this);
QAction *aRemoveFromIgnoreList = new QAction(tr("Remove from &ignore list"), this);
QAction *aBan = new QAction(tr("Ban from &server"), this);
QMenu *menu = new QMenu(this);
menu->addAction(aUserName);
menu->addSeparator();
menu->addAction(aDetails);
menu->addAction(aShowGames);
menu->addAction(aChat);
if ((userLevel & ServerInfo_User::IsRegistered) && (tabSupervisor->getUserLevel() & ServerInfo_User::IsRegistered)) {
menu->addSeparator();
if (tabSupervisor->getUserListsTab()->getBuddyList()->getUsers().contains(userName))
menu->addAction(aRemoveFromBuddyList);
else
menu->addAction(aAddToBuddyList);
if (tabSupervisor->getUserListsTab()->getIgnoreList()->getUsers().contains(userName))
menu->addAction(aRemoveFromIgnoreList);
else
menu->addAction(aAddToIgnoreList);
}
if (!tabSupervisor->getAdminLocked()) {
menu->addSeparator();
menu->addAction(aBan);
}
if (userName == QString::fromStdString(tabSupervisor->getUserInfo()->name())) {
aChat->setEnabled(false);
aAddToBuddyList->setEnabled(false);
aRemoveFromBuddyList->setEnabled(false);
aAddToIgnoreList->setEnabled(false);
aRemoveFromIgnoreList->setEnabled(false);
aBan->setEnabled(false);
}
QAction *actionClicked = menu->exec(pos);
if (actionClicked == aDetails) {
UserInfoBox *infoWidget = new UserInfoBox(client, true, this, Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
infoWidget->updateInfo(userName);
} else if (actionClicked == aChat)
emit openMessageDialog(userName, true);
else if (actionClicked == aAddToBuddyList) {
Command_AddToList cmd;
cmd.set_list("buddy");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aRemoveFromBuddyList) {
Command_RemoveFromList cmd;
cmd.set_list("buddy");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aShowGames) {
Command_GetGamesOfUser cmd;
cmd.set_user_name(userName.toStdString());
PendingCommand *pend = client->prepareSessionCommand(cmd);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(gamesOfUserReceived(Response, CommandContainer)));
client->sendCommand(pend);
} else if (actionClicked == aAddToIgnoreList) {
Command_AddToList cmd;
cmd.set_list("ignore");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aRemoveFromIgnoreList) {
Command_RemoveFromList cmd;
cmd.set_list("ignore");
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
} else if (actionClicked == aBan) {
Command_GetUserInfo cmd;
cmd.set_user_name(userName.toStdString());
PendingCommand *pend = client->prepareSessionCommand(cmd);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response)));
client->sendCommand(pend);
}
delete menu;
delete aUserName;
delete aDetails;
delete aChat;
delete aAddToBuddyList;
delete aRemoveFromBuddyList;
delete aAddToIgnoreList;
delete aRemoveFromIgnoreList;
delete aBan;
userContextMenu->showContextMenu(pos, userName, userLevel);
}
void UserList::sortItems()

View file

@ -17,6 +17,7 @@ class QRadioButton;
class QPlainTextEdit;
class Response;
class CommandContainer;
class UserContextMenu;
class BanDialog : public QDialog {
Q_OBJECT
@ -64,15 +65,13 @@ private:
UserListType type;
QTreeWidget *userTree;
UserListItemDelegate *itemDelegate;
UserContextMenu *userContextMenu;
int onlineCount;
QString titleStr;
void updateCount();
void setUserOnline(QTreeWidgetItem *user, bool online);
private slots:
void userClicked(QTreeWidgetItem *item, int column);
void banUser_processUserInfoResponse(const Response &resp);
void banUser_dialogFinished();
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
signals:
void openMessageDialog(const QString &userName, bool focus);
void addBuddy(const QString &userName);