Browse Source

Merge pull request #6385 from thalieht/Trackerlist

Trackerlist: Seperate seeds from peers for DHT, PeX, LSD
adaptive-webui-19844
sledgehammer999 8 years ago committed by GitHub
parent
commit
9e56f3d318
  1. 80
      src/gui/properties/trackerlist.cpp

80
src/gui/properties/trackerlist.cpp

@ -74,13 +74,13 @@ TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), propertie
header << tr("Downloaded"); header << tr("Downloaded");
header << tr("Message"); header << tr("Message");
setHeaderItem(new QTreeWidgetItem(header)); setHeaderItem(new QTreeWidgetItem(header));
dht_item = new QTreeWidgetItem(QStringList() << "" << "** [DHT] **" << "" << "" << "0" << "0" << "0"); dht_item = new QTreeWidgetItem({ "", "** [DHT] **", "", "0", "", "", "0" });
insertTopLevelItem(0, dht_item); insertTopLevelItem(0, dht_item);
setRowColor(0, QColor("grey")); setRowColor(0, QColor("grey"));
pex_item = new QTreeWidgetItem(QStringList() << "" << "** [PeX] **" << "" << "" << "0" << "0" << "0"); pex_item = new QTreeWidgetItem({ "", "** [PeX] **", "", "0", "", "", "0" });
insertTopLevelItem(1, pex_item); insertTopLevelItem(1, pex_item);
setRowColor(1, QColor("grey")); setRowColor(1, QColor("grey"));
lsd_item = new QTreeWidgetItem(QStringList() << "" << "** [LSD] **" << "" << "" << "0" << "0" << "0"); lsd_item = new QTreeWidgetItem({ "", "** [LSD] **", "", "0", "", "", "0" });
insertTopLevelItem(2, lsd_item); insertTopLevelItem(2, lsd_item);
setRowColor(2, QColor("grey")); setRowColor(2, QColor("grey"));
editHotkey = new QShortcut(Qt::Key_F2, this, SLOT(editSelectedTracker()), 0, Qt::WidgetShortcut); editHotkey = new QShortcut(Qt::Key_F2, this, SLOT(editSelectedTracker()), 0, Qt::WidgetShortcut);
@ -202,18 +202,22 @@ void TrackerList::moveSelectionDown() {
torrent->forceReannounce(); torrent->forceReannounce();
} }
void TrackerList::clear() { void TrackerList::clear()
qDeleteAll(tracker_items.values()); {
tracker_items.clear(); qDeleteAll(tracker_items.values());
dht_item->setText(COL_RECEIVED, ""); tracker_items.clear();
dht_item->setText(COL_STATUS, ""); dht_item->setText(COL_STATUS, "");
dht_item->setText(COL_MSG, ""); dht_item->setText(COL_SEEDS, "");
pex_item->setText(COL_RECEIVED, ""); dht_item->setText(COL_PEERS, "");
pex_item->setText(COL_STATUS, ""); dht_item->setText(COL_MSG, "");
pex_item->setText(COL_MSG, ""); pex_item->setText(COL_STATUS, "");
lsd_item->setText(COL_RECEIVED, ""); pex_item->setText(COL_SEEDS, "");
lsd_item->setText(COL_STATUS, ""); pex_item->setText(COL_PEERS, "");
lsd_item->setText(COL_MSG, ""); pex_item->setText(COL_MSG, "");
lsd_item->setText(COL_STATUS, "");
lsd_item->setText(COL_SEEDS, "");
lsd_item->setText(COL_PEERS, "");
lsd_item->setText(COL_MSG, "");
} }
void TrackerList::loadStickyItems(BitTorrent::TorrentHandle *const torrent) { void TrackerList::loadStickyItems(BitTorrent::TorrentHandle *const torrent) {
@ -245,20 +249,38 @@ void TrackerList::loadStickyItems(BitTorrent::TorrentHandle *const torrent) {
lsd_item->setText(COL_MSG, privateMsg); lsd_item->setText(COL_MSG, privateMsg);
} }
// XXX: libtorrent should provide this info... // XXX: libtorrent should provide this info...
// Count peers from DHT, LSD, PeX // Count peers from DHT, PeX, LSD
uint nb_dht = 0, nb_lsd = 0, nb_pex = 0; uint seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, peersDHT = 0, peersPeX = 0, peersLSD = 0;
foreach (const BitTorrent::PeerInfo &peer, torrent->peers()) { foreach (const BitTorrent::PeerInfo &peer, torrent->peers()) {
if (peer.fromDHT()) if (peer.isConnecting()) continue;
++nb_dht;
if (peer.fromLSD()) if (peer.fromDHT()) {
++nb_lsd; if (peer.isSeed())
if (peer.fromPeX()) ++seedsDHT;
++nb_pex; else
} ++peersDHT;
dht_item->setText(COL_RECEIVED, QString::number(nb_dht)); }
pex_item->setText(COL_RECEIVED, QString::number(nb_pex)); if (peer.fromPeX()) {
lsd_item->setText(COL_RECEIVED, QString::number(nb_lsd)); if (peer.isSeed())
++seedsPeX;
else
++peersPeX;
}
if (peer.fromLSD()) {
if (peer.isSeed())
++seedsLSD;
else
++peersLSD;
}
}
dht_item->setText(COL_SEEDS, QString::number(seedsDHT));
dht_item->setText(COL_PEERS, QString::number(peersDHT));
pex_item->setText(COL_SEEDS, QString::number(seedsPeX));
pex_item->setText(COL_PEERS, QString::number(peersPeX));
lsd_item->setText(COL_SEEDS, QString::number(seedsLSD));
lsd_item->setText(COL_PEERS, QString::number(peersLSD));
} }
void TrackerList::loadTrackers() { void TrackerList::loadTrackers() {

Loading…
Cancel
Save