Merge pull request #973 from poixen/filter_dlg

Filter password games consistancy
This commit is contained in:
ctrlaltca 2015-04-17 09:47:18 +02:00
commit b99a0a682e
5 changed files with 22 additions and 22 deletions

View file

@ -23,8 +23,8 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, const Ga
unavailableGamesVisibleCheckBox = new QCheckBox(tr("Show &unavailable games")); unavailableGamesVisibleCheckBox = new QCheckBox(tr("Show &unavailable games"));
unavailableGamesVisibleCheckBox->setChecked(gamesProxyModel->getUnavailableGamesVisible()); unavailableGamesVisibleCheckBox->setChecked(gamesProxyModel->getUnavailableGamesVisible());
passwordProtectedGamesHiddenCheckBox = new QCheckBox(tr("Hide &password protected games")); showPasswordProtectedGames = new QCheckBox(tr("Show &password protected games"));
passwordProtectedGamesHiddenCheckBox->setChecked(gamesProxyModel->getPasswordProtectedGamesHidden()); showPasswordProtectedGames->setChecked(gamesProxyModel->getShowPasswordProtectedGames());
gameNameFilterEdit = new QLineEdit; gameNameFilterEdit = new QLineEdit;
gameNameFilterEdit->setText(gamesProxyModel->getGameNameFilter()); gameNameFilterEdit->setText(gamesProxyModel->getGameNameFilter());
@ -84,7 +84,7 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, const Ga
leftGrid->addWidget(creatorNameFilterEdit, 1, 1); leftGrid->addWidget(creatorNameFilterEdit, 1, 1);
leftGrid->addWidget(maxPlayersGroupBox, 2, 0, 1, 2); leftGrid->addWidget(maxPlayersGroupBox, 2, 0, 1, 2);
leftGrid->addWidget(unavailableGamesVisibleCheckBox, 3, 0, 1, 2); leftGrid->addWidget(unavailableGamesVisibleCheckBox, 3, 0, 1, 2);
leftGrid->addWidget(passwordProtectedGamesHiddenCheckBox, 4, 0, 1, 2); leftGrid->addWidget(showPasswordProtectedGames, 4, 0, 1, 2);
QVBoxLayout *leftColumn = new QVBoxLayout; QVBoxLayout *leftColumn = new QVBoxLayout;
leftColumn->addLayout(leftGrid); leftColumn->addLayout(leftGrid);
@ -123,14 +123,14 @@ void DlgFilterGames::setUnavailableGamesVisible(bool _unavailableGamesVisible)
unavailableGamesVisibleCheckBox->setChecked(_unavailableGamesVisible); unavailableGamesVisibleCheckBox->setChecked(_unavailableGamesVisible);
} }
bool DlgFilterGames::getPasswordProtectedGamesHidden() const bool DlgFilterGames::getShowPasswordProtectedGames() const
{ {
return passwordProtectedGamesHiddenCheckBox->isChecked(); return showPasswordProtectedGames->isChecked();
} }
void DlgFilterGames::setPasswordProtectedGamesHidden(bool _passwordProtectedGamesHidden) void DlgFilterGames::setShowPasswordProtectedGames(bool _passwordProtectedGamesHidden)
{ {
passwordProtectedGamesHiddenCheckBox->setChecked(_passwordProtectedGamesHidden); showPasswordProtectedGames->setChecked(_passwordProtectedGamesHidden);
} }
QString DlgFilterGames::getGameNameFilter() const QString DlgFilterGames::getGameNameFilter() const

View file

@ -14,7 +14,7 @@ class DlgFilterGames : public QDialog {
Q_OBJECT Q_OBJECT
private: private:
QCheckBox *unavailableGamesVisibleCheckBox; QCheckBox *unavailableGamesVisibleCheckBox;
QCheckBox *passwordProtectedGamesHiddenCheckBox; QCheckBox *showPasswordProtectedGames;
QLineEdit *gameNameFilterEdit; QLineEdit *gameNameFilterEdit;
QLineEdit *creatorNameFilterEdit; QLineEdit *creatorNameFilterEdit;
QMap<int, QCheckBox *> gameTypeFilterCheckBoxes; QMap<int, QCheckBox *> gameTypeFilterCheckBoxes;
@ -31,8 +31,8 @@ public:
bool getUnavailableGamesVisible() const; bool getUnavailableGamesVisible() const;
void setUnavailableGamesVisible(bool _unavailableGamesVisible); void setUnavailableGamesVisible(bool _unavailableGamesVisible);
bool getPasswordProtectedGamesHidden() const; bool getShowPasswordProtectedGames() const;
void setPasswordProtectedGamesHidden(bool _passwordProtectedGamesHidden); void setShowPasswordProtectedGames(bool _passwordProtectedGamesHidden);
QString getGameNameFilter() const; QString getGameNameFilter() const;
void setGameNameFilter(const QString &_gameNameFilter); void setGameNameFilter(const QString &_gameNameFilter);
QString getCreatorNameFilter() const; QString getCreatorNameFilter() const;

View file

@ -113,7 +113,7 @@ void GameSelector::actSetFilter()
clearFilterButton->setEnabled(true); clearFilterButton->setEnabled(true);
gameListProxyModel->setUnavailableGamesVisible(dlg.getUnavailableGamesVisible()); gameListProxyModel->setUnavailableGamesVisible(dlg.getUnavailableGamesVisible());
gameListProxyModel->setPasswordProtectedGamesHidden(dlg.getPasswordProtectedGamesHidden()); gameListProxyModel->setShowPasswordProtectedGames(dlg.getShowPasswordProtectedGames());
gameListProxyModel->setGameNameFilter(dlg.getGameNameFilter()); gameListProxyModel->setGameNameFilter(dlg.getGameNameFilter());
gameListProxyModel->setCreatorNameFilter(dlg.getCreatorNameFilter()); gameListProxyModel->setCreatorNameFilter(dlg.getCreatorNameFilter());
gameListProxyModel->setGameTypeFilter(dlg.getGameTypeFilter()); gameListProxyModel->setGameTypeFilter(dlg.getGameTypeFilter());

View file

@ -223,7 +223,7 @@ GamesProxyModel::GamesProxyModel(QObject *parent, ServerInfo_User *_ownUser)
: QSortFilterProxyModel(parent), : QSortFilterProxyModel(parent),
ownUser(_ownUser), ownUser(_ownUser),
unavailableGamesVisible(false), unavailableGamesVisible(false),
passwordProtectedGamesHidden(false), showPasswordProtectedGames(true),
maxPlayersFilterMin(-1), maxPlayersFilterMin(-1),
maxPlayersFilterMax(-1) maxPlayersFilterMax(-1)
{ {
@ -237,9 +237,9 @@ void GamesProxyModel::setUnavailableGamesVisible(bool _unavailableGamesVisible)
invalidateFilter(); invalidateFilter();
} }
void GamesProxyModel::setPasswordProtectedGamesHidden(bool _passwordProtectedGamesHidden) void GamesProxyModel::setShowPasswordProtectedGames(bool _showPasswordProtectedGames)
{ {
passwordProtectedGamesHidden = _passwordProtectedGamesHidden; showPasswordProtectedGames = _showPasswordProtectedGames;
invalidateFilter(); invalidateFilter();
} }
@ -271,7 +271,7 @@ void GamesProxyModel::setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlay
void GamesProxyModel::resetFilterParameters() void GamesProxyModel::resetFilterParameters()
{ {
unavailableGamesVisible = false; unavailableGamesVisible = false;
passwordProtectedGamesHidden = false; showPasswordProtectedGames = true;
gameNameFilter = QString(); gameNameFilter = QString();
creatorNameFilter = QString(); creatorNameFilter = QString();
gameTypeFilter.clear(); gameTypeFilter.clear();
@ -287,7 +287,7 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
settings.beginGroup("filter_games"); settings.beginGroup("filter_games");
unavailableGamesVisible = settings.value("unavailable_games_visible", false).toBool(); unavailableGamesVisible = settings.value("unavailable_games_visible", false).toBool();
passwordProtectedGamesHidden = settings.value("password_protected_games_hidden", false).toBool(); showPasswordProtectedGames = settings.value("show_password_protected_games", true).toBool();
gameNameFilter = settings.value("game_name_filter", "").toString(); gameNameFilter = settings.value("game_name_filter", "").toString();
maxPlayersFilterMin = settings.value("min_players", 1).toInt(); maxPlayersFilterMin = settings.value("min_players", 1).toInt();
maxPlayersFilterMax = settings.value("max_players", DEFAULT_MAX_PLAYERS_MAX).toInt(); maxPlayersFilterMax = settings.value("max_players", DEFAULT_MAX_PLAYERS_MAX).toInt();
@ -310,8 +310,8 @@ void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameType
settings.setValue("unavailable_games_visible", unavailableGamesVisible); settings.setValue("unavailable_games_visible", unavailableGamesVisible);
settings.setValue( settings.setValue(
"password_protected_games_hidden", "show_password_protected_games",
passwordProtectedGamesHidden showPasswordProtectedGames
); );
settings.setValue("game_name_filter", gameNameFilter); settings.setValue("game_name_filter", gameNameFilter);
@ -345,7 +345,7 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
if (game.only_registered()) if (game.only_registered())
return false; return false;
} }
if (passwordProtectedGamesHidden && game.with_password()) if (!showPasswordProtectedGames && game.with_password())
return false; return false;
if (!gameNameFilter.isEmpty()) if (!gameNameFilter.isEmpty())
if (!QString::fromStdString(game.description()).contains(gameNameFilter, Qt::CaseInsensitive)) if (!QString::fromStdString(game.description()).contains(gameNameFilter, Qt::CaseInsensitive))

View file

@ -47,7 +47,7 @@ class GamesProxyModel : public QSortFilterProxyModel {
private: private:
ServerInfo_User *ownUser; ServerInfo_User *ownUser;
bool unavailableGamesVisible; bool unavailableGamesVisible;
bool passwordProtectedGamesHidden; bool showPasswordProtectedGames;
QString gameNameFilter, creatorNameFilter; QString gameNameFilter, creatorNameFilter;
QSet<int> gameTypeFilter; QSet<int> gameTypeFilter;
int maxPlayersFilterMin, maxPlayersFilterMax; int maxPlayersFilterMin, maxPlayersFilterMax;
@ -64,8 +64,8 @@ public:
bool getUnavailableGamesVisible() const { return unavailableGamesVisible; } bool getUnavailableGamesVisible() const { return unavailableGamesVisible; }
void setUnavailableGamesVisible(bool _unavailableGamesVisible); void setUnavailableGamesVisible(bool _unavailableGamesVisible);
bool getPasswordProtectedGamesHidden() const { return passwordProtectedGamesHidden; } bool getShowPasswordProtectedGames() const { return showPasswordProtectedGames; }
void setPasswordProtectedGamesHidden(bool _passwordProtectedGamesHidden); void setShowPasswordProtectedGames(bool _showPasswordProtectedGames);
QString getGameNameFilter() const { return gameNameFilter; } QString getGameNameFilter() const { return gameNameFilter; }
void setGameNameFilter(const QString &_gameNameFilter); void setGameNameFilter(const QString &_gameNameFilter);
QString getCreatorNameFilter() const { return creatorNameFilter; } QString getCreatorNameFilter() const { return creatorNameFilter; }