mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 00:42:14 -07:00
support multiselect in deck editor
This commit is contained in:
parent
6e1047032d
commit
4603bf7767
1 changed files with 29 additions and 11 deletions
|
|
@ -64,6 +64,7 @@ void TabDeckEditor::createDeckDock()
|
|||
deckView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
deckView->installEventFilter(&deckViewKeySignals);
|
||||
deckView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
deckView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
connect(deckView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this,
|
||||
SLOT(updateCardInfoRight(const QModelIndex &, const QModelIndex &)));
|
||||
connect(deckView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this,
|
||||
|
|
@ -1299,14 +1300,23 @@ void TabDeckEditor::actAddCardToSideboard()
|
|||
|
||||
void TabDeckEditor::actRemoveCard()
|
||||
{
|
||||
const QModelIndex ¤tIndex = deckView->selectionModel()->currentIndex();
|
||||
if (!currentIndex.isValid() || deckModel->hasChildren(currentIndex))
|
||||
return;
|
||||
deckModel->removeRow(currentIndex.row(), currentIndex.parent());
|
||||
auto selectedRows = deckView->selectionModel()->selectedRows();
|
||||
std::reverse(selectedRows.begin(), selectedRows.end());
|
||||
|
||||
DeckLoader *const deck = deckModel->getDeckList();
|
||||
setSaveStatus(!deck->isEmpty());
|
||||
setModified(true);
|
||||
bool modified = false;
|
||||
for (const auto &index : selectedRows) {
|
||||
if (!index.isValid() || deckModel->hasChildren(index)) {
|
||||
continue;
|
||||
}
|
||||
deckModel->removeRow(index.row(), index.parent());
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
DeckLoader *const deck = deckModel->getDeckList();
|
||||
setSaveStatus(!deck->isEmpty());
|
||||
setModified(true);
|
||||
}
|
||||
}
|
||||
|
||||
void TabDeckEditor::offsetCountAtIndex(const QModelIndex &idx, int offset)
|
||||
|
|
@ -1357,14 +1367,22 @@ void TabDeckEditor::copyDatabaseCellContents()
|
|||
|
||||
void TabDeckEditor::actIncrement()
|
||||
{
|
||||
const QModelIndex ¤tIndex = deckView->selectionModel()->currentIndex();
|
||||
offsetCountAtIndex(currentIndex, 1);
|
||||
auto selectedRows = deckView->selectionModel()->selectedRows();
|
||||
|
||||
for (const auto &index : selectedRows) {
|
||||
offsetCountAtIndex(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void TabDeckEditor::actDecrement()
|
||||
{
|
||||
const QModelIndex ¤tIndex = deckView->selectionModel()->currentIndex();
|
||||
offsetCountAtIndex(currentIndex, -1);
|
||||
auto selectedRows = deckView->selectionModel()->selectedRows();
|
||||
// we need to iterate the rows in reverse order since there may be row deletions
|
||||
std::reverse(selectedRows.begin(), selectedRows.end());
|
||||
|
||||
for (const auto &index : selectedRows) {
|
||||
offsetCountAtIndex(index, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void TabDeckEditor::setDeck(DeckLoader *_deck)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue