Revise string literal usage

PR #16703.
This commit is contained in:
Chocobo1
2022-03-26 11:53:50 +08:00
committed by GitHub
parent e1abcc684a
commit 4ca6de2b54
55 changed files with 485 additions and 472 deletions

View File

@@ -217,8 +217,8 @@ QString PeerInfo::connectionType() const
return C_UTP;
return (m_nativeInfo.connection_type == lt::peer_info::standard_bittorrent)
? QLatin1String {"BT"}
: QLatin1String {"Web"};
? u"BT"_qs
: u"Web"_qs;
}
qreal PeerInfo::calcRelevance(const Torrent *torrent) const
@@ -242,8 +242,8 @@ void PeerInfo::determineFlags()
{
const auto updateFlags = [this](const QChar specifier, const QString &explanation)
{
m_flags += (specifier + QLatin1Char(' '));
m_flagsDescription += QString::fromLatin1("%1 = %2\n").arg(specifier, explanation);
m_flags += (specifier + u' ');
m_flagsDescription += u"%1 = %2\n"_qs.arg(specifier, explanation);
};
if (isInteresting())
@@ -251,12 +251,12 @@ void PeerInfo::determineFlags()
if (isRemoteChocked())
{
// d = Your client wants to download, but peer doesn't want to send (interested and choked)
updateFlags(QLatin1Char('d'), tr("Interested (local) and choked (peer)"));
updateFlags(u'd', tr("Interested (local) and choked (peer)"));
}
else
{
// D = Currently downloading (interested and not choked)
updateFlags(QLatin1Char('D'), tr("Interested (local) and unchoked (peer)"));
updateFlags(u'D', tr("Interested (local) and unchoked (peer)"));
}
}
@@ -265,58 +265,58 @@ void PeerInfo::determineFlags()
if (isChocked())
{
// u = Peer wants your client to upload, but your client doesn't want to (interested and choked)
updateFlags(QLatin1Char('u'), tr("Interested (peer) and choked (local)"));
updateFlags(u'u', tr("Interested (peer) and choked (local)"));
}
else
{
// U = Currently uploading (interested and not choked)
updateFlags(QLatin1Char('U'), tr("Interested (peer) and unchoked (local)"));
updateFlags(u'U', tr("Interested (peer) and unchoked (local)"));
}
}
// K = Peer is unchoking your client, but your client is not interested
if (!isRemoteChocked() && !isInteresting())
updateFlags(QLatin1Char('K'), tr("Not interested (local) and unchoked (peer)"));
updateFlags(u'K', tr("Not interested (local) and unchoked (peer)"));
// ? = Your client unchoked the peer but the peer is not interested
if (!isChocked() && !isRemoteInterested())
updateFlags(QLatin1Char('?'), tr("Not interested (peer) and unchoked (local)"));
updateFlags(u'?', tr("Not interested (peer) and unchoked (local)"));
// O = Optimistic unchoke
if (optimisticUnchoke())
updateFlags(QLatin1Char('O'), tr("Optimistic unchoke"));
updateFlags(u'O', tr("Optimistic unchoke"));
// S = Peer is snubbed
if (isSnubbed())
updateFlags(QLatin1Char('S'), tr("Peer snubbed"));
updateFlags(u'S', tr("Peer snubbed"));
// I = Peer is an incoming connection
if (!isLocalConnection())
updateFlags(QLatin1Char('I'), tr("Incoming connection"));
updateFlags(u'I', tr("Incoming connection"));
// H = Peer was obtained through DHT
if (fromDHT())
updateFlags(QLatin1Char('H'), tr("Peer from DHT"));
updateFlags(u'H', tr("Peer from DHT"));
// X = Peer was included in peerlists obtained through Peer Exchange (PEX)
if (fromPeX())
updateFlags(QLatin1Char('X'), tr("Peer from PEX"));
updateFlags(u'X', tr("Peer from PEX"));
// L = Peer is local
if (fromLSD())
updateFlags(QLatin1Char('L'), tr("Peer from LSD"));
updateFlags(u'L', tr("Peer from LSD"));
// E = Peer is using Protocol Encryption (all traffic)
if (isRC4Encrypted())
updateFlags(QLatin1Char('E'), tr("Encrypted traffic"));
updateFlags(u'E', tr("Encrypted traffic"));
// e = Peer is using Protocol Encryption (handshake)
if (isPlaintextEncrypted())
updateFlags(QLatin1Char('e'), tr("Encrypted handshake"));
updateFlags(u'e', tr("Encrypted handshake"));
// P = Peer is using uTorrent uTP
if (useUTPSocket())
updateFlags(QLatin1Char('P'), C_UTP);
updateFlags(u'P', C_UTP);
m_flags.chop(1);
m_flagsDescription.chop(1);