mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-20 17:32:15 -07:00
support multi delete
This commit is contained in:
parent
a2b2e0cc38
commit
3ab9610219
2 changed files with 28 additions and 16 deletions
|
|
@ -355,12 +355,30 @@ void TabDeckStorage::newFolderFinished(const Response &response, const CommandCo
|
||||||
|
|
||||||
void TabDeckStorage::actDeleteRemoteDeck()
|
void TabDeckStorage::actDeleteRemoteDeck()
|
||||||
{
|
{
|
||||||
PendingCommand *pend;
|
auto curRights = serverDirView->getCurrentSelection();
|
||||||
RemoteDeckList_TreeModel::Node *curRight = serverDirView->getCurrentItem();
|
|
||||||
if (!curRight)
|
if (curRights.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
RemoteDeckList_TreeModel::DirectoryNode *dir = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(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<const RemoteDeckList_TreeModel::DirectoryNode *>(curRight)) {
|
||||||
QString targetPath = dir->getPath();
|
QString targetPath = dir->getPath();
|
||||||
if (targetPath.isEmpty())
|
if (targetPath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -368,22 +386,13 @@ void TabDeckStorage::actDeleteRemoteDeck()
|
||||||
qCritical() << "target path to delete is too long" << targetPath;
|
qCritical() << "target path to delete is too long" << targetPath;
|
||||||
return;
|
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;
|
Command_DeckDelDir cmd;
|
||||||
cmd.set_path(targetPath.toStdString());
|
cmd.set_path(targetPath.toStdString());
|
||||||
pend = client->prepareSessionCommand(cmd);
|
pend = client->prepareSessionCommand(cmd);
|
||||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||||
SLOT(deleteFolderFinished(Response, CommandContainer)));
|
SLOT(deleteFolderFinished(Response, CommandContainer)));
|
||||||
} else {
|
} else {
|
||||||
RemoteDeckList_TreeModel::FileNode *deckNode = dynamic_cast<RemoteDeckList_TreeModel::FileNode *>(curRight);
|
const auto *deckNode = dynamic_cast<const RemoteDeckList_TreeModel::FileNode *>(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;
|
|
||||||
|
|
||||||
Command_DeckDel cmd;
|
Command_DeckDel cmd;
|
||||||
cmd.set_deck_id(deckNode->getId());
|
cmd.set_deck_id(deckNode->getId());
|
||||||
pend = client->prepareSessionCommand(cmd);
|
pend = client->prepareSessionCommand(cmd);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef TAB_DECK_STORAGE_H
|
#ifndef TAB_DECK_STORAGE_H
|
||||||
#define TAB_DECK_STORAGE_H
|
#define TAB_DECK_STORAGE_H
|
||||||
|
|
||||||
|
#include "../../server/remote/remote_decklist_tree_widget.h"
|
||||||
#include "tab.h"
|
#include "tab.h"
|
||||||
|
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
|
|
@ -10,7 +11,6 @@ class QToolBar;
|
||||||
class QTreeWidget;
|
class QTreeWidget;
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
class RemoteDeckList_TreeWidget;
|
|
||||||
class CommandContainer;
|
class CommandContainer;
|
||||||
class Response;
|
class Response;
|
||||||
class DeckLoader;
|
class DeckLoader;
|
||||||
|
|
@ -28,6 +28,9 @@ private:
|
||||||
|
|
||||||
QAction *aOpenLocalDeck, *aUpload, *aDeleteLocalDeck, *aOpenRemoteDeck, *aDownload, *aNewFolder, *aDeleteRemoteDeck;
|
QAction *aOpenLocalDeck, *aUpload, *aDeleteLocalDeck, *aOpenRemoteDeck, *aDownload, *aNewFolder, *aDeleteRemoteDeck;
|
||||||
QString getTargetPath() const;
|
QString getTargetPath() const;
|
||||||
|
|
||||||
|
void deleteRemoteDeck(const RemoteDeckList_TreeModel::Node *node);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void actOpenLocalDeck();
|
void actOpenLocalDeck();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue