Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
game_selector.h
Go to the documentation of this file.
1#ifndef GAMESELECTOR_H
2#define GAMESELECTOR_H
3
4#include "game_type_map.h"
5
6#include <QGroupBox>
7#include <QTimer>
8#include <qtmetamacros.h>
9// IWYU pragma: keep
10// ServerInfo_User appears by value and inside QList in slot signatures, so the
11// moc-generated code needs the complete type.
12#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
13
14class QTreeView;
15class GamesModel;
16class GamesProxyModel;
17class QPushButton;
18class AbstractClient;
19class TabSupervisor;
20class TabRoom;
21class ServerInfo_Game;
22class Response;
23class Event_AddToList;
26class QModelIndex;
27class QPoint;
28class QString;
29class QWidget;
30class ServerInfo_User;
31template <class Key, class T> class QMap;
32template <typename T> class QList;
33
43class GameSelector : public QGroupBox
44{
45 Q_OBJECT
46private slots:
52 void actSetFilter();
54
60 void actClearFilter();
61
65 void actCreate();
66
70 void actJoin();
74 void actJoinAsJudge();
75
79 void actJoinAsSpectator();
81
86 void customContextMenu(const QPoint &point);
87
95 void actSelectedGameChanged(const QModelIndex &current, const QModelIndex &previous);
96
103 void checkResponse(const Response &response);
104
109 void ignoreListReceived(const QList<ServerInfo_User> &_ignoreList);
110
115 void processAddToListEvent(const Event_AddToList &event);
116
122
123signals:
128 void gameJoined(int gameId);
129
130private:
134
135 QTreeView *gameListView;
138
140
141 QPushButton *filterButton;
142 QPushButton *clearFilterButton;
143 QPushButton *createButton;
144 QPushButton *joinButton;
145 QPushButton *joinAsJudgeButton;
146 QPushButton *spectateButton;
148
149 const bool showFilters;
151
154
160 void updateTitle();
161
165 void disableButtons();
166
170 void enableButtons();
171
176 void enableButtonsForIndex(const QModelIndex &current);
177
185 void joinGame(bool asSpectator = false, bool asJudge = false);
186
196 void joinGame(const ServerInfo_Game &game, bool asSpectator = false, bool asJudge = false);
197
198public:
211 TabSupervisor *_tabSupervisor,
212 TabRoom *_room,
213 const QMap<int, QString> &_rooms,
214 const QMap<int, GameTypeMap> &_gameTypes,
215 const bool restoresettings,
216 const bool _showfilters,
217 QWidget *parent = nullptr);
218 ~GameSelector() override;
219
223 void retranslateUi();
224
229 void processGameInfo(const ServerInfo_Game &info);
239 bool joinGameById(int gameId, bool asSpectator = false);
240};
241
242#endif
Definition abstract_client.h:73
Definition game_selector_quick_filter_toolbar.h:19
void enableButtons()
Enables buttons for the currently selected game.
Definition game_selector.cpp:493
AbstractClient * client
Definition game_selector.h:131
void actJoinAsSpectator()
Joins the currently selected game as a spectator.
Definition game_selector.cpp:332
QPushButton * createButton
Definition game_selector.h:143
QPushButton * joinAsJudgeSpectatorButton
Definition game_selector.h:147
void actSelectedGameChanged(const QModelIndex &current, const QModelIndex &previous)
Slot called when the selected game changes.
Definition game_selector.cpp:537
void actJoin()
Joins the currently selected game as a player.
Definition game_selector.cpp:318
void retranslateUi()
Updates UI text for translation/localization.
Definition game_selector.cpp:516
const bool showFilters
Definition game_selector.h:149
GameSelectorQuickFilterToolBar * quickFilterToolBar
Definition game_selector.h:139
bool joinGameById(int gameId, bool asSpectator=false)
Finds a game by ID and joins or spectates it.
Definition game_selector.cpp:467
GameSelector(AbstractClient *_client, TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap< int, QString > &_rooms, const QMap< int, GameTypeMap > &_gameTypes, const bool restoresettings, const bool _showfilters, QWidget *parent=nullptr)
Constructs a GameSelector widget.
Definition game_selector.cpp:53
QTimer filterSaveDebounceTimer
Definition game_selector.h:152
void ignoreListReceived(const QList< ServerInfo_User > &_ignoreList)
Refreshes the game list when the ignore list is received from the server.
Definition game_selector.cpp:213
GamesProxyModel * gameListProxyModel
Definition game_selector.h:137
QPushButton * joinAsJudgeButton
Definition game_selector.h:145
void actJoinAsJudge()
Joins the currently selected game as a judge.
Definition game_selector.cpp:323
void actSetFilter()
Opens a dialog to set filters for the game list.
Definition game_selector.cpp:234
TabSupervisor * tabSupervisor
Definition game_selector.h:132
void actClearFilter()
Clears all filters applied to the game list.
Definition game_selector.cpp:253
QPushButton * joinButton
Definition game_selector.h:144
GameTypeMap gameTypeMap
Definition game_selector.h:150
void processAddToListEvent(const Event_AddToList &event)
Processes events where a user is added to a list (e.g., ignore or buddy).
Definition game_selector.cpp:218
void checkClearFilterButtonState()
Definition game_selector.cpp:248
GamesModel * gameListModel
Definition game_selector.h:136
QPushButton * spectateButton
Definition game_selector.h:146
void customContextMenu(const QPoint &point)
Shows the custom context menu for a game when right-clicked.
Definition game_selector.cpp:346
void disableButtons()
Disables create/join/spectate buttons.
Definition game_selector.cpp:483
void processGameInfo(const ServerInfo_Game &info)
Updates or adds a game entry in the list.
Definition game_selector.cpp:531
void gameJoined(int gameId)
Emitted when a game has been successfully joined.
void processRemoveFromListEvent(const Event_RemoveFromList &event)
Processes events where a user is removed from a list (e.g., ignore or buddy).
Definition game_selector.cpp:226
TabRoom * room
Definition game_selector.h:133
void enableButtonsForIndex(const QModelIndex &current)
Enables buttons for a specific game index.
Definition game_selector.cpp:503
void actCreate()
Opens the dialog to create a new game in the current room.
Definition game_selector.cpp:261
QPushButton * clearFilterButton
Definition game_selector.h:142
void updateTitle()
Updates the widget title to reflect the current number of displayed games.
Definition game_selector.cpp:542
void joinGame(bool asSpectator=false, bool asJudge=false)
Performs the join or spectate action for the currently selected game.
Definition game_selector.cpp:401
QPushButton * filterButton
Definition game_selector.h:141
QTreeView * gameListView
Definition game_selector.h:135
void checkResponse(const Response &response)
Processes server responses for join or spectate commands.
Definition game_selector.cpp:273
void actJoinAsJudgeSpectator()
Definition game_selector.cpp:337
Model storing all available games for display in a QTreeView or QTableView.
Definition games_model.h:29
Proxy model for filtering and sorting the GamesModel based on user preferences.
Definition games_model.h:118
Definition remote_connection_controller.h:20
Definition game.h:18
Definition tab_room.h:59
Definition tab_supervisor.h:92
QMap< int, QString > GameTypeMap
Definition game_type_map.h:6
Definition event_add_to_list.proto:4
Definition event_remove_from_list.proto:3
Definition response.proto:11
Definition serverinfo_game.proto:5
Definition serverinfo_user.proto:2