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

6
src/TransferListWidget.cpp

@ -789,6 +789,12 @@ void TransferListWidget::loadLastSortedColumn() { @@ -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) {
switch(f) {
case DOWNLOADING:

4
src/TransferListWidget.h

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

249
src/propertiesWidget.ui

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

78
src/propertieswidget.cpp

@ -28,12 +28,88 @@ @@ -28,12 +28,88 @@
* Contact : chris@qbittorrent.org
*/
#include <QTimer>
#include <QVBoxLayout>
#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);
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() {
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 @@ @@ -33,11 +33,31 @@
#include <QWidget>
#include "ui_propertiesWidget.h"
#include "qtorrenthandle.h"
class TransferListWidget;
class QTimer;
class RealProgressBar;
class QVBoxLayout;
class RealProgressBarThread;
class PropertiesWidget : public QWidget, private Ui::PropertiesWidget {
Q_OBJECT
private:
TransferListWidget *transferList;
QTorrentHandle h;
QTimer *refreshTimer;
RealProgressBar *progressBar;
RealProgressBarThread *progressBarUpdater;
QVBoxLayout *progressBarVbox;
protected slots:
void loadTorrentInfos(QTorrentHandle &h);
void loadDynamicData();
public:
PropertiesWidget(QWidget *parent);
PropertiesWidget(QWidget *parent, TransferListWidget *transferList);
~PropertiesWidget();
};

Loading…
Cancel
Save