From 31fe32776350f715ba6cb057b966557eb4a514de Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 11 Aug 2023 13:47:55 +0800 Subject: [PATCH] Move to separate headers Hopefully this can speed up compilation times. https://doc.qt.io/qt-6/qtglobal.html#details PR #19430. --- CODING_GUIDELINES.md | 4 +-- src/app/application.h | 2 +- src/app/applicationinstancemanager.cpp | 2 +- src/app/main.cpp | 2 +- src/app/qtlocalpeer/qtlocalpeer.cpp | 2 +- src/app/signalhandler.cpp | 2 +- src/app/upgrade.cpp | 2 +- src/base/applicationcomponent.h | 2 +- src/base/bittorrent/abstractfilestorage.h | 1 - src/base/bittorrent/cachestatus.h | 2 +- src/base/bittorrent/infohash.h | 1 - src/base/bittorrent/peeraddress.h | 2 +- src/base/bittorrent/sessionstatus.h | 2 +- src/base/bittorrent/speedmonitor.h | 2 +- src/base/bittorrent/torrent.h | 2 +- src/base/bittorrent/tracker.h | 2 +- src/base/bittorrent/trackerentry.h | 1 - src/base/digest32.h | 1 - src/base/global.h | 2 +- src/base/indexrange.h | 2 +- src/base/interfaces/iapplication.h | 2 +- src/base/net/downloadmanager.h | 2 +- src/base/net/geoipdatabase.h | 2 +- src/base/path.h | 3 ++- src/base/preferences.h | 2 +- src/base/torrentfileswatcher.cpp | 2 +- src/base/utils/compare.h | 2 +- src/base/utils/gzip.cpp | 2 +- src/base/utils/misc.h | 2 +- src/base/utils/random.cpp | 2 +- src/gui/log/loglistview.cpp | 2 +- src/gui/mainwindow.cpp | 3 +-- src/gui/powermanagement/powermanagement.cpp | 2 +- src/gui/programupdater.cpp | 2 +- src/gui/properties/peerlistwidget.cpp | 1 - src/gui/rss/automatedrssdownloader.cpp | 1 - src/gui/search/searchwidget.cpp | 2 +- src/gui/uithemecommon.h | 1 - src/gui/uithememanager.h | 2 +- src/gui/uithemesource.h | 2 +- src/gui/utils.cpp | 2 +- test/testalgorithm.cpp | 1 + test/testbittorrenttrackerentry.cpp | 1 + test/testglobal.cpp | 29 ++++++++++++++++----- test/testorderedset.cpp | 1 + test/testpath.cpp | 3 ++- test/testutilsbytearray.cpp | 1 + test/testutilscompare.cpp | 1 + test/testutilsgzip.cpp | 1 + test/testutilsio.cpp | 3 ++- test/testutilsstring.cpp | 1 + test/testutilsversion.cpp | 1 + 52 files changed, 71 insertions(+), 51 deletions(-) diff --git a/CODING_GUIDELINES.md b/CODING_GUIDELINES.md index 0bbf0e2c6..4c4e84083 100644 --- a/CODING_GUIDELINES.md +++ b/CODING_GUIDELINES.md @@ -318,7 +318,7 @@ The headers should be ordered alphabetically within each group. \ If there are conditionals for the same header group, then put them at the bottom of the respective group. \ If there are conditionals that contain headers from several different header groups, then put them above the "qBittorrent's own headers" group. -One exception is the header containing the library version (for example, QtGlobal), this particular header isn't constrained by the aforementioned order. +One exception is the header containing the library version (for example, QtVersionChecks), this particular header isn't constrained by the aforementioned order. Example: @@ -331,7 +331,7 @@ Example: // exceptions, headers containing version number #include #include -#include +#include // C++ Standard Library headers #include diff --git a/src/app/application.h b/src/app/application.h index ee69f5afc..c08d7ef94 100644 --- a/src/app/application.h +++ b/src/app/application.h @@ -30,7 +30,7 @@ #pragma once -#include +#include #include #include #include diff --git a/src/app/applicationinstancemanager.cpp b/src/app/applicationinstancemanager.cpp index a897733e2..26001724a 100644 --- a/src/app/applicationinstancemanager.cpp +++ b/src/app/applicationinstancemanager.cpp @@ -28,7 +28,7 @@ #include "applicationinstancemanager.h" -#include +#include #ifdef Q_OS_WIN #include diff --git a/src/app/main.cpp b/src/app/main.cpp index a9e29f86d..71ebb2160 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -27,7 +27,7 @@ * exception statement from your version. */ -#include +#include #include #include diff --git a/src/app/qtlocalpeer/qtlocalpeer.cpp b/src/app/qtlocalpeer/qtlocalpeer.cpp index 5e9dbe797..2b264b593 100644 --- a/src/app/qtlocalpeer/qtlocalpeer.cpp +++ b/src/app/qtlocalpeer/qtlocalpeer.cpp @@ -68,7 +68,7 @@ #include "qtlocalpeer.h" -#include +#include #if defined(Q_OS_WIN) #include diff --git a/src/app/signalhandler.cpp b/src/app/signalhandler.cpp index be70f254d..f5ef5263c 100644 --- a/src/app/signalhandler.cpp +++ b/src/app/signalhandler.cpp @@ -30,7 +30,7 @@ #include "signalhandler.h" -#include +#include #include #include diff --git a/src/app/upgrade.cpp b/src/app/upgrade.cpp index 59e715c7f..15e077724 100644 --- a/src/app/upgrade.cpp +++ b/src/app/upgrade.cpp @@ -28,7 +28,7 @@ #include "upgrade.h" -#include +#include #include #include diff --git a/src/base/applicationcomponent.h b/src/base/applicationcomponent.h index bbf530b46..29d0fcbc7 100644 --- a/src/base/applicationcomponent.h +++ b/src/base/applicationcomponent.h @@ -28,7 +28,7 @@ #pragma once -#include +#include #include "interfaces/iapplication.h" diff --git a/src/base/bittorrent/abstractfilestorage.h b/src/base/bittorrent/abstractfilestorage.h index f6f8eec92..dc50b6c42 100644 --- a/src/base/bittorrent/abstractfilestorage.h +++ b/src/base/bittorrent/abstractfilestorage.h @@ -28,7 +28,6 @@ #pragma once -#include #include #include "base/pathfwd.h" diff --git a/src/base/bittorrent/cachestatus.h b/src/base/bittorrent/cachestatus.h index 4dd228dda..0abab1dbb 100644 --- a/src/base/bittorrent/cachestatus.h +++ b/src/base/bittorrent/cachestatus.h @@ -28,7 +28,7 @@ #pragma once -#include +#include namespace BitTorrent { diff --git a/src/base/bittorrent/infohash.h b/src/base/bittorrent/infohash.h index fbf6b8f95..c79b34968 100644 --- a/src/base/bittorrent/infohash.h +++ b/src/base/bittorrent/infohash.h @@ -32,7 +32,6 @@ #include #endif -#include #include #include "base/digest32.h" diff --git a/src/base/bittorrent/peeraddress.h b/src/base/bittorrent/peeraddress.h index 46e6de15c..dbaca6919 100644 --- a/src/base/bittorrent/peeraddress.h +++ b/src/base/bittorrent/peeraddress.h @@ -28,7 +28,7 @@ #pragma once -#include +#include #include class QString; diff --git a/src/base/bittorrent/sessionstatus.h b/src/base/bittorrent/sessionstatus.h index 9997a24d7..20ec0d6fc 100644 --- a/src/base/bittorrent/sessionstatus.h +++ b/src/base/bittorrent/sessionstatus.h @@ -28,7 +28,7 @@ #pragma once -#include +#include namespace BitTorrent { diff --git a/src/base/bittorrent/speedmonitor.h b/src/base/bittorrent/speedmonitor.h index 6bb7c97c9..ba1f52e81 100644 --- a/src/base/bittorrent/speedmonitor.h +++ b/src/base/bittorrent/speedmonitor.h @@ -33,7 +33,7 @@ #include #endif -#include +#include template struct Sample diff --git a/src/base/bittorrent/torrent.h b/src/base/bittorrent/torrent.h index 80e22b77a..d7e690d67 100644 --- a/src/base/bittorrent/torrent.h +++ b/src/base/bittorrent/torrent.h @@ -29,8 +29,8 @@ #pragma once -#include #include +#include #include #include diff --git a/src/base/bittorrent/tracker.h b/src/base/bittorrent/tracker.h index 892c5f3e2..8370d3958 100644 --- a/src/base/bittorrent/tracker.h +++ b/src/base/bittorrent/tracker.h @@ -34,7 +34,7 @@ #include -#include +#include #include #include #include diff --git a/src/base/bittorrent/trackerentry.h b/src/base/bittorrent/trackerentry.h index 502a8b096..8e0b98b1a 100644 --- a/src/base/bittorrent/trackerentry.h +++ b/src/base/bittorrent/trackerentry.h @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/base/digest32.h b/src/base/digest32.h index 5fdace840..3aaf27c35 100644 --- a/src/base/digest32.h +++ b/src/base/digest32.h @@ -30,7 +30,6 @@ #include -#include #include #include #include diff --git a/src/base/global.h b/src/base/global.h index bd714058d..6bf4ccdcc 100644 --- a/src/base/global.h +++ b/src/base/global.h @@ -30,7 +30,7 @@ #include -#include +#include #include diff --git a/src/base/indexrange.h b/src/base/indexrange.h index 37931f791..31b5fefea 100644 --- a/src/base/indexrange.h +++ b/src/base/indexrange.h @@ -28,7 +28,7 @@ #pragma once -#include +#include // Interval is defined via [first;last] template diff --git a/src/base/interfaces/iapplication.h b/src/base/interfaces/iapplication.h index 3942fd9d0..8b1a156c2 100644 --- a/src/base/interfaces/iapplication.h +++ b/src/base/interfaces/iapplication.h @@ -30,7 +30,7 @@ #pragma once -#include +#include #include class QString; diff --git a/src/base/net/downloadmanager.h b/src/base/net/downloadmanager.h index 263ed700b..d7a407f97 100644 --- a/src/base/net/downloadmanager.h +++ b/src/base/net/downloadmanager.h @@ -29,7 +29,7 @@ #pragma once -#include +#include #include #include #include diff --git a/src/base/net/geoipdatabase.h b/src/base/net/geoipdatabase.h index 06b6a209f..cc4c13205 100644 --- a/src/base/net/geoipdatabase.h +++ b/src/base/net/geoipdatabase.h @@ -28,7 +28,7 @@ #pragma once -#include +#include #include #include #include diff --git a/src/base/path.h b/src/base/path.h index 4501e2668..17dcbb40a 100644 --- a/src/base/path.h +++ b/src/base/path.h @@ -31,7 +31,6 @@ #include -#include #include #include @@ -39,6 +38,8 @@ #include "base/interfaces/istringable.h" +class QStringView; + class Path final : public IStringable { public: diff --git a/src/base/preferences.h b/src/base/preferences.h index 9f17eabb5..fbf763eea 100644 --- a/src/base/preferences.h +++ b/src/base/preferences.h @@ -30,7 +30,7 @@ #pragma once #include -#include +#include #include #include "base/pathfwd.h" diff --git a/src/base/torrentfileswatcher.cpp b/src/base/torrentfileswatcher.cpp index f50768767..c8ec3e9d6 100644 --- a/src/base/torrentfileswatcher.cpp +++ b/src/base/torrentfileswatcher.cpp @@ -31,7 +31,7 @@ #include -#include +#include #include #include #include diff --git a/src/base/utils/compare.h b/src/base/utils/compare.h index 53de6b73a..aa63d102b 100644 --- a/src/base/utils/compare.h +++ b/src/base/utils/compare.h @@ -29,7 +29,7 @@ #pragma once #include -#include +#include #if !defined(Q_OS_WIN) && (!defined(Q_OS_UNIX) || defined(Q_OS_MACOS) || defined(QT_FEATURE_icu)) #define QBT_USE_QCOLLATOR diff --git a/src/base/utils/gzip.cpp b/src/base/utils/gzip.cpp index 9419d1ba6..2375850ef 100644 --- a/src/base/utils/gzip.cpp +++ b/src/base/utils/gzip.cpp @@ -31,7 +31,7 @@ #include -#include +#include #include #ifndef ZLIB_CONST diff --git a/src/base/utils/misc.h b/src/base/utils/misc.h index fc1eac40d..157bb357a 100644 --- a/src/base/utils/misc.h +++ b/src/base/utils/misc.h @@ -28,7 +28,7 @@ #pragma once -#include +#include #ifdef Q_OS_WIN #include diff --git a/src/base/utils/random.cpp b/src/base/utils/random.cpp index 768973762..7938e5a0c 100644 --- a/src/base/utils/random.cpp +++ b/src/base/utils/random.cpp @@ -30,7 +30,7 @@ #include -#include +#include #ifdef Q_OS_WIN #include diff --git a/src/gui/log/loglistview.cpp b/src/gui/log/loglistview.cpp index a50906ba4..2fb4a1ce1 100644 --- a/src/gui/log/loglistview.cpp +++ b/src/gui/log/loglistview.cpp @@ -29,7 +29,7 @@ #include "loglistview.h" -#include +#include #include #include #include diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 0f6a2d82e..31feea966 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -29,7 +29,7 @@ #include "mainwindow.h" -#include +#include #include #include @@ -59,7 +59,6 @@ #include #include #include -#include #include #include "base/bittorrent/session.h" diff --git a/src/gui/powermanagement/powermanagement.cpp b/src/gui/powermanagement/powermanagement.cpp index 2fbecec45..a51bb10fe 100644 --- a/src/gui/powermanagement/powermanagement.cpp +++ b/src/gui/powermanagement/powermanagement.cpp @@ -28,7 +28,7 @@ #include "powermanagement.h" -#include +#include #ifdef Q_OS_MACOS #include diff --git a/src/gui/programupdater.cpp b/src/gui/programupdater.cpp index 5fa4abf18..68db32ab8 100644 --- a/src/gui/programupdater.cpp +++ b/src/gui/programupdater.cpp @@ -29,7 +29,7 @@ #include "programupdater.h" -#include +#include #if defined(Q_OS_WIN) #include diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 9f6b37b08..02f0cc609 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -31,7 +31,6 @@ #include -#include #include #include #include diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index 233e28f6a..6ebfaaf4c 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -29,7 +29,6 @@ #include "automatedrssdownloader.h" -#include #include #include #include diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index cb08799ef..a8764a3c4 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -30,7 +30,7 @@ #include "searchwidget.h" -#include +#include #include diff --git a/src/gui/uithemecommon.h b/src/gui/uithemecommon.h index 087357395..f08cb2de1 100644 --- a/src/gui/uithemecommon.h +++ b/src/gui/uithemecommon.h @@ -29,7 +29,6 @@ #pragma once -#include #include #include #include diff --git a/src/gui/uithememanager.h b/src/gui/uithememanager.h index df5e0984c..88c7eba3b 100644 --- a/src/gui/uithememanager.h +++ b/src/gui/uithememanager.h @@ -30,7 +30,7 @@ #pragma once -#include +#include #include #include #include diff --git a/src/gui/uithemesource.h b/src/gui/uithemesource.h index 4969c3cee..8a156d8fc 100644 --- a/src/gui/uithemesource.h +++ b/src/gui/uithemesource.h @@ -32,8 +32,8 @@ #include -#include #include +#include #include #include #include diff --git a/src/gui/utils.cpp b/src/gui/utils.cpp index b82646cf8..1757e1b35 100644 --- a/src/gui/utils.cpp +++ b/src/gui/utils.cpp @@ -28,7 +28,7 @@ #include "utils.h" -#include +#include #ifdef Q_OS_WIN #include diff --git a/test/testalgorithm.cpp b/test/testalgorithm.cpp index 1a17f861d..dccfeb36b 100644 --- a/test/testalgorithm.cpp +++ b/test/testalgorithm.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include "base/algorithm.h" diff --git a/test/testbittorrenttrackerentry.cpp b/test/testbittorrenttrackerentry.cpp index 380a11f36..ebac85bcf 100644 --- a/test/testbittorrenttrackerentry.cpp +++ b/test/testbittorrenttrackerentry.cpp @@ -28,6 +28,7 @@ #include +#include #include #include diff --git a/test/testglobal.cpp b/test/testglobal.cpp index bc56d2659..f3c8393f5 100644 --- a/test/testglobal.cpp +++ b/test/testglobal.cpp @@ -26,7 +26,10 @@ * exception statement from your version. */ -#include +#include + +#include +#include #include #include "base/global.h" @@ -40,13 +43,27 @@ public: TestGlobal() = default; private slots: -#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0)) - void testStringLiteral() const + void testAsConst() const { - QCOMPARE(u""_s, QStringLiteral("")); - QCOMPARE(u"abc"_s, QStringLiteral("abc")); + { + QList list = {0, 1, 2}; + + static_assert(std::is_const_v>); + QCOMPARE(list, asConst(list)); + QCOMPARE(list, asConst(QList(list))); + } + + { + const QList list = {0, 1, 2}; + + static_assert(std::is_const_v>); + QCOMPARE(list, asConst(list)); + QCOMPARE(list, asConst(QList(list))); + + // should not compile: + //asConst(std::move(list)); + } } -#endif }; QTEST_APPLESS_MAIN(TestGlobal) diff --git a/test/testorderedset.cpp b/test/testorderedset.cpp index 52843a75f..5246b6355 100644 --- a/test/testorderedset.cpp +++ b/test/testorderedset.cpp @@ -27,6 +27,7 @@ * exception statement from your version. */ +#include #include #include diff --git a/test/testpath.cpp b/test/testpath.cpp index 50ee84f66..6449a8071 100644 --- a/test/testpath.cpp +++ b/test/testpath.cpp @@ -26,7 +26,8 @@ * exception statement from your version. */ -#include +#include +#include #include #include "base/global.h" diff --git a/test/testutilsbytearray.cpp b/test/testutilsbytearray.cpp index 951ded736..562c59020 100644 --- a/test/testutilsbytearray.cpp +++ b/test/testutilsbytearray.cpp @@ -26,6 +26,7 @@ * exception statement from your version. */ +#include #include #include "base/global.h" diff --git a/test/testutilscompare.cpp b/test/testutilscompare.cpp index 1d1c49bd7..980f1895c 100644 --- a/test/testutilscompare.cpp +++ b/test/testutilscompare.cpp @@ -28,6 +28,7 @@ #include +#include #include #include "base/global.h" diff --git a/test/testutilsgzip.cpp b/test/testutilsgzip.cpp index c46cc1fa1..637e71922 100644 --- a/test/testutilsgzip.cpp +++ b/test/testutilsgzip.cpp @@ -26,6 +26,7 @@ * exception statement from your version. */ +#include #include #include "base/global.h" diff --git a/test/testutilsio.cpp b/test/testutilsio.cpp index fdc1358b1..2e2b970ed 100644 --- a/test/testutilsio.cpp +++ b/test/testutilsio.cpp @@ -26,7 +26,8 @@ * exception statement from your version. */ -#include +#include +#include #include #include "base/global.h" diff --git a/test/testutilsstring.cpp b/test/testutilsstring.cpp index 8fbb12d5c..164b2b480 100644 --- a/test/testutilsstring.cpp +++ b/test/testutilsstring.cpp @@ -26,6 +26,7 @@ * exception statement from your version. */ +#include #include #include "base/global.h" diff --git a/test/testutilsversion.cpp b/test/testutilsversion.cpp index ce0ff52be..9c07f81f7 100644 --- a/test/testutilsversion.cpp +++ b/test/testutilsversion.cpp @@ -26,6 +26,7 @@ * exception statement from your version. */ +#include #include #include "base/global.h"