diff --git a/cockatrice/src/client/tabs/tab_deck_storage.cpp b/cockatrice/src/client/tabs/tab_deck_storage.cpp index 817c6ab54..399db46f8 100644 --- a/cockatrice/src/client/tabs/tab_deck_storage.cpp +++ b/cockatrice/src/client/tabs/tab_deck_storage.cpp @@ -355,12 +355,30 @@ void TabDeckStorage::newFolderFinished(const Response &response, const CommandCo void TabDeckStorage::actDeleteRemoteDeck() { - PendingCommand *pend; - RemoteDeckList_TreeModel::Node *curRight = serverDirView->getCurrentItem(); - if (!curRight) + auto curRights = serverDirView->getCurrentSelection(); + + if (curRights.isEmpty()) { return; - RemoteDeckList_TreeModel::DirectoryNode *dir = dynamic_cast(curRight); - if (dir) { + } + + if (QMessageBox::warning(this, tr("Delete remote decks"), tr("Are you sure you want to delete the selected decks?"), + QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) { + return; + } + + for (const auto &curRight : curRights) { + deleteRemoteDeck(curRight); + } +} + +void TabDeckStorage::deleteRemoteDeck(const RemoteDeckList_TreeModel::Node *curRight) +{ + if (!curRight) { + return; + } + + PendingCommand *pend; + if (const auto *dir = dynamic_cast(curRight)) { QString targetPath = dir->getPath(); if (targetPath.isEmpty()) return; @@ -368,22 +386,13 @@ void TabDeckStorage::actDeleteRemoteDeck() qCritical() << "target path to delete is too long" << targetPath; return; } - if (QMessageBox::warning(this, tr("Delete remote folder"), - tr("Are you sure you want to delete \"%1\"?").arg(targetPath), - QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) - return; Command_DeckDelDir cmd; cmd.set_path(targetPath.toStdString()); pend = client->prepareSessionCommand(cmd); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(deleteFolderFinished(Response, CommandContainer))); } else { - RemoteDeckList_TreeModel::FileNode *deckNode = dynamic_cast(curRight); - if (QMessageBox::warning(this, tr("Delete remote deck"), - tr("Are you sure you want to delete \"%1\"?").arg(deckNode->getName()), - QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) - return; - + const auto *deckNode = dynamic_cast(curRight); Command_DeckDel cmd; cmd.set_deck_id(deckNode->getId()); pend = client->prepareSessionCommand(cmd); diff --git a/cockatrice/src/client/tabs/tab_deck_storage.h b/cockatrice/src/client/tabs/tab_deck_storage.h index 2c7d1e726..dbe32b2b0 100644 --- a/cockatrice/src/client/tabs/tab_deck_storage.h +++ b/cockatrice/src/client/tabs/tab_deck_storage.h @@ -1,6 +1,7 @@ #ifndef TAB_DECK_STORAGE_H #define TAB_DECK_STORAGE_H +#include "../../server/remote/remote_decklist_tree_widget.h" #include "tab.h" class AbstractClient; @@ -10,7 +11,6 @@ class QToolBar; class QTreeWidget; class QTreeWidgetItem; class QGroupBox; -class RemoteDeckList_TreeWidget; class CommandContainer; class Response; class DeckLoader; @@ -28,6 +28,9 @@ private: QAction *aOpenLocalDeck, *aUpload, *aDeleteLocalDeck, *aOpenRemoteDeck, *aDownload, *aNewFolder, *aDeleteRemoteDeck; QString getTargetPath() const; + + void deleteRemoteDeck(const RemoteDeckList_TreeModel::Node *node); + private slots: void actOpenLocalDeck();