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 { @@ -551,6 +551,18 @@ QString QTorrentHandle::firstFileSavePath() const {
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 {
#if LIBTORRENT_VERSION_MINOR > 15
torrent_status st = torrent_handle::status(0x0);

12
src/transferlistwidget.cpp

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

Loading…
Cancel
Save