Browse Source

- Display more information regarding the torrent in its properties pannel

- Made properties pannel scrollable, it behaves better with the splitter
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
a6f31c7950
  1. 1
      Changelog
  2. 10
      src/misc.h
  3. 697
      src/propertiesWidget.ui
  4. 33
      src/propertieswidget.cpp
  5. 28
      src/qtorrenthandle.cpp
  6. 11
      src/qtorrenthandle.h

1
Changelog

@ -14,6 +14,7 @@
- FEATURE: Option to skip file checking and start seeding immediately in torrent addition dialog (Stephanos Antaris) - FEATURE: Option to skip file checking and start seeding immediately in torrent addition dialog (Stephanos Antaris)
- FEATURE: Dropped dependency on libcurl - FEATURE: Dropped dependency on libcurl
- FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is required) - 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 - FEATURE: Various optimizations to save CPU and memory
- COSMETIC: Merged download / upload lists - COSMETIC: Merged download / upload lists
- COSMETIC: Torrents can be filtered based on their status - COSMETIC: Torrents can be filtered based on their status

10
src/misc.h

@ -41,6 +41,10 @@
#include <QList> #include <QList>
#include <QPair> #include <QPair>
#include <QThread> #include <QThread>
#include <ctime>
#include <QDateTime>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
#ifndef Q_WS_WIN #ifndef Q_WS_WIN
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
@ -308,6 +312,12 @@ public:
return hash; return hash;
} }
static QString boostTimeToQString(boost::optional<boost::posix_time::ptime> 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 // Take a number of seconds and return an user-friendly
// time duration like "1d 2h 10m". // time duration like "1d 2h 10m".
static QString userFriendlyDuration(qlonglong seconds) { static QString userFriendlyDuration(qlonglong seconds) {

697
src/propertiesWidget.ui

@ -2,26 +2,14 @@
<ui version="4.0"> <ui version="4.0">
<class>PropertiesWidget</class> <class>PropertiesWidget</class>
<widget class="QWidget" name="PropertiesWidget"> <widget class="QWidget" name="PropertiesWidget">
<property name="geometry"> <property name="font">
<rect> <font>
<x>0</x> <pointsize>8</pointsize>
<y>0</y> </font>
<width>758</width>
<height>235</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<property name="styleSheet">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
@ -31,470 +19,454 @@
</property> </property>
<item> <item>
<widget class="QStackedWidget" name="stackedProperties"> <widget class="QStackedWidget" name="stackedProperties">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>260</height>
</size>
</property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item> <property name="spacing">
<layout class="QHBoxLayout" name="ProgressHLayout"> <number>0</number>
<item> </property>
<widget class="QLabel" name="downloaded_pieces_lbl"> <property name="margin">
<property name="sizePolicy"> <number>0</number>
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> </property>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Downloaded:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="progress_lbl">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>44</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string notr="true">0.0%</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <widget class="QScrollArea" name="scrollArea">
<property name="spacing"> <property name="verticalScrollBarPolicy">
<number>0</number> <enum>Qt::ScrollBarAsNeeded</enum>
</property> </property>
<item> <property name="widgetResizable">
<widget class="QGroupBox" name="groupTorrentInfos"> <bool>true</bool>
<property name="font"> </property>
<font> <widget class="QWidget" name="scrollAreaWidgetContents">
<pointsize>8</pointsize> <property name="geometry">
<weight>75</weight> <rect>
<bold>true</bold> <x>0</x>
</font> <y>-39</y>
<width>714</width>
<height>285</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<property name="spacing">
<number>3</number>
</property> </property>
<property name="title"> <property name="topMargin">
<string>Torrent information</string> <number>3</number>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <property name="bottomMargin">
<property name="bottomMargin"> <number>1</number>
<number>0</number> </property>
</property> <item>
<item> <layout class="QHBoxLayout" name="ProgressHLayout">
<item>
<widget class="QLabel" name="downloaded_pieces_lbl">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Downloaded:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="progress_lbl">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>44</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string notr="true">0.0%</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Transfer</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="_4">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="savePath_lbl"> <widget class="QLabel" name="label_5">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>Save path:</string> <string>Uploaded:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="creator_lbl"> <widget class="QLabel" name="label_6">
<property name="font">
<font>
<pointsize>8</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>Creator:</string> <string>Downloaded:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="hash_lbl2"> <widget class="QLabel" name="label_8">
<property name="font"> <property name="text">
<font> <string>Wasted:</string>
<pointsize>8</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property> </property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="_5">
<item>
<widget class="QLabel" name="upTotal">
<property name="text"> <property name="text">
<string>Torrent hash:</string> <string notr="true">0 Kb</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="comment_lbl2"> <widget class="QLabel" name="dlTotal">
<property name="font"> <property name="text">
<font> <string notr="true">0 Kb</string>
<pointsize>8</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property> </property>
</widget>
</item>
<item>
<widget class="QLabel" name="wasted">
<property name="text"> <property name="text">
<string>Comment:</string> <string notr="true">0 kb</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_3"> <spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>97</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <widget class="QLabel" name="label">
<item> <property name="text">
<widget class="QLabel" name="save_path"> <string>UP limit:</string>
<property name="maximumSize"> </property>
<size> </widget>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="changeSavePathButton">
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QLabel" name="creator"> <widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string/> <string>DL limit:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="hash_lbl"> <widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string/> <string>Time elapsed:</string>
</property> </property>
<property name="textInteractionFlags"> </widget>
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> </item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="lbl_uplimit">
<property name="text">
<string notr="true">∞</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="comment_lbl"> <widget class="QLabel" name="lbl_dllimit">
<property name="font"> <property name="text">
<font> <string notr="true">∞</string>
<weight>50</weight>
<bold>false</bold>
</font>
</property> </property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_elapsed">
<property name="text"> <property name="text">
<string/> <string notr="true">∞</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
</layout>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>190</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="title">
<string>Current session</string>
</property>
<layout class="QVBoxLayout" name="_2">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="_3">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" name="_4"> <spacer name="horizontalSpacer_5">
<property name="spacing"> <property name="orientation">
<number>6</number> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="margin"> <property name="sizeHint" stdset="0">
<number>0</number> <size>
<width>98</width>
<height>20</height>
</size>
</property> </property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item> <item>
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="lbl_ratio">
<property name="font">
<font>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text"> <property name="text">
<string>Total uploaded:</string> <string>Share ratio:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text"> <property name="text">
<string>Total downloaded:</string> <string>Connections:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="lbl_ratio"> <widget class="QLabel" name="label_10">
<property name="font"> <property name="text">
<font> <string notr="true"> </string>
<weight>50</weight>
<bold>false</bold>
</font>
</property> </property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QLabel" name="shareRatio">
<property name="text"> <property name="text">
<string>Share ratio:</string> <string notr="true">1.0</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="lbl_connections">
<property name="font"> <property name="text">
<font> <string notr="true">0</string>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property> </property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="text"> <property name="text">
<string>Total failed:</string> <string notr="true"> </string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="_5"> <spacer name="horizontalSpacer_3">
<property name="spacing"> <property name="orientation">
<number>6</number> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="margin"> <property name="sizeHint" stdset="0">
<number>0</number> <size>
<width>97</width>
<height>20</height>
</size>
</property> </property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupTorrentInfos">
<property name="title">
<string>Information</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QLabel" name="upTotal"> <widget class="QLabel" name="savePath_lbl">
<property name="font"> <property name="maximumSize">
<font> <size>
<weight>50</weight> <width>16777215</width>
<bold>false</bold> <height>19</height>
</font> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>Save path:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="dlTotal"> <widget class="QLabel" name="label_9">
<property name="font"> <property name="text">
<font> <string>Created on:</string>
<weight>50</weight>
<bold>false</bold>
</font>
</property> </property>
</widget>
</item>
<item>
<widget class="QLabel" name="hash_lbl2">
<property name="text"> <property name="text">
<string/> <string>Torrent hash:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="shareRatio"> <widget class="QLabel" name="comment_lbl2">
<property name="font"> <property name="text">
<font> <string>Comment:</string>
<weight>50</weight> </property>
<bold>false</bold> </widget>
</font> </item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property> </property>
<item>
<widget class="QLabel" name="save_path">
<property name="text">
<string notr="true">path</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="changeSavePathButton">
<property name="maximumSize">
<size>
<width>22</width>
<height>19</height>
</size>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="lbl_creationDate">
<property name="text"> <property name="text">
<string/> <string notr="true">date</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="failed"> <widget class="QLabel" name="hash_lbl">
<property name="font"> <property name="text">
<font> <string notr="true">hash</string>
<weight>50</weight>
<bold>false</bold>
</font>
</property> </property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="comment_lbl">
<property name="text"> <property name="text">
<string/> <string notr="true">comment</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<spacer> <spacer name="horizontalSpacer_4">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>181</width> <width>517</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</item> </widget>
</layout> </item>
</widget> <item>
</item> <widget class="QCheckBox" name="incrementalDownload">
</layout> <property name="text">
</item> <string>Download in correct order (slower but good for previewing)</string>
<item> </property>
<widget class="QCheckBox" name="incrementalDownload"> </widget>
<property name="font"> </item>
<font> </layout>
<pointsize>8</pointsize> </widget>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text">
<string>Download in correct order (slower but good for previewing)</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -714,16 +686,6 @@
<height>16</height> <height>16</height>
</size> </size>
</property> </property>
<property name="font">
<font>
<pointsize>8</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text"> <property name="text">
<string>Current tracker:</string> <string>Current tracker:</string>
</property> </property>
@ -920,6 +882,9 @@
<property name="rightMargin"> <property name="rightMargin">
<number>5</number> <number>5</number>
</property> </property>
<property name="bottomMargin">
<number>2</number>
</property>
<item> <item>
<widget class="QPushButton" name="main_infos_button"> <widget class="QPushButton" name="main_infos_button">
<property name="styleSheet"> <property name="styleSheet">

33
src/propertieswidget.cpp

@ -140,16 +140,20 @@ void PropertiesWidget::slide() {
void PropertiesWidget::clear() { void PropertiesWidget::clear() {
save_path->clear(); save_path->clear();
creator->clear(); lbl_creationDate->clear();
hash_lbl->clear(); hash_lbl->clear();
comment_lbl->clear(); comment_lbl->clear();
incrementalDownload->setChecked(false); incrementalDownload->setChecked(false);
trackersURLS->clear(); trackersURLS->clear();
trackerURL->clear(); trackerURL->clear();
progressBar->setProgress(QRealArray()); progressBar->setProgress(QRealArray());
failed->clear(); wasted->clear();
upTotal->clear(); upTotal->clear();
dlTotal->clear(); dlTotal->clear();
lbl_uplimit->clear();
lbl_dllimit->clear();
lbl_elapsed->clear();
lbl_connections->clear();
shareRatio->clear(); shareRatio->clear();
listWebSeeds->clear(); listWebSeeds->clear();
PropListModel->clear(); PropListModel->clear();
@ -171,11 +175,8 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
try { try {
// Save path // Save path
save_path->setText(TorrentPersistentData::getSavePath(h.hash())); save_path->setText(TorrentPersistentData::getSavePath(h.hash()));
// Author // Creation date
QString author = h.creator().trimmed(); lbl_creationDate->setText(h.creation_date());
if(author.isEmpty())
author = tr("Unknown");
creator->setText(author);
// Hash // Hash
hash_lbl->setText(h.hash()); hash_lbl->setText(h.hash());
// Comment // Comment
@ -225,7 +226,7 @@ void PropertiesWidget::readSettings() {
reduce(); reduce();
} else { } else {
main_infos_button->setStyleSheet(SELECTED_BUTTON_CSS); main_infos_button->setStyleSheet(SELECTED_BUTTON_CSS);
setEnabled(false); //setEnabled(false);
} }
} }
@ -254,10 +255,18 @@ void PropertiesWidget::saveSettings() {
void PropertiesWidget::loadDynamicData() { void PropertiesWidget::loadDynamicData() {
if(!h.is_valid()) return; if(!h.is_valid()) return;
try { try {
// Session infos // Transfer infos
failed->setText(misc::friendlyUnit(h.total_failed_bytes())); wasted->setText(misc::friendlyUnit(h.total_failed_bytes()+h.total_redundant_bytes()));
upTotal->setText(misc::friendlyUnit(h.total_payload_upload())); upTotal->setText(misc::friendlyUnit(h.all_time_upload()) + " ("+misc::friendlyUnit(h.total_payload_upload())+" "+tr("this session")+")");
dlTotal->setText(misc::friendlyUnit(h.total_payload_download())); 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 // Update ratio info
float ratio; float ratio;
if(h.total_payload_download() == 0){ if(h.total_payload_download() == 0){

28
src/qtorrenthandle.cpp

@ -63,6 +63,12 @@ QString QTorrentHandle::name() const {
return misc::toQString(h.name()); return misc::toQString(h.name());
} }
QString QTorrentHandle::creation_date() const {
Q_ASSERT(h.is_valid());
boost::optional<boost::posix_time::ptime> boostDate = h.get_torrent_info().creation_date();
return misc::boostTimeToQString(boostDate);
}
float QTorrentHandle::progress() const { float QTorrentHandle::progress() const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
if(!h.status().total_wanted) if(!h.status().total_wanted)
@ -264,6 +270,11 @@ size_type QTorrentHandle::total_failed_bytes() const {
return h.status().total_failed_bytes; 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<size_type>& fp) { void QTorrentHandle::file_progress(std::vector<size_type>& fp) {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
return h.file_progress(fp); return h.file_progress(fp);
@ -328,11 +339,26 @@ bool QTorrentHandle::is_auto_managed() const {
return h.is_auto_managed(); return h.is_auto_managed();
} }
int QTorrentHandle::active_time() const { qlonglong QTorrentHandle::active_time() const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
return h.status().active_time; 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 { bool QTorrentHandle::is_sequential_download() const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
return h.is_sequential_download(); return h.is_sequential_download();

11
src/qtorrenthandle.h

@ -35,13 +35,13 @@
#include <libtorrent/torrent_info.hpp> #include <libtorrent/torrent_info.hpp>
using namespace libtorrent; using namespace libtorrent;
#include <QString>
class QString;
class QStringList; class QStringList;
// A wrapper for torrent_handle in libtorrent // A wrapper for torrent_handle in libtorrent
// to interact well with Qt types // to interact well with Qt types
class QTorrentHandle { class QTorrentHandle {
private: private:
torrent_handle h; torrent_handle h;
@ -75,6 +75,8 @@ class QTorrentHandle {
size_type total_wanted_done() const; size_type total_wanted_done() const;
float download_payload_rate() const; float download_payload_rate() const;
float upload_payload_rate() const; float upload_payload_rate() const;
int num_connections() const;
int connections_limit() const;
int num_peers() const; int num_peers() const;
int num_seeds() const; int num_seeds() const;
int num_complete() const; int num_complete() const;
@ -97,6 +99,7 @@ class QTorrentHandle {
QString creator() const; QString creator() const;
QString comment() const; QString comment() const;
size_type total_failed_bytes() const; size_type total_failed_bytes() const;
size_type total_redundant_bytes() const;
void file_progress(std::vector<size_type>& fp); void file_progress(std::vector<size_type>& fp);
size_type total_payload_download(); size_type total_payload_download();
size_type total_payload_upload(); size_type total_payload_upload();
@ -106,10 +109,12 @@ class QTorrentHandle {
int num_uploads() const; int num_uploads() const;
bool is_seed() const; bool is_seed() const;
bool is_auto_managed() const; bool is_auto_managed() const;
int active_time() const; qlonglong active_time() const;
qlonglong seeding_time() const;
std::vector<int> file_priorities() const; std::vector<int> file_priorities() const;
bool is_sequential_download() const; bool is_sequential_download() const;
bool super_seeding() const; bool super_seeding() const;
QString creation_date() const;
// //
// Setters // Setters

Loading…
Cancel
Save