mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-02 11:33:55 -07:00
[DeckDockWidget] clean up grouping and format sync (#6467)
* [DeckDockWidget] clean up grouping and format sync * refresh legalities in rebuildTree * extract applyActiveGroupCriteria * Fix build failure
This commit is contained in:
parent
df9a8b2272
commit
987fe9c9e2
3 changed files with 19 additions and 15 deletions
|
|
@ -64,6 +64,8 @@ void DeckEditorDeckDockWidget::createDeckDock()
|
||||||
connect(deckStateManager, &DeckStateManager::focusIndexChanged, this, &DeckEditorDeckDockWidget::setSelectedIndex);
|
connect(deckStateManager, &DeckStateManager::focusIndexChanged, this, &DeckEditorDeckDockWidget::setSelectedIndex);
|
||||||
connect(deckStateManager, &DeckStateManager::deckReplaced, this,
|
connect(deckStateManager, &DeckStateManager::deckReplaced, this,
|
||||||
&DeckEditorDeckDockWidget::syncDisplayWidgetsToModel);
|
&DeckEditorDeckDockWidget::syncDisplayWidgetsToModel);
|
||||||
|
connect(deckStateManager, &DeckStateManager::deckReplaced, this,
|
||||||
|
&DeckEditorDeckDockWidget::applyActiveGroupCriteria);
|
||||||
|
|
||||||
deckView = new QTreeView();
|
deckView = new QTreeView();
|
||||||
deckView->setObjectName("deckView");
|
deckView->setObjectName("deckView");
|
||||||
|
|
@ -174,11 +176,8 @@ void DeckEditorDeckDockWidget::createDeckDock()
|
||||||
activeGroupCriteriaComboBox->addItem(tr("Main Type"), DeckListModelGroupCriteria::MAIN_TYPE);
|
activeGroupCriteriaComboBox->addItem(tr("Main Type"), DeckListModelGroupCriteria::MAIN_TYPE);
|
||||||
activeGroupCriteriaComboBox->addItem(tr("Mana Cost"), DeckListModelGroupCriteria::MANA_COST);
|
activeGroupCriteriaComboBox->addItem(tr("Mana Cost"), DeckListModelGroupCriteria::MANA_COST);
|
||||||
activeGroupCriteriaComboBox->addItem(tr("Colors"), DeckListModelGroupCriteria::COLOR);
|
activeGroupCriteriaComboBox->addItem(tr("Colors"), DeckListModelGroupCriteria::COLOR);
|
||||||
connect(activeGroupCriteriaComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this]() {
|
connect(activeGroupCriteriaComboBox, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||||
getModel()->setActiveGroupCriteria(static_cast<DeckListModelGroupCriteria::Type>(
|
&DeckEditorDeckDockWidget::applyActiveGroupCriteria);
|
||||||
activeGroupCriteriaComboBox->currentData(Qt::UserRole).toInt()));
|
|
||||||
getModel()->sort(deckView->header()->sortIndicatorSection(), deckView->header()->sortIndicatorOrder());
|
|
||||||
});
|
|
||||||
|
|
||||||
aIncrement = new QAction(QString(), this);
|
aIncrement = new QAction(QString(), this);
|
||||||
aIncrement->setIcon(QPixmap("theme:icons/increment"));
|
aIncrement->setIcon(QPixmap("theme:icons/increment"));
|
||||||
|
|
@ -297,7 +296,6 @@ void DeckEditorDeckDockWidget::initializeFormats()
|
||||||
|
|
||||||
QString format = deckStateManager->getMetadata().gameFormat;
|
QString format = deckStateManager->getMetadata().gameFormat;
|
||||||
if (!format.isEmpty()) {
|
if (!format.isEmpty()) {
|
||||||
getModel()->setActiveFormat(format);
|
|
||||||
formatComboBox->setCurrentIndex(formatComboBox->findData(format));
|
formatComboBox->setCurrentIndex(formatComboBox->findData(format));
|
||||||
} else {
|
} else {
|
||||||
// Ensure no selection is visible initially
|
// Ensure no selection is visible initially
|
||||||
|
|
@ -429,6 +427,13 @@ void DeckEditorDeckDockWidget::writeBannerCard(int index)
|
||||||
deckStateManager->setBannerCard(bannerCard);
|
deckStateManager->setBannerCard(bannerCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeckEditorDeckDockWidget::applyActiveGroupCriteria()
|
||||||
|
{
|
||||||
|
getModel()->setActiveGroupCriteria(
|
||||||
|
static_cast<DeckListModelGroupCriteria::Type>(activeGroupCriteriaComboBox->currentData(Qt::UserRole).toInt()));
|
||||||
|
getModel()->sort(deckView->header()->sortIndicatorSection(), deckView->header()->sortIndicatorOrder());
|
||||||
|
}
|
||||||
|
|
||||||
void DeckEditorDeckDockWidget::updateShowBannerCardComboBox(const bool visible)
|
void DeckEditorDeckDockWidget::updateShowBannerCardComboBox(const bool visible)
|
||||||
{
|
{
|
||||||
bannerCardLabel->setHidden(!visible);
|
bannerCardLabel->setHidden(!visible);
|
||||||
|
|
@ -477,16 +482,14 @@ void DeckEditorDeckDockWidget::syncDisplayWidgetsToModel()
|
||||||
updateBannerCardComboBox();
|
updateBannerCardComboBox();
|
||||||
bannerCardComboBox->blockSignals(false);
|
bannerCardComboBox->blockSignals(false);
|
||||||
updateHash();
|
updateHash();
|
||||||
sortDeckModelToDeckView();
|
|
||||||
|
|
||||||
deckTagsDisplayWidget->setTags(deckStateManager->getMetadata().tags);
|
formatComboBox->blockSignals(true);
|
||||||
}
|
|
||||||
|
|
||||||
void DeckEditorDeckDockWidget::sortDeckModelToDeckView()
|
|
||||||
{
|
|
||||||
getModel()->sort(deckView->header()->sortIndicatorSection(), deckView->header()->sortIndicatorOrder());
|
|
||||||
getModel()->setActiveFormat(deckStateManager->getMetadata().gameFormat);
|
|
||||||
formatComboBox->setCurrentIndex(formatComboBox->findData(deckStateManager->getMetadata().gameFormat));
|
formatComboBox->setCurrentIndex(formatComboBox->findData(deckStateManager->getMetadata().gameFormat));
|
||||||
|
formatComboBox->blockSignals(false);
|
||||||
|
|
||||||
|
deckTagsDisplayWidget->blockSignals(true);
|
||||||
|
deckTagsDisplayWidget->setTags(deckStateManager->getMetadata().tags);
|
||||||
|
deckTagsDisplayWidget->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ public slots:
|
||||||
void selectNextCard();
|
void selectNextCard();
|
||||||
void updateBannerCardComboBox();
|
void updateBannerCardComboBox();
|
||||||
void syncDisplayWidgetsToModel();
|
void syncDisplayWidgetsToModel();
|
||||||
void sortDeckModelToDeckView();
|
|
||||||
void actAddCard(const ExactCard &card, const QString &zoneName);
|
void actAddCard(const ExactCard &card, const QString &zoneName);
|
||||||
void actIncrementSelection();
|
void actIncrementSelection();
|
||||||
void actDecrementCard(const ExactCard &card, QString zoneName);
|
void actDecrementCard(const ExactCard &card, QString zoneName);
|
||||||
|
|
@ -100,6 +99,7 @@ private slots:
|
||||||
void writeName();
|
void writeName();
|
||||||
void writeComments();
|
void writeComments();
|
||||||
void writeBannerCard(int);
|
void writeBannerCard(int);
|
||||||
|
void applyActiveGroupCriteria();
|
||||||
void setSelectedIndex(const QModelIndex &newCardIndex);
|
void setSelectedIndex(const QModelIndex &newCardIndex);
|
||||||
void updateHash();
|
void updateHash();
|
||||||
void refreshShortcuts();
|
void refreshShortcuts();
|
||||||
|
|
|
||||||
|
|
@ -599,6 +599,7 @@ void DeckListModel::setDeckList(const QSharedPointer<DeckList> &_deck)
|
||||||
deckList = _deck;
|
deckList = _deck;
|
||||||
}
|
}
|
||||||
rebuildTree();
|
rebuildTree();
|
||||||
|
refreshCardFormatLegalities();
|
||||||
emit deckReplaced();
|
emit deckReplaced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue