Merge pull request #973 from poixen/filter_dlg
Filter password games consistancy
This commit is contained in:
commit
b99a0a682e
5 changed files with 22 additions and 22 deletions
|
@ -23,8 +23,8 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, const Ga
|
|||
unavailableGamesVisibleCheckBox = new QCheckBox(tr("Show &unavailable games"));
|
||||
unavailableGamesVisibleCheckBox->setChecked(gamesProxyModel->getUnavailableGamesVisible());
|
||||
|
||||
passwordProtectedGamesHiddenCheckBox = new QCheckBox(tr("Hide &password protected games"));
|
||||
passwordProtectedGamesHiddenCheckBox->setChecked(gamesProxyModel->getPasswordProtectedGamesHidden());
|
||||
showPasswordProtectedGames = new QCheckBox(tr("Show &password protected games"));
|
||||
showPasswordProtectedGames->setChecked(gamesProxyModel->getShowPasswordProtectedGames());
|
||||
|
||||
gameNameFilterEdit = new QLineEdit;
|
||||
gameNameFilterEdit->setText(gamesProxyModel->getGameNameFilter());
|
||||
|
@ -84,7 +84,7 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, const Ga
|
|||
leftGrid->addWidget(creatorNameFilterEdit, 1, 1);
|
||||
leftGrid->addWidget(maxPlayersGroupBox, 2, 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;
|
||||
leftColumn->addLayout(leftGrid);
|
||||
|
@ -123,14 +123,14 @@ void DlgFilterGames::setUnavailableGamesVisible(bool _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
|
||||
|
|
|
@ -14,7 +14,7 @@ class DlgFilterGames : public QDialog {
|
|||
Q_OBJECT
|
||||
private:
|
||||
QCheckBox *unavailableGamesVisibleCheckBox;
|
||||
QCheckBox *passwordProtectedGamesHiddenCheckBox;
|
||||
QCheckBox *showPasswordProtectedGames;
|
||||
QLineEdit *gameNameFilterEdit;
|
||||
QLineEdit *creatorNameFilterEdit;
|
||||
QMap<int, QCheckBox *> gameTypeFilterCheckBoxes;
|
||||
|
@ -31,8 +31,8 @@ public:
|
|||
|
||||
bool getUnavailableGamesVisible() const;
|
||||
void setUnavailableGamesVisible(bool _unavailableGamesVisible);
|
||||
bool getPasswordProtectedGamesHidden() const;
|
||||
void setPasswordProtectedGamesHidden(bool _passwordProtectedGamesHidden);
|
||||
bool getShowPasswordProtectedGames() const;
|
||||
void setShowPasswordProtectedGames(bool _passwordProtectedGamesHidden);
|
||||
QString getGameNameFilter() const;
|
||||
void setGameNameFilter(const QString &_gameNameFilter);
|
||||
QString getCreatorNameFilter() const;
|
||||
|
|
|
@ -113,7 +113,7 @@ void GameSelector::actSetFilter()
|
|||
clearFilterButton->setEnabled(true);
|
||||
|
||||
gameListProxyModel->setUnavailableGamesVisible(dlg.getUnavailableGamesVisible());
|
||||
gameListProxyModel->setPasswordProtectedGamesHidden(dlg.getPasswordProtectedGamesHidden());
|
||||
gameListProxyModel->setShowPasswordProtectedGames(dlg.getShowPasswordProtectedGames());
|
||||
gameListProxyModel->setGameNameFilter(dlg.getGameNameFilter());
|
||||
gameListProxyModel->setCreatorNameFilter(dlg.getCreatorNameFilter());
|
||||
gameListProxyModel->setGameTypeFilter(dlg.getGameTypeFilter());
|
||||
|
|
|
@ -223,7 +223,7 @@ GamesProxyModel::GamesProxyModel(QObject *parent, ServerInfo_User *_ownUser)
|
|||
: QSortFilterProxyModel(parent),
|
||||
ownUser(_ownUser),
|
||||
unavailableGamesVisible(false),
|
||||
passwordProtectedGamesHidden(false),
|
||||
showPasswordProtectedGames(true),
|
||||
maxPlayersFilterMin(-1),
|
||||
maxPlayersFilterMax(-1)
|
||||
{
|
||||
|
@ -237,9 +237,9 @@ void GamesProxyModel::setUnavailableGamesVisible(bool _unavailableGamesVisible)
|
|||
invalidateFilter();
|
||||
}
|
||||
|
||||
void GamesProxyModel::setPasswordProtectedGamesHidden(bool _passwordProtectedGamesHidden)
|
||||
void GamesProxyModel::setShowPasswordProtectedGames(bool _showPasswordProtectedGames)
|
||||
{
|
||||
passwordProtectedGamesHidden = _passwordProtectedGamesHidden;
|
||||
showPasswordProtectedGames = _showPasswordProtectedGames;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ void GamesProxyModel::setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlay
|
|||
void GamesProxyModel::resetFilterParameters()
|
||||
{
|
||||
unavailableGamesVisible = false;
|
||||
passwordProtectedGamesHidden = false;
|
||||
showPasswordProtectedGames = true;
|
||||
gameNameFilter = QString();
|
||||
creatorNameFilter = QString();
|
||||
gameTypeFilter.clear();
|
||||
|
@ -287,7 +287,7 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
|
|||
settings.beginGroup("filter_games");
|
||||
|
||||
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();
|
||||
maxPlayersFilterMin = settings.value("min_players", 1).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(
|
||||
"password_protected_games_hidden",
|
||||
passwordProtectedGamesHidden
|
||||
"show_password_protected_games",
|
||||
showPasswordProtectedGames
|
||||
);
|
||||
settings.setValue("game_name_filter", gameNameFilter);
|
||||
|
||||
|
@ -345,7 +345,7 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
|
|||
if (game.only_registered())
|
||||
return false;
|
||||
}
|
||||
if (passwordProtectedGamesHidden && game.with_password())
|
||||
if (!showPasswordProtectedGames && game.with_password())
|
||||
return false;
|
||||
if (!gameNameFilter.isEmpty())
|
||||
if (!QString::fromStdString(game.description()).contains(gameNameFilter, Qt::CaseInsensitive))
|
||||
|
|
|
@ -47,7 +47,7 @@ class GamesProxyModel : public QSortFilterProxyModel {
|
|||
private:
|
||||
ServerInfo_User *ownUser;
|
||||
bool unavailableGamesVisible;
|
||||
bool passwordProtectedGamesHidden;
|
||||
bool showPasswordProtectedGames;
|
||||
QString gameNameFilter, creatorNameFilter;
|
||||
QSet<int> gameTypeFilter;
|
||||
int maxPlayersFilterMin, maxPlayersFilterMax;
|
||||
|
@ -64,8 +64,8 @@ public:
|
|||
|
||||
bool getUnavailableGamesVisible() const { return unavailableGamesVisible; }
|
||||
void setUnavailableGamesVisible(bool _unavailableGamesVisible);
|
||||
bool getPasswordProtectedGamesHidden() const { return passwordProtectedGamesHidden; }
|
||||
void setPasswordProtectedGamesHidden(bool _passwordProtectedGamesHidden);
|
||||
bool getShowPasswordProtectedGames() const { return showPasswordProtectedGames; }
|
||||
void setShowPasswordProtectedGames(bool _showPasswordProtectedGames);
|
||||
QString getGameNameFilter() const { return gameNameFilter; }
|
||||
void setGameNameFilter(const QString &_gameNameFilter);
|
||||
QString getCreatorNameFilter() const { return creatorNameFilter; }
|
||||
|
|
Loading…
Reference in a new issue