mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-11 04:43:56 -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()
|
void DlgSelectSetForCards::actClear()
|
||||||
{
|
{
|
||||||
emit deckAboutToBeModified(tr("Cleared all printing information."));
|
emit deckAboutToBeModified(tr("Cleared all printing information."));
|
||||||
model->getDeckList()->forEachCard(CardNodeFunction::ClearPrintingData());
|
model->forEachCard(CardNodeFunction::ClearPrintingData());
|
||||||
emit deckModified();
|
emit deckModified();
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
@ -186,8 +186,8 @@ void DlgSelectSetForCards::actClear()
|
||||||
void DlgSelectSetForCards::actSetAllToPreferred()
|
void DlgSelectSetForCards::actSetAllToPreferred()
|
||||||
{
|
{
|
||||||
emit deckAboutToBeModified(tr("Set all printings to preferred."));
|
emit deckAboutToBeModified(tr("Set all printings to preferred."));
|
||||||
model->getDeckList()->forEachCard(CardNodeFunction::ClearPrintingData());
|
model->forEachCard(CardNodeFunction::ClearPrintingData());
|
||||||
model->getDeckList()->forEachCard(CardNodeFunction::SetProviderIdToPreferred());
|
model->forEachCard(CardNodeFunction::SetProviderIdToPreferred());
|
||||||
emit deckModified();
|
emit deckModified();
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,7 @@ ArchidektApiResponseDeckDisplayWidget::ArchidektApiResponseDeckDisplayWidget(QWi
|
||||||
connect(model, &DeckListModel::modelReset, this, &ArchidektApiResponseDeckDisplayWidget::decklistModelReset);
|
connect(model, &DeckListModel::modelReset, this, &ArchidektApiResponseDeckDisplayWidget::decklistModelReset);
|
||||||
model->getDeckList()->loadFromStream_Plain(deckStream, false);
|
model->getDeckList()->loadFromStream_Plain(deckStream, false);
|
||||||
|
|
||||||
model->getDeckList()->forEachCard(CardNodeFunction::ResolveProviderId());
|
model->forEachCard(CardNodeFunction::ResolveProviderId());
|
||||||
|
|
||||||
model->rebuildTree();
|
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -561,6 +561,11 @@ void DeckListModel::setDeckList(DeckList *_deck)
|
||||||
rebuildTree();
|
rebuildTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeckListModel::forEachCard(const std::function<void(InnerDecklistNode *, DecklistCardNode *)> &func)
|
||||||
|
{
|
||||||
|
deckList->forEachCard(func);
|
||||||
|
}
|
||||||
|
|
||||||
static QList<ExactCard> cardNodesToExactCards(QList<const DecklistCardNode *> nodes)
|
static QList<ExactCard> cardNodesToExactCards(QList<const DecklistCardNode *> nodes)
|
||||||
{
|
{
|
||||||
QList<ExactCard> cards;
|
QList<ExactCard> cards;
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,13 @@ public:
|
||||||
}
|
}
|
||||||
void setDeckList(DeckList *_deck);
|
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
|
* @brief Creates a list consisting of the entries of the model mapped into ExactCards (with each entry looked up
|
||||||
* in the card database).
|
* in the card database).
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue