extract method

This commit is contained in:
RickyRister 2025-12-16 02:25:44 -08:00
parent a77246c5f7
commit 64c5a678c1

View file

@ -561,10 +561,8 @@ void DeckListModel::setDeckList(DeckList *_deck)
rebuildTree(); rebuildTree();
} }
QList<ExactCard> DeckListModel::getCards() const static QList<ExactCard> cardNodesToExactCards(QList<const DecklistCardNode *> nodes)
{ {
auto nodes = deckList->getCardNodes();
QList<ExactCard> cards; QList<ExactCard> cards;
for (auto node : nodes) { for (auto node : nodes) {
ExactCard card = CardDatabaseManager::query()->getCard(node->toCardRef()); ExactCard card = CardDatabaseManager::query()->getCard(node->toCardRef());
@ -580,23 +578,16 @@ QList<ExactCard> DeckListModel::getCards() const
return cards; return cards;
} }
QList<ExactCard> DeckListModel::getCards() const
{
auto nodes = deckList->getCardNodes();
return cardNodesToExactCards(nodes);
}
QList<ExactCard> DeckListModel::getCardsForZone(const QString &zoneName) const QList<ExactCard> DeckListModel::getCardsForZone(const QString &zoneName) const
{ {
auto nodes = deckList->getCardNodes({zoneName}); auto nodes = deckList->getCardNodes({zoneName});
return cardNodesToExactCards(nodes);
QList<ExactCard> cards;
for (auto node : nodes) {
ExactCard card = CardDatabaseManager::query()->getCard(node->toCardRef());
if (card) {
for (int k = 0; k < node->getNumber(); ++k) {
cards.append(card);
}
} else {
qDebug() << "Card not found in database!";
}
}
return cards;
} }
QList<QString> DeckListModel::getCardNames() const QList<QString> DeckListModel::getCardNames() const