1 | // Copyright (C) 2016 Research In Motion. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | #ifndef CONF_H |
4 | #define CONF_H |
5 | |
6 | #include <QtQml/QQmlContext> |
7 | #include <QtQml/QQmlListProperty> |
8 | #include <QtQml/qqml.h> |
9 | #include <QObject> |
10 | #include <QUrl> |
11 | |
12 | class PartialScene : public QObject |
13 | { |
14 | Q_OBJECT |
15 | Q_PROPERTY(QUrl container READ container WRITE setContainer NOTIFY containerChanged) |
16 | Q_PROPERTY(QString itemType READ itemType WRITE setItemType NOTIFY itemTypeChanged) |
17 | QML_ELEMENT |
18 | QML_ADDED_IN_VERSION(1, 0) |
19 | public: |
20 | PartialScene(QObject *parent = nullptr) : QObject(parent) |
21 | {} |
22 | |
23 | const QUrl container() const { return m_container; } |
24 | const QString itemType() const { return m_itemType; } |
25 | |
26 | void setContainer(const QUrl &a) { |
27 | if (a==m_container) |
28 | return; |
29 | m_container = a; |
30 | Q_EMIT containerChanged(); |
31 | } |
32 | void setItemType(const QString &a) { |
33 | if (a==m_itemType) |
34 | return; |
35 | m_itemType = a; |
36 | Q_EMIT itemTypeChanged(); |
37 | } |
38 | |
39 | Q_SIGNALS: |
40 | void containerChanged(); |
41 | void itemTypeChanged(); |
42 | |
43 | private: |
44 | QUrl m_container; |
45 | QString m_itemType; |
46 | }; |
47 | |
48 | class Config : public QObject |
49 | { |
50 | Q_OBJECT |
51 | Q_PROPERTY(QQmlListProperty<PartialScene> sceneCompleters READ sceneCompleters) |
52 | Q_CLASSINFO("DefaultProperty", "sceneCompleters") |
53 | QML_NAMED_ELEMENT(Configuration) |
54 | QML_ADDED_IN_VERSION(1, 0) |
55 | public: |
56 | Config (QObject *parent = nullptr) : QObject(parent) {} |
57 | |
58 | QQmlListProperty<PartialScene> sceneCompleters() |
59 | { |
60 | return QQmlListProperty<PartialScene>(this, &completers); |
61 | } |
62 | |
63 | QList<PartialScene*> completers; |
64 | }; |
65 | |
66 | #endif |
67 |