itemmodels/qidentityproxymodel.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui 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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qidentityproxymodel.h" -
43 -
44#ifndef QT_NO_IDENTITYPROXYMODEL -
45 -
46#include "qitemselectionmodel.h" -
47#include <private/qabstractproxymodel_p.h> -
48 -
49QT_BEGIN_NAMESPACE -
50 -
51class QIdentityProxyModelPrivate : public QAbstractProxyModelPrivate -
52{ -
53 QIdentityProxyModelPrivate() -
54 { -
55 -
56 } -
57 -
58 Q_DECLARE_PUBLIC(QIdentityProxyModel) -
59 -
60 QList<QPersistentModelIndex> layoutChangePersistentIndexes; -
61 QModelIndexList proxyIndexes; -
62 -
63 void _q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end); -
64 void _q_sourceRowsInserted(const QModelIndex &parent, int start, int end); -
65 void _q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); -
66 void _q_sourceRowsRemoved(const QModelIndex &parent, int start, int end); -
67 void _q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest); -
68 void _q_sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest); -
69 -
70 void _q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end); -
71 void _q_sourceColumnsInserted(const QModelIndex &parent, int start, int end); -
72 void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end); -
73 void _q_sourceColumnsRemoved(const QModelIndex &parent, int start, int end); -
74 void _q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest); -
75 void _q_sourceColumnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest); -
76 -
77 void _q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles); -
78 void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last); -
79 -
80 void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint); -
81 void _q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint); -
82 void _q_sourceModelAboutToBeReset(); -
83 void _q_sourceModelReset(); -
84 -
85}; -
86 -
87/*! -
88 \since 4.8 -
89 \class QIdentityProxyModel -
90 \inmodule QtCore -
91 \brief The QIdentityProxyModel class proxies its source model unmodified -
92 -
93 \ingroup model-view -
94 -
95 QIdentityProxyModel can be used to forward the structure of a source model exactly, with no sorting, filtering or other transformation. -
96 This is similar in concept to an identity matrix where A.I = A. -
97 -
98 Because it does no sorting or filtering, this class is most suitable to proxy models which transform the data() of the source model. -
99 For example, a proxy model could be created to define the font used, or the background colour, or the tooltip etc. This removes the -
100 need to implement all data handling in the same class that creates the structure of the model, and can also be used to create -
101 re-usable components. -
102 -
103 This also provides a way to change the data in the case where a source model is supplied by a third party which can not be modified. -
104 -
105 \snippet code/src_gui_itemviews_qidentityproxymodel.cpp 0 -
106 -
107 \sa QAbstractProxyModel, {Model/View Programming}, QAbstractItemModel -
108 -
109*/ -
110 -
111/*! -
112 Constructs an identity model with the given \a parent. -
113*/ -
114QIdentityProxyModel::QIdentityProxyModel(QObject* parent) -
115 : QAbstractProxyModel(*new QIdentityProxyModelPrivate, parent) -
116{ -
117 -
118} -
119 -
120/*! -
121 \internal -
122 */ -
123QIdentityProxyModel::QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent) -
124 : QAbstractProxyModel(dd, parent) -
125{ -
126 -
127} -
128 -
129/*! -
130 Destroys this identity model. -
131*/ -
132QIdentityProxyModel::~QIdentityProxyModel() -
133{ -
134} -
135 -
136/*! -
137 \reimp -
138 */ -
139int QIdentityProxyModel::columnCount(const QModelIndex& parent) const -
140{ -
141 Q_ASSERT(parent.isValid() ? parent.model() == this : true); -
142 Q_D(const QIdentityProxyModel); -
143 return d->model->columnCount(mapToSource(parent)); -
144} -
145 -
146/*! -
147 \reimp -
148 */ -
149bool QIdentityProxyModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) -
150{ -
151 Q_ASSERT(parent.isValid() ? parent.model() == this : true); -
152 Q_D(QIdentityProxyModel); -
153 return d->model->dropMimeData(data, action, row, column, mapToSource(parent)); -
154} -
155 -
156/*! -
157 \reimp -
158 */ -
159QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex& parent) const -
160{ -
161 Q_ASSERT(parent.isValid() ? parent.model() == this : true); -
162 Q_D(const QIdentityProxyModel); -
163 if (!hasIndex(row, column, parent)) -
164 return QModelIndex(); -
165 const QModelIndex sourceParent = mapToSource(parent); -
166 const QModelIndex sourceIndex = d->model->index(row, column, sourceParent); -
167 Q_ASSERT(sourceIndex.isValid()); -
168 return mapFromSource(sourceIndex); -
169} -
170 -
171/*! -
172 \reimp -
173 */ -
174QModelIndex QIdentityProxyModel::sibling(int row, int column, const QModelIndex &idx) const -
175{ -
176 Q_D(const QIdentityProxyModel); -
177 return mapFromSource(d->model->sibling(row, column, mapToSource(idx))); -
178} -
179 -
180/*! -
181 \reimp -
182 */ -
183bool QIdentityProxyModel::insertColumns(int column, int count, const QModelIndex& parent) -
184{ -
185 Q_ASSERT(parent.isValid() ? parent.model() == this : true); -
186 Q_D(QIdentityProxyModel); -
187 return d->model->insertColumns(column, count, mapToSource(parent)); -
188} -
189 -
190/*! -
191 \reimp -
192 */ -
193bool QIdentityProxyModel::insertRows(int row, int count, const QModelIndex& parent) -
194{ -
195 Q_ASSERT(parent.isValid() ? parent.model() == this : true); -
196 Q_D(QIdentityProxyModel); -
197 return d->model->insertRows(row, count, mapToSource(parent)); -
198} -
199 -
200/*! -
201 \reimp -
202 */ -
203QModelIndex QIdentityProxyModel::mapFromSource(const QModelIndex& sourceIndex) const -
204{ -
205 Q_D(const QIdentityProxyModel); -
206 if (!d->model || !sourceIndex.isValid()) -
207 return QModelIndex(); -
208 -
209 Q_ASSERT(sourceIndex.model() == d->model); -
210 return createIndex(sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer()); -
211} -
212 -
213/*! -
214 \reimp -
215 */ -
216QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection& selection) const -
217{ -
218 Q_D(const QIdentityProxyModel); -
219 QItemSelection proxySelection; -
220 -
221 if (!d->model) -
222 return proxySelection; -
223 -
224 QItemSelection::const_iterator it = selection.constBegin(); -
225 const QItemSelection::const_iterator end = selection.constEnd(); -
226 for ( ; it != end; ++it) { -
227 Q_ASSERT(it->model() == d->model); -
228 const QItemSelectionRange range(mapFromSource(it->topLeft()), mapFromSource(it->bottomRight())); -
229 proxySelection.append(range); -
230 } -
231 -
232 return proxySelection; -
233} -
234 -
235/*! -
236 \reimp -
237 */ -
238QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection& selection) const -
239{ -
240 Q_D(const QIdentityProxyModel); -
241 QItemSelection sourceSelection; -
242 -
243 if (!d->model) -
244 return sourceSelection; -
245 -
246 QItemSelection::const_iterator it = selection.constBegin(); -
247 const QItemSelection::const_iterator end = selection.constEnd(); -
248 for ( ; it != end; ++it) { -
249 Q_ASSERT(it->model() == this); -
250 const QItemSelectionRange range(mapToSource(it->topLeft()), mapToSource(it->bottomRight())); -
251 sourceSelection.append(range); -
252 } -
253 -
254 return sourceSelection; -
255} -
256 -
257/*! -
258 \reimp -
259 */ -
260QModelIndex QIdentityProxyModel::mapToSource(const QModelIndex& proxyIndex) const -
261{ -
262 Q_D(const QIdentityProxyModel); -
263 if (!d->model || !proxyIndex.isValid()) -
264 return QModelIndex(); -
265 Q_ASSERT(proxyIndex.model() == this); -
266 return d->model->createIndex(proxyIndex.row(), proxyIndex.column(), proxyIndex.internalPointer()); -
267} -
268 -
269/*! -
270 \reimp -
271 */ -
272QModelIndexList QIdentityProxyModel::match(const QModelIndex& start, int role, const QVariant& value, int hits, Qt::MatchFlags flags) const -
273{ -
274 Q_D(const QIdentityProxyModel); -
275 Q_ASSERT(start.isValid() ? start.model() == this : true); -
276 if (!d->model) -
277 return QModelIndexList(); -
278 -
279 const QModelIndexList sourceList = d->model->match(mapToSource(start), role, value, hits, flags); -
280 QModelIndexList::const_iterator it = sourceList.constBegin(); -
281 const QModelIndexList::const_iterator end = sourceList.constEnd(); -
282 QModelIndexList proxyList; -
283 for ( ; it != end; ++it) -
284 proxyList.append(mapFromSource(*it)); -
285 return proxyList; -
286} -
287 -
288/*! -
289 \reimp -
290 */ -
291QModelIndex QIdentityProxyModel::parent(const QModelIndex& child) const -
292{ -
293 Q_ASSERT(child.isValid() ? child.model() == this : true); -
294 const QModelIndex sourceIndex = mapToSource(child); -
295 const QModelIndex sourceParent = sourceIndex.parent(); -
296 return mapFromSource(sourceParent); -
297} -
298 -
299/*! -
300 \reimp -
301 */ -
302bool QIdentityProxyModel::removeColumns(int column, int count, const QModelIndex& parent) -
303{ -
304 Q_ASSERT(parent.isValid() ? parent.model() == this : true); -
305 Q_D(QIdentityProxyModel); -
306 return d->model->removeColumns(column, count, mapToSource(parent)); -
307} -
308 -
309/*! -
310 \reimp -
311 */ -
312bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex& parent) -
313{ -
314 Q_ASSERT(parent.isValid() ? parent.model() == this : true); -
315 Q_D(QIdentityProxyModel); -
316 return d->model->removeRows(row, count, mapToSource(parent)); -
317} -
318 -
319/*! -
320 \reimp -
321 */ -
322int QIdentityProxyModel::rowCount(const QModelIndex& parent) const -
323{ -
324 Q_ASSERT(parent.isValid() ? parent.model() == this : true); -
325 Q_D(const QIdentityProxyModel); -
326 return d->model->rowCount(mapToSource(parent)); -
327} -
328 -
329/*! -
330 \reimp -
331 */ -
332QVariant QIdentityProxyModel::headerData(int section, Qt::Orientation orientation, int role) const -
333{ -
334 Q_D(const QIdentityProxyModel); -
335 return d->model->headerData(section, orientation, role); -
336} -
337 -
338/*! -
339 \reimp -
340 */ -
341void QIdentityProxyModel::setSourceModel(QAbstractItemModel* newSourceModel) -
342{ -
343 beginResetModel();
executed (the execution status of this line is deduced): beginResetModel();
-
344 -
345 if (sourceModel()) {
evaluated: sourceModel()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:3
3-5
346 disconnect(sourceModel(), SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""rowsAboutToBeInserted(QModelIndex,int,int)",
-
347 this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)");
-
348 disconnect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""rowsInserted(QModelIndex,int,int)",
-
349 this, SLOT(_q_sourceRowsInserted(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceRowsInserted(QModelIndex,int,int)");
-
350 disconnect(sourceModel(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""rowsAboutToBeRemoved(QModelIndex,int,int)",
-
351 this, SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)");
-
352 disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""rowsRemoved(QModelIndex,int,int)",
-
353 this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceRowsRemoved(QModelIndex,int,int)");
-
354 disconnect(sourceModel(), SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)",
-
355 this, SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)");
-
356 disconnect(sourceModel(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""rowsMoved(QModelIndex,int,int,QModelIndex,int)",
-
357 this, SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)");
-
358 disconnect(sourceModel(), SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""columnsAboutToBeInserted(QModelIndex,int,int)",
-
359 this, SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)");
-
360 disconnect(sourceModel(), SIGNAL(columnsInserted(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""columnsInserted(QModelIndex,int,int)",
-
361 this, SLOT(_q_sourceColumnsInserted(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsInserted(QModelIndex,int,int)");
-
362 disconnect(sourceModel(), SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""columnsAboutToBeRemoved(QModelIndex,int,int)",
-
363 this, SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)");
-
364 disconnect(sourceModel(), SIGNAL(columnsRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""columnsRemoved(QModelIndex,int,int)",
-
365 this, SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsRemoved(QModelIndex,int,int)");
-
366 disconnect(sourceModel(), SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)",
-
367 this, SLOT(_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)");
-
368 disconnect(sourceModel(), SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""columnsMoved(QModelIndex,int,int,QModelIndex,int)",
-
369 this, SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)");
-
370 disconnect(sourceModel(), SIGNAL(modelAboutToBeReset()),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""modelAboutToBeReset()",
-
371 this, SLOT(_q_sourceModelAboutToBeReset()));
executed (the execution status of this line is deduced): this, "1""_q_sourceModelAboutToBeReset()");
-
372 disconnect(sourceModel(), SIGNAL(modelReset()),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""modelReset()",
-
373 this, SLOT(_q_sourceModelReset()));
executed (the execution status of this line is deduced): this, "1""_q_sourceModelReset()");
-
374 disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),,QVector<int>)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""dataChanged(QModelIndex,QModelIndex,QVector<int>)",
-
375 this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));,QVector<int>)));
executed (the execution status of this line is deduced): this, "1""_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)");
-
376 disconnect(sourceModel(), SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""headerDataChanged(Qt::Orientation,int,int)",
-
377 this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
executed (the execution status of this line is deduced): this, "1""_q_sourceHeaderDataChanged(Qt::Orientation,int,int)");
-
378 disconnect(sourceModel(), SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)",
-
379 this, SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
executed (the execution status of this line is deduced): this, "1""_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)");
-
380 disconnect(sourceModel(), SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
executed (the execution status of this line is deduced): disconnect(sourceModel(), "2""layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)",
-
381 this, SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
executed (the execution status of this line is deduced): this, "1""_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)");
-
382 }
executed: }
Execution Count:5
5
383 -
384 QAbstractProxyModel::setSourceModel(newSourceModel);
executed (the execution status of this line is deduced): QAbstractProxyModel::setSourceModel(newSourceModel);
-
385 -
386 if (sourceModel()) {
evaluated: sourceModel()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:3
3-5
387 connect(sourceModel(), SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""rowsAboutToBeInserted(QModelIndex,int,int)",
-
388 SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)));
executed (the execution status of this line is deduced): "1""_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)");
-
389 connect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""rowsInserted(QModelIndex,int,int)",
-
390 SLOT(_q_sourceRowsInserted(QModelIndex,int,int)));
executed (the execution status of this line is deduced): "1""_q_sourceRowsInserted(QModelIndex,int,int)");
-
391 connect(sourceModel(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""rowsAboutToBeRemoved(QModelIndex,int,int)",
-
392 SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): "1""_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)");
-
393 connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""rowsRemoved(QModelIndex,int,int)",
-
394 SLOT(_q_sourceRowsRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): "1""_q_sourceRowsRemoved(QModelIndex,int,int)");
-
395 connect(sourceModel(), SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)",
-
396 SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
executed (the execution status of this line is deduced): "1""_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)");
-
397 connect(sourceModel(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""rowsMoved(QModelIndex,int,int,QModelIndex,int)",
-
398 SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)));
executed (the execution status of this line is deduced): "1""_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)");
-
399 connect(sourceModel(), SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""columnsAboutToBeInserted(QModelIndex,int,int)",
-
400 SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)));
executed (the execution status of this line is deduced): "1""_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)");
-
401 connect(sourceModel(), SIGNAL(columnsInserted(QModelIndex,int,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""columnsInserted(QModelIndex,int,int)",
-
402 SLOT(_q_sourceColumnsInserted(QModelIndex,int,int)));
executed (the execution status of this line is deduced): "1""_q_sourceColumnsInserted(QModelIndex,int,int)");
-
403 connect(sourceModel(), SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""columnsAboutToBeRemoved(QModelIndex,int,int)",
-
404 SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): "1""_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)");
-
405 connect(sourceModel(), SIGNAL(columnsRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""columnsRemoved(QModelIndex,int,int)",
-
406 SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): "1""_q_sourceColumnsRemoved(QModelIndex,int,int)");
-
407 connect(sourceModel(), SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)",
-
408 SLOT(_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
executed (the execution status of this line is deduced): "1""_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)");
-
409 connect(sourceModel(), SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""columnsMoved(QModelIndex,int,int,QModelIndex,int)",
-
410 SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)));
executed (the execution status of this line is deduced): "1""_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)");
-
411 connect(sourceModel(), SIGNAL(modelAboutToBeReset()),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""modelAboutToBeReset()",
-
412 SLOT(_q_sourceModelAboutToBeReset()));
executed (the execution status of this line is deduced): "1""_q_sourceModelAboutToBeReset()");
-
413 connect(sourceModel(), SIGNAL(modelReset()),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""modelReset()",
-
414 SLOT(_q_sourceModelReset()));
executed (the execution status of this line is deduced): "1""_q_sourceModelReset()");
-
415 connect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),,QVector<int>)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""dataChanged(QModelIndex,QModelIndex,QVector<int>)",
-
416 SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));,QVector<int>)));
executed (the execution status of this line is deduced): "1""_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)");
-
417 connect(sourceModel(), SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""headerDataChanged(Qt::Orientation,int,int)",
-
418 SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
executed (the execution status of this line is deduced): "1""_q_sourceHeaderDataChanged(Qt::Orientation,int,int)");
-
419 connect(sourceModel(), SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)",
-
420 SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
executed (the execution status of this line is deduced): "1""_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)");
-
421 connect(sourceModel(), SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
executed (the execution status of this line is deduced): connect(sourceModel(), "2""layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)",
-
422 SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
executed (the execution status of this line is deduced): "1""_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)");
-
423 }
executed: }
Execution Count:5
5
424 -
425 endResetModel();
executed (the execution status of this line is deduced): endResetModel();
-
426}
executed: }
Execution Count:8
8
427 -
428void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end) -
429{ -
430 Q_ASSERT(parent.isValid() ? parent.model() == model : true); -
431 Q_Q(QIdentityProxyModel); -
432 q->beginInsertColumns(q->mapFromSource(parent), start, end); -
433} -
434 -
435void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -
436{ -
437 Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true); -
438 Q_ASSERT(destParent.isValid() ? destParent.model() == model : true); -
439 Q_Q(QIdentityProxyModel); -
440 q->beginMoveColumns(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destParent), dest); -
441} -
442 -
443void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end) -
444{ -
445 Q_ASSERT(parent.isValid() ? parent.model() == model : true); -
446 Q_Q(QIdentityProxyModel); -
447 q->beginRemoveColumns(q->mapFromSource(parent), start, end); -
448} -
449 -
450void QIdentityProxyModelPrivate::_q_sourceColumnsInserted(const QModelIndex &parent, int start, int end) -
451{ -
452 Q_ASSERT(parent.isValid() ? parent.model() == model : true); -
453 Q_Q(QIdentityProxyModel); -
454 Q_UNUSED(parent) -
455 Q_UNUSED(start) -
456 Q_UNUSED(end) -
457 q->endInsertColumns(); -
458} -
459 -
460void QIdentityProxyModelPrivate::_q_sourceColumnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -
461{ -
462 Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true); -
463 Q_ASSERT(destParent.isValid() ? destParent.model() == model : true); -
464 Q_Q(QIdentityProxyModel); -
465 Q_UNUSED(sourceParent) -
466 Q_UNUSED(sourceStart) -
467 Q_UNUSED(sourceEnd) -
468 Q_UNUSED(destParent) -
469 Q_UNUSED(dest) -
470 q->endMoveColumns(); -
471} -
472 -
473void QIdentityProxyModelPrivate::_q_sourceColumnsRemoved(const QModelIndex &parent, int start, int end) -
474{ -
475 Q_ASSERT(parent.isValid() ? parent.model() == model : true); -
476 Q_Q(QIdentityProxyModel); -
477 Q_UNUSED(parent) -
478 Q_UNUSED(start) -
479 Q_UNUSED(end) -
480 q->endRemoveColumns(); -
481} -
482 -
483void QIdentityProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) -
484{ -
485 Q_ASSERT(topLeft.isValid() ? topLeft.model() == model : true);
executed (the execution status of this line is deduced): qt_noop();
-
486 Q_ASSERT(bottomRight.isValid() ? bottomRight.model() == model : true);
executed (the execution status of this line is deduced): qt_noop();
-
487 Q_Q(QIdentityProxyModel);
executed (the execution status of this line is deduced): QIdentityProxyModel * const q = q_func();
-
488 q->dataChanged(q->mapFromSource(topLeft), q->mapFromSource(bottomRight));), roles);
executed (the execution status of this line is deduced): q->dataChanged(q->mapFromSource(topLeft), q->mapFromSource(bottomRight), roles);
-
489}
executed: }
Execution Count:1
1
490 -
491void QIdentityProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last) -
492{ -
493 Q_Q(QIdentityProxyModel); -
494 q->headerDataChanged(orientation, first, last); -
495} -
496 -
497void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint) -
498{ -
499 Q_Q(QIdentityProxyModel); -
500 -
501 foreach(const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) { -
502 proxyIndexes << proxyPersistentIndex; -
503 Q_ASSERT(proxyPersistentIndex.isValid()); -
504 const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); -
505 Q_ASSERT(srcPersistentIndex.isValid()); -
506 layoutChangePersistentIndexes << srcPersistentIndex; -
507 } -
508 -
509 QList<QPersistentModelIndex> parents; -
510 parents.reserve(sourceParents.size()); -
511 foreach (const QPersistentModelIndex &parent, sourceParents) { -
512 if (!parent.isValid()) { -
513 parents << QPersistentModelIndex(); -
514 continue; -
515 } -
516 const QModelIndex mappedParent = q->mapFromSource(parent); -
517 Q_ASSERT(mappedParent.isValid()); -
518 parents << mappedParent; -
519 } -
520 -
521 q->layoutAboutToBeChanged(parents, hint); -
522} -
523 -
524void QIdentityProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint) -
525{ -
526 Q_Q(QIdentityProxyModel); -
527 -
528 for (int i = 0; i < proxyIndexes.size(); ++i) { -
529 q->changePersistentIndex(proxyIndexes.at(i), q->mapFromSource(layoutChangePersistentIndexes.at(i))); -
530 } -
531 -
532 layoutChangePersistentIndexes.clear(); -
533 proxyIndexes.clear(); -
534 -
535 QList<QPersistentModelIndex> parents; -
536 parents.reserve(sourceParents.size()); -
537 foreach (const QPersistentModelIndex &parent, sourceParents) { -
538 if (!parent.isValid()) { -
539 parents << QPersistentModelIndex(); -
540 continue; -
541 } -
542 const QModelIndex mappedParent = q->mapFromSource(parent); -
543 Q_ASSERT(mappedParent.isValid()); -
544 parents << mappedParent; -
545 } -
546 -
547 q->layoutChanged(parents, hint); -
548} -
549 -
550void QIdentityProxyModelPrivate::_q_sourceModelAboutToBeReset() -
551{ -
552 Q_Q(QIdentityProxyModel); -
553 q->beginResetModel(); -
554} -
555 -
556void QIdentityProxyModelPrivate::_q_sourceModelReset() -
557{ -
558 Q_Q(QIdentityProxyModel); -
559 q->endResetModel(); -
560} -
561 -
562void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end) -
563{ -
564 Q_ASSERT(parent.isValid() ? parent.model() == model : true); -
565 Q_Q(QIdentityProxyModel); -
566 q->beginInsertRows(q->mapFromSource(parent), start, end); -
567} -
568 -
569void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -
570{ -
571 Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true); -
572 Q_ASSERT(destParent.isValid() ? destParent.model() == model : true); -
573 Q_Q(QIdentityProxyModel); -
574 q->beginMoveRows(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destParent), dest); -
575} -
576 -
577void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) -
578{ -
579 Q_ASSERT(parent.isValid() ? parent.model() == model : true); -
580 Q_Q(QIdentityProxyModel); -
581 q->beginRemoveRows(q->mapFromSource(parent), start, end); -
582} -
583 -
584void QIdentityProxyModelPrivate::_q_sourceRowsInserted(const QModelIndex &parent, int start, int end) -
585{ -
586 Q_ASSERT(parent.isValid() ? parent.model() == model : true); -
587 Q_Q(QIdentityProxyModel); -
588 Q_UNUSED(parent) -
589 Q_UNUSED(start) -
590 Q_UNUSED(end) -
591 q->endInsertRows(); -
592} -
593 -
594void QIdentityProxyModelPrivate::_q_sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -
595{ -
596 Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true); -
597 Q_ASSERT(destParent.isValid() ? destParent.model() == model : true); -
598 Q_Q(QIdentityProxyModel); -
599 Q_UNUSED(sourceParent) -
600 Q_UNUSED(sourceStart) -
601 Q_UNUSED(sourceEnd) -
602 Q_UNUSED(destParent) -
603 Q_UNUSED(dest) -
604 q->endMoveRows(); -
605} -
606 -
607void QIdentityProxyModelPrivate::_q_sourceRowsRemoved(const QModelIndex &parent, int start, int end) -
608{ -
609 Q_ASSERT(parent.isValid() ? parent.model() == model : true); -
610 Q_Q(QIdentityProxyModel); -
611 Q_UNUSED(parent) -
612 Q_UNUSED(start) -
613 Q_UNUSED(end) -
614 q->endRemoveRows(); -
615} -
616 -
617QT_END_NAMESPACE -
618 -
619#include "moc_qidentityproxymodel.cpp" -
620 -
621#endif // QT_NO_IDENTITYPROXYMODEL -
622 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial