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:
Kaitlin 2020-09-30 23:46:10 -04:00 committed by GitHub
parent 58d024d067
commit eba9c097f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 136 additions and 46 deletions

View file

@ -1,6 +1,7 @@
#include "gamefilterssettings.h"
#include <QCryptographicHash>
#include <QTime>
GameFiltersSettings::GameFiltersSettings(QString settingPath, QObject *parent)
: SettingsManager(settingPath + "gamefilters.ini", parent)
@ -102,6 +103,17 @@ int GameFiltersSettings::getMaxPlayers()
return previous == QVariant() ? 99 : previous.toInt();
}
void GameFiltersSettings::setMaxGameAge(const QTime &maxGameAge)
{
setValue(maxGameAge, "max_game_age_time", "filter_games");
}
QTime GameFiltersSettings::getMaxGameAge()
{
QVariant previous = getValue("max_game_age_time", "filter_games");
return previous.toTime();
}
void GameFiltersSettings::setGameTypeEnabled(QString gametype, bool enabled)
{
setValue(enabled, "game_type/" + hashGameType(gametype), "filter_games");

View file

@ -17,6 +17,7 @@ public:
QString getCreatorNameFilter();
int getMinPlayers();
int getMaxPlayers();
QTime getMaxGameAge();
bool isGameTypeEnabled(QString gametype);
void setShowBuddiesOnlyGames(bool show);
@ -27,6 +28,7 @@ public:
void setCreatorNameFilter(QString creatorName);
void setMinPlayers(int min);
void setMaxPlayers(int max);
void setMaxGameAge(const QTime &maxGameAge);
void setGameTypeEnabled(QString gametype, bool enabled);
void setGameHashedTypeEnabled(QString gametypeHASHED, bool enabled);
signals: