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 <QDialogButtonBox>
|
||||
#include <QSettings>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, QWidget *parent)
|
||||
: QDialog(parent),
|
||||
|
@ -50,7 +51,7 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, QWidget
|
|||
QCheckBox *temp = new QCheckBox(gameTypesIterator.value());
|
||||
temp->setChecked(
|
||||
settings.value(
|
||||
"game_type/" + gameTypesIterator.value(),
|
||||
"game_type/" + hashGameType(gameTypesIterator.value()),
|
||||
false
|
||||
).toBool()
|
||||
);
|
||||
|
@ -145,7 +146,7 @@ void DlgFilterGames::actOk() {
|
|||
checkboxIterator.next();
|
||||
|
||||
settings.setValue(
|
||||
"game_type/" + gameTypeIterator.value(),
|
||||
"game_type/" + hashGameType(gameTypeIterator.value()),
|
||||
checkboxIterator.value()->isChecked()
|
||||
);
|
||||
}
|
||||
|
@ -156,6 +157,10 @@ void DlgFilterGames::actOk() {
|
|||
accept();
|
||||
}
|
||||
|
||||
QString DlgFilterGames::hashGameType(const QString &gameType) const {
|
||||
return QCryptographicHash::hash(gameType.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||
}
|
||||
|
||||
bool DlgFilterGames::getUnavailableGamesVisible() const
|
||||
{
|
||||
return unavailableGamesVisibleCheckBox->isChecked();
|
||||
|
|
|
@ -21,6 +21,12 @@ private:
|
|||
QSpinBox *maxPlayersFilterMaxSpinBox;
|
||||
|
||||
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:
|
||||
void actOk();
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue