Browse Source

Merge pull request #1258 from Gelmir/selective_reannounce

Support selective reannounce with libtorrent 1.0
adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
5bf7106e5c
  1. 36
      src/properties/trackerlist.cpp
  2. 3
      src/properties/trackerlist.h

36
src/properties/trackerlist.cpp

@ -405,6 +405,33 @@ void TrackerList::editSelectedTracker() { @@ -405,6 +405,33 @@ void TrackerList::editSelectedTracker() {
loadTrackers();
}
#if LIBTORRENT_VERSION_NUM >= 10000
void TrackerList::reannounceSelected() {
try {
QTorrentHandle h = properties->getCurrentTorrent();
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
if (selected_items.isEmpty())
return;
std::vector<announce_entry> trackers = h.trackers();
for (int i = 0; i < trackers.size(); ++i) {
foreach (QTreeWidgetItem* w, selected_items) {
if (w->text(COL_URL) == misc::toQString(trackers[i].url)) {
h.force_reannounce(0, i);
break;
}
}
}
} catch(invalid_handle&) {
return;
}
loadTrackers();
}
#endif
void TrackerList::showTrackerListMenu(QPoint) {
QTorrentHandle h = properties->getCurrentTorrent();
if (!h.is_valid()) return;
@ -420,6 +447,9 @@ void TrackerList::showTrackerListMenu(QPoint) { @@ -420,6 +447,9 @@ void TrackerList::showTrackerListMenu(QPoint) {
copyAct = menu.addAction(IconProvider::instance()->getIcon("edit-copy"), tr("Copy tracker url"));
editAct = menu.addAction(IconProvider::instance()->getIcon("edit-rename"),tr("Edit selected tracker URL"));
}
#if LIBTORRENT_VERSION_MAJOR >= 1
QAction *reannounceSelAct = menu.addAction(IconProvider::instance()->getIcon("view-refresh"), tr("Force reannounce to selected trackers"));
#endif
menu.addSeparator();
QAction *reannounceAct = menu.addAction(IconProvider::instance()->getIcon("view-refresh"), tr("Force reannounce to all trackers"));
QAction *act = menu.exec(QCursor::pos());
@ -436,6 +466,12 @@ void TrackerList::showTrackerListMenu(QPoint) { @@ -436,6 +466,12 @@ void TrackerList::showTrackerListMenu(QPoint) {
deleteSelectedTrackers();
return;
}
#if LIBTORRENT_VERSION_MAJOR >= 1
if (act == reannounceSelAct) {
reannounceSelected();
return;
}
#endif
if (act == reannounceAct) {
properties->getCurrentTorrent().force_reannounce();
return;

3
src/properties/trackerlist.h

@ -74,6 +74,9 @@ public slots: @@ -74,6 +74,9 @@ public slots:
void loadTrackers();
void askForTrackers();
void copyTrackerUrl();
#if LIBTORRENT_VERSION_NUM >= 10000
void reannounceSelected();
#endif
void deleteSelectedTrackers();
void editSelectedTracker();
void showTrackerListMenu(QPoint);

Loading…
Cancel
Save