Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmlloggingcategory.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 Pelagicore AG
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtQml/qqmlinfo.h>
7
8#include <memory>
9
67 , m_initialized(false)
68{
69}
70
72{
73}
74
76{
77 return QString::fromUtf8(m_name);
78}
79
81{
82 return m_defaultLogLevel;
83}
84
86{
87 return m_category.get();
88}
89
91{
92}
93
95{
96 m_initialized = true;
97 if (m_name.isNull()) {
98 qmlWarning(this) << QLatin1String("Declaring the name of a LoggingCategory is mandatory and cannot be changed later");
99 } else {
100 auto category = std::make_unique<QLoggingCategory>(m_name.constData(), QtMsgType(m_defaultLogLevel));
101 m_category.swap(category);
102 }
103}
104
106{
107 if (m_defaultLogLevel == defaultLogLevel)
108 return;
109
110 if (m_initialized) {
111 qmlWarning(this) << QLatin1String("The defaultLogLevel of a LoggingCategory cannot be changed after the component is completed");
112 return;
113 }
114
115 m_defaultLogLevel = defaultLogLevel;
116}
117
119{
120 const QByteArray newName = name.toUtf8();
121
122 if (m_name == newName)
123 return;
124
125 if (m_initialized) {
126 qmlWarning(this) << QLatin1String("The name of a LoggingCategory cannot be changed after the component is completed");
127 return;
128 }
129
130 m_name = newName;
131}
132
133#include "moc_qqmlloggingcategory_p.cpp"
\inmodule QtCore
Definition qbytearray.h:57
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:122
bool isNull() const noexcept
Returns true if this byte array is null; otherwise returns false.
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:90
void setDefaultLogLevel(DefaultLogLevel defaultLogLevel)
void setName(const QString &name)
QLoggingCategory * category() const
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
QQmlLoggingCategory(QObject *parent=nullptr)
\qmltype LoggingCategory\inqmlmodule QtQml
DefaultLogLevel defaultLogLevel
void classBegin() override
Invoked after class creation, but before any properties have been set.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
QtMsgType
Definition qlogging.h:29
GLuint name
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent