diff --git a/src/app/cmdoptions.cpp b/src/app/cmdoptions.cpp index 5b5762182..8c305f825 100644 --- a/src/app/cmdoptions.cpp +++ b/src/app/cmdoptions.cpp @@ -486,7 +486,7 @@ CommandLineParameterError::CommandLineParameterError(const QString &messageForUs { } -const QString& CommandLineParameterError::messageForUser() const +const QString &CommandLineParameterError::messageForUser() const { return m_messageForUser; } diff --git a/src/app/main.cpp b/src/app/main.cpp index a4d0438a1..77e6110cc 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -202,7 +202,7 @@ int main(int argc, char *argv[]) // this is the default in Qt6 app->setAttribute(Qt::AA_DisableWindowContextHelpButton); #endif -#endif +#endif // Q_OS_WIN #if defined(Q_OS_MAC) // Since Apple made difficult for users to set PATH, we set here for convenience. diff --git a/src/app/upgrade.h b/src/app/upgrade.h index eeefc8678..b22f8d872 100644 --- a/src/app/upgrade.h +++ b/src/app/upgrade.h @@ -83,7 +83,7 @@ bool userAcceptsUpgrade() msgBox.move(Utils::Misc::screenCenter(&msgBox)); if (msgBox.exec() == QMessageBox::Ok) return true; -#endif +#endif // DISABLE_GUI return false; } diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index d15e26c05..0084dbcbc 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -469,7 +469,7 @@ Session::Session(QObject *parent) }); configurePeerClasses(); -#endif +#endif // LIBTORRENT_VERSION_NUM < 10100 // Enabling plugins //m_nativeSession->add_extension(&libt::create_metadata_plugin); @@ -1253,7 +1253,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack) } #else settingsPack.set_str(libt::settings_pack::outgoing_interfaces, networkInterface().toStdString()); -#endif +#endif // Q_OS_WIN m_listenInterfaceChanged = false; } @@ -1462,7 +1462,7 @@ void Session::configurePeerClasses() , 1 << libt::session::global_peer_class_id); } catch (std::exception &) {} -#endif +#endif // TORRENT_USE_IPV6 if (ignoreLimitsOnLAN()) { // local networks f.add_rule(libt::address_v4::from_string("10.0.0.0") @@ -1501,7 +1501,7 @@ void Session::configurePeerClasses() , 1 << libt::session::local_peer_class_id); } catch (std::exception &) {} -#endif +#endif // TORRENT_USE_IPV6 } m_nativeSession->set_peer_class_filter(f); @@ -1518,7 +1518,7 @@ void Session::configurePeerClasses() m_nativeSession->set_peer_class_type_filter(peerClassTypeFilter); } -#else +#else // LIBTORRENT_VERSION_NUM >= 10100 void Session::adjustLimits(libt::session_settings &sessionSettings) { @@ -1735,7 +1735,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings) break; } } -#endif +#endif // LIBTORRENT_VERSION_NUM >= 10100 void Session::enableTracker(bool enable) { @@ -1983,8 +1983,8 @@ void Session::increaseTorrentsPriority(const QStringList &hashes) std::greater>> torrentQueue; // Sort torrents by priority - foreach (const InfoHash &hash, hashes) { - TorrentHandle *const torrent = m_torrents.value(hash); + foreach (const InfoHash &infoHash, hashes) { + TorrentHandle *const torrent = m_torrents.value(infoHash); if (torrent && !torrent->isSeed()) torrentQueue.push(qMakePair(torrent->queuePosition(), torrent)); } @@ -2006,8 +2006,8 @@ void Session::decreaseTorrentsPriority(const QStringList &hashes) std::less>> torrentQueue; // Sort torrents by priority - foreach (const InfoHash &hash, hashes) { - TorrentHandle *const torrent = m_torrents.value(hash); + foreach (const InfoHash &infoHash, hashes) { + TorrentHandle *const torrent = m_torrents.value(infoHash); if (torrent && !torrent->isSeed()) torrentQueue.push(qMakePair(torrent->queuePosition(), torrent)); } @@ -2032,8 +2032,8 @@ void Session::topTorrentsPriority(const QStringList &hashes) std::greater>> torrentQueue; // Sort torrents by priority - foreach (const InfoHash &hash, hashes) { - TorrentHandle *const torrent = m_torrents.value(hash); + foreach (const InfoHash &infoHash, hashes) { + TorrentHandle *const torrent = m_torrents.value(infoHash); if (torrent && !torrent->isSeed()) torrentQueue.push(qMakePair(torrent->queuePosition(), torrent)); } @@ -2055,8 +2055,8 @@ void Session::bottomTorrentsPriority(const QStringList &hashes) std::less>> torrentQueue; // Sort torrents by priority - foreach (const InfoHash &hash, hashes) { - TorrentHandle *const torrent = m_torrents.value(hash); + foreach (const InfoHash &infoHash, hashes) { + TorrentHandle *const torrent = m_torrents.value(infoHash); if (torrent && !torrent->isSeed()) torrentQueue.push(qMakePair(torrent->queuePosition(), torrent)); } @@ -2397,7 +2397,7 @@ void Session::saveResumeData() break; } - for (const auto a: alerts) { + for (const auto a : alerts) { switch (a->type()) { case libt::save_resume_data_failed_alert::alert_type: case libt::save_resume_data_alert::alert_type: @@ -2598,7 +2598,7 @@ void Session::configureListeningInterface() #else m_listenInterfaceChanged = true; configureDeferred(); -#endif +#endif // LIBTORRENT_VERSION_NUM < 10100 } int Session::globalDownloadSpeedLimit() const @@ -3011,7 +3011,7 @@ void Session::setMaxConnectionsPerTorrent(int max) m_maxConnectionsPerTorrent = max; // Apply this to all session torrents - for (const auto &handle: m_nativeSession->get_torrents()) { + for (const auto &handle : m_nativeSession->get_torrents()) { if (!handle.is_valid()) continue; try { handle.set_max_connections(max); @@ -3033,7 +3033,7 @@ void Session::setMaxUploadsPerTorrent(int max) m_maxUploadsPerTorrent = max; // Apply this to all session torrents - for (const auto &handle: m_nativeSession->get_torrents()) { + for (const auto &handle : m_nativeSession->get_torrents()) { if (!handle.is_valid()) continue; try { handle.set_max_uploads(max); @@ -4095,7 +4095,7 @@ void Session::readAlerts() std::vector alerts; getPendingAlerts(alerts); - for (const auto a: alerts) { + for (const auto a : alerts) { handleAlert(a); #if LIBTORRENT_VERSION_NUM < 10100 delete a; @@ -4502,7 +4502,7 @@ void Session::handleSessionStatsAlert(libt::session_stats_alert *p) emit statsUpdated(); } -#else +#else // LIBTORRENT_VERSION_NUM >= 10100 void Session::updateStats() { libt::session_status ss = m_nativeSession->status(); @@ -4539,7 +4539,7 @@ void Session::updateStats() emit statsUpdated(); } -#endif +#endif // LIBTORRENT_VERSION_NUM >= 10100 void Session::handleStateUpdateAlert(libt::state_update_alert *p) { @@ -4590,7 +4590,7 @@ namespace return true; } - bool loadTorrentResumeData(const QByteArray &data, CreateTorrentParams &torrentParams, int &prio, MagnetUri &magnetUri) + bool loadTorrentResumeData(const QByteArray &data, CreateTorrentParams &torrentParams, int &prio, MagnetUri &magnetUri) { torrentParams = CreateTorrentParams(); torrentParams.restored = true; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 0c0156ae6..0ba2acef0 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -237,7 +237,7 @@ namespace BitTorrent int diskJobTime = 0; } disk; }; -#endif +#endif // LIBTORRENT_VERSION_NUM >= 10100 class Session : public QObject { diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index e8761c66a..7f8022d9a 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -158,14 +158,14 @@ namespace { // new constructor is available template::value, int>::type = 0> - T makeTorrentCreator(const libtorrent::torrent_info & ti) + T makeTorrentCreator(const libtorrent::torrent_info &ti) { return T(ti, true); } // new constructor isn't available template::value, int>::type = 0> - T makeTorrentCreator(const libtorrent::torrent_info & ti) + T makeTorrentCreator(const libtorrent::torrent_info &ti) { return T(ti); } @@ -623,7 +623,7 @@ QString TorrentHandle::filePath(int index) const QString TorrentHandle::fileName(int index) const { - if (!hasMetadata()) return QString(); + if (!hasMetadata()) return QString(); return Utils::Fs::fileName(filePath(index)); } @@ -636,7 +636,7 @@ qlonglong TorrentHandle::fileSize(int index) const // to all files in a torrent QStringList TorrentHandle::absoluteFilePaths() const { - if (!hasMetadata()) return QStringList(); + if (!hasMetadata()) return QStringList(); QDir saveDir(savePath(true)); QStringList res; @@ -647,7 +647,7 @@ QStringList TorrentHandle::absoluteFilePaths() const QStringList TorrentHandle::absoluteFilePathsUnwanted() const { - if (!hasMetadata()) return QStringList(); + if (!hasMetadata()) return QStringList(); QDir saveDir(savePath(true)); QStringList res; @@ -2063,7 +2063,7 @@ void TorrentHandle::prioritizeFiles(const QVector &priorities) if (created) { // Hide the folder on Windows qDebug() << "Hiding folder (Windows)"; - std::wstring winPath = Utils::Fs::toNativePath(unwantedAbsPath).toStdWString(); + std::wstring winPath = Utils::Fs::toNativePath(unwantedAbsPath).toStdWString(); DWORD dwAttrs = ::GetFileAttributesW(winPath.c_str()); bool ret = ::SetFileAttributesW(winPath.c_str(), dwAttrs | FILE_ATTRIBUTE_HIDDEN); Q_ASSERT(ret != 0); Q_UNUSED(ret); diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index df96014a6..f5db8fdcf 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -350,7 +350,7 @@ void TorrentInfo::renameFile(const int index, const QString &newPath) nativeInfo()->rename_file(index, Utils::Fs::toNativePath(newPath).toStdString()); } -int BitTorrent::TorrentInfo::fileIndex(const QString& fileName) const +int BitTorrent::TorrentInfo::fileIndex(const QString &fileName) const { // the check whether the object is valid is not needed here // because if filesCount() returns -1 the loop exits immediately diff --git a/src/base/http/types.h b/src/base/http/types.h index 0e30feb9e..464e53920 100644 --- a/src/base/http/types.h +++ b/src/base/http/types.h @@ -107,7 +107,7 @@ namespace Http uint code; QString text; - ResponseStatus(uint code = 200, const QString& text = "OK"): code(code), text(text) {} + ResponseStatus(uint code = 200, const QString &text = "OK"): code(code), text(text) {} }; struct Response @@ -116,7 +116,7 @@ namespace Http QStringMap headers; QByteArray content; - Response(uint code = 200, const QString& text = "OK"): status(code, text) {} + Response(uint code = 200, const QString &text = "OK"): status(code, text) {} }; } diff --git a/src/base/net/proxyconfigurationmanager.cpp b/src/base/net/proxyconfigurationmanager.cpp index d06352792..1255fc6c1 100644 --- a/src/base/net/proxyconfigurationmanager.cpp +++ b/src/base/net/proxyconfigurationmanager.cpp @@ -40,7 +40,7 @@ const QString KEY_PASSWORD = SETTINGS_KEY("Password"); namespace { - inline SettingsStorage *settings() { return SettingsStorage::instance(); } + inline SettingsStorage *settings() { return SettingsStorage::instance(); } inline bool isSameConfig(const Net::ProxyConfiguration &conf1, const Net::ProxyConfiguration &conf2) { diff --git a/src/base/net/smtp.cpp b/src/base/net/smtp.cpp index 691ba1890..c3a90f4e8 100644 --- a/src/base/net/smtp.cpp +++ b/src/base/net/smtp.cpp @@ -291,7 +291,7 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex if (!prefix.isEmpty()) line += prefix; if (!value.contains("=?") && latin1->canEncode(value)) { bool firstWord = true; - foreach (const QByteArray& word, value.toLatin1().split(' ')) { + foreach (const QByteArray &word, value.toLatin1().split(' ')) { if (line.size() > 78) { rv = rv + line + "\r\n"; line.clear(); diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp index 6bebb22c1..c5febd7e5 100644 --- a/src/base/preferences.cpp +++ b/src/base/preferences.cpp @@ -212,7 +212,7 @@ void Preferences::setCloseToTrayNotified(bool b) { setValue("Preferences/General/CloseToTrayNotified", b); } -#endif +#endif // Q_OS_MAC bool Preferences::isToolbarDisplayed() const { @@ -293,7 +293,7 @@ void Preferences::setWinStartup(bool b) settings.remove("qBittorrent"); } } -#endif +#endif // Q_OS_WIN // Downloads QString Preferences::lastLocationPath() const @@ -967,7 +967,7 @@ void Preferences::setMagnetLinkAssoc(bool set) SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0); } -#endif +#endif // Q_OS_WIN #ifdef Q_OS_MAC namespace @@ -1023,7 +1023,7 @@ void Preferences::setMagnetLinkAssoc() CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle()); LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId); } -#endif +#endif // Q_OS_MAC int Preferences::getTrackerPort() const { diff --git a/src/base/preferences.h b/src/base/preferences.h index 26e21f60b..5a58cc835 100644 --- a/src/base/preferences.h +++ b/src/base/preferences.h @@ -299,7 +299,7 @@ public: void setCloseToTrayNotified(bool b); TrayIcon::Style trayIconStyle() const; void setTrayIconStyle(TrayIcon::Style style); -#endif +#endif // Q_OS_MAC // Stuff that don't appear in the Options GUI but are saved // in the same file. diff --git a/src/base/rss/private/rss_parser.cpp b/src/base/rss/private/rss_parser.cpp index 96201bb3c..1d445f1c7 100644 --- a/src/base/rss/private/rss_parser.cpp +++ b/src/base/rss/private/rss_parser.cpp @@ -435,13 +435,13 @@ namespace if (leapSecond) second = 59; // apparently a leap second - validate below, once time zone is known int month = 0; - for ( ; (month < 12) && (parts[nmonth] != shortMonth[month]); ++month); + for ( ; (month < 12) && (parts[nmonth] != shortMonth[month]); ++month); int dayOfWeek = -1; if (!parts[nwday].isEmpty()) { // Look up the weekday name - while (++dayOfWeek < 7 && (shortDay[dayOfWeek] != parts[nwday])); + while ((++dayOfWeek < 7) && (shortDay[dayOfWeek] != parts[nwday])); if (dayOfWeek >= 7) - for (dayOfWeek = 0; dayOfWeek < 7 && (longDay[dayOfWeek] != parts[nwday]); ++dayOfWeek); + for (dayOfWeek = 0; (dayOfWeek < 7) && (longDay[dayOfWeek] != parts[nwday]); ++dayOfWeek); } // if (month >= 12 || dayOfWeek >= 7 @@ -450,7 +450,7 @@ namespace int i = parts[nyear].size(); if (i < 4) { // It's an obsolete year specification with less than 4 digits - year += (i == 2 && year < 50) ? 2000 : 1900; + year += ((i == 2) && (year < 50)) ? 2000 : 1900; } // Parse the UTC offset part @@ -473,17 +473,17 @@ namespace else { // Check for an obsolete time zone name QByteArray zone = parts[10].toLatin1(); - if (zone.length() == 1 && isalpha(zone[0]) && toupper(zone[0]) != 'J') { + if ((zone.length() == 1) && (isalpha(zone[0])) && (toupper(zone[0]) != 'J')) { negOffset = true; // military zone: RFC 2822 treats as '-0000' } - else if (zone != "UT" && zone != "GMT") { // treated as '+0000' + else if ((zone != "UT") && (zone != "GMT")) { // treated as '+0000' offset = (zone == "EDT") ? -4 * 3600 : ((zone == "EST") || (zone == "CDT")) ? -5 * 3600 : ((zone == "CST") || (zone == "MDT")) ? -6 * 3600 - : (zone == "MST" || zone == "PDT") + : ((zone == "MST") || (zone == "PDT")) ? -7 * 3600 : (zone == "PST") ? -8 * 3600 @@ -502,12 +502,12 @@ namespace } } - QDate qdate(year, month + 1, day); // convert date, and check for out-of-range - if (!qdate.isValid()) + QDate qDate(year, month + 1, day); // convert date, and check for out-of-range + if (!qDate.isValid()) return QDateTime::currentDateTime(); QTime qTime(hour, minute, second); - QDateTime result(qdate, qTime, Qt::UTC); + QDateTime result(qDate, qTime, Qt::UTC); if (offset) result = result.addSecs(-offset); if (!result.isValid()) diff --git a/src/base/rss/rss_autodownloader.cpp b/src/base/rss/rss_autodownloader.cpp index de29f00b3..112d65286 100644 --- a/src/base/rss/rss_autodownloader.cpp +++ b/src/base/rss/rss_autodownloader.cpp @@ -373,7 +373,7 @@ void AutoDownloader::addJobForArticle(Article *article) void AutoDownloader::processJob(const QSharedPointer &job) { - for (AutoDownloadRule &rule: m_rules) { + for (AutoDownloadRule &rule : m_rules) { if (!rule.isEnabled()) continue; if (!rule.feedURLs().contains(job->feedURL)) continue; if (!rule.accepts(job->articleData)) continue; diff --git a/src/base/rss/rss_autodownloadrule.cpp b/src/base/rss/rss_autodownloadrule.cpp index f87846fe9..e6cd5f8e5 100644 --- a/src/base/rss/rss_autodownloadrule.cpp +++ b/src/base/rss/rss_autodownloadrule.cpp @@ -246,7 +246,7 @@ bool AutoDownloadRule::matchesMustContainExpression(const QString &articleTitle) return false; } -bool AutoDownloadRule::matchesMustNotContainExpression(const QString& articleTitle) const +bool AutoDownloadRule::matchesMustNotContainExpression(const QString &articleTitle) const { if (m_dataPtr->mustNotContain.empty()) return true; @@ -262,7 +262,7 @@ bool AutoDownloadRule::matchesMustNotContainExpression(const QString& articleTit return true; } -bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString& articleTitle) const +bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString &articleTitle) const { // Reset the lastComputedEpisode, we don't want to leak it between matches m_dataPtr->lastComputedEpisode.clear(); @@ -332,7 +332,7 @@ bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString& articleTitl return false; } -bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString& articleTitle) const +bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString &articleTitle) const { if (!useSmartFilter()) return true; diff --git a/src/base/rss/rss_folder.cpp b/src/base/rss/rss_folder.cpp index f9c934080..e52669811 100644 --- a/src/base/rss/rss_folder.cpp +++ b/src/base/rss/rss_folder.cpp @@ -123,7 +123,7 @@ void Folder::addItem(Item *item) connect(item, &Item::articleAboutToBeRemoved, this, &Item::articleAboutToBeRemoved); connect(item, &Item::unreadCountChanged, this, &Folder::handleItemUnreadCountChanged); - for (auto article: copyAsConst(item->articles())) + for (auto article : copyAsConst(item->articles())) emit newArticle(article); if (item->unreadCount() > 0) @@ -134,7 +134,7 @@ void Folder::removeItem(Item *item) { Q_ASSERT(m_items.contains(item)); - for (auto article: copyAsConst(item->articles())) + for (auto article : copyAsConst(item->articles())) emit articleAboutToBeRemoved(article); item->disconnect(this); diff --git a/src/base/utils/foreignapps.cpp b/src/base/utils/foreignapps.cpp index 6f27ab3d7..aae8f89e6 100644 --- a/src/base/utils/foreignapps.cpp +++ b/src/base/utils/foreignapps.cpp @@ -229,7 +229,7 @@ namespace return QString(); } -#endif +#endif // Q_OS_WIN } bool Utils::ForeignApps::PythonInfo::isValid() const diff --git a/src/base/utils/fs.cpp b/src/base/utils/fs.cpp index 12dc6cf17..f928a29cb 100644 --- a/src/base/utils/fs.cpp +++ b/src/base/utils/fs.cpp @@ -329,7 +329,7 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path) return ((strncmp(buf.f_fstypename, "cifs", sizeof(buf.f_fstypename)) == 0) || (strncmp(buf.f_fstypename, "nfs", sizeof(buf.f_fstypename)) == 0) || (strncmp(buf.f_fstypename, "smbfs", sizeof(buf.f_fstypename)) == 0)); -#else +#else // Q_OS_WIN QString file = path; if (!file.endsWith('/')) file += '/'; @@ -351,6 +351,6 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path) default: return false; } -#endif +#endif // Q_OS_WIN } -#endif +#endif // Q_OS_HAIKU diff --git a/src/base/utils/misc.cpp b/src/base/utils/misc.cpp index abaaab883..a00e10585 100644 --- a/src/base/utils/misc.cpp +++ b/src/base/utils/misc.cpp @@ -66,7 +66,7 @@ #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) #include "base/utils/version.h" #endif -#endif +#endif // DISABLE_GUI #include "base/logger.h" #include "base/unicodestrings.h" diff --git a/src/base/utils/misc.h b/src/base/utils/misc.h index 7cdcea2b6..45a2e1e89 100644 --- a/src/base/utils/misc.h +++ b/src/base/utils/misc.h @@ -124,7 +124,7 @@ namespace Utils return reinterpret_cast( ::GetProcAddress(::LoadLibraryW(pathWchar.get()), funcName)); } -#endif +#endif // Q_OS_WIN } } diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index fd59048d8..5342a1888 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -425,7 +425,7 @@ void AdvancedSettings::loadAdvancedSettings() const QString currentInterface = session->networkInterface(); bool interfaceExists = currentInterface.isEmpty(); int i = 1; - foreach (const QNetworkInterface& iface, QNetworkInterface::allInterfaces()) { + foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) { // This line fixes a Qt bug => https://bugreports.qt.io/browse/QTBUG-52633 // Tested in Qt 5.6.0. For more info see: // https://github.com/qbittorrent/qBittorrent/issues/5131 diff --git a/src/gui/fspathedit.cpp b/src/gui/fspathedit.cpp index 2d18d0660..b19a64b80 100644 --- a/src/gui/fspathedit.cpp +++ b/src/gui/fspathedit.cpp @@ -350,7 +350,7 @@ void FileSystemPathComboEdit::addItem(const QString &text) editWidget()->addItem(Utils::Fs::toNativePath(text)); } -void FileSystemPathComboEdit::insertItem(int index, const QString& text) +void FileSystemPathComboEdit::insertItem(int index, const QString &text) { editWidget()->insertItem(index, Utils::Fs::toNativePath(text)); } diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index d91e3f29b..b53ef50ca 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -305,7 +305,7 @@ MainWindow::MainWindow(QWidget *parent) spacer->setMinimumWidth(8); m_ui->toolBar->addWidget(spacer); } -#endif +#endif // Q_OS_MAC // Transfer list slots connect(m_ui->actionStart, &QAction::triggered, m_transferListWidget, &TransferListWidget::startSelectedTorrents); @@ -1110,7 +1110,7 @@ void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason break; } } -#endif +#endif // Q_OS_MAC // Display About Dialog void MainWindow::on_actionAbout_triggered() @@ -1272,7 +1272,7 @@ bool MainWindow::event(QEvent *e) default: break; } -#endif +#endif // Q_OS_MAC return QMainWindow::event(e); } @@ -1361,7 +1361,7 @@ void MainWindow::setupDockClickHandler() MacUtils::overrideDockClickHandler(dockClickHandler); } -#endif +#endif // Q_OS_MAC /***************************************************** * * diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 4615e9090..6674d80ee 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -163,7 +163,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) QList buttons = m_ui->buttonBox->buttons(); foreach (QAbstractButton *button, buttons) { if (m_ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) { - applyButton = button; + m_applyButton = button; break; } } @@ -424,13 +424,13 @@ OptionsDialog::OptionsDialog(QWidget *parent) connect(m_ui->btnEditRules, &QPushButton::clicked, this, [this]() { AutomatedRssDownloader(this).exec(); }); // Disable apply Button - applyButton->setEnabled(false); + m_applyButton->setEnabled(false); // Tab selection mechanism connect(m_ui->tabSelection, &QListWidget::currentItemChanged, this, &ThisType::changePage); // Load Advanced settings - advancedSettings = new AdvancedSettings(m_ui->tabAdvancedPage); - m_ui->advPageLayout->addWidget(advancedSettings); - connect(advancedSettings, &AdvancedSettings::settingsChanged, this, &ThisType::enableApplyButton); + m_advancedSettings = new AdvancedSettings(m_ui->tabAdvancedPage); + m_ui->advPageLayout->addWidget(m_advancedSettings); + connect(m_advancedSettings, &AdvancedSettings::settingsChanged, this, &ThisType::enableApplyButton); m_ui->textFileLogPath->setDialogCaption(tr("Choose a save directory")); m_ui->textFileLogPath->setMode(FileSystemPathEdit::Mode::DirectorySave); @@ -493,7 +493,7 @@ OptionsDialog::~OptionsDialog() saveWindowState(); - foreach (const QString &path, addedScanDirs) + foreach (const QString &path, m_addedScanDirs) ScanFoldersModel::instance()->removePath(path); ScanFoldersModel::instance()->configure(); // reloads "removed" paths delete m_ui; @@ -541,7 +541,7 @@ void OptionsDialog::saveWindowState() const void OptionsDialog::saveOptions() { - applyButton->setEnabled(false); + m_applyButton->setEnabled(false); Preferences *const pref = Preferences::instance(); // Load the translation QString locale = getLocale(); @@ -625,11 +625,11 @@ void OptionsDialog::saveOptions() AddNewTorrentDialog::setTopLevel(m_ui->checkAdditionDialogFront->isChecked()); session->setAddTorrentPaused(addTorrentsInPause()); session->setCreateTorrentSubfolder(m_ui->checkCreateSubfolder->isChecked()); - ScanFoldersModel::instance()->removeFromFSWatcher(removedScanDirs); - ScanFoldersModel::instance()->addToFSWatcher(addedScanDirs); + ScanFoldersModel::instance()->removeFromFSWatcher(m_removedScanDirs); + ScanFoldersModel::instance()->addToFSWatcher(m_addedScanDirs); ScanFoldersModel::instance()->makePersistent(); - removedScanDirs.clear(); - addedScanDirs.clear(); + m_removedScanDirs.clear(); + m_addedScanDirs.clear(); session->setTorrentExportDirectory(getTorrentExportDir()); session->setFinishedTorrentExportDirectory(getFinishedTorrentExportDir()); pref->setMailNotificationEnabled(m_ui->groupMailNotification->isChecked()); @@ -748,7 +748,7 @@ void OptionsDialog::saveOptions() // End Web UI // End preferences // Save advanced settings - advancedSettings->saveAdvancedSettings(); + m_advancedSettings->saveAdvancedSettings(); // Assume that user changed multiple settings // so it's best to save immediately pref->apply(); @@ -1240,7 +1240,7 @@ int OptionsDialog::getMaxUploadsPerTorrent() const void OptionsDialog::on_buttonBox_accepted() { - if (applyButton->isEnabled()) { + if (m_applyButton->isEnabled()) { if (!schedTimesOk()) { m_ui->tabSelection->setCurrentRow(TAB_SPEED); return; @@ -1249,7 +1249,7 @@ void OptionsDialog::on_buttonBox_accepted() m_ui->tabSelection->setCurrentRow(TAB_WEBUI); return; } - applyButton->setEnabled(false); + m_applyButton->setEnabled(false); this->hide(); saveOptions(); } @@ -1259,7 +1259,7 @@ void OptionsDialog::on_buttonBox_accepted() void OptionsDialog::applySettings(QAbstractButton *button) { - if (button == applyButton) { + if (button == m_applyButton) { if (!schedTimesOk()) { m_ui->tabSelection->setCurrentRow(TAB_SPEED); return; @@ -1291,7 +1291,7 @@ bool OptionsDialog::useAdditionDialog() const void OptionsDialog::enableApplyButton() { - applyButton->setEnabled(true); + m_applyButton->setEnabled(true); } void OptionsDialog::toggleComboRatioLimitAct() @@ -1486,7 +1486,7 @@ void OptionsDialog::on_addScanFolderButton_clicked() break; default: pref->setScanDirsLastPath(dir); - addedScanDirs << dir; + m_addedScanDirs << dir; for (int i = 0; i < ScanFoldersModel::instance()->columnCount(); ++i) m_ui->scanFoldersView->resizeColumnToContents(i); enableApplyButton(); @@ -1506,7 +1506,7 @@ void OptionsDialog::on_removeScanFolderButton_clicked() Q_ASSERT(selected.count() == ScanFoldersModel::instance()->columnCount()); foreach (const QModelIndex &index, selected) { if (index.column() == ScanFoldersModel::WATCH) - removedScanDirs << index.data().toString(); + m_removedScanDirs << index.data().toString(); } ScanFoldersModel::instance()->removePath(selected.first().row(), false); } diff --git a/src/gui/optionsdialog.h b/src/gui/optionsdialog.h index d4a7a9c74..37d475c50 100644 --- a/src/gui/optionsdialog.h +++ b/src/gui/optionsdialog.h @@ -176,11 +176,10 @@ private: QByteArray m_sslCert, m_sslKey; Ui::OptionsDialog *m_ui; - QButtonGroup choiceLanguage; - QAbstractButton *applyButton; - AdvancedSettings *advancedSettings; - QList addedScanDirs; - QList removedScanDirs; + QAbstractButton *m_applyButton; + AdvancedSettings *m_advancedSettings; + QList m_addedScanDirs; + QList m_removedScanDirs; }; #endif // OPTIONSDIALOG_H diff --git a/src/gui/programupdater.cpp b/src/gui/programupdater.cpp index c3c9261ee..80ce8f054 100644 --- a/src/gui/programupdater.cpp +++ b/src/gui/programupdater.cpp @@ -141,7 +141,7 @@ bool ProgramUpdater::isVersionMoreRecent(const QString &remoteVersion) const qDebug() << Q_FUNC_INFO << "local version:" << localVersion << "/" << QBT_VERSION; QStringList remoteParts = remoteVersion.split('.'); QStringList localParts = localVersion.split('.'); - for (int i = 0; i localParts[i].toInt()) return true; if (remoteParts[i].toInt() < localParts[i].toInt()) diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 66c122bfa..94b77bb19 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -103,7 +103,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) hideColumn(PeerListDelegate::COUNTRY); // Ensure that at least one column is visible at all times bool atLeastOne = false; - for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) { + for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) { if (!isColumnHidden(i)) { atLeastOne = true; break; @@ -114,7 +114,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) // To also mitigate the above issue, we have to resize each column when // its size is 0, because explicitly 'showing' the column isn't enough // in the above scenario. - for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) + for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) if ((columnWidth(i) <= 0) && !isColumnHidden(i)) resizeColumnToContents(i); // Context menu @@ -169,7 +169,7 @@ void PeerListWidget::displayToggleColumnsMenu(const QPoint &) actions.append(myAct); } int visibleCols = 0; - for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) { + for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) { if (!isColumnHidden(i)) ++visibleCols; @@ -321,7 +321,7 @@ void PeerListWidget::clear() int nbrows = m_listModel->rowCount(); if (nbrows > 0) { qDebug("Cleared %d peers", nbrows); - m_listModel->removeRows(0, nbrows); + m_listModel->removeRows(0, nbrows); } } diff --git a/src/gui/properties/piecesbar.cpp b/src/gui/properties/piecesbar.cpp index 75298d054..34047f442 100644 --- a/src/gui/properties/piecesbar.cpp +++ b/src/gui/properties/piecesbar.cpp @@ -275,7 +275,7 @@ void PiecesBar::showToolTip(const QHelpEvent *e) DetailedTooltipRenderer renderer(stream, tooltipTitle); const bool isFileNameCorrectionNeeded = this->isFileNameCorrectionNeeded(); - for (int f: files) { + for (int f : files) { QString filePath {m_torrent->info().filePath(f)}; if (isFileNameCorrectionNeeded) filePath.replace(QLatin1String("/.unwanted"), QString()); diff --git a/src/gui/search/searchsortmodel.cpp b/src/gui/search/searchsortmodel.cpp index 2369cc477..2fe8e3234 100644 --- a/src/gui/search/searchsortmodel.cpp +++ b/src/gui/search/searchsortmodel.cpp @@ -126,7 +126,7 @@ bool SearchSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP const QAbstractItemModel *const sourceModel = this->sourceModel(); if (m_isNameFilterEnabled && !m_searchTerm.isEmpty()) { QString name = sourceModel->data(sourceModel->index(sourceRow, NAME, sourceParent)).toString(); - for (const QString &word: m_searchTermWords) { + for (const QString &word : m_searchTermWords) { int i = name.indexOf(word, 0, Qt::CaseInsensitive); if (i == -1) { return false; diff --git a/src/gui/torrentcontentmodel.cpp b/src/gui/torrentcontentmodel.cpp index 01bc66c30..242c913eb 100644 --- a/src/gui/torrentcontentmodel.cpp +++ b/src/gui/torrentcontentmodel.cpp @@ -146,7 +146,7 @@ namespace #elif defined(Q_OS_MAC) // There is a similar bug on macOS, to be reported to Qt // https://github.com/qbittorrent/qBittorrent/pull/6156#issuecomment-316302615 - class MacFileIconProvider final: public CachingFileIconProvider + class MacFileIconProvider final : public CachingFileIconProvider { QPixmap pixmapForExtension(const QString &ext) const override { @@ -346,7 +346,7 @@ int TorrentContentModel::getFileIndex(const QModelIndex &index) return -1; } -QVariant TorrentContentModel::data(const QModelIndex& index, int role) const +QVariant TorrentContentModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); diff --git a/src/gui/torrentcontentmodel.h b/src/gui/torrentcontentmodel.h index 3a151cffa..921310ef9 100644 --- a/src/gui/torrentcontentmodel.h +++ b/src/gui/torrentcontentmodel.h @@ -54,13 +54,13 @@ public: QVector getFilePriorities() const; bool allFiltered() const; int columnCount(const QModelIndex &parent = QModelIndex()) const override; - bool setData(const QModelIndex &index, const QVariant& value, int role = Qt::EditRole) override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const; int getFileIndex(const QModelIndex &index); QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &index) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; void clear(); diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index 66a90de56..96ba93523 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -404,7 +404,7 @@ void TrackerFiltersList::trackerWarning(const QString &hash, const QString &trac applyFilter(3); } -void TrackerFiltersList::downloadFavicon(const QString& url) +void TrackerFiltersList::downloadFavicon(const QString &url) { if (!m_downloadTrackerFavicon) return; Net::DownloadHandler *h = Net::DownloadManager::instance()->download( @@ -416,7 +416,7 @@ void TrackerFiltersList::downloadFavicon(const QString& url) , &TrackerFiltersList::handleFavicoFailure); } -void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& filePath) +void TrackerFiltersList::handleFavicoDownload(const QString &url, const QString &filePath) { QString host = url.startsWith(GOOGLE_FAVICON_URL) ? url.mid(GOOGLE_FAVICON_URL.size()) diff --git a/src/gui/transferlistmodel.h b/src/gui/transferlistmodel.h index 618d33331..a7eb4bf24 100644 --- a/src/gui/transferlistmodel.h +++ b/src/gui/transferlistmodel.h @@ -83,7 +83,7 @@ public: explicit TransferListModel(QObject *parent = nullptr); - int rowCount(const QModelIndex& index = QModelIndex()) const override; + int rowCount(const QModelIndex &index = QModelIndex()) const override; int columnCount(const QModelIndex &parent=QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; bool setData(const QModelIndex &index, const QVariant &value, int role) override; diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 13349987c..6782d70ad 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -582,7 +582,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const } pathsList.insert(path); } -#endif +#endif // Q_OS_MAC } void TransferListWidget::previewSelectedTorrents() @@ -595,16 +595,16 @@ void TransferListWidget::previewSelectedTorrents() void TransferListWidget::setDlLimitSelectedTorrents() { - QList TorrentsList; + QList torrentsList; foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) { if (torrent->isSeed()) continue; - TorrentsList += torrent; + torrentsList += torrent; } - if (TorrentsList.empty()) return; + if (torrentsList.empty()) return; - int oldLimit = TorrentsList.first()->downloadLimit(); - foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) { + int oldLimit = torrentsList.first()->downloadLimit(); + foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) { if (torrent->downloadLimit() != oldLimit) { oldLimit = -1; break; @@ -617,7 +617,7 @@ void TransferListWidget::setDlLimitSelectedTorrents() , BitTorrent::Session::instance()->globalDownloadSpeedLimit()); if (!ok) return; - foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) { + foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) { qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qUtf8Printable(torrent->hash())); torrent->setDownloadLimit(newLimit); } @@ -625,11 +625,11 @@ void TransferListWidget::setDlLimitSelectedTorrents() void TransferListWidget::setUpLimitSelectedTorrents() { - QList TorrentsList = getSelectedTorrents(); - if (TorrentsList.empty()) return; + QList torrentsList = getSelectedTorrents(); + if (torrentsList.empty()) return; - int oldLimit = TorrentsList.first()->uploadLimit(); - foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) { + int oldLimit = torrentsList.first()->uploadLimit(); + foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) { if (torrent->uploadLimit() != oldLimit) { oldLimit = -1; break; @@ -642,7 +642,7 @@ void TransferListWidget::setUpLimitSelectedTorrents() , BitTorrent::Session::instance()->globalUploadSpeedLimit()); if (!ok) return; - foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) { + foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) { qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qUtf8Printable(torrent->hash())); torrent->setUploadLimit(newLimit); } @@ -1144,7 +1144,7 @@ void TransferListWidget::displayListMenu(const QPoint&) } } -void TransferListWidget::currentChanged(const QModelIndex& current, const QModelIndex&) +void TransferListWidget::currentChanged(const QModelIndex ¤t, const QModelIndex&) { qDebug("CURRENT CHANGED"); BitTorrent::TorrentHandle *torrent = nullptr; diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index 97e7d7573..2807d0325 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -106,7 +106,7 @@ protected: protected slots: void torrentDoubleClicked(); void displayListMenu(const QPoint&); - void currentChanged(const QModelIndex& current, const QModelIndex&) override; + void currentChanged(const QModelIndex ¤t, const QModelIndex&) override; void toggleSelectedTorrentsSuperSeeding() const; void toggleSelectedTorrentsSequentialDownload() const; void toggleSelectedFirstLastPiecePrio() const;