From 8ed0e58d63beb7f62eb8af518c721dd814138c33 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 23 Jan 2010 09:54:50 +0000 Subject: [PATCH] - "Open destination folder" now opens torrent root folder (if it contains one) instead of the parent folder --- src/qtorrenthandle.cpp | 9 +++++++++ src/qtorrenthandle.h | 1 + src/transferlistwidget.cpp | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 5f2c5d32a..9bdabf1ba 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -432,6 +432,15 @@ bool QTorrentHandle::priv() const { return h.get_torrent_info().priv(); } +QString QTorrentHandle::root_path() const { + Q_ASSERT(h.is_valid()); + if(num_files() == 0) return ""; + QStringList path_list = misc::toQString(h.get_torrent_info().file_at(0).path.string()).split(QDir::separator()); + if(path_list.size() > 1) + return save_path()+QDir::separator()+path_list.first(); + return save_path(); +} + // // Setters // diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index 59863c1a7..7056afedf 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -126,6 +126,7 @@ class QTorrentHandle { #endif bool priv() const; bool first_last_piece_first() const; + QString root_path() const; // // Setters diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index ce334b306..726e0f321 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -529,7 +529,7 @@ void TransferListWidget::torrentDoubleClicked(QModelIndex index) { } break; case OPEN_DEST: - QDesktopServices::openUrl("file://" + h.save_path()); + QDesktopServices::openUrl("file://" + h.root_path()); break; } } @@ -663,7 +663,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const { foreach(const QModelIndex &index, selectedIndexes) { QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row())); if(h.is_valid()) { - QString savePath = h.save_path(); + QString savePath = h.root_path(); if(!pathsList.contains(savePath)) { pathsList.append(savePath); QDesktopServices::openUrl(QUrl(QString("file://")+savePath));