From 0ead6f72c69650a4e6c2dfaa2acabd58d24efffe Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 17 Apr 2011 15:00:48 +0000 Subject: [PATCH] Code optimization --- src/properties/propertieswidget.cpp | 2 +- src/qtlibtorrent/qtorrenthandle.cpp | 11 +++++++++-- src/qtlibtorrent/qtorrenthandle.h | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/properties/propertieswidget.cpp b/src/properties/propertieswidget.cpp index aaca8ab81..1817e7d0c 100644 --- a/src/properties/propertieswidget.cpp +++ b/src/properties/propertieswidget.cpp @@ -373,7 +373,7 @@ void PropertiesWidget::loadDynamicData() { std::vector avail; h.piece_availability(avail); pieces_availability->setAvailability(avail); - avail_average_lbl->setText(QString::number(h.status().distributed_copies, 'f', 3)); + avail_average_lbl->setText(QString::number(h.distributed_copies(), 'f', 3)); } else { showPiecesAvailability(false); } diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index f5b0066c1..83b2f59fb 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -559,13 +559,20 @@ void QTorrentHandle::downloading_pieces(bitfield &bf) const { bool QTorrentHandle::has_metadata() const { #if LIBTORRENT_VERSION_MINOR > 15 - torrent_status st = torrent_handle::status(0x0); - return st.has_metadata; + return torrent_handle::status(query_distributed_copies).has_metadata; #else return torrent_handle::has_metadata(); #endif } +float QTorrentHandle::distributed_copies() const { +#if LIBTORRENT_VERSION_MINOR > 15 +return torrent_handle::status(0x0).distributed_copies; +#else + return torrent_handle::status().distributed_copies; +#endif +} + // // Setters // diff --git a/src/qtlibtorrent/qtorrenthandle.h b/src/qtlibtorrent/qtorrenthandle.h index d957b462c..8bb1b6f6c 100644 --- a/src/qtlibtorrent/qtorrenthandle.h +++ b/src/qtlibtorrent/qtorrenthandle.h @@ -118,6 +118,7 @@ public: QString error() const; void downloading_pieces(libtorrent::bitfield &bf) const; bool has_metadata() const; + float distributed_copies() const; // // Setters