mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 00:24:47 -07:00
Add modelDirty signal, add helper functions to gather all main and sub card types. (#5819)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
676ea0d5a7
commit
9b5f5595b0
3 changed files with 47 additions and 0 deletions
|
|
@ -472,6 +472,45 @@ QStringList CardDatabase::getAllMainCardTypes() const
|
|||
return types.values();
|
||||
}
|
||||
|
||||
QMap<QString, int> CardDatabase::getAllMainCardTypesWithCount() const
|
||||
{
|
||||
QMap<QString, int> typeCounts;
|
||||
QHashIterator<QString, CardInfoPtr> cardIterator(cards);
|
||||
|
||||
while (cardIterator.hasNext()) {
|
||||
QString type = cardIterator.next().value()->getMainCardType();
|
||||
typeCounts[type]++;
|
||||
}
|
||||
|
||||
return typeCounts;
|
||||
}
|
||||
|
||||
QMap<QString, int> CardDatabase::getAllSubCardTypesWithCount() const
|
||||
{
|
||||
QMap<QString, int> typeCounts;
|
||||
QHashIterator<QString, CardInfoPtr> cardIterator(cards);
|
||||
|
||||
while (cardIterator.hasNext()) {
|
||||
QString type = cardIterator.next().value()->getCardType();
|
||||
|
||||
QStringList parts = type.split(" — ");
|
||||
|
||||
if (parts.size() > 1) { // Ensure there are subtypes
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
QStringList subtypes = parts[1].split(" ", Qt::SkipEmptyParts);
|
||||
#else
|
||||
QStringList subtypes = parts[1].split(" ", QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
for (const QString &subtype : subtypes) {
|
||||
typeCounts[subtype]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return typeCounts;
|
||||
}
|
||||
|
||||
void CardDatabase::checkUnknownSets()
|
||||
{
|
||||
auto _sets = getSetList();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue