Browse Source

- Added back trackers display in torrent properties

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
cee9ece4c7
  1. 2
      src/GUI.cpp
  2. 280
      src/propertiesWidget.ui
  3. 51
      src/propertieswidget.cpp
  4. 9
      src/propertieswidget.h

2
src/GUI.cpp

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

280
src/propertiesWidget.ui

@ -451,7 +451,285 @@ @@ -451,7 +451,285 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2"/>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QHBoxLayout" name="_20">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_12">
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text">
<string>Trackers:</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="_21">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QListWidget" name="trackersURLS">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="_22">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="removeTracker_button">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/Icons/oxygen/list-remove.png</normaloff>:/Icons/oxygen/list-remove.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addTracker_button">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/Icons/oxygen/list-add.png</normaloff>:/Icons/oxygen/list-add.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="_23">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="riseTracker_button">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/Icons/uparrow.png</normaloff>:/Icons/uparrow.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="lowerTracker_button">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/Icons/downarrow.png</normaloff>:/Icons/downarrow.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_24">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text">
<string>Current tracker:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="trackerURL">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>

51
src/propertieswidget.cpp

@ -29,14 +29,17 @@ @@ -29,14 +29,17 @@
*/
#include <QTimer>
#include <QListWidgetItem>
#include <QVBoxLayout>
#include <QStackedWidget>
#include "propertieswidget.h"
#include "TransferListWidget.h"
#include "torrentPersistentData.h"
#include "realprogressbar.h"
#include "realprogressbarthread.h"
#include "bittorrent.h"
PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transferList): QWidget(parent), transferList(transferList) {
PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession): QWidget(parent), transferList(transferList), BTSession(BTSession) {
setupUi(this);
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
connect(incrementalDownload, SIGNAL(stateChanged(int)), this, SLOT(setIncrementalDownload(int)));
@ -80,6 +83,8 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) { @@ -80,6 +83,8 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
comment_lbl->setText(h.comment());
// Sequential download
incrementalDownload->setChecked(TorrentPersistentData::isSequentialDownload(h.hash()));
// Trackers
loadTrackers();
// downloaded pieces updater
progressBarUpdater = new RealProgressBarThread(progressBar, h);
progressBarUpdater->start();
@ -122,3 +127,47 @@ void PropertiesWidget::setIncrementalDownload(int checkboxState) { @@ -122,3 +127,47 @@ void PropertiesWidget::setIncrementalDownload(int checkboxState) {
h.set_sequential_download(checkboxState == Qt::Checked);
TorrentPersistentData::saveSequentialStatus(h);
}
void PropertiesWidget::loadTrackers() {
if(!h.is_valid()) return;
//Trackers
std::vector<announce_entry> trackers = h.trackers();
trackersURLS->clear();
QHash<QString, QString> errors = BTSession->getTrackersErrors(h.hash());
unsigned int nbTrackers = trackers.size();
for(unsigned int i=0; i<nbTrackers; ++i){
QString current_tracker = misc::toQString(trackers[i].url);
QListWidgetItem *item = new QListWidgetItem(current_tracker, trackersURLS);
// IsThere any errors ?
if(errors.contains(current_tracker)) {
item->setForeground(QBrush(QColor("red")));
// Set tooltip
QString msg="";
unsigned int i=0;
foreach(QString word, errors[current_tracker].split(" ")) {
if(i > 0 && i%5!=1) msg += " ";
msg += word;
if(i> 0 && i%5==0) msg += "\n";
++i;
}
item->setToolTip(msg);
} else {
item->setForeground(QBrush(QColor("green")));
}
}
QString tracker = h.current_tracker().trimmed();
if(!tracker.isEmpty()){
trackerURL->setText(tracker);
}else{
trackerURL->setText(tr("None - Unreachable?"));
}
}
/* Tab buttons */
void PropertiesWidget::on_main_infos_button_clicked() {
stackedProperties->setCurrentIndex(MAIN_TAB);
}
void PropertiesWidget::on_trackers_button_clicked() {
stackedProperties->setCurrentIndex(TRACKERS_TAB);
}

9
src/propertieswidget.h

@ -40,6 +40,9 @@ class QTimer; @@ -40,6 +40,9 @@ class QTimer;
class RealProgressBar;
class QVBoxLayout;
class RealProgressBarThread;
class bittorrent;
enum Tab {MAIN_TAB, TRACKERS_TAB, URLSEEDS_TAB, FILES_TAB};
class PropertiesWidget : public QWidget, private Ui::PropertiesWidget {
Q_OBJECT
@ -51,14 +54,18 @@ private: @@ -51,14 +54,18 @@ private:
RealProgressBar *progressBar;
RealProgressBarThread *progressBarUpdater;
QVBoxLayout *progressBarVbox;
bittorrent* BTSession;
protected slots:
void loadTorrentInfos(QTorrentHandle &h);
void loadDynamicData();
void setIncrementalDownload(int checkboxState);
void loadTrackers();
void on_main_infos_button_clicked();
void on_trackers_button_clicked();
public:
PropertiesWidget(QWidget *parent, TransferListWidget *transferList);
PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession);
~PropertiesWidget();
};

Loading…
Cancel
Save