Browse Source

- Keep on working on trackers edition

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
3467d68020
  1. 17
      src/properties.ui
  2. 52
      src/properties_imp.cpp
  3. 2
      src/properties_imp.h

17
src/properties.ui

@ -796,6 +796,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -980,8 +993,8 @@
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel" >
<x>278</x> <x>306</x>
<y>253</y> <y>556</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel" >
<x>96</x> <x>96</x>

52
src/properties_imp.cpp

@ -22,6 +22,7 @@
#include "properties_imp.h" #include "properties_imp.h"
#include "misc.h" #include "misc.h"
#include "PropListDelegate.h" #include "PropListDelegate.h"
#include <QInputDialog>
// Constructor // Constructor
properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErrors): QDialog(parent), h(h){ 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(); PropDelegate = new PropListDelegate();
filesList->setItemDelegate(PropDelegate); filesList->setItemDelegate(PropDelegate);
connect(filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(toggleSelectedState(const QModelIndex&))); connect(filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(toggleSelectedState(const QModelIndex&)));
connect(addTracker_button, SIGNAL(clicked()), this, SLOT(askForTracker()));
// get Infos from torrent handle // get Infos from torrent handle
fileHash = QString(misc::toString(h.info_hash()).c_str()); fileHash = QString(misc::toString(h.info_hash()).c_str());
torrent_status torrentStatus = h.status(); torrent_status torrentStatus = h.status();
@ -55,16 +57,7 @@ properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErr
hash_lbl->setText(fileHash); hash_lbl->setText(fileHash);
comment_txt->setText(QString(torrentInfo.comment().c_str())); comment_txt->setText(QString(torrentInfo.comment().c_str()));
//Trackers //Trackers
QString tracker = QString(torrentStatus.current_tracker.c_str()).trimmed(); loadTrackers();
if(!tracker.isEmpty()){
trackerURL->setText(tracker);
}else{
trackerURL->setText(tr("None - Unreachable?"));
}
std::vector<announce_entry> trackers = torrentInfo.trackers();
for(unsigned int i=0; i<trackers.size(); ++i){
trackersURLS->addItem(QString(trackers[i].url.c_str()));
}
// Session infos // Session infos
char tmp[MAX_CHAR_TMP]; char tmp[MAX_CHAR_TMP];
failed->setText(misc::friendlyUnit(torrentStatus.total_failed_bytes)); 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<announce_entry> trackers = torrentInfo.trackers();
trackersURLS->clear();
for(unsigned int i=0; i<trackers.size(); ++i){
trackersURLS->addItem(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<announce_entry> trackers = torrentInfo.trackers();
// for(unsigned int i=0; i<trackers.size(); ++i){
// if(QString(trackers[i].url.c_str())
// }
torrentInfo.add_tracker(trackerUrl.toStdString(), trackersURLS->count());
h.force_reannounce();
// Reload Trackers
loadTrackers();
}
void properties::updateProgress(){ void properties::updateProgress(){
std::vector<float> fp; std::vector<float> fp;
try{ try{

2
src/properties_imp.h

@ -53,6 +53,8 @@ class properties : public QDialog, private Ui::properties{
void updateProgress(); void updateProgress();
void loadFilteredFiles(); void loadFilteredFiles();
void setAllPiecesState(bool selected); void setAllPiecesState(bool selected);
void askForTracker();
void loadTrackers();
signals: signals:
void changedFilteredFiles(torrent_handle h, bool compact_mode); void changedFilteredFiles(torrent_handle h, bool compact_mode);

Loading…
Cancel
Save