Browse Source

- "Open destination folder" now opens torrent root folder (if it contains one) instead of the parent folder

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
8ed0e58d63
  1. 9
      src/qtorrenthandle.cpp
  2. 1
      src/qtorrenthandle.h
  3. 4
      src/transferlistwidget.cpp

9
src/qtorrenthandle.cpp

@ -432,6 +432,15 @@ bool QTorrentHandle::priv() const {
return h.get_torrent_info().priv(); 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 // Setters
// //

1
src/qtorrenthandle.h

@ -126,6 +126,7 @@ class QTorrentHandle {
#endif #endif
bool priv() const; bool priv() const;
bool first_last_piece_first() const; bool first_last_piece_first() const;
QString root_path() const;
// //
// Setters // Setters

4
src/transferlistwidget.cpp

@ -529,7 +529,7 @@ void TransferListWidget::torrentDoubleClicked(QModelIndex index) {
} }
break; break;
case OPEN_DEST: case OPEN_DEST:
QDesktopServices::openUrl("file://" + h.save_path()); QDesktopServices::openUrl("file://" + h.root_path());
break; break;
} }
} }
@ -663,7 +663,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const {
foreach(const QModelIndex &index, selectedIndexes) { foreach(const QModelIndex &index, selectedIndexes) {
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row())); QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row()));
if(h.is_valid()) { if(h.is_valid()) {
QString savePath = h.save_path(); QString savePath = h.root_path();
if(!pathsList.contains(savePath)) { if(!pathsList.contains(savePath)) {
pathsList.append(savePath); pathsList.append(savePath);
QDesktopServices::openUrl(QUrl(QString("file://")+savePath)); QDesktopServices::openUrl(QUrl(QString("file://")+savePath));

Loading…
Cancel
Save