diff --git a/src/GUI.cpp b/src/GUI.cpp index 1689a0ca7..1472f5a1f 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -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); diff --git a/src/propertiesWidget.ui b/src/propertiesWidget.ui index ce34fe123..8725943de 100644 --- a/src/propertiesWidget.ui +++ b/src/propertiesWidget.ui @@ -451,7 +451,285 @@ - + + + + + + 6 + + + 0 + + + + + + Sans Serif + 9 + 50 + false + false + false + false + + + + Trackers: + + + + + + + 6 + + + 0 + + + + + + 0 + 0 + + + + QAbstractItemView::ExtendedSelection + + + + + + + 6 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/Icons/oxygen/list-remove.png:/Icons/oxygen/list-remove.png + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/Icons/oxygen/list-add.png:/Icons/oxygen/list-add.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 6 + + + 0 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/Icons/uparrow.png:/Icons/uparrow.png + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/Icons/downarrow.png:/Icons/downarrow.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + 6 + + + 0 + + + + + + 16777215 + 16 + + + + + Sans Serif + 9 + 50 + false + false + false + false + + + + Current tracker: + + + + + + + + 16777215 + 16 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 8543b0eb7..de26eae6c 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -29,14 +29,17 @@ */ #include +#include #include +#include #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) { 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) { h.set_sequential_download(checkboxState == Qt::Checked); TorrentPersistentData::saveSequentialStatus(h); } + +void PropertiesWidget::loadTrackers() { + if(!h.is_valid()) return; + //Trackers + std::vector trackers = h.trackers(); + trackersURLS->clear(); + QHash errors = BTSession->getTrackersErrors(h.hash()); + unsigned int nbTrackers = trackers.size(); + for(unsigned int i=0; isetForeground(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); +} diff --git a/src/propertieswidget.h b/src/propertieswidget.h index f4d8130e9..cb381cfc4 100644 --- a/src/propertieswidget.h +++ b/src/propertieswidget.h @@ -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: 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(); };