Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmlobjectmodel_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
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 QtQml module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
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 Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
24 | ** | - | ||||||
25 | ** GNU General Public License Usage | - | ||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
35 | ** | - | ||||||
36 | ** $QT_END_LICENSE$ | - | ||||||
37 | ** | - | ||||||
38 | ****************************************************************************/ | - | ||||||
39 | - | |||||||
40 | #ifndef QQMLINSTANCEMODEL_P_H | - | ||||||
41 | #define QQMLINSTANCEMODEL_P_H | - | ||||||
42 | - | |||||||
43 | // | - | ||||||
44 | // W A R N I N G | - | ||||||
45 | // ------------- | - | ||||||
46 | // | - | ||||||
47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
48 | // implementation detail. This header file may change from version to | - | ||||||
49 | // version without notice, or even be removed. | - | ||||||
50 | // | - | ||||||
51 | // We mean it. | - | ||||||
52 | // | - | ||||||
53 | - | |||||||
54 | #include <private/qtqmlglobal_p.h> | - | ||||||
55 | #include <private/qqmlincubator_p.h> | - | ||||||
56 | #include <QtQml/qqml.h> | - | ||||||
57 | #include <QtCore/qobject.h> | - | ||||||
58 | - | |||||||
59 | QT_BEGIN_NAMESPACE | - | ||||||
60 | - | |||||||
61 | class QObject; | - | ||||||
62 | class QQmlChangeSet; | - | ||||||
63 | class QAbstractItemModel; | - | ||||||
64 | - | |||||||
65 | class Q_QML_PRIVATE_EXPORT QQmlInstanceModel : public QObject | - | ||||||
66 | { | - | ||||||
67 | Q_OBJECT | - | ||||||
68 | - | |||||||
69 | Q_PROPERTY(int count READ count NOTIFY countChanged) | - | ||||||
70 | - | |||||||
71 | public: | - | ||||||
72 | virtual ~QQmlInstanceModel() {} | - | ||||||
73 | - | |||||||
74 | enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 }; | - | ||||||
75 | Q_DECLARE_FLAGS(ReleaseFlags, ReleaseFlag) | - | ||||||
76 | - | |||||||
77 | virtual int count() const = 0; | - | ||||||
78 | virtual bool isValid() const = 0; | - | ||||||
79 | virtual QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) = 0; | - | ||||||
80 | virtual ReleaseFlags release(QObject *object) = 0; | - | ||||||
81 | virtual void cancel(int) {} | - | ||||||
82 | virtual QString stringValue(int, const QString &) = 0; | - | ||||||
83 | virtual void setWatchedRoles(const QList<QByteArray> &roles) = 0; | - | ||||||
84 | virtual QQmlIncubator::Status incubationStatus(int index) = 0; | - | ||||||
85 | - | |||||||
86 | virtual int indexOf(QObject *object, QObject *objectContext) const = 0; | - | ||||||
87 | virtual const QAbstractItemModel *abstractItemModel() const { return nullptr; } never executed: return nullptr; | 0 | ||||||
88 | - | |||||||
89 | Q_SIGNALS: | - | ||||||
90 | void countChanged(); | - | ||||||
91 | void modelUpdated(const QQmlChangeSet &changeSet, bool reset); | - | ||||||
92 | void createdItem(int index, QObject *object); | - | ||||||
93 | void initItem(int index, QObject *object); | - | ||||||
94 | void destroyingItem(QObject *object); | - | ||||||
95 | - | |||||||
96 | protected: | - | ||||||
97 | QQmlInstanceModel(QObjectPrivate &dd, QObject *parent = nullptr) | - | ||||||
98 | : QObject(dd, parent) {} executed 6042 times by 28 tests: end of block Executed by:
| 6042 | ||||||
99 | - | |||||||
100 | private: | - | ||||||
101 | Q_DISABLE_COPY(QQmlInstanceModel) | - | ||||||
102 | }; | - | ||||||
103 | - | |||||||
104 | class QQmlObjectModelAttached; | - | ||||||
105 | class QQmlObjectModelPrivate; | - | ||||||
106 | class Q_QML_PRIVATE_EXPORT QQmlObjectModel : public QQmlInstanceModel | - | ||||||
107 | { | - | ||||||
108 | Q_OBJECT | - | ||||||
109 | Q_DECLARE_PRIVATE(QQmlObjectModel) executed 754 times by 6 tests: return reinterpret_cast<QQmlObjectModelPrivate *>(qGetPtrHelper(d_ptr)); Executed by:
executed 5898 times by 6 tests: return reinterpret_cast<const QQmlObjectModelPrivate *>(qGetPtrHelper(d_ptr)); Executed by:
| 754-5898 | ||||||
110 | - | |||||||
111 | Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged DESIGNABLE false) | - | ||||||
112 | Q_CLASSINFO("DefaultProperty", "children") | - | ||||||
113 | - | |||||||
114 | public: | - | ||||||
115 | QQmlObjectModel(QObject *parent=nullptr); | - | ||||||
116 | ~QQmlObjectModel() {} | - | ||||||
117 | - | |||||||
118 | int count() const override; | - | ||||||
119 | bool isValid() const override; | - | ||||||
120 | QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; | - | ||||||
121 | ReleaseFlags release(QObject *object) override; | - | ||||||
122 | QString stringValue(int index, const QString &role) override; | - | ||||||
123 | void setWatchedRoles(const QList<QByteArray> &) override {} | - | ||||||
124 | QQmlIncubator::Status incubationStatus(int index) override; | - | ||||||
125 | - | |||||||
126 | int indexOf(QObject *object, QObject *objectContext) const override; | - | ||||||
127 | - | |||||||
128 | QQmlListProperty<QObject> children(); | - | ||||||
129 | - | |||||||
130 | static QQmlObjectModelAttached *qmlAttachedProperties(QObject *obj); | - | ||||||
131 | - | |||||||
132 | Q_REVISION(3) Q_INVOKABLE QObject *get(int index) const; | - | ||||||
133 | Q_REVISION(3) Q_INVOKABLE void append(QObject *object); | - | ||||||
134 | Q_REVISION(3) Q_INVOKABLE void insert(int index, QObject *object); | - | ||||||
135 | Q_REVISION(3) Q_INVOKABLE void move(int from, int to, int n = 1); | - | ||||||
136 | Q_REVISION(3) Q_INVOKABLE void remove(int index, int n = 1); | - | ||||||
137 | - | |||||||
138 | public Q_SLOTS: | - | ||||||
139 | Q_REVISION(3) void clear(); | - | ||||||
140 | - | |||||||
141 | Q_SIGNALS: | - | ||||||
142 | void childrenChanged(); | - | ||||||
143 | - | |||||||
144 | private: | - | ||||||
145 | Q_DISABLE_COPY(QQmlObjectModel) | - | ||||||
146 | }; | - | ||||||
147 | - | |||||||
148 | class QQmlObjectModelAttached : public QObject | - | ||||||
149 | { | - | ||||||
150 | Q_OBJECT | - | ||||||
151 | - | |||||||
152 | public: | - | ||||||
153 | QQmlObjectModelAttached(QObject *parent) | - | ||||||
154 | : QObject(parent), m_index(-1) {} executed 154 times by 6 tests: end of block Executed by:
| 154 | ||||||
155 | ~QQmlObjectModelAttached() { | - | ||||||
156 | attachedProperties.remove(parent()); | - | ||||||
157 | } executed 154 times by 6 tests: end of block Executed by:
| 154 | ||||||
158 | - | |||||||
159 | Q_PROPERTY(int index READ index NOTIFY indexChanged) | - | ||||||
160 | int index() const { return m_index; } executed 52 times by 3 tests: return m_index; Executed by:
| 52 | ||||||
161 | void setIndex(int idx) { | - | ||||||
162 | if (m_index != idx) {
| 0-240 | ||||||
163 | m_index = idx; | - | ||||||
164 | Q_EMIT indexChanged(); | - | ||||||
165 | } executed 240 times by 6 tests: end of block Executed by:
| 240 | ||||||
166 | } executed 240 times by 6 tests: end of block Executed by:
| 240 | ||||||
167 | - | |||||||
168 | static QQmlObjectModelAttached *properties(QObject *obj) { | - | ||||||
169 | QQmlObjectModelAttached *rv = attachedProperties.value(obj); | - | ||||||
170 | if (!rv) {
| 138-154 | ||||||
171 | rv = new QQmlObjectModelAttached(obj); | - | ||||||
172 | attachedProperties.insert(obj, rv); | - | ||||||
173 | } executed 154 times by 6 tests: end of block Executed by:
| 154 | ||||||
174 | return rv; executed 292 times by 6 tests: return rv; Executed by:
| 292 | ||||||
175 | } | - | ||||||
176 | - | |||||||
177 | Q_SIGNALS: | - | ||||||
178 | void indexChanged(); | - | ||||||
179 | - | |||||||
180 | public: | - | ||||||
181 | int m_index; | - | ||||||
182 | - | |||||||
183 | static QHash<QObject*, QQmlObjectModelAttached*> attachedProperties; | - | ||||||
184 | }; | - | ||||||
185 | - | |||||||
186 | - | |||||||
187 | QT_END_NAMESPACE | - | ||||||
188 | - | |||||||
189 | QML_DECLARE_TYPE(QQmlInstanceModel) | - | ||||||
190 | QML_DECLARE_TYPE(QQmlObjectModel) | - | ||||||
191 | QML_DECLARE_TYPEINFO(QQmlObjectModel, QML_HAS_ATTACHED_PROPERTIES) | - | ||||||
192 | - | |||||||
193 | #endif // QQMLINSTANCEMODEL_P_H | - | ||||||
Source code | Switch to Preprocessed file |