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