mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Add sideboard helpers.
This commit is contained in:
parent
2aeecc6063
commit
fefb6fc612
4 changed files with 29 additions and 0 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue