Browse Source

Simplify map initialization

adaptive-webui-19844
Thomas Piccirello 6 years ago
parent
commit
9e1f7a72b7
  1. 21
      src/webui/api/torrentscontroller.cpp

21
src/webui/api/torrentscontroller.cpp

@ -385,8 +385,6 @@ void TorrentsController::trackersAction()
QHash<QString, BitTorrent::TrackerInfo> trackersData = torrent->trackerInfos(); QHash<QString, BitTorrent::TrackerInfo> trackersData = torrent->trackerInfos();
for (const BitTorrent::TrackerEntry &tracker : asConst(torrent->trackers())) { for (const BitTorrent::TrackerEntry &tracker : asConst(torrent->trackers())) {
QVariantMap trackerDict;
trackerDict[KEY_TRACKER_URL] = tracker.url();
const BitTorrent::TrackerInfo data = trackersData.value(tracker.url()); const BitTorrent::TrackerInfo data = trackersData.value(tracker.url());
QString status; QString status;
switch (tracker.status()) { switch (tracker.status()) {
@ -399,16 +397,17 @@ void TorrentsController::trackersAction()
case BitTorrent::TrackerEntry::NotWorking: case BitTorrent::TrackerEntry::NotWorking:
status = tr("Not working"); break; status = tr("Not working"); break;
} }
trackerDict[KEY_TRACKER_TIER] = tracker.tier();
trackerDict[KEY_TRACKER_STATUS] = status;
trackerDict[KEY_TRACKER_PEERS_COUNT] = data.numPeers;
trackerDict[KEY_TRACKER_MSG] = data.lastMessage.trimmed();
trackerDict[KEY_TRACKER_SEEDS_COUNT] = tracker.nativeEntry().scrape_complete; trackerList << QVariantMap {
trackerDict[KEY_TRACKER_LEECHES_COUNT] = tracker.nativeEntry().scrape_incomplete; {KEY_TRACKER_URL, tracker.url()},
trackerDict[KEY_TRACKER_DOWNLOADED_COUNT] = tracker.nativeEntry().scrape_downloaded; {KEY_TRACKER_TIER, tracker.tier()},
{KEY_TRACKER_STATUS, status},
trackerList.append(trackerDict); {KEY_TRACKER_PEERS_COUNT, data.numPeers},
{KEY_TRACKER_MSG, data.lastMessage.trimmed()},
{KEY_TRACKER_SEEDS_COUNT, tracker.nativeEntry().scrape_complete},
{KEY_TRACKER_LEECHES_COUNT, tracker.nativeEntry().scrape_incomplete},
{KEY_TRACKER_DOWNLOADED_COUNT, tracker.nativeEntry().scrape_downloaded}
};
} }
setResult(QJsonArray::fromVariantList(trackerList)); setResult(QJsonArray::fromVariantList(trackerList));

Loading…
Cancel
Save