mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-30 16:34:16 +00:00
- Update trackers edition code
- current tracker is now updated regularly when properties are displayed
This commit is contained in:
parent
f839d6fe41
commit
3e36cd3c46
1
TODO
1
TODO
@ -43,7 +43,6 @@
|
|||||||
- Translations update
|
- Translations update
|
||||||
- Optimize and cleanup code
|
- Optimize and cleanup code
|
||||||
- document url seeds
|
- document url seeds
|
||||||
- Improve trackers edition code
|
|
||||||
- check painting problems in dl list
|
- check painting problems in dl list
|
||||||
- Wait for some bug fixes in libtorrent :
|
- Wait for some bug fixes in libtorrent :
|
||||||
- upload/download limit per torrent
|
- upload/download limit per torrent
|
||||||
|
10
src/misc.h
10
src/misc.h
@ -31,6 +31,9 @@
|
|||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
|
#include <libtorrent/torrent_info.hpp>
|
||||||
|
using namespace libtorrent;
|
||||||
|
|
||||||
#define MAX_CHAR_TMP 128
|
#define MAX_CHAR_TMP 128
|
||||||
|
|
||||||
/* Miscellaneaous functions that can be useful */
|
/* Miscellaneaous functions that can be useful */
|
||||||
@ -144,6 +147,13 @@ class misc : public QObject{
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fixTrackersTiers(std::vector<announce_entry> trackers){
|
||||||
|
unsigned int nbTrackers = trackers.size();
|
||||||
|
for(unsigned int i=0; i<nbTrackers; ++i){
|
||||||
|
trackers[i].tier = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Insertion sort, used instead of bubble sort because it is
|
// Insertion sort, used instead of bubble sort because it is
|
||||||
// approx. 5 times faster.
|
// approx. 5 times faster.
|
||||||
template <class T> static void insertSort(QList<QPair<int, T> > &list, const QPair<int, T>& value, Qt::SortOrder sortOrder){
|
template <class T> static void insertSort(QList<QPair<int, T> > &list, const QPair<int, T>& value, Qt::SortOrder sortOrder){
|
||||||
|
@ -264,7 +264,8 @@ void properties::loadTrackers(){
|
|||||||
//Trackers
|
//Trackers
|
||||||
std::vector<announce_entry> trackers = h.trackers();
|
std::vector<announce_entry> trackers = h.trackers();
|
||||||
trackersURLS->clear();
|
trackersURLS->clear();
|
||||||
for(unsigned int i=0; i<trackers.size(); ++i){
|
unsigned int nbTrackers = trackers.size();
|
||||||
|
for(unsigned int i=0; i<nbTrackers; ++i){
|
||||||
trackersURLS->addItem(QString(trackers[i].url.c_str()));
|
trackersURLS->addItem(QString(trackers[i].url.c_str()));
|
||||||
}
|
}
|
||||||
torrent_status torrentStatus = h.status();
|
torrent_status torrentStatus = h.status();
|
||||||
@ -311,8 +312,9 @@ void properties::askForTracker(){
|
|||||||
// Add the tracker to the list
|
// Add the tracker to the list
|
||||||
std::vector<announce_entry> trackers = h.trackers();
|
std::vector<announce_entry> trackers = h.trackers();
|
||||||
announce_entry new_tracker(trackerUrl.toStdString());
|
announce_entry new_tracker(trackerUrl.toStdString());
|
||||||
new_tracker.tier = trackersURLS->count();
|
new_tracker.tier = 0; // Will be fixed a bit later
|
||||||
trackers.push_back(new_tracker);
|
trackers.push_back(new_tracker);
|
||||||
|
misc::fixTrackersTiers(trackers);
|
||||||
h.replace_trackers(trackers);
|
h.replace_trackers(trackers);
|
||||||
h.force_reannounce();
|
h.force_reannounce();
|
||||||
// Reload Trackers
|
// Reload Trackers
|
||||||
@ -379,12 +381,14 @@ void properties::riseSelectedTracker(){
|
|||||||
selectedItems = trackersURLS->selectedItems();
|
selectedItems = trackersURLS->selectedItems();
|
||||||
QListWidgetItem *item;
|
QListWidgetItem *item;
|
||||||
bool change = false;
|
bool change = false;
|
||||||
|
unsigned int nbTrackers = trackers.size();
|
||||||
foreach(item, selectedItems){
|
foreach(item, selectedItems){
|
||||||
QString url = item->text();
|
QString url = item->text();
|
||||||
for(i=0; i<trackers.size(); ++i){
|
for(i=0; i<nbTrackers; ++i){
|
||||||
if(QString(trackers.at(i).url.c_str()) == url){
|
if(QString(trackers.at(i).url.c_str()) == url){
|
||||||
if(trackers[i].tier>0 && i != 0){
|
qDebug("Asked to rise %s", trackers.at(i).url.c_str());
|
||||||
trackers[i].tier -= 1;
|
qDebug("its tier was %d and will become %d", trackers[i].tier, trackers[i].tier-1);
|
||||||
|
if(i > 0){
|
||||||
announce_entry tmp = trackers[i];
|
announce_entry tmp = trackers[i];
|
||||||
trackers[i] = trackers[i-1];
|
trackers[i] = trackers[i-1];
|
||||||
trackers[i-1] = tmp;
|
trackers[i-1] = tmp;
|
||||||
@ -395,6 +399,7 @@ void properties::riseSelectedTracker(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(change){
|
if(change){
|
||||||
|
misc::fixTrackersTiers(trackers);
|
||||||
h.replace_trackers(trackers);
|
h.replace_trackers(trackers);
|
||||||
h.force_reannounce();
|
h.force_reannounce();
|
||||||
// Reload Trackers
|
// Reload Trackers
|
||||||
@ -410,12 +415,14 @@ void properties::lowerSelectedTracker(){
|
|||||||
selectedItems = trackersURLS->selectedItems();
|
selectedItems = trackersURLS->selectedItems();
|
||||||
QListWidgetItem *item;
|
QListWidgetItem *item;
|
||||||
bool change = false;
|
bool change = false;
|
||||||
|
unsigned int nbTrackers = trackers.size();
|
||||||
foreach(item, selectedItems){
|
foreach(item, selectedItems){
|
||||||
QString url = item->text();
|
QString url = item->text();
|
||||||
for(i=0; i<trackers.size(); ++i){
|
for(i=0; i<nbTrackers; ++i){
|
||||||
if(QString(trackers.at(i).url.c_str()) == url){
|
if(QString(trackers.at(i).url.c_str()) == url){
|
||||||
if(i != trackers.size()-1){
|
qDebug("Asked to lower %s", trackers.at(i).url.c_str());
|
||||||
trackers[i].tier += 1;
|
qDebug("its tier was %d and will become %d", trackers[i].tier, trackers[i].tier+1);
|
||||||
|
if(i < nbTrackers-1){
|
||||||
announce_entry tmp = trackers[i];
|
announce_entry tmp = trackers[i];
|
||||||
trackers[i] = trackers[i+1];
|
trackers[i] = trackers[i+1];
|
||||||
trackers[i+1] = tmp;
|
trackers[i+1] = tmp;
|
||||||
@ -426,6 +433,7 @@ void properties::lowerSelectedTracker(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(change){
|
if(change){
|
||||||
|
misc::fixTrackersTiers(trackers);
|
||||||
h.replace_trackers(trackers);
|
h.replace_trackers(trackers);
|
||||||
h.force_reannounce();
|
h.force_reannounce();
|
||||||
// Reload Trackers
|
// Reload Trackers
|
||||||
@ -447,6 +455,14 @@ void properties::updateInfos(){
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
loadTrackersErrors();
|
loadTrackersErrors();
|
||||||
|
// Update current tracker
|
||||||
|
torrent_status torrentStatus = h.status();
|
||||||
|
QString tracker = QString(torrentStatus.current_tracker.c_str()).trimmed();
|
||||||
|
if(!tracker.isEmpty()){
|
||||||
|
trackerURL->setText(tracker);
|
||||||
|
}else{
|
||||||
|
trackerURL->setText(tr("None - Unreachable?"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the color of a row in data model
|
// Set the color of a row in data model
|
||||||
|
Loading…
x
Reference in New Issue
Block a user