diff --git a/cockatrice/src/keysignals.cpp b/cockatrice/src/keysignals.cpp index 5db58cb5..bbd94dbb 100644 --- a/cockatrice/src/keysignals.cpp +++ b/cockatrice/src/keysignals.cpp @@ -56,6 +56,10 @@ bool KeySignals::eventFilter(QObject * /*object*/, QEvent *event) { && kevent->modifiers().testFlag(Qt::ControlModifier) ) emit onCtrlAltRBracket(); + break; + case Qt::Key_S: + emit onS(); + break; default: return false; diff --git a/cockatrice/src/keysignals.h b/cockatrice/src/keysignals.h index 693488c5..94c9dd39 100644 --- a/cockatrice/src/keysignals.h +++ b/cockatrice/src/keysignals.h @@ -18,6 +18,7 @@ signals: void onCtrlAltEqual(); void onCtrlAltLBracket(); void onCtrlAltRBracket(); + void onS(); protected: virtual bool eventFilter(QObject *, QEvent *event); diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index c0138931..82a356d1 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -141,6 +141,8 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent) #endif deckView->installEventFilter(&deckViewKeySignals); connect(deckView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoRight(const QModelIndex &, const QModelIndex &))); + connect(deckView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actSwapCard())); + connect(&deckViewKeySignals, SIGNAL(onS()), this, SLOT(actSwapCard())); connect(&deckViewKeySignals, SIGNAL(onEnter()), this, SLOT(actIncrement())); connect(&deckViewKeySignals, SIGNAL(onCtrlAltEqual()), this, SLOT(actIncrement())); connect(&deckViewKeySignals, SIGNAL(onCtrlAltMinus()), this, SLOT(actDecrement())); @@ -571,6 +573,27 @@ void TabDeckEditor::addCardHelper(QString zoneName) setModified(true); } +void TabDeckEditor::actSwapCard() +{ + const QModelIndex currentIndex = deckView->selectionModel()->currentIndex(); + if (!currentIndex.isValid()) + return; + const QString cardName = currentIndex.sibling(currentIndex.row(), 1).data().toString(); + const QModelIndex gparent = currentIndex.parent().parent(); + if (!gparent.isValid()) + return; + + const QString zoneName = gparent.sibling(gparent.row(), 1).data().toString(); + actDecrement(); + + const QString otherZoneName = zoneName == "Maindeck" ? "side" : "main"; + + QModelIndex newCardIndex = deckModel->addCard(cardName, otherZoneName); + recursiveExpand(newCardIndex); + deckView->setCurrentIndex(newCardIndex); + setModified(true); +} + void TabDeckEditor::actAddCard() { addCardHelper("main"); diff --git a/cockatrice/src/tab_deck_editor.h b/cockatrice/src/tab_deck_editor.h index b3ba8dcf..dd3b56ac 100644 --- a/cockatrice/src/tab_deck_editor.h +++ b/cockatrice/src/tab_deck_editor.h @@ -53,6 +53,7 @@ private slots: void actClearSearch(); + void actSwapCard(); void actAddCard(); void actAddCardToSideboard(); void actRemoveCard();