| 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) 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 | - | |||||||||||||
| 44 | QT_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 | - | ||||||||||||
| 84 | void QAbstractProxyModelPrivate::_q_sourceModelDestroyed() | - | ||||||||||||
| 85 | { | - | ||||||||||||
| 86 | invalidatePersistentIndexes(); | - | ||||||||||||
| 87 | model = QAbstractItemModelPrivate::staticEmptyModel(); | - | ||||||||||||
| 88 | } executed 361 times by 22 tests: end of blockExecuted by:
| 361 | ||||||||||||
| 89 | - | |||||||||||||
| 90 | /*! | - | ||||||||||||
| 91 | Constructs a proxy model with the given \a parent. | - | ||||||||||||
| 92 | */ | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | QAbstractProxyModel::QAbstractProxyModel(QObject *parent) | - | ||||||||||||
| 95 | :QAbstractItemModel(*new QAbstractProxyModelPrivate, parent) | - | ||||||||||||
| 96 | { | - | ||||||||||||
| 97 | setSourceModel(QAbstractItemModelPrivate::staticEmptyModel()); | - | ||||||||||||
| 98 | } executed 19 times by 2 tests: end of blockExecuted by:
| 19 | ||||||||||||
| 99 | - | |||||||||||||
| 100 | /*! | - | ||||||||||||
| 101 | \internal | - | ||||||||||||
| 102 | */ | - | ||||||||||||
| 103 | - | |||||||||||||
| 104 | QAbstractProxyModel::QAbstractProxyModel(QAbstractProxyModelPrivate &dd, QObject *parent) | - | ||||||||||||
| 105 | : QAbstractItemModel(dd, parent) | - | ||||||||||||
| 106 | { | - | ||||||||||||
| 107 | setSourceModel(QAbstractItemModelPrivate::staticEmptyModel()); | - | ||||||||||||
| 108 | } executed 751 times by 27 tests: end of blockExecuted by:
| 751 | ||||||||||||
| 109 | - | |||||||||||||
| 110 | /*! | - | ||||||||||||
| 111 | Destroys the proxy model. | - | ||||||||||||
| 112 | */ | - | ||||||||||||
| 113 | QAbstractProxyModel::~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 | */ | - | ||||||||||||
| 125 | void QAbstractProxyModel::setSourceModel(QAbstractItemModel *sourceModel) | - | ||||||||||||
| 126 | { | - | ||||||||||||
| 127 | Q_D(QAbstractProxyModel); | - | ||||||||||||
| 128 | if (sourceModel != d->model) {
| 1-2018 | ||||||||||||
| 129 | if (d->model)
| 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:
| 1248 | ||||||||||||
| 131 | - | |||||||||||||
| 132 | if (sourceModel) {
| 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 blockExecuted by:
| 1651 | ||||||||||||
| 136 | d->model = QAbstractItemModelPrivate::staticEmptyModel(); | - | ||||||||||||
| 137 | } executed 367 times by 18 tests: end of blockExecuted by:
| 367 | ||||||||||||
| 138 | d->roleNames = d->model->roleNames(); | - | ||||||||||||
| 139 | emit sourceModelChanged(QPrivateSignal()); | - | ||||||||||||
| 140 | } executed 2018 times by 28 tests: end of blockExecuted by:
| 2018 | ||||||||||||
| 141 | } executed 2019 times by 28 tests: end of blockExecuted by:
| 2019 | ||||||||||||
| 142 | - | |||||||||||||
| 143 | /*! | - | ||||||||||||
| 144 | Clears the roleNames of this proxy model. | - | ||||||||||||
| 145 | */ | - | ||||||||||||
| 146 | void QAbstractProxyModel::resetInternalData() | - | ||||||||||||
| 147 | { | - | ||||||||||||
| 148 | Q_D(QAbstractProxyModel); | - | ||||||||||||
| 149 | d->roleNames = d->model->roleNames(); | - | ||||||||||||
| 150 | } executed 6063 times by 27 tests: end of blockExecuted by:
| 6063 | ||||||||||||
| 151 | - | |||||||||||||
| 152 | /*! | - | ||||||||||||
| 153 | Returns the model that contains the data that is available through the proxy model. | - | ||||||||||||
| 154 | */ | - | ||||||||||||
| 155 | QAbstractItemModel *QAbstractProxyModel::sourceModel() const | - | ||||||||||||
| 156 | { | - | ||||||||||||
| 157 | Q_D(const QAbstractProxyModel); | - | ||||||||||||
| 158 | if (d->model == QAbstractItemModelPrivate::staticEmptyModel())
| 1747-30757 | ||||||||||||
| 159 | return 0; executed 1747 times by 19 tests: return 0;Executed by:
| 1747 | ||||||||||||
| 160 | return d->model; executed 30757 times by 20 tests: return d->model;Executed by:
| 30757 | ||||||||||||
| 161 | } | - | ||||||||||||
| 162 | - | |||||||||||||
| 163 | /*! | - | ||||||||||||
| 164 | \reimp | - | ||||||||||||
| 165 | */ | - | ||||||||||||
| 166 | bool QAbstractProxyModel::submit() | - | ||||||||||||
| 167 | { | - | ||||||||||||
| 168 | Q_D(QAbstractProxyModel); | - | ||||||||||||
| 169 | return d->model->submit(); executed 181 times by 6 tests: return d->model->submit();Executed by:
| 181 | ||||||||||||
| 170 | } | - | ||||||||||||
| 171 | - | |||||||||||||
| 172 | /*! | - | ||||||||||||
| 173 | \reimp | - | ||||||||||||
| 174 | */ | - | ||||||||||||
| 175 | void QAbstractProxyModel::revert() | - | ||||||||||||
| 176 | { | - | ||||||||||||
| 177 | Q_D(QAbstractProxyModel); | - | ||||||||||||
| 178 | d->model->revert(); | - | ||||||||||||
| 179 | } executed 5 times by 2 tests: end of blockExecuted by:
| 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 | */ | - | ||||||||||||
| 205 | QItemSelection QAbstractProxyModel::mapSelectionToSource(const QItemSelection &proxySelection) const | - | ||||||||||||
| 206 | { | - | ||||||||||||
| 207 | QModelIndexList proxyIndexes = proxySelection.indexes(); | - | ||||||||||||
| 208 | QItemSelection sourceSelection; | - | ||||||||||||
| 209 | for (int i = 0; i < proxyIndexes.size(); ++i) {
| 0-3 | ||||||||||||
| 210 | const QModelIndex proxyIdx = mapToSource(proxyIndexes.at(i)); | - | ||||||||||||
| 211 | if (!proxyIdx.isValid())
| 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:
| 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 | */ | - | ||||||||||||
| 223 | QItemSelection QAbstractProxyModel::mapSelectionFromSource(const QItemSelection &sourceSelection) const | - | ||||||||||||
| 224 | { | - | ||||||||||||
| 225 | QModelIndexList sourceIndexes = sourceSelection.indexes(); | - | ||||||||||||
| 226 | QItemSelection proxySelection; | - | ||||||||||||
| 227 | for (int i = 0; i < sourceIndexes.size(); ++i) {
| 3-4 | ||||||||||||
| 228 | const QModelIndex srcIdx = mapFromSource(sourceIndexes.at(i)); | - | ||||||||||||
| 229 | if (!srcIdx.isValid())
| 1-2 | ||||||||||||
| 230 | continue; executed 2 times by 1 test: continue;Executed by:
| 2 | ||||||||||||
| 231 | proxySelection << QItemSelectionRange(srcIdx); | - | ||||||||||||
| 232 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||
| 233 | return proxySelection; executed 4 times by 2 tests: return proxySelection;Executed by:
| 4 | ||||||||||||
| 234 | } | - | ||||||||||||
| 235 | - | |||||||||||||
| 236 | /*! | - | ||||||||||||
| 237 | \reimp | - | ||||||||||||
| 238 | */ | - | ||||||||||||
| 239 | QVariant 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:
| 619 | ||||||||||||
| 243 | } | - | ||||||||||||
| 244 | - | |||||||||||||
| 245 | /*! | - | ||||||||||||
| 246 | \reimp | - | ||||||||||||
| 247 | */ | - | ||||||||||||
| 248 | QVariant QAbstractProxyModel::headerData(int section, Qt::Orientation orientation, int role) const | - | ||||||||||||
| 249 | { | - | ||||||||||||
| 250 | Q_D(const QAbstractProxyModel); | - | ||||||||||||
| 251 | int sourceSection; | - | ||||||||||||
| 252 | if (orientation == Qt::Horizontal) {
| 487-1764 | ||||||||||||
| 253 | const QModelIndex proxyIndex = index(0, section); | - | ||||||||||||
| 254 | sourceSection = mapToSource(proxyIndex).column(); | - | ||||||||||||
| 255 | } else { executed 487 times by 8 tests: end of blockExecuted by:
| 487 | ||||||||||||
| 256 | const QModelIndex proxyIndex = index(section, 0); | - | ||||||||||||
| 257 | sourceSection = mapToSource(proxyIndex).row(); | - | ||||||||||||
| 258 | } executed 1764 times by 5 tests: end of blockExecuted by:
| 1764 | ||||||||||||
| 259 | return d->model->headerData(sourceSection, orientation, role); executed 2251 times by 9 tests: return d->model->headerData(sourceSection, orientation, role);Executed by:
| 2251 | ||||||||||||
| 260 | } | - | ||||||||||||
| 261 | - | |||||||||||||
| 262 | /*! | - | ||||||||||||
| 263 | \reimp | - | ||||||||||||
| 264 | */ | - | ||||||||||||
| 265 | QMap<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:
| 51 | ||||||||||||
| 268 | } | - | ||||||||||||
| 269 | - | |||||||||||||
| 270 | /*! | - | ||||||||||||
| 271 | \reimp | - | ||||||||||||
| 272 | */ | - | ||||||||||||
| 273 | Qt::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:
| 665 | ||||||||||||
| 277 | } | - | ||||||||||||
| 278 | - | |||||||||||||
| 279 | /*! | - | ||||||||||||
| 280 | \reimp | - | ||||||||||||
| 281 | */ | - | ||||||||||||
| 282 | bool 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 | */ | - | ||||||||||||
| 291 | bool 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:
| 3 | ||||||||||||
| 294 | } | - | ||||||||||||
| 295 | - | |||||||||||||
| 296 | /*! | - | ||||||||||||
| 297 | \reimp | - | ||||||||||||
| 298 | */ | - | ||||||||||||
| 299 | bool 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) {
| 10-92 | ||||||||||||
| 304 | const QModelIndex proxyIndex = index(0, section); | - | ||||||||||||
| 305 | sourceSection = mapToSource(proxyIndex).column(); | - | ||||||||||||
| 306 | } else { executed 92 times by 3 tests: end of blockExecuted by:
| 92 | ||||||||||||
| 307 | const QModelIndex proxyIndex = index(section, 0); | - | ||||||||||||
| 308 | sourceSection = mapToSource(proxyIndex).row(); | - | ||||||||||||
| 309 | } executed 10 times by 1 test: end of blockExecuted by:
| 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:
| 102 | ||||||||||||
| 311 | } | - | ||||||||||||
| 312 | - | |||||||||||||
| 313 | /*! | - | ||||||||||||
| 314 | \reimp | - | ||||||||||||
| 315 | */ | - | ||||||||||||
| 316 | QModelIndex 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:
| 97 | ||||||||||||
| 320 | } | - | ||||||||||||
| 321 | - | |||||||||||||
| 322 | /*! | - | ||||||||||||
| 323 | \reimp | - | ||||||||||||
| 324 | */ | - | ||||||||||||
| 325 | bool 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:
| 50 | ||||||||||||
| 329 | } | - | ||||||||||||
| 330 | - | |||||||||||||
| 331 | /*! | - | ||||||||||||
| 332 | \reimp | - | ||||||||||||
| 333 | */ | - | ||||||||||||
| 334 | void 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 | */ | - | ||||||||||||
| 343 | void 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 | */ | - | ||||||||||||
| 352 | QSize 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 | */ | - | ||||||||||||
| 361 | bool 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:
| 97 | ||||||||||||
| 365 | } | - | ||||||||||||
| 366 | - | |||||||||||||
| 367 | /*! | - | ||||||||||||
| 368 | \reimp | - | ||||||||||||
| 369 | */ | - | ||||||||||||
| 370 | QModelIndex 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:
| 62 | ||||||||||||
| 373 | } | - | ||||||||||||
| 374 | - | |||||||||||||
| 375 | /*! | - | ||||||||||||
| 376 | \reimp | - | ||||||||||||
| 377 | */ | - | ||||||||||||
| 378 | QMimeData* 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 | - | |||||||||||||
| 388 | void 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) {
| 0-10 | ||||||||||||
| 395 | *sourceParent = q->mapToSource(parent); | - | ||||||||||||
| 396 | } else if (row == q->rowCount(parent)) { executed 10 times by 1 test: end of blockExecuted by:
| 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 blockExecuted by:
| 2 | ||||||||||||
| 406 | } | - | ||||||||||||
| 407 | - | |||||||||||||
| 408 | /*! | - | ||||||||||||
| 409 | \reimp | - | ||||||||||||
| 410 | \since 5.4 | - | ||||||||||||
| 411 | */ | - | ||||||||||||
| 412 | bool 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:
| 11 | ||||||||||||
| 421 | } | - | ||||||||||||
| 422 | - | |||||||||||||
| 423 | /*! | - | ||||||||||||
| 424 | \reimp | - | ||||||||||||
| 425 | \since 5.4 | - | ||||||||||||
| 426 | */ | - | ||||||||||||
| 427 | bool 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:
| 1 | ||||||||||||
| 436 | } | - | ||||||||||||
| 437 | - | |||||||||||||
| 438 | /*! | - | ||||||||||||
| 439 | \reimp | - | ||||||||||||
| 440 | */ | - | ||||||||||||
| 441 | QStringList 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:
| 1 | ||||||||||||
| 445 | } | - | ||||||||||||
| 446 | - | |||||||||||||
| 447 | /*! | - | ||||||||||||
| 448 | \reimp | - | ||||||||||||
| 449 | */ | - | ||||||||||||
| 450 | Qt::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:
| 1 | ||||||||||||
| 454 | } | - | ||||||||||||
| 455 | - | |||||||||||||
| 456 | /*! | - | ||||||||||||
| 457 | \reimp | - | ||||||||||||
| 458 | */ | - | ||||||||||||
| 459 | Qt::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:
| 1 | ||||||||||||
| 463 | } | - | ||||||||||||
| 464 | - | |||||||||||||
| 465 | QT_END_NAMESPACE | - | ||||||||||||
| 466 | - | |||||||||||||
| 467 | #include "moc_qabstractproxymodel.cpp" | - | ||||||||||||
| 468 | - | |||||||||||||
| 469 | #endif // QT_NO_PROXYMODEL | - | ||||||||||||
| Source code | Switch to Preprocessed file |