mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 17:02:15 -07:00
refactor
This commit is contained in:
parent
3452cb01d0
commit
804715947b
2 changed files with 24 additions and 22 deletions
|
|
@ -376,34 +376,34 @@ void TabDeckStorage::openRemoteDeckFinished(const Response &r, const CommandCont
|
||||||
|
|
||||||
void TabDeckStorage::actDownload()
|
void TabDeckStorage::actDownload()
|
||||||
{
|
{
|
||||||
QString dirPath;
|
|
||||||
QModelIndex curLeft = localDirView->selectionModel()->currentIndex();
|
QModelIndex curLeft = localDirView->selectionModel()->currentIndex();
|
||||||
if (!curLeft.isValid())
|
while (!localDirModel->isDir(curLeft)) {
|
||||||
dirPath = localDirModel->rootPath();
|
curLeft = curLeft.parent();
|
||||||
else {
|
|
||||||
while (!localDirModel->isDir(curLeft))
|
|
||||||
curLeft = curLeft.parent();
|
|
||||||
dirPath = localDirModel->filePath(curLeft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &curRight : serverDirView->getCurrentSelection()) {
|
for (const auto curRight : serverDirView->selectionModel()->selectedRows()) {
|
||||||
RemoteDeckList_TreeModel::FileNode *node = dynamic_cast<RemoteDeckList_TreeModel::FileNode *>(curRight);
|
downloadNodeAtIndex(curLeft, 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabDeckStorage::downloadNodeAtIndex(const QModelIndex &curLeft, const QModelIndex &curRight)
|
||||||
|
{
|
||||||
|
auto node = dynamic_cast<RemoteDeckList_TreeModel::FileNode *>(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,
|
void TabDeckStorage::downloadFinished(const Response &r,
|
||||||
const CommandContainer & /*commandContainer*/,
|
const CommandContainer & /*commandContainer*/,
|
||||||
const QVariant &extraData)
|
const QVariant &extraData)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ private:
|
||||||
void uploadDeck(const QString &filePath, const QString &targetPath);
|
void uploadDeck(const QString &filePath, const QString &targetPath);
|
||||||
void deleteRemoteDeck(const RemoteDeckList_TreeModel::Node *node);
|
void deleteRemoteDeck(const RemoteDeckList_TreeModel::Node *node);
|
||||||
|
|
||||||
|
void downloadNodeAtIndex(const QModelIndex &curLeft, const QModelIndex &curRight);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void actLocalDoubleClick(const QModelIndex &curLeft);
|
void actLocalDoubleClick(const QModelIndex &curLeft);
|
||||||
void actOpenLocalDeck();
|
void actOpenLocalDeck();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue