From c09294df2fdb72dc66ad9dd0f407b8fde97201ea Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 21 May 2010 14:26:18 +0000 Subject: [PATCH] FEATURE: Several torrents can be moved at once --- Changelog | 1 + src/transferlistwidget.cpp | 38 +++++++++++++++++++++++++++++++++++--- src/transferlistwidget.h | 1 + 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index e375c5eda..d717f6ac6 100644 --- a/Changelog +++ b/Changelog @@ -6,6 +6,7 @@ - FEATURE: Added cookie support for RSS feeds - FEATURE: User can force tracker reannounce - FEATURE: Added "No action" setting for double-click action + - FEATURE: Several torrents can be moved at once - COSMETIC: Display peers country name in tooltip * Sun Mar 14 2010 - Christophe Dumez - v2.2.0 diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 1d4d8e1c3..9854bb1dd 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include TransferListWidget::TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent *_BTSession): @@ -602,6 +603,34 @@ QStringList TransferListWidget::getSelectedTorrentsHashes() const { return hashes; } +void TransferListWidget::setSelectedTorrentsLocation() { + const QStringList &hashes = getSelectedTorrentsHashes(); + if(hashes.isEmpty()) return; + QString dir; + const QDir saveDir(BTSession->getTorrentHandle(hashes.first()).save_path()); + if(saveDir.exists()){ + dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), saveDir.path()); + }else{ + dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath()); + } + if(!dir.isNull()){ + // Check if savePath exists + QDir savePath(misc::expandPath(dir)); + if(!savePath.exists()){ + if(!savePath.mkpath(savePath.absolutePath())){ + QMessageBox::critical(0, tr("Save path creation error"), tr("Could not create the save path")); + return; + } + } + foreach(const QString & hash, hashes) { + // Actually move storage + QTorrentHandle h = BTSession->getTorrentHandle(hash); + if(!BTSession->useTemporaryFolder() || h.is_seed()) + h.move_storage(savePath.absolutePath()); + } + } +} + void TransferListWidget::startSelectedTorrents() { const QStringList &hashes = getSelectedTorrentsHashes(); foreach(const QString &hash, hashes) { @@ -992,8 +1021,10 @@ void TransferListWidget::displayListMenu(const QPoint&) { connect(&actionSet_download_limit, SIGNAL(triggered()), this, SLOT(setDlLimitSelectedTorrents())); QAction actionOpen_destination_folder(QIcon(QString::fromUtf8(":/Icons/oxygen/folder.png")), tr("Open destination folder"), 0); connect(&actionOpen_destination_folder, SIGNAL(triggered()), this, SLOT(openSelectedTorrentsFolder())); - QAction actionBuy_it(QIcon(QString::fromUtf8(":/Icons/oxygen/wallet.png")), tr("Buy it"), 0); - connect(&actionBuy_it, SIGNAL(triggered()), this, SLOT(buySelectedTorrents())); + //QAction actionBuy_it(QIcon(QString::fromUtf8(":/Icons/oxygen/wallet.png")), tr("Buy it"), 0); + //connect(&actionBuy_it, SIGNAL(triggered()), this, SLOT(buySelectedTorrents())); + QAction actionSetTorrentPath(QIcon(QString::fromUtf8(":/Icons/skin/folder.png")), tr("Set location..."), 0); + connect(&actionSetTorrentPath, SIGNAL(triggered()), this, SLOT(setSelectedTorrentsLocation())); QAction actionIncreasePriority(QIcon(QString::fromUtf8(":/Icons/skin/increase.png")), tr("Increase priority"), 0); connect(&actionIncreasePriority, SIGNAL(triggered()), this, SLOT(increasePrioSelectedTorrents())); QAction actionDecreasePriority(QIcon(QString::fromUtf8(":/Icons/skin/decrease.png")), tr("Decrease priority"), 0); @@ -1084,6 +1115,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { listMenu.addSeparator(); listMenu.addAction(&actionDelete); listMenu.addSeparator(); + listMenu.addAction(&actionSetTorrentPath); if(selectedIndexes.size() == 1) listMenu.addAction(&actionRename); // Label Menu @@ -1158,7 +1190,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { listMenu.addSeparator(); if(one_has_metadata) listMenu.addAction(&actionCopy_magnet_link); - listMenu.addAction(&actionBuy_it); + //listMenu.addAction(&actionBuy_it); // Call menu QAction *act = 0; act = listMenu.exec(QCursor::pos()); diff --git a/src/transferlistwidget.h b/src/transferlistwidget.h index bad59f83c..2173e18a9 100644 --- a/src/transferlistwidget.h +++ b/src/transferlistwidget.h @@ -59,6 +59,7 @@ public slots: void setFinished(QTorrentHandle &h); void setSelectionLabel(QString label); void setRefreshInterval(int t); + void setSelectedTorrentsLocation(); void startSelectedTorrents(); void startAllTorrents(); void pauseSelectedTorrents();