Invert "Show" games, so all games are visible by default

- Fix #4185
This commit is contained in:
ZeldaZach 2025-01-25 00:41:57 -05:00
parent 50c1ce673d
commit 7d0b95e9d6
No known key found for this signature in database
5 changed files with 45 additions and 88 deletions

View file

@ -6,12 +6,10 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QGridLayout> #include <QGridLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QSpinBox> #include <QSpinBox>
#include <QVBoxLayout>
DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
const GamesProxyModel *_gamesProxyModel, const GamesProxyModel *_gamesProxyModel,
@ -24,17 +22,17 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
{QTime(1, 0), tr("1 hour")}, {QTime(1, 0), tr("1 hour")},
{QTime(2, 0), tr("2 hours")}}) {QTime(2, 0), tr("2 hours")}})
{ {
showBuddiesOnlyGames = new QCheckBox(tr("Hide 'buddies only' games")); hideBuddiesOnlyGames = new QCheckBox(tr("Hide 'buddies only' games"));
showBuddiesOnlyGames->setChecked(gamesProxyModel->getShowBuddiesOnlyGames()); hideBuddiesOnlyGames->setChecked(gamesProxyModel->getHideBuddiesOnlyGames());
showFullGames = new QCheckBox(tr("Hide full games")); hideFullGames = new QCheckBox(tr("Hide full games"));
showFullGames->setChecked(gamesProxyModel->getShowFullGames()); hideFullGames->setChecked(gamesProxyModel->getHideFullGames());
showGamesThatStarted = new QCheckBox(tr("Hide games that have started")); hideGamesThatStarted = new QCheckBox(tr("Hide games that have started"));
showGamesThatStarted->setChecked(gamesProxyModel->getShowGamesThatStarted()); hideGamesThatStarted->setChecked(gamesProxyModel->getHideGamesThatStarted());
showPasswordProtectedGames = new QCheckBox(tr("Hide password protected games")); hidePasswordProtectedGames = new QCheckBox(tr("Hide password protected games"));
showPasswordProtectedGames->setChecked(gamesProxyModel->getShowPasswordProtectedGames()); hidePasswordProtectedGames->setChecked(gamesProxyModel->getHidePasswordProtectedGames());
hideIgnoredUserGames = new QCheckBox(tr("Hide 'ignored user' games")); hideIgnoredUserGames = new QCheckBox(tr("Hide 'ignored user' games"));
hideIgnoredUserGames->setChecked(gamesProxyModel->getHideIgnoredUserGames()); hideIgnoredUserGames->setChecked(gamesProxyModel->getHideIgnoredUserGames());
@ -108,10 +106,10 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
maxPlayersGroupBox->setLayout(maxPlayersFilterLayout); maxPlayersGroupBox->setLayout(maxPlayersFilterLayout);
auto *restrictionsLayout = new QGridLayout; auto *restrictionsLayout = new QGridLayout;
restrictionsLayout->addWidget(showFullGames, 0, 0); restrictionsLayout->addWidget(hideFullGames, 0, 0);
restrictionsLayout->addWidget(showGamesThatStarted, 1, 0); restrictionsLayout->addWidget(hideGamesThatStarted, 1, 0);
restrictionsLayout->addWidget(showPasswordProtectedGames, 2, 0); restrictionsLayout->addWidget(hidePasswordProtectedGames, 2, 0);
restrictionsLayout->addWidget(showBuddiesOnlyGames, 3, 0); restrictionsLayout->addWidget(hideBuddiesOnlyGames, 3, 0);
restrictionsLayout->addWidget(hideIgnoredUserGames, 4, 0); restrictionsLayout->addWidget(hideIgnoredUserGames, 4, 0);
auto *restrictionsGroupBox = new QGroupBox(tr("Restrictions")); auto *restrictionsGroupBox = new QGroupBox(tr("Restrictions"));
@ -185,34 +183,24 @@ void DlgFilterGames::toggleSpectatorCheckboxEnabledness(bool spectatorsEnabled)
showOnlyIfSpectatorsCanSeeHands->setDisabled(!spectatorsEnabled); showOnlyIfSpectatorsCanSeeHands->setDisabled(!spectatorsEnabled);
} }
bool DlgFilterGames::getShowFullGames() const bool DlgFilterGames::getHideFullGames() const
{ {
return showFullGames->isChecked(); return hideFullGames->isChecked();
} }
bool DlgFilterGames::getShowGamesThatStarted() const bool DlgFilterGames::getHideGamesThatStarted() const
{ {
return showGamesThatStarted->isChecked(); return hideGamesThatStarted->isChecked();
} }
bool DlgFilterGames::getShowBuddiesOnlyGames() const bool DlgFilterGames::getHideBuddiesOnlyGames() const
{ {
return showBuddiesOnlyGames->isChecked(); return hideBuddiesOnlyGames->isChecked();
} }
void DlgFilterGames::setShowBuddiesOnlyGames(bool _showBuddiesOnlyGames) bool DlgFilterGames::getHidePasswordProtectedGames() const
{ {
showBuddiesOnlyGames->setChecked(_showBuddiesOnlyGames); return hidePasswordProtectedGames->isChecked();
}
bool DlgFilterGames::getShowPasswordProtectedGames() const
{
return showPasswordProtectedGames->isChecked();
}
void DlgFilterGames::setShowPasswordProtectedGames(bool _passwordProtectedGamesHidden)
{
showPasswordProtectedGames->setChecked(_passwordProtectedGamesHidden);
} }
bool DlgFilterGames::getHideIgnoredUserGames() const bool DlgFilterGames::getHideIgnoredUserGames() const
@ -220,31 +208,16 @@ bool DlgFilterGames::getHideIgnoredUserGames() const
return hideIgnoredUserGames->isChecked(); return hideIgnoredUserGames->isChecked();
} }
void DlgFilterGames::setHideIgnoredUserGames(bool _hideIgnoredUserGames)
{
hideIgnoredUserGames->setChecked(_hideIgnoredUserGames);
}
QString DlgFilterGames::getGameNameFilter() const QString DlgFilterGames::getGameNameFilter() const
{ {
return gameNameFilterEdit->text(); return gameNameFilterEdit->text();
} }
void DlgFilterGames::setGameNameFilter(const QString &_gameNameFilter)
{
gameNameFilterEdit->setText(_gameNameFilter);
}
QString DlgFilterGames::getCreatorNameFilter() const QString DlgFilterGames::getCreatorNameFilter() const
{ {
return creatorNameFilterEdit->text(); return creatorNameFilterEdit->text();
} }
void DlgFilterGames::setCreatorNameFilter(const QString &_creatorNameFilter)
{
creatorNameFilterEdit->setText(_creatorNameFilter);
}
QSet<int> DlgFilterGames::getGameTypeFilter() const QSet<int> DlgFilterGames::getGameTypeFilter() const
{ {
QSet<int> result; QSet<int> result;
@ -257,15 +230,6 @@ QSet<int> DlgFilterGames::getGameTypeFilter() const
return result; return result;
} }
void DlgFilterGames::setGameTypeFilter(const QSet<int> &_gameTypeFilter)
{
QMapIterator<int, QCheckBox *> i(gameTypeFilterCheckBoxes);
while (i.hasNext()) {
i.next();
i.value()->setChecked(_gameTypeFilter.contains(i.key()));
}
}
int DlgFilterGames::getMaxPlayersFilterMin() const int DlgFilterGames::getMaxPlayersFilterMin() const
{ {
return maxPlayersFilterMinSpinBox->value(); return maxPlayersFilterMinSpinBox->value();
@ -285,13 +249,6 @@ QTime DlgFilterGames::getMaxGameAge() const
return gameAgeMap.keys().at(index); return gameAgeMap.keys().at(index);
} }
void DlgFilterGames::setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlayersFilterMax)
{
maxPlayersFilterMinSpinBox->setValue(_maxPlayersFilterMin);
maxPlayersFilterMaxSpinBox->setValue(_maxPlayersFilterMax == -1 ? maxPlayersFilterMaxSpinBox->maximum()
: _maxPlayersFilterMax);
}
bool DlgFilterGames::getShowOnlyIfSpectatorsCanWatch() const bool DlgFilterGames::getShowOnlyIfSpectatorsCanWatch() const
{ {
return showOnlyIfSpectatorsCanWatch->isChecked(); return showOnlyIfSpectatorsCanWatch->isChecked();

View file

@ -21,10 +21,10 @@ class DlgFilterGames : public QDialog
Q_OBJECT Q_OBJECT
private: private:
QGroupBox *generalGroupBox; QGroupBox *generalGroupBox;
QCheckBox *showBuddiesOnlyGames; QCheckBox *hideBuddiesOnlyGames;
QCheckBox *showFullGames; QCheckBox *hideFullGames;
QCheckBox *showGamesThatStarted; QCheckBox *hideGamesThatStarted;
QCheckBox *showPasswordProtectedGames; QCheckBox *hidePasswordProtectedGames;
QCheckBox *hideIgnoredUserGames; QCheckBox *hideIgnoredUserGames;
QLineEdit *gameNameFilterEdit; QLineEdit *gameNameFilterEdit;
QLineEdit *creatorNameFilterEdit; QLineEdit *creatorNameFilterEdit;
@ -50,12 +50,12 @@ public:
const GamesProxyModel *_gamesProxyModel, const GamesProxyModel *_gamesProxyModel,
QWidget *parent = nullptr); QWidget *parent = nullptr);
bool getShowFullGames() const; bool getHideFullGames() const;
bool getShowGamesThatStarted() const; bool getHideGamesThatStarted() const;
bool getShowPasswordProtectedGames() const; bool getHidePasswordProtectedGames() const;
void setShowPasswordProtectedGames(bool _passwordProtectedGamesHidden); void setShowPasswordProtectedGames(bool _passwordProtectedGamesHidden);
bool getShowBuddiesOnlyGames() const; bool getHideBuddiesOnlyGames() const;
void setShowBuddiesOnlyGames(bool _showBuddiesOnlyGames); void setHideBuddiesOnlyGames(bool _hideBuddiesOnlyGames);
bool getHideIgnoredUserGames() const; bool getHideIgnoredUserGames() const;
void setHideIgnoredUserGames(bool _hideIgnoredUserGames); void setHideIgnoredUserGames(bool _hideIgnoredUserGames);
QString getGameNameFilter() const; QString getGameNameFilter() const;

View file

@ -151,10 +151,10 @@ void GameSelector::actSetFilter()
if (!dlg.exec()) if (!dlg.exec())
return; return;
gameListProxyModel->setShowBuddiesOnlyGames(dlg.getShowBuddiesOnlyGames()); gameListProxyModel->setHideBuddiesOnlyGames(dlg.getHideBuddiesOnlyGames());
gameListProxyModel->setShowFullGames(dlg.getShowFullGames()); gameListProxyModel->setHideFullGames(dlg.getHideFullGames());
gameListProxyModel->setShowGamesThatStarted(dlg.getShowGamesThatStarted()); gameListProxyModel->setHideGamesThatStarted(dlg.getHideGamesThatStarted());
gameListProxyModel->setShowPasswordProtectedGames(dlg.getShowPasswordProtectedGames()); gameListProxyModel->setHidePasswordProtectedGames(dlg.getHidePasswordProtectedGames());
gameListProxyModel->setHideIgnoredUserGames(dlg.getHideIgnoredUserGames()); gameListProxyModel->setHideIgnoredUserGames(dlg.getHideIgnoredUserGames());
gameListProxyModel->setGameNameFilter(dlg.getGameNameFilter()); gameListProxyModel->setGameNameFilter(dlg.getGameNameFilter());
gameListProxyModel->setCreatorNameFilter(dlg.getCreatorNameFilter()); gameListProxyModel->setCreatorNameFilter(dlg.getCreatorNameFilter());

View file

@ -284,7 +284,7 @@ GamesProxyModel::GamesProxyModel(QObject *parent, const UserListProxy *_userList
setDynamicSortFilter(true); setDynamicSortFilter(true);
} }
void GamesProxyModel::setShowBuddiesOnlyGames(bool _showBuddiesOnlyGames) void GamesProxyModel::setHideBuddiesOnlyGames(bool _showBuddiesOnlyGames)
{ {
hideBuddiesOnlyGames = _showBuddiesOnlyGames; hideBuddiesOnlyGames = _showBuddiesOnlyGames;
invalidateFilter(); invalidateFilter();
@ -296,19 +296,19 @@ void GamesProxyModel::setHideIgnoredUserGames(bool _hideIgnoredUserGames)
invalidateFilter(); invalidateFilter();
} }
void GamesProxyModel::setShowFullGames(bool _showFullGames) void GamesProxyModel::setHideFullGames(bool _showFullGames)
{ {
hideFullGames = _showFullGames; hideFullGames = _showFullGames;
invalidateFilter(); invalidateFilter();
} }
void GamesProxyModel::setShowGamesThatStarted(bool _showGamesThatStarted) void GamesProxyModel::setHideGamesThatStarted(bool _showGamesThatStarted)
{ {
hideGamesThatStarted = _showGamesThatStarted; hideGamesThatStarted = _showGamesThatStarted;
invalidateFilter(); invalidateFilter();
} }
void GamesProxyModel::setShowPasswordProtectedGames(bool _showPasswordProtectedGames) void GamesProxyModel::setHidePasswordProtectedGames(bool _showPasswordProtectedGames)
{ {
hidePasswordProtectedGames = _showPasswordProtectedGames; hidePasswordProtectedGames = _showPasswordProtectedGames;
invalidateFilter(); invalidateFilter();

View file

@ -90,31 +90,31 @@ private:
public: public:
explicit GamesProxyModel(QObject *parent = nullptr, const UserListProxy *_userListProxy = nullptr); explicit GamesProxyModel(QObject *parent = nullptr, const UserListProxy *_userListProxy = nullptr);
bool getShowBuddiesOnlyGames() const bool getHideBuddiesOnlyGames() const
{ {
return hideBuddiesOnlyGames; return hideBuddiesOnlyGames;
} }
void setShowBuddiesOnlyGames(bool _showBuddiesOnlyGames); void setHideBuddiesOnlyGames(bool _showBuddiesOnlyGames);
bool getHideIgnoredUserGames() const bool getHideIgnoredUserGames() const
{ {
return hideIgnoredUserGames; return hideIgnoredUserGames;
} }
void setHideIgnoredUserGames(bool _hideIgnoredUserGames); void setHideIgnoredUserGames(bool _hideIgnoredUserGames);
bool getShowFullGames() const bool getHideFullGames() const
{ {
return hideFullGames; return hideFullGames;
} }
void setShowFullGames(bool _showFullGames); void setHideFullGames(bool _showFullGames);
bool getShowGamesThatStarted() const bool getHideGamesThatStarted() const
{ {
return hideGamesThatStarted; return hideGamesThatStarted;
} }
void setShowGamesThatStarted(bool _showGamesThatStarted); void setHideGamesThatStarted(bool _showGamesThatStarted);
bool getShowPasswordProtectedGames() const bool getHidePasswordProtectedGames() const
{ {
return hidePasswordProtectedGames; return hidePasswordProtectedGames;
} }
void setShowPasswordProtectedGames(bool _showPasswordProtectedGames); void setHidePasswordProtectedGames(bool _showPasswordProtectedGames);
QString getGameNameFilter() const QString getGameNameFilter() const
{ {
return gameNameFilter; return gameNameFilter;