diff --git a/Changelog b/Changelog index b65991e60..44152ae9e 100644 --- a/Changelog +++ b/Changelog @@ -14,6 +14,7 @@ - FEATURE: Option to skip file checking and start seeding immediately in torrent addition dialog (Stephanos Antaris) - FEATURE: Dropped dependency on libcurl - FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is required) + - FEATURE: Display more information regarding the torrent in its properties - FEATURE: Various optimizations to save CPU and memory - COSMETIC: Merged download / upload lists - COSMETIC: Torrents can be filtered based on their status diff --git a/src/misc.h b/src/misc.h index c951fd329..2b8d86ceb 100644 --- a/src/misc.h +++ b/src/misc.h @@ -41,6 +41,10 @@ #include #include #include +#include +#include +#include +#include #ifndef Q_WS_WIN #ifdef Q_WS_MAC @@ -308,6 +312,12 @@ public: return hash; } + static QString boostTimeToQString(boost::optional boostDate) { + if(!boostDate) return tr("Unknown"); + struct std::tm tm = boost::posix_time::to_tm(*boostDate); + return QDateTime::fromTime_t(mktime(&tm)).toString(Qt::DefaultLocaleLongDate); + } + // Take a number of seconds and return an user-friendly // time duration like "1d 2h 10m". static QString userFriendlyDuration(qlonglong seconds) { diff --git a/src/propertiesWidget.ui b/src/propertiesWidget.ui index 162a67a6b..7623c00d7 100644 --- a/src/propertiesWidget.ui +++ b/src/propertiesWidget.ui @@ -2,26 +2,14 @@ PropertiesWidget - - - 0 - 0 - 758 - 235 - - - - - 0 - 0 - + + + 8 + Form - - - 0 @@ -31,301 +19,113 @@ - - - 0 - 0 - - - - - 16777215 - 260 - - 0 - + + + 0 + + + 0 + - - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - Downloaded: - - - - - - - - 0 - 0 - - - - - 44 - 16777215 - - - - 0.0% - - - - - - - - - 0 + + + Qt::ScrollBarAsNeeded - - - - - 8 - 75 - true - + + true + + + + + 0 + -39 + 714 + 285 + + + + + 3 - - Torrent information + + 3 - - - 0 - - + + 1 + + + + + + + + 0 + 0 + + + + + 100 + 16777215 + + + + Downloaded: + + + + + + + + 0 + 0 + + + + + 44 + 16777215 + + + + 0.0% + + + Qt::AlignCenter + + + 0 + + + + + + + + + Qt::Horizontal + + + + + + + Transfer + - - - - - - - 16777215 - 22 - - - - - 8 - 50 - false - - - - Save path: - - - - - - - - 8 - 50 - false - - - - Creator: - - - - - - - - 8 - 50 - false - - - - Torrent hash: - - - - - - - - 8 - 50 - false - - - - Comment: - - - - - - - - - - - - - - 16777215 - 22 - - - - - 50 - false - - - - - - - - - - - - 22 - 22 - - - - - 50 - false - - - - ... - - - - - - - - - - 50 - false - - - - - - - - - - - - 50 - false - - - - - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 50 - false - - - - - - - - - - - - - - - Qt::Horizontal + + 3 - - - 190 - 20 - + + 3 - - - - - - - - - - 0 - 0 - - - - - 8 - 75 - false - true - false - false - - - - Current session - - - - 9 - - - 9 - - - 9 - - - 0 - - - - - 6 - - - 0 + + 3 @@ -337,62 +137,22 @@ - - - 50 - false - false - false - false - - - Total uploaded: + Uploaded: - - - 50 - false - false - false - false - - - Total downloaded: - - - - - - - - 50 - false - - - - Share ratio: + Downloaded: - - - 50 - false - false - false - false - - - Total failed: + Wasted: @@ -400,101 +160,313 @@ - - 6 - - - 0 - - - - 50 - false - - - + 0 Kb - - - 50 - false - - - + 0 Kb - - - - 50 - false - - + - - - - - - - - - 50 - false - - - - + 0 kb - + Qt::Horizontal - 181 + 97 + 20 + + + + + + + + + + UP limit: + + + + + + + DL limit: + + + + + + + Time elapsed: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 98 + 20 + + + + + + + + + + Share ratio: + + + + + + + Connections: + + + + + + + + + + + + + + + + + + 1.0 + + + + + + + 0 + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 97 20 - - - - - - - - - - - 8 - 50 - false - false - false - false - - - - Download in correct order (slower but good for previewing) - + + + + + + Information + + + + 6 + + + 3 + + + 9 + + + 3 + + + 3 + + + + + + + + 16777215 + 19 + + + + Save path: + + + + + + + Created on: + + + + + + + Torrent hash: + + + + + + + Comment: + + + + + + + + + + + 6 + + + + + path + + + + + + + + 22 + 19 + + + + ... + + + false + + + + + + + + + date + + + + + + + hash + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + comment + + + + + + + + + Qt::Horizontal + + + + 517 + 20 + + + + + + + + + + + Download in correct order (slower but good for previewing) + + + + + @@ -714,16 +686,6 @@ 16 - - - 8 - 50 - false - false - false - false - - Current tracker: @@ -920,6 +882,9 @@ 5 + + 2 + diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 19ac5a0f4..74c1af20c 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -140,16 +140,20 @@ void PropertiesWidget::slide() { void PropertiesWidget::clear() { save_path->clear(); - creator->clear(); + lbl_creationDate->clear(); hash_lbl->clear(); comment_lbl->clear(); incrementalDownload->setChecked(false); trackersURLS->clear(); trackerURL->clear(); progressBar->setProgress(QRealArray()); - failed->clear(); + wasted->clear(); upTotal->clear(); dlTotal->clear(); + lbl_uplimit->clear(); + lbl_dllimit->clear(); + lbl_elapsed->clear(); + lbl_connections->clear(); shareRatio->clear(); listWebSeeds->clear(); PropListModel->clear(); @@ -171,11 +175,8 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) { try { // Save path save_path->setText(TorrentPersistentData::getSavePath(h.hash())); - // Author - QString author = h.creator().trimmed(); - if(author.isEmpty()) - author = tr("Unknown"); - creator->setText(author); + // Creation date + lbl_creationDate->setText(h.creation_date()); // Hash hash_lbl->setText(h.hash()); // Comment @@ -225,7 +226,7 @@ void PropertiesWidget::readSettings() { reduce(); } else { main_infos_button->setStyleSheet(SELECTED_BUTTON_CSS); - setEnabled(false); + //setEnabled(false); } } @@ -254,10 +255,18 @@ void PropertiesWidget::saveSettings() { void PropertiesWidget::loadDynamicData() { if(!h.is_valid()) return; try { - // Session infos - failed->setText(misc::friendlyUnit(h.total_failed_bytes())); - upTotal->setText(misc::friendlyUnit(h.total_payload_upload())); - dlTotal->setText(misc::friendlyUnit(h.total_payload_download())); + // Transfer infos + wasted->setText(misc::friendlyUnit(h.total_failed_bytes()+h.total_redundant_bytes())); + upTotal->setText(misc::friendlyUnit(h.all_time_upload()) + " ("+misc::friendlyUnit(h.total_payload_upload())+" "+tr("this session")+")"); + dlTotal->setText(misc::friendlyUnit(h.all_time_download()) + " ("+misc::friendlyUnit(h.total_payload_download())+" "+tr("this session")+")"); + lbl_uplimit->setText(misc::friendlyUnit(h.upload_limit())); + lbl_dllimit->setText(misc::friendlyUnit(h.download_limit())); + QString elapsed_txt = misc::userFriendlyDuration(h.active_time()); + if(h.is_seed()) { + elapsed_txt += " ("+tr("Seeding for %1", "e.g. Seeding for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")"; + } + lbl_elapsed->setText(elapsed_txt); + lbl_connections->setText(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")"); // Update ratio info float ratio; if(h.total_payload_download() == 0){ diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index bb3ccb7ab..0382a58eb 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -63,6 +63,12 @@ QString QTorrentHandle::name() const { return misc::toQString(h.name()); } +QString QTorrentHandle::creation_date() const { + Q_ASSERT(h.is_valid()); + boost::optional boostDate = h.get_torrent_info().creation_date(); + return misc::boostTimeToQString(boostDate); +} + float QTorrentHandle::progress() const { Q_ASSERT(h.is_valid()); if(!h.status().total_wanted) @@ -264,6 +270,11 @@ size_type QTorrentHandle::total_failed_bytes() const { return h.status().total_failed_bytes; } +size_type QTorrentHandle::total_redundant_bytes() const { + Q_ASSERT(h.is_valid()); + return h.status().total_redundant_bytes; +} + void QTorrentHandle::file_progress(std::vector& fp) { Q_ASSERT(h.is_valid()); return h.file_progress(fp); @@ -328,11 +339,26 @@ bool QTorrentHandle::is_auto_managed() const { return h.is_auto_managed(); } -int QTorrentHandle::active_time() const { +qlonglong QTorrentHandle::active_time() const { Q_ASSERT(h.is_valid()); return h.status().active_time; } +qlonglong QTorrentHandle::seeding_time() const { + Q_ASSERT(h.is_valid()); + return h.status().seeding_time; +} + +int QTorrentHandle::num_connections() const { + Q_ASSERT(h.is_valid()); + return h.status().num_connections; +} + +int QTorrentHandle::connections_limit() const { + Q_ASSERT(h.is_valid()); + return h.status().connections_limit; +} + bool QTorrentHandle::is_sequential_download() const { Q_ASSERT(h.is_valid()); return h.is_sequential_download(); diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index 090a165b2..1e62f42cf 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -35,13 +35,13 @@ #include using namespace libtorrent; - -class QString; +#include class QStringList; // A wrapper for torrent_handle in libtorrent // to interact well with Qt types class QTorrentHandle { + private: torrent_handle h; @@ -75,6 +75,8 @@ class QTorrentHandle { size_type total_wanted_done() const; float download_payload_rate() const; float upload_payload_rate() const; + int num_connections() const; + int connections_limit() const; int num_peers() const; int num_seeds() const; int num_complete() const; @@ -97,6 +99,7 @@ class QTorrentHandle { QString creator() const; QString comment() const; size_type total_failed_bytes() const; + size_type total_redundant_bytes() const; void file_progress(std::vector& fp); size_type total_payload_download(); size_type total_payload_upload(); @@ -106,10 +109,12 @@ class QTorrentHandle { int num_uploads() const; bool is_seed() const; bool is_auto_managed() const; - int active_time() const; + qlonglong active_time() const; + qlonglong seeding_time() const; std::vector file_priorities() const; bool is_sequential_download() const; bool super_seeding() const; + QString creation_date() const; // // Setters