void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameTypes) { QSettings settings; settings.beginGroup("filter_games"); settings.setValue("unavailable_games_visible", unavailableGamesVisible); settings.setValue( "password_protected_games_visible", passwordProtectedGamesVisible ); settings.setValue("game_name_filter", gameNameFilter); settings.setValue("creator_name_filter", creatorNameFilter); QMapIterator<int, QString> gameTypeIterator(allGameTypes); while (gameTypeIterator.hasNext()) { gameTypeIterator.next(); settings.setValue( "game_type/" + hashGameType(gameTypeIterator.value()), gameTypeFilter.contains(gameTypeIterator.key()) ); } settings.setValue("min_players", maxPlayersFilterMin); settings.setValue("max_players", maxPlayersFilterMax); }
void DlgFilterGames::actOk() { QSettings settings; settings.beginGroup("filter_games"); settings.setValue( "unavailable_games_visible", unavailableGamesVisibleCheckBox->isChecked() ); settings.setValue( "password_protected_games_visible", passwordProtectedGamesVisibleCheckBox->isChecked() ); settings.setValue("game_name_filter", gameNameFilterEdit->text()); settings.setValue("creator_name_filter", creatorNameFilterEdit->text()); QMapIterator<int, QString> gameTypeIterator(allGameTypes); QMapIterator<int, QCheckBox *> checkboxIterator(gameTypeFilterCheckBoxes); while (gameTypeIterator.hasNext()) { gameTypeIterator.next(); checkboxIterator.next(); settings.setValue( "game_type/" + hashGameType(gameTypeIterator.value()), checkboxIterator.value()->isChecked() ); } settings.setValue("min_players", maxPlayersFilterMinSpinBox->value()); settings.setValue("max_players", maxPlayersFilterMaxSpinBox->value()); accept(); }
void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameTypes) { QSettings settings; settings.beginGroup("filter_games"); unavailableGamesVisible = settings.value("unavailable_games_visible", false).toBool(); passwordProtectedGamesVisible = settings.value("password_protected_games_visible", false).toBool(); gameNameFilter = settings.value("game_name_filter", "").toString(); creatorNameFilter = settings.value("creator_name_filter", "").toString(); maxPlayersFilterMin = settings.value("min_players", 1).toInt(); maxPlayersFilterMax = settings.value("max_players", DEFAULT_MAX_PLAYERS_MAX).toInt(); QMapIterator<int, QString> gameTypesIterator(allGameTypes); while (gameTypesIterator.hasNext()) { gameTypesIterator.next(); if (settings.value("game_type/" + hashGameType(gameTypesIterator.value()), false).toBool()) { gameTypeFilter.insert(gameTypesIterator.key()); } } invalidateFilter(); }
bool GameFiltersSettings::isGameTypeEnabled(QString gametype) { QVariant previous = getValue("game_type/"+hashGameType(gametype),"filter_games"); return previous == QVariant() ? false : previous.toBool(); }
void GameFiltersSettings::setGameTypeEnabled(QString gametype, bool enabled) { setValue(enabled, "game_type/"+hashGameType(gametype),"filter_games"); }
DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, QWidget *parent) : QDialog(parent), allGameTypes(_allGameTypes) { QSettings settings; settings.beginGroup("filter_games"); unavailableGamesVisibleCheckBox = new QCheckBox(tr("Show &unavailable games")); unavailableGamesVisibleCheckBox->setChecked( settings.value("unavailable_games_visible", false).toBool() ); passwordProtectedGamesVisibleCheckBox = new QCheckBox(tr("Show &password protected games")); passwordProtectedGamesVisibleCheckBox->setChecked( settings.value("password_protected_games_visible", false).toBool() ); gameNameFilterEdit = new QLineEdit; gameNameFilterEdit->setText( settings.value("game_name_filter", "").toString() ); QLabel *gameNameFilterLabel = new QLabel(tr("Game &description:")); gameNameFilterLabel->setBuddy(gameNameFilterEdit); creatorNameFilterEdit = new QLineEdit; creatorNameFilterEdit->setText( settings.value("creator_name_filter", "").toString() ); QLabel *creatorNameFilterLabel = new QLabel(tr("&Creator name:")); creatorNameFilterLabel->setBuddy(creatorNameFilterEdit); QVBoxLayout *gameTypeFilterLayout = new QVBoxLayout; QMapIterator<int, QString> gameTypesIterator(allGameTypes); while (gameTypesIterator.hasNext()) { gameTypesIterator.next(); QCheckBox *temp = new QCheckBox(gameTypesIterator.value()); temp->setChecked( settings.value( "game_type/" + hashGameType(gameTypesIterator.value()), false ).toBool() ); gameTypeFilterCheckBoxes.insert(gameTypesIterator.key(), temp); gameTypeFilterLayout->addWidget(temp); } QGroupBox *gameTypeFilterGroupBox; if (!allGameTypes.isEmpty()) { gameTypeFilterGroupBox = new QGroupBox(tr("&Game types")); gameTypeFilterGroupBox->setLayout(gameTypeFilterLayout); } else gameTypeFilterGroupBox = 0; QLabel *maxPlayersFilterMinLabel = new QLabel(tr("at &least:")); maxPlayersFilterMinSpinBox = new QSpinBox; maxPlayersFilterMinSpinBox->setMinimum(1); maxPlayersFilterMinSpinBox->setMaximum(99); maxPlayersFilterMinSpinBox->setValue( settings.value("min_players", 1).toInt() ); maxPlayersFilterMinLabel->setBuddy(maxPlayersFilterMinSpinBox); QLabel *maxPlayersFilterMaxLabel = new QLabel(tr("at &most:")); maxPlayersFilterMaxSpinBox = new QSpinBox; maxPlayersFilterMaxSpinBox->setMinimum(1); maxPlayersFilterMaxSpinBox->setMaximum(99); maxPlayersFilterMaxSpinBox->setValue( settings.value("max_players", 99).toInt() ); maxPlayersFilterMaxLabel->setBuddy(maxPlayersFilterMaxSpinBox); QGridLayout *maxPlayersFilterLayout = new QGridLayout; maxPlayersFilterLayout->addWidget(maxPlayersFilterMinLabel, 0, 0); maxPlayersFilterLayout->addWidget(maxPlayersFilterMinSpinBox, 0, 1); maxPlayersFilterLayout->addWidget(maxPlayersFilterMaxLabel, 1, 0); maxPlayersFilterLayout->addWidget(maxPlayersFilterMaxSpinBox, 1, 1); QGroupBox *maxPlayersGroupBox = new QGroupBox(tr("Maximum player count")); maxPlayersGroupBox->setLayout(maxPlayersFilterLayout); QGridLayout *leftGrid = new QGridLayout; leftGrid->addWidget(gameNameFilterLabel, 0, 0); leftGrid->addWidget(gameNameFilterEdit, 0, 1); leftGrid->addWidget(creatorNameFilterLabel, 1, 0); leftGrid->addWidget(creatorNameFilterEdit, 1, 1); leftGrid->addWidget(maxPlayersGroupBox, 2, 0, 1, 2); leftGrid->addWidget(unavailableGamesVisibleCheckBox, 3, 0, 1, 2); leftGrid->addWidget(passwordProtectedGamesVisibleCheckBox, 4, 0, 1, 2); QVBoxLayout *leftColumn = new QVBoxLayout; leftColumn->addLayout(leftGrid); leftColumn->addStretch(); QVBoxLayout *rightColumn = new QVBoxLayout; rightColumn->addWidget(gameTypeFilterGroupBox); QHBoxLayout *hbox = new QHBoxLayout; hbox->addLayout(leftColumn); hbox->addLayout(rightColumn); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(hbox); mainLayout->addWidget(buttonBox); setLayout(mainLayout); setWindowTitle(tr("Filter games")); }