Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform 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
5#include "game_type_map.h"
6
7#include <QGroupBox>
8#include <libcockatrice/protocol/pb/commands.pb.h>
9#include <libcockatrice/protocol/pb/event_add_to_list.pb.h>
10#include <libcockatrice/protocol/pb/event_remove_from_list.pb.h>
11
12class QTreeView;
13class GamesModel;
14class GamesProxyModel;
15class QPushButton;
16class QCheckBox;
17class QLabel;
18class AbstractClient;
19class TabSupervisor;
20class TabRoom;
21class ServerInfo_Game;
22class Response;
23
33class GameSelector : public QGroupBox
34{
35 Q_OBJECT
36private slots:
42 void actSetFilter();
43
49 void actClearFilter();
50
54 void actCreate();
55
59 void actJoin();
63 void actJoinAsJudge();
64
68 void actJoinAsSpectator();
70
75 void customContextMenu(const QPoint &point);
76
84 void actSelectedGameChanged(const QModelIndex &current, const QModelIndex &previous);
85
92 void checkResponse(const Response &response);
93
98 void ignoreListReceived(const QList<ServerInfo_User> &_ignoreList);
99
104 void processAddToListEvent(const Event_AddToList &event);
105
110 void processRemoveFromListEvent(const Event_RemoveFromList &event);
111
112signals:
117 void gameJoined(int gameId);
118
119private:
123
124 QTreeView *gameListView;
127
129
130 QPushButton *filterButton;
131 QPushButton *clearFilterButton;
132 QPushButton *createButton;
133 QPushButton *joinButton;
134 QPushButton *joinAsJudgeButton;
135 QPushButton *spectateButton;
137
138 const bool showFilters;
140
146 void updateTitle();
147
151 void disableButtons();
152
156 void enableButtons();
157
162 void enableButtonsForIndex(const QModelIndex &current);
163
171 void joinGame(bool asSpectator = false, bool asJudge = false);
172
173public:
186 TabSupervisor *_tabSupervisor,
187 TabRoom *_room,
188 const QMap<int, QString> &_rooms,
189 const QMap<int, GameTypeMap> &_gameTypes,
190 const bool restoresettings,
191 const bool _showfilters,
192 QWidget *parent = nullptr);
193
197 void retranslateUi();
198
203 void processGameInfo(const ServerInfo_Game &info);
204};
205
206#endif
Definition abstract_client.h:51
Definition game_selector_quick_filter_toolbar.h:12
void enableButtons()
Enables buttons for the currently selected game.
Definition game_selector.cpp:380
AbstractClient * client
Definition game_selector.h:120
void actJoinAsSpectator()
Joins the currently selected game as a spectator.
Definition game_selector.cpp:271
QPushButton * createButton
Definition game_selector.h:132
QPushButton * joinAsJudgeSpectatorButton
Definition game_selector.h:136
void actSelectedGameChanged(const QModelIndex &current, const QModelIndex &previous)
Slot called when the selected game changes.
Definition game_selector.cpp:421
void actJoin()
Joins the currently selected game as a player.
Definition game_selector.cpp:257
void retranslateUi()
Updates UI text for translation/localization.
Definition game_selector.cpp:401
const bool showFilters
Definition game_selector.h:138
GameSelectorQuickFilterToolBar * quickFilterToolBar
Definition game_selector.h:128
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:25
void ignoreListReceived(const QList< ServerInfo_User > &_ignoreList)
Refreshes the game list when the ignore list is received from the server.
Definition game_selector.cpp:148
GamesProxyModel * gameListProxyModel
Definition game_selector.h:126
QPushButton * joinAsJudgeButton
Definition game_selector.h:134
void actJoinAsJudge()
Joins the currently selected game as a judge.
Definition game_selector.cpp:262
void actSetFilter()
Opens a dialog to set filters for the game list.
Definition game_selector.cpp:169
TabSupervisor * tabSupervisor
Definition game_selector.h:121
void actClearFilter()
Clears all filters applied to the game list.
Definition game_selector.cpp:190
QPushButton * joinButton
Definition game_selector.h:133
GameTypeMap gameTypeMap
Definition game_selector.h:139
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:153
GamesModel * gameListModel
Definition game_selector.h:125
QPushButton * spectateButton
Definition game_selector.h:135
void customContextMenu(const QPoint &point)
Shows the custom context menu for a game when right-clicked.
Definition game_selector.cpp:285
void disableButtons()
Disables create/join/spectate buttons.
Definition game_selector.cpp:371
void processGameInfo(const ServerInfo_Game &info)
Updates or adds a game entry in the list.
Definition game_selector.cpp:415
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:161
TabRoom * room
Definition game_selector.h:122
void enableButtonsForIndex(const QModelIndex &current)
Enables buttons for a specific game index.
Definition game_selector.cpp:389
void actCreate()
Opens the dialog to create a new game in the current room.
Definition game_selector.cpp:200
QPushButton * clearFilterButton
Definition game_selector.h:131
void updateTitle()
Updates the widget title to reflect the current number of displayed games.
Definition game_selector.cpp:426
void joinGame(bool asSpectator=false, bool asJudge=false)
Performs the join or spectate action for the currently selected game.
Definition game_selector.cpp:327
QPushButton * filterButton
Definition game_selector.h:130
QTreeView * gameListView
Definition game_selector.h:124
void checkResponse(const Response &response)
Processes server responses for join or spectate commands.
Definition game_selector.cpp:212
void actJoinAsJudgeSpectator()
Definition game_selector.cpp:276
Model storing all available games for display in a QTreeView or QTableView.
Definition games_model.h:23
Proxy model for filtering and sorting the GamesModel based on user preferences.
Definition games_model.h:112
Definition tab_room.h:49
Definition tab_supervisor.h:83
QMap< int, QString > GameTypeMap
Definition game_type_map.h:6