Replace single-character string with character literal

Also remove unnecessary dynamic allocation.
This commit is contained in:
Chocobo1
2018-07-21 13:28:13 +08:00
parent 7e3cf99bb9
commit 0217d5b4c0
32 changed files with 96 additions and 96 deletions

View File

@@ -100,7 +100,7 @@ public:
case RELEVANCE: {
qreal progress = index.data().toDouble();
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress * 100.0, 1) + "%");
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress * 100.0, 1) + '%');
}
break;
default:

View File

@@ -304,9 +304,9 @@ void PeerListWidget::copySelectedPeers()
QString ip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString();
QString myport = m_listModel->data(m_listModel->index(row, PeerListDelegate::PORT)).toString();
if (ip.indexOf('.') == -1) // IPv6
selectedPeers << "[" + ip + "]:" + myport;
selectedPeers << '[' + ip + "]:" + myport;
else // IPv4
selectedPeers << ip + ":" + myport;
selectedPeers << ip + ':' + myport;
}
QApplication::clipboard()->setText(selectedPeers.join('\n'));
}
@@ -404,8 +404,8 @@ QStandardItem *PeerListWidget::addPeer(const QString &ip, BitTorrent::TorrentHan
m_listModel->setData(m_listModel->index(row, PeerListDelegate::TOT_UP), peer.totalUpload());
m_listModel->setData(m_listModel->index(row, PeerListDelegate::RELEVANCE), peer.relevance());
QStringList downloadingFiles(torrent->info().filesForPiece(peer.downloadingPieceIndex()));
m_listModel->setData(m_listModel->index(row, PeerListDelegate::DOWNLOADING_PIECE), downloadingFiles.join(QLatin1String(";")));
m_listModel->setData(m_listModel->index(row, PeerListDelegate::DOWNLOADING_PIECE), downloadingFiles.join(QLatin1String("\n")), Qt::ToolTipRole);
m_listModel->setData(m_listModel->index(row, PeerListDelegate::DOWNLOADING_PIECE), downloadingFiles.join(QLatin1Char(';')));
m_listModel->setData(m_listModel->index(row, PeerListDelegate::DOWNLOADING_PIECE), downloadingFiles.join(QLatin1Char('\n')), Qt::ToolTipRole);
return m_listModel->item(row, PeerListDelegate::IP);
}

View File

@@ -474,7 +474,7 @@ void PropertiesWidget::loadDynamicData()
// Progress
qreal progress = m_torrent->progress() * 100.;
m_ui->labelProgressVal->setText(Utils::String::fromDouble(progress, 1) + "%");
m_ui->labelProgressVal->setText(Utils::String::fromDouble(progress, 1) + '%');
m_downloadedPieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces());
}
else {

View File

@@ -87,7 +87,7 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
QStyleOptionProgressBar newopt;
qreal progress = index.data().toDouble() * 100.;
newopt.rect = opt.rect;
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + '%');
newopt.progress = int(progress);
newopt.maximum = 100;
newopt.minimum = 0;

View File

@@ -371,9 +371,9 @@ void TrackerListWidget::loadTrackers()
item->setText(COL_PEERS, QString::number(entry.nativeEntry().scrape_incomplete > 0 ? entry.nativeEntry().scrape_incomplete : 0));
item->setText(COL_DOWNLOADED, QString::number(entry.nativeEntry().scrape_downloaded > 0 ? entry.nativeEntry().scrape_downloaded : 0));
#else
item->setText(COL_SEEDS, "0");
item->setText(COL_PEERS, "0");
item->setText(COL_DOWNLOADED, "0");
item->setText(COL_SEEDS, '0');
item->setText(COL_PEERS, '0');
item->setText(COL_DOWNLOADED, '0');
#endif
item->setTextAlignment(COL_TIER, (Qt::AlignRight | Qt::AlignVCenter));