Browse Source

- Made progress on torrent properties (main tab)

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
75e5a7e3d4
  1. 4
      src/GUI.cpp
  2. 6
      src/TransferListWidget.cpp
  3. 4
      src/TransferListWidget.h
  4. 249
      src/propertiesWidget.ui
  5. 78
      src/propertieswidget.cpp
  6. 22
      src/propertieswidget.h

4
src/GUI.cpp

@ -141,8 +141,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
hSplitter = new QSplitter(Qt::Vertical, vSplitter); hSplitter = new QSplitter(Qt::Vertical, vSplitter);
// Transfer List tab // Transfer List tab
properties = new PropertiesWidget(hSplitter); transferList = new TransferListWidget(hSplitter, BTSession);
transferList = new TransferListWidget(vSplitter, BTSession); properties = new PropertiesWidget(hSplitter, transferList);
transferListFilters = new TransferListFiltersWidget(vSplitter, transferList); transferListFilters = new TransferListFiltersWidget(vSplitter, transferList);
hSplitter->addWidget(transferList); hSplitter->addWidget(transferList);
hSplitter->addWidget(properties); hSplitter->addWidget(properties);

6
src/TransferListWidget.cpp

@ -789,6 +789,12 @@ void TransferListWidget::loadLastSortedColumn() {
} }
} }
void TransferListWidget::currentChanged(const QModelIndex& current, const QModelIndex&) {
int row = proxyModel->mapToSource(current).row();
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(row));
emit currentTorrentChanged(h);
}
void TransferListWidget::applyFilter(int f) { void TransferListWidget::applyFilter(int f) {
switch(f) { switch(f) {
case DOWNLOADING: case DOWNLOADING:

4
src/TransferListWidget.h

@ -74,6 +74,7 @@ protected slots:
void saveHiddenColumns(); void saveHiddenColumns();
void displayListMenu(const QPoint&); void displayListMenu(const QPoint&);
void updateMetadata(QTorrentHandle &h); void updateMetadata(QTorrentHandle &h);
void currentChanged(const QModelIndex& current, const QModelIndex&);
//void setRowColor(int row, QColor color); //void setRowColor(int row, QColor color);
public slots: public slots:
@ -101,6 +102,9 @@ public slots:
void displayDLHoSMenu(const QPoint&); void displayDLHoSMenu(const QPoint&);
void applyFilter(int f); void applyFilter(int f);
signals:
void currentTorrentChanged(QTorrentHandle &h);
}; };
#endif // TRANSFERLISTWIDGET_H #endif // TRANSFERLISTWIDGET_H

249
src/propertiesWidget.ui

@ -22,7 +22,7 @@
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>
<widget class="QGroupBox" name="groupTorrentInfos"> <widget class="QGroupBox" name="groupTorrentInfos">
<property name="font"> <property name="font">
@ -34,82 +34,146 @@
<property name="title"> <property name="title">
<string>Torrent information</string> <string>Torrent information</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QLabel" name="savePath_lbl"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="font"> <item>
<font> <widget class="QLabel" name="savePath_lbl">
<weight>50</weight> <property name="maximumSize">
<bold>false</bold> <size>
</font> <width>16777215</width>
</property> <height>22</height>
<property name="text"> </size>
<string>Save path:</string> </property>
</property> <property name="font">
</widget> <font>
</item> <weight>50</weight>
<item> <bold>false</bold>
<widget class="QLabel" name="creator_lbl"> </font>
<property name="font"> </property>
<font> <property name="text">
<weight>50</weight> <string>Save path:</string>
<bold>false</bold> </property>
</font> </widget>
</property> </item>
<property name="text"> <item>
<string>Creator:</string> <widget class="QLabel" name="creator_lbl">
</property> <property name="font">
</widget> <font>
</item> <weight>50</weight>
<item> <bold>false</bold>
<widget class="QLabel" name="hash_lbl2"> </font>
<property name="font"> </property>
<font> <property name="text">
<weight>50</weight> <string>Creator:</string>
<bold>false</bold> </property>
</font> </widget>
</property> </item>
<property name="text"> <item>
<string>Torrent hash:</string> <widget class="QLabel" name="hash_lbl2">
</property> <property name="font">
</widget> <font>
</item> <weight>50</weight>
<item> <bold>false</bold>
<widget class="QLabel" name="comment_lbl2"> </font>
<property name="font"> </property>
<font> <property name="text">
<weight>50</weight> <string>Torrent hash:</string>
<bold>false</bold> </property>
</font> </widget>
</property> </item>
<property name="text"> <item>
<string>Comment:</string> <widget class="QLabel" name="comment_lbl2">
</property> <property name="font">
</widget> <font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Comment:</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QLabel" name="save_path"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="save_path">
<property name="maximumSize">
<size>
<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>
<widget class="QLabel" name="creator">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="changeSavePathButton"> <widget class="QLabel" name="hash_lbl">
<property name="maximumSize"> <property name="font">
<size> <font>
<width>27</width> <weight>50</weight>
<height>16777215</height> <bold>false</bold>
</size> </font>
</property>
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property> </property>
</widget>
</item>
<item>
<widget class="QLabel" name="comment_lbl">
<property name="font"> <property name="font">
<font> <font>
<weight>50</weight> <weight>50</weight>
@ -117,39 +181,12 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>...</string> <string/>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QLabel" name="creator">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="hash_lbl">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="comment_lbl">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -159,7 +196,7 @@
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>185</width> <width>190</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
@ -303,6 +340,12 @@
</property> </property>
<item> <item>
<widget class="QLabel" name="upTotal"> <widget class="QLabel" name="upTotal">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -310,6 +353,12 @@
</item> </item>
<item> <item>
<widget class="QLabel" name="dlTotal"> <widget class="QLabel" name="dlTotal">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -317,6 +366,12 @@
</item> </item>
<item> <item>
<widget class="QLabel" name="shareRatio"> <widget class="QLabel" name="shareRatio">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -324,6 +379,12 @@
</item> </item>
<item> <item>
<widget class="QLabel" name="failed"> <widget class="QLabel" name="failed">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>

78
src/propertieswidget.cpp

@ -28,12 +28,88 @@
* Contact : chris@qbittorrent.org * Contact : chris@qbittorrent.org
*/ */
#include <QTimer>
#include <QVBoxLayout>
#include "propertieswidget.h" #include "propertieswidget.h"
#include "TransferListWidget.h"
#include "torrentPersistentData.h"
#include "realprogressbar.h"
#include "realprogressbarthread.h"
PropertiesWidget::PropertiesWidget(QWidget *parent): QWidget(parent) { PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transferList): QWidget(parent), transferList(transferList) {
setupUi(this); setupUi(this);
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
// Downloaded pieces progress bar
progressBar = new RealProgressBar(this);
progressBar->setForegroundColor(Qt::blue);
progressBarVbox = new QVBoxLayout(RealProgressBox);
progressBarVbox->addWidget(progressBar);
progressBarUpdater = 0;
// Dynamic data refresher
refreshTimer = new QTimer(this);
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData()));
refreshTimer->start(10000); // 10sec
} }
PropertiesWidget::~PropertiesWidget() { PropertiesWidget::~PropertiesWidget() {
delete refreshTimer;
if(progressBarUpdater)
delete progressBarUpdater;
delete progressBar;
delete progressBarVbox;
}
void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
h = _h;
if(!h.is_valid()) return;
if(progressBarUpdater)
delete progressBarUpdater;
progressBarUpdater = 0;
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);
// Hash
hash_lbl->setText(h.hash());
// Comment
comment_lbl->setText(h.comment());
// downloaded pieces updater
progressBarUpdater = new RealProgressBarThread(progressBar, h);
progressBarUpdater->start();
} catch(invalid_handle e) {
}
// Load dynamic data
loadDynamicData();
}
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()));
// Update ratio info
float ratio;
if(h.total_payload_download() == 0){
if(h.total_payload_upload() == 0)
ratio = 1.;
else
ratio = 10.; // Max ratio
}else{
ratio = (double)h.total_payload_upload()/(double)h.total_payload_download();
if(ratio > 10.){
ratio = 10.;
}
}
shareRatio->setText(QString(QByteArray::number(ratio, 'f', 1)));
// Downloaded pieces
if(progressBarUpdater)
progressBarUpdater->refresh();
} catch(invalid_handle e) {}
} }

22
src/propertieswidget.h

@ -33,11 +33,31 @@
#include <QWidget> #include <QWidget>
#include "ui_propertiesWidget.h" #include "ui_propertiesWidget.h"
#include "qtorrenthandle.h"
class TransferListWidget;
class QTimer;
class RealProgressBar;
class QVBoxLayout;
class RealProgressBarThread;
class PropertiesWidget : public QWidget, private Ui::PropertiesWidget { class PropertiesWidget : public QWidget, private Ui::PropertiesWidget {
Q_OBJECT Q_OBJECT
private:
TransferListWidget *transferList;
QTorrentHandle h;
QTimer *refreshTimer;
RealProgressBar *progressBar;
RealProgressBarThread *progressBarUpdater;
QVBoxLayout *progressBarVbox;
protected slots:
void loadTorrentInfos(QTorrentHandle &h);
void loadDynamicData();
public: public:
PropertiesWidget(QWidget *parent); PropertiesWidget(QWidget *parent, TransferListWidget *transferList);
~PropertiesWidget(); ~PropertiesWidget();
}; };

Loading…
Cancel
Save