Hash the game type.
This commit is contained in:
parent
8141901679
commit
1217689ed6
2 changed files with 13 additions and 2 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, QWidget *parent)
|
DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
|
@ -50,7 +51,7 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, QWidget
|
||||||
QCheckBox *temp = new QCheckBox(gameTypesIterator.value());
|
QCheckBox *temp = new QCheckBox(gameTypesIterator.value());
|
||||||
temp->setChecked(
|
temp->setChecked(
|
||||||
settings.value(
|
settings.value(
|
||||||
"game_type/" + gameTypesIterator.value(),
|
"game_type/" + hashGameType(gameTypesIterator.value()),
|
||||||
false
|
false
|
||||||
).toBool()
|
).toBool()
|
||||||
);
|
);
|
||||||
|
@ -145,7 +146,7 @@ void DlgFilterGames::actOk() {
|
||||||
checkboxIterator.next();
|
checkboxIterator.next();
|
||||||
|
|
||||||
settings.setValue(
|
settings.setValue(
|
||||||
"game_type/" + gameTypeIterator.value(),
|
"game_type/" + hashGameType(gameTypeIterator.value()),
|
||||||
checkboxIterator.value()->isChecked()
|
checkboxIterator.value()->isChecked()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -156,6 +157,10 @@ void DlgFilterGames::actOk() {
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DlgFilterGames::hashGameType(const QString &gameType) const {
|
||||||
|
return QCryptographicHash::hash(gameType.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||||
|
}
|
||||||
|
|
||||||
bool DlgFilterGames::getUnavailableGamesVisible() const
|
bool DlgFilterGames::getUnavailableGamesVisible() const
|
||||||
{
|
{
|
||||||
return unavailableGamesVisibleCheckBox->isChecked();
|
return unavailableGamesVisibleCheckBox->isChecked();
|
||||||
|
|
|
@ -21,6 +21,12 @@ private:
|
||||||
QSpinBox *maxPlayersFilterMaxSpinBox;
|
QSpinBox *maxPlayersFilterMaxSpinBox;
|
||||||
|
|
||||||
const QMap<int, QString> &allGameTypes;
|
const QMap<int, QString> &allGameTypes;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The game type might contain special characters, so to use it in
|
||||||
|
* QSettings we just hash it.
|
||||||
|
*/
|
||||||
|
QString hashGameType(const QString &gameType) const;
|
||||||
private slots:
|
private slots:
|
||||||
void actOk();
|
void actOk();
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue