Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlproperty_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
4#ifndef QQMLPROPERTY_P_H
5#define QQMLPROPERTY_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qqmlproperty.h"
19
20#include <private/qobject_p.h>
21#include <private/qqmlcontextdata_p.h>
22#include <private/qqmlpropertydata_p.h>
23#include <private/qqmlpropertyindex_p.h>
24#include <private/qqmlrefcount_p.h>
25#include <private/qtqmlglobal_p.h>
26
27#include <QtQml/qqmlengine.h>
28
29#include <QtCore/qpointer.h>
30
32
33class QQmlContext;
35class QQmlJavaScriptExpression;
36class QQmlMetaObject;
37class QQmlAbstractBinding;
38class QQmlBoundSignalExpression;
39
40class Q_QML_EXPORT QQmlPropertyPrivate final : public QQmlRefCounted<QQmlPropertyPrivate>
41{
42public:
43 enum class InitFlag {
44 None = 0x0,
45 AllowId = 0x1,
46 AllowSignal = 0x2
47 };
48 Q_DECLARE_FLAGS(InitFlags, InitFlag);
49
50 QQmlRefPointer<QQmlContextData> context;
51 QPointer<QQmlEngine> engine;
52 QPointer<QObject> object;
53
54 QQmlPropertyData core;
55 QQmlPropertyData valueTypeData;
56
57 QString nameCache;
58
59 // ### Qt7: Get rid of this.
60 static bool resolveUrlsOnAssignment();
61
62 QQmlPropertyPrivate() {}
63
64 QQmlPropertyIndex encodedIndex() const
65 { return encodedIndex(core, valueTypeData); }
66 static QQmlPropertyIndex encodedIndex(const QQmlPropertyData &core, const QQmlPropertyData &valueTypeData)
67 { return QQmlPropertyIndex(core.coreIndex(), valueTypeData.coreIndex()); }
68
69 QQmlRefPointer<QQmlContextData> effectiveContext() const;
70
71 void initProperty(QObject *obj, const QString &name, InitFlags flags = InitFlag::None);
72 void initDefault(QObject *obj);
73
74 bool isValueType() const;
75 QMetaType propertyType() const;
76 QQmlProperty::Type type() const;
77 QQmlProperty::PropertyTypeCategory propertyTypeCategory() const;
78
79 QVariant readValueProperty();
80 bool writeValueProperty(const QVariant &, QQmlPropertyData::WriteFlags);
81
82 static QQmlMetaObject rawMetaObjectForType(QMetaType metaType);
83 static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
84 const QVariant &value, int flags);
85 static bool writeValueProperty(QObject *,
86 const QQmlPropertyData &, const QQmlPropertyData &valueTypeData,
87 const QVariant &, const QQmlRefPointer<QQmlContextData> &,
88 QQmlPropertyData::WriteFlags flags = {});
89 static bool resetValueProperty(QObject *,
90 const QQmlPropertyData &, const QQmlPropertyData &valueTypeData,
91 const QQmlRefPointer<QQmlContextData> &,
92 QQmlPropertyData::WriteFlags flags = {});
93 static bool write(QObject *, const QQmlPropertyData &, const QVariant &,
94 const QQmlRefPointer<QQmlContextData> &,
95 QQmlPropertyData::WriteFlags flags = {});
96 static bool reset(QObject *, const QQmlPropertyData &,
97 QQmlPropertyData::WriteFlags flags = {});
98 static void findAliasTarget(QObject *, QQmlPropertyIndex, QObject **, QQmlPropertyIndex *);
99
100 struct ResolvedAlias
101 {
102 QObject *targetObject;
103 QQmlPropertyIndex targetIndex;
104 };
105 /*!
106 \internal
107 Given an alias property specified by \a baseObject and \a baseIndex, this function
108 computes the alias target.
109 */
110 static ResolvedAlias findAliasTarget(QObject *baseObject, QQmlPropertyIndex baseIndex);
111
112 enum BindingFlag {
113 None = 0,
114 DontEnable = 0x1,
115 OverrideSticky = 0x2
116 };
117 Q_DECLARE_FLAGS(BindingFlags, BindingFlag)
118
119 static void setBinding(QQmlAbstractBinding *binding, BindingFlags flags = None,
120 QQmlPropertyData::WriteFlags writeFlags = QQmlPropertyData::DontRemoveBinding);
121
122 static bool removeBinding(const QQmlProperty &that, BindingFlags flags = None);
123 static bool removeBinding(QObject *o, QQmlPropertyIndex index, BindingFlags flags = None);
124 static bool removeBinding(QQmlAbstractBinding *b, QQmlPropertyPrivate::BindingFlags flags = None);
125 static QQmlAbstractBinding *binding(QObject *, QQmlPropertyIndex index);
126
127 static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *,
128 const QQmlRefPointer<QQmlContextData> &);
129
130 int signalIndex() const;
131
132 static inline QQmlPropertyPrivate *get(const QQmlProperty &p) { return p.d; }
133
134 // "Public" (to QML) methods
135 static QQmlAbstractBinding *binding(const QQmlProperty &that);
136 static void setBinding(const QQmlProperty &that, QQmlAbstractBinding *);
137 static QQmlBoundSignalExpression *signalExpression(const QQmlProperty &that);
138 static void setSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *);
139 static void takeSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *);
140 static bool write(const QQmlProperty &that, const QVariant &, QQmlPropertyData::WriteFlags);
141 static QQmlPropertyIndex propertyIndex(const QQmlProperty &that);
142 static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
143 static QMetaProperty findPropertyByName(const QMetaObject *mo, const QByteArray &);
144 static bool connect(const QObject *sender, int signal_index,
145 const QObject *receiver, int method_index,
146 int type = 0, int *types = nullptr);
147 static void flushSignal(const QObject *sender, int signal_index);
148
149 static QList<QUrl> urlSequence(const QVariant &value);
150 static QList<QUrl> urlSequence(
151 const QVariant &value, const QQmlRefPointer<QQmlContextData> &ctxt);
152 static QQmlProperty create(
153 QObject *target, const QString &propertyName,
154 const QQmlRefPointer<QQmlContextData> &context,
155 QQmlPropertyPrivate::InitFlags flags);
156};
157
158Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyPrivate::BindingFlags)
159Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyPrivate::InitFlags);
160
161QT_END_NAMESPACE
162
163#endif // QQMLPROPERTY_P_H
friend class QQmlEnginePrivate
void setSender(qintptr sender)
void cancelNotify()
Cancel any notifies that are in progress.
bool isNotifying() const
Returns true if a notify is in progress.
QObject * senderAsObject() const
void connect(QObject *source, int sourceSignal, QQmlEngine *engine, bool doNotify=true)
QQmlNotifier * senderAsNotifier() const
bool isConnected(QQmlNotifier *) const
void stopNotifying(qintptr *originalSenderPtr)
qintptr sender() const
void connect(QQmlNotifier *)
bool isConnected(QObject *source, int sourceSignal) const
void startNotifying(qintptr *originalSenderPtr)
QQmlNotifierEndpoint(Callback callback)
void QQmlUnbindableToUnbindableGuard_callback(QQmlNotifierEndpoint *, void **)
void QQmlVMEMetaObjectEndpoint_callback(QQmlNotifierEndpoint *, void **)
void QQmlBoundSignal_callback(QQmlNotifierEndpoint *, void **)
void QQmlUnbindableToBindableGuard_callback(QQmlNotifierEndpoint *, void **)
QT_BEGIN_NAMESPACE typedef void(* Callback)(QQmlNotifierEndpoint *, void **)
void QQmlDirtyReferenceObject_callback(QQmlNotifierEndpoint *, void **)
void QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint *, void **)
static Callback QQmlNotifier_callbacks[]