diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-08-29 20:56:35 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-08-30 14:18:17 +0200 |
commit | 50f714789d43136ea2f8c29536b6b80d598e3b6f (patch) | |
tree | d5edca63a5e1a5de7848656c6cdadee5cb2b2d94 | |
parent | e86a91dfd5535ce548618270343a2521fb0ef4c6 (diff) |
QmlCompiler: Make LoggerCategory private again
It is not needed by the QQmlSA API. Additionally, remove the comparison
operator for LoggerCategory and LoggerId, and replace its users by
getting the id from the category before comparing.
Pick-to: 6.6
Change-Id: I7747b09b941cfd5326b95d2ee2f78b0ee10991d3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
-rw-r--r-- | src/qmlcompiler/qqmljslogger_p.h | 2 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljsloggingutils.h | 36 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljsloggingutils_p.h | 32 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 8 | ||||
-rw-r--r-- | tests/auto/quickcontrols/sanity/tst_sanity.cpp | 2 | ||||
-rw-r--r-- | tools/qmltc/main.cpp | 2 |
6 files changed, 41 insertions, 41 deletions
diff --git a/src/qmlcompiler/qqmljslogger_p.h b/src/qmlcompiler/qqmljslogger_p.h index f7ac8fdea4..7d6e9f2900 100644 --- a/src/qmlcompiler/qqmljslogger_p.h +++ b/src/qmlcompiler/qqmljslogger_p.h @@ -18,7 +18,7 @@ #include <private/qtqmlcompilerexports_p.h> #include "qcoloroutput_p.h" -#include "qqmljsloggingutils.h" +#include "qqmljsloggingutils_p.h" #include <private/qqmljsdiagnosticmessage_p.h> diff --git a/src/qmlcompiler/qqmljsloggingutils.h b/src/qmlcompiler/qqmljsloggingutils.h index caca28072c..0c11e03b87 100644 --- a/src/qmlcompiler/qqmljsloggingutils.h +++ b/src/qmlcompiler/qqmljsloggingutils.h @@ -17,7 +17,6 @@ class SourceLocation; } namespace QQmlJS { -class LoggerCategoryPrivate; class Q_QMLCOMPILER_EXPORT LoggerWarningId { @@ -39,41 +38,6 @@ private: const QAnyStringView m_name; }; -class Q_QMLCOMPILER_EXPORT LoggerCategory -{ - Q_DECLARE_PRIVATE(LoggerCategory) - -public: - LoggerCategory(); - LoggerCategory(QString name, QString settingsName, QString description, QtMsgType level, - bool ignored = false, bool isDefault = false); - LoggerCategory(const LoggerCategory &); - LoggerCategory(LoggerCategory &&) noexcept; - LoggerCategory &operator=(const LoggerCategory &); - LoggerCategory &operator=(LoggerCategory &&) noexcept; - ~LoggerCategory(); - - QString name() const; - QString settingsName() const; - QString description() const; - QtMsgType level() const; - bool isIgnored() const; - bool isDefault() const; - - LoggerWarningId id() const; - - void setLevel(QtMsgType); - void setIgnored(bool); - - friend bool operator==(const LoggerCategory &category, const LoggerWarningId &warningId) - { - return category.name() == warningId.name(); - } - -private: - std::unique_ptr<QQmlJS::LoggerCategoryPrivate> d_ptr; -}; - } // namespace QQmlJS extern const Q_QMLCOMPILER_EXPORT QQmlJS::LoggerWarningId qmlRequired; diff --git a/src/qmlcompiler/qqmljsloggingutils_p.h b/src/qmlcompiler/qqmljsloggingutils_p.h index 683836ca6c..f124e6f9a7 100644 --- a/src/qmlcompiler/qqmljsloggingutils_p.h +++ b/src/qmlcompiler/qqmljsloggingutils_p.h @@ -23,6 +23,38 @@ QT_BEGIN_NAMESPACE namespace QQmlJS { +class LoggerCategoryPrivate; + +class Q_QMLCOMPILER_EXPORT LoggerCategory +{ + Q_DECLARE_PRIVATE(LoggerCategory) + +public: + LoggerCategory(); + LoggerCategory(QString name, QString settingsName, QString description, QtMsgType level, + bool ignored = false, bool isDefault = false); + LoggerCategory(const LoggerCategory &); + LoggerCategory(LoggerCategory &&) noexcept; + LoggerCategory &operator=(const LoggerCategory &); + LoggerCategory &operator=(LoggerCategory &&) noexcept; + ~LoggerCategory(); + + QString name() const; + QString settingsName() const; + QString description() const; + QtMsgType level() const; + bool isIgnored() const; + bool isDefault() const; + + LoggerWarningId id() const; + + void setLevel(QtMsgType); + void setIgnored(bool); + +private: + std::unique_ptr<QQmlJS::LoggerCategoryPrivate> d_ptr; +}; + class LoggerCategoryPrivate { friend class QT_PREPEND_NAMESPACE(QQmlJS::LoggerCategory); diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index f0dca8ca7e..a215c0b691 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -1320,7 +1320,9 @@ void TestQmllint::compilerWarnings() auto categories = QQmlJSLogger::defaultCategories(); - auto category = std::find(categories.begin(), categories.end(), qmlCompiler); + auto category = std::find_if(categories.begin(), categories.end(), [](const QQmlJS::LoggerCategory& category) { + return category.id() == qmlCompiler; + }); Q_ASSERT(category != categories.end()); if (enableCompilerWarnings) { @@ -1691,7 +1693,9 @@ void TestQmllint::qrcUrlImport() void TestQmllint::attachedPropertyReuse() { auto categories = QQmlJSLogger::defaultCategories(); - auto category = std::find(categories.begin(), categories.end(), qmlAttachedPropertyReuse); + auto category = std::find_if(categories.begin(), categories.end(), [](const QQmlJS::LoggerCategory& category) { + return category.id() == qmlAttachedPropertyReuse; + }); Q_ASSERT(category != categories.end()); category->setLevel(QtWarningMsg); diff --git a/tests/auto/quickcontrols/sanity/tst_sanity.cpp b/tests/auto/quickcontrols/sanity/tst_sanity.cpp index 720c744056..1c41c4a53c 100644 --- a/tests/auto/quickcontrols/sanity/tst_sanity.cpp +++ b/tests/auto/quickcontrols/sanity/tst_sanity.cpp @@ -66,7 +66,7 @@ tst_Sanity::tst_Sanity() m_linter.setPluginsEnabled(true); for (auto &category : m_categories) { - if (category == qmlDeferredPropertyId || category == qmlAttachedPropertyReuse) { + if (category.id() == qmlDeferredPropertyId || category.id() == qmlAttachedPropertyReuse) { category.setLevel(QtWarningMsg); category.setIgnored(false); } else { diff --git a/tools/qmltc/main.cpp b/tools/qmltc/main.cpp index 5d4bfcc4b7..7c3bf3bacd 100644 --- a/tools/qmltc/main.cpp +++ b/tools/qmltc/main.cpp @@ -32,7 +32,7 @@ using namespace Qt::StringLiterals; void setupLogger(QQmlJSLogger &logger) // prepare logger to work with compiler { for (const QQmlJS::LoggerCategory &category : logger.categories()) { - if (category == qmlUnusedImports) + if (category.id() == qmlUnusedImports) continue; logger.setCategoryLevel(category.id(), QtCriticalMsg); logger.setCategoryIgnored(category.id(), false); |