qabstractproxymodel.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/itemmodels/qabstractproxymodel.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
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 "qabstractproxymodel.h"-
35-
36#ifndef QT_NO_PROXYMODEL-
37-
38#include "qitemselectionmodel.h"-
39#include <private/qabstractproxymodel_p.h>-
40#include <QtCore/QSize>-
41#include <QtCore/QStringList>-
42-
43-
44QT_BEGIN_NAMESPACE-
45-
46/*!-
47 \since 4.1-
48 \class QAbstractProxyModel-
49 \brief The QAbstractProxyModel class provides a base class for proxy item-
50 models that can do sorting, filtering or other data processing tasks.-
51 \ingroup model-view-
52 \inmodule QtCore-
53-
54 This class defines the standard interface that proxy models must use to be-
55 able to interoperate correctly with other model/view components. It is not-
56 supposed to be instantiated directly.-
57-
58 All standard proxy models are derived from the QAbstractProxyModel class.-
59 If you need to create a new proxy model class, it is usually better to-
60 subclass an existing class that provides the closest behavior to the one-
61 you want to provide.-
62-
63 Proxy models that filter or sort items of data from a source model should-
64 be created by using or subclassing QSortFilterProxyModel.-
65-
66 To subclass QAbstractProxyModel, you need to implement mapFromSource() and-
67 mapToSource(). The mapSelectionFromSource() and mapSelectionToSource()-
68 functions only need to be reimplemented if you need a behavior different-
69 from the default behavior.-
70-
71 \note If the source model is deleted or no source model is specified, the-
72 proxy model operates on a empty placeholder model.-
73-
74 \sa QSortFilterProxyModel, QAbstractItemModel, {Model/View Programming}-
75*/-
76-
77/*!-
78 \property QAbstractProxyModel::sourceModel-
79-
80 \brief the source model of this proxy model.-
81*/-
82-
83//detects the deletion of the source model-
84void QAbstractProxyModelPrivate::_q_sourceModelDestroyed()-
85{-
86 invalidatePersistentIndexes();-
87 model = QAbstractItemModelPrivate::staticEmptyModel();-
88}
executed 361 times by 22 tests: end of block
Executed by:
  • tst_QAbstractItemModel
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QInputDialog
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTreeView
  • tst_languageChange
  • tst_modeltest - unknown status
  • tst_qapplication - unknown status
  • tst_qsortfilterproxymodel - unknown status
361
89-
90/*!-
91 Constructs a proxy model with the given \a parent.-
92*/-
93-
94QAbstractProxyModel::QAbstractProxyModel(QObject *parent)-
95 :QAbstractItemModel(*new QAbstractProxyModelPrivate, parent)-
96{-
97 setSourceModel(QAbstractItemModelPrivate::staticEmptyModel());-
98}
executed 19 times by 2 tests: end of block
Executed by:
  • tst_QAbstractProxyModel
  • tst_QSortFilterProxyModel
19
99-
100/*!-
101 \internal-
102*/-
103-
104QAbstractProxyModel::QAbstractProxyModel(QAbstractProxyModelPrivate &dd, QObject *parent)-
105 : QAbstractItemModel(dd, parent)-
106{-
107 setSourceModel(QAbstractItemModelPrivate::staticEmptyModel());-
108}
executed 751 times by 27 tests: end of block
Executed by:
  • tst_ModelTest
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QItemSelectionModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTableView
  • tst_QTreeView
  • ...
751
109-
110/*!-
111 Destroys the proxy model.-
112*/-
113QAbstractProxyModel::~QAbstractProxyModel()-
114{-
115-
116}-
117-
118/*!-
119 Sets the given \a sourceModel to be processed by the proxy model.-
120-
121 Subclasses should call beginResetModel() at the beginning of the method,-
122 disconnect from the old model, call this method, connect to the new model,-
123 and call endResetModel().-
124*/-
125void QAbstractProxyModel::setSourceModel(QAbstractItemModel *sourceModel)-
126{-
127 Q_D(QAbstractProxyModel);-
128 if (sourceModel != d->model) {
sourceModel != d->modelDescription
TRUEevaluated 2018 times by 28 tests
Evaluated by:
  • tst_ModelTest
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QItemSelectionModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTableView
  • ...
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QIdentityProxyModel
1-2018
129 if (d->model)
d->modelDescription
TRUEevaluated 1248 times by 28 tests
Evaluated by:
  • tst_ModelTest
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QItemSelectionModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTableView
  • ...
FALSEevaluated 770 times by 28 tests
Evaluated by:
  • tst_ModelTest
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QItemSelectionModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTableView
  • ...
770-1248
130 disconnect(d->model, SIGNAL(destroyed()), this, SLOT(_q_sourceModelDestroyed()));
executed 1248 times by 28 tests: disconnect(d->model, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "130"), this, qFlagLocation("1""_q_sourceModelDestroyed()" "\0" __FILE__ ":" "130"));
Executed by:
  • tst_ModelTest
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QItemSelectionModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTableView
  • ...
1248
131-
132 if (sourceModel) {
sourceModelDescription
TRUEevaluated 1651 times by 28 tests
Evaluated by:
  • tst_ModelTest
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QItemSelectionModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTableView
  • ...
FALSEevaluated 367 times by 18 tests
Evaluated by:
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_languageChange
  • tst_qapplication - unknown status
367-1651
133 d->model = sourceModel;-
134 connect(d->model, SIGNAL(destroyed()), this, SLOT(_q_sourceModelDestroyed()));-
135 } else {
executed 1651 times by 28 tests: end of block
Executed by:
  • tst_ModelTest
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QItemSelectionModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTableView
  • ...
1651
136 d->model = QAbstractItemModelPrivate::staticEmptyModel();-
137 }
executed 367 times by 18 tests: end of block
Executed by:
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_languageChange
  • tst_qapplication - unknown status
367
138 d->roleNames = d->model->roleNames();-
139 emit sourceModelChanged(QPrivateSignal());-
140 }
executed 2018 times by 28 tests: end of block
Executed by:
  • tst_ModelTest
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QItemSelectionModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTableView
  • ...
2018
141}
executed 2019 times by 28 tests: end of block
Executed by:
  • tst_ModelTest
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QItemSelectionModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTableView
  • ...
2019
142-
143/*!-
144 Clears the roleNames of this proxy model.-
145*/-
146void QAbstractProxyModel::resetInternalData()-
147{-
148 Q_D(QAbstractProxyModel);-
149 d->roleNames = d->model->roleNames();-
150}
executed 6063 times by 27 tests: end of block
Executed by:
  • tst_ModelTest
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QHeaderView
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QItemSelectionModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_QTableView
  • tst_QTreeView
  • ...
6063
151-
152/*!-
153 Returns the model that contains the data that is available through the proxy model.-
154*/-
155QAbstractItemModel *QAbstractProxyModel::sourceModel() const-
156{-
157 Q_D(const QAbstractProxyModel);-
158 if (d->model == QAbstractItemModelPrivate::staticEmptyModel())
d->model == QA...icEmptyModel()Description
TRUEevaluated 1747 times by 19 tests
Evaluated by:
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_languageChange
  • tst_qapplication - unknown status
FALSEevaluated 30757 times by 20 tests
Evaluated by:
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_languageChange
  • tst_qapplication - unknown status
1747-30757
159 return 0;
executed 1747 times by 19 tests: return 0;
Executed by:
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_languageChange
  • tst_qapplication - unknown status
1747
160 return d->model;
executed 30757 times by 20 tests: return d->model;
Executed by:
  • tst_QAbstractProxyModel
  • tst_QAccessibility
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QIdentityProxyModel
  • tst_QInputDialog
  • tst_QItemModel
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QPrinter
  • tst_QSortFilterProxyModel
  • tst_QStyle
  • tst_QStyleSheetStyle
  • tst_languageChange
  • tst_qapplication - unknown status
30757
161}-
162-
163/*!-
164 \reimp-
165 */-
166bool QAbstractProxyModel::submit()-
167{-
168 Q_D(QAbstractProxyModel);-
169 return d->model->submit();
executed 181 times by 6 tests: return d->model->submit();
Executed by:
  • tst_QAbstractProxyModel
  • tst_QFileDialog2
  • tst_QItemModel
  • tst_QSortFilterProxyModel
  • tst_QTableView
  • tst_QTreeView
181
170}-
171-
172/*!-
173 \reimp-
174 */-
175void QAbstractProxyModel::revert()-
176{-
177 Q_D(QAbstractProxyModel);-
178 d->model->revert();-
179}
executed 5 times by 2 tests: end of block
Executed by:
  • tst_QAbstractProxyModel
  • tst_QItemModel
5
180-
181-
182/*!-
183 \fn QModelIndex QAbstractProxyModel::mapToSource(const QModelIndex &proxyIndex) const-
184-
185 Reimplement this function to return the model index in the source model that-
186 corresponds to the \a proxyIndex in the proxy model.-
187-
188 \sa mapFromSource()-
189*/-
190-
191/*!-
192 \fn QModelIndex QAbstractProxyModel::mapFromSource(const QModelIndex &sourceIndex) const-
193-
194 Reimplement this function to return the model index in the proxy model that-
195 corresponds to the \a sourceIndex from the source model.-
196-
197 \sa mapToSource()-
198*/-
199-
200/*!-
201 Returns a source selection mapped from the specified \a proxySelection.-
202-
203 Reimplement this method to map proxy selections to source selections.-
204 */-
205QItemSelection QAbstractProxyModel::mapSelectionToSource(const QItemSelection &proxySelection) const-
206{-
207 QModelIndexList proxyIndexes = proxySelection.indexes();-
208 QItemSelection sourceSelection;-
209 for (int i = 0; i < proxyIndexes.size(); ++i) {
i < proxyIndexes.size()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QAbstractProxyModel
0-3
210 const QModelIndex proxyIdx = mapToSource(proxyIndexes.at(i));-
211 if (!proxyIdx.isValid())
!proxyIdx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
212 continue;
never executed: continue;
0
213 sourceSelection << QItemSelectionRange(proxyIdx);-
214 }
never executed: end of block
0
215 return sourceSelection;
executed 3 times by 1 test: return sourceSelection;
Executed by:
  • tst_QAbstractProxyModel
3
216}-
217-
218/*!-
219 Returns a proxy selection mapped from the specified \a sourceSelection.-
220-
221 Reimplement this method to map source selections to proxy selections.-
222*/-
223QItemSelection QAbstractProxyModel::mapSelectionFromSource(const QItemSelection &sourceSelection) const-
224{-
225 QModelIndexList sourceIndexes = sourceSelection.indexes();-
226 QItemSelection proxySelection;-
227 for (int i = 0; i < sourceIndexes.size(); ++i) {
i < sourceIndexes.size()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QSortFilterProxyModel
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QAbstractProxyModel
  • tst_QSortFilterProxyModel
3-4
228 const QModelIndex srcIdx = mapFromSource(sourceIndexes.at(i));-
229 if (!srcIdx.isValid())
!srcIdx.isValid()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSortFilterProxyModel
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSortFilterProxyModel
1-2
230 continue;
executed 2 times by 1 test: continue;
Executed by:
  • tst_QSortFilterProxyModel
2
231 proxySelection << QItemSelectionRange(srcIdx);-
232 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QSortFilterProxyModel
1
233 return proxySelection;
executed 4 times by 2 tests: return proxySelection;
Executed by:
  • tst_QAbstractProxyModel
  • tst_QSortFilterProxyModel
4
234}-
235-
236/*!-
237 \reimp-
238 */-
239QVariant QAbstractProxyModel::data(const QModelIndex &proxyIndex, int role) const-
240{-
241 Q_D(const QAbstractProxyModel);-
242 return d->model->data(mapToSource(proxyIndex), role);
executed 619 times by 2 tests: return d->model->data(mapToSource(proxyIndex), role);
Executed by:
  • tst_QAbstractProxyModel
  • tst_QIdentityProxyModel
619
243}-
244-
245/*!-
246 \reimp-
247 */-
248QVariant QAbstractProxyModel::headerData(int section, Qt::Orientation orientation, int role) const-
249{-
250 Q_D(const QAbstractProxyModel);-
251 int sourceSection;-
252 if (orientation == Qt::Horizontal) {
orientation == Qt::HorizontalDescription
TRUEevaluated 487 times by 8 tests
Evaluated by:
  • tst_ModelTest
  • tst_QFileDialog2
  • tst_QHeaderView
  • tst_QItemModel
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QTableView
  • tst_QTreeView
FALSEevaluated 1764 times by 5 tests
Evaluated by:
  • tst_QAbstractProxyModel
  • tst_QHeaderView
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QTableView
487-1764
253 const QModelIndex proxyIndex = index(0, section);-
254 sourceSection = mapToSource(proxyIndex).column();-
255 } else {
executed 487 times by 8 tests: end of block
Executed by:
  • tst_ModelTest
  • tst_QFileDialog2
  • tst_QHeaderView
  • tst_QItemModel
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QTableView
  • tst_QTreeView
487
256 const QModelIndex proxyIndex = index(section, 0);-
257 sourceSection = mapToSource(proxyIndex).row();-
258 }
executed 1764 times by 5 tests: end of block
Executed by:
  • tst_QAbstractProxyModel
  • tst_QHeaderView
  • tst_QItemModel
  • tst_QSqlQueryModel
  • tst_QTableView
1764
259 return d->model->headerData(sourceSection, orientation, role);
executed 2251 times by 9 tests: return d->model->headerData(sourceSection, orientation, role);
Executed by:
  • tst_ModelTest
  • tst_QAbstractProxyModel
  • tst_QFileDialog2
  • tst_QHeaderView
  • tst_QItemModel
  • tst_QSortFilterProxyModel
  • tst_QSqlQueryModel
  • tst_QTableView
  • tst_QTreeView
2251
260}-
261-
262/*!-
263 \reimp-
264 */-
265QMap<int, QVariant> QAbstractProxyModel::itemData(const QModelIndex &proxyIndex) const-
266{-
267 return QAbstractItemModel::itemData(proxyIndex);
executed 51 times by 5 tests: return QAbstractItemModel::itemData(proxyIndex);
Executed by:
  • tst_ModelTest
  • tst_QAbstractProxyModel
  • tst_QIdentityProxyModel
  • tst_QItemModel
  • tst_QSortFilterProxyModel
51
268}-
269-
270/*!-
271 \reimp-
272 */-
273Qt::ItemFlags QAbstractProxyModel::flags(const QModelIndex &index) const-
274{-
275 Q_D(const QAbstractProxyModel);-
276 return d->model->flags(mapToSource(index));
executed 665 times by 8 tests: return d->model->flags(mapToSource(index));
Executed by:
  • tst_QAbstractProxyModel
  • tst_QComboBox
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QIdentityProxyModel
  • tst_QLineEdit
  • tst_QListWidget
665
277}-
278-
279/*!-
280 \reimp-
281 */-
282bool QAbstractProxyModel::setData(const QModelIndex &index, const QVariant &value, int role)-
283{-
284 Q_D(QAbstractProxyModel);-
285 return d->model->setData(mapToSource(index), value, role);
never executed: return d->model->setData(mapToSource(index), value, role);
0
286}-
287-
288/*!-
289 \reimp-
290 */-
291bool QAbstractProxyModel::setItemData(const QModelIndex &index, const QMap< int, QVariant >& roles)-
292{-
293 return QAbstractItemModel::setItemData(index, roles);
executed 3 times by 1 test: return QAbstractItemModel::setItemData(index, roles);
Executed by:
  • tst_QItemModel
3
294}-
295-
296/*!-
297 \reimp-
298 */-
299bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role)-
300{-
301 Q_D(QAbstractProxyModel);-
302 int sourceSection;-
303 if (orientation == Qt::Horizontal) {
orientation == Qt::HorizontalDescription
TRUEevaluated 92 times by 3 tests
Evaluated by:
  • tst_ModelTest
  • tst_QItemModel
  • tst_QSortFilterProxyModel
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QItemModel
10-92
304 const QModelIndex proxyIndex = index(0, section);-
305 sourceSection = mapToSource(proxyIndex).column();-
306 } else {
executed 92 times by 3 tests: end of block
Executed by:
  • tst_ModelTest
  • tst_QItemModel
  • tst_QSortFilterProxyModel
92
307 const QModelIndex proxyIndex = index(section, 0);-
308 sourceSection = mapToSource(proxyIndex).row();-
309 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_QItemModel
10
310 return d->model->setHeaderData(sourceSection, orientation, value, role);
executed 102 times by 3 tests: return d->model->setHeaderData(sourceSection, orientation, value, role);
Executed by:
  • tst_ModelTest
  • tst_QItemModel
  • tst_QSortFilterProxyModel
102
311}-
312-
313/*!-
314 \reimp-
315 */-
316QModelIndex QAbstractProxyModel::buddy(const QModelIndex &index) const-
317{-
318 Q_D(const QAbstractProxyModel);-
319 return mapFromSource(d->model->buddy(mapToSource(index)));
executed 97 times by 3 tests: return mapFromSource(d->model->buddy(mapToSource(index)));
Executed by:
  • tst_QComboBox
  • tst_QCompleter
  • tst_QFileDialog2
97
320}-
321-
322/*!-
323 \reimp-
324 */-
325bool QAbstractProxyModel::canFetchMore(const QModelIndex &parent) const-
326{-
327 Q_D(const QAbstractProxyModel);-
328 return d->model->canFetchMore(mapToSource(parent));
executed 50 times by 4 tests: return d->model->canFetchMore(mapToSource(parent));
Executed by:
  • tst_QComboBox
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFiledialog
50
329}-
330-
331/*!-
332 \reimp-
333 */-
334void QAbstractProxyModel::fetchMore(const QModelIndex &parent)-
335{-
336 Q_D(QAbstractProxyModel);-
337 d->model->fetchMore(mapToSource(parent));-
338}
never executed: end of block
0
339-
340/*!-
341 \reimp-
342 */-
343void QAbstractProxyModel::sort(int column, Qt::SortOrder order)-
344{-
345 Q_D(QAbstractProxyModel);-
346 d->model->sort(column, order);-
347}
never executed: end of block
0
348-
349/*!-
350 \reimp-
351 */-
352QSize QAbstractProxyModel::span(const QModelIndex &index) const-
353{-
354 Q_D(const QAbstractProxyModel);-
355 return d->model->span(mapToSource(index));
never executed: return d->model->span(mapToSource(index));
0
356}-
357-
358/*!-
359 \reimp-
360 */-
361bool QAbstractProxyModel::hasChildren(const QModelIndex &parent) const-
362{-
363 Q_D(const QAbstractProxyModel);-
364 return d->model->hasChildren(mapToSource(parent));
executed 97 times by 1 test: return d->model->hasChildren(mapToSource(parent));
Executed by:
  • tst_QIdentityProxyModel
97
365}-
366-
367/*!-
368 \reimp-
369 */-
370QModelIndex QAbstractProxyModel::sibling(int row, int column, const QModelIndex &idx) const-
371{-
372 return index(row, column, idx.parent());
executed 62 times by 3 tests: return index(row, column, idx.parent());
Executed by:
  • tst_QAbstractProxyModel
  • tst_QCompleter
  • tst_QFileDialog2
62
373}-
374-
375/*!-
376 \reimp-
377 */-
378QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const-
379{-
380 Q_D(const QAbstractProxyModel);-
381 QModelIndexList list;-
382 list.reserve(indexes.count());-
383 foreach(const QModelIndex &index, indexes)-
384 list << mapToSource(index);
never executed: list << mapToSource(index);
0
385 return d->model->mimeData(list);
never executed: return d->model->mimeData(list);
0
386}-
387-
388void QAbstractProxyModelPrivate::mapDropCoordinatesToSource(int row, int column, const QModelIndex &parent,-
389 int *sourceRow, int *sourceColumn, QModelIndex *sourceParent) const-
390{-
391 Q_Q(const QAbstractProxyModel);-
392 *sourceRow = -1;-
393 *sourceColumn = -1;-
394 if (row == -1 && column == -1) {
row == -1Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QSortFilterProxyModel
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSortFilterProxyModel
column == -1Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QSortFilterProxyModel
FALSEnever evaluated
0-10
395 *sourceParent = q->mapToSource(parent);-
396 } else if (row == q->rowCount(parent)) {
executed 10 times by 1 test: end of block
Executed by:
  • tst_QSortFilterProxyModel
row == q->rowCount(parent)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSortFilterProxyModel
0-10
397 *sourceParent = q->mapToSource(parent);-
398 *sourceRow = model->rowCount(*sourceParent);-
399 } else {
never executed: end of block
0
400 QModelIndex proxyIndex = q->index(row, column, parent);-
401 QModelIndex sourceIndex = q->mapToSource(proxyIndex);-
402 *sourceRow = sourceIndex.row();-
403 *sourceColumn = sourceIndex.column();-
404 *sourceParent = sourceIndex.parent();-
405 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QSortFilterProxyModel
2
406}-
407-
408/*!-
409 \reimp-
410 \since 5.4-
411 */-
412bool QAbstractProxyModel::canDropMimeData(const QMimeData *data, Qt::DropAction action,-
413 int row, int column, const QModelIndex &parent) const-
414{-
415 Q_D(const QAbstractProxyModel);-
416 int sourceDestinationRow;-
417 int sourceDestinationColumn;-
418 QModelIndex sourceParent;-
419 d->mapDropCoordinatesToSource(row, column, parent, &sourceDestinationRow, &sourceDestinationColumn, &sourceParent);-
420 return d->model->canDropMimeData(data, action, sourceDestinationRow, sourceDestinationColumn, sourceParent);
executed 11 times by 1 test: return d->model->canDropMimeData(data, action, sourceDestinationRow, sourceDestinationColumn, sourceParent);
Executed by:
  • tst_QSortFilterProxyModel
11
421}-
422-
423/*!-
424 \reimp-
425 \since 5.4-
426 */-
427bool QAbstractProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action,-
428 int row, int column, const QModelIndex &parent)-
429{-
430 Q_D(QAbstractProxyModel);-
431 int sourceDestinationRow;-
432 int sourceDestinationColumn;-
433 QModelIndex sourceParent;-
434 d->mapDropCoordinatesToSource(row, column, parent, &sourceDestinationRow, &sourceDestinationColumn, &sourceParent);-
435 return d->model->dropMimeData(data, action, sourceDestinationRow, sourceDestinationColumn, sourceParent);
executed 1 time by 1 test: return d->model->dropMimeData(data, action, sourceDestinationRow, sourceDestinationColumn, sourceParent);
Executed by:
  • tst_QSortFilterProxyModel
1
436}-
437-
438/*!-
439 \reimp-
440 */-
441QStringList QAbstractProxyModel::mimeTypes() const-
442{-
443 Q_D(const QAbstractProxyModel);-
444 return d->model->mimeTypes();
executed 1 time by 1 test: return d->model->mimeTypes();
Executed by:
  • tst_QAbstractProxyModel
1
445}-
446-
447/*!-
448 \reimp-
449 */-
450Qt::DropActions QAbstractProxyModel::supportedDragActions() const-
451{-
452 Q_D(const QAbstractProxyModel);-
453 return d->model->supportedDragActions();
executed 1 time by 1 test: return d->model->supportedDragActions();
Executed by:
  • tst_QAbstractProxyModel
1
454}-
455-
456/*!-
457 \reimp-
458 */-
459Qt::DropActions QAbstractProxyModel::supportedDropActions() const-
460{-
461 Q_D(const QAbstractProxyModel);-
462 return d->model->supportedDropActions();
executed 1 time by 1 test: return d->model->supportedDropActions();
Executed by:
  • tst_QAbstractProxyModel
1
463}-
464-
465QT_END_NAMESPACE-
466-
467#include "moc_qabstractproxymodel.cpp"-
468-
469#endif // QT_NO_PROXYMODEL-
Source codeSwitch to Preprocessed file

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