mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-22 17:45:09 -07:00
[Card] Add a Tags filter to the visual card database
This commit is contained in:
parent
0ea0e231bf
commit
ea38af774a
9 changed files with 288 additions and 2 deletions
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue