mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-14 01:54:47 -07:00
[DeckListModel] Consolidate methods and signals for card change (#6466)
This commit is contained in:
parent
85c9d8a9ff
commit
192dac0396
7 changed files with 86 additions and 6 deletions
|
|
@ -12,7 +12,7 @@ DeckListStatisticsAnalyzer::DeckListStatisticsAnalyzer(QObject *parent,
|
|||
DeckListStatisticsAnalyzerConfig _config)
|
||||
: QObject(parent), model(_model), config(_config)
|
||||
{
|
||||
connect(model, &DeckListModel::dataChanged, this, &DeckListStatisticsAnalyzer::analyze);
|
||||
connect(model, &DeckListModel::cardsChanged, this, &DeckListStatisticsAnalyzer::analyze);
|
||||
}
|
||||
|
||||
void DeckListStatisticsAnalyzer::analyze()
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ void DeckEditorDeckDockWidget::createDeckDock()
|
|||
bannerCardLabel->setText(tr("Banner Card"));
|
||||
bannerCardLabel->setHidden(!SettingsCache::instance().getDeckEditorBannerCardComboBoxVisible());
|
||||
bannerCardComboBox = new QComboBox(this);
|
||||
connect(getModel(), &DeckListModel::dataChanged, this, [this]() {
|
||||
connect(getModel(), &DeckListModel::cardNodesChanged, this, [this]() {
|
||||
// Delay the update to avoid race conditions
|
||||
QTimer::singleShot(100, this, &DeckEditorDeckDockWidget::updateBannerCardComboBox);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ DeckStateManager::DeckStateManager(QObject *parent)
|
|||
setModified(true);
|
||||
emit historyChanged();
|
||||
});
|
||||
connect(deckListModel, &DeckListModel::rowsInserted, this, &DeckStateManager::uniqueCardsChanged);
|
||||
connect(deckListModel, &DeckListModel::rowsRemoved, this, &DeckStateManager::uniqueCardsChanged);
|
||||
connect(deckListModel, &DeckListModel::cardNodesChanged, this, &DeckStateManager::uniqueCardsChanged);
|
||||
}
|
||||
|
||||
const DeckList &DeckStateManager::getDeckList() const
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ static bool swapPrinting(DeckListModel *model, const QString &modifiedSet, const
|
|||
return false;
|
||||
}
|
||||
int amount = model->data(idx.siblingAtColumn(DeckListModelColumns::CARD_AMOUNT), Qt::DisplayRole).toInt();
|
||||
model->removeRow(idx.row(), idx.parent());
|
||||
model->removeCardAtIndex(idx);
|
||||
CardInfoPtr cardInfo = CardDatabaseManager::query()->getCardInfo(cardName);
|
||||
PrintingInfo printing = CardDatabaseManager::query()->getSpecificPrinting(cardName, modifiedSet, "");
|
||||
for (int i = 0; i < amount; i++) {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ static QModelIndex addAndReplacePrintings(DeckListModel *model,
|
|||
// Check if a card without a providerId already exists in the deckModel and replace it, if so.
|
||||
if (existing.isValid() && existing != newCardIndex && replaceProviderless) {
|
||||
model->offsetCountAtIndex(newCardIndex, extraCopies);
|
||||
model->removeRow(existing.row(), existing.parent());
|
||||
model->removeCardAtIndex(existing);
|
||||
}
|
||||
|
||||
// Set Index and Focus as if the user had just clicked the new card and modify the deckEditor saveState
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue