From 8219b1f695c94bcb646b949d8c9a5301a099307c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 5 May 2023 01:57:01 +0800 Subject: [PATCH] Use default constructor, destructor --- src/base/bittorrent/torrentimpl.cpp | 2 +- src/base/bittorrent/torrentinfo.cpp | 6 ------ src/base/bittorrent/torrentinfo.h | 2 +- src/base/http/irequesthandler.h | 2 +- src/base/http/requestparser.cpp | 4 ---- src/base/http/requestparser.h | 2 +- src/base/iconprovider.cpp | 2 -- src/base/iconprovider.h | 2 +- src/base/rss/rss_autodownloadrule.cpp | 7 ++----- src/base/rss/rss_autodownloadrule.h | 4 ++-- src/base/rss/rss_folder.h | 2 +- src/base/rss/rss_item.cpp | 2 -- src/base/rss/rss_item.h | 2 +- src/gui/powermanagement/powermanagement.cpp | 4 ---- src/gui/powermanagement/powermanagement.h | 2 +- src/gui/powermanagement/powermanagement_x11.cpp | 4 ---- src/gui/powermanagement/powermanagement_x11.h | 2 +- src/gui/rss/htmlbrowser.cpp | 4 ---- src/gui/rss/htmlbrowser.h | 2 +- src/gui/transferlistfilters/categoryfiltermodel.cpp | 4 +--- 20 files changed, 15 insertions(+), 46 deletions(-) diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 19575dbdd..fc51f1caf 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -338,7 +338,7 @@ TorrentImpl::TorrentImpl(SessionImpl *session, lt::session *nativeSession // == END UPGRADE CODE == } -TorrentImpl::~TorrentImpl() {} +TorrentImpl::~TorrentImpl() = default; bool TorrentImpl::isValid() const { 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/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/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_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/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/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/transferlistfilters/categoryfiltermodel.cpp b/src/gui/transferlistfilters/categoryfiltermodel.cpp index 8229fcc40..b96b292ff 100644 --- a/src/gui/transferlistfilters/categoryfiltermodel.cpp +++ b/src/gui/transferlistfilters/categoryfiltermodel.cpp @@ -38,9 +38,7 @@ class CategoryModelItem { public: - CategoryModelItem() - { - } + CategoryModelItem() = default; CategoryModelItem(CategoryModelItem *parent, QString categoryName, int torrentsCount = 0) : m_parent(nullptr)