From b9c83650099ea2e2e200272885f35dc01ee7a7e1 Mon Sep 17 00:00:00 2001 From: RickyRister Date: Sun, 22 Dec 2024 23:38:28 -0800 Subject: [PATCH] support multi upload --- .../src/client/tabs/tab_deck_storage.cpp | 19 ++++++++++++++++--- cockatrice/src/client/tabs/tab_deck_storage.h | 3 +++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/client/tabs/tab_deck_storage.cpp b/cockatrice/src/client/tabs/tab_deck_storage.cpp index 92452699f..c71a29fbb 100644 --- a/cockatrice/src/client/tabs/tab_deck_storage.cpp +++ b/cockatrice/src/client/tabs/tab_deck_storage.cpp @@ -164,16 +164,29 @@ void TabDeckStorage::actOpenLocalDeck() void TabDeckStorage::actUpload() { - QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); - if (localDirModel->isDir(curLeft)) + QModelIndexList curLefts = localDirView->selectionModel()->selectedRows(); + if (curLefts.isEmpty()) { return; + } + QString targetPath = getTargetPath(); if (targetPath.length() > MAX_NAME_LENGTH) { qCritical() << "target path to upload to is too long" << targetPath; return; } - QString filePath = localDirModel->filePath(curLeft); + for (const auto &curLeft : curLefts) { + if (localDirModel->isDir(curLeft)) { + continue; + } + + QString filePath = localDirModel->filePath(curLeft); + uploadDeck(filePath, targetPath); + } +} + +void TabDeckStorage::uploadDeck(const QString &filePath, const QString &targetPath) +{ QFile deckFile(filePath); QFileInfo deckFileInfo(deckFile); diff --git a/cockatrice/src/client/tabs/tab_deck_storage.h b/cockatrice/src/client/tabs/tab_deck_storage.h index 2c7d1e726..1a69a621d 100644 --- a/cockatrice/src/client/tabs/tab_deck_storage.h +++ b/cockatrice/src/client/tabs/tab_deck_storage.h @@ -28,6 +28,9 @@ private: QAction *aOpenLocalDeck, *aUpload, *aDeleteLocalDeck, *aOpenRemoteDeck, *aDownload, *aNewFolder, *aDeleteRemoteDeck; QString getTargetPath() const; + + void uploadDeck(const QString &filePath, const QString &targetPath); + private slots: void actOpenLocalDeck();