| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the test suite of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | #ifndef TESTTYPES_H |
| 29 | #define TESTTYPES_H |
| 30 | |
| 31 | #include <QtCore/qobject.h> |
| 32 | #include <QQmlParserStatus> |
| 33 | |
| 34 | class SelfRegisteringType : public QObject |
| 35 | { |
| 36 | Q_OBJECT |
| 37 | Q_PROPERTY(int value READ value WRITE setValue); |
| 38 | public: |
| 39 | SelfRegisteringType(); |
| 40 | |
| 41 | int value() const { return m_v; } |
| 42 | void setValue(int v) { m_v = v; } |
| 43 | |
| 44 | static SelfRegisteringType *me(); |
| 45 | static void clearMe(); |
| 46 | |
| 47 | private: |
| 48 | static SelfRegisteringType *m_me; |
| 49 | |
| 50 | int m_v; |
| 51 | }; |
| 52 | |
| 53 | class SelfRegisteringOuterType : public QObject |
| 54 | { |
| 55 | Q_OBJECT |
| 56 | Q_PROPERTY(QObject* value READ value WRITE setValue); |
| 57 | public: |
| 58 | SelfRegisteringOuterType(); |
| 59 | ~SelfRegisteringOuterType(); |
| 60 | |
| 61 | static bool beenDeleted; |
| 62 | |
| 63 | QObject *value() const { return m_v; } |
| 64 | void setValue(QObject *v) { m_v = v; } |
| 65 | |
| 66 | static SelfRegisteringOuterType *me(); |
| 67 | |
| 68 | private: |
| 69 | static SelfRegisteringOuterType *m_me; |
| 70 | |
| 71 | QObject *m_v; |
| 72 | }; |
| 73 | |
| 74 | class CallbackRegisteringType : public QObject |
| 75 | { |
| 76 | Q_OBJECT |
| 77 | Q_PROPERTY(int value READ value WRITE setValue) |
| 78 | public: |
| 79 | CallbackRegisteringType(); |
| 80 | |
| 81 | int value() const { return m_v; } |
| 82 | void setValue(int v) { if (m_callback) m_callback(this, m_data); m_v = v; } |
| 83 | |
| 84 | typedef void (*callback)(CallbackRegisteringType *, void *); |
| 85 | static void clearCallback(); |
| 86 | static void registerCallback(callback, void *); |
| 87 | |
| 88 | private: |
| 89 | static callback m_callback; |
| 90 | static void *m_data; |
| 91 | |
| 92 | int m_v; |
| 93 | }; |
| 94 | |
| 95 | class CompletionRegisteringType : public QObject, public QQmlParserStatus |
| 96 | { |
| 97 | Q_OBJECT |
| 98 | Q_INTERFACES(QQmlParserStatus) |
| 99 | public: |
| 100 | CompletionRegisteringType(); |
| 101 | |
| 102 | virtual void classBegin(); |
| 103 | virtual void componentComplete(); |
| 104 | |
| 105 | static CompletionRegisteringType *me(); |
| 106 | static void clearMe(); |
| 107 | |
| 108 | private: |
| 109 | static CompletionRegisteringType *m_me; |
| 110 | }; |
| 111 | |
| 112 | class CompletionCallbackType : public QObject, public QQmlParserStatus |
| 113 | { |
| 114 | Q_OBJECT |
| 115 | Q_INTERFACES(QQmlParserStatus) |
| 116 | public: |
| 117 | CompletionCallbackType(); |
| 118 | |
| 119 | virtual void classBegin(); |
| 120 | virtual void componentComplete(); |
| 121 | |
| 122 | typedef void (*callback)(CompletionCallbackType *, void *); |
| 123 | static void clearCallback(); |
| 124 | static void registerCallback(callback, void *); |
| 125 | |
| 126 | private: |
| 127 | static callback m_callback; |
| 128 | static void *m_data; |
| 129 | }; |
| 130 | |
| 131 | void registerTypes(); |
| 132 | |
| 133 | #endif // TESTTYPES_H |
| 134 | |