From d1c3a07ba6d5ef4ed5787f018032bfa20f72e0e1 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Wed, 1 May 2013 07:52:06 +0200 Subject: [PATCH] Adding "Save path" column because it's useful when moving files It's the same path as in properties because that's consistent --- src/properties/propertieswidget.cpp | 13 +------------ src/qtlibtorrent/qtorrenthandle.cpp | 15 +++++++++++++++ src/qtlibtorrent/qtorrenthandle.h | 1 + src/qtlibtorrent/torrentmodel.cpp | 3 +++ src/qtlibtorrent/torrentmodel.h | 2 +- src/transferlistwidget.cpp | 1 + 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/properties/propertieswidget.cpp b/src/properties/propertieswidget.cpp index 72c74a9b2..af86e1b8c 100644 --- a/src/properties/propertieswidget.cpp +++ b/src/properties/propertieswidget.cpp @@ -210,18 +210,7 @@ QTorrentHandle PropertiesWidget::getCurrentTorrent() const { void PropertiesWidget::updateSavePath(const QTorrentHandle& _h) { if (h.is_valid() && h == _h) { - QString p; - if (h.has_metadata() && h.num_files() == 1) { - p = h.firstFileSavePath(); - } else { - p = TorrentPersistentData::getSavePath(h.hash()); - if (p.isEmpty()) - p = h.save_path(); - } -#if defined(Q_WS_WIN) || defined(Q_OS_OS2) - p.replace("/", "\\"); -#endif - save_path->setText(p); + save_path->setText(h.save_path_parsed()); } } diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index 5837122ab..2db4464e4 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -277,6 +277,21 @@ QString QTorrentHandle::save_path() const { #endif } +QString QTorrentHandle::save_path_parsed() const { + QString p; + if (has_metadata() && num_files() == 1) { + p = firstFileSavePath(); + } else { + p = TorrentPersistentData::getSavePath(hash()); + if (p.isEmpty()) + p = save_path(); + } +#if defined(Q_WS_WIN) || defined(Q_OS_OS2) + p.replace("/", "\\"); +#endif + return p; +} + QStringList QTorrentHandle::url_seeds() const { QStringList res; try { diff --git a/src/qtlibtorrent/qtorrenthandle.h b/src/qtlibtorrent/qtorrenthandle.h index 5a60a4d00..a32453f48 100644 --- a/src/qtlibtorrent/qtorrenthandle.h +++ b/src/qtlibtorrent/qtorrenthandle.h @@ -78,6 +78,7 @@ public: int num_complete() const; int num_incomplete() const; QString save_path() const; + QString save_path_parsed() const; QStringList url_seeds() const; libtorrent::size_type actual_size() const; int num_files() const; diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index 435c62af7..6ce65f697 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -197,6 +197,8 @@ QVariant TorrentModelItem::data(int column, int role) const return static_cast(m_torrent.total_wanted() - m_torrent.total_wanted_done()); case TR_TIME_ELAPSED: return (role == Qt::DisplayRole) ? m_torrent.active_time() : m_torrent.seeding_time(); + case TR_SAVE_PATH: + return m_torrent.save_path_parsed(); default: return QVariant(); } @@ -266,6 +268,7 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation, case TorrentModelItem::TR_AMOUNT_UPLOADED: return tr("Amount uploaded", "Amount of data uploaded (e.g. in MB)"); case TorrentModelItem::TR_AMOUNT_LEFT: return tr("Amount left", "Amount of data left to download (e.g. in MB)"); case TorrentModelItem::TR_TIME_ELAPSED: return tr("Time Active", "Time (duration) the torrent is active (not paused)"); + case TorrentModelItem::TR_SAVE_PATH: return tr("Save path", "Torrent save path"); default: return QVariant(); } diff --git a/src/qtlibtorrent/torrentmodel.h b/src/qtlibtorrent/torrentmodel.h index 328e604c1..cdecfe4fb 100644 --- a/src/qtlibtorrent/torrentmodel.h +++ b/src/qtlibtorrent/torrentmodel.h @@ -49,7 +49,7 @@ Q_OBJECT public: enum State {STATE_DOWNLOADING, STATE_STALLED_DL, STATE_STALLED_UP, STATE_SEEDING, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_INVALID}; - enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_ADD_DATE, TR_SEED_DATE, TR_TRACKER, TR_DLLIMIT, TR_UPLIMIT, TR_AMOUNT_DOWNLOADED, TR_AMOUNT_UPLOADED, TR_AMOUNT_LEFT, TR_TIME_ELAPSED, NB_COLUMNS}; + enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_ADD_DATE, TR_SEED_DATE, TR_TRACKER, TR_DLLIMIT, TR_UPLIMIT, TR_AMOUNT_DOWNLOADED, TR_AMOUNT_UPLOADED, TR_AMOUNT_LEFT, TR_TIME_ELAPSED, TR_SAVE_PATH, NB_COLUMNS}; public: TorrentModelItem(const QTorrentHandle& h); diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index df04528b7..c98fdc921 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -123,6 +123,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, setColumnHidden(TorrentModelItem::TR_AMOUNT_UPLOADED, true); setColumnHidden(TorrentModelItem::TR_AMOUNT_LEFT, true); setColumnHidden(TorrentModelItem::TR_TIME_ELAPSED, true); + setColumnHidden(TorrentModelItem::TR_SAVE_PATH, true); } setContextMenuPolicy(Qt::CustomContextMenu);