mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 17:44:01 -07:00
[DeckListModel] remove more access to underlying decklist for iteration
This commit is contained in:
parent
73a90bdf38
commit
46c99889d7
4 changed files with 16 additions and 6 deletions
|
|
@ -178,7 +178,7 @@ void DlgSelectSetForCards::actOK()
|
|||
void DlgSelectSetForCards::actClear()
|
||||
{
|
||||
emit deckAboutToBeModified(tr("Cleared all printing information."));
|
||||
model->getDeckList()->forEachCard(CardNodeFunction::ClearPrintingData());
|
||||
model->forEachCard(CardNodeFunction::ClearPrintingData());
|
||||
emit deckModified();
|
||||
accept();
|
||||
}
|
||||
|
|
@ -186,8 +186,8 @@ void DlgSelectSetForCards::actClear()
|
|||
void DlgSelectSetForCards::actSetAllToPreferred()
|
||||
{
|
||||
emit deckAboutToBeModified(tr("Set all printings to preferred."));
|
||||
model->getDeckList()->forEachCard(CardNodeFunction::ClearPrintingData());
|
||||
model->getDeckList()->forEachCard(CardNodeFunction::SetProviderIdToPreferred());
|
||||
model->forEachCard(CardNodeFunction::ClearPrintingData());
|
||||
model->forEachCard(CardNodeFunction::SetProviderIdToPreferred());
|
||||
emit deckModified();
|
||||
accept();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,9 +70,7 @@ ArchidektApiResponseDeckDisplayWidget::ArchidektApiResponseDeckDisplayWidget(QWi
|
|||
connect(model, &DeckListModel::modelReset, this, &ArchidektApiResponseDeckDisplayWidget::decklistModelReset);
|
||||
model->getDeckList()->loadFromStream_Plain(deckStream, false);
|
||||
|
||||
model->getDeckList()->forEachCard(CardNodeFunction::ResolveProviderId());
|
||||
|
||||
model->rebuildTree();
|
||||
model->forEachCard(CardNodeFunction::ResolveProviderId());
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -561,6 +561,11 @@ void DeckListModel::setDeckList(DeckList *_deck)
|
|||
rebuildTree();
|
||||
}
|
||||
|
||||
void DeckListModel::forEachCard(const std::function<void(InnerDecklistNode *, DecklistCardNode *)> &func)
|
||||
{
|
||||
deckList->forEachCard(func);
|
||||
}
|
||||
|
||||
static QList<ExactCard> cardNodesToExactCards(QList<const DecklistCardNode *> nodes)
|
||||
{
|
||||
QList<ExactCard> cards;
|
||||
|
|
|
|||
|
|
@ -309,6 +309,13 @@ public:
|
|||
}
|
||||
void setDeckList(DeckList *_deck);
|
||||
|
||||
/**
|
||||
* @brief Apply a function to every card in the deck tree.
|
||||
*
|
||||
* @param func Function taking (zone node, card node).
|
||||
*/
|
||||
void forEachCard(const std::function<void(InnerDecklistNode *, DecklistCardNode *)> &func);
|
||||
|
||||
/**
|
||||
* @brief Creates a list consisting of the entries of the model mapped into ExactCards (with each entry looked up
|
||||
* in the card database).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue