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);
226 bool _hideIgnoredUserGames,
228 bool _hideGamesThatStarted,
229 bool _hidePasswordProtectedGames,
230 bool _hideNotBuddyCreatedGames,
231 bool _hideOpenDecklistGames,
232 const QString &_gameNameFilter,
233 const QStringList &_creatorNameFilter,
234 const QSet<int> &_gameTypeFilter,
235 int _maxPlayersFilterMin,
236 int _maxPlayersFilterMax,
237 const QTime &_maxGameAge,
238 bool _showOnlyIfSpectatorsCanWatch,
239 bool _showSpectatorPasswordProtected,
240 bool _showOnlyIfSpectatorsCanChat,
241 bool _showOnlyIfSpectatorsCanSeeHands);
363 [[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:169
void setHideIgnoredUserGames(bool value)
Definition games_model.h:249
void setGameTypeFilter(const QSet< int > &value)
Definition games_model.h:289
bool getHideNotBuddyCreatedGames() const
Definition games_model.h:173
void setGameNameFilter(const QString &value)
Definition games_model.h:279
bool hidePasswordProtectedGames
Definition games_model.h:128
QStringList getCreatorNameFilters() const
Definition games_model.h:185
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:264
void setHideGamesThatStarted(bool value)
Definition games_model.h:259
int getMaxPlayersFilterMax() const
Definition games_model.h:197
bool hideNotBuddyCreatedGames
Definition games_model.h:129
void setMaxPlayersFilterMin(int value)
Definition games_model.h:294
QTime maxGameAge
Definition games_model.h:135
QStringList creatorNameFilters
Definition games_model.h:132
void setHideBuddiesOnlyGames(bool value)
Definition games_model.h:244
int getMaxPlayersFilterMin() const
Definition games_model.h:193
bool areFilterParametersSetToDefaults() const
Returns true if all filter parameters are set to their defaults.
Definition games_model.cpp:353
bool getHideBuddiesOnlyGames() const
Definition games_model.h:153
void resetFilterParameters()
Resets all filter parameters to default values.
Definition games_model.cpp:347
bool getShowOnlyIfSpectatorsCanChat() const
Definition games_model.h:213
void loadFilterParameters(const QMap< int, QString > &allGameTypes)
Loads filter parameters from persistent settings.
Definition games_model.cpp:363
void setHideFullGames(bool value)
Definition games_model.h:254
QString gameNameFilter
Definition games_model.h:131
void setHideOpenDecklistGames(bool value)
Definition games_model.h:274
bool hideGamesThatStarted
Definition games_model.h:127
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Definition games_model.cpp:416
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:386
bool showOnlyIfSpectatorsCanSeeHands
Definition games_model.h:139
void setShowOnlyIfSpectatorsCanSeeHands(bool value)
Definition games_model.h:324
bool hideOpenDecklistGames
Definition games_model.h:130
quint32 maxPlayersFilterMax
Definition games_model.h:134
void setShowOnlyIfSpectatorsCanChat(bool value)
Definition games_model.h:319
QSet< int > gameTypeFilter
Definition games_model.h:133
const QTime & getMaxGameAge() const
Definition games_model.h:201
bool getHideIgnoredUserGames() const
Definition games_model.h:157
void setCreatorNameFilters(const QStringList &values)
Definition games_model.h:284
void setShowSpectatorPasswordProtected(bool value)
Definition games_model.h:314
bool getShowOnlyIfSpectatorsCanWatch() const
Definition games_model.h:205
bool getShowOnlyIfSpectatorsCanSeeHands() const
Definition games_model.h:217
bool getShowSpectatorPasswordProtected() const
Definition games_model.h:209
bool showOnlyIfSpectatorsCanWatch
Definition games_model.h:136
QSet< int > getGameTypeFilter() const
Definition games_model.h:189
bool getHideGamesThatStarted() const
Definition games_model.h:165
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:332
void setShowOnlyIfSpectatorsCanWatch(bool value)
Definition games_model.h:309
void refresh()
Refreshes the proxy model (re-applies filters).
Definition games_model.cpp:505
void setHideNotBuddyCreatedGames(bool value)
Definition games_model.h:269
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:304
bool getHideFullGames() const
Definition games_model.h:161
bool getHideOpenDecklistGames() const
Definition games_model.h:177
QString getGameNameFilter() const
Definition games_model.h:181
void setMaxPlayersFilterMax(int value)
Definition games_model.h:299
Definition user_list_proxy.h:19