[Card] Add a Tags filter to the visual card database

This commit is contained in:
Lukas Brübach 2026-09-21 13:21:09 +02:00
parent 0ea0e231bf
commit ea38af774a
9 changed files with 288 additions and 2 deletions

View file

@ -1,6 +1,7 @@
#include "card_database_querier.h"
#include "../card_info.h"
#include "../game_specific_terms.h"
#include "../printing/exact_card.h"
#include "../set/card_set_comparator.h"
#include "card_database.h"
@ -23,6 +24,7 @@ void CardDatabaseQuerier::invalidateCaches()
mainCardTypeCountsCache.clear();
subCardTypeCountsCache.clear();
formatsCountCache.clear();
tagCountsCache.clear();
}
/**
@ -359,6 +361,21 @@ FormatRulesPtr CardDatabaseQuerier::getFormat(const QString &formatName) const
return db->formats.value(formatName.toLower());
}
QMap<QString, int> CardDatabaseQuerier::getAllTagsWithCount() const
{
if (tagCountsCache.isEmpty()) {
for (const auto &card : db->cards.values()) {
const QStringList tags = card->getProperty(Mtg::Tags).split(" ", Qt::SkipEmptyParts);
for (const QString &tag : tags) {
tagCountsCache[tag]++;
}
}
}
return tagCountsCache;
}
QMap<QString, int> CardDatabaseQuerier::getAllFormatsWithCount() const
{
if (formatsCountCache.isEmpty()) {