Browse Source

Use the torrent_status for the queue_position too.

adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
a361c0ea03
  1. 10
      src/qtlibtorrent/qtorrenthandle.cpp
  2. 1
      src/qtlibtorrent/qtorrenthandle.h
  3. 2
      src/qtlibtorrent/torrentmodel.cpp
  4. 6
      src/webui/btjson.cpp

10
src/qtlibtorrent/qtorrenthandle.cpp

@ -317,9 +317,7 @@ bool QTorrentHandle::has_missing_files() const {
} }
int QTorrentHandle::queue_position() const { int QTorrentHandle::queue_position() const {
if (torrent_handle::queue_position() < 0) return queue_position(status(0x0));
return -1;
return torrent_handle::queue_position()+1;
} }
bool QTorrentHandle::is_seed() const { bool QTorrentHandle::is_seed() const {
@ -621,6 +619,12 @@ bool QTorrentHandle::is_paused(const libtorrent::torrent_status &status) {
return status.paused && !status.auto_managed; return status.paused && !status.auto_managed;
} }
int QTorrentHandle::queue_position(const libtorrent::torrent_status &status) {
if (status.queue_position < 0)
return -1;
return status.queue_position+1;
}
bool QTorrentHandle::is_queued(const libtorrent::torrent_status &status) { bool QTorrentHandle::is_queued(const libtorrent::torrent_status &status) {
return status.paused && status.auto_managed; return status.paused && status.auto_managed;
} }

1
src/qtlibtorrent/qtorrenthandle.h

@ -117,6 +117,7 @@ public:
bool operator ==(const QTorrentHandle& new_h) const; bool operator ==(const QTorrentHandle& new_h) const;
static bool is_paused(const libtorrent::torrent_status &status); static bool is_paused(const libtorrent::torrent_status &status);
static int queue_position(const libtorrent::torrent_status &status);
static bool is_queued(const libtorrent::torrent_status &status); static bool is_queued(const libtorrent::torrent_status &status);
static bool is_seed(const libtorrent::torrent_status &status); static bool is_seed(const libtorrent::torrent_status &status);
static bool is_checking(const libtorrent::torrent_status &status); static bool is_checking(const libtorrent::torrent_status &status);

2
src/qtlibtorrent/torrentmodel.cpp

@ -212,7 +212,7 @@ QVariant TorrentModelItem::data(int column, int role) const
case TR_NAME: case TR_NAME:
return m_name.isEmpty() ? m_torrent.name() : m_name; return m_name.isEmpty() ? m_torrent.name() : m_name;
case TR_PRIORITY: { case TR_PRIORITY: {
int pos = m_torrent.queue_position(); int pos = m_torrent.queue_position(m_lastStatus);;
if (pos > -1) if (pos > -1)
return pos - HiddenData::getSize(); return pos - HiddenData::getSize();
else else

6
src/webui/btjson.cpp

@ -128,12 +128,12 @@ static QVariantMap toMap(const QTorrentHandle& h)
QVariantMap ret; QVariantMap ret;
ret[KEY_TORRENT_HASH] = h.hash(); ret[KEY_TORRENT_HASH] = h.hash();
ret[KEY_TORRENT_NAME] = h.name(); ret[KEY_TORRENT_NAME] = h.name();
ret[KEY_TORRENT_SIZE] = misc::friendlyUnit(h.actual_size()); // FIXME: Should pass as Number, not formatted String (for sorting). ret[KEY_TORRENT_SIZE] = misc::friendlyUnit(status.total_wanted); // FIXME: Should pass as Number, not formatted String (for sorting).
ret[KEY_TORRENT_PROGRESS] = (double)h.progress(status); ret[KEY_TORRENT_PROGRESS] = (double)h.progress(status);
ret[KEY_TORRENT_DLSPEED] = misc::friendlyUnit(status.download_payload_rate, true); // FIXME: Should be passed as a Number ret[KEY_TORRENT_DLSPEED] = misc::friendlyUnit(status.download_payload_rate, true); // FIXME: Should be passed as a Number
ret[KEY_TORRENT_UPSPEED] = misc::friendlyUnit(status.upload_payload_rate, true); // FIXME: Should be passed as a Number ret[KEY_TORRENT_UPSPEED] = misc::friendlyUnit(status.upload_payload_rate, true); // FIXME: Should be passed as a Number
if (QBtSession::instance()->isQueueingEnabled() && h.queue_position() >= 0) if (QBtSession::instance()->isQueueingEnabled() && h.queue_position(status) >= 0)
ret[KEY_TORRENT_PRIORITY] = QString::number(h.queue_position()); ret[KEY_TORRENT_PRIORITY] = QString::number(h.queue_position(status));
else else
ret[KEY_TORRENT_PRIORITY] = "*"; ret[KEY_TORRENT_PRIORITY] = "*";
QString seeds = QString::number(status.num_seeds); QString seeds = QString::number(status.num_seeds);

Loading…
Cancel
Save