mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-17 07:52:16 -07:00
New DeckList method to return cards as CardInfoPtrs
Saner update to prevent crashes.
This commit is contained in:
parent
f994ffa02d
commit
443f8717a3
6 changed files with 75 additions and 31 deletions
|
|
@ -81,7 +81,7 @@ void TabDeckEditorVisual::createCentralFrame()
|
|||
void TabDeckEditorVisual::onDeckChanged()
|
||||
{
|
||||
AbstractTabDeckEditor::onDeckChanged();
|
||||
tabContainer->visualDeckView->updateDisplay();
|
||||
tabContainer->visualDeckView->decklistDataChanged(QModelIndex(), QModelIndex());
|
||||
tabContainer->deckAnalytics->refreshDisplays(deckDockWidget->deckModel);
|
||||
tabContainer->sampleHandWidget->setDeckModel(deckDockWidget->deckModel);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -309,6 +309,8 @@ void DeckEditorDeckDockWidget::setDeck(DeckLoader *_deck)
|
|||
deckView->expandAll();
|
||||
|
||||
deckTagsDisplayWidget->connectDeckList(deckModel->getDeckList());
|
||||
|
||||
emit deckChanged();
|
||||
}
|
||||
|
||||
DeckLoader *DeckEditorDeckDockWidget::getDeckList()
|
||||
|
|
@ -325,6 +327,7 @@ void DeckEditorDeckDockWidget::cleanDeck()
|
|||
nameEdit->setText(QString());
|
||||
commentsEdit->setText(QString());
|
||||
hashLabel->setText(QString());
|
||||
emit deckChanged();
|
||||
updateBannerCardComboBox();
|
||||
deckTagsDisplayWidget->connectDeckList(deckModel->getDeckList());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,35 +205,8 @@ void VisualDeckEditorWidget::populateCards()
|
|||
if (!deck_list_model)
|
||||
return;
|
||||
DeckList *decklist = deck_list_model->getDeckList();
|
||||
if (!decklist)
|
||||
return;
|
||||
InnerDecklistNode *listRoot = decklist->getRoot();
|
||||
if (!listRoot)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < listRoot->size(); i++) {
|
||||
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
|
||||
if (!currentZone)
|
||||
continue;
|
||||
for (int j = 0; j < currentZone->size(); j++) {
|
||||
DecklistCardNode *currentCard = dynamic_cast<DecklistCardNode *>(currentZone->at(j));
|
||||
if (!currentCard)
|
||||
continue;
|
||||
for (int k = 0; k < currentCard->getNumber(); ++k) {
|
||||
CardInfoPtr info = CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
|
||||
currentCard->getName(), currentCard->getCardProviderId());
|
||||
if (info) {
|
||||
if (currentZone->getName() == DECK_ZONE_MAIN) {
|
||||
mainDeckCards->append(info);
|
||||
} else if (currentZone->getName() == DECK_ZONE_SIDE) {
|
||||
sideboardCards->append(info);
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Card not found in database!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mainDeckCards = decklist->getCardsAsCardInfoPtrsForZone(DECK_ZONE_MAIN);
|
||||
sideboardCards = decklist->getCardsAsCardInfoPtrsForZone(DECK_ZONE_SIDE);
|
||||
}
|
||||
|
||||
void VisualDeckEditorWidget::sortCardList(const QStringList properties, Qt::SortOrder order = Qt::AscendingOrder)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ public:
|
|||
void sortCardList(QStringList properties, Qt::SortOrder order);
|
||||
void setDeckList(const DeckList &new_deck_list_model);
|
||||
|
||||
public slots:
|
||||
void decklistDataChanged(QModelIndex topLeft, QModelIndex bottomRight);
|
||||
|
||||
signals:
|
||||
void activeCardChanged(CardInfoPtr activeCard);
|
||||
void mainboardCardClicked(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance);
|
||||
|
|
@ -35,7 +38,6 @@ protected slots:
|
|||
void onHover(CardInfoPtr hoveredCard);
|
||||
void onMainboardClick(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance);
|
||||
void onSideboardClick(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance);
|
||||
void decklistDataChanged(QModelIndex topLeft, QModelIndex bottomRight);
|
||||
void activeSortCriteriaChanged();
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue