| 1 | // Copyright (C) 2021 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 QQMLCPPONASSIGNMENT_P_H |
| 5 | #define QQMLCPPONASSIGNMENT_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/qqmlpropertyvalueinterceptor_p.h> |
| 19 | #include <QtQml/qqmlpropertyvaluesource.h> |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | /*! \internal |
| 24 | |
| 25 | Helper class that provides setTarget() functionality for both value |
| 26 | interceptors and value sources. |
| 27 | |
| 28 | Property value sources could be problematic because QQuickAbstractAnimation |
| 29 | changes access specifier of QQmlPropertyValueSource::setTarget() to private |
| 30 | (unintentionally?). This API allows to avoid manual casts to base types as |
| 31 | the C++ compiler would implicitly cast derived classes in this case. |
| 32 | */ |
| 33 | struct Q_QML_EXPORT QQmlCppOnAssignmentHelper |
| 34 | { |
| 35 | // TODO: in theory, this API might just accept QObject * and int that would |
| 36 | // give the QMetaProperty. using the meta property, one could create |
| 37 | // QQmlProperty with a call to QQmlProperty::restore() (if there's an |
| 38 | // overload that takes QMetaProperty instead of QQmlPropertyData - which is |
| 39 | // also possible to add by using QQmlPropertyData::load()) |
| 40 | static void set(QQmlPropertyValueInterceptor *interceptor, const QQmlProperty &property); |
| 41 | static void set(QQmlPropertyValueSource *valueSource, const QQmlProperty &property); |
| 42 | }; |
| 43 | |
| 44 | QT_END_NAMESPACE |
| 45 | |
| 46 | #endif // QQMLCPPONASSIGNMENT_P_H |
| 47 | |