mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-12 21:44:18 -07:00
Add dropdown for game age filtering (#4092)
* Part 1 for #3067: Basic combo box (dropdown) filtering mechanism for game age. * Apply suggestions from draft review # Conflicts: # cockatrice/src/gamesmodel.cpp # cockatrice/src/gamesmodel.h * switch to using QTime * check for games older than a day * formatting for casts and more unnecessary cosmetic changes * ebbit1q fixes Co-authored-by: ebbit1q <ebbit1q@gmail.com>
This commit is contained in:
parent
58d024d067
commit
eba9c097f6
7 changed files with 136 additions and 46 deletions
|
|
@ -9,6 +9,8 @@
|
|||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStringList>
|
||||
#include <QTime>
|
||||
|
||||
class GamesModel : public QAbstractTableModel
|
||||
{
|
||||
|
|
@ -37,7 +39,7 @@ public:
|
|||
}
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
const QString getGameCreatedString(const int secs) const;
|
||||
static const QString getGameCreatedString(const int secs);
|
||||
const ServerInfo_Game &getGame(int row);
|
||||
|
||||
/**
|
||||
|
|
@ -68,20 +70,22 @@ class GamesProxyModel : public QSortFilterProxyModel
|
|||
private:
|
||||
bool ownUserIsRegistered;
|
||||
const TabSupervisor *tabSupervisor;
|
||||
|
||||
// If adding any additional filters, make sure to update:
|
||||
// - GamesProxyModel()
|
||||
// - resetFilterParameters()
|
||||
// - areFilterParametersSetToDefaults()
|
||||
// - loadFilterParameters()
|
||||
// - saveFilterParameters()
|
||||
// - filterAcceptsRow()
|
||||
bool showBuddiesOnlyGames;
|
||||
bool hideIgnoredUserGames;
|
||||
bool unavailableGamesVisible;
|
||||
bool showPasswordProtectedGames;
|
||||
QString gameNameFilter, creatorNameFilter;
|
||||
QSet<int> gameTypeFilter;
|
||||
int maxPlayersFilterMin, maxPlayersFilterMax;
|
||||
|
||||
static const bool DEFAULT_UNAVAILABLE_GAMES_VISIBLE = false;
|
||||
static const bool DEFAULT_SHOW_PASSWORD_PROTECTED_GAMES = true;
|
||||
static const bool DEFAULT_SHOW_BUDDIES_ONLY_GAMES = true;
|
||||
static const bool DEFAULT_HIDE_IGNORED_USER_GAMES = false;
|
||||
static const int DEFAULT_MAX_PLAYERS_MIN = 1;
|
||||
static const int DEFAULT_MAX_PLAYERS_MAX = 99;
|
||||
quint32 maxPlayersFilterMin, maxPlayersFilterMax;
|
||||
QTime maxGameAge;
|
||||
|
||||
public:
|
||||
GamesProxyModel(QObject *parent = nullptr, const TabSupervisor *_tabSupervisor = nullptr);
|
||||
|
|
@ -130,6 +134,12 @@ public:
|
|||
return maxPlayersFilterMax;
|
||||
}
|
||||
void setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlayersFilterMax);
|
||||
const QTime &getMaxGameAge() const
|
||||
{
|
||||
return maxGameAge;
|
||||
}
|
||||
void setMaxGameAge(const QTime &_maxGameAge);
|
||||
|
||||
int getNumFilteredGames() const;
|
||||
void resetFilterParameters();
|
||||
bool areFilterParametersSetToDefaults() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue