qidentityproxymodel.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9