1 | // Copyright (C) 2022 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 QQMLPROPERTYTOPROPERTYBINDINDING_P_H |
5 | #define QQMLPROPERTYTOPROPERTYBINDINDING_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 <private/qqmlabstractbinding_p.h> |
19 | #include <private/qqmlnotifier_p.h> |
20 | #include <QtCore/qproperty.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | class Q_QML_PRIVATE_EXPORT QQmlPropertyToPropertyBinding |
25 | : public QQmlAbstractBinding, public QQmlNotifierEndpoint |
26 | { |
27 | public: |
28 | QQmlPropertyToPropertyBinding( |
29 | QQmlEngine *engine, QObject *sourceObject, int sourcePropertyIndex, |
30 | QObject *targetObject, int targetPropertyIndex); |
31 | |
32 | Kind kind() const final; |
33 | void setEnabled(bool e, QQmlPropertyData::WriteFlags flags) final; |
34 | |
35 | void update(QQmlPropertyData::WriteFlags flags = QQmlPropertyData::DontRemoveBinding); |
36 | |
37 | private: |
38 | static void trigger(QPropertyObserver *, QUntypedPropertyData *); |
39 | |
40 | void captureProperty( |
41 | const QMetaObject *sourceMetaObject, int notifyIndex, |
42 | bool isSourceBindable, bool isTargetBindable); |
43 | |
44 | struct Observer : QPropertyObserver { |
45 | static void trigger(QPropertyObserver *observer, QUntypedPropertyData *); |
46 | Observer(QQmlPropertyToPropertyBinding *binding) |
47 | : QPropertyObserver(trigger) |
48 | , binding(binding) |
49 | { |
50 | } |
51 | QQmlPropertyToPropertyBinding *binding = nullptr; |
52 | }; |
53 | |
54 | std::unique_ptr<Observer> observer; |
55 | QQmlEngine *m_engine = nullptr; |
56 | QObject *m_sourceObject = nullptr; |
57 | int m_sourcePropertyIndex = -1; |
58 | }; |
59 | |
60 | void QQmlPropertyGuard_callback(QQmlNotifierEndpoint *e, void **); |
61 | |
62 | QT_END_NAMESPACE |
63 | |
64 | #endif |
65 | |