Browse Source

Use a QString directly instead of QStringList

adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
d92bf13706
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 59
      src/base/bittorrent/peerinfo.cpp
  2. 1
      src/base/bittorrent/peerinfo.h

59
src/base/bittorrent/peerinfo.cpp

@ -33,7 +33,6 @@
#include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
#include "base/net/geoipmanager.h" #include "base/net/geoipmanager.h"
#include "base/unicodestrings.h" #include "base/unicodestrings.h"
#include "base/utils/string.h"
#include "peeraddress.h" #include "peeraddress.h"
using namespace BitTorrent; using namespace BitTorrent;
@ -261,20 +260,18 @@ qreal PeerInfo::relevance() const
void PeerInfo::determineFlags() void PeerInfo::determineFlags()
{ {
QStringList flagsDescriptionList;
if (isInteresting()) { if (isInteresting()) {
// d = Your client wants to download, but peer doesn't want to send (interested and choked) // d = Your client wants to download, but peer doesn't want to send (interested and choked)
if (isRemoteChocked()) { if (isRemoteChocked()) {
m_flags += "d "; m_flags += "d ";
flagsDescriptionList += "d = " m_flagsDescription += ("d = "
+ tr("Interested(local) and Choked(peer)"); + tr("Interested(local) and Choked(peer)") + '\n');
} }
else { else {
// D = Currently downloading (interested and not choked) // D = Currently downloading (interested and not choked)
m_flags += "D "; m_flags += "D ";
flagsDescriptionList += "D = " m_flagsDescription += ("D = "
+ tr("interested(local) and unchoked(peer)"); + tr("interested(local) and unchoked(peer)") + '\n');
} }
} }
@ -282,95 +279,87 @@ void PeerInfo::determineFlags()
// u = Peer wants your client to upload, but your client doesn't want to (interested and choked) // u = Peer wants your client to upload, but your client doesn't want to (interested and choked)
if (isChocked()) { if (isChocked()) {
m_flags += "u "; m_flags += "u ";
flagsDescriptionList += "u = " m_flagsDescription += ("u = "
+ tr("interested(peer) and choked(local)"); + tr("interested(peer) and choked(local)") + '\n');
} }
else { else {
// U = Currently uploading (interested and not choked) // U = Currently uploading (interested and not choked)
m_flags += "U "; m_flags += "U ";
flagsDescriptionList += "U = " m_flagsDescription += ("U = "
+ tr("interested(peer) and unchoked(local)"); + tr("interested(peer) and unchoked(local)") + '\n');
} }
} }
// O = Optimistic unchoke // O = Optimistic unchoke
if (optimisticUnchoke()) { if (optimisticUnchoke()) {
m_flags += "O "; m_flags += "O ";
flagsDescriptionList += "O = " m_flagsDescription += ("O = " + tr("optimistic unchoke") + '\n');
+ tr("optimistic unchoke");
} }
// S = Peer is snubbed // S = Peer is snubbed
if (isSnubbed()) { if (isSnubbed()) {
m_flags += "S "; m_flags += "S ";
flagsDescriptionList += "S = " m_flagsDescription += ("S = " + tr("peer snubbed") + '\n');
+ tr("peer snubbed");
} }
// I = Peer is an incoming connection // I = Peer is an incoming connection
if (!isLocalConnection()) { if (!isLocalConnection()) {
m_flags += "I "; m_flags += "I ";
flagsDescriptionList += "I = " m_flagsDescription += ("I = " + tr("incoming connection") + '\n');
+ tr("incoming connection");
} }
// K = Peer is unchoking your client, but your client is not interested // K = Peer is unchoking your client, but your client is not interested
if (!isRemoteChocked() && !isInteresting()) { if (!isRemoteChocked() && !isInteresting()) {
m_flags += "K "; m_flags += "K ";
flagsDescriptionList += "K = " m_flagsDescription += ("K = "
+ tr("not interested(local) and unchoked(peer)"); + tr("not interested(local) and unchoked(peer)") + '\n');
} }
// ? = Your client unchoked the peer but the peer is not interested // ? = Your client unchoked the peer but the peer is not interested
if (!isChocked() && !isRemoteInterested()) { if (!isChocked() && !isRemoteInterested()) {
m_flags += "? "; m_flags += "? ";
flagsDescriptionList += "? = " m_flagsDescription += ("? = "
+ tr("not interested(peer) and unchoked(local)"); + tr("not interested(peer) and unchoked(local)") + '\n');
} }
// X = Peer was included in peerlists obtained through Peer Exchange (PEX) // X = Peer was included in peerlists obtained through Peer Exchange (PEX)
if (fromPeX()) { if (fromPeX()) {
m_flags += "X "; m_flags += "X ";
flagsDescriptionList += "X = " m_flagsDescription += ("X = " + tr("peer from PEX") + '\n');
+ tr("peer from PEX");
} }
// H = Peer was obtained through DHT // H = Peer was obtained through DHT
if (fromDHT()) { if (fromDHT()) {
m_flags += "H "; m_flags += "H ";
flagsDescriptionList += "H = " m_flagsDescription += ("H = " + tr("peer from DHT") + '\n');
+ tr("peer from DHT");
} }
// E = Peer is using Protocol Encryption (all traffic) // E = Peer is using Protocol Encryption (all traffic)
if (isRC4Encrypted()) { if (isRC4Encrypted()) {
m_flags += "E "; m_flags += "E ";
flagsDescriptionList += "E = " m_flagsDescription += ("E = " + tr("encrypted traffic") + '\n');
+ tr("encrypted traffic");
} }
// e = Peer is using Protocol Encryption (handshake) // e = Peer is using Protocol Encryption (handshake)
if (isPlaintextEncrypted()) { if (isPlaintextEncrypted()) {
m_flags += "e "; m_flags += "e ";
flagsDescriptionList += "e = " m_flagsDescription += ("e = " + tr("encrypted handshake") + '\n');
+ tr("encrypted handshake");
} }
// P = Peer is using uTorrent uTP // P = Peer is using uTorrent uTP
if (useUTPSocket()) { if (useUTPSocket()) {
m_flags += "P "; m_flags += "P ";
flagsDescriptionList += "P = " m_flagsDescription += ("P = " + QString::fromUtf8(C_UTP) + '\n');
+ QString::fromUtf8(C_UTP);
} }
// L = Peer is local // L = Peer is local
if (fromLSD()) { if (fromLSD()) {
m_flags += 'L'; m_flags += "L ";
flagsDescriptionList += "L = " m_flagsDescription += ("L = " + tr("peer from LSD") + '\n');
+ tr("peer from LSD");
} }
m_flags = m_flags.trimmed(); m_flags = m_flags.trimmed();
m_flagsDescription = flagsDescriptionList.join('\n'); m_flagsDescription = m_flagsDescription.trimmed();
} }
QString PeerInfo::flags() const QString PeerInfo::flags() const

1
src/base/bittorrent/peerinfo.h

@ -32,7 +32,6 @@
#include <libtorrent/peer_info.hpp> #include <libtorrent/peer_info.hpp>
#include <QCoreApplication> #include <QCoreApplication>
#include <QHostAddress>
class QBitArray; class QBitArray;

Loading…
Cancel
Save