Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qqmlcontext_p.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant
4
5
#
ifndef
QQMLCONTEXT_P_H
6
#
define
QQMLCONTEXT_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtQml
/
qqmlcontext
.
h
>
20
#
include
<
QtQml
/
qqmllist
.
h
>
21
22
#
include
<
QtCore
/
qlist
.
h
>
23
#
include
<
QtCore
/
qpointer
.
h
>
24
#
include
<
QtCore
/
qstring
.
h
>
25
#
include
<
QtCore
/
qtaggedpointer
.
h
>
26
#
include
<
QtCore
/
qvariant
.
h
>
27
28
#
include
<
private
/
qmetaobject_p
.
h
>
29
#
include
<
private
/
qobject_p
.
h
>
30
#
include
<
private
/
qqmlrefcount_p
.
h
>
31
32
QT_BEGIN_NAMESPACE
33
34
class
QQmlContextData;
35
36
class
QQmlContextPrivate
:
public
QObjectPrivate
37
{
38
Q_DECLARE_PUBLIC(QQmlContext)
39
public
:
40
static
QQmlContextPrivate
*
get
(
QQmlContext
*
context
) {
41
return
static_cast
<
QQmlContextPrivate
*>(
QObjectPrivate
::
get
(
context
));
42
}
43
44
static
QQmlContext
*
get
(
QQmlContextPrivate
*
context
) {
45
return
static_cast
<
QQmlContext
*>(
context
->
q_func
());
46
}
47
48
static
qsizetype
context_count
(
QQmlListProperty
<
QObject
> *);
49
static
QObject
*
context_at
(QQmlListProperty<QObject> *,
qsizetype
);
50
51
void
dropDestroyedQObject
(
const
QString &name, QObject *destroyed);
52
53
int
notifyIndex
()
const
{
return
m_notifyIndex; }
54
void
setNotifyIndex
(
int
notifyIndex) { m_notifyIndex = notifyIndex; }
55
56
int
numPropertyValues
()
const
{
57
auto
size = m_propertyValues.size();
58
Q_ASSERT(size <= std::numeric_limits<
int
>::max());
59
return
int
(size);
60
}
61
void
appendPropertyValue
(
const
QVariant &value) { m_propertyValues.append(value); }
62
void
setPropertyValue
(
int
index,
const
QVariant &value) { m_propertyValues[index] = value; }
63
QVariant
propertyValue
(
int
index)
const
{
return
m_propertyValues[index]; }
64
65
QList
<
QPointer
<
QObject
>>
instances
()
const
{
return
m_instances; }
66
void
appendInstance
(QObject *instance) { m_instances.append(instance); }
67
void
cleanInstances
()
68
{
69
for
(
auto
it = m_instances.begin(); it != m_instances.end();
70
it->isNull() ? (it = m_instances.erase(it)) : ++it) {}
71
}
72
73
void
emitDestruction
();
74
75
Q_QML_AUTOTEST_EXPORT
void
setContextProperty
(
const
QString &name,
const
QVariant &value);
76
77
private
:
78
friend
class
QQmlContextData;
79
80
QQmlContextPrivate(QQmlContextData *data) : m_data(data) {}
81
QQmlContextPrivate(QQmlContext *publicContext,
const
QQmlRefPointer<QQmlContextData> &parent,
82
QQmlEngine *engine =
nullptr
);
83
84
// Intentionally a bare pointer. QQmlContextData knows whether it owns QQmlContext or vice
85
// versa. If QQmlContext is the owner, QQmlContextData keeps an extra ref for its publicContext.
86
// The publicContext ref is released when doing QQmlContextData::setPublicContext(nullptr).
87
QQmlContextData *m_data;
88
89
QList<QVariant> m_propertyValues;
90
int
m_notifyIndex = -1;
91
92
// Only used for debugging
93
QList<QPointer<QObject>> m_instances;
94
};
95
96
QT_END_NAMESPACE
97
98
#
endif
// QQMLCONTEXT_P_H
QQmlContextPrivate
Definition
qqmlcontext_p.h:37
QQmlContextPrivate::dropDestroyedQObject
void dropDestroyedQObject(const QString &name, QObject *destroyed)
Definition
qqmlcontext.cpp:598
QQmlContextPrivate::cleanInstances
void cleanInstances()
Definition
qqmlcontext_p.h:67
QQmlContextPrivate::setNotifyIndex
void setNotifyIndex(int notifyIndex)
Definition
qqmlcontext_p.h:54
QQmlContextPrivate::setPropertyValue
void setPropertyValue(int index, const QVariant &value)
Definition
qqmlcontext_p.h:62
QQmlContextPrivate::appendInstance
void appendInstance(QObject *instance)
Definition
qqmlcontext_p.h:66
QQmlContextPrivate::notifyIndex
int notifyIndex() const
Definition
qqmlcontext_p.h:53
QQmlContextPrivate::appendPropertyValue
void appendPropertyValue(const QVariant &value)
Definition
qqmlcontext_p.h:61
QQmlContextPrivate::instances
QList< QPointer< QObject > > instances() const
Definition
qqmlcontext_p.h:65
QQmlContextPrivate::numPropertyValues
int numPropertyValues() const
Definition
qqmlcontext_p.h:56
QQmlContextPrivate::emitDestruction
void emitDestruction()
Definition
qqmlcontext.cpp:612
QQmlContextPrivate::setContextProperty
Q_QML_AUTOTEST_EXPORT void setContextProperty(const QString &name, const QVariant &value)
Definition
qqmlcontext.cpp:617
QQmlContextPrivate::propertyValue
QVariant propertyValue(int index) const
Definition
qqmlcontext_p.h:63
QQmlContextPrivate::context_at
static QObject * context_at(QQmlListProperty< QObject > *, qsizetype)
Definition
qqmlcontext.cpp:586
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
readObjectProperty
static bool readObjectProperty(const QQmlRefPointer< QQmlContextData > &data, QObject *object, const QString &name, QVariant *target)
Definition
qqmlcontext.cpp:345
objectForNameInQQmlContextData
static QObject * objectForNameInQQmlContextData(const QQmlRefPointer< QQmlContextData > &data, const QQmlContextPrivate *d, const QString &name)
Definition
qqmlcontext.cpp:415
qtdeclarative
src
qml
qml
qqmlcontext_p.h
Generated on
for Qt by
1.18.0