Browse Source

Fix "Open destination folder" functionality to consider torrent root folder

adaptive-webui-19844
Christophe Dumez 13 years ago
parent
commit
02c4be4eaa
  1. 12
      src/qtlibtorrent/qtorrenthandle.cpp
  2. 12
      src/transferlistwidget.cpp

12
src/qtlibtorrent/qtorrenthandle.cpp

@ -551,6 +551,18 @@ QString QTorrentHandle::firstFileSavePath() const {
return fsave_path; return fsave_path;
} }
QString QTorrentHandle::root_path() const
{
if (num_files() < 2)
return save_path();
QString first_filepath = filepath_at(0);
const int slashIndex = first_filepath.indexOf(QRegExp("[/\\\\]"));
QString root_folder;
if (slashIndex >= 0)
return QDir(save_path()).absoluteFilePath(first_filepath.left(slashIndex));
return save_path();
}
bool QTorrentHandle::has_error() const { bool QTorrentHandle::has_error() const {
#if LIBTORRENT_VERSION_MINOR > 15 #if LIBTORRENT_VERSION_MINOR > 15
torrent_status st = torrent_handle::status(0x0); torrent_status st = torrent_handle::status(0x0);

12
src/transferlistwidget.cpp

@ -402,16 +402,16 @@ void TransferListWidget::hidePriorityColumn(bool hide) {
} }
void TransferListWidget::openSelectedTorrentsFolder() const { void TransferListWidget::openSelectedTorrentsFolder() const {
QStringList pathsList; QSet<QString> pathsList;
const QStringList hashes = getSelectedTorrentsHashes(); const QStringList hashes = getSelectedTorrentsHashes();
foreach (const QString &hash, hashes) { foreach (const QString &hash, hashes) {
const QTorrentHandle h = BTSession->getTorrentHandle(hash); const QTorrentHandle h = BTSession->getTorrentHandle(hash);
if (h.is_valid()) { if (h.is_valid()) {
const QString savePath = h.save_path(); QString rootFolder = h.root_path();
qDebug("Opening path at %s", qPrintable(savePath)); qDebug("Opening path at %s", qPrintable(rootFolder));
if (!pathsList.contains(savePath)) { if (!pathsList.contains(rootFolder)) {
pathsList.append(savePath); pathsList.insert(rootFolder);
QDesktopServices::openUrl(QUrl::fromLocalFile(savePath)); QDesktopServices::openUrl(QUrl::fromLocalFile(rootFolder));
} }
} }
} }

Loading…
Cancel
Save