extract applyActiveGroupCriteria

This commit is contained in:
RickyRister 2025-12-31 21:00:29 -08:00
parent 8967ec6683
commit 2e5d6ccb74
2 changed files with 12 additions and 5 deletions

View file

@ -64,6 +64,8 @@ void DeckEditorDeckDockWidget::createDeckDock()
connect(deckStateManager, &DeckStateManager::focusIndexChanged, this, &DeckEditorDeckDockWidget::setSelectedIndex);
connect(deckStateManager, &DeckStateManager::deckReplaced, this,
&DeckEditorDeckDockWidget::syncDisplayWidgetsToModel);
connect(deckStateManager, &DeckStateManager::deckReplaced, this,
&DeckEditorDeckDockWidget::applyActiveGroupCriteria);
deckView = new QTreeView();
deckView->setObjectName("deckView");
@ -174,11 +176,8 @@ void DeckEditorDeckDockWidget::createDeckDock()
activeGroupCriteriaComboBox->addItem(tr("Main Type"), DeckListModelGroupCriteria::MAIN_TYPE);
activeGroupCriteriaComboBox->addItem(tr("Mana Cost"), DeckListModelGroupCriteria::MANA_COST);
activeGroupCriteriaComboBox->addItem(tr("Colors"), DeckListModelGroupCriteria::COLOR);
connect(activeGroupCriteriaComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this]() {
getModel()->setActiveGroupCriteria(static_cast<DeckListModelGroupCriteria::Type>(
activeGroupCriteriaComboBox->currentData(Qt::UserRole).toInt()));
getModel()->sort(deckView->header()->sortIndicatorSection(), deckView->header()->sortIndicatorOrder());
});
connect(activeGroupCriteriaComboBox, &QComboBox::currentIndexChanged, this,
&DeckEditorDeckDockWidget::applyActiveGroupCriteria);
aIncrement = new QAction(QString(), this);
aIncrement->setIcon(QPixmap("theme:icons/increment"));
@ -428,6 +427,13 @@ void DeckEditorDeckDockWidget::writeBannerCard(int index)
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)
{
bannerCardLabel->setHidden(!visible);

View file

@ -99,6 +99,7 @@ private slots:
void writeName();
void writeComments();
void writeBannerCard(int);
void applyActiveGroupCriteria();
void setSelectedIndex(const QModelIndex &newCardIndex);
void updateHash();
void refreshShortcuts();