mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-05 07:02:31 -06:00
Fix coding style
This commit is contained in:
committed by
sledgehammer999
parent
b107b745f2
commit
ac6426eab1
@@ -101,7 +101,7 @@ QVector<float> DownloadedPiecesBar::bitfieldToFloatVector(const QBitArray &vecin
|
||||
// normalization <0, 1>
|
||||
value /= ratio;
|
||||
|
||||
// float precision sometimes gives > 1, because in not possible to store irrational numbers
|
||||
// float precision sometimes gives > 1, because it's not possible to store irrational numbers
|
||||
value = qMin(value, 1.0f);
|
||||
|
||||
result[x] = value;
|
||||
|
||||
@@ -54,7 +54,7 @@ protected:
|
||||
const QString strR = right.data().toString();
|
||||
const int result = Utils::String::naturalCompare(strL, strR, Qt::CaseInsensitive);
|
||||
return (result < 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
|
||||
@@ -303,12 +303,12 @@ void PeerListWidget::copySelectedPeers()
|
||||
int row = m_proxyModel->mapToSource(index).row();
|
||||
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
|
||||
if (ip.indexOf('.') == -1) // IPv6
|
||||
selectedPeers << "[" + ip + "]:" + myport;
|
||||
else // IPv4
|
||||
selectedPeers << ip + ":" + myport;
|
||||
}
|
||||
QApplication::clipboard()->setText(selectedPeers.join("\n"));
|
||||
QApplication::clipboard()->setText(selectedPeers.join('\n'));
|
||||
}
|
||||
|
||||
void PeerListWidget::clear()
|
||||
@@ -339,7 +339,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo
|
||||
if (!torrent) return;
|
||||
|
||||
QList<BitTorrent::PeerInfo> peers = torrent->peers();
|
||||
QSet<QString> oldeersSet = m_peerItems.keys().toSet();
|
||||
QSet<QString> oldPeersSet = m_peerItems.keys().toSet();
|
||||
|
||||
foreach (const BitTorrent::PeerInfo &peer, peers) {
|
||||
BitTorrent::PeerAddress addr = peer.address();
|
||||
@@ -349,7 +349,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo
|
||||
if (m_peerItems.contains(peerIp)) {
|
||||
// Update existing peer
|
||||
updatePeer(peerIp, torrent, peer);
|
||||
oldeersSet.remove(peerIp);
|
||||
oldPeersSet.remove(peerIp);
|
||||
if (forceHostnameResolution && m_resolver)
|
||||
m_resolver->resolve(peerIp);
|
||||
}
|
||||
@@ -363,7 +363,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo
|
||||
}
|
||||
}
|
||||
// Delete peers that are gone
|
||||
QSetIterator<QString> it(oldeersSet);
|
||||
QSetIterator<QString> it(oldPeersSet);
|
||||
while (it.hasNext()) {
|
||||
const QString &ip = it.next();
|
||||
m_missingFlags.remove(ip);
|
||||
|
||||
@@ -61,7 +61,7 @@ void PeersAdditionDlg::validateInput()
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
foreach (const QString &peer, m_ui->peers_txt->toPlainText().trimmed().split("\n")) {
|
||||
foreach (const QString &peer, m_ui->peers_txt->toPlainText().trimmed().split('\n')) {
|
||||
BitTorrent::PeerAddress addr = parsePeer(peer);
|
||||
if (!addr.ip.isNull()) {
|
||||
m_peersList.append(addr);
|
||||
@@ -82,10 +82,10 @@ BitTorrent::PeerAddress PeersAdditionDlg::parsePeer(QString peer)
|
||||
BitTorrent::PeerAddress addr;
|
||||
QStringList ipPort;
|
||||
|
||||
if (peer[0] == '[' && peer.indexOf("]:") != -1) // IPv6
|
||||
if ((peer[0] == '[') && (peer.indexOf("]:") != -1)) // IPv6
|
||||
ipPort = peer.remove(QChar('[')).split("]:");
|
||||
else if (peer.indexOf(":") != -1) // IPv4
|
||||
ipPort = peer.split(":");
|
||||
else if (peer.indexOf(':') != -1) // IPv4
|
||||
ipPort = peer.split(':');
|
||||
else
|
||||
return addr;
|
||||
|
||||
@@ -95,7 +95,7 @@ BitTorrent::PeerAddress PeersAdditionDlg::parsePeer(QString peer)
|
||||
|
||||
bool ok;
|
||||
int port = ipPort[1].toInt(&ok);
|
||||
if (!ok || port < 1 || port > 65535)
|
||||
if (!ok || (port < 1) || (port > 65535))
|
||||
return addr;
|
||||
|
||||
addr.ip = ip;
|
||||
|
||||
@@ -109,7 +109,7 @@ QVector<float> PieceAvailabilityBar::intToFloatVector(const QVector<int> &vecin,
|
||||
// normalization <0, 1>
|
||||
value /= ratio * maxElement;
|
||||
|
||||
// float precision sometimes gives > 1, because in not possible to store irrational numbers
|
||||
// float precision sometimes gives > 1, because it's not possible to store irrational numbers
|
||||
value = qMin(value, 1.0f);
|
||||
|
||||
result[x] = value;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace
|
||||
{
|
||||
public:
|
||||
PieceIndexToImagePos(const BitTorrent::TorrentInfo &torrentInfo, const QImage &image)
|
||||
: m_bytesPerPixel {(image.width() > 0 && torrentInfo.totalSize() >= image.width())
|
||||
: m_bytesPerPixel {((image.width() > 0) && (torrentInfo.totalSize() >= image.width()))
|
||||
? torrentInfo.totalSize() / image.width() : -1}
|
||||
, m_torrentInfo {torrentInfo}
|
||||
{
|
||||
|
||||
@@ -357,7 +357,7 @@ void PropertiesWidget::readSettings()
|
||||
{
|
||||
const Preferences *const pref = Preferences::instance();
|
||||
// Restore splitter sizes
|
||||
QStringList sizesStr = pref->getPropSplitterSizes().split(",");
|
||||
QStringList sizesStr = pref->getPropSplitterSizes().split(',');
|
||||
if (sizesStr.size() == 2) {
|
||||
m_slideSizes << sizesStr.first().toInt();
|
||||
m_slideSizes << sizesStr.last().toInt();
|
||||
@@ -561,7 +561,7 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containingFolde
|
||||
if (pathItems.isEmpty())
|
||||
return;
|
||||
const QDir saveDir(m_torrent->savePath(true));
|
||||
const QString relativePath = pathItems.join("/");
|
||||
const QString relativePath = pathItems.join('/');
|
||||
absolutePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(relativePath));
|
||||
}
|
||||
else {
|
||||
@@ -743,15 +743,15 @@ void PropertiesWidget::renameSelectedFile()
|
||||
pathItems.prepend(parent.data().toString());
|
||||
parent = m_propListModel->parent(parent);
|
||||
}
|
||||
const QString oldPath = pathItems.join("/");
|
||||
const QString oldPath = pathItems.join('/');
|
||||
pathItems.removeLast();
|
||||
pathItems << newName;
|
||||
QString newPath = pathItems.join("/");
|
||||
QString newPath = pathItems.join('/');
|
||||
if (Utils::Fs::sameFileNames(oldPath, newPath)) {
|
||||
qDebug("Name did not change");
|
||||
return;
|
||||
}
|
||||
if (!newPath.endsWith("/")) newPath += "/";
|
||||
if (!newPath.endsWith('/')) newPath += '/';
|
||||
// Check for overwriting
|
||||
for (int i = 0; i < m_torrent->filesCount(); ++i) {
|
||||
const QString ¤tName = m_torrent->filePath(i);
|
||||
@@ -785,9 +785,9 @@ void PropertiesWidget::renameSelectedFile()
|
||||
// Rename folder in torrent files model too
|
||||
m_propListModel->setData(modelIndex, newName);
|
||||
// Remove old folder
|
||||
const QDir oldFolder(m_torrent->savePath(true) + "/" + oldPath);
|
||||
const QDir oldFolder(m_torrent->savePath(true) + '/' + oldPath);
|
||||
int timeout = 10;
|
||||
while (!QDir().rmpath(oldFolder.absolutePath()) && timeout > 0) {
|
||||
while (!QDir().rmpath(oldFolder.absolutePath()) && (timeout > 0)) {
|
||||
// FIXME: We should not sleep here (freezes the UI for 1 second)
|
||||
QThread::msleep(100);
|
||||
--timeout;
|
||||
@@ -847,7 +847,7 @@ void PropertiesWidget::copySelectedWebSeedsToClipboard() const
|
||||
foreach (QListWidgetItem *item, selectedItems)
|
||||
urlsToCopy << item->text();
|
||||
|
||||
QApplication::clipboard()->setText(urlsToCopy.join("\n"));
|
||||
QApplication::clipboard()->setText(urlsToCopy.join('\n'));
|
||||
}
|
||||
|
||||
void PropertiesWidget::editWebSeed()
|
||||
|
||||
@@ -161,7 +161,7 @@ int SpeedPlotView::maxYValue()
|
||||
if (!m_properties[static_cast<GraphID>(id)].enable)
|
||||
continue;
|
||||
|
||||
for (int i = int(queue.size()) - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j)
|
||||
for (int i = static_cast<int>(queue.size()) - 1, j = 0; (i >= 0) && (j <= m_viewablePointsCount); --i, ++j)
|
||||
if (queue[i].y[id] > maxYValue)
|
||||
maxYValue = queue[i].y[id];
|
||||
}
|
||||
@@ -241,7 +241,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||
continue;
|
||||
|
||||
QVector<QPoint> points;
|
||||
for (int i = int(queue.size()) - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j) {
|
||||
for (int i = static_cast<int>(queue.size()) - 1, j = 0; (i >= 0) && (j <= m_viewablePointsCount); --i, ++j) {
|
||||
|
||||
int newX = rect.right() - j * xTickSize;
|
||||
int newY = rect.bottom() - queue[i].y[id] * yMultiplier;
|
||||
|
||||
@@ -47,7 +47,7 @@ class ComboBoxMenuButton : public QComboBox
|
||||
|
||||
public:
|
||||
ComboBoxMenuButton(QWidget *parent, QMenu *menu);
|
||||
virtual void showPopup();
|
||||
void showPopup() override;
|
||||
|
||||
private:
|
||||
QMenu *m_menu;
|
||||
|
||||
@@ -411,7 +411,7 @@ void TrackerList::copyTrackerUrl()
|
||||
qDebug() << QString("Copy: ") + trackerURL;
|
||||
urlsToCopy << trackerURL;
|
||||
}
|
||||
QApplication::clipboard()->setText(urlsToCopy.join("\n"));
|
||||
QApplication::clipboard()->setText(urlsToCopy.join('\n'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ TrackersAdditionDlg::~TrackersAdditionDlg()
|
||||
QStringList TrackersAdditionDlg::newTrackers() const
|
||||
{
|
||||
QStringList cleanTrackers;
|
||||
foreach (QString url, m_ui->trackers_list->toPlainText().split("\n")) {
|
||||
foreach (QString url, m_ui->trackers_list->toPlainText().split('\n')) {
|
||||
url = url.trimmed();
|
||||
if (!url.isEmpty())
|
||||
cleanTrackers << url;
|
||||
@@ -92,7 +92,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
|
||||
// Load from torrent handle
|
||||
QList<BitTorrent::TrackerEntry> existingTrackers = m_torrent->trackers();
|
||||
// Load from current user list
|
||||
QStringList tmp = m_ui->trackers_list->toPlainText().split("\n");
|
||||
QStringList tmp = m_ui->trackers_list->toPlainText().split('\n');
|
||||
foreach (const QString &userURL, tmp) {
|
||||
BitTorrent::TrackerEntry userTracker(userURL);
|
||||
if (!existingTrackers.contains(userTracker))
|
||||
@@ -100,7 +100,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
|
||||
}
|
||||
|
||||
// Add new trackers to the list
|
||||
if (!m_ui->trackers_list->toPlainText().isEmpty() && !m_ui->trackers_list->toPlainText().endsWith("\n"))
|
||||
if (!m_ui->trackers_list->toPlainText().isEmpty() && !m_ui->trackers_list->toPlainText().endsWith('\n'))
|
||||
m_ui->trackers_list->insertPlainText("\n");
|
||||
int nb = 0;
|
||||
while (!listFile.atEnd()) {
|
||||
@@ -108,7 +108,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
|
||||
if (line.isEmpty()) continue;
|
||||
BitTorrent::TrackerEntry newTracker(line);
|
||||
if (!existingTrackers.contains(newTracker)) {
|
||||
m_ui->trackers_list->insertPlainText(line + "\n");
|
||||
m_ui->trackers_list->insertPlainText(line + '\n');
|
||||
++nb;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
|
||||
|
||||
void TrackersAdditionDlg::getTrackerError(const QString &, const QString &error)
|
||||
{
|
||||
//To restore the cursor ...
|
||||
// To restore the cursor ...
|
||||
setCursor(Qt::ArrowCursor);
|
||||
m_ui->uTorrentListButton->setEnabled(true);
|
||||
QMessageBox::warning(this, tr("Download error"), tr("The trackers list could not be downloaded, reason: %1").arg(error), QMessageBox::Ok);
|
||||
|
||||
Reference in New Issue
Block a user