mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 00:42:14 -07:00
maintain reselection behavior when deleting single selection
This commit is contained in:
parent
5e728c2796
commit
3dcd25383b
1 changed files with 16 additions and 0 deletions
|
|
@ -1320,6 +1320,12 @@ void TabDeckEditor::actRemoveCard()
|
|||
{
|
||||
auto selectedRows = getSelectedCardNodes();
|
||||
|
||||
// hack to maintain the old reselection behavior when currently selected row of a single-selection gets deleted
|
||||
// TODO: remove the hack and also handle reselection when all rows of a multi-selection gets deleted
|
||||
if (selectedRows.length() == 1) {
|
||||
deckView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
}
|
||||
|
||||
bool modified = false;
|
||||
for (const auto &index : selectedRows) {
|
||||
if (!index.isValid() || deckModel->hasChildren(index)) {
|
||||
|
|
@ -1329,6 +1335,8 @@ void TabDeckEditor::actRemoveCard()
|
|||
modified = true;
|
||||
}
|
||||
|
||||
deckView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
if (modified) {
|
||||
DeckLoader *const deck = deckModel->getDeckList();
|
||||
setSaveStatus(!deck->isEmpty());
|
||||
|
|
@ -1399,9 +1407,17 @@ void TabDeckEditor::actDecrement()
|
|||
{
|
||||
auto selectedRows = getSelectedCardNodes();
|
||||
|
||||
// hack to maintain the old reselection behavior when currently selected row of a single-selection gets deleted
|
||||
// TODO: remove the hack and also handle reselection when all rows of a multi-selection gets deleted
|
||||
if (selectedRows.length() == 1) {
|
||||
deckView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
}
|
||||
|
||||
for (const auto &index : selectedRows) {
|
||||
offsetCountAtIndex(index, -1);
|
||||
}
|
||||
|
||||
deckView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
}
|
||||
|
||||
void TabDeckEditor::setDeck(DeckLoader *_deck)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue