8#include <QSortFilterProxyModel>
10#include <libcockatrice/protocol/pb/serverinfo_game.pb.h>
41 GamesModel(
const QMap<int, QString> &_rooms,
const QMap<int, GameTypeMap> &_gameTypes, QObject *parent =
nullptr);
43 [[nodiscard]]
int rowCount(
const QModelIndex &parent = QModelIndex())
const override
45 return parent.isValid() ? 0 :
gameList.size();
48 [[nodiscard]]
int columnCount(
const QModelIndex & = QModelIndex())
const override
53 [[nodiscard]] QVariant
data(
const QModelIndex &index,
int role)
const override;
55 [[nodiscard]] QVariant
56 headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override;
70 const ServerInfo_Game &
getGame(
int row);
223 bool _hideIgnoredUserGames,
225 bool _hideGamesThatStarted,
226 bool _hidePasswordProtectedGames,
227 bool _hideNotBuddyCreatedGames,
228 bool _hideOpenDecklistGames,
229 const QString &_gameNameFilter,
230 const QStringList &_creatorNameFilter,
231 const QSet<int> &_gameTypeFilter,
232 int _maxPlayersFilterMin,
233 int _maxPlayersFilterMax,
234 const QTime &_maxGameAge,
235 bool _showOnlyIfSpectatorsCanWatch,
236 bool _showSpectatorPasswordProtected,
237 bool _showOnlyIfSpectatorsCanChat,
238 bool _showOnlyIfSpectatorsCanSeeHands);
360 [[nodiscard]]
bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent)
const override;
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition games_model.cpp:210
QMap< int, GameTypeMap > gameTypes
Definition games_model.h:28
const QMap< int, GameTypeMap > & getGameTypes()
Returns the map of game types per room.
Definition games_model.h:97
const ServerInfo_Game & getGame(int row)
Returns a reference to a specific game by row index.
Definition games_model.cpp:252
int columnCount(const QModelIndex &=QModelIndex()) const override
Definition games_model.h:48
void updateGameList(const ServerInfo_Game &game)
Updates the game list with a new or updated game.
Definition games_model.cpp:258
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition games_model.h:43
int startTimeColIndex()
Returns the index of the start time column.
Definition games_model.h:89
QVariant data(const QModelIndex &index, int role) const override
Definition games_model.cpp:68
GamesModel(const QMap< int, QString > &_rooms, const QMap< int, GameTypeMap > &_gameTypes, QObject *parent=nullptr)
Constructs a GamesModel.
Definition games_model.cpp:63
int roomColIndex()
Returns the index of the room column.
Definition games_model.h:81
QList< ServerInfo_Game > gameList
Definition games_model.h:26
static const QString getGameCreatedString(const int secs)
Formats the game creation time into a human-readable string.
Definition games_model.cpp:30
static const int SORT_ROLE
Definition games_model.h:33
static const int NUM_COLS
Definition games_model.h:30
QMap< int, QString > rooms
Definition games_model.h:27
bool getHidePasswordProtectedGames() const
Definition games_model.h:166
void setHideIgnoredUserGames(bool value)
Definition games_model.h:246
void setGameTypeFilter(const QSet< int > &value)
Definition games_model.h:286
bool getHideNotBuddyCreatedGames() const
Definition games_model.h:170
void setGameNameFilter(const QString &value)
Definition games_model.h:276
bool hidePasswordProtectedGames
Definition games_model.h:128
QStringList getCreatorNameFilters() const
Definition games_model.h:182
void setGameFilters(bool _hideBuddiesOnlyGames, bool _hideIgnoredUserGames, bool _hideFullGames, bool _hideGamesThatStarted, bool _hidePasswordProtectedGames, bool _hideNotBuddyCreatedGames, bool _hideOpenDecklistGames, const QString &_gameNameFilter, const QStringList &_creatorNameFilter, const QSet< int > &_gameTypeFilter, int _maxPlayersFilterMin, int _maxPlayersFilterMax, const QTime &_maxGameAge, bool _showOnlyIfSpectatorsCanWatch, bool _showSpectatorPasswordProtected, bool _showOnlyIfSpectatorsCanChat, bool _showOnlyIfSpectatorsCanSeeHands)
Sets all game filters at once.
Definition games_model.cpp:286
void setHidePasswordProtectedGames(bool value)
Definition games_model.h:261
void setHideGamesThatStarted(bool value)
Definition games_model.h:256
int getMaxPlayersFilterMax() const
Definition games_model.h:194
bool hideNotBuddyCreatedGames
Definition games_model.h:129
void setMaxPlayersFilterMin(int value)
Definition games_model.h:291
QTime maxGameAge
Definition games_model.h:135
QStringList creatorNameFilters
Definition games_model.h:132
void setHideBuddiesOnlyGames(bool value)
Definition games_model.h:241
int getMaxPlayersFilterMin() const
Definition games_model.h:190
bool areFilterParametersSetToDefaults() const
Returns true if all filter parameters are set to their defaults.
Definition games_model.cpp:352
bool getHideBuddiesOnlyGames() const
Definition games_model.h:150
void resetFilterParameters()
Resets all filter parameters to default values.
Definition games_model.cpp:346
bool getShowOnlyIfSpectatorsCanChat() const
Definition games_model.h:210
void loadFilterParameters(const QMap< int, QString > &allGameTypes)
Loads filter parameters from persistent settings.
Definition games_model.cpp:362
void setHideFullGames(bool value)
Definition games_model.h:251
QString gameNameFilter
Definition games_model.h:131
void setHideOpenDecklistGames(bool value)
Definition games_model.h:271
bool hideGamesThatStarted
Definition games_model.h:127
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Definition games_model.cpp:415
const UserListProxy * userListProxy
Definition games_model.h:115
quint32 maxPlayersFilterMin
Definition games_model.h:134
bool showOnlyIfSpectatorsCanChat
Definition games_model.h:138
void saveFilterParameters(const QMap< int, QString > &allGameTypes)
Saves filter parameters to persistent settings.
Definition games_model.cpp:385
bool showOnlyIfSpectatorsCanSeeHands
Definition games_model.h:139
void setShowOnlyIfSpectatorsCanSeeHands(bool value)
Definition games_model.h:321
bool hideOpenDecklistGames
Definition games_model.h:130
quint32 maxPlayersFilterMax
Definition games_model.h:134
void setShowOnlyIfSpectatorsCanChat(bool value)
Definition games_model.h:316
QSet< int > gameTypeFilter
Definition games_model.h:133
const QTime & getMaxGameAge() const
Definition games_model.h:198
bool getHideIgnoredUserGames() const
Definition games_model.h:154
void setCreatorNameFilters(const QStringList &values)
Definition games_model.h:281
void setShowSpectatorPasswordProtected(bool value)
Definition games_model.h:311
bool getShowOnlyIfSpectatorsCanWatch() const
Definition games_model.h:202
bool getShowOnlyIfSpectatorsCanSeeHands() const
Definition games_model.h:214
bool getShowSpectatorPasswordProtected() const
Definition games_model.h:206
bool showOnlyIfSpectatorsCanWatch
Definition games_model.h:136
QSet< int > getGameTypeFilter() const
Definition games_model.h:186
bool getHideGamesThatStarted() const
Definition games_model.h:162
bool showSpectatorPasswordProtected
Definition games_model.h:137
bool hideBuddiesOnlyGames
Definition games_model.h:124
int getNumFilteredGames() const
Returns the number of games filtered out by the current filter.
Definition games_model.cpp:331
void setShowOnlyIfSpectatorsCanWatch(bool value)
Definition games_model.h:306
void refresh()
Refreshes the proxy model (re-applies filters).
Definition games_model.cpp:506
void setHideNotBuddyCreatedGames(bool value)
Definition games_model.h:266
GamesProxyModel(QObject *parent=nullptr, const UserListProxy *_userListProxy=nullptr)
Constructs a GamesProxyModel.
Definition games_model.cpp:278
bool hideIgnoredUserGames
Definition games_model.h:125
bool hideFullGames
Definition games_model.h:126
void setMaxGameAge(const QTime &value)
Definition games_model.h:301
bool getHideFullGames() const
Definition games_model.h:158
bool getHideOpenDecklistGames() const
Definition games_model.h:174
QString getGameNameFilter() const
Definition games_model.h:178
void setMaxPlayersFilterMax(int value)
Definition games_model.h:296
Definition user_list_proxy.h:19