remove one last direct iteration of decklist

This commit is contained in:
RickyRister 2025-12-20 20:40:39 -08:00
parent 46c99889d7
commit b0cf289b71
3 changed files with 19 additions and 4 deletions

View file

@ -386,15 +386,15 @@ void DeckEditorDeckDockWidget::updateBannerCardComboBox()
// Collect unique (name, providerId) pairs
QSet<QPair<QString, QString>> bannerCardSet;
QList<const DecklistCardNode *> cardsInDeck = deckModel->getDeckList()->getCardNodes();
QList<CardRef> cardsInDeck = deckModel->getCardRefs();
for (auto currentCard : cardsInDeck) {
if (!CardDatabaseManager::query()->getCard(currentCard->toCardRef())) {
for (auto cardRef : cardsInDeck) {
if (!CardDatabaseManager::query()->getCard(cardRef)) {
continue;
}
// Insert one entry per distinct card, ignore copies
bannerCardSet.insert({currentCard->getName(), currentCard->getCardProviderId()});
bannerCardSet.insert({cardRef.name, cardRef.providerId});
}
// Convert to sorted list

View file

@ -605,6 +605,17 @@ QList<QString> DeckListModel::getCardNames() const
return names;
}
QList<CardRef> DeckListModel::getCardRefs() const
{
auto nodes = deckList->getCardNodes();
QList<CardRef> cardRefs;
std::transform(nodes.cbegin(), nodes.cend(), std::back_inserter(cardRefs),
[](auto node) { return node->toCardRef(); });
return cardRefs;
}
QList<QString> DeckListModel::getZones() const
{
auto zoneNodes = deckList->getZoneNodes();

View file

@ -330,6 +330,10 @@ public:
* @brief Gets a deduplicated list of all card names that appear in the model
*/
[[nodiscard]] QList<QString> getCardNames() const;
/**
* @brief Gets a deduplicated list of all CardRefs that appear in the model
*/
[[nodiscard]] QList<CardRef> getCardRefs() const;
/**
* @brief Gets a list of all zone names that appear in the model
*/