Cockatrice 2026-04-21-Development-2.11.0-beta.61
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
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();
44
50 void actClearFilter();
51
55 void actCreate();
56
60 void actJoin();
64 void actJoinAsJudge();
65
69 void actJoinAsSpectator();
71
76 void customContextMenu(const QPoint &point);
77
85 void actSelectedGameChanged(const QModelIndex &current, const QModelIndex &previous);
86
93 void checkResponse(const Response &response);
94
99 void ignoreListReceived(const QList<ServerInfo_User> &_ignoreList);
100
105 void processAddToListEvent(const Event_AddToList &event);
106
111 void processRemoveFromListEvent(const Event_RemoveFromList &event);
112
113signals:
118 void gameJoined(int gameId);
119
120private:
124
125 QTreeView *gameListView;
128
130
131 QPushButton *filterButton;
132 QPushButton *clearFilterButton;
133 QPushButton *createButton;
134 QPushButton *joinButton;
135 QPushButton *joinAsJudgeButton;
136 QPushButton *spectateButton;
138
139 const bool showFilters;
141
147 void updateTitle();
148
152 void disableButtons();
153
157 void enableButtons();
158
163 void enableButtonsForIndex(const QModelIndex &current);
164
172 void joinGame(bool asSpectator = false, bool asJudge = false);
173
174public:
187 TabSupervisor *_tabSupervisor,
188 TabRoom *_room,
189 const QMap<int, QString> &_rooms,
190 const QMap<int, GameTypeMap> &_gameTypes,
191 const bool restoresettings,
192 const bool _showfilters,
193 QWidget *parent = nullptr);
194
198 void retranslateUi();
199
204 void processGameInfo(const ServerInfo_Game &info);
205};
206
207#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:388
AbstractClient * client
Definition game_selector.h:121
void actJoinAsSpectator()
Joins the currently selected game as a spectator.
Definition game_selector.cpp:279
QPushButton * createButton
Definition game_selector.h:133
QPushButton * joinAsJudgeSpectatorButton
Definition game_selector.h:137
void actSelectedGameChanged(const QModelIndex &current, const QModelIndex &previous)
Slot called when the selected game changes.
Definition game_selector.cpp:429
void actJoin()
Joins the currently selected game as a player.
Definition game_selector.cpp:265
void retranslateUi()
Updates UI text for translation/localization.
Definition game_selector.cpp:409
const bool showFilters
Definition game_selector.h:139
GameSelectorQuickFilterToolBar * quickFilterToolBar
Definition game_selector.h:129
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:155
GamesProxyModel * gameListProxyModel
Definition game_selector.h:127
QPushButton * joinAsJudgeButton
Definition game_selector.h:135
void actJoinAsJudge()
Joins the currently selected game as a judge.
Definition game_selector.cpp:270
void actSetFilter()
Opens a dialog to set filters for the game list.
Definition game_selector.cpp:176
TabSupervisor * tabSupervisor
Definition game_selector.h:122
void actClearFilter()
Clears all filters applied to the game list.
Definition game_selector.cpp:200
QPushButton * joinButton
Definition game_selector.h:134
GameTypeMap gameTypeMap
Definition game_selector.h:140
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:160
void checkClearFilterButtonState()
Definition game_selector.cpp:195
GamesModel * gameListModel
Definition game_selector.h:126
QPushButton * spectateButton
Definition game_selector.h:136
void customContextMenu(const QPoint &point)
Shows the custom context menu for a game when right-clicked.
Definition game_selector.cpp:293
void disableButtons()
Disables create/join/spectate buttons.
Definition game_selector.cpp:379
void processGameInfo(const ServerInfo_Game &info)
Updates or adds a game entry in the list.
Definition game_selector.cpp:423
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:168
TabRoom * room
Definition game_selector.h:123
void enableButtonsForIndex(const QModelIndex &current)
Enables buttons for a specific game index.
Definition game_selector.cpp:397
void actCreate()
Opens the dialog to create a new game in the current room.
Definition game_selector.cpp:208
QPushButton * clearFilterButton
Definition game_selector.h:132
void updateTitle()
Updates the widget title to reflect the current number of displayed games.
Definition game_selector.cpp:434
void joinGame(bool asSpectator=false, bool asJudge=false)
Performs the join or spectate action for the currently selected game.
Definition game_selector.cpp:335
QPushButton * filterButton
Definition game_selector.h:131
QTreeView * gameListView
Definition game_selector.h:125
void checkResponse(const Response &response)
Processes server responses for join or spectate commands.
Definition game_selector.cpp:220
void actJoinAsJudgeSpectator()
Definition game_selector.cpp:284
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