maintain old reselecting behavior when changing cards from left side

This commit is contained in:
RickyRister 2024-12-31 18:19:02 -08:00
parent d4aff201bf
commit 58042ad9fe

View file

@ -1252,6 +1252,7 @@ void TabDeckEditor::addCardHelper(QString zoneName)
QModelIndex newCardIndex = deckModel->addPreferredPrintingCard(info->getName(), zoneName, false); QModelIndex newCardIndex = deckModel->addPreferredPrintingCard(info->getName(), zoneName, false);
recursiveExpand(newCardIndex); recursiveExpand(newCardIndex);
deckView->clearSelection();
deckView->setCurrentIndex(newCardIndex); deckView->setCurrentIndex(newCardIndex);
setModified(true); setModified(true);
searchEdit->setSelection(0, searchEdit->text().length()); searchEdit->setSelection(0, searchEdit->text().length());
@ -1338,14 +1339,18 @@ void TabDeckEditor::offsetCountAtIndex(const QModelIndex &idx, int offset)
void TabDeckEditor::decrementCardHelper(QString zoneName) void TabDeckEditor::decrementCardHelper(QString zoneName)
{ {
const CardInfoPtr info = currentCardInfo(); const CardInfoPtr info = currentCardInfo();
QModelIndex idx;
if (!info) if (!info)
return; return;
if (info->getIsToken()) if (info->getIsToken())
zoneName = DECK_ZONE_TOKENS; zoneName = DECK_ZONE_TOKENS;
idx = deckModel->findCard(info->getName(), zoneName); QModelIndex idx = deckModel->findCard(info->getName(), zoneName);
if (!idx.isValid()) {
return;
}
deckView->clearSelection();
deckView->setCurrentIndex(idx);
offsetCountAtIndex(idx, -1); offsetCountAtIndex(idx, -1);
} }