Game filter for games created by buddy (#5991)

This commit is contained in:
RickyRister 2025-06-14 08:10:24 -07:00 committed by GitHub
parent 6cb4e203f1
commit 61a6b32137
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 45 additions and 2 deletions

View file

@ -160,6 +160,7 @@ void GameSelector::actSetFilter()
gameListProxyModel->setHideGamesThatStarted(dlg.getHideGamesThatStarted());
gameListProxyModel->setHidePasswordProtectedGames(dlg.getHidePasswordProtectedGames());
gameListProxyModel->setHideIgnoredUserGames(dlg.getHideIgnoredUserGames());
gameListProxyModel->setHideNotBuddyCreatedGames(dlg.getHideNotBuddyCreatedGames());
gameListProxyModel->setGameNameFilter(dlg.getGameNameFilter());
gameListProxyModel->setCreatorNameFilter(dlg.getCreatorNameFilter());
gameListProxyModel->setGameTypeFilter(dlg.getGameTypeFilter());

View file

@ -314,6 +314,12 @@ void GamesProxyModel::setHidePasswordProtectedGames(bool _showPasswordProtectedG
invalidateFilter();
}
void GamesProxyModel::setHideNotBuddyCreatedGames(bool value)
{
hideNotBuddyCreatedGames = value;
invalidateFilter();
}
void GamesProxyModel::setGameNameFilter(const QString &_gameNameFilter)
{
gameNameFilter = _gameNameFilter;
@ -391,6 +397,7 @@ void GamesProxyModel::resetFilterParameters()
hidePasswordProtectedGames = false;
hideBuddiesOnlyGames = false;
hideIgnoredUserGames = false;
hideNotBuddyCreatedGames = false;
gameNameFilter = QString();
creatorNameFilter = QString();
gameTypeFilter.clear();
@ -408,8 +415,8 @@ void GamesProxyModel::resetFilterParameters()
bool GamesProxyModel::areFilterParametersSetToDefaults() const
{
return !hideFullGames && !hideGamesThatStarted && !hidePasswordProtectedGames && !hideBuddiesOnlyGames &&
!hideIgnoredUserGames && gameNameFilter.isEmpty() && creatorNameFilter.isEmpty() &&
gameTypeFilter.isEmpty() && maxPlayersFilterMin == DEFAULT_MAX_PLAYERS_MIN &&
!hideIgnoredUserGames && !hideNotBuddyCreatedGames && gameNameFilter.isEmpty() &&
creatorNameFilter.isEmpty() && gameTypeFilter.isEmpty() && maxPlayersFilterMin == DEFAULT_MAX_PLAYERS_MIN &&
maxPlayersFilterMax == DEFAULT_MAX_PLAYERS_MAX && maxGameAge == DEFAULT_MAX_GAME_AGE &&
!showOnlyIfSpectatorsCanWatch && !showSpectatorPasswordProtected && !showOnlyIfSpectatorsCanChat &&
!showOnlyIfSpectatorsCanSeeHands;
@ -423,6 +430,7 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
hidePasswordProtectedGames = gameFilters.isHidePasswordProtectedGames();
hideIgnoredUserGames = gameFilters.isHideIgnoredUserGames();
hideBuddiesOnlyGames = gameFilters.isHideBuddiesOnlyGames();
hideNotBuddyCreatedGames = gameFilters.isHideNotBuddyCreatedGames();
gameNameFilter = gameFilters.getGameNameFilter();
creatorNameFilter = gameFilters.getCreatorNameFilter();
maxPlayersFilterMin = gameFilters.getMinPlayers();
@ -452,6 +460,7 @@ void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameType
gameFilters.setHideGamesThatStarted(hideGamesThatStarted);
gameFilters.setHidePasswordProtectedGames(hidePasswordProtectedGames);
gameFilters.setHideIgnoredUserGames(hideIgnoredUserGames);
gameFilters.setHideNotBuddyCreatedGames(hideNotBuddyCreatedGames);
gameFilters.setGameNameFilter(gameNameFilter);
gameFilters.setCreatorNameFilter(creatorNameFilter);
@ -498,6 +507,9 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow) const
if (hideIgnoredUserGames && userListProxy->isUserIgnored(QString::fromStdString(game.creator_info().name()))) {
return false;
}
if (hideNotBuddyCreatedGames && !userListProxy->isUserBuddy(QString::fromStdString(game.creator_info().name()))) {
return false;
}
if (hideFullGames && game.player_count() == game.max_players())
return false;
if (hideGamesThatStarted && game.started())

View file

@ -80,6 +80,7 @@ private:
bool hideFullGames;
bool hideGamesThatStarted;
bool hidePasswordProtectedGames;
bool hideNotBuddyCreatedGames;
QString gameNameFilter, creatorNameFilter;
QSet<int> gameTypeFilter;
quint32 maxPlayersFilterMin, maxPlayersFilterMax;
@ -115,6 +116,11 @@ public:
return hidePasswordProtectedGames;
}
void setHidePasswordProtectedGames(bool _showPasswordProtectedGames);
bool getHideNotBuddyCreatedGames() const
{
return hideNotBuddyCreatedGames;
}
void setHideNotBuddyCreatedGames(bool value);
QString getGameNameFilter() const
{
return gameNameFilter;