diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..5143187d0 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,82 @@ +Checks: > + bugprone-*, + cert-*, + concurrency-*, + cppcoreguidelines-*, + misc-*, + modernize-*, + performance-*, + portability-*, + readability-*, + -# not applicable at all, + -bugprone-easily-swappable-parameters, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-macro-parentheses, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-owning-memory, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -cppcoreguidelines-pro-bounds-constant-array-index, + -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -cppcoreguidelines-pro-type-const-cast, + -cppcoreguidelines-pro-type-reinterpret-cast, + -cppcoreguidelines-pro-type-union-access, + -cppcoreguidelines-pro-type-vararg, + -cppcoreguidelines-special-member-functions, + -cppcoreguidelines-virtual-class-destructor, + -misc-no-recursion, + -misc-non-private-member-variables-in-classes, + -misc-unused-parameters, + -modernize-avoid-c-arrays, + -modernize-pass-by-value, + -modernize-use-auto, + -modernize-use-nodiscard, + -modernize-use-trailing-return-type, + -modernize-use-using, + -readability-function-cognitive-complexity, + -readability-function-size, + -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-isolate-declaration, + -readability-magic-numbers, + -readability-named-parameter, + -readability-redundant-access-specifiers, + -readability-simplify-boolean-expr, + -readability-uppercase-literal-suffix, + -# only sometimes useful, + -bugprone-narrowing-conversions, + -cert-dcl58-cpp, + -cert-err33-c, + -cert-err58-cpp, + -clang-analyzer-core.CallAndMessage, + -clang-analyzer-cplusplus.NewDelete, + -clang-analyzer-cplusplus.NewDeleteLeaks, + -concurrency-mt-unsafe, + -cppcoreguidelines-init-variables, + -cppcoreguidelines-narrowing-conversions, + -cppcoreguidelines-prefer-member-initializer, + -cppcoreguidelines-pro-type-static-cast-downcast, + -misc-definitions-in-headers, + -modernize-concat-nested-namespaces, + -modernize-loop-convert, + -modernize-raw-string-literal, + -modernize-unary-static-assert, + -performance-no-automatic-move, + -readability-convert-member-functions-to-static, + -readability-else-after-return, + -readability-redundant-declaration, + -# obsoleted, + -cert-dcl21-cpp + +CheckOptions: + - { key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors, value: true } + - { key: modernize-use-override.IgnoreDestructors, value: true } + - { key: performance-for-range-copy.AllowedTypes, value: "QJsonValue" } + - { key: performance-for-range-copy.WarnOnAllAutoCopies, value: true } + - { key: readability-braces-around-statements.ShortStatementLines, value: 3 } + +HeaderFilterRegex: ".+/src/.*\\.h" +WarningsAsErrors: "*" diff --git a/src/app/application.cpp b/src/app/application.cpp index 02a9f8b8a..c50c82a4b 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -225,7 +225,7 @@ namespace Application::Application(int &argc, char **argv) : BaseApplication(argc, argv) , m_shutdownAct(ShutdownDialogAction::Exit) - , m_commandLineArgs(parseCommandLine(this->arguments())) + , m_commandLineArgs(parseCommandLine(Application::arguments())) , m_storeFileLoggerEnabled(FILELOGGER_SETTINGS_KEY(u"Enabled"_qs)) , m_storeFileLoggerBackup(FILELOGGER_SETTINGS_KEY(u"Backup"_qs)) , m_storeFileLoggerDeleteOld(FILELOGGER_SETTINGS_KEY(u"DeleteOld"_qs)) diff --git a/src/app/qtlocalpeer/qtlocalpeer.cpp b/src/app/qtlocalpeer/qtlocalpeer.cpp index 757f6a08f..5e9dbe797 100644 --- a/src/app/qtlocalpeer/qtlocalpeer.cpp +++ b/src/app/qtlocalpeer/qtlocalpeer.cpp @@ -152,10 +152,10 @@ bool QtLocalPeer::sendMessage(const QString &message, const int timeout) break; int ms = 250; #if defined(Q_OS_WIN) - Sleep(DWORD(ms)); + ::Sleep(DWORD(ms)); #else struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; - nanosleep(&ts, NULL); + ::nanosleep(&ts, nullptr); #endif } if (!connOk) diff --git a/src/base/bittorrent/customstorage.cpp b/src/base/bittorrent/customstorage.cpp index 74f4f9e21..2d25e45a3 100644 --- a/src/base/bittorrent/customstorage.cpp +++ b/src/base/bittorrent/customstorage.cpp @@ -171,7 +171,7 @@ void CustomDiskIOThread::async_set_file_priority(lt::storage_index_t storage, lt , std::function)> handler) { m_nativeDiskIO->async_set_file_priority(storage, priorities - , [=, handler = std::move(handler)](const lt::storage_error &error, lt::aux::vector priorities) + , [=, handler = std::move(handler)](const lt::storage_error &error, const lt::aux::vector &priorities) { m_storageData[storage].filePriorities = priorities; handler(error, priorities); diff --git a/src/base/bittorrent/filterparserthread.cpp b/src/base/bittorrent/filterparserthread.cpp index eb599fa6b..cdd8f88b1 100644 --- a/src/base/bittorrent/filterparserthread.cpp +++ b/src/base/bittorrent/filterparserthread.cpp @@ -484,9 +484,9 @@ int FilterParserThread::parseP2BFilterFile() char buf[7]; unsigned char version; if (!stream.readRawData(buf, sizeof(buf)) - || memcmp(buf, "\xFF\xFF\xFF\xFFP2B", 7) + || (memcmp(buf, "\xFF\xFF\xFF\xFFP2B", 7) != 0) || !stream.readRawData(reinterpret_cast(&version), sizeof(version))) - { + { LogMsg(tr("Parsing Error: The filter file is not a valid PeerGuardian P2B file."), Log::CRITICAL); return ruleCount; } diff --git a/src/base/bittorrent/filterparserthread.h b/src/base/bittorrent/filterparserthread.h index 28a209a3a..b118d706e 100644 --- a/src/base/bittorrent/filterparserthread.h +++ b/src/base/bittorrent/filterparserthread.h @@ -55,8 +55,8 @@ protected: void run() override; private: - int findAndNullDelimiter(char *const data, char delimiter, int start, int end, bool reverse = false); - int trim(char *const data, int start, int end); + int findAndNullDelimiter(char *data, char delimiter, int start, int end, bool reverse = false); + int trim(char *data, int start, int end); int parseDATFilterFile(); int parseP2PFilterFile(); int getlineInStream(QDataStream &stream, std::string &name, char delim); diff --git a/src/base/bittorrent/infohash.cpp b/src/base/bittorrent/infohash.cpp index dcef97874..e4ee0f08d 100644 --- a/src/base/bittorrent/infohash.cpp +++ b/src/base/bittorrent/infohash.cpp @@ -93,7 +93,7 @@ BitTorrent::InfoHash::operator WrappedType() const BitTorrent::TorrentID BitTorrent::TorrentID::fromString(const QString &hashString) { - return TorrentID(BaseType::fromString(hashString)); + return {BaseType::fromString(hashString)}; } BitTorrent::TorrentID BitTorrent::TorrentID::fromInfoHash(const BitTorrent::InfoHash &infoHash) @@ -103,7 +103,7 @@ BitTorrent::TorrentID BitTorrent::TorrentID::fromInfoHash(const BitTorrent::Info BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA1Hash(const SHA1Hash &hash) { - return TorrentID(hash); + return {hash}; } BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA256Hash(const SHA256Hash &hash) diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index e0256aa00..663cb29fe 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -400,7 +400,7 @@ namespace BitTorrent virtual bool isTrackerFilteringEnabled() const = 0; virtual void setTrackerFilteringEnabled(bool enabled) = 0; virtual bool isExcludedFileNamesEnabled() const = 0; - virtual void setExcludedFileNamesEnabled(const bool enabled) = 0; + virtual void setExcludedFileNamesEnabled(bool enabled) = 0; virtual QStringList excludedFileNames() const = 0; virtual void setExcludedFileNames(const QStringList &newList) = 0; virtual bool isFilenameExcluded(const QString &fileName) const = 0; diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index 40557e227..091224bd2 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -72,7 +72,6 @@ #endif #include #include -#include #include #include #include @@ -1651,7 +1650,7 @@ lt::settings_pack SessionImpl::loadLTSettings() const settingsPack.set_int(lt::settings_pack::proxy_type, lt::settings_pack::none); if (Preferences::instance()->useProxyForBT()) { - const auto proxyManager = Net::ProxyConfigurationManager::instance(); + const auto *proxyManager = Net::ProxyConfigurationManager::instance(); const Net::ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration(); switch (proxyConfig.type) @@ -4986,7 +4985,7 @@ void SessionImpl::upgradeCategories() const auto legacyCategories = SettingValue(u"BitTorrent/Session/Categories"_qs).get(); for (auto it = legacyCategories.cbegin(); it != legacyCategories.cend(); ++it) { - const QString categoryName = it.key(); + const QString &categoryName = it.key(); CategoryOptions categoryOptions; categoryOptions.savePath = Path(it.value().toString()); m_categories[categoryName] = categoryOptions; @@ -5229,7 +5228,7 @@ void SessionImpl::handleAddTorrentAlerts(const std::vector &alerts) if (a->type() != lt::add_torrent_alert::alert_type) continue; - auto alert = static_cast(a); + const auto *alert = static_cast(a); if (alert->error) { const QString msg = QString::fromStdString(alert->message()); diff --git a/src/base/bittorrent/sessionimpl.h b/src/base/bittorrent/sessionimpl.h index 76dda63a2..449a7f44e 100644 --- a/src/base/bittorrent/sessionimpl.h +++ b/src/base/bittorrent/sessionimpl.h @@ -378,9 +378,9 @@ namespace BitTorrent bool isTrackerFilteringEnabled() const override; void setTrackerFilteringEnabled(bool enabled) override; bool isExcludedFileNamesEnabled() const override; - void setExcludedFileNamesEnabled(const bool enabled) override; + void setExcludedFileNamesEnabled(bool enabled) override; QStringList excludedFileNames() const override; - void setExcludedFileNames(const QStringList &newList) override; + void setExcludedFileNames(const QStringList &excludedFileNames) override; bool isFilenameExcluded(const QString &fileName) const override; QStringList bannedIPs() const override; void setBannedIPs(const QStringList &newList) override; @@ -420,24 +420,24 @@ namespace BitTorrent void handleTorrentNeedSaveResumeData(const TorrentImpl *torrent); void handleTorrentSaveResumeDataRequested(const TorrentImpl *torrent); void handleTorrentSaveResumeDataFailed(const TorrentImpl *torrent); - void handleTorrentShareLimitChanged(TorrentImpl *const torrent); - void handleTorrentNameChanged(TorrentImpl *const torrent); - void handleTorrentSavePathChanged(TorrentImpl *const torrent); - void handleTorrentCategoryChanged(TorrentImpl *const torrent, const QString &oldCategory); - void handleTorrentTagAdded(TorrentImpl *const torrent, const QString &tag); - void handleTorrentTagRemoved(TorrentImpl *const torrent, const QString &tag); - void handleTorrentSavingModeChanged(TorrentImpl *const torrent); - void handleTorrentMetadataReceived(TorrentImpl *const torrent); - void handleTorrentPaused(TorrentImpl *const torrent); - void handleTorrentResumed(TorrentImpl *const torrent); - void handleTorrentChecked(TorrentImpl *const torrent); - void handleTorrentFinished(TorrentImpl *const torrent); - void handleTorrentTrackersAdded(TorrentImpl *const torrent, const QVector &newTrackers); - void handleTorrentTrackersRemoved(TorrentImpl *const torrent, const QStringList &deletedTrackers); - void handleTorrentTrackersChanged(TorrentImpl *const torrent); - void handleTorrentUrlSeedsAdded(TorrentImpl *const torrent, const QVector &newUrlSeeds); - void handleTorrentUrlSeedsRemoved(TorrentImpl *const torrent, const QVector &urlSeeds); - void handleTorrentResumeDataReady(TorrentImpl *const torrent, const LoadTorrentParams &data); + void handleTorrentShareLimitChanged(TorrentImpl *torrent); + void handleTorrentNameChanged(TorrentImpl *torrent); + void handleTorrentSavePathChanged(TorrentImpl *torrent); + void handleTorrentCategoryChanged(TorrentImpl *torrent, const QString &oldCategory); + void handleTorrentTagAdded(TorrentImpl *torrent, const QString &tag); + void handleTorrentTagRemoved(TorrentImpl *torrent, const QString &tag); + void handleTorrentSavingModeChanged(TorrentImpl *torrent); + void handleTorrentMetadataReceived(TorrentImpl *torrent); + void handleTorrentPaused(TorrentImpl *torrent); + void handleTorrentResumed(TorrentImpl *torrent); + void handleTorrentChecked(TorrentImpl *torrent); + void handleTorrentFinished(TorrentImpl *torrent); + void handleTorrentTrackersAdded(TorrentImpl *torrent, const QVector &newTrackers); + void handleTorrentTrackersRemoved(TorrentImpl *torrent, const QStringList &deletedTrackers); + void handleTorrentTrackersChanged(TorrentImpl *torrent); + void handleTorrentUrlSeedsAdded(TorrentImpl *torrent, const QVector &newUrlSeeds); + void handleTorrentUrlSeedsRemoved(TorrentImpl *torrent, const QVector &urlSeeds); + void handleTorrentResumeDataReady(TorrentImpl *torrent, const LoadTorrentParams &data); void handleTorrentInfoHashChanged(TorrentImpl *torrent, const InfoHash &prevInfoHash); bool addMoveTorrentStorageJob(TorrentImpl *torrent, const Path &newPath, MoveStorageMode mode, MoveStorageContext context); diff --git a/src/base/bittorrent/torrent.h b/src/base/bittorrent/torrent.h index bb6f76477..f501dc175 100644 --- a/src/base/bittorrent/torrent.h +++ b/src/base/bittorrent/torrent.h @@ -192,7 +192,6 @@ namespace BitTorrent virtual void setSavePath(const Path &savePath) = 0; virtual Path downloadPath() const = 0; virtual void setDownloadPath(const Path &downloadPath) = 0; - virtual Path actualStorageLocation() const = 0; virtual Path rootPath() const = 0; virtual Path contentPath() const = 0; virtual QString category() const = 0; @@ -212,9 +211,7 @@ namespace BitTorrent virtual qreal ratioLimit() const = 0; virtual int seedingTimeLimit() const = 0; - virtual Path actualFilePath(int index) const = 0; virtual PathList filePaths() const = 0; - virtual QVector filePriorities() const = 0; virtual TorrentInfo info() const = 0; virtual bool isFinished() const = 0; @@ -232,7 +229,6 @@ namespace BitTorrent virtual bool isSequentialDownload() const = 0; virtual bool hasFirstLastPiecePriority() const = 0; virtual TorrentState state() const = 0; - virtual bool hasMetadata() const = 0; virtual bool hasMissingFiles() const = 0; virtual bool hasError() const = 0; virtual int queuePosition() const = 0; @@ -244,7 +240,6 @@ namespace BitTorrent virtual qlonglong activeTime() const = 0; virtual qlonglong finishedTime() const = 0; virtual qlonglong eta() const = 0; - virtual QVector filesProgress() const = 0; virtual int seedsCount() const = 0; virtual int peersCount() const = 0; virtual int leechsCount() const = 0; @@ -277,13 +272,6 @@ namespace BitTorrent virtual int connectionsCount() const = 0; virtual int connectionsLimit() const = 0; virtual qlonglong nextAnnounce() const = 0; - /** - * @brief fraction of file pieces that are available at least from one peer - * - * This is not the same as torrrent availability, it is just a fraction of pieces - * that can be downloaded right now. It varies between 0 to 1. - */ - virtual QVector availableFileFractions() const = 0; virtual void setName(const QString &name) = 0; virtual void setSequentialDownload(bool enable) = 0; @@ -301,7 +289,6 @@ namespace BitTorrent virtual void setDHTDisabled(bool disable) = 0; virtual void setPEXDisabled(bool disable) = 0; virtual void setLSDDisabled(bool disable) = 0; - virtual void flushCache() const = 0; virtual void addTrackers(QVector trackers) = 0; virtual void removeTrackers(const QStringList &trackers) = 0; virtual void replaceTrackers(QVector trackers) = 0; diff --git a/src/base/bittorrent/torrentcreatorthread.h b/src/base/bittorrent/torrentcreatorthread.h index ec09c8a4c..02b33f79b 100644 --- a/src/base/bittorrent/torrentcreatorthread.h +++ b/src/base/bittorrent/torrentcreatorthread.h @@ -74,7 +74,7 @@ namespace BitTorrent void create(const TorrentCreatorParams ¶ms); #ifdef QBT_USES_LIBTORRENT2 - static int calculateTotalPieces(const Path &inputPath, const int pieceSize, const TorrentFormat torrentFormat); + static int calculateTotalPieces(const Path &inputPath, int pieceSize, TorrentFormat torrentFormat); #else static int calculateTotalPieces(const Path &inputPath , const int pieceSize, const bool isAlignmentOptimized, int paddedFileSizeLimit); diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 19575dbdd..4abc49c6a 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -98,7 +98,7 @@ namespace QString firstTrackerMessage; QString firstErrorMessage; #ifdef QBT_USES_LIBTORRENT2 - const auto numEndpoints = static_cast(nativeEntry.endpoints.size() * ((hashes.has_v1() && hashes.has_v2()) ? 2 : 1)); + const auto numEndpoints = static_cast(nativeEntry.endpoints.size()) * ((hashes.has_v1() && hashes.has_v2()) ? 2 : 1); for (const lt::announce_endpoint &endpoint : nativeEntry.endpoints) { for (const auto protocolVersion : {lt::protocol_version::V1, lt::protocol_version::V2}) @@ -338,7 +338,7 @@ TorrentImpl::TorrentImpl(SessionImpl *session, lt::session *nativeSession // == END UPGRADE CODE == } -TorrentImpl::~TorrentImpl() {} +TorrentImpl::~TorrentImpl() = default; bool TorrentImpl::isValid() const { @@ -1632,7 +1632,7 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi { const auto nativeIndex = nativeIndexes.at(i); - const Path actualFilePath = fileNames.at(i); + const Path &actualFilePath = fileNames.at(i); p.renamed_files[nativeIndex] = actualFilePath.toString().toStdString(); const Path filePath = actualFilePath.removedExtension(QB_EXT); diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index e2b7533df..01080e28b 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -66,12 +66,6 @@ TorrentInfo::TorrentInfo(const lt::torrent_info &nativeInfo) } } -TorrentInfo::TorrentInfo(const TorrentInfo &other) - : m_nativeInfo {other.m_nativeInfo} - , m_nativeIndexes {other.m_nativeIndexes} -{ -} - TorrentInfo &TorrentInfo::operator=(const TorrentInfo &other) { if (this != &other) diff --git a/src/base/bittorrent/torrentinfo.h b/src/base/bittorrent/torrentinfo.h index 71a778ad5..e9b467939 100644 --- a/src/base/bittorrent/torrentinfo.h +++ b/src/base/bittorrent/torrentinfo.h @@ -54,7 +54,7 @@ namespace BitTorrent public: TorrentInfo() = default; - TorrentInfo(const TorrentInfo &other); + TorrentInfo(const TorrentInfo &other) = default; explicit TorrentInfo(const lt::torrent_info &nativeInfo); diff --git a/src/base/digest32.h b/src/base/digest32.h index c4e8f26c5..1be904a2f 100644 --- a/src/base/digest32.h +++ b/src/base/digest32.h @@ -45,7 +45,7 @@ public: Digest32() = default; Digest32(const Digest32 &other) = default; - Digest32(Digest32 &&other) = default; + Digest32(Digest32 &&other) noexcept = default; Digest32(const UnderlyingType &nativeDigest) : m_dataPtr {new Data(nativeDigest)} @@ -63,7 +63,7 @@ public: } Digest32 &operator=(const Digest32 &other) = default; - Digest32 &operator=(Digest32 &&other) = default; + Digest32 &operator=(Digest32 &&other) noexcept = default; operator UnderlyingType() const { diff --git a/src/base/global.h b/src/base/global.h index fdb251b94..255797250 100644 --- a/src/base/global.h +++ b/src/base/global.h @@ -42,7 +42,7 @@ constexpr typename std::add_const_t &asConst(T &t) noexcept { return t; } // Forward rvalue as const template -constexpr typename std::add_const_t asConst(T &&t) noexcept { return std::move(t); } +constexpr typename std::add_const_t asConst(T &&t) noexcept { return std::forward(t); } // Prevent const rvalue arguments template diff --git a/src/base/http/irequesthandler.h b/src/base/http/irequesthandler.h index 699ce4feb..54cb7d881 100644 --- a/src/base/http/irequesthandler.h +++ b/src/base/http/irequesthandler.h @@ -37,7 +37,7 @@ namespace Http class IRequestHandler { public: - virtual ~IRequestHandler() {} + virtual ~IRequestHandler() = default; virtual Response processRequest(const Request &request, const Environment &env) = 0; }; } diff --git a/src/base/http/requestparser.cpp b/src/base/http/requestparser.cpp index b72d994cf..a64215251 100644 --- a/src/base/http/requestparser.cpp +++ b/src/base/http/requestparser.cpp @@ -75,10 +75,6 @@ namespace } } -RequestParser::RequestParser() -{ -} - RequestParser::ParseResult RequestParser::parse(const QByteArray &data) { // Warning! Header names are converted to lowercase diff --git a/src/base/http/requestparser.h b/src/base/http/requestparser.h index b9eb7cdfa..56ecc51e8 100644 --- a/src/base/http/requestparser.h +++ b/src/base/http/requestparser.h @@ -57,7 +57,7 @@ namespace Http static const long MAX_CONTENT_SIZE = 64 * 1024 * 1024; // 64 MB private: - RequestParser(); + RequestParser() = default; ParseResult doParse(const QByteArray &data); bool parseStartLines(QStringView data); diff --git a/src/base/iconprovider.cpp b/src/base/iconprovider.cpp index 112b4352d..f2d285f1c 100644 --- a/src/base/iconprovider.cpp +++ b/src/base/iconprovider.cpp @@ -36,8 +36,6 @@ IconProvider::IconProvider(QObject *parent) { } -IconProvider::~IconProvider() {} - void IconProvider::initInstance() { if (!m_instance) diff --git a/src/base/iconprovider.h b/src/base/iconprovider.h index 33b44bf2d..35ba113ed 100644 --- a/src/base/iconprovider.h +++ b/src/base/iconprovider.h @@ -48,7 +48,7 @@ public: protected: explicit IconProvider(QObject *parent = nullptr); - ~IconProvider(); + ~IconProvider() = default; static IconProvider *m_instance; }; diff --git a/src/base/net/downloadhandlerimpl.cpp b/src/base/net/downloadhandlerimpl.cpp index e08a394a1..58648714b 100644 --- a/src/base/net/downloadhandlerimpl.cpp +++ b/src/base/net/downloadhandlerimpl.cpp @@ -208,7 +208,7 @@ void Net::DownloadHandlerImpl::handleRedirection(const QUrl &newUrl) return; } - auto redirected = static_cast( + auto *redirected = static_cast( m_manager->download(DownloadRequest(m_downloadRequest).url(newUrlString), useProxy())); redirected->m_redirectionCount = m_redirectionCount + 1; connect(redirected, &DownloadHandlerImpl::finished, this, [this](const DownloadResult &result) diff --git a/src/base/net/downloadmanager.cpp b/src/base/net/downloadmanager.cpp index 416ec19b9..2b08d6761 100644 --- a/src/base/net/downloadmanager.cpp +++ b/src/base/net/downloadmanager.cpp @@ -163,7 +163,7 @@ Net::DownloadHandler *Net::DownloadManager::download(const DownloadRequest &down const ServiceID id = ServiceID::fromURL(downloadRequest.url()); const bool isSequentialService = m_sequentialServices.contains(id); - auto downloadHandler = new DownloadHandlerImpl(this, downloadRequest, useProxy); + auto *downloadHandler = new DownloadHandlerImpl(this, downloadRequest, useProxy); connect(downloadHandler, &DownloadHandler::finished, downloadHandler, &QObject::deleteLater); connect(downloadHandler, &QObject::destroyed, this, [this, id, downloadHandler]() { @@ -274,7 +274,7 @@ void Net::DownloadManager::handleDownloadFinished(DownloadHandlerImpl *finishedH return; } - auto handler = waitingJobsIter.value().dequeue(); + auto *handler = waitingJobsIter.value().dequeue(); qDebug("Downloading %s...", qUtf8Printable(handler->url())); processRequest(handler); handler->disconnect(this); diff --git a/src/base/net/smtp.cpp b/src/base/net/smtp.cpp index d34ef9edc..f0cffb594 100644 --- a/src/base/net/smtp.cpp +++ b/src/base/net/smtp.cpp @@ -162,7 +162,7 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje // Connect to SMTP server const QStringList serverEndpoint = pref->getMailNotificationSMTP().split(u':'); - const QString serverAddress = serverEndpoint[0]; + const QString &serverAddress = serverEndpoint[0]; const std::optional serverPort = Utils::String::parseInt(serverEndpoint.value(1)); #ifndef QT_NO_OPENSSL diff --git a/src/base/preferences.h b/src/base/preferences.h index 57b6e0499..f7c719966 100644 --- a/src/base/preferences.h +++ b/src/base/preferences.h @@ -253,7 +253,7 @@ public: void setUILocked(bool locked); bool isAutoRunOnTorrentAddedEnabled() const; - void setAutoRunOnTorrentAddedEnabled(const bool enabled); + void setAutoRunOnTorrentAddedEnabled(bool enabled); QString getAutoRunOnTorrentAddedProgram() const; void setAutoRunOnTorrentAddedProgram(const QString &program); bool isAutoRunOnTorrentFinishedEnabled() const; diff --git a/src/base/profile_p.cpp b/src/base/profile_p.cpp index 57a56beb0..e27a232a4 100644 --- a/src/base/profile_p.cpp +++ b/src/base/profile_p.cpp @@ -116,9 +116,9 @@ Path Private::DefaultProfile::downloadLocation() const std::unique_ptr Private::DefaultProfile::applicationSettings(const QString &name) const { #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) - return std::unique_ptr(new QSettings(QSettings::IniFormat, QSettings::UserScope, profileName(), name)); + return std::make_unique(QSettings::IniFormat, QSettings::UserScope, profileName(), name); #else - return std::unique_ptr(new QSettings(profileName(), name)); + return std::make_unique(profileName(), name); #endif } diff --git a/src/base/rss/rss_autodownloader.cpp b/src/base/rss/rss_autodownloader.cpp index 1c74e169c..6aab0504a 100644 --- a/src/base/rss/rss_autodownloader.cpp +++ b/src/base/rss/rss_autodownloader.cpp @@ -382,13 +382,13 @@ void AutoDownloader::handleFeedURLChanged(Feed *feed, const QString &oldURL) } } - for (QSharedPointer job : asConst(m_processingQueue)) + for (const QSharedPointer &job : asConst(m_processingQueue)) { if (job->feedURL == oldURL) job->feedURL = feed->url(); } - for (QSharedPointer job : asConst(m_waitingJobs)) + for (const QSharedPointer &job : asConst(m_waitingJobs)) { if (job->feedURL == oldURL) job->feedURL = feed->url(); diff --git a/src/base/rss/rss_autodownloadrule.cpp b/src/base/rss/rss_autodownloadrule.cpp index b7b7cefe4..e6db0aede 100644 --- a/src/base/rss/rss_autodownloadrule.cpp +++ b/src/base/rss/rss_autodownloadrule.cpp @@ -208,12 +208,9 @@ AutoDownloadRule::AutoDownloadRule(const QString &name) setName(name); } -AutoDownloadRule::AutoDownloadRule(const AutoDownloadRule &other) - : m_dataPtr(other.m_dataPtr) -{ -} +AutoDownloadRule::AutoDownloadRule(const AutoDownloadRule &other) = default; -AutoDownloadRule::~AutoDownloadRule() {} +AutoDownloadRule::~AutoDownloadRule() = default; QRegularExpression AutoDownloadRule::cachedRegex(const QString &expression, const bool isRegex) const { diff --git a/src/base/rss/rss_autodownloadrule.h b/src/base/rss/rss_autodownloadrule.h index afe6131b8..a37d14f91 100644 --- a/src/base/rss/rss_autodownloadrule.h +++ b/src/base/rss/rss_autodownloadrule.h @@ -49,7 +49,7 @@ namespace RSS class AutoDownloadRule { public: - explicit AutoDownloadRule(const QString &name = u""_qs); + explicit AutoDownloadRule(const QString &name = {}); AutoDownloadRule(const AutoDownloadRule &other); ~AutoDownloadRule(); @@ -96,7 +96,7 @@ namespace RSS friend bool operator==(const AutoDownloadRule &left, const AutoDownloadRule &right); QJsonObject toJsonObject() const; - static AutoDownloadRule fromJsonObject(const QJsonObject &jsonObj, const QString &name = u""_qs); + static AutoDownloadRule fromJsonObject(const QJsonObject &jsonObj, const QString &name = {}); QVariantHash toLegacyDict() const; static AutoDownloadRule fromLegacyDict(const QVariantHash &dict); diff --git a/src/base/rss/rss_feed.cpp b/src/base/rss/rss_feed.cpp index 3de73fe3c..a0b114360 100644 --- a/src/base/rss/rss_feed.cpp +++ b/src/base/rss/rss_feed.cpp @@ -345,7 +345,7 @@ bool Feed::addArticle(const QVariantHash &articleData) void Feed::removeOldestArticle() { - auto oldestArticle = m_articlesByDate.last(); + auto *oldestArticle = m_articlesByDate.last(); emit articleAboutToBeRemoved(oldestArticle); m_articles.remove(oldestArticle->guid()); diff --git a/src/base/rss/rss_folder.cpp b/src/base/rss/rss_folder.cpp index 01a8ac70a..252f4b94c 100644 --- a/src/base/rss/rss_folder.cpp +++ b/src/base/rss/rss_folder.cpp @@ -49,7 +49,7 @@ Folder::~Folder() { emit aboutToBeDestroyed(this); - for (auto item : asConst(items())) + for (auto *item : asConst(items())) delete item; } @@ -127,7 +127,7 @@ void Folder::addItem(Item *item) connect(item, &Item::articleAboutToBeRemoved, this, &Item::articleAboutToBeRemoved); connect(item, &Item::unreadCountChanged, this, &Folder::handleItemUnreadCountChanged); - for (auto article : asConst(item->articles())) + for (auto *article : asConst(item->articles())) emit newArticle(article); if (item->unreadCount() > 0) @@ -138,7 +138,7 @@ void Folder::removeItem(Item *item) { Q_ASSERT(m_items.contains(item)); - for (auto article : asConst(item->articles())) + for (auto *article : asConst(item->articles())) emit articleAboutToBeRemoved(article); item->disconnect(this); diff --git a/src/base/rss/rss_folder.h b/src/base/rss/rss_folder.h index 147267b7f..3441e3a02 100644 --- a/src/base/rss/rss_folder.h +++ b/src/base/rss/rss_folder.h @@ -46,7 +46,7 @@ namespace RSS friend class Session; - explicit Folder(const QString &path = u""_qs); + explicit Folder(const QString &path = {}); ~Folder() override; public: diff --git a/src/base/rss/rss_item.cpp b/src/base/rss/rss_item.cpp index 05fe8677e..0d6da7a9d 100644 --- a/src/base/rss/rss_item.cpp +++ b/src/base/rss/rss_item.cpp @@ -45,8 +45,6 @@ Item::Item(const QString &path) { } -Item::~Item() {} - void Item::setPath(const QString &path) { if (path != m_path) diff --git a/src/base/rss/rss_item.h b/src/base/rss/rss_item.h index f16d22751..df7c6ff7b 100644 --- a/src/base/rss/rss_item.h +++ b/src/base/rss/rss_item.h @@ -76,7 +76,7 @@ namespace RSS protected: explicit Item(const QString &path); - ~Item() override; + ~Item() override = default; virtual void cleanup() = 0; diff --git a/src/base/rss/rss_parser.cpp b/src/base/rss/rss_parser.cpp index a312ba314..e07e7811d 100644 --- a/src/base/rss/rss_parser.cpp +++ b/src/base/rss/rss_parser.cpp @@ -541,7 +541,7 @@ namespace const int PARSINGRESULT_TYPEID = qRegisterMetaType(); -RSS::Private::Parser::Parser(const QString lastBuildDate) +RSS::Private::Parser::Parser(const QString &lastBuildDate) { m_result.lastBuildDate = lastBuildDate; } diff --git a/src/base/rss/rss_parser.h b/src/base/rss/rss_parser.h index d5fc4f938..7abfeeb2e 100644 --- a/src/base/rss/rss_parser.h +++ b/src/base/rss/rss_parser.h @@ -53,7 +53,7 @@ namespace RSS::Private Q_DISABLE_COPY_MOVE(Parser) public: - explicit Parser(QString lastBuildDate); + explicit Parser(const QString &lastBuildDate); void parse(const QByteArray &feedData); signals: diff --git a/src/base/rss/rss_session.cpp b/src/base/rss/rss_session.cpp index fc3990e44..ef01e5b98 100644 --- a/src/base/rss/rss_session.cpp +++ b/src/base/rss/rss_session.cpp @@ -100,7 +100,7 @@ Session::Session() // Remove legacy/corrupted settings // (at least on Windows, QSettings is case-insensitive and it can get // confused when asked about settings that differ only in their case) - auto settingsStorage = SettingsStorage::instance(); + auto *settingsStorage = SettingsStorage::instance(); settingsStorage->removeValue(u"Rss/streamList"_qs); settingsStorage->removeValue(u"Rss/streamAlias"_qs); settingsStorage->removeValue(u"Rss/open_folders"_qs); @@ -140,7 +140,7 @@ nonstd::expected Session::addFolder(const QString &path) if (!result) return result.get_unexpected(); - const auto destFolder = result.value(); + auto *destFolder = result.value(); addItem(new Folder(path), destFolder); store(); return {}; @@ -155,7 +155,7 @@ nonstd::expected Session::addFeed(const QString &url, const QStri if (!result) return result.get_unexpected(); - const auto destFolder = result.value(); + auto *destFolder = result.value(); auto *feed = new Feed(generateUID(), url, path, this); addItem(feed, destFolder); store(); @@ -198,7 +198,7 @@ nonstd::expected Session::moveItem(const QString &itemPath, const if (itemPath.isEmpty()) return nonstd::make_unexpected(tr("Cannot move root folder.")); - auto item = m_itemsByPath.value(itemPath); + auto *item = m_itemsByPath.value(itemPath); if (!item) return nonstd::make_unexpected(tr("Item doesn't exist: %1.").arg(itemPath)); @@ -214,11 +214,11 @@ nonstd::expected Session::moveItem(Item *item, const QString &des if (!result) return result.get_unexpected(); - const auto destFolder = result.value(); + auto *destFolder = result.value(); if (static_cast(destFolder) == item) return nonstd::make_unexpected(tr("Couldn't move folder into itself.")); - auto srcFolder = static_cast(m_itemsByPath.value(Item::parentPath(item->path()))); + auto *srcFolder = static_cast(m_itemsByPath.value(Item::parentPath(item->path()))); if (srcFolder != destFolder) { srcFolder->removeItem(item); @@ -242,7 +242,7 @@ nonstd::expected Session::removeItem(const QString &itemPath) emit itemAboutToBeRemoved(item); item->cleanup(); - auto folder = static_cast(m_itemsByPath.value(Item::parentPath(item->path()))); + auto *folder = static_cast(m_itemsByPath.value(Item::parentPath(item->path()))); folder->removeItem(item); delete item; store(); @@ -410,7 +410,7 @@ nonstd::expected Session::prepareItemDest(const QString &path return nonstd::make_unexpected(tr("RSS item with given path already exists: %1.").arg(path)); const QString destFolderPath = Item::parentPath(path); - const auto destFolder = qobject_cast(m_itemsByPath.value(destFolderPath)); + auto *destFolder = qobject_cast(m_itemsByPath.value(destFolderPath)); if (!destFolder) return nonstd::make_unexpected(tr("Parent folder doesn't exist: %1.").arg(destFolderPath)); @@ -419,21 +419,21 @@ nonstd::expected Session::prepareItemDest(const QString &path Folder *Session::addSubfolder(const QString &name, Folder *parentFolder) { - auto folder = new Folder(Item::joinPath(parentFolder->path(), name)); + auto *folder = new Folder(Item::joinPath(parentFolder->path(), name)); addItem(folder, parentFolder); return folder; } Feed *Session::addFeedToFolder(const QUuid &uid, const QString &url, const QString &name, Folder *parentFolder) { - auto feed = new Feed(uid, url, Item::joinPath(parentFolder->path(), name), this); + auto *feed = new Feed(uid, url, Item::joinPath(parentFolder->path(), name), this); addItem(feed, parentFolder); return feed; } void Session::addItem(Item *item, Folder *destFolder) { - if (auto feed = qobject_cast(item)) + if (auto *feed = qobject_cast(item)) { connect(feed, &Feed::titleChanged, this, &Session::handleFeedTitleChanged); connect(feed, &Feed::iconLoaded, this, &Session::feedIconLoaded); @@ -530,7 +530,7 @@ QThread *Session::workingThread() const void Session::handleItemAboutToBeDestroyed(Item *item) { m_itemsByPath.remove(item->path()); - auto feed = qobject_cast(item); + auto *feed = qobject_cast(item); if (feed) { m_feedsByUID.remove(feed->uid()); diff --git a/src/base/search/searchdownloadhandler.cpp b/src/base/search/searchdownloadhandler.cpp index dbbee9bbd..75b737f71 100644 --- a/src/base/search/searchdownloadhandler.cpp +++ b/src/base/search/searchdownloadhandler.cpp @@ -46,7 +46,7 @@ SearchDownloadHandler::SearchDownloadHandler(const QString &siteUrl, const QStri , this, &SearchDownloadHandler::downloadProcessFinished); const QStringList params { - (m_manager->engineLocation() / Path(u"nova2dl.py"_qs)).toString(), + (SearchPluginManager::engineLocation() / Path(u"nova2dl.py"_qs)).toString(), siteUrl, url }; diff --git a/src/base/search/searchhandler.cpp b/src/base/search/searchhandler.cpp index 691d0b79e..a3fde897b 100644 --- a/src/base/search/searchhandler.cpp +++ b/src/base/search/searchhandler.cpp @@ -73,7 +73,7 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co const QStringList params { - (m_manager->engineLocation() / Path(u"nova2.py"_qs)).toString(), + (SearchPluginManager::engineLocation() / Path(u"nova2.py"_qs)).toString(), m_usedPlugins.join(u','), m_category }; diff --git a/src/base/search/searchpluginmanager.cpp b/src/base/search/searchpluginmanager.cpp index 097c34045..b697ef05b 100644 --- a/src/base/search/searchpluginmanager.cpp +++ b/src/base/search/searchpluginmanager.cpp @@ -609,7 +609,7 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info) } } -bool SearchPluginManager::isUpdateNeeded(const QString &pluginName, const PluginVersion newVersion) const +bool SearchPluginManager::isUpdateNeeded(const QString &pluginName, const PluginVersion &newVersion) const { const PluginInfo *plugin = pluginInfo(pluginName); if (!plugin) return true; diff --git a/src/base/search/searchpluginmanager.h b/src/base/search/searchpluginmanager.h index e87e9d8a4..0425f9439 100644 --- a/src/base/search/searchpluginmanager.h +++ b/src/base/search/searchpluginmanager.h @@ -80,7 +80,7 @@ public: void updatePlugin(const QString &name); void installPlugin(const QString &source); bool uninstallPlugin(const QString &name); - static void updateIconPath(PluginInfo *const plugin); + static void updateIconPath(PluginInfo *plugin); void checkForUpdates(); SearchHandler *startSearch(const QString &pattern, const QString &category, const QStringList &usedPlugins); @@ -109,7 +109,7 @@ private: void updateNova(); void parseVersionInfo(const QByteArray &info); void installPlugin_impl(const QString &name, const Path &path); - bool isUpdateNeeded(const QString &pluginName, PluginVersion newVersion) const; + bool isUpdateNeeded(const QString &pluginName, const PluginVersion &newVersion) const; void versionInfoDownloadFinished(const Net::DownloadResult &result); void pluginDownloadFinished(const Net::DownloadResult &result); diff --git a/src/base/torrentfileguard.cpp b/src/base/torrentfileguard.cpp index 9c398b365..125d3aae6 100644 --- a/src/base/torrentfileguard.cpp +++ b/src/base/torrentfileguard.cpp @@ -59,7 +59,6 @@ FileGuard::~FileGuard() TorrentFileGuard::TorrentFileGuard(const Path &path, const TorrentFileGuard::AutoDeleteMode mode) : FileGuard {mode != Never ? path : Path()} , m_mode {mode} - , m_wasAdded {false} { } diff --git a/src/base/torrentfilter.cpp b/src/base/torrentfilter.cpp index 9eb2a8833..1c81da452 100644 --- a/src/base/torrentfilter.cpp +++ b/src/base/torrentfilter.cpp @@ -62,8 +62,7 @@ TorrentFilter::TorrentFilter(const Type type, const std::optional TorrentFilter::TorrentFilter(const QString &filter, const std::optional &idSet , const std::optional &category, const std::optional &tag) - : m_type(All) - , m_category(category) + : m_category(category) , m_tag(tag) , m_idSet(idSet) { diff --git a/src/base/utils/bytearray.h b/src/base/utils/bytearray.h index c3d959b4c..8d00f1671 100644 --- a/src/base/utils/bytearray.h +++ b/src/base/utils/bytearray.h @@ -36,7 +36,7 @@ class QByteArray; namespace Utils::ByteArray { // Mimic QStringView(in).split(sep, behavior) - QVector splitToViews(const QByteArray &in, const QByteArray &sep, const Qt::SplitBehavior behavior = Qt::KeepEmptyParts); + QVector splitToViews(const QByteArray &in, const QByteArray &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts); // Mimic QByteArray::mid(pos, len) but instead of returning a full-copy, // we only return a partial view diff --git a/src/base/utils/io.h b/src/base/utils/io.h index 06a2d71e1..767381ebe 100644 --- a/src/base/utils/io.h +++ b/src/base/utils/io.h @@ -53,7 +53,7 @@ namespace Utils::IO using pointer = void; using reference = void; - explicit FileDeviceOutputIterator(QFileDevice &device, const int bufferSize = (4 * 1024)); + explicit FileDeviceOutputIterator(QFileDevice &device, int bufferSize = (4 * 1024)); FileDeviceOutputIterator(const FileDeviceOutputIterator &other) = default; ~FileDeviceOutputIterator(); diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index e9d6ca2ae..7e2ac691d 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -831,7 +831,7 @@ void AdvancedSettings::loadAdvancedSettings() template void AdvancedSettings::addRow(const int row, const QString &text, T *widget) { - auto label = new QLabel(text); + auto *label = new QLabel(text); label->setOpenExternalLinks(true); setCellWidget(row, PROPERTY, label); diff --git a/src/gui/desktopintegration.cpp b/src/gui/desktopintegration.cpp index 825d8cb99..ad5c7cae9 100644 --- a/src/gui/desktopintegration.cpp +++ b/src/gui/desktopintegration.cpp @@ -100,8 +100,7 @@ DesktopIntegration::DesktopIntegration(QObject *parent) DesktopIntegration::~DesktopIntegration() { - if (m_menu) - delete m_menu; + delete m_menu; } bool DesktopIntegration::isActive() const diff --git a/src/gui/desktopintegration.h b/src/gui/desktopintegration.h index 3d55262e7..62dbbc4a9 100644 --- a/src/gui/desktopintegration.h +++ b/src/gui/desktopintegration.h @@ -63,7 +63,7 @@ public: int notificationTimeout() const; #ifdef QBT_USES_DBUS - void setNotificationTimeout(const int value); + void setNotificationTimeout(int value); #endif void showNotification(const QString &title, const QString &msg) const; diff --git a/src/gui/fspathedit_p.cpp b/src/gui/fspathedit_p.cpp index c0488fff1..db4498925 100644 --- a/src/gui/fspathedit_p.cpp +++ b/src/gui/fspathedit_p.cpp @@ -152,8 +152,6 @@ Private::FileLineEdit::FileLineEdit(QWidget *parent) : QLineEdit {parent} , m_completerModel {new QFileSystemModel(this)} , m_completer {new QCompleter(this)} - , m_browseAction {nullptr} - , m_warningAction {nullptr} { m_iconProvider.setOptions(QFileIconProvider::DontUseCustomDirectoryIcons); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index befe5cd00..126216f7b 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -942,7 +942,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(const BitTorrent::Torre void MainWindow::on_actionSetGlobalSpeedLimits_triggered() { - auto dialog = new SpeedLimitDialog {this}; + auto *dialog = new SpeedLimitDialog {this}; dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->open(); } diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index d94f65486..fc975c4fc 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -334,7 +334,7 @@ void OptionsDialog::loadBehaviorTabOptions() }); connect(m_ui->buttonCustomizeUITheme, &QPushButton::clicked, this, [this] { - auto dialog = new UIThemeDialog(this); + auto *dialog = new UIThemeDialog(this); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->open(); }); @@ -698,7 +698,7 @@ void OptionsDialog::saveDownloadsTabOptions() const session->setTorrentExportDirectory(getTorrentExportDir()); session->setFinishedTorrentExportDirectory(getFinishedTorrentExportDir()); - auto watchedFoldersModel = static_cast(m_ui->scanFoldersView->model()); + auto *watchedFoldersModel = static_cast(m_ui->scanFoldersView->model()); watchedFoldersModel->apply(); session->setExcludedFileNamesEnabled(m_ui->groupExcludedFileNames->isChecked()); @@ -882,7 +882,7 @@ void OptionsDialog::saveConnectionTabOptions() const session->setI2PPort(m_ui->spinI2PPort->value()); session->setI2PMixedMode(m_ui->checkI2PMixed->isChecked()); - auto proxyConfigManager = Net::ProxyConfigurationManager::instance(); + auto *proxyConfigManager = Net::ProxyConfigurationManager::instance(); Net::ProxyConfiguration proxyConf; proxyConf.type = getProxyType(); proxyConf.ip = getProxyIp(); @@ -1668,13 +1668,13 @@ void OptionsDialog::on_addWatchedFolderButton_clicked() if (dir.isEmpty()) return; - auto dialog = new WatchedFolderOptionsDialog({}, this); + auto *dialog = new WatchedFolderOptionsDialog({}, this); dialog->setAttribute(Qt::WA_DeleteOnClose); connect(dialog, &QDialog::accepted, this, [this, dialog, dir, pref]() { try { - auto watchedFoldersModel = static_cast(m_ui->scanFoldersView->model()); + auto *watchedFoldersModel = static_cast(m_ui->scanFoldersView->model()); watchedFoldersModel->addFolder(dir, dialog->watchedFolderOptions()); pref->setScanDirsLastPath(dir); @@ -1722,8 +1722,8 @@ void OptionsDialog::editWatchedFolderOptions(const QModelIndex &index) if (!index.isValid()) return; - auto watchedFoldersModel = static_cast(m_ui->scanFoldersView->model()); - auto dialog = new WatchedFolderOptionsDialog(watchedFoldersModel->folderOptions(index.row()), this); + auto *watchedFoldersModel = static_cast(m_ui->scanFoldersView->model()); + auto *dialog = new WatchedFolderOptionsDialog(watchedFoldersModel->folderOptions(index.row()), this); dialog->setAttribute(Qt::WA_DeleteOnClose); connect(dialog, &QDialog::accepted, this, [this, dialog, index, watchedFoldersModel]() { @@ -1880,7 +1880,7 @@ bool OptionsDialog::schedTimesOk() void OptionsDialog::on_banListButton_clicked() { - auto dialog = new BanListOptionsDialog(this); + auto *dialog = new BanListOptionsDialog(this); dialog->setAttribute(Qt::WA_DeleteOnClose); connect(dialog, &QDialog::accepted, this, &OptionsDialog::enableApplyButton); dialog->open(); @@ -1888,7 +1888,7 @@ void OptionsDialog::on_banListButton_clicked() void OptionsDialog::on_IPSubnetWhitelistButton_clicked() { - auto dialog = new IPSubnetWhitelistOptionsDialog(this); + auto *dialog = new IPSubnetWhitelistOptionsDialog(this); dialog->setAttribute(Qt::WA_DeleteOnClose); connect(dialog, &QDialog::accepted, this, &OptionsDialog::enableApplyButton); dialog->open(); diff --git a/src/gui/powermanagement/powermanagement.cpp b/src/gui/powermanagement/powermanagement.cpp index 174548cf8..dfdfb6e54 100644 --- a/src/gui/powermanagement/powermanagement.cpp +++ b/src/gui/powermanagement/powermanagement.cpp @@ -50,10 +50,6 @@ PowerManagement::PowerManagement(QObject *parent) #endif } -PowerManagement::~PowerManagement() -{ -} - void PowerManagement::setActivityState(const bool busy) { if (busy) diff --git a/src/gui/powermanagement/powermanagement.h b/src/gui/powermanagement/powermanagement.h index f83192293..d8019d79c 100644 --- a/src/gui/powermanagement/powermanagement.h +++ b/src/gui/powermanagement/powermanagement.h @@ -47,7 +47,7 @@ class PowerManagement : public QObject public: PowerManagement(QObject *parent = nullptr); - virtual ~PowerManagement(); + virtual ~PowerManagement() = default; void setActivityState(bool busy); diff --git a/src/gui/powermanagement/powermanagement_x11.cpp b/src/gui/powermanagement/powermanagement_x11.cpp index c3027d8b4..18f244ea5 100644 --- a/src/gui/powermanagement/powermanagement_x11.cpp +++ b/src/gui/powermanagement/powermanagement_x11.cpp @@ -51,10 +51,6 @@ PowerManagementInhibitor::PowerManagementInhibitor(QObject *parent) m_useGSM = false; } -PowerManagementInhibitor::~PowerManagementInhibitor() -{ -} - void PowerManagementInhibitor::requestIdle() { m_intendedState = Idle; diff --git a/src/gui/powermanagement/powermanagement_x11.h b/src/gui/powermanagement/powermanagement_x11.h index 34defe1b8..5b9b6a88d 100644 --- a/src/gui/powermanagement/powermanagement_x11.h +++ b/src/gui/powermanagement/powermanagement_x11.h @@ -39,7 +39,7 @@ class PowerManagementInhibitor : public QObject public: PowerManagementInhibitor(QObject *parent = nullptr); - virtual ~PowerManagementInhibitor(); + virtual ~PowerManagementInhibitor() = default; void requestIdle(); void requestBusy(); diff --git a/src/gui/previewselectdialog.cpp b/src/gui/previewselectdialog.cpp index b7c05f16e..f2f41d2d3 100644 --- a/src/gui/previewselectdialog.cpp +++ b/src/gui/previewselectdialog.cpp @@ -145,7 +145,7 @@ void PreviewSelectDialog::previewButtonClicked() void PreviewSelectDialog::displayColumnHeaderMenu() { - auto menu = new QMenu(this); + auto *menu = new QMenu(this); menu->setAttribute(Qt::WA_DeleteOnClose); menu->setToolTipsVisible(true); diff --git a/src/gui/properties/downloadedpiecesbar.h b/src/gui/properties/downloadedpiecesbar.h index 29c33a2f8..d98a114b2 100644 --- a/src/gui/properties/downloadedpiecesbar.h +++ b/src/gui/properties/downloadedpiecesbar.h @@ -52,7 +52,7 @@ public: private: // scale bitfield vector to float vector QVector bitfieldToFloatVector(const QBitArray &vecin, int reqSize); - virtual bool updateImage(QImage &image) override; + bool updateImage(QImage &image) override; QString simpleToolTipText() const override; // incomplete piece color diff --git a/src/gui/properties/piecesbar.h b/src/gui/properties/piecesbar.h index 1ee7299d4..1e87ba364 100644 --- a/src/gui/properties/piecesbar.h +++ b/src/gui/properties/piecesbar.h @@ -55,7 +55,7 @@ public: virtual void clear(); // QObject interface - virtual bool event(QEvent *e) override; + bool event(QEvent *e) override; protected: // QWidget interface diff --git a/src/gui/properties/propertieswidget.h b/src/gui/properties/propertieswidget.h index d28e74e70..a8f0f9f95 100644 --- a/src/gui/properties/propertieswidget.h +++ b/src/gui/properties/propertieswidget.h @@ -76,16 +76,16 @@ public: public slots: void setVisibility(bool visible); - void loadTorrentInfos(BitTorrent::Torrent *const torrent); + void loadTorrentInfos(BitTorrent::Torrent *torrent); void loadDynamicData(); void clear(); void readSettings(); void saveSettings(); void reloadPreferences(); - void loadTrackers(BitTorrent::Torrent *const torrent); + void loadTrackers(BitTorrent::Torrent *torrent); protected slots: - void updateTorrentInfos(BitTorrent::Torrent *const torrent); + void updateTorrentInfos(BitTorrent::Torrent *torrent); void loadUrlSeeds(); void askWebSeed(); void deleteSelectedUrlSeeds(); @@ -97,7 +97,7 @@ protected slots: private slots: void configure(); - void updateSavePath(BitTorrent::Torrent *const torrent); + void updateSavePath(BitTorrent::Torrent *torrent); private: QPushButton *getButtonFromIndex(int index); diff --git a/src/gui/properties/trackerlistwidget.cpp b/src/gui/properties/trackerlistwidget.cpp index 963df819d..cffb6d244 100644 --- a/src/gui/properties/trackerlistwidget.cpp +++ b/src/gui/properties/trackerlistwidget.cpp @@ -58,8 +58,7 @@ #define NB_STICKY_ITEM 3 TrackerListWidget::TrackerListWidget(PropertiesWidget *properties) - : QTreeWidget() - , m_properties(properties) + : m_properties(properties) { // Set header // Must be set before calling loadSettings() otherwise the header is reset on restart @@ -438,7 +437,7 @@ void TrackerListWidget::openAddTrackersDialog() if (!torrent) return; - const auto dialog = new TrackersAdditionDialog(this, torrent); + auto *dialog = new TrackersAdditionDialog(this, torrent); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->open(); } diff --git a/src/gui/properties/trackersadditiondialog.h b/src/gui/properties/trackersadditiondialog.h index b9313b6fd..0dc658cff 100644 --- a/src/gui/properties/trackersadditiondialog.h +++ b/src/gui/properties/trackersadditiondialog.h @@ -54,7 +54,7 @@ class TrackersAdditionDialog : public QDialog Q_DISABLE_COPY_MOVE(TrackersAdditionDialog) public: - TrackersAdditionDialog(QWidget *parent, BitTorrent::Torrent *const torrent); + TrackersAdditionDialog(QWidget *parent, BitTorrent::Torrent *torrent); ~TrackersAdditionDialog(); private slots: diff --git a/src/gui/rss/articlelistwidget.cpp b/src/gui/rss/articlelistwidget.cpp index 5b4cac365..6437c3184 100644 --- a/src/gui/rss/articlelistwidget.cpp +++ b/src/gui/rss/articlelistwidget.cpp @@ -71,11 +71,11 @@ void ArticleListWidget::setRSSItem(RSS::Item *rssItem, bool unreadOnly) connect(m_rssItem, &RSS::Item::articleRead, this, &ArticleListWidget::handleArticleRead); connect(m_rssItem, &RSS::Item::articleAboutToBeRemoved, this, &ArticleListWidget::handleArticleAboutToBeRemoved); - for (const auto article : asConst(rssItem->articles())) + for (auto *article : asConst(rssItem->articles())) { if (!(m_unreadOnly && article->isRead())) { - auto item = createItem(article); + auto *item = createItem(article); addItem(item); m_rssArticleToListItemMapping.insert(article, item); } @@ -89,7 +89,7 @@ void ArticleListWidget::handleArticleAdded(RSS::Article *rssArticle) { if (!(m_unreadOnly && rssArticle->isRead())) { - auto item = createItem(rssArticle); + auto *item = createItem(rssArticle); insertItem(0, item); m_rssArticleToListItemMapping.insert(rssArticle, item); } @@ -99,7 +99,7 @@ void ArticleListWidget::handleArticleAdded(RSS::Article *rssArticle) void ArticleListWidget::handleArticleRead(RSS::Article *rssArticle) { - auto item = mapRSSArticle(rssArticle); + auto *item = mapRSSArticle(rssArticle); if (!item) return; const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_qs)}; diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index bbd5bc1e7..c5add9633 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -64,7 +64,6 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) , m_formatFilterJSON(u"%1 (*%2)"_qs.arg(tr("Rules"), EXT_JSON)) , m_formatFilterLegacy(u"%1 (*%2)"_qs.arg(tr("Rules (legacy)"), EXT_LEGACY)) , m_ui(new Ui::AutomatedRssDownloader) - , m_currentRuleItem(nullptr) , m_storeDialogSize {u"RssFeedDownloader/geometrySize"_qs} #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) , m_storeHSplitterSize {u"GUI/Qt6/RSSFeedDownloader/HSplitterSizes"_qs} @@ -193,7 +192,7 @@ void AutomatedRssDownloader::loadFeedList() { const QSignalBlocker feedListSignalBlocker(m_ui->listFeeds); - for (const auto feed : asConst(RSS::Session::instance()->feeds())) + for (const auto *feed : asConst(RSS::Session::instance()->feeds())) { QListWidgetItem *item = new QListWidgetItem(feed->name(), m_ui->listFeeds); item->setData(Qt::UserRole, feed->url()); @@ -637,11 +636,11 @@ void AutomatedRssDownloader::updateMatchingArticles() : RSS::AutoDownloader::instance()->ruleByName(ruleItem->text())); for (const QString &feedURL : asConst(rule.feedURLs())) { - auto feed = RSS::Session::instance()->feedByURL(feedURL); + auto *feed = RSS::Session::instance()->feedByURL(feedURL); if (!feed) continue; // feed doesn't exist QStringList matchingArticles; - for (const auto article : asConst(feed->articles())) + for (const auto *article : asConst(feed->articles())) if (rule.matches(article->data())) matchingArticles << article->title(); if (!matchingArticles.isEmpty()) @@ -854,7 +853,7 @@ void AutomatedRssDownloader::handleRuleAdded(const QString &ruleName) void AutomatedRssDownloader::handleRuleRenamed(const QString &ruleName, const QString &oldRuleName) { - auto item = m_itemsByRuleName.take(oldRuleName); + auto *item = m_itemsByRuleName.take(oldRuleName); m_itemsByRuleName.insert(ruleName, item); if (m_currentRule.name() == oldRuleName) m_currentRule.setName(ruleName); @@ -863,7 +862,7 @@ void AutomatedRssDownloader::handleRuleRenamed(const QString &ruleName, const QS void AutomatedRssDownloader::handleRuleChanged(const QString &ruleName) { - auto item = m_itemsByRuleName.value(ruleName); + auto *item = m_itemsByRuleName.value(ruleName); if (item && (item != m_currentRuleItem)) item->setCheckState(RSS::AutoDownloader::instance()->ruleByName(ruleName).isEnabled() ? Qt::Checked : Qt::Unchecked); } diff --git a/src/gui/rss/feedlistwidget.cpp b/src/gui/rss/feedlistwidget.cpp index 428fd9546..dba3a7b25 100644 --- a/src/gui/rss/feedlistwidget.cpp +++ b/src/gui/rss/feedlistwidget.cpp @@ -123,7 +123,7 @@ FeedListWidget::FeedListWidget(QWidget *parent) void FeedListWidget::handleItemAdded(RSS::Item *rssItem) { - auto parentItem = m_rssToTreeItemMapping.value( + auto *parentItem = m_rssToTreeItemMapping.value( RSS::Session::instance()->itemByPath(RSS::Item::parentPath(rssItem->path()))); createItem(rssItem, parentItem); } @@ -264,7 +264,7 @@ void FeedListWidget::dropEvent(QDropEvent *event) // move as much items as possible for (QTreeWidgetItem *srcItem : asConst(selectedItems())) { - auto rssItem = getRSSItem(srcItem); + auto *rssItem = getRSSItem(srcItem); RSS::Session::instance()->moveItem(rssItem, RSS::Item::joinPath(destFolder->path(), rssItem->name())); } @@ -281,7 +281,7 @@ QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem m_rssToTreeItemMapping[rssItem] = item; QIcon icon; - if (auto feed = qobject_cast(rssItem)) + if (auto *feed = qobject_cast(rssItem)) icon = rssFeedIcon(feed); else icon = UIThemeManager::instance()->getIcon(u"directory"_qs); @@ -299,11 +299,11 @@ QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem void FeedListWidget::fill(QTreeWidgetItem *parent, RSS::Folder *rssParent) { - for (const auto rssItem : asConst(rssParent->items())) + for (auto *rssItem : asConst(rssParent->items())) { QTreeWidgetItem *item = createItem(rssItem, parent); // Recursive call if this is a folder. - if (auto folder = qobject_cast(rssItem)) + if (auto *folder = qobject_cast(rssItem)) fill(item, folder); } } diff --git a/src/gui/rss/htmlbrowser.cpp b/src/gui/rss/htmlbrowser.cpp index d2797192a..28452c387 100644 --- a/src/gui/rss/htmlbrowser.cpp +++ b/src/gui/rss/htmlbrowser.cpp @@ -54,10 +54,6 @@ HtmlBrowser::HtmlBrowser(QWidget *parent) connect(m_netManager, &QNetworkAccessManager::finished, this, &HtmlBrowser::resourceLoaded); } -HtmlBrowser::~HtmlBrowser() -{ -} - QVariant HtmlBrowser::loadResource(int type, const QUrl &name) { if (type == QTextDocument::ImageResource) diff --git a/src/gui/rss/htmlbrowser.h b/src/gui/rss/htmlbrowser.h index b503f257a..15734483c 100644 --- a/src/gui/rss/htmlbrowser.h +++ b/src/gui/rss/htmlbrowser.h @@ -42,7 +42,7 @@ class HtmlBrowser final : public QTextBrowser public: explicit HtmlBrowser(QWidget* parent = nullptr); - ~HtmlBrowser(); + ~HtmlBrowser() = default; QVariant loadResource(int type, const QUrl &name) override; diff --git a/src/gui/rss/rsswidget.cpp b/src/gui/rss/rsswidget.cpp index 9069b5301..c341a6e4e 100644 --- a/src/gui/rss/rsswidget.cpp +++ b/src/gui/rss/rsswidget.cpp @@ -203,7 +203,7 @@ void RSSWidget::displayItemsListMenu() bool hasLink = false; for (const QListWidgetItem *item : asConst(m_articleListWidget->selectedItems())) { - auto article = item->data(Qt::UserRole).value(); + auto *article = item->data(Qt::UserRole).value(); Q_ASSERT(article); if (!article->torrentUrl().isEmpty()) @@ -364,7 +364,7 @@ void RSSWidget::downloadSelectedTorrents() { for (QListWidgetItem *item : asConst(m_articleListWidget->selectedItems())) { - auto article = item->data(Qt::UserRole).value(); + auto *article = item->data(Qt::UserRole).value(); Q_ASSERT(article); // Mark as read @@ -385,7 +385,7 @@ void RSSWidget::openSelectedArticlesUrls() { for (QListWidgetItem *item : asConst(m_articleListWidget->selectedItems())) { - auto article = item->data(Qt::UserRole).value(); + auto *article = item->data(Qt::UserRole).value(); Q_ASSERT(article); // Mark as read @@ -467,7 +467,7 @@ void RSSWidget::copySelectedFeedsURL() QStringList URLs; for (QTreeWidgetItem *item : asConst(m_feedListWidget->selectedItems())) { - if (auto feed = qobject_cast(m_feedListWidget->getRSSItem(item))) + if (auto *feed = qobject_cast(m_feedListWidget->getRSSItem(item))) URLs << feed->url(); } qApp->clipboard()->setText(URLs.join(u'\n')); @@ -496,14 +496,14 @@ void RSSWidget::handleCurrentArticleItemChanged(QListWidgetItem *currentItem, QL if (previousItem) { - auto article = m_articleListWidget->getRSSArticle(previousItem); + auto *article = m_articleListWidget->getRSSArticle(previousItem); Q_ASSERT(article); article->markAsRead(); } if (!currentItem) return; - auto article = m_articleListWidget->getRSSArticle(currentItem); + auto *article = m_articleListWidget->getRSSArticle(currentItem); Q_ASSERT(article); const QString highlightedBaseColor = m_ui->textBrowser->palette().color(QPalette::Highlight).name(); diff --git a/src/gui/search/searchjobwidget.cpp b/src/gui/search/searchjobwidget.cpp index 3b7cb37d1..c0320741d 100644 --- a/src/gui/search/searchjobwidget.cpp +++ b/src/gui/search/searchjobwidget.cpp @@ -459,7 +459,7 @@ int SearchJobWidget::visibleColumnsCount() const void SearchJobWidget::displayColumnHeaderMenu() { - auto menu = new QMenu(this); + auto *menu = new QMenu(this); menu->setAttribute(Qt::WA_DeleteOnClose); menu->setTitle(tr("Column visibility")); menu->setToolTipsVisible(true); diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index 2896f773e..a1ea7c15f 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -144,7 +144,7 @@ SearchWidget::SearchWidget(IGUIApplication *app, MainWindow *mainWindow) connect(m_ui->selectPlugin, qOverload(&QComboBox::currentIndexChanged) , this, &SearchWidget::fillCatCombobox); - const auto focusSearchHotkey = new QShortcut(QKeySequence::Find, this); + const auto *focusSearchHotkey = new QShortcut(QKeySequence::Find, this); connect(focusSearchHotkey, &QShortcut::activated, this, &SearchWidget::toggleFocusBetweenLineEdits); } @@ -156,7 +156,7 @@ bool SearchWidget::eventFilter(QObject *object, QEvent *event) if (event->type() != QEvent::MouseButtonRelease) return false; - const auto mouseEvent = static_cast(event); + const auto *mouseEvent = static_cast(event); const int tabIndex = m_ui->tabWidget->tabBar()->tabAt(mouseEvent->pos()); if ((mouseEvent->button() == Qt::MiddleButton) && (tabIndex >= 0)) { diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp index b4877b692..1d3d8db70 100644 --- a/src/gui/statusbar.cpp +++ b/src/gui/statusbar.cpp @@ -255,7 +255,7 @@ void StatusBar::updateAltSpeedsBtn(bool alternative) void StatusBar::capSpeed() { - auto dialog = new SpeedLimitDialog {parentWidget()}; + auto *dialog = new SpeedLimitDialog {parentWidget()}; dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->open(); } diff --git a/src/gui/torrentcategorydialog.cpp b/src/gui/torrentcategorydialog.cpp index ccbc3bd62..36fe38d9a 100644 --- a/src/gui/torrentcategorydialog.cpp +++ b/src/gui/torrentcategorydialog.cpp @@ -108,7 +108,7 @@ void TorrentCategoryDialog::editCategory(QWidget *parent, const QString &categor Q_ASSERT(Session::instance()->categories().contains(categoryName)); - auto dialog = new TorrentCategoryDialog(parent); + auto *dialog = new TorrentCategoryDialog(parent); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setCategoryNameEditable(false); dialog->setCategoryName(categoryName); diff --git a/src/gui/torrentcontentwidget.cpp b/src/gui/torrentcontentwidget.cpp index 58a2fef29..f086516cc 100644 --- a/src/gui/torrentcontentwidget.cpp +++ b/src/gui/torrentcontentwidget.cpp @@ -75,7 +75,7 @@ TorrentContentWidget::TorrentContentWidget(QWidget *parent) m_filterModel->setSourceModel(m_model); QTreeView::setModel(m_filterModel); - auto itemDelegate = new TorrentContentItemDelegate(this); + auto *itemDelegate = new TorrentContentItemDelegate(this); setItemDelegate(itemDelegate); connect(this, &QAbstractItemView::clicked, this, qOverload(&QAbstractItemView::edit)); @@ -436,7 +436,7 @@ void TorrentContentWidget::openParentFolder(const QModelIndex &index) const Path TorrentContentWidget::getFullPath(const QModelIndex &index) const { - const auto contentHandler = m_model->contentHandler(); + const auto *contentHandler = m_model->contentHandler(); if (const int fileIdx = getFileIndex(index); fileIdx >= 0) { const Path fullPath = contentHandler->actualStorageLocation() / contentHandler->actualFilePath(fileIdx); @@ -450,7 +450,7 @@ Path TorrentContentWidget::getFullPath(const QModelIndex &index) const void TorrentContentWidget::onItemDoubleClicked(const QModelIndex &index) { - const auto contentHandler = m_model->contentHandler(); + const auto *contentHandler = m_model->contentHandler(); Q_ASSERT(contentHandler && contentHandler->hasMetadata()); if (Q_UNLIKELY(!contentHandler || !contentHandler->hasMetadata())) diff --git a/src/gui/transferlistfilters/basefilterwidget.h b/src/gui/transferlistfilters/basefilterwidget.h index bcb2753c8..9f0afecdb 100644 --- a/src/gui/transferlistfilters/basefilterwidget.h +++ b/src/gui/transferlistfilters/basefilterwidget.h @@ -56,7 +56,7 @@ private slots: virtual void showMenu() = 0; virtual void applyFilter(int row) = 0; virtual void handleTorrentsLoaded(const QVector &torrents) = 0; - virtual void torrentAboutToBeDeleted(BitTorrent::Torrent *const) = 0; + virtual void torrentAboutToBeDeleted(BitTorrent::Torrent *) = 0; private: TransferListWidget *m_transferList = nullptr; diff --git a/src/gui/transferlistfilters/categoryfiltermodel.cpp b/src/gui/transferlistfilters/categoryfiltermodel.cpp index 8229fcc40..99abeef62 100644 --- a/src/gui/transferlistfilters/categoryfiltermodel.cpp +++ b/src/gui/transferlistfilters/categoryfiltermodel.cpp @@ -38,13 +38,10 @@ class CategoryModelItem { public: - CategoryModelItem() - { - } + CategoryModelItem() = default; CategoryModelItem(CategoryModelItem *parent, QString categoryName, int torrentsCount = 0) - : m_parent(nullptr) - , m_name(categoryName) + : m_name(categoryName) , m_torrentsCount(torrentsCount) { if (parent) @@ -207,7 +204,7 @@ QVariant CategoryFilterModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return {}; - auto item = static_cast(index.internalPointer()); + const auto *item = static_cast(index.internalPointer()); if ((index.column() == 0) && (role == Qt::DecorationRole)) { @@ -251,7 +248,7 @@ QModelIndex CategoryFilterModel::index(int row, int column, const QModelIndex &p if (parent.isValid() && (parent.column() != 0)) return {}; - auto parentItem = parent.isValid() ? static_cast(parent.internalPointer()) + auto *parentItem = parent.isValid() ? static_cast(parent.internalPointer()) : m_rootItem; if (row < parentItem->childCount()) return createIndex(row, column, parentItem->childAt(row)); @@ -264,7 +261,7 @@ QModelIndex CategoryFilterModel::parent(const QModelIndex &index) const if (!index.isValid()) return {}; - auto item = static_cast(index.internalPointer()); + auto *item = static_cast(index.internalPointer()); if (!item) return {}; return this->index(item->parent()); @@ -278,7 +275,7 @@ int CategoryFilterModel::rowCount(const QModelIndex &parent) const if (!parent.isValid()) return m_rootItem->childCount(); - auto item = static_cast(parent.internalPointer()); + auto *item = static_cast(parent.internalPointer()); if (!item) return 0; return item->childCount(); @@ -308,7 +305,7 @@ void CategoryFilterModel::categoryAdded(const QString &categoryName) if (m_isSubcategoriesEnabled) { - QStringList expanded = BitTorrent::Session::instance()->expandCategory(categoryName); + QStringList expanded = BitTorrent::Session::expandCategory(categoryName); if (expanded.count() > 1) parent = findItem(expanded[expanded.count() - 2]); } @@ -322,7 +319,7 @@ void CategoryFilterModel::categoryAdded(const QString &categoryName) void CategoryFilterModel::categoryRemoved(const QString &categoryName) { - auto item = findItem(categoryName); + auto *item = findItem(categoryName); if (item) { QModelIndex i = index(item); @@ -357,7 +354,7 @@ void CategoryFilterModel::torrentCategoryChanged(BitTorrent::Torrent *const torr { QModelIndex i; - auto item = findItem(oldCategory); + auto *item = findItem(oldCategory); Q_ASSERT(item); item->decreaseTorrentsCount(); @@ -413,7 +410,7 @@ void CategoryFilterModel::populate() for (const QString &categoryName : asConst(session->categories())) { CategoryModelItem *parent = m_rootItem; - for (const QString &subcat : asConst(session->expandCategory(categoryName))) + for (const QString &subcat : asConst(BitTorrent::Session::expandCategory(categoryName))) { const QString subcatName = shortName(subcat); if (!parent->hasChild(subcatName)) @@ -446,7 +443,7 @@ CategoryModelItem *CategoryFilterModel::findItem(const QString &fullName) const return m_rootItem->child(fullName); CategoryModelItem *item = m_rootItem; - for (const QString &subcat : asConst(BitTorrent::Session::instance()->expandCategory(fullName))) + for (const QString &subcat : asConst(BitTorrent::Session::expandCategory(fullName))) { const QString subcatName = shortName(subcat); if (!item->hasChild(subcatName)) return nullptr; diff --git a/src/gui/transferlistfilters/categoryfiltermodel.h b/src/gui/transferlistfilters/categoryfiltermodel.h index 744f6b319..1ba799f09 100644 --- a/src/gui/transferlistfilters/categoryfiltermodel.h +++ b/src/gui/transferlistfilters/categoryfiltermodel.h @@ -63,8 +63,8 @@ private slots: void categoryAdded(const QString &categoryName); void categoryRemoved(const QString &categoryName); void torrentsLoaded(const QVector &torrents); - void torrentAboutToBeRemoved(BitTorrent::Torrent *const torrent); - void torrentCategoryChanged(BitTorrent::Torrent *const torrent, const QString &oldCategory); + void torrentAboutToBeRemoved(BitTorrent::Torrent *torrent); + void torrentCategoryChanged(BitTorrent::Torrent *torrent, const QString &oldCategory); void subcategoriesSupportChanged(); private: diff --git a/src/gui/transferlistfilters/categoryfilterwidget.cpp b/src/gui/transferlistfilters/categoryfilterwidget.cpp index a41316ef6..b1f4b22c1 100644 --- a/src/gui/transferlistfilters/categoryfilterwidget.cpp +++ b/src/gui/transferlistfilters/categoryfilterwidget.cpp @@ -214,7 +214,7 @@ void CategoryFilterWidget::removeCategory() void CategoryFilterWidget::removeUnusedCategories() { - auto session = BitTorrent::Session::instance(); + auto *session = BitTorrent::Session::instance(); for (const QString &category : asConst(session->categories())) { if (model()->data(static_cast(model())->index(category), Qt::UserRole) == 0) diff --git a/src/gui/transferlistfilters/statusfilterwidget.cpp b/src/gui/transferlistfilters/statusfilterwidget.cpp index e0caf03f7..9fcb9af3d 100644 --- a/src/gui/transferlistfilters/statusfilterwidget.cpp +++ b/src/gui/transferlistfilters/statusfilterwidget.cpp @@ -199,7 +199,7 @@ void StatusFilterWidget::hideZeroItems() setCurrentRow(TorrentFilter::All, QItemSelectionModel::SelectCurrent); } -void StatusFilterWidget::update(const QVector torrents) +void StatusFilterWidget::update(const QVector &torrents) { for (const BitTorrent::Torrent *torrent : torrents) updateTorrentStatus(torrent); diff --git a/src/gui/transferlistfilters/statusfilterwidget.h b/src/gui/transferlistfilters/statusfilterwidget.h index 1e13bc0d7..ac1bbd5a5 100644 --- a/src/gui/transferlistfilters/statusfilterwidget.h +++ b/src/gui/transferlistfilters/statusfilterwidget.h @@ -54,11 +54,11 @@ private: void showMenu() override; void applyFilter(int row) override; void handleTorrentsLoaded(const QVector &torrents) override; - void torrentAboutToBeDeleted(BitTorrent::Torrent *const) override; + void torrentAboutToBeDeleted(BitTorrent::Torrent *) override; void configure(); - void update(const QVector torrents); + void update(const QVector &torrents); void updateTorrentStatus(const BitTorrent::Torrent *torrent); void updateTexts(); void hideZeroItems(); diff --git a/src/gui/transferlistfilters/tagfiltermodel.h b/src/gui/transferlistfilters/tagfiltermodel.h index d51addb1b..577530ac8 100644 --- a/src/gui/transferlistfilters/tagfiltermodel.h +++ b/src/gui/transferlistfilters/tagfiltermodel.h @@ -61,10 +61,10 @@ public: private slots: void tagAdded(const QString &tag); void tagRemoved(const QString &tag); - void torrentTagAdded(BitTorrent::Torrent *const torrent, const QString &tag); - void torrentTagRemoved(BitTorrent::Torrent *const, const QString &tag); + void torrentTagAdded(BitTorrent::Torrent *torrent, const QString &tag); + void torrentTagRemoved(BitTorrent::Torrent *, const QString &tag); void torrentsLoaded(const QVector &torrents); - void torrentAboutToBeRemoved(BitTorrent::Torrent *const torrent); + void torrentAboutToBeRemoved(BitTorrent::Torrent *torrent); private: static QString tagDisplayName(const QString &tag); diff --git a/src/gui/transferlistfilters/tagfilterwidget.cpp b/src/gui/transferlistfilters/tagfilterwidget.cpp index 1a97b82c0..18b1fb2db 100644 --- a/src/gui/transferlistfilters/tagfilterwidget.cpp +++ b/src/gui/transferlistfilters/tagfilterwidget.cpp @@ -208,7 +208,7 @@ void TagFilterWidget::removeTag() void TagFilterWidget::removeUnusedTags() { - auto session = BitTorrent::Session::instance(); + auto *session = BitTorrent::Session::instance(); for (const QString &tag : asConst(session->tags())) if (model()->data(static_cast(model())->index(tag), Qt::UserRole) == 0) session->removeTag(tag); diff --git a/src/gui/transferlistfilters/trackersfilterwidget.h b/src/gui/transferlistfilters/trackersfilterwidget.h index 153b6b3ec..0626c65d4 100644 --- a/src/gui/transferlistfilters/trackersfilterwidget.h +++ b/src/gui/transferlistfilters/trackersfilterwidget.h @@ -69,7 +69,7 @@ private: void showMenu() override; void applyFilter(int row) override; void handleTorrentsLoaded(const QVector &torrents) override; - void torrentAboutToBeDeleted(BitTorrent::Torrent *const torrent) override; + void torrentAboutToBeDeleted(BitTorrent::Torrent *torrent) override; void addItems(const QString &trackerURL, const QVector &torrents); void removeItem(const QString &trackerURL, const BitTorrent::TorrentID &id); diff --git a/src/gui/transferlistmodel.h b/src/gui/transferlistmodel.h index 7f42c6aef..f0d7e8ad1 100644 --- a/src/gui/transferlistmodel.h +++ b/src/gui/transferlistmodel.h @@ -107,15 +107,15 @@ public: private slots: void addTorrents(const QVector &torrents); - void handleTorrentAboutToBeRemoved(BitTorrent::Torrent *const torrent); - void handleTorrentStatusUpdated(BitTorrent::Torrent *const torrent); + void handleTorrentAboutToBeRemoved(BitTorrent::Torrent *torrent); + void handleTorrentStatusUpdated(BitTorrent::Torrent *torrent); void handleTorrentsUpdated(const QVector &torrents); private: void configure(); QString displayValue(const BitTorrent::Torrent *torrent, int column) const; QVariant internalValue(const BitTorrent::Torrent *torrent, int column, bool alt) const; - QIcon getIconByState(const BitTorrent::TorrentState state) const; + QIcon getIconByState(BitTorrent::TorrentState state) const; QList m_torrentList; // maps row number to torrent handle QHash m_torrentMap; // maps torrent handle to row number diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 246a72860..0ed31f203 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -335,7 +335,7 @@ void TransferListWidget::setSelectedTorrentsLocation() const Path oldLocation = torrents[0]->savePath(); - auto fileDialog = new QFileDialog(this, tr("Choose save path"), oldLocation.data()); + auto *fileDialog = new QFileDialog(this, tr("Choose save path"), oldLocation.data()); fileDialog->setAttribute(Qt::WA_DeleteOnClose); fileDialog->setFileMode(QFileDialog::Directory); fileDialog->setOptions(QFileDialog::DontConfirmOverwrite | QFileDialog::ShowDirsOnly | QFileDialog::HideNameFilterDetails); @@ -616,7 +616,7 @@ void TransferListWidget::setTorrentOptions() const QVector selectedTorrents = getSelectedTorrents(); if (selectedTorrents.empty()) return; - auto dialog = new TorrentOptionsDialog {this, selectedTorrents}; + auto *dialog = new TorrentOptionsDialog {this, selectedTorrents}; dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->open(); } @@ -654,7 +654,7 @@ int TransferListWidget::visibleColumnsCount() const // hide/show columns menu void TransferListWidget::displayColumnHeaderMenu() { - auto menu = new QMenu(this); + auto *menu = new QMenu(this); menu->setAttribute(Qt::WA_DeleteOnClose); menu->setTitle(tr("Column visibility")); menu->setToolTipsVisible(true); @@ -767,7 +767,7 @@ void TransferListWidget::editTorrentTrackers() } } - auto trackerDialog = new TrackerEntriesDialog(this); + auto *trackerDialog = new TrackerEntriesDialog(this); trackerDialog->setAttribute(Qt::WA_DeleteOnClose); trackerDialog->setTrackers(commonTrackers); @@ -785,7 +785,7 @@ void TransferListWidget::exportTorrent() if (getSelectedTorrents().isEmpty()) return; - auto fileDialog = new QFileDialog(this, tr("Choose folder to save exported .torrent files")); + auto *fileDialog = new QFileDialog(this, tr("Choose folder to save exported .torrent files")); fileDialog->setAttribute(Qt::WA_DeleteOnClose); fileDialog->setFileMode(QFileDialog::Directory); fileDialog->setOptions(QFileDialog::ShowDirsOnly); diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index 5b5be7d61..205b21246 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -102,7 +102,7 @@ public slots: void renameSelectedTorrent(); signals: - void currentTorrentChanged(BitTorrent::Torrent *const torrent); + void currentTorrentChanged(BitTorrent::Torrent *torrent); private slots: void torrentDoubleClicked(); diff --git a/src/gui/uithemedialog.cpp b/src/gui/uithemedialog.cpp index 54f8f86d0..a927e7839 100644 --- a/src/gui/uithemedialog.cpp +++ b/src/gui/uithemedialog.cpp @@ -124,7 +124,7 @@ private: void showColorDialog() { - auto dialog = new QColorDialog(m_currentColor, this); + auto *dialog = new QColorDialog(m_currentColor, this); dialog->setAttribute(Qt::WA_DeleteOnClose); connect(dialog, &QDialog::accepted, this, [this, dialog] { diff --git a/src/gui/uithemesource.h b/src/gui/uithemesource.h index bfd89546c..4969c3cee 100644 --- a/src/gui/uithemesource.h +++ b/src/gui/uithemesource.h @@ -54,8 +54,8 @@ class UIThemeSource public: virtual ~UIThemeSource() = default; - virtual QColor getColor(const QString &colorId, const ColorMode colorMode) const = 0; - virtual Path getIconPath(const QString &iconId, const ColorMode colorMode) const = 0; + virtual QColor getColor(const QString &colorId, ColorMode colorMode) const = 0; + virtual Path getIconPath(const QString &iconId, ColorMode colorMode) const = 0; virtual QByteArray readStyleSheet() = 0; }; @@ -65,8 +65,8 @@ public: DefaultThemeSource(); QByteArray readStyleSheet() override; - QColor getColor(const QString &colorId, const ColorMode colorMode) const override; - Path getIconPath(const QString &iconId, const ColorMode colorMode) const override; + QColor getColor(const QString &colorId, ColorMode colorMode) const override; + Path getIconPath(const QString &iconId, ColorMode colorMode) const override; private: void loadColors(); @@ -79,8 +79,8 @@ private: class CustomThemeSource : public UIThemeSource { public: - QColor getColor(const QString &colorId, const ColorMode colorMode) const override; - Path getIconPath(const QString &iconId, const ColorMode colorMode) const override; + QColor getColor(const QString &colorId, ColorMode colorMode) const override; + Path getIconPath(const QString &iconId, ColorMode colorMode) const override; QByteArray readStyleSheet() override; protected: diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index f04cbc962..f91521b7c 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -149,7 +149,7 @@ void AppController::preferencesAction() QJsonObject nativeDirs; for (auto i = watchedFolders.cbegin(); i != watchedFolders.cend(); ++i) { - const Path watchedFolder = i.key(); + const Path &watchedFolder = i.key(); const BitTorrent::AddTorrentParams params = i.value().addTorrentParams; if (params.savePath.isEmpty()) nativeDirs.insert(watchedFolder.toString(), 1); @@ -616,7 +616,7 @@ void AppController::setPreferencesAction() session->setMaxUploadsPerTorrent(it.value().toInt()); // Proxy Server - auto proxyManager = Net::ProxyConfigurationManager::instance(); + auto *proxyManager = Net::ProxyConfigurationManager::instance(); Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration(); if (hasKey(u"proxy_type"_qs)) proxyConf.type = Utils::String::toEnum(it.value().toString(), Net::ProxyType::HTTP); diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 529b7b8c0..16ecc789f 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -1279,7 +1279,7 @@ void TorrentsController::removeCategoriesAction() void TorrentsController::categoriesAction() { - const auto session = BitTorrent::Session::instance(); + const auto *session = BitTorrent::Session::instance(); QJsonObject categories; const QStringList categoriesList = session->categories();