mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Change filter hint text to "Games shown: X / Y" and fix user-game segfault (#3973)
This commit is contained in:
parent
9246c190fa
commit
1988e4558f
4 changed files with 51 additions and 61 deletions
|
|
@ -38,7 +38,7 @@ const QString GamesModel::getGameCreatedString(const int secs) const
|
|||
} else { // from 1 hr onward we show hrs
|
||||
int hours = secs / SECS_PER_HOUR;
|
||||
if (secs % SECS_PER_HOUR >= SECS_PER_MIN * 30) // if the room is open for 1hr 30 mins, we round to 2hrs
|
||||
hours++;
|
||||
++hours;
|
||||
ret = QString("%1+ h").arg(QString::number(hours));
|
||||
}
|
||||
return ret;
|
||||
|
|
@ -314,11 +314,26 @@ void GamesProxyModel::setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlay
|
|||
invalidateFilter();
|
||||
}
|
||||
|
||||
int GamesProxyModel::getNumFilteredGames() const
|
||||
{
|
||||
GamesModel *model = qobject_cast<GamesModel *>(sourceModel());
|
||||
if (!model)
|
||||
return 0;
|
||||
|
||||
int numFilteredGames = 0;
|
||||
for (int row = 0; row < model->rowCount(); ++row) {
|
||||
if (!filterAcceptsRow(row)) {
|
||||
++numFilteredGames;
|
||||
}
|
||||
}
|
||||
return numFilteredGames;
|
||||
}
|
||||
|
||||
void GamesProxyModel::resetFilterParameters()
|
||||
{
|
||||
unavailableGamesVisible = DEFAULT_UNAVAILABLE_GAMES_VISIBLE;
|
||||
showPasswordProtectedGames = DEFAULT_SHOW_PASSWORD_PROTECTED_GAMES;
|
||||
showBuddiesOnlyGames = DEFAULT_SHOW_BUDDIES_ONLY_GAMES;
|
||||
unavailableGamesVisible = false;
|
||||
showPasswordProtectedGames = true;
|
||||
showBuddiesOnlyGames = true;
|
||||
gameNameFilter = QString();
|
||||
creatorNameFilter = QString();
|
||||
gameTypeFilter.clear();
|
||||
|
|
@ -368,40 +383,12 @@ void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameType
|
|||
settingsCache->gameFilters().setMaxPlayers(maxPlayersFilterMax);
|
||||
}
|
||||
|
||||
int GamesProxyModel::getNumberOfAlteredFilters() const
|
||||
bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
|
||||
{
|
||||
int numFiltersAltered = 0;
|
||||
if (showBuddiesOnlyGames != DEFAULT_SHOW_BUDDIES_ONLY_GAMES) {
|
||||
numFiltersAltered++;
|
||||
}
|
||||
if (hideIgnoredUserGames) {
|
||||
numFiltersAltered++;
|
||||
}
|
||||
if (unavailableGamesVisible != DEFAULT_UNAVAILABLE_GAMES_VISIBLE) {
|
||||
numFiltersAltered++;
|
||||
}
|
||||
if (showPasswordProtectedGames != DEFAULT_SHOW_PASSWORD_PROTECTED_GAMES) {
|
||||
numFiltersAltered++;
|
||||
}
|
||||
if (!gameNameFilter.isEmpty()) {
|
||||
numFiltersAltered++;
|
||||
}
|
||||
if (!creatorNameFilter.isEmpty()) {
|
||||
numFiltersAltered++;
|
||||
}
|
||||
if (!gameTypeFilter.isEmpty()) {
|
||||
numFiltersAltered++;
|
||||
}
|
||||
if (maxPlayersFilterMin != -1 && maxPlayersFilterMin != 1) {
|
||||
numFiltersAltered++;
|
||||
}
|
||||
if (maxPlayersFilterMax != -1 && maxPlayersFilterMax != DEFAULT_MAX_PLAYERS_MAX) {
|
||||
numFiltersAltered++;
|
||||
}
|
||||
return numFiltersAltered;
|
||||
return filterAcceptsRow(sourceRow);
|
||||
}
|
||||
|
||||
bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
|
||||
bool GamesProxyModel::filterAcceptsRow(int sourceRow) const
|
||||
{
|
||||
GamesModel *model = qobject_cast<GamesModel *>(sourceModel());
|
||||
if (!model)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue