[DeckListModel] Refactor: Don't access underlying decklist for iteration

This commit is contained in:
RickyRister 2025-12-16 01:57:40 -08:00
parent 64bb5355ff
commit 49a4bb1a3c
7 changed files with 52 additions and 85 deletions

View file

@ -599,6 +599,16 @@ QList<ExactCard> DeckListModel::getCardsForZone(const QString &zoneName) const
return cards;
}
QList<QString> DeckListModel::getCardNames() const
{
auto nodes = deckList->getCardNodes();
QList<QString> names;
std::transform(nodes.cbegin(), nodes.cend(), std::back_inserter(names), [](auto node) { return node->getName(); });
return names;
}
QList<QString> DeckListModel::getZones() const
{
auto zoneNodes = deckList->getZoneNodes();
@ -632,7 +642,6 @@ int maxAllowedForLegality(const FormatRules &format, const QString &legality)
return -1; // unknown legality → treat as illegal
}
bool DeckListModel::isCardQuantityLegalForCurrentFormat(const CardInfoPtr cardInfo, int quantity)
{
auto formatRules = CardDatabaseManager::query()->getFormat(deckList->getGameFormat());

View file

@ -311,6 +311,7 @@ public:
[[nodiscard]] QList<ExactCard> getCards() const;
[[nodiscard]] QList<ExactCard> getCardsForZone(const QString &zoneName) const;
[[nodiscard]] QList<QString> getCardNames() const;
[[nodiscard]] QList<QString> getZones() const;
bool isCardLegalForCurrentFormat(CardInfoPtr cardInfo);
bool isCardQuantityLegalForCurrentFormat(CardInfoPtr cardInfo, int quantity);