OpenCoverage

qqmllistmodel_p.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmllistmodel_p.h
Source codeSwitch to Preprocessed file
LineSourceCount
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 QQMLLISTMODEL_H-
41#define QQMLLISTMODEL_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 <qqml.h>-
55#include <private/qqmlcustomparser_p.h>-
56-
57#include <QtCore/QObject>-
58#include <QtCore/QStringList>-
59#include <QtCore/QHash>-
60#include <QtCore/QList>-
61#include <QtCore/QVariant>-
62#include <QtCore/qabstractitemmodel.h>-
63-
64#include <private/qv4engine_p.h>-
65#include <private/qpodvector_p.h>-
66-
67QT_REQUIRE_CONFIG(qml_list_model);-
68-
69QT_BEGIN_NAMESPACE-
70-
71-
72class QQmlListModelWorkerAgent;-
73class ListModel;-
74class ListLayout;-
75-
76namespace QV4 {-
77struct ModelObject;-
78}-
79-
80class Q_QML_PRIVATE_EXPORT QQmlListModel : public QAbstractListModel-
81{-
82 Q_OBJECT-
83 Q_PROPERTY(int count READ count NOTIFY countChanged)-
84 Q_PROPERTY(bool dynamicRoles READ dynamicRoles WRITE setDynamicRoles)-
85-
86public:-
87 QQmlListModel(QObject *parent=nullptr);-
88 ~QQmlListModel();-
89-
90 QModelIndex index(int row, int column, const QModelIndex &parent) const override;-
91 int rowCount(const QModelIndex &parent) const override;-
92 QVariant data(const QModelIndex &index, int role) const override;-
93 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;-
94 QHash<int,QByteArray> roleNames() const override;-
95-
96 QVariant data(int index, int role) const;-
97 int count() const;-
98-
99 Q_INVOKABLE void clear();-
100 Q_INVOKABLE void remove(QQmlV4Function *args);-
101 Q_INVOKABLE void append(QQmlV4Function *args);-
102 Q_INVOKABLE void insert(QQmlV4Function *args);-
103 Q_INVOKABLE QQmlV4Handle get(int index) const;-
104 Q_INVOKABLE void set(int index, const QQmlV4Handle &);-
105 Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value);-
106 Q_INVOKABLE void move(int from, int to, int count);-
107 Q_INVOKABLE void sync();-
108-
109 QQmlListModelWorkerAgent *agent();-
110-
111 bool dynamicRoles() const { return m_dynamicRoles; }
executed 10 times by 1 test: return m_dynamicRoles;
Executed by:
  • tst_qqmllistmodel
10
112 void setDynamicRoles(bool enableDynamicRoles);-
113-
114Q_SIGNALS:-
115 void countChanged();-
116-
117private:-
118 friend class QQmlListModelParser;-
119 friend class QQmlListModelWorkerAgent;-
120 friend class ModelObject;-
121 friend struct QV4::ModelObject;-
122 friend class ModelNodeMetaObject;-
123 friend class ListModel;-
124 friend class ListElement;-
125 friend class DynamicRoleModelNode;-
126 friend class DynamicRoleModelNodeMetaObject;-
127 friend struct StringOrTranslation;-
128-
129 // Constructs a flat list model for a worker agent-
130 QQmlListModel(QQmlListModel *orig, QQmlListModelWorkerAgent *agent);-
131 QQmlListModel(const QQmlListModel *owner, ListModel *data, QV4::ExecutionEngine *engine, QObject *parent=nullptr);-
132-
133 QV4::ExecutionEngine *engine() const;-
134-
135 inline bool canMove(int from, int to, int n) const { return !(from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0); }
executed 190 times by 5 tests: return !(from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0);
Executed by:
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquicklistview
  • tst_qquickrepeater
  • tst_qquickvisualdatamodel
190
136-
137 QQmlListModelWorkerAgent *m_agent;-
138 mutable QV4::ExecutionEngine *m_engine;-
139 QQmlRefPointer<QV4::CompiledData::CompilationUnit> m_compilationUnit;-
140 bool m_mainThread;-
141 bool m_primary;-
142-
143 bool m_dynamicRoles;-
144-
145 ListLayout *m_layout;-
146 ListModel *m_listModel;-
147-
148 QVector<class DynamicRoleModelNode *> m_modelObjects;-
149 QVector<QString> m_roles;-
150-
151 struct ElementSync-
152 {-
153 DynamicRoleModelNode *src = nullptr;-
154 DynamicRoleModelNode *target = nullptr;-
155 int srcIndex = -1;-
156 int targetIndex = -1;-
157 QVector<int> changedRoles;-
158 };-
159-
160 static bool sync(QQmlListModel *src, QQmlListModel *target);-
161 static QQmlListModel *createWithOwner(QQmlListModel *newOwner);-
162-
163 void emitItemsChanged(int index, int count, const QVector<int> &roles);-
164 void emitItemsAboutToBeInserted(int index, int count);-
165 void emitItemsInserted();-
166-
167 void removeElements(int index, int removeCount);-
168};-
169-
170// ### FIXME-
171class QQmlListElement : public QObject-
172{-
173Q_OBJECT-
174};-
175-
176class QQmlListModelParser : public QQmlCustomParser-
177{-
178public:-
179 enum PropertyType {-
180 Invalid,-
181 Boolean,-
182 Number,-
183 String,-
184 Script-
185 };-
186-
187-
188 QQmlListModelParser() : QQmlCustomParser(QQmlCustomParser::AcceptsSignalHandlers) {}
executed 12 times by 6 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickrepeater
  • tst_qtqmlmodules
12
189-
190 void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;-
191 void applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;-
192-
193private:-
194 bool verifyProperty(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding);-
195 // returns true if a role was set-
196 bool applyProperty(QV4::CompiledData::CompilationUnit *compilationUnit, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding, ListModel *model, int outterElementIndex);-
197-
198 static bool definesEmptyList(const QString &);-
199-
200 QString listElementTypeName;-
201};-
202-
203QT_END_NAMESPACE-
204-
205QML_DECLARE_TYPE(QQmlListModel)-
206QML_DECLARE_TYPE(QQmlListElement)-
207-
208#endif // QQMLLISTMODEL_H-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0