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 DESIGNERCUSTOMOBJECTDATA_H
5#define DESIGNERCUSTOMOBJECTDATA_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 "qquickdesignersupport_p.h"
19
20#include <QHash>
21#include <QObject>
22#include <QVariant>
23
24#include <private/qqmlanybinding_p.h>
25
26QT_BEGIN_NAMESPACE
27class QQmlContext;
28
29class QQuickDesignerCustomObjectData
30{
31public:
32 static void registerData(QObject *object);
33 static QQuickDesignerCustomObjectData *get(QObject *object);
34 static QVariant getResetValue(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName);
35 static void doResetProperty(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName);
36 static bool hasValidResetBinding(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName);
37 static bool hasBindingForProperty(QObject *object,
38 QQmlContext *context,
39 const QQuickDesignerSupport::PropertyName &propertyName,
40 bool *hasChanged);
41 static void setPropertyBinding(QObject *object,
42 QQmlContext *context,
43 const QQuickDesignerSupport::PropertyName &propertyName,
44 const QString &expression);
45 static void keepBindingFromGettingDeleted(QObject *object,
46 QQmlContext *context,
47 const QQuickDesignerSupport::PropertyName &propertyName);
48 void handleDestroyed();
49
50private:
51 QQuickDesignerCustomObjectData(QObject *object);
52 void populateResetHashes();
53 QObject *object() const;
54 QVariant getResetValue(const QQuickDesignerSupport::PropertyName &propertyName) const;
55 void doResetProperty(QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName);
56 bool hasValidResetBinding(const QQuickDesignerSupport::PropertyName &propertyName) const;
57 QQmlAnyBinding getResetBinding(const QQuickDesignerSupport::PropertyName &propertyName) const;
58 bool hasBindingForProperty(QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName, bool *hasChanged) const;
59 void setPropertyBinding(QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName, const QString &expression);
60 void keepBindingFromGettingDeleted(QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName);
61
62 QObject *m_object;
63 QHash<QQuickDesignerSupport::PropertyName, QVariant> m_resetValueHash;
64 QHash<QQuickDesignerSupport::PropertyName, QQmlAnyBinding> m_resetBindingHash;
65 mutable QHash<QQuickDesignerSupport::PropertyName, bool> m_hasBindingHash;
66};
67
68QT_END_NAMESPACE
69
70#endif // DESIGNERCUSTOMOBJECTDATA_H
71

source code of qtdeclarative/src/quick/designer/qquickdesignercustomobjectdata_p.h