Browse Source

Adding "Save path" column

because it's useful when moving files

It's the same path as in properties because that's consistent
adaptive-webui-19844
John Peterson 12 years ago
parent
commit
d1c3a07ba6
  1. 13
      src/properties/propertieswidget.cpp
  2. 15
      src/qtlibtorrent/qtorrenthandle.cpp
  3. 1
      src/qtlibtorrent/qtorrenthandle.h
  4. 3
      src/qtlibtorrent/torrentmodel.cpp
  5. 2
      src/qtlibtorrent/torrentmodel.h
  6. 1
      src/transferlistwidget.cpp

13
src/properties/propertieswidget.cpp

@ -210,18 +210,7 @@ QTorrentHandle PropertiesWidget::getCurrentTorrent() const {
void PropertiesWidget::updateSavePath(const QTorrentHandle& _h) { void PropertiesWidget::updateSavePath(const QTorrentHandle& _h) {
if (h.is_valid() && h == _h) { if (h.is_valid() && h == _h) {
QString p; save_path->setText(h.save_path_parsed());
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);
} }
} }

15
src/qtlibtorrent/qtorrenthandle.cpp

@ -277,6 +277,21 @@ QString QTorrentHandle::save_path() const {
#endif #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 QTorrentHandle::url_seeds() const {
QStringList res; QStringList res;
try { try {

1
src/qtlibtorrent/qtorrenthandle.h

@ -78,6 +78,7 @@ public:
int num_complete() const; int num_complete() const;
int num_incomplete() const; int num_incomplete() const;
QString save_path() const; QString save_path() const;
QString save_path_parsed() const;
QStringList url_seeds() const; QStringList url_seeds() const;
libtorrent::size_type actual_size() const; libtorrent::size_type actual_size() const;
int num_files() const; int num_files() const;

3
src/qtlibtorrent/torrentmodel.cpp

@ -197,6 +197,8 @@ QVariant TorrentModelItem::data(int column, int role) const
return static_cast<qlonglong>(m_torrent.total_wanted() - m_torrent.total_wanted_done()); return static_cast<qlonglong>(m_torrent.total_wanted() - m_torrent.total_wanted_done());
case TR_TIME_ELAPSED: case TR_TIME_ELAPSED:
return (role == Qt::DisplayRole) ? m_torrent.active_time() : m_torrent.seeding_time(); return (role == Qt::DisplayRole) ? m_torrent.active_time() : m_torrent.seeding_time();
case TR_SAVE_PATH:
return m_torrent.save_path_parsed();
default: default:
return QVariant(); 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_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_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_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: default:
return QVariant(); return QVariant();
} }

2
src/qtlibtorrent/torrentmodel.h

@ -49,7 +49,7 @@ Q_OBJECT
public: 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 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: public:
TorrentModelItem(const QTorrentHandle& h); TorrentModelItem(const QTorrentHandle& h);

1
src/transferlistwidget.cpp

@ -123,6 +123,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
setColumnHidden(TorrentModelItem::TR_AMOUNT_UPLOADED, true); setColumnHidden(TorrentModelItem::TR_AMOUNT_UPLOADED, true);
setColumnHidden(TorrentModelItem::TR_AMOUNT_LEFT, true); setColumnHidden(TorrentModelItem::TR_AMOUNT_LEFT, true);
setColumnHidden(TorrentModelItem::TR_TIME_ELAPSED, true); setColumnHidden(TorrentModelItem::TR_TIME_ELAPSED, true);
setColumnHidden(TorrentModelItem::TR_SAVE_PATH, true);
} }
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);

Loading…
Cancel
Save