diff --git a/cockatrice/src/client/tabs/tab_deck_storage.cpp b/cockatrice/src/client/tabs/tab_deck_storage.cpp index 4cc2b02c6..ce3f0b1cd 100644 --- a/cockatrice/src/client/tabs/tab_deck_storage.cpp +++ b/cockatrice/src/client/tabs/tab_deck_storage.cpp @@ -376,34 +376,34 @@ void TabDeckStorage::openRemoteDeckFinished(const Response &r, const CommandCont void TabDeckStorage::actDownload() { - QString dirPath; QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); - if (!curLeft.isValid()) - dirPath = localDirModel->rootPath(); - else { - while (!localDirModel->isDir(curLeft)) - curLeft = curLeft.parent(); - dirPath = localDirModel->filePath(curLeft); + while (!localDirModel->isDir(curLeft)) { + curLeft = curLeft.parent(); } - for (const auto &curRight : serverDirView->getCurrentSelection()) { - RemoteDeckList_TreeModel::FileNode *node = dynamic_cast(curRight); - if (!node) - continue; - - QString filePath = dirPath + QString("/deck_%1.cod").arg(node->getId()); - - Command_DeckDownload cmd; - cmd.set_deck_id(node->getId()); - - PendingCommand *pend = client->prepareSessionCommand(cmd); - pend->setExtraData(filePath); - connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, - SLOT(downloadFinished(Response, CommandContainer, QVariant))); - client->sendCommand(pend); + for (const auto curRight : serverDirView->selectionModel()->selectedRows()) { + downloadNodeAtIndex(curLeft, curRight); } } +void TabDeckStorage::downloadNodeAtIndex(const QModelIndex &curLeft, const QModelIndex &curRight) +{ + auto node = dynamic_cast(serverDirView->getNode(curRight)); + if (!node) + return; + + const QString filePath = localDirModel->filePath(curLeft) + QString("/deck_%1.cod").arg(node->getId()); + + Command_DeckDownload cmd; + cmd.set_deck_id(node->getId()); + + PendingCommand *pend = client->prepareSessionCommand(cmd); + pend->setExtraData(filePath); + connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, + SLOT(downloadFinished(Response, CommandContainer, QVariant))); + client->sendCommand(pend); +} + void TabDeckStorage::downloadFinished(const Response &r, const CommandContainer & /*commandContainer*/, const QVariant &extraData) diff --git a/cockatrice/src/client/tabs/tab_deck_storage.h b/cockatrice/src/client/tabs/tab_deck_storage.h index 38e4af438..bebeaab5b 100644 --- a/cockatrice/src/client/tabs/tab_deck_storage.h +++ b/cockatrice/src/client/tabs/tab_deck_storage.h @@ -34,6 +34,8 @@ private: void uploadDeck(const QString &filePath, const QString &targetPath); void deleteRemoteDeck(const RemoteDeckList_TreeModel::Node *node); + void downloadNodeAtIndex(const QModelIndex &curLeft, const QModelIndex &curRight); + private slots: void actLocalDoubleClick(const QModelIndex &curLeft); void actOpenLocalDeck();