From 3467d68020494504dfc20429dfba8fb79bf1faa8 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 24 Mar 2007 21:36:22 +0000 Subject: [PATCH] - Keep on working on trackers edition --- src/properties.ui | 17 ++++++++++++-- src/properties_imp.cpp | 52 ++++++++++++++++++++++++++++++++++-------- src/properties_imp.h | 2 ++ 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/properties.ui b/src/properties.ui index 4ff30d251..acc230a16 100644 --- a/src/properties.ui +++ b/src/properties.ui @@ -796,6 +796,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -980,8 +993,8 @@ accept() - 278 - 253 + 306 + 556 96 diff --git a/src/properties_imp.cpp b/src/properties_imp.cpp index 3024ae842..13c59e9bf 100644 --- a/src/properties_imp.cpp +++ b/src/properties_imp.cpp @@ -22,6 +22,7 @@ #include "properties_imp.h" #include "misc.h" #include "PropListDelegate.h" +#include // Constructor properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErrors): QDialog(parent), h(h){ @@ -44,6 +45,7 @@ properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErr PropDelegate = new PropListDelegate(); filesList->setItemDelegate(PropDelegate); connect(filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(toggleSelectedState(const QModelIndex&))); + connect(addTracker_button, SIGNAL(clicked()), this, SLOT(askForTracker())); // get Infos from torrent handle fileHash = QString(misc::toString(h.info_hash()).c_str()); torrent_status torrentStatus = h.status(); @@ -55,16 +57,7 @@ properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErr hash_lbl->setText(fileHash); comment_txt->setText(QString(torrentInfo.comment().c_str())); //Trackers - QString tracker = QString(torrentStatus.current_tracker.c_str()).trimmed(); - if(!tracker.isEmpty()){ - trackerURL->setText(tracker); - }else{ - trackerURL->setText(tr("None - Unreachable?")); - } - std::vector trackers = torrentInfo.trackers(); - for(unsigned int i=0; iaddItem(QString(trackers[i].url.c_str())); - } + loadTrackers(); // Session infos char tmp[MAX_CHAR_TMP]; failed->setText(misc::friendlyUnit(torrentStatus.total_failed_bytes)); @@ -154,6 +147,45 @@ void properties::loadFilteredFiles(){ } } +void properties::loadTrackers(){ + torrent_status torrentStatus = h.status(); + torrent_info torrentInfo = h.get_torrent_info(); + //Trackers + std::vector trackers = torrentInfo.trackers(); + trackersURLS->clear(); + for(unsigned int i=0; iaddItem(QString(trackers[i].url.c_str())); + } + QString tracker = QString(torrentStatus.current_tracker.c_str()).trimmed(); + if(!tracker.isEmpty()){ + trackerURL->setText(tracker); + }else{ + trackerURL->setText(tr("None - Unreachable?")); + } +} + +// Ask the user for a new tracker +// and add it to the download list +// if it is not already in it +void properties::askForTracker(){ + bool ok; + // Ask user for a new tracker + QString trackerUrl = QInputDialog::getText(this, tr("New tracker"), + tr("New tracker url:"), QLineEdit::Normal, + "http://www.", &ok); + if(!ok) return; + // Checking if it already exists in the list + torrent_info torrentInfo = h.get_torrent_info(); +// std::vector trackers = torrentInfo.trackers(); +// for(unsigned int i=0; icount()); + h.force_reannounce(); + // Reload Trackers + loadTrackers(); +} + void properties::updateProgress(){ std::vector fp; try{ diff --git a/src/properties_imp.h b/src/properties_imp.h index 99028b023..4497eb84e 100644 --- a/src/properties_imp.h +++ b/src/properties_imp.h @@ -53,6 +53,8 @@ class properties : public QDialog, private Ui::properties{ void updateProgress(); void loadFilteredFiles(); void setAllPiecesState(bool selected); + void askForTracker(); + void loadTrackers(); signals: void changedFilteredFiles(torrent_handle h, bool compact_mode);