| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qstandarditemmodel.h" | - |
| 43 | | - |
| 44 | #ifndef QT_NO_STANDARDITEMMODEL | - |
| 45 | | - |
| 46 | #include <QtCore/qdatetime.h> | - |
| 47 | #include <QtCore/qlist.h> | - |
| 48 | #include <QtCore/qmap.h> | - |
| 49 | #include <QtCore/qpair.h> | - |
| 50 | #include <QtCore/qvariant.h> | - |
| 51 | #include <QtCore/qvector.h> | - |
| 52 | #include <QtCore/qstringlist.h> | - |
| 53 | #include <QtCore/qbitarray.h> | - |
| 54 | #include <QtCore/qmimedata.h> | - |
| 55 | | - |
| 56 | #include <private/qstandarditemmodel_p.h> | - |
| 57 | #include <qdebug.h> | - |
| 58 | | - |
| 59 | QT_BEGIN_NAMESPACE | - |
| 60 | | - |
| 61 | class QStandardItemModelLessThan | - |
| 62 | { | - |
| 63 | public: | - |
| 64 | inline QStandardItemModelLessThan() | - |
| 65 | { } | - |
| 66 | | - |
| 67 | inline bool operator()(const QPair<QStandardItem*, int> &l, | - |
| 68 | const QPair<QStandardItem*, int> &r) const | - |
| 69 | { | - |
| 70 | return *(l.first) < *(r.first); executed: return *(l.first) < *(r.first);Execution Count:5054 | 5054 |
| 71 | } | - |
| 72 | }; | - |
| 73 | | - |
| 74 | class QStandardItemModelGreaterThan | - |
| 75 | { | - |
| 76 | public: | - |
| 77 | inline QStandardItemModelGreaterThan() | - |
| 78 | { } | - |
| 79 | | - |
| 80 | inline bool operator()(const QPair<QStandardItem*, int> &l, | - |
| 81 | const QPair<QStandardItem*, int> &r) const | - |
| 82 | { | - |
| 83 | return *(r.first) < *(l.first); executed: return *(r.first) < *(l.first);Execution Count:258 | 258 |
| 84 | } | - |
| 85 | }; | - |
| 86 | | - |
| 87 | /*! | - |
| 88 | \internal | - |
| 89 | */ | - |
| 90 | QStandardItemPrivate::~QStandardItemPrivate() | - |
| 91 | { | - |
| 92 | QVector<QStandardItem*>::const_iterator it; executed (the execution status of this line is deduced): QVector<QStandardItem*>::const_iterator it; | - |
| 93 | for (it = children.constBegin(); it != children.constEnd(); ++it) { evaluated: it != children.constEnd()| yes Evaluation Count:11936835 | yes Evaluation Count:3490082 |
| 3490082-11936835 |
| 94 | QStandardItem *child = *it; executed (the execution status of this line is deduced): QStandardItem *child = *it; | - |
| 95 | if (child) evaluated: child| yes Evaluation Count:3482528 | yes Evaluation Count:8454307 |
| 3482528-8454307 |
| 96 | child->d_func()->setModel(0); executed: child->d_func()->setModel(0);Execution Count:3482528 | 3482528 |
| 97 | delete child; executed (the execution status of this line is deduced): delete child; | - |
| 98 | } executed: }Execution Count:11936835 | 11936835 |
| 99 | children.clear(); executed (the execution status of this line is deduced): children.clear(); | - |
| 100 | if (parent && model) evaluated: parent| yes Evaluation Count:3487493 | yes Evaluation Count:2589 |
evaluated: model| yes Evaluation Count:74 | yes Evaluation Count:3487419 |
| 74-3487493 |
| 101 | parent->d_func()->childDeleted(q_func()); executed: parent->d_func()->childDeleted(q_func());Execution Count:74 | 74 |
| 102 | } executed: }Execution Count:3490082 | 3490082 |
| 103 | | - |
| 104 | /*! | - |
| 105 | \internal | - |
| 106 | */ | - |
| 107 | QPair<int, int> QStandardItemPrivate::position() const | - |
| 108 | { | - |
| 109 | if (QStandardItem *par = parent) { partially evaluated: QStandardItem *par = parent| yes Evaluation Count:17074275 | no Evaluation Count:0 |
| 0-17074275 |
| 110 | int idx = par->d_func()->childIndex(q_func()); executed (the execution status of this line is deduced): int idx = par->d_func()->childIndex(q_func()); | - |
| 111 | if (idx == -1) partially evaluated: idx == -1| no Evaluation Count:0 | yes Evaluation Count:17074275 |
| 0-17074275 |
| 112 | return QPair<int, int>(-1, -1); never executed: return QPair<int, int>(-1, -1); | 0 |
| 113 | return QPair<int, int>(idx / par->columnCount(), idx % par->columnCount()); executed: return QPair<int, int>(idx / par->columnCount(), idx % par->columnCount());Execution Count:17074275 | 17074275 |
| 114 | } | - |
| 115 | // ### support header items? | - |
| 116 | return QPair<int, int>(-1, -1); never executed: return QPair<int, int>(-1, -1); | 0 |
| 117 | } | - |
| 118 | | - |
| 119 | /*! | - |
| 120 | \internal | - |
| 121 | */ | - |
| 122 | void QStandardItemPrivate::setChild(int row, int column, QStandardItem *item, | - |
| 123 | bool emitChanged) | - |
| 124 | { | - |
| 125 | Q_Q(QStandardItem); executed (the execution status of this line is deduced): QStandardItem * const q = q_func(); | - |
| 126 | if (item == q) { partially evaluated: item == q| no Evaluation Count:0 | yes Evaluation Count:3479082 |
| 0-3479082 |
| 127 | qWarning("QStandardItem::setChild: Can't make an item a child of itself %p", never executed (the execution status of this line is deduced): QMessageLogger("itemmodels/qstandarditemmodel.cpp", 127, __PRETTY_FUNCTION__).warning("QStandardItem::setChild: Can't make an item a child of itself %p", | - |
| 128 | item); never executed (the execution status of this line is deduced): item); | - |
| 129 | return; | 0 |
| 130 | } | - |
| 131 | if ((row < 0) || (column < 0)) evaluated: (row < 0)| yes Evaluation Count:1 | yes Evaluation Count:3479081 |
partially evaluated: (column < 0)| no Evaluation Count:0 | yes Evaluation Count:3479081 |
| 0-3479081 |
| 132 | return; executed: return;Execution Count:1 | 1 |
| 133 | if (rows <= row) evaluated: rows <= row| yes Evaluation Count:161 | yes Evaluation Count:3478920 |
| 161-3478920 |
| 134 | q->setRowCount(row + 1); executed: q->setRowCount(row + 1);Execution Count:161 | 161 |
| 135 | if (columns <= column) evaluated: columns <= column| yes Evaluation Count:122 | yes Evaluation Count:3478959 |
| 122-3478959 |
| 136 | q->setColumnCount(column + 1); executed: q->setColumnCount(column + 1);Execution Count:122 | 122 |
| 137 | int index = childIndex(row, column); executed (the execution status of this line is deduced): int index = childIndex(row, column); | - |
| 138 | Q_ASSERT(index != -1); executed (the execution status of this line is deduced): qt_noop(); | - |
| 139 | QStandardItem *oldItem = children.at(index); executed (the execution status of this line is deduced): QStandardItem *oldItem = children.at(index); | - |
| 140 | if (item == oldItem) partially evaluated: item == oldItem| no Evaluation Count:0 | yes Evaluation Count:3479081 |
| 0-3479081 |
| 141 | return; | 0 |
| 142 | | - |
| 143 | if (model && emitChanged) { evaluated: model| yes Evaluation Count:3478659 | yes Evaluation Count:422 |
evaluated: emitChanged| yes Evaluation Count:4020 | yes Evaluation Count:3474639 |
| 422-3478659 |
| 144 | emit model->layoutAboutToBeChanged(); executed (the execution status of this line is deduced): model->layoutAboutToBeChanged(); | - |
| 145 | } executed: }Execution Count:4020 | 4020 |
| 146 | | - |
| 147 | if (item) { evaluated: item| yes Evaluation Count:3479080 | yes Evaluation Count:1 |
| 1-3479080 |
| 148 | if (item->d_func()->parent == 0) { partially evaluated: item->d_func()->parent == 0| yes Evaluation Count:3479080 | no Evaluation Count:0 |
| 0-3479080 |
| 149 | item->d_func()->setParentAndModel(q, model); executed (the execution status of this line is deduced): item->d_func()->setParentAndModel(q, model); | - |
| 150 | } else { executed: }Execution Count:3479080 | 3479080 |
| 151 | qWarning("QStandardItem::setChild: Ignoring duplicate insertion of item %p", never executed (the execution status of this line is deduced): QMessageLogger("itemmodels/qstandarditemmodel.cpp", 151, __PRETTY_FUNCTION__).warning("QStandardItem::setChild: Ignoring duplicate insertion of item %p", | - |
| 152 | item); never executed (the execution status of this line is deduced): item); | - |
| 153 | return; | 0 |
| 154 | } | - |
| 155 | } | - |
| 156 | if (oldItem) evaluated: oldItem| yes Evaluation Count:3 | yes Evaluation Count:3479078 |
| 3-3479078 |
| 157 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0);Execution Count:3 | 3 |
| 158 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
| 159 | children.replace(index, item); executed (the execution status of this line is deduced): children.replace(index, item); | - |
| 160 | | - |
| 161 | if (model && emitChanged) evaluated: model| yes Evaluation Count:3478659 | yes Evaluation Count:422 |
evaluated: emitChanged| yes Evaluation Count:4020 | yes Evaluation Count:3474639 |
| 422-3478659 |
| 162 | emit model->layoutChanged(); executed: model->layoutChanged();Execution Count:4020 | 4020 |
| 163 | | - |
| 164 | if (emitChanged && model) evaluated: emitChanged| yes Evaluation Count:4442 | yes Evaluation Count:3474639 |
evaluated: model| yes Evaluation Count:4020 | yes Evaluation Count:422 |
| 422-3474639 |
| 165 | model->d_func()->itemChanged(item); executed: model->d_func()->itemChanged(item);Execution Count:4020 | 4020 |
| 166 | } executed: }Execution Count:3479081 | 3479081 |
| 167 | | - |
| 168 | | - |
| 169 | /*! | - |
| 170 | \internal | - |
| 171 | */ | - |
| 172 | void QStandardItemPrivate::changeFlags(bool enable, Qt::ItemFlags f) | - |
| 173 | { | - |
| 174 | Q_Q(QStandardItem); executed (the execution status of this line is deduced): QStandardItem * const q = q_func(); | - |
| 175 | Qt::ItemFlags flags = q->flags(); executed (the execution status of this line is deduced): Qt::ItemFlags flags = q->flags(); | - |
| 176 | if (enable) evaluated: enable| yes Evaluation Count:72 | yes Evaluation Count:108 |
| 72-108 |
| 177 | flags |= f; executed: flags |= f;Execution Count:72 | 72 |
| 178 | else | - |
| 179 | flags &= ~f; executed: flags &= ~f;Execution Count:108 | 108 |
| 180 | q->setFlags(flags); executed (the execution status of this line is deduced): q->setFlags(flags); | - |
| 181 | } executed: }Execution Count:180 | 180 |
| 182 | | - |
| 183 | /*! | - |
| 184 | \internal | - |
| 185 | */ | - |
| 186 | void QStandardItemPrivate::childDeleted(QStandardItem *child) | - |
| 187 | { | - |
| 188 | int index = childIndex(child); executed (the execution status of this line is deduced): int index = childIndex(child); | - |
| 189 | Q_ASSERT(index != -1); executed (the execution status of this line is deduced): qt_noop(); | - |
| 190 | children.replace(index, 0); executed (the execution status of this line is deduced): children.replace(index, 0); | - |
| 191 | } executed: }Execution Count:74 | 74 |
| 192 | | - |
| 193 | /*! | - |
| 194 | \internal | - |
| 195 | */ | - |
| 196 | void QStandardItemPrivate::setItemData(const QMap<int, QVariant> &roles) | - |
| 197 | { | - |
| 198 | Q_Q(QStandardItem); executed (the execution status of this line is deduced): QStandardItem * const q = q_func(); | - |
| 199 | | - |
| 200 | //let's build the vector of new values | - |
| 201 | QVector<QStandardItemData> newValues; executed (the execution status of this line is deduced): QVector<QStandardItemData> newValues; | - |
| 202 | QMap<int, QVariant>::const_iterator it; executed (the execution status of this line is deduced): QMap<int, QVariant>::const_iterator it; | - |
| 203 | for (it = roles.begin(); it != roles.end(); ++it) { evaluated: it != roles.end()| yes Evaluation Count:24 | yes Evaluation Count:2 |
| 2-24 |
| 204 | QVariant value = it.value(); executed (the execution status of this line is deduced): QVariant value = it.value(); | - |
| 205 | if (value.isValid()) { partially evaluated: value.isValid()| yes Evaluation Count:24 | no Evaluation Count:0 |
| 0-24 |
| 206 | int role = it.key(); executed (the execution status of this line is deduced): int role = it.key(); | - |
| 207 | role = (role == Qt::EditRole) ? Qt::DisplayRole : role; partially evaluated: (role == Qt::EditRole)| no Evaluation Count:0 | yes Evaluation Count:24 |
| 0-24 |
| 208 | QStandardItemData wid(role,it.value()); executed (the execution status of this line is deduced): QStandardItemData wid(role,it.value()); | - |
| 209 | newValues.append(wid); executed (the execution status of this line is deduced): newValues.append(wid); | - |
| 210 | } executed: }Execution Count:24 | 24 |
| 211 | } executed: }Execution Count:24 | 24 |
| 212 | | - |
| 213 | if (values!=newValues) { evaluated: values!=newValues| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 214 | values=newValues; executed (the execution status of this line is deduced): values=newValues; | - |
| 215 | if (model) partially evaluated: model| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 216 | model->d_func()->itemChanged(q); executed: model->d_func()->itemChanged(q);Execution Count:1 | 1 |
| 217 | } executed: }Execution Count:1 | 1 |
| 218 | } executed: }Execution Count:2 | 2 |
| 219 | | - |
| 220 | /*! | - |
| 221 | \internal | - |
| 222 | */ | - |
| 223 | const QMap<int, QVariant> QStandardItemPrivate::itemData() const | - |
| 224 | { | - |
| 225 | QMap<int, QVariant> result; executed (the execution status of this line is deduced): QMap<int, QVariant> result; | - |
| 226 | QVector<QStandardItemData>::const_iterator it; executed (the execution status of this line is deduced): QVector<QStandardItemData>::const_iterator it; | - |
| 227 | for (it = values.begin(); it != values.end(); ++it) evaluated: it != values.end()| yes Evaluation Count:43 | yes Evaluation Count:32 |
| 32-43 |
| 228 | result.insert((*it).role, (*it).value); executed: result.insert((*it).role, (*it).value);Execution Count:43 | 43 |
| 229 | return result; executed: return result;Execution Count:32 | 32 |
| 230 | } | - |
| 231 | | - |
| 232 | /*! | - |
| 233 | \internal | - |
| 234 | */ | - |
| 235 | void QStandardItemPrivate::sortChildren(int column, Qt::SortOrder order) | - |
| 236 | { | - |
| 237 | Q_Q(QStandardItem); executed (the execution status of this line is deduced): QStandardItem * const q = q_func(); | - |
| 238 | if (column >= columnCount()) evaluated: column >= columnCount()| yes Evaluation Count:1331 | yes Evaluation Count:114 |
| 114-1331 |
| 239 | return; executed: return;Execution Count:1331 | 1331 |
| 240 | | - |
| 241 | QVector<QPair<QStandardItem*, int> > sortable; executed (the execution status of this line is deduced): QVector<QPair<QStandardItem*, int> > sortable; | - |
| 242 | QVector<int> unsortable; executed (the execution status of this line is deduced): QVector<int> unsortable; | - |
| 243 | | - |
| 244 | sortable.reserve(rowCount()); executed (the execution status of this line is deduced): sortable.reserve(rowCount()); | - |
| 245 | unsortable.reserve(rowCount()); executed (the execution status of this line is deduced): unsortable.reserve(rowCount()); | - |
| 246 | | - |
| 247 | for (int row = 0; row < rowCount(); ++row) { evaluated: row < rowCount()| yes Evaluation Count:3432 | yes Evaluation Count:114 |
| 114-3432 |
| 248 | QStandardItem *itm = q->child(row, column); executed (the execution status of this line is deduced): QStandardItem *itm = q->child(row, column); | - |
| 249 | if (itm) evaluated: itm| yes Evaluation Count:1225 | yes Evaluation Count:2207 |
| 1225-2207 |
| 250 | sortable.append(QPair<QStandardItem*,int>(itm, row)); executed: sortable.append(QPair<QStandardItem*,int>(itm, row));Execution Count:1225 | 1225 |
| 251 | else | - |
| 252 | unsortable.append(row); executed: unsortable.append(row);Execution Count:2207 | 2207 |
| 253 | } | - |
| 254 | | - |
| 255 | if (order == Qt::AscendingOrder) { evaluated: order == Qt::AscendingOrder| yes Evaluation Count:98 | yes Evaluation Count:16 |
| 16-98 |
| 256 | QStandardItemModelLessThan lt; executed (the execution status of this line is deduced): QStandardItemModelLessThan lt; | - |
| 257 | qStableSort(sortable.begin(), sortable.end(), lt); executed (the execution status of this line is deduced): qStableSort(sortable.begin(), sortable.end(), lt); | - |
| 258 | } else { executed: }Execution Count:98 | 98 |
| 259 | QStandardItemModelGreaterThan gt; executed (the execution status of this line is deduced): QStandardItemModelGreaterThan gt; | - |
| 260 | qStableSort(sortable.begin(), sortable.end(), gt); executed (the execution status of this line is deduced): qStableSort(sortable.begin(), sortable.end(), gt); | - |
| 261 | } executed: }Execution Count:16 | 16 |
| 262 | | - |
| 263 | QModelIndexList changedPersistentIndexesFrom, changedPersistentIndexesTo; executed (the execution status of this line is deduced): QModelIndexList changedPersistentIndexesFrom, changedPersistentIndexesTo; | - |
| 264 | QVector<QStandardItem*> sorted_children(children.count()); executed (the execution status of this line is deduced): QVector<QStandardItem*> sorted_children(children.count()); | - |
| 265 | for (int i = 0; i < rowCount(); ++i) { evaluated: i < rowCount()| yes Evaluation Count:3432 | yes Evaluation Count:114 |
| 114-3432 |
| 266 | int r = (i < sortable.count() evaluated: i < sortable.count()| yes Evaluation Count:1225 | yes Evaluation Count:2207 |
| 1225-2207 |
| 267 | ? sortable.at(i).second executed (the execution status of this line is deduced): ? sortable.at(i).second | - |
| 268 | : unsortable.at(i - sortable.count())); executed (the execution status of this line is deduced): : unsortable.at(i - sortable.count())); | - |
| 269 | for (int c = 0; c < columnCount(); ++c) { evaluated: c < columnCount()| yes Evaluation Count:76078 | yes Evaluation Count:3432 |
| 3432-76078 |
| 270 | QStandardItem *itm = q->child(r, c); executed (the execution status of this line is deduced): QStandardItem *itm = q->child(r, c); | - |
| 271 | sorted_children[childIndex(i, c)] = itm; executed (the execution status of this line is deduced): sorted_children[childIndex(i, c)] = itm; | - |
| 272 | if (model) { evaluated: model| yes Evaluation Count:76064 | yes Evaluation Count:14 |
| 14-76064 |
| 273 | QModelIndex from = model->createIndex(r, c, q); executed (the execution status of this line is deduced): QModelIndex from = model->createIndex(r, c, q); | - |
| 274 | if (model->d_func()->persistent.indexes.contains(from)) { evaluated: model->d_func()->persistent.indexes.contains(from)| yes Evaluation Count:37 | yes Evaluation Count:76027 |
| 37-76027 |
| 275 | QModelIndex to = model->createIndex(i, c, q); executed (the execution status of this line is deduced): QModelIndex to = model->createIndex(i, c, q); | - |
| 276 | changedPersistentIndexesFrom.append(from); executed (the execution status of this line is deduced): changedPersistentIndexesFrom.append(from); | - |
| 277 | changedPersistentIndexesTo.append(to); executed (the execution status of this line is deduced): changedPersistentIndexesTo.append(to); | - |
| 278 | } executed: }Execution Count:37 | 37 |
| 279 | } executed: }Execution Count:76064 | 76064 |
| 280 | } executed: }Execution Count:76078 | 76078 |
| 281 | } executed: }Execution Count:3432 | 3432 |
| 282 | | - |
| 283 | children = sorted_children; executed (the execution status of this line is deduced): children = sorted_children; | - |
| 284 | | - |
| 285 | if (model) { evaluated: model| yes Evaluation Count:109 | yes Evaluation Count:5 |
| 5-109 |
| 286 | model->changePersistentIndexList(changedPersistentIndexesFrom, changedPersistentIndexesTo); executed (the execution status of this line is deduced): model->changePersistentIndexList(changedPersistentIndexesFrom, changedPersistentIndexesTo); | - |
| 287 | } executed: }Execution Count:109 | 109 |
| 288 | | - |
| 289 | QVector<QStandardItem*>::iterator it; executed (the execution status of this line is deduced): QVector<QStandardItem*>::iterator it; | - |
| 290 | for (it = children.begin(); it != children.end(); ++it) { evaluated: it != children.end()| yes Evaluation Count:76078 | yes Evaluation Count:114 |
| 114-76078 |
| 291 | if (*it) evaluated: *it| yes Evaluation Count:1396 | yes Evaluation Count:74682 |
| 1396-74682 |
| 292 | (*it)->d_func()->sortChildren(column, order); executed: (*it)->d_func()->sortChildren(column, order);Execution Count:1396 | 1396 |
| 293 | } executed: }Execution Count:76078 | 76078 |
| 294 | } executed: }Execution Count:114 | 114 |
| 295 | | - |
| 296 | /*! | - |
| 297 | \internal | - |
| 298 | set the model of this item and all its children | - |
| 299 | */ | - |
| 300 | void QStandardItemPrivate::setModel(QStandardItemModel *mod) | - |
| 301 | { | - |
| 302 | if (children.isEmpty()) { evaluated: children.isEmpty()| yes Evaluation Count:6967404 | yes Evaluation Count:6659 |
| 6659-6967404 |
| 303 | if (model) evaluated: model| yes Evaluation Count:155055 | yes Evaluation Count:6812349 |
| 155055-6812349 |
| 304 | model->d_func()->invalidatePersistentIndex(model->indexFromItem(q_ptr)); executed: model->d_func()->invalidatePersistentIndex(model->indexFromItem(q_ptr));Execution Count:155055 | 155055 |
| 305 | model = mod; executed (the execution status of this line is deduced): model = mod; | - |
| 306 | } else { executed: }Execution Count:6967404 | 6967404 |
| 307 | QStack<QStandardItem*> stack; executed (the execution status of this line is deduced): QStack<QStandardItem*> stack; | - |
| 308 | stack.push(q_ptr); executed (the execution status of this line is deduced): stack.push(q_ptr); | - |
| 309 | while (!stack.isEmpty()) { evaluated: !stack.isEmpty()| yes Evaluation Count:66473281 | yes Evaluation Count:6659 |
| 6659-66473281 |
| 310 | QStandardItem *itm = stack.pop(); executed (the execution status of this line is deduced): QStandardItem *itm = stack.pop(); | - |
| 311 | if (itm->d_func()->model) { evaluated: itm->d_func()->model| yes Evaluation Count:3331832 | yes Evaluation Count:63141449 |
| 3331832-63141449 |
| 312 | itm->d_func()->model->d_func()->invalidatePersistentIndex(itm->d_func()->model->indexFromItem(itm)); executed (the execution status of this line is deduced): itm->d_func()->model->d_func()->invalidatePersistentIndex(itm->d_func()->model->indexFromItem(itm)); | - |
| 313 | } executed: }Execution Count:3331832 | 3331832 |
| 314 | itm->d_func()->model = mod; executed (the execution status of this line is deduced): itm->d_func()->model = mod; | - |
| 315 | const QVector<QStandardItem*> &childList = itm->d_func()->children; executed (the execution status of this line is deduced): const QVector<QStandardItem*> &childList = itm->d_func()->children; | - |
| 316 | for (int i = 0; i < childList.count(); ++i) { evaluated: i < childList.count()| yes Evaluation Count:278605762 | yes Evaluation Count:66473281 |
| 66473281-278605762 |
| 317 | QStandardItem *chi = childList.at(i); executed (the execution status of this line is deduced): QStandardItem *chi = childList.at(i); | - |
| 318 | if (chi) evaluated: chi| yes Evaluation Count:66466622 | yes Evaluation Count:212139140 |
| 66466622-212139140 |
| 319 | stack.push(chi); executed: stack.push(chi);Execution Count:66466622 | 66466622 |
| 320 | } executed: }Execution Count:278605762 | 278605762 |
| 321 | } executed: }Execution Count:66473281 | 66473281 |
| 322 | } executed: }Execution Count:6659 | 6659 |
| 323 | } | - |
| 324 | | - |
| 325 | /*! | - |
| 326 | \internal | - |
| 327 | */ | - |
| 328 | QStandardItemModelPrivate::QStandardItemModelPrivate() | - |
| 329 | : root(new QStandardItem), | - |
| 330 | itemPrototype(0), | - |
| 331 | sortRole(Qt::DisplayRole) | - |
| 332 | { | - |
| 333 | root->setFlags(Qt::ItemIsDropEnabled); executed (the execution status of this line is deduced): root->setFlags(Qt::ItemIsDropEnabled); | - |
| 334 | } executed: }Execution Count:1907 | 1907 |
| 335 | | - |
| 336 | /*! | - |
| 337 | \internal | - |
| 338 | */ | - |
| 339 | QStandardItemModelPrivate::~QStandardItemModelPrivate() | - |
| 340 | { | - |
| 341 | delete itemPrototype; executed (the execution status of this line is deduced): delete itemPrototype; | - |
| 342 | qDeleteAll(columnHeaderItems); executed (the execution status of this line is deduced): qDeleteAll(columnHeaderItems); | - |
| 343 | qDeleteAll(rowHeaderItems); executed (the execution status of this line is deduced): qDeleteAll(rowHeaderItems); | - |
| 344 | } executed: }Execution Count:1749 | 1749 |
| 345 | | - |
| 346 | /*! | - |
| 347 | \internal | - |
| 348 | */ | - |
| 349 | void QStandardItemModelPrivate::init() | - |
| 350 | { | - |
| 351 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 352 | QObject::connect(q, SIGNAL(dataChanged(QModelIndex,QModelIndex)), executed (the execution status of this line is deduced): QObject::connect(q, "2""dataChanged(QModelIndex,QModelIndex)", | - |
| 353 | q, SLOT(_q_emitItemChanged(QModelIndex,QModelIndex))); executed (the execution status of this line is deduced): q, "1""_q_emitItemChanged(QModelIndex,QModelIndex)"); | - |
| 354 | } executed: }Execution Count:1907 | 1907 |
| 355 | | - |
| 356 | /*! | - |
| 357 | \internal | - |
| 358 | */ | - |
| 359 | void QStandardItemModelPrivate::_q_emitItemChanged(const QModelIndex &topLeft, | - |
| 360 | const QModelIndex &bottomRight) | - |
| 361 | { | - |
| 362 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 363 | QModelIndex parent = topLeft.parent(); executed (the execution status of this line is deduced): QModelIndex parent = topLeft.parent(); | - |
| 364 | for (int row = topLeft.row(); row <= bottomRight.row(); ++row) { evaluated: row <= bottomRight.row()| yes Evaluation Count:6888989 | yes Evaluation Count:6888989 |
| 6888989 |
| 365 | for (int column = topLeft.column(); column <= bottomRight.column(); ++column) { evaluated: column <= bottomRight.column()| yes Evaluation Count:6888990 | yes Evaluation Count:6888989 |
| 6888989-6888990 |
| 366 | QModelIndex index = q->index(row, column, parent); executed (the execution status of this line is deduced): QModelIndex index = q->index(row, column, parent); | - |
| 367 | if (QStandardItem *item = itemFromIndex(index)) partially evaluated: QStandardItem *item = itemFromIndex(index)| yes Evaluation Count:6888990 | no Evaluation Count:0 |
| 0-6888990 |
| 368 | emit q->itemChanged(item); executed: q->itemChanged(item);Execution Count:6888990 | 6888990 |
| 369 | } executed: }Execution Count:6888990 | 6888990 |
| 370 | } executed: }Execution Count:6888989 | 6888989 |
| 371 | } executed: }Execution Count:6888989 | 6888989 |
| 372 | | - |
| 373 | /*! | - |
| 374 | \internal | - |
| 375 | */ | - |
| 376 | bool QStandardItemPrivate::insertRows(int row, const QList<QStandardItem*> &items) | - |
| 377 | { | - |
| 378 | Q_Q(QStandardItem); executed (the execution status of this line is deduced): QStandardItem * const q = q_func(); | - |
| 379 | if ((row < 0) || (row > rowCount())) partially evaluated: (row < 0)| no Evaluation Count:0 | yes Evaluation Count:232 |
partially evaluated: (row > rowCount())| no Evaluation Count:0 | yes Evaluation Count:232 |
| 0-232 |
| 380 | return false; never executed: return false; | 0 |
| 381 | int count = items.count(); executed (the execution status of this line is deduced): int count = items.count(); | - |
| 382 | if (model) evaluated: model| yes Evaluation Count:231 | yes Evaluation Count:1 |
| 1-231 |
| 383 | model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1); executed: model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1);Execution Count:231 | 231 |
| 384 | if (rowCount() == 0) { evaluated: rowCount() == 0| yes Evaluation Count:231 | yes Evaluation Count:1 |
| 1-231 |
| 385 | if (columnCount() == 0) evaluated: columnCount() == 0| yes Evaluation Count:1 | yes Evaluation Count:230 |
| 1-230 |
| 386 | q->setColumnCount(1); executed: q->setColumnCount(1);Execution Count:1 | 1 |
| 387 | children.resize(columnCount() * count); executed (the execution status of this line is deduced): children.resize(columnCount() * count); | - |
| 388 | rows = count; executed (the execution status of this line is deduced): rows = count; | - |
| 389 | } else { executed: }Execution Count:231 | 231 |
| 390 | rows += count; executed (the execution status of this line is deduced): rows += count; | - |
| 391 | int index = childIndex(row, 0); executed (the execution status of this line is deduced): int index = childIndex(row, 0); | - |
| 392 | if (index != -1) partially evaluated: index != -1| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 393 | children.insert(index, columnCount() * count, 0); executed: children.insert(index, columnCount() * count, 0);Execution Count:1 | 1 |
| 394 | } executed: }Execution Count:1 | 1 |
| 395 | for (int i = 0; i < items.count(); ++i) { evaluated: i < items.count()| yes Evaluation Count:10346 | yes Evaluation Count:232 |
| 232-10346 |
| 396 | QStandardItem *item = items.at(i); executed (the execution status of this line is deduced): QStandardItem *item = items.at(i); | - |
| 397 | item->d_func()->model = model; executed (the execution status of this line is deduced): item->d_func()->model = model; | - |
| 398 | item->d_func()->parent = q; executed (the execution status of this line is deduced): item->d_func()->parent = q; | - |
| 399 | int index = childIndex(i + row, 0); executed (the execution status of this line is deduced): int index = childIndex(i + row, 0); | - |
| 400 | children.replace(index, item); executed (the execution status of this line is deduced): children.replace(index, item); | - |
| 401 | } executed: }Execution Count:10346 | 10346 |
| 402 | if (model) evaluated: model| yes Evaluation Count:231 | yes Evaluation Count:1 |
| 1-231 |
| 403 | model->d_func()->rowsInserted(q, row, count); executed: model->d_func()->rowsInserted(q, row, count);Execution Count:231 | 231 |
| 404 | return true; executed: return true;Execution Count:232 | 232 |
| 405 | } | - |
| 406 | | - |
| 407 | bool QStandardItemPrivate::insertRows(int row, int count, const QList<QStandardItem*> &items) | - |
| 408 | { | - |
| 409 | Q_Q(QStandardItem); executed (the execution status of this line is deduced): QStandardItem * const q = q_func(); | - |
| 410 | if ((count < 1) || (row < 0) || (row > rowCount())) evaluated: (count < 1)| yes Evaluation Count:585 | yes Evaluation Count:24672 |
evaluated: (row < 0)| yes Evaluation Count:5 | yes Evaluation Count:24667 |
evaluated: (row > rowCount())| yes Evaluation Count:5 | yes Evaluation Count:24662 |
| 5-24672 |
| 411 | return false; executed: return false;Execution Count:595 | 595 |
| 412 | if (model) evaluated: model| yes Evaluation Count:23971 | yes Evaluation Count:691 |
| 691-23971 |
| 413 | model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1); executed: model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1);Execution Count:23971 | 23971 |
| 414 | if (rowCount() == 0) { evaluated: rowCount() == 0| yes Evaluation Count:8674 | yes Evaluation Count:15988 |
| 8674-15988 |
| 415 | children.resize(columnCount() * count); executed (the execution status of this line is deduced): children.resize(columnCount() * count); | - |
| 416 | rows = count; executed (the execution status of this line is deduced): rows = count; | - |
| 417 | } else { executed: }Execution Count:8674 | 8674 |
| 418 | rows += count; executed (the execution status of this line is deduced): rows += count; | - |
| 419 | int index = childIndex(row, 0); executed (the execution status of this line is deduced): int index = childIndex(row, 0); | - |
| 420 | if (index != -1) evaluated: index != -1| yes Evaluation Count:3012 | yes Evaluation Count:12976 |
| 3012-12976 |
| 421 | children.insert(index, columnCount() * count, 0); executed: children.insert(index, columnCount() * count, 0);Execution Count:3012 | 3012 |
| 422 | } executed: }Execution Count:15988 | 15988 |
| 423 | if (!items.isEmpty()) { evaluated: !items.isEmpty()| yes Evaluation Count:1830 | yes Evaluation Count:22832 |
| 1830-22832 |
| 424 | int index = childIndex(row, 0); executed (the execution status of this line is deduced): int index = childIndex(row, 0); | - |
| 425 | int limit = qMin(items.count(), columnCount() * count); executed (the execution status of this line is deduced): int limit = qMin(items.count(), columnCount() * count); | - |
| 426 | for (int i = 0; i < limit; ++i) { evaluated: i < limit| yes Evaluation Count:4545 | yes Evaluation Count:1830 |
| 1830-4545 |
| 427 | QStandardItem *item = items.at(i); executed (the execution status of this line is deduced): QStandardItem *item = items.at(i); | - |
| 428 | if (item) { partially evaluated: item| yes Evaluation Count:4545 | no Evaluation Count:0 |
| 0-4545 |
| 429 | if (item->d_func()->parent == 0) { partially evaluated: item->d_func()->parent == 0| yes Evaluation Count:4545 | no Evaluation Count:0 |
| 0-4545 |
| 430 | item->d_func()->setParentAndModel(q, model); executed (the execution status of this line is deduced): item->d_func()->setParentAndModel(q, model); | - |
| 431 | } else { executed: }Execution Count:4545 | 4545 |
| 432 | qWarning("QStandardItem::insertRows: Ignoring duplicate insertion of item %p", never executed (the execution status of this line is deduced): QMessageLogger("itemmodels/qstandarditemmodel.cpp", 432, __PRETTY_FUNCTION__).warning("QStandardItem::insertRows: Ignoring duplicate insertion of item %p", | - |
| 433 | item); never executed (the execution status of this line is deduced): item); | - |
| 434 | item = 0; never executed (the execution status of this line is deduced): item = 0; | - |
| 435 | } | 0 |
| 436 | } | - |
| 437 | children.replace(index, item); executed (the execution status of this line is deduced): children.replace(index, item); | - |
| 438 | ++index; executed (the execution status of this line is deduced): ++index; | - |
| 439 | } executed: }Execution Count:4545 | 4545 |
| 440 | } executed: }Execution Count:1830 | 1830 |
| 441 | if (model) evaluated: model| yes Evaluation Count:23971 | yes Evaluation Count:691 |
| 691-23971 |
| 442 | model->d_func()->rowsInserted(q, row, count); executed: model->d_func()->rowsInserted(q, row, count);Execution Count:23971 | 23971 |
| 443 | return true; executed: return true;Execution Count:24662 | 24662 |
| 444 | } | - |
| 445 | | - |
| 446 | /*! | - |
| 447 | \internal | - |
| 448 | */ | - |
| 449 | bool QStandardItemPrivate::insertColumns(int column, int count, const QList<QStandardItem*> &items) | - |
| 450 | { | - |
| 451 | Q_Q(QStandardItem); executed (the execution status of this line is deduced): QStandardItem * const q = q_func(); | - |
| 452 | if ((count < 1) || (column < 0) || (column > columnCount())) evaluated: (count < 1)| yes Evaluation Count:19 | yes Evaluation Count:10383 |
evaluated: (column < 0)| yes Evaluation Count:5 | yes Evaluation Count:10378 |
evaluated: (column > columnCount())| yes Evaluation Count:5 | yes Evaluation Count:10373 |
| 5-10383 |
| 453 | return false; executed: return false;Execution Count:29 | 29 |
| 454 | if (model) evaluated: model| yes Evaluation Count:9170 | yes Evaluation Count:1203 |
| 1203-9170 |
| 455 | model->d_func()->columnsAboutToBeInserted(q, column, column + count - 1); executed: model->d_func()->columnsAboutToBeInserted(q, column, column + count - 1);Execution Count:9170 | 9170 |
| 456 | if (columnCount() == 0) { evaluated: columnCount() == 0| yes Evaluation Count:10079 | yes Evaluation Count:294 |
| 294-10079 |
| 457 | children.resize(rowCount() * count); executed (the execution status of this line is deduced): children.resize(rowCount() * count); | - |
| 458 | columns = count; executed (the execution status of this line is deduced): columns = count; | - |
| 459 | } else { executed: }Execution Count:10079 | 10079 |
| 460 | columns += count; executed (the execution status of this line is deduced): columns += count; | - |
| 461 | int index = childIndex(0, column); executed (the execution status of this line is deduced): int index = childIndex(0, column); | - |
| 462 | for (int row = 0; row < rowCount(); ++row) { evaluated: row < rowCount()| yes Evaluation Count:9885 | yes Evaluation Count:294 |
| 294-9885 |
| 463 | children.insert(index, count, 0); executed (the execution status of this line is deduced): children.insert(index, count, 0); | - |
| 464 | index += columnCount(); executed (the execution status of this line is deduced): index += columnCount(); | - |
| 465 | } executed: }Execution Count:9885 | 9885 |
| 466 | } executed: }Execution Count:294 | 294 |
| 467 | if (!items.isEmpty()) { evaluated: !items.isEmpty()| yes Evaluation Count:61 | yes Evaluation Count:10312 |
| 61-10312 |
| 468 | int limit = qMin(items.count(), rowCount() * count); executed (the execution status of this line is deduced): int limit = qMin(items.count(), rowCount() * count); | - |
| 469 | for (int i = 0; i < limit; ++i) { evaluated: i < limit| yes Evaluation Count:358 | yes Evaluation Count:61 |
| 61-358 |
| 470 | QStandardItem *item = items.at(i); executed (the execution status of this line is deduced): QStandardItem *item = items.at(i); | - |
| 471 | if (item) { partially evaluated: item| yes Evaluation Count:358 | no Evaluation Count:0 |
| 0-358 |
| 472 | if (item->d_func()->parent == 0) { partially evaluated: item->d_func()->parent == 0| yes Evaluation Count:358 | no Evaluation Count:0 |
| 0-358 |
| 473 | item->d_func()->setParentAndModel(q, model); executed (the execution status of this line is deduced): item->d_func()->setParentAndModel(q, model); | - |
| 474 | } else { executed: }Execution Count:358 | 358 |
| 475 | qWarning("QStandardItem::insertColumns: Ignoring duplicate insertion of item %p", never executed (the execution status of this line is deduced): QMessageLogger("itemmodels/qstandarditemmodel.cpp", 475, __PRETTY_FUNCTION__).warning("QStandardItem::insertColumns: Ignoring duplicate insertion of item %p", | - |
| 476 | item); never executed (the execution status of this line is deduced): item); | - |
| 477 | item = 0; never executed (the execution status of this line is deduced): item = 0; | - |
| 478 | } | 0 |
| 479 | } | - |
| 480 | int r = i / count; executed (the execution status of this line is deduced): int r = i / count; | - |
| 481 | int c = column + (i % count); executed (the execution status of this line is deduced): int c = column + (i % count); | - |
| 482 | int index = childIndex(r, c); executed (the execution status of this line is deduced): int index = childIndex(r, c); | - |
| 483 | children.replace(index, item); executed (the execution status of this line is deduced): children.replace(index, item); | - |
| 484 | } executed: }Execution Count:358 | 358 |
| 485 | } executed: }Execution Count:61 | 61 |
| 486 | if (model) evaluated: model| yes Evaluation Count:9170 | yes Evaluation Count:1203 |
| 1203-9170 |
| 487 | model->d_func()->columnsInserted(q, column, count); executed: model->d_func()->columnsInserted(q, column, count);Execution Count:9170 | 9170 |
| 488 | return true; executed: return true;Execution Count:10373 | 10373 |
| 489 | } | - |
| 490 | | - |
| 491 | /*! | - |
| 492 | \internal | - |
| 493 | */ | - |
| 494 | void QStandardItemModelPrivate::itemChanged(QStandardItem *item) | - |
| 495 | { | - |
| 496 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 497 | if (item->d_func()->parent == 0) { evaluated: item->d_func()->parent == 0| yes Evaluation Count:125 | yes Evaluation Count:6888988 |
| 125-6888988 |
| 498 | // Header item | - |
| 499 | int idx = columnHeaderItems.indexOf(item); executed (the execution status of this line is deduced): int idx = columnHeaderItems.indexOf(item); | - |
| 500 | if (idx != -1) { evaluated: idx != -1| yes Evaluation Count:95 | yes Evaluation Count:30 |
| 30-95 |
| 501 | emit q->headerDataChanged(Qt::Horizontal, idx, idx); executed (the execution status of this line is deduced): q->headerDataChanged(Qt::Horizontal, idx, idx); | - |
| 502 | } else { executed: }Execution Count:95 | 95 |
| 503 | idx = rowHeaderItems.indexOf(item); executed (the execution status of this line is deduced): idx = rowHeaderItems.indexOf(item); | - |
| 504 | if (idx != -1) evaluated: idx != -1| yes Evaluation Count:28 | yes Evaluation Count:2 |
| 2-28 |
| 505 | emit q->headerDataChanged(Qt::Vertical, idx, idx); executed: q->headerDataChanged(Qt::Vertical, idx, idx);Execution Count:28 | 28 |
| 506 | } executed: }Execution Count:30 | 30 |
| 507 | } else { | - |
| 508 | // Normal item | - |
| 509 | QModelIndex index = q->indexFromItem(item); executed (the execution status of this line is deduced): QModelIndex index = q->indexFromItem(item); | - |
| 510 | emit q->dataChanged(index, index); executed (the execution status of this line is deduced): q->dataChanged(index, index); | - |
| 511 | } executed: }Execution Count:6888988 | 6888988 |
| 512 | } | - |
| 513 | | - |
| 514 | /*! | - |
| 515 | \internal | - |
| 516 | */ | - |
| 517 | void QStandardItemModelPrivate::rowsAboutToBeInserted(QStandardItem *parent, | - |
| 518 | int start, int end) | - |
| 519 | { | - |
| 520 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 521 | QModelIndex index = q->indexFromItem(parent); executed (the execution status of this line is deduced): QModelIndex index = q->indexFromItem(parent); | - |
| 522 | q->beginInsertRows(index, start, end); executed (the execution status of this line is deduced): q->beginInsertRows(index, start, end); | - |
| 523 | } executed: }Execution Count:24202 | 24202 |
| 524 | | - |
| 525 | /*! | - |
| 526 | \internal | - |
| 527 | */ | - |
| 528 | void QStandardItemModelPrivate::columnsAboutToBeInserted(QStandardItem *parent, | - |
| 529 | int start, int end) | - |
| 530 | { | - |
| 531 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 532 | QModelIndex index = q->indexFromItem(parent); executed (the execution status of this line is deduced): QModelIndex index = q->indexFromItem(parent); | - |
| 533 | q->beginInsertColumns(index, start, end); executed (the execution status of this line is deduced): q->beginInsertColumns(index, start, end); | - |
| 534 | } executed: }Execution Count:9170 | 9170 |
| 535 | | - |
| 536 | /*! | - |
| 537 | \internal | - |
| 538 | */ | - |
| 539 | void QStandardItemModelPrivate::rowsAboutToBeRemoved(QStandardItem *parent, | - |
| 540 | int start, int end) | - |
| 541 | { | - |
| 542 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 543 | QModelIndex index = q->indexFromItem(parent); executed (the execution status of this line is deduced): QModelIndex index = q->indexFromItem(parent); | - |
| 544 | q->beginRemoveRows(index, start, end); executed (the execution status of this line is deduced): q->beginRemoveRows(index, start, end); | - |
| 545 | } executed: }Execution Count:458 | 458 |
| 546 | | - |
| 547 | /*! | - |
| 548 | \internal | - |
| 549 | */ | - |
| 550 | void QStandardItemModelPrivate::columnsAboutToBeRemoved(QStandardItem *parent, | - |
| 551 | int start, int end) | - |
| 552 | { | - |
| 553 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 554 | QModelIndex index = q->indexFromItem(parent); executed (the execution status of this line is deduced): QModelIndex index = q->indexFromItem(parent); | - |
| 555 | q->beginRemoveColumns(index, start, end); executed (the execution status of this line is deduced): q->beginRemoveColumns(index, start, end); | - |
| 556 | } executed: }Execution Count:65 | 65 |
| 557 | | - |
| 558 | /*! | - |
| 559 | \internal | - |
| 560 | */ | - |
| 561 | void QStandardItemModelPrivate::rowsInserted(QStandardItem *parent, | - |
| 562 | int row, int count) | - |
| 563 | { | - |
| 564 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 565 | if (parent == root.data()) evaluated: parent == root.data()| yes Evaluation Count:15695 | yes Evaluation Count:8507 |
| 8507-15695 |
| 566 | rowHeaderItems.insert(row, count, 0); executed: rowHeaderItems.insert(row, count, 0);Execution Count:15695 | 15695 |
| 567 | q->endInsertRows(); executed (the execution status of this line is deduced): q->endInsertRows(); | - |
| 568 | } executed: }Execution Count:24202 | 24202 |
| 569 | | - |
| 570 | /*! | - |
| 571 | \internal | - |
| 572 | */ | - |
| 573 | void QStandardItemModelPrivate::columnsInserted(QStandardItem *parent, | - |
| 574 | int column, int count) | - |
| 575 | { | - |
| 576 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 577 | if (parent == root.data()) evaluated: parent == root.data()| yes Evaluation Count:1223 | yes Evaluation Count:7947 |
| 1223-7947 |
| 578 | columnHeaderItems.insert(column, count, 0); executed: columnHeaderItems.insert(column, count, 0);Execution Count:1223 | 1223 |
| 579 | q->endInsertColumns(); executed (the execution status of this line is deduced): q->endInsertColumns(); | - |
| 580 | } executed: }Execution Count:9170 | 9170 |
| 581 | | - |
| 582 | /*! | - |
| 583 | \internal | - |
| 584 | */ | - |
| 585 | void QStandardItemModelPrivate::rowsRemoved(QStandardItem *parent, | - |
| 586 | int row, int count) | - |
| 587 | { | - |
| 588 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 589 | if (parent == root.data()) { evaluated: parent == root.data()| yes Evaluation Count:405 | yes Evaluation Count:53 |
| 53-405 |
| 590 | for (int i = row; i < row + count; ++i) { evaluated: i < row + count| yes Evaluation Count:2688 | yes Evaluation Count:405 |
| 405-2688 |
| 591 | QStandardItem *oldItem = rowHeaderItems.at(i); executed (the execution status of this line is deduced): QStandardItem *oldItem = rowHeaderItems.at(i); | - |
| 592 | if (oldItem) evaluated: oldItem| yes Evaluation Count:1 | yes Evaluation Count:2687 |
| 1-2687 |
| 593 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0);Execution Count:1 | 1 |
| 594 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
| 595 | } executed: }Execution Count:2688 | 2688 |
| 596 | rowHeaderItems.remove(row, count); executed (the execution status of this line is deduced): rowHeaderItems.remove(row, count); | - |
| 597 | } executed: }Execution Count:405 | 405 |
| 598 | q->endRemoveRows(); executed (the execution status of this line is deduced): q->endRemoveRows(); | - |
| 599 | } executed: }Execution Count:458 | 458 |
| 600 | | - |
| 601 | /*! | - |
| 602 | \internal | - |
| 603 | */ | - |
| 604 | void QStandardItemModelPrivate::columnsRemoved(QStandardItem *parent, | - |
| 605 | int column, int count) | - |
| 606 | { | - |
| 607 | Q_Q(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModel * const q = q_func(); | - |
| 608 | if (parent == root.data()) { evaluated: parent == root.data()| yes Evaluation Count:29 | yes Evaluation Count:36 |
| 29-36 |
| 609 | for (int i = column; i < column + count; ++i) { evaluated: i < column + count| yes Evaluation Count:45 | yes Evaluation Count:29 |
| 29-45 |
| 610 | QStandardItem *oldItem = columnHeaderItems.at(i); executed (the execution status of this line is deduced): QStandardItem *oldItem = columnHeaderItems.at(i); | - |
| 611 | if (oldItem) evaluated: oldItem| yes Evaluation Count:13 | yes Evaluation Count:32 |
| 13-32 |
| 612 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0);Execution Count:13 | 13 |
| 613 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
| 614 | } executed: }Execution Count:45 | 45 |
| 615 | columnHeaderItems.remove(column, count); executed (the execution status of this line is deduced): columnHeaderItems.remove(column, count); | - |
| 616 | } executed: }Execution Count:29 | 29 |
| 617 | q->endRemoveColumns(); executed (the execution status of this line is deduced): q->endRemoveColumns(); | - |
| 618 | } executed: }Execution Count:65 | 65 |
| 619 | | - |
| 620 | /*! | - |
| 621 | \class QStandardItem | - |
| 622 | \brief The QStandardItem class provides an item for use with the | - |
| 623 | QStandardItemModel class. | - |
| 624 | \since 4.2 | - |
| 625 | \ingroup model-view | - |
| 626 | \inmodule QtGui | - |
| 627 | | - |
| 628 | Items usually contain text, icons, or checkboxes. | - |
| 629 | | - |
| 630 | Each item can have its own background brush which is set with the | - |
| 631 | setBackground() function. The current background brush can be found with | - |
| 632 | background(). The text label for each item can be rendered with its own | - |
| 633 | font and brush. These are specified with the setFont() and setForeground() | - |
| 634 | functions, and read with font() and foreground(). | - |
| 635 | | - |
| 636 | By default, items are enabled, editable, selectable, checkable, and can be | - |
| 637 | used both as the source of a drag and drop operation and as a drop target. | - |
| 638 | Each item's flags can be changed by calling setFlags(). Checkable items | - |
| 639 | can be checked and unchecked with the setCheckState() function. The | - |
| 640 | corresponding checkState() function indicates whether the item is | - |
| 641 | currently checked. | - |
| 642 | | - |
| 643 | You can store application-specific data in an item by calling setData(). | - |
| 644 | | - |
| 645 | Each item can have a two-dimensional table of child items. This makes it | - |
| 646 | possible to build hierarchies of items. The typical hierarchy is the tree, | - |
| 647 | in which case the child table is a table with a single column (a list). | - |
| 648 | | - |
| 649 | The dimensions of the child table can be set with setRowCount() and | - |
| 650 | setColumnCount(). Items can be positioned in the child table with | - |
| 651 | setChild(). Get a pointer to a child item with child(). New rows and | - |
| 652 | columns of children can also be inserted with insertRow() and | - |
| 653 | insertColumn(), or appended with appendRow() and appendColumn(). When | - |
| 654 | using the append and insert functions, the dimensions of the child table | - |
| 655 | will grow as needed. | - |
| 656 | | - |
| 657 | An existing row of children can be removed with removeRow() or takeRow(); | - |
| 658 | correspondingly, a column can be removed with removeColumn() or | - |
| 659 | takeColumn(). | - |
| 660 | | - |
| 661 | An item's children can be sorted by calling sortChildren(). | - |
| 662 | | - |
| 663 | \section1 Subclassing | - |
| 664 | | - |
| 665 | When subclassing QStandardItem to provide custom items, it is possible to | - |
| 666 | define new types for them so that they can be distinguished from the base | - |
| 667 | class. The type() function should be reimplemented to return a new type | - |
| 668 | value equal to or greater than \l UserType. | - |
| 669 | | - |
| 670 | Reimplement data() and setData() if you want to perform custom handling of | - |
| 671 | data queries and/or control how an item's data is represented. | - |
| 672 | | - |
| 673 | Reimplement clone() if you want QStandardItemModel to be able to create | - |
| 674 | instances of your custom item class on demand (see | - |
| 675 | QStandardItemModel::setItemPrototype()). | - |
| 676 | | - |
| 677 | Reimplement read() and write() if you want to control how items are | - |
| 678 | represented in their serialized form. | - |
| 679 | | - |
| 680 | Reimplement \l{operator<()} if you want to control the semantics of item | - |
| 681 | comparison. \l{operator<()} determines the sorted order when sorting items | - |
| 682 | with sortChildren() or with QStandardItemModel::sort(). | - |
| 683 | | - |
| 684 | \sa QStandardItemModel, {Item View Convenience Classes}, {Model/View Programming} | - |
| 685 | */ | - |
| 686 | | - |
| 687 | /*! | - |
| 688 | \enum QStandardItem::ItemType | - |
| 689 | | - |
| 690 | This enum describes the types that are used to describe standard items. | - |
| 691 | | - |
| 692 | \value Type The default type for standard items. | - |
| 693 | \value UserType The minimum value for custom types. Values below UserType are | - |
| 694 | reserved by Qt. | - |
| 695 | | - |
| 696 | You can define new user types in QStandardItem subclasses to ensure that | - |
| 697 | custom items are treated specially; for example, when items are sorted. | - |
| 698 | | - |
| 699 | \sa type() | - |
| 700 | */ | - |
| 701 | | - |
| 702 | /*! | - |
| 703 | Constructs an item. | - |
| 704 | */ | - |
| 705 | QStandardItem::QStandardItem() | - |
| 706 | : d_ptr(new QStandardItemPrivate) | - |
| 707 | { | - |
| 708 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 709 | d->q_ptr = this; executed (the execution status of this line is deduced): d->q_ptr = this; | - |
| 710 | } executed: }Execution Count:3480661 | 3480661 |
| 711 | | - |
| 712 | /*! | - |
| 713 | Constructs an item with the given \a text. | - |
| 714 | */ | - |
| 715 | QStandardItem::QStandardItem(const QString &text) | - |
| 716 | : d_ptr(new QStandardItemPrivate) | - |
| 717 | { | - |
| 718 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 719 | d->q_ptr = this; executed (the execution status of this line is deduced): d->q_ptr = this; | - |
| 720 | setText(text); executed (the execution status of this line is deduced): setText(text); | - |
| 721 | } executed: }Execution Count:16259 | 16259 |
| 722 | | - |
| 723 | /*! | - |
| 724 | Constructs an item with the given \a icon and \a text. | - |
| 725 | */ | - |
| 726 | QStandardItem::QStandardItem(const QIcon &icon, const QString &text) | - |
| 727 | : d_ptr(new QStandardItemPrivate) | - |
| 728 | { | - |
| 729 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 730 | d->q_ptr = this; executed (the execution status of this line is deduced): d->q_ptr = this; | - |
| 731 | setIcon(icon); executed (the execution status of this line is deduced): setIcon(icon); | - |
| 732 | setText(text); executed (the execution status of this line is deduced): setText(text); | - |
| 733 | } executed: }Execution Count:3 | 3 |
| 734 | | - |
| 735 | /*! | - |
| 736 | Constructs an item with \a rows rows and \a columns columns of child items. | - |
| 737 | */ | - |
| 738 | QStandardItem::QStandardItem(int rows, int columns) | - |
| 739 | : d_ptr(new QStandardItemPrivate) | - |
| 740 | { | - |
| 741 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 742 | d->q_ptr = this; executed (the execution status of this line is deduced): d->q_ptr = this; | - |
| 743 | setRowCount(rows); executed (the execution status of this line is deduced): setRowCount(rows); | - |
| 744 | setColumnCount(columns); executed (the execution status of this line is deduced): setColumnCount(columns); | - |
| 745 | } executed: }Execution Count:134 | 134 |
| 746 | | - |
| 747 | /*! | - |
| 748 | \internal | - |
| 749 | */ | - |
| 750 | QStandardItem::QStandardItem(QStandardItemPrivate &dd) | - |
| 751 | : d_ptr(&dd) | - |
| 752 | { | - |
| 753 | Q_D(QStandardItem); never executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 754 | d->q_ptr = this; never executed (the execution status of this line is deduced): d->q_ptr = this; | - |
| 755 | } | 0 |
| 756 | | - |
| 757 | /*! | - |
| 758 | Constructs a copy of \a other. Note that model() is | - |
| 759 | not copied. | - |
| 760 | | - |
| 761 | This function is useful when reimplementing clone(). | - |
| 762 | */ | - |
| 763 | QStandardItem::QStandardItem(const QStandardItem &other) | - |
| 764 | : d_ptr(new QStandardItemPrivate) | - |
| 765 | { | - |
| 766 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 767 | d->q_ptr = this; executed (the execution status of this line is deduced): d->q_ptr = this; | - |
| 768 | operator=(other); executed (the execution status of this line is deduced): operator=(other); | - |
| 769 | } executed: }Execution Count:1 | 1 |
| 770 | | - |
| 771 | /*! | - |
| 772 | Assigns \a other's data and flags to this item. Note that | - |
| 773 | type() and model() are not copied. | - |
| 774 | | - |
| 775 | This function is useful when reimplementing clone(). | - |
| 776 | */ | - |
| 777 | QStandardItem &QStandardItem::operator=(const QStandardItem &other) | - |
| 778 | { | - |
| 779 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 780 | d->values = other.d_func()->values; executed (the execution status of this line is deduced): d->values = other.d_func()->values; | - |
| 781 | return *this; executed: return *this;Execution Count:1 | 1 |
| 782 | } | - |
| 783 | | - |
| 784 | /*! | - |
| 785 | Destructs the item. | - |
| 786 | This causes the item's children to be destructed as well. | - |
| 787 | */ | - |
| 788 | QStandardItem::~QStandardItem() | - |
| 789 | { | - |
| 790 | } | - |
| 791 | | - |
| 792 | /*! | - |
| 793 | Returns the item's parent item, or 0 if the item has no parent. | - |
| 794 | \note For toplevel items parent() returns 0. To receive toplevel | - |
| 795 | item's parent use QStandardItemModel::invisibleRootItem() instead. | - |
| 796 | | - |
| 797 | \sa child(), QStandardItemModel::invisibleRootItem() | - |
| 798 | */ | - |
| 799 | QStandardItem *QStandardItem::parent() const | - |
| 800 | { | - |
| 801 | Q_D(const QStandardItem); executed (the execution status of this line is deduced): const QStandardItemPrivate * const d = d_func(); | - |
| 802 | if (!d->model || (d->model->d_func()->root.data() != d->parent)) evaluated: !d->model| yes Evaluation Count:103 | yes Evaluation Count:101 |
evaluated: (d->model->d_func()->root.data() != d->parent)| yes Evaluation Count:99 | yes Evaluation Count:2 |
| 2-103 |
| 803 | return d->parent; executed: return d->parent;Execution Count:202 | 202 |
| 804 | return 0; executed: return 0;Execution Count:2 | 2 |
| 805 | } | - |
| 806 | | - |
| 807 | /*! | - |
| 808 | Sets the item's data for the given \a role to the specified \a value. | - |
| 809 | | - |
| 810 | If you subclass QStandardItem and reimplement this function, your | - |
| 811 | reimplementation should call emitDataChanged() if you do not call | - |
| 812 | the base implementation of setData(). This will ensure that e.g. | - |
| 813 | views using the model are notified of the changes. | - |
| 814 | | - |
| 815 | \note The default implementation treats Qt::EditRole and Qt::DisplayRole | - |
| 816 | as referring to the same data. | - |
| 817 | | - |
| 818 | \sa Qt::ItemDataRole, data(), setFlags() | - |
| 819 | */ | - |
| 820 | void QStandardItem::setData(const QVariant &value, int role) | - |
| 821 | { | - |
| 822 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 823 | role = (role == Qt::EditRole) ? Qt::DisplayRole : role; evaluated: (role == Qt::EditRole)| yes Evaluation Count:3473084 | yes Evaluation Count:3431963 |
| 3431963-3473084 |
| 824 | QVector<QStandardItemData>::iterator it; executed (the execution status of this line is deduced): QVector<QStandardItemData>::iterator it; | - |
| 825 | for (it = d->values.begin(); it != d->values.end(); ++it) { evaluated: it != d->values.end()| yes Evaluation Count:3420967 | yes Evaluation Count:6902379 |
| 3420967-6902379 |
| 826 | if ((*it).role == role) { evaluated: (*it).role == role| yes Evaluation Count:2668 | yes Evaluation Count:3418299 |
| 2668-3418299 |
| 827 | if (value.isValid()) { evaluated: value.isValid()| yes Evaluation Count:2642 | yes Evaluation Count:26 |
| 26-2642 |
| 828 | if ((*it).value.type() == value.type() && (*it).value == value) evaluated: (*it).value.type() == value.type()| yes Evaluation Count:2342 | yes Evaluation Count:300 |
evaluated: (*it).value == value| yes Evaluation Count:1437 | yes Evaluation Count:905 |
| 300-2342 |
| 829 | return; executed: return;Execution Count:1437 | 1437 |
| 830 | (*it).value = value; executed (the execution status of this line is deduced): (*it).value = value; | - |
| 831 | } else { executed: }Execution Count:1205 | 1205 |
| 832 | d->values.erase(it); executed (the execution status of this line is deduced): d->values.erase(it); | - |
| 833 | } executed: }Execution Count:26 | 26 |
| 834 | if (d->model) evaluated: d->model| yes Evaluation Count:1163 | yes Evaluation Count:68 |
| 68-1163 |
| 835 | d->model->d_func()->itemChanged(this); executed: d->model->d_func()->itemChanged(this);Execution Count:1163 | 1163 |
| 836 | return; executed: return;Execution Count:1231 | 1231 |
| 837 | } | - |
| 838 | } executed: }Execution Count:3418299 | 3418299 |
| 839 | d->values.append(QStandardItemData(role, value)); executed (the execution status of this line is deduced): d->values.append(QStandardItemData(role, value)); | - |
| 840 | if (d->model) evaluated: d->model| yes Evaluation Count:6883928 | yes Evaluation Count:18451 |
| 18451-6883928 |
| 841 | d->model->d_func()->itemChanged(this); executed: d->model->d_func()->itemChanged(this);Execution Count:6883928 | 6883928 |
| 842 | } executed: }Execution Count:6902379 | 6902379 |
| 843 | | - |
| 844 | /*! | - |
| 845 | Returns the item's data for the given \a role, or an invalid | - |
| 846 | QVariant if there is no data for the role. | - |
| 847 | | - |
| 848 | \note The default implementation treats Qt::EditRole and Qt::DisplayRole | - |
| 849 | as referring to the same data. | - |
| 850 | */ | - |
| 851 | QVariant QStandardItem::data(int role) const | - |
| 852 | { | - |
| 853 | Q_D(const QStandardItem); executed (the execution status of this line is deduced): const QStandardItemPrivate * const d = d_func(); | - |
| 854 | role = (role == Qt::EditRole) ? Qt::DisplayRole : role; evaluated: (role == Qt::EditRole)| yes Evaluation Count:306 | yes Evaluation Count:807266 |
| 306-807266 |
| 855 | QVector<QStandardItemData>::const_iterator it; executed (the execution status of this line is deduced): QVector<QStandardItemData>::const_iterator it; | - |
| 856 | for (it = d->values.begin(); it != d->values.end(); ++it) { evaluated: it != d->values.end()| yes Evaluation Count:1258329 | yes Evaluation Count:456453 |
| 456453-1258329 |
| 857 | if ((*it).role == role) evaluated: (*it).role == role| yes Evaluation Count:351119 | yes Evaluation Count:907210 |
| 351119-907210 |
| 858 | return (*it).value; executed: return (*it).value;Execution Count:351119 | 351119 |
| 859 | } executed: }Execution Count:907210 | 907210 |
| 860 | return QVariant(); executed: return QVariant();Execution Count:456453 | 456453 |
| 861 | } | - |
| 862 | | - |
| 863 | /*! | - |
| 864 | \since 4.4 | - |
| 865 | | - |
| 866 | Causes the model associated with this item to emit a | - |
| 867 | \l{QAbstractItemModel::dataChanged()}{dataChanged}() signal for this | - |
| 868 | item. | - |
| 869 | | - |
| 870 | You normally only need to call this function if you have subclassed | - |
| 871 | QStandardItem and reimplemented data() and/or setData(). | - |
| 872 | | - |
| 873 | \sa setData() | - |
| 874 | */ | - |
| 875 | void QStandardItem::emitDataChanged() | - |
| 876 | { | - |
| 877 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 878 | if (d->model) evaluated: d->model| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 879 | d->model->d_func()->itemChanged(this); executed: d->model->d_func()->itemChanged(this);Execution Count:1 | 1 |
| 880 | } executed: }Execution Count:2 | 2 |
| 881 | | - |
| 882 | /*! | - |
| 883 | Sets the item flags for the item to \a flags. | - |
| 884 | | - |
| 885 | The item flags determine how the user can interact with the item. | - |
| 886 | This is often used to disable an item. | - |
| 887 | | - |
| 888 | \sa flags(), setData() | - |
| 889 | */ | - |
| 890 | void QStandardItem::setFlags(Qt::ItemFlags flags) | - |
| 891 | { | - |
| 892 | setData((int)flags, Qt::UserRole - 1); executed (the execution status of this line is deduced): setData((int)flags, Qt::UserRole - 1); | - |
| 893 | } executed: }Execution Count:2144 | 2144 |
| 894 | | - |
| 895 | /*! | - |
| 896 | Returns the item flags for the item. | - |
| 897 | | - |
| 898 | The item flags determine how the user can interact with the item. | - |
| 899 | | - |
| 900 | By default, items are enabled, editable, selectable, checkable, and can be | - |
| 901 | used both as the source of a drag and drop operation and as a drop target. | - |
| 902 | | - |
| 903 | \sa setFlags() | - |
| 904 | */ | - |
| 905 | Qt::ItemFlags QStandardItem::flags() const | - |
| 906 | { | - |
| 907 | QVariant v = data(Qt::UserRole - 1); executed (the execution status of this line is deduced): QVariant v = data(Qt::UserRole - 1); | - |
| 908 | if (!v.isValid()) evaluated: !v.isValid()| yes Evaluation Count:17362 | yes Evaluation Count:369 |
| 369-17362 |
| 909 | return (Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable executed: return (Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable |Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled);Execution Count:17362 | 17362 |
| 910 | |Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled); executed: return (Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable |Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled);Execution Count:17362 | 17362 |
| 911 | return Qt::ItemFlags(v.toInt()); executed: return Qt::ItemFlags(v.toInt());Execution Count:369 | 369 |
| 912 | } | - |
| 913 | | - |
| 914 | /*! | - |
| 915 | \fn QString QStandardItem::text() const | - |
| 916 | | - |
| 917 | Returns the item's text. This is the text that's presented to the user | - |
| 918 | in a view. | - |
| 919 | | - |
| 920 | \sa setText() | - |
| 921 | */ | - |
| 922 | | - |
| 923 | /*! | - |
| 924 | \fn void QStandardItem::setText(const QString &text) | - |
| 925 | | - |
| 926 | Sets the item's text to the \a text specified. | - |
| 927 | | - |
| 928 | \sa text(), setFont(), setForeground() | - |
| 929 | */ | - |
| 930 | | - |
| 931 | /*! | - |
| 932 | \fn QIcon QStandardItem::icon() const | - |
| 933 | | - |
| 934 | Returns the item's icon. | - |
| 935 | | - |
| 936 | \sa setIcon(), {QAbstractItemView::iconSize}{iconSize} | - |
| 937 | */ | - |
| 938 | | - |
| 939 | /*! | - |
| 940 | \fn void QStandardItem::setIcon(const QIcon &icon) | - |
| 941 | | - |
| 942 | Sets the item's icon to the \a icon specified. | - |
| 943 | */ | - |
| 944 | | - |
| 945 | /*! | - |
| 946 | \fn QString QStandardItem::statusTip() const | - |
| 947 | | - |
| 948 | Returns the item's status tip. | - |
| 949 | | - |
| 950 | \sa setStatusTip(), toolTip(), whatsThis() | - |
| 951 | */ | - |
| 952 | | - |
| 953 | /*! | - |
| 954 | \fn void QStandardItem::setStatusTip(const QString &statusTip) | - |
| 955 | | - |
| 956 | Sets the item's status tip to the string specified by \a statusTip. | - |
| 957 | | - |
| 958 | \sa statusTip(), setToolTip(), setWhatsThis() | - |
| 959 | */ | - |
| 960 | | - |
| 961 | /*! | - |
| 962 | \fn QString QStandardItem::toolTip() const | - |
| 963 | | - |
| 964 | Returns the item's tooltip. | - |
| 965 | | - |
| 966 | \sa setToolTip(), statusTip(), whatsThis() | - |
| 967 | */ | - |
| 968 | | - |
| 969 | /*! | - |
| 970 | \fn void QStandardItem::setToolTip(const QString &toolTip) | - |
| 971 | | - |
| 972 | Sets the item's tooltip to the string specified by \a toolTip. | - |
| 973 | | - |
| 974 | \sa toolTip(), setStatusTip(), setWhatsThis() | - |
| 975 | */ | - |
| 976 | | - |
| 977 | /*! | - |
| 978 | \fn QString QStandardItem::whatsThis() const | - |
| 979 | | - |
| 980 | Returns the item's "What's This?" help. | - |
| 981 | | - |
| 982 | \sa setWhatsThis(), toolTip(), statusTip() | - |
| 983 | */ | - |
| 984 | | - |
| 985 | /*! | - |
| 986 | \fn void QStandardItem::setWhatsThis(const QString &whatsThis) | - |
| 987 | | - |
| 988 | Sets the item's "What's This?" help to the string specified by \a whatsThis. | - |
| 989 | | - |
| 990 | \sa whatsThis(), setStatusTip(), setToolTip() | - |
| 991 | */ | - |
| 992 | | - |
| 993 | /*! | - |
| 994 | \fn QFont QStandardItem::font() const | - |
| 995 | | - |
| 996 | Returns the font used to render the item's text. | - |
| 997 | | - |
| 998 | \sa setFont() | - |
| 999 | */ | - |
| 1000 | | - |
| 1001 | /*! | - |
| 1002 | \fn void QStandardItem::setFont(const QFont &font) | - |
| 1003 | | - |
| 1004 | Sets the font used to display the item's text to the given \a font. | - |
| 1005 | | - |
| 1006 | \sa font(), setText(), setForeground() | - |
| 1007 | */ | - |
| 1008 | | - |
| 1009 | /*! | - |
| 1010 | \fn QBrush QStandardItem::background() const | - |
| 1011 | | - |
| 1012 | Returns the brush used to render the item's background. | - |
| 1013 | | - |
| 1014 | \sa foreground(), setBackground() | - |
| 1015 | */ | - |
| 1016 | | - |
| 1017 | /*! | - |
| 1018 | \fn void QStandardItem::setBackground(const QBrush &brush) | - |
| 1019 | | - |
| 1020 | Sets the item's background brush to the specified \a brush. | - |
| 1021 | | - |
| 1022 | \sa background(), setForeground() | - |
| 1023 | */ | - |
| 1024 | | - |
| 1025 | /*! | - |
| 1026 | \fn QBrush QStandardItem::foreground() const | - |
| 1027 | | - |
| 1028 | Returns the brush used to render the item's foreground (e.g. text). | - |
| 1029 | | - |
| 1030 | \sa setForeground(), background() | - |
| 1031 | */ | - |
| 1032 | | - |
| 1033 | /*! | - |
| 1034 | \fn void QStandardItem::setForeground(const QBrush &brush) | - |
| 1035 | | - |
| 1036 | Sets the brush used to display the item's foreground (e.g. text) to the | - |
| 1037 | given \a brush. | - |
| 1038 | | - |
| 1039 | \sa foreground(), setBackground(), setFont() | - |
| 1040 | */ | - |
| 1041 | | - |
| 1042 | /*! | - |
| 1043 | \fn int QStandardItem::textAlignment() const | - |
| 1044 | | - |
| 1045 | Returns the text alignment for the item's text. | - |
| 1046 | */ | - |
| 1047 | | - |
| 1048 | /*! | - |
| 1049 | \fn void QStandardItem::setTextAlignment(Qt::Alignment alignment) | - |
| 1050 | | - |
| 1051 | Sets the text alignment for the item's text to the \a alignment | - |
| 1052 | specified. | - |
| 1053 | | - |
| 1054 | \sa textAlignment() | - |
| 1055 | */ | - |
| 1056 | | - |
| 1057 | /*! | - |
| 1058 | \fn QSize QStandardItem::sizeHint() const | - |
| 1059 | | - |
| 1060 | Returns the size hint set for the item, or an invalid QSize if no | - |
| 1061 | size hint has been set. | - |
| 1062 | | - |
| 1063 | If no size hint has been set, the item delegate will compute the | - |
| 1064 | size hint based on the item data. | - |
| 1065 | | - |
| 1066 | \sa setSizeHint() | - |
| 1067 | */ | - |
| 1068 | | - |
| 1069 | /*! | - |
| 1070 | \fn void QStandardItem::setSizeHint(const QSize &size) | - |
| 1071 | | - |
| 1072 | Sets the size hint for the item to be \a size. | - |
| 1073 | If no size hint is set, the item delegate will compute the | - |
| 1074 | size hint based on the item data. | - |
| 1075 | | - |
| 1076 | \sa sizeHint() | - |
| 1077 | */ | - |
| 1078 | | - |
| 1079 | /*! | - |
| 1080 | \fn Qt::CheckState QStandardItem::checkState() const | - |
| 1081 | | - |
| 1082 | Returns the checked state of the item. | - |
| 1083 | | - |
| 1084 | \sa setCheckState(), isCheckable() | - |
| 1085 | */ | - |
| 1086 | | - |
| 1087 | /*! | - |
| 1088 | \fn void QStandardItem::setCheckState(Qt::CheckState state) | - |
| 1089 | | - |
| 1090 | Sets the check state of the item to be \a state. | - |
| 1091 | | - |
| 1092 | \sa checkState(), setCheckable() | - |
| 1093 | */ | - |
| 1094 | | - |
| 1095 | /*! | - |
| 1096 | \fn QString QStandardItem::accessibleText() const | - |
| 1097 | | - |
| 1098 | Returns the item's accessible text. | - |
| 1099 | | - |
| 1100 | The accessible text is used by assistive technologies (i.e. for users who | - |
| 1101 | cannot use conventional means of interaction). | - |
| 1102 | | - |
| 1103 | \sa setAccessibleText(), accessibleDescription() | - |
| 1104 | */ | - |
| 1105 | | - |
| 1106 | /*! | - |
| 1107 | \fn void QStandardItem::setAccessibleText(const QString &accessibleText) | - |
| 1108 | | - |
| 1109 | Sets the item's accessible text to the string specified by \a accessibleText. | - |
| 1110 | | - |
| 1111 | The accessible text is used by assistive technologies (i.e. for users who | - |
| 1112 | cannot use conventional means of interaction). | - |
| 1113 | | - |
| 1114 | \sa accessibleText(), setAccessibleDescription() | - |
| 1115 | */ | - |
| 1116 | | - |
| 1117 | /*! | - |
| 1118 | \fn QString QStandardItem::accessibleDescription() const | - |
| 1119 | | - |
| 1120 | Returns the item's accessible description. | - |
| 1121 | | - |
| 1122 | The accessible description is used by assistive technologies (i.e. for | - |
| 1123 | users who cannot use conventional means of interaction). | - |
| 1124 | | - |
| 1125 | \sa setAccessibleDescription(), accessibleText() | - |
| 1126 | */ | - |
| 1127 | | - |
| 1128 | /*! | - |
| 1129 | \fn void QStandardItem::setAccessibleDescription(const QString &accessibleDescription) | - |
| 1130 | | - |
| 1131 | Sets the item's accessible description to the string specified by \a | - |
| 1132 | accessibleDescription. | - |
| 1133 | | - |
| 1134 | The accessible description is used by assistive technologies (i.e. for | - |
| 1135 | users who cannot use conventional means of interaction). | - |
| 1136 | | - |
| 1137 | \sa accessibleDescription(), setAccessibleText() | - |
| 1138 | */ | - |
| 1139 | | - |
| 1140 | /*! | - |
| 1141 | Sets whether the item is enabled. If \a enabled is true, the item is enabled, | - |
| 1142 | meaning that the user can interact with the item; if \a enabled is false, the | - |
| 1143 | user cannot interact with the item. | - |
| 1144 | | - |
| 1145 | This flag takes precedence over the other item flags; e.g. if an item is not | - |
| 1146 | enabled, it cannot be selected by the user, even if the Qt::ItemIsSelectable | - |
| 1147 | flag has been set. | - |
| 1148 | | - |
| 1149 | \sa isEnabled(), Qt::ItemIsEnabled, setFlags() | - |
| 1150 | */ | - |
| 1151 | void QStandardItem::setEnabled(bool enabled) | - |
| 1152 | { | - |
| 1153 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1154 | d->changeFlags(enabled, Qt::ItemIsEnabled); executed (the execution status of this line is deduced): d->changeFlags(enabled, Qt::ItemIsEnabled); | - |
| 1155 | } executed: }Execution Count:116 | 116 |
| 1156 | | - |
| 1157 | /*! | - |
| 1158 | \fn bool QStandardItem::isEnabled() const | - |
| 1159 | | - |
| 1160 | Returns whether the item is enabled. | - |
| 1161 | | - |
| 1162 | When an item is enabled, the user can interact with it. The possible | - |
| 1163 | types of interaction are specified by the other item flags, such as | - |
| 1164 | isEditable() and isSelectable(). | - |
| 1165 | | - |
| 1166 | The default value is true. | - |
| 1167 | | - |
| 1168 | \sa setEnabled(), flags() | - |
| 1169 | */ | - |
| 1170 | | - |
| 1171 | /*! | - |
| 1172 | Sets whether the item is editable. If \a editable is true, the item can be | - |
| 1173 | edited by the user; otherwise, the user cannot edit the item. | - |
| 1174 | | - |
| 1175 | How the user can edit items in a view is determined by the view's edit | - |
| 1176 | triggers; see QAbstractItemView::editTriggers. | - |
| 1177 | | - |
| 1178 | \sa isEditable(), setFlags() | - |
| 1179 | */ | - |
| 1180 | void QStandardItem::setEditable(bool editable) | - |
| 1181 | { | - |
| 1182 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1183 | d->changeFlags(editable, Qt::ItemIsEditable); executed (the execution status of this line is deduced): d->changeFlags(editable, Qt::ItemIsEditable); | - |
| 1184 | } executed: }Execution Count:4 | 4 |
| 1185 | | - |
| 1186 | /*! | - |
| 1187 | \fn bool QStandardItem::isEditable() const | - |
| 1188 | | - |
| 1189 | Returns whether the item can be edited by the user. | - |
| 1190 | | - |
| 1191 | When an item is editable (and enabled), the user can edit the item by | - |
| 1192 | invoking one of the view's edit triggers; see | - |
| 1193 | QAbstractItemView::editTriggers. | - |
| 1194 | | - |
| 1195 | The default value is true. | - |
| 1196 | | - |
| 1197 | \sa setEditable(), flags() | - |
| 1198 | */ | - |
| 1199 | | - |
| 1200 | /*! | - |
| 1201 | Sets whether the item is selectable. If \a selectable is true, the item | - |
| 1202 | can be selected by the user; otherwise, the user cannot select the item. | - |
| 1203 | | - |
| 1204 | You can control the selection behavior and mode by manipulating their | - |
| 1205 | view properties; see QAbstractItemView::selectionMode and | - |
| 1206 | QAbstractItemView::selectionBehavior. | - |
| 1207 | | - |
| 1208 | \sa isSelectable(), setFlags() | - |
| 1209 | */ | - |
| 1210 | void QStandardItem::setSelectable(bool selectable) | - |
| 1211 | { | - |
| 1212 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1213 | d->changeFlags(selectable, Qt::ItemIsSelectable); executed (the execution status of this line is deduced): d->changeFlags(selectable, Qt::ItemIsSelectable); | - |
| 1214 | } executed: }Execution Count:2 | 2 |
| 1215 | | - |
| 1216 | /*! | - |
| 1217 | \fn bool QStandardItem::isSelectable() const | - |
| 1218 | | - |
| 1219 | Returns whether the item is selectable by the user. | - |
| 1220 | | - |
| 1221 | The default value is true. | - |
| 1222 | | - |
| 1223 | \sa setSelectable(), flags() | - |
| 1224 | */ | - |
| 1225 | | - |
| 1226 | /*! | - |
| 1227 | Sets whether the item is user-checkable. If \a checkable is true, the | - |
| 1228 | item can be checked by the user; otherwise, the user cannot check | - |
| 1229 | the item. | - |
| 1230 | | - |
| 1231 | The item delegate will render a checkable item with a check box next to the | - |
| 1232 | item's text. | - |
| 1233 | | - |
| 1234 | \sa isCheckable(), setCheckState(), setTristate() | - |
| 1235 | */ | - |
| 1236 | void QStandardItem::setCheckable(bool checkable) | - |
| 1237 | { | - |
| 1238 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1239 | if (checkable && !isCheckable()) { evaluated: checkable| yes Evaluation Count:49 | yes Evaluation Count:2 |
partially evaluated: !isCheckable()| yes Evaluation Count:49 | no Evaluation Count:0 |
| 0-49 |
| 1240 | // make sure there's data for the checkstate role | - |
| 1241 | if (!data(Qt::CheckStateRole).isValid()) evaluated: !data(Qt::CheckStateRole).isValid()| yes Evaluation Count:48 | yes Evaluation Count:1 |
| 1-48 |
| 1242 | setData(Qt::Unchecked, Qt::CheckStateRole); executed: setData(Qt::Unchecked, Qt::CheckStateRole);Execution Count:48 | 48 |
| 1243 | } executed: }Execution Count:49 | 49 |
| 1244 | d->changeFlags(checkable, Qt::ItemIsUserCheckable); executed (the execution status of this line is deduced): d->changeFlags(checkable, Qt::ItemIsUserCheckable); | - |
| 1245 | } executed: }Execution Count:51 | 51 |
| 1246 | | - |
| 1247 | /*! | - |
| 1248 | \fn bool QStandardItem::isCheckable() const | - |
| 1249 | | - |
| 1250 | Returns whether the item is user-checkable. | - |
| 1251 | | - |
| 1252 | The default value is false. | - |
| 1253 | | - |
| 1254 | \sa setCheckable(), checkState(), isTristate() | - |
| 1255 | */ | - |
| 1256 | | - |
| 1257 | /*! | - |
| 1258 | Sets whether the item is tristate. If \a tristate is true, the | - |
| 1259 | item is checkable with three separate states; otherwise, the item | - |
| 1260 | is checkable with two states. (Note that this also requires that | - |
| 1261 | the item is checkable; see isCheckable().) | - |
| 1262 | | - |
| 1263 | \sa isTristate(), setCheckable(), setCheckState() | - |
| 1264 | */ | - |
| 1265 | void QStandardItem::setTristate(bool tristate) | - |
| 1266 | { | - |
| 1267 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1268 | d->changeFlags(tristate, Qt::ItemIsTristate); executed (the execution status of this line is deduced): d->changeFlags(tristate, Qt::ItemIsTristate); | - |
| 1269 | } executed: }Execution Count:2 | 2 |
| 1270 | | - |
| 1271 | /*! | - |
| 1272 | \fn bool QStandardItem::isTristate() const | - |
| 1273 | | - |
| 1274 | Returns whether the item is tristate; that is, if it's checkable with three | - |
| 1275 | separate states. | - |
| 1276 | | - |
| 1277 | The default value is false. | - |
| 1278 | | - |
| 1279 | \sa setTristate(), isCheckable(), checkState() | - |
| 1280 | */ | - |
| 1281 | | - |
| 1282 | #ifndef QT_NO_DRAGANDDROP | - |
| 1283 | | - |
| 1284 | /*! | - |
| 1285 | Sets whether the item is drag enabled. If \a dragEnabled is true, the item | - |
| 1286 | can be dragged by the user; otherwise, the user cannot drag the item. | - |
| 1287 | | - |
| 1288 | Note that you also need to ensure that item dragging is enabled in the view; | - |
| 1289 | see QAbstractItemView::dragEnabled. | - |
| 1290 | | - |
| 1291 | \sa isDragEnabled(), setDropEnabled(), setFlags() | - |
| 1292 | */ | - |
| 1293 | void QStandardItem::setDragEnabled(bool dragEnabled) | - |
| 1294 | { | - |
| 1295 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1296 | d->changeFlags(dragEnabled, Qt::ItemIsDragEnabled); executed (the execution status of this line is deduced): d->changeFlags(dragEnabled, Qt::ItemIsDragEnabled); | - |
| 1297 | } executed: }Execution Count:2 | 2 |
| 1298 | | - |
| 1299 | /*! | - |
| 1300 | \fn bool QStandardItem::isDragEnabled() const | - |
| 1301 | | - |
| 1302 | Returns whether the item is drag enabled. An item that is drag enabled can | - |
| 1303 | be dragged by the user. | - |
| 1304 | | - |
| 1305 | The default value is true. | - |
| 1306 | | - |
| 1307 | Note that item dragging must be enabled in the view for dragging to work; | - |
| 1308 | see QAbstractItemView::dragEnabled. | - |
| 1309 | | - |
| 1310 | \sa setDragEnabled(), isDropEnabled(), flags() | - |
| 1311 | */ | - |
| 1312 | | - |
| 1313 | /*! | - |
| 1314 | Sets whether the item is drop enabled. If \a dropEnabled is true, the item | - |
| 1315 | can be used as a drop target; otherwise, it cannot. | - |
| 1316 | | - |
| 1317 | Note that you also need to ensure that drops are enabled in the view; see | - |
| 1318 | QWidget::acceptDrops(); and that the model supports the desired drop actions; | - |
| 1319 | see QAbstractItemModel::supportedDropActions(). | - |
| 1320 | | - |
| 1321 | \sa isDropEnabled(), setDragEnabled(), setFlags() | - |
| 1322 | */ | - |
| 1323 | void QStandardItem::setDropEnabled(bool dropEnabled) | - |
| 1324 | { | - |
| 1325 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1326 | d->changeFlags(dropEnabled, Qt::ItemIsDropEnabled); executed (the execution status of this line is deduced): d->changeFlags(dropEnabled, Qt::ItemIsDropEnabled); | - |
| 1327 | } executed: }Execution Count:3 | 3 |
| 1328 | | - |
| 1329 | /*! | - |
| 1330 | \fn bool QStandardItem::isDropEnabled() const | - |
| 1331 | | - |
| 1332 | Returns whether the item is drop enabled. When an item is drop enabled, it | - |
| 1333 | can be used as a drop target. | - |
| 1334 | | - |
| 1335 | The default value is true. | - |
| 1336 | | - |
| 1337 | \sa setDropEnabled(), isDragEnabled(), flags() | - |
| 1338 | */ | - |
| 1339 | | - |
| 1340 | #endif // QT_NO_DRAGANDDROP | - |
| 1341 | | - |
| 1342 | /*! | - |
| 1343 | Returns the row where the item is located in its parent's child table, or | - |
| 1344 | -1 if the item has no parent. | - |
| 1345 | | - |
| 1346 | \sa column(), parent() | - |
| 1347 | */ | - |
| 1348 | int QStandardItem::row() const | - |
| 1349 | { | - |
| 1350 | Q_D(const QStandardItem); executed (the execution status of this line is deduced): const QStandardItemPrivate * const d = d_func(); | - |
| 1351 | QPair<int, int> pos = d->position(); executed (the execution status of this line is deduced): QPair<int, int> pos = d->position(); | - |
| 1352 | return pos.first; executed: return pos.first;Execution Count:2770 | 2770 |
| 1353 | } | - |
| 1354 | | - |
| 1355 | /*! | - |
| 1356 | Returns the column where the item is located in its parent's child table, | - |
| 1357 | or -1 if the item has no parent. | - |
| 1358 | | - |
| 1359 | \sa row(), parent() | - |
| 1360 | */ | - |
| 1361 | int QStandardItem::column() const | - |
| 1362 | { | - |
| 1363 | Q_D(const QStandardItem); executed (the execution status of this line is deduced): const QStandardItemPrivate * const d = d_func(); | - |
| 1364 | QPair<int, int> pos = d->position(); executed (the execution status of this line is deduced): QPair<int, int> pos = d->position(); | - |
| 1365 | return pos.second; executed: return pos.second;Execution Count:2770 | 2770 |
| 1366 | } | - |
| 1367 | | - |
| 1368 | /*! | - |
| 1369 | Returns the QModelIndex associated with this item. | - |
| 1370 | | - |
| 1371 | When you need to invoke item functionality in a QModelIndex-based API (e.g. | - |
| 1372 | QAbstractItemView), you can call this function to obtain an index that | - |
| 1373 | corresponds to the item's location in the model. | - |
| 1374 | | - |
| 1375 | If the item is not associated with a model, an invalid QModelIndex is | - |
| 1376 | returned. | - |
| 1377 | | - |
| 1378 | \sa model(), QStandardItemModel::itemFromIndex() | - |
| 1379 | */ | - |
| 1380 | QModelIndex QStandardItem::index() const | - |
| 1381 | { | - |
| 1382 | Q_D(const QStandardItem); executed (the execution status of this line is deduced): const QStandardItemPrivate * const d = d_func(); | - |
| 1383 | return d->model ? d->model->indexFromItem(this) : QModelIndex(); executed: return d->model ? d->model->indexFromItem(this) : QModelIndex();Execution Count:104 | 104 |
| 1384 | } | - |
| 1385 | | - |
| 1386 | /*! | - |
| 1387 | Returns the QStandardItemModel that this item belongs to. | - |
| 1388 | | - |
| 1389 | If the item is not a child of another item that belongs to the model, this | - |
| 1390 | function returns 0. | - |
| 1391 | | - |
| 1392 | \sa index() | - |
| 1393 | */ | - |
| 1394 | QStandardItemModel *QStandardItem::model() const | - |
| 1395 | { | - |
| 1396 | Q_D(const QStandardItem); executed (the execution status of this line is deduced): const QStandardItemPrivate * const d = d_func(); | - |
| 1397 | return d->model; executed: return d->model;Execution Count:10927 | 10927 |
| 1398 | } | - |
| 1399 | | - |
| 1400 | /*! | - |
| 1401 | Sets the number of child item rows to \a rows. If this is less than | - |
| 1402 | rowCount(), the data in the unwanted rows is discarded. | - |
| 1403 | | - |
| 1404 | \sa rowCount(), setColumnCount() | - |
| 1405 | */ | - |
| 1406 | void QStandardItem::setRowCount(int rows) | - |
| 1407 | { | - |
| 1408 | int rc = rowCount(); executed (the execution status of this line is deduced): int rc = rowCount(); | - |
| 1409 | if (rc == rows) evaluated: rc == rows| yes Evaluation Count:65 | yes Evaluation Count:13363 |
| 65-13363 |
| 1410 | return; executed: return;Execution Count:65 | 65 |
| 1411 | if (rc < rows) evaluated: rc < rows| yes Evaluation Count:13344 | yes Evaluation Count:19 |
| 19-13344 |
| 1412 | insertRows(qMax(rc, 0), rows - rc); executed: insertRows(qMax(rc, 0), rows - rc);Execution Count:13344 | 13344 |
| 1413 | else | - |
| 1414 | removeRows(qMax(rows, 0), rc - rows); executed: removeRows(qMax(rows, 0), rc - rows);Execution Count:19 | 19 |
| 1415 | } | - |
| 1416 | | - |
| 1417 | /*! | - |
| 1418 | Returns the number of child item rows that the item has. | - |
| 1419 | | - |
| 1420 | \sa setRowCount(), columnCount() | - |
| 1421 | */ | - |
| 1422 | int QStandardItem::rowCount() const | - |
| 1423 | { | - |
| 1424 | Q_D(const QStandardItem); executed (the execution status of this line is deduced): const QStandardItemPrivate * const d = d_func(); | - |
| 1425 | return d->rowCount(); executed: return d->rowCount();Execution Count:11196220 | 11196220 |
| 1426 | } | - |
| 1427 | | - |
| 1428 | /*! | - |
| 1429 | Sets the number of child item columns to \a columns. If this is less than | - |
| 1430 | columnCount(), the data in the unwanted columns is discarded. | - |
| 1431 | | - |
| 1432 | \sa columnCount(), setRowCount() | - |
| 1433 | */ | - |
| 1434 | void QStandardItem::setColumnCount(int columns) | - |
| 1435 | { | - |
| 1436 | int cc = columnCount(); executed (the execution status of this line is deduced): int cc = columnCount(); | - |
| 1437 | if (cc == columns) evaluated: cc == columns| yes Evaluation Count:35 | yes Evaluation Count:2204 |
| 35-2204 |
| 1438 | return; executed: return;Execution Count:35 | 35 |
| 1439 | if (cc < columns) evaluated: cc < columns| yes Evaluation Count:2200 | yes Evaluation Count:4 |
| 4-2200 |
| 1440 | insertColumns(qMax(cc, 0), columns - cc); executed: insertColumns(qMax(cc, 0), columns - cc);Execution Count:2200 | 2200 |
| 1441 | else | - |
| 1442 | removeColumns(qMax(columns, 0), cc - columns); executed: removeColumns(qMax(columns, 0), cc - columns);Execution Count:4 | 4 |
| 1443 | } | - |
| 1444 | | - |
| 1445 | /*! | - |
| 1446 | Returns the number of child item columns that the item has. | - |
| 1447 | | - |
| 1448 | \sa setColumnCount(), rowCount() | - |
| 1449 | */ | - |
| 1450 | int QStandardItem::columnCount() const | - |
| 1451 | { | - |
| 1452 | Q_D(const QStandardItem); executed (the execution status of this line is deduced): const QStandardItemPrivate * const d = d_func(); | - |
| 1453 | return d->columnCount(); executed: return d->columnCount();Execution Count:48638556 | 48638556 |
| 1454 | } | - |
| 1455 | | - |
| 1456 | /*! | - |
| 1457 | Inserts a row at \a row containing \a items. If necessary, the column | - |
| 1458 | count is increased to the size of \a items. | - |
| 1459 | | - |
| 1460 | \sa insertRows(), insertColumn() | - |
| 1461 | */ | - |
| 1462 | void QStandardItem::insertRow(int row, const QList<QStandardItem*> &items) | - |
| 1463 | { | - |
| 1464 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1465 | if (row < 0) evaluated: row < 0| yes Evaluation Count:2 | yes Evaluation Count:3199 |
| 2-3199 |
| 1466 | return; executed: return;Execution Count:2 | 2 |
| 1467 | if (columnCount() < items.count()) evaluated: columnCount() < items.count()| yes Evaluation Count:537 | yes Evaluation Count:2662 |
| 537-2662 |
| 1468 | setColumnCount(items.count()); executed: setColumnCount(items.count());Execution Count:537 | 537 |
| 1469 | d->insertRows(row, 1, items); executed (the execution status of this line is deduced): d->insertRows(row, 1, items); | - |
| 1470 | } executed: }Execution Count:3199 | 3199 |
| 1471 | | - |
| 1472 | /*! | - |
| 1473 | Inserts \a items at \a row. The column count won't be changed. | - |
| 1474 | | - |
| 1475 | \sa insertRow(), insertColumn() | - |
| 1476 | */ | - |
| 1477 | void QStandardItem::insertRows(int row, const QList<QStandardItem*> &items) | - |
| 1478 | { | - |
| 1479 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1480 | if (row < 0) partially evaluated: row < 0| no Evaluation Count:0 | yes Evaluation Count:232 |
| 0-232 |
| 1481 | return; | 0 |
| 1482 | d->insertRows(row, items); executed (the execution status of this line is deduced): d->insertRows(row, items); | - |
| 1483 | } executed: }Execution Count:232 | 232 |
| 1484 | | - |
| 1485 | /*! | - |
| 1486 | Inserts a column at \a column containing \a items. If necessary, | - |
| 1487 | the row count is increased to the size of \a items. | - |
| 1488 | | - |
| 1489 | \sa insertColumns(), insertRow() | - |
| 1490 | */ | - |
| 1491 | void QStandardItem::insertColumn(int column, const QList<QStandardItem*> &items) | - |
| 1492 | { | - |
| 1493 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1494 | if (column < 0) evaluated: column < 0| yes Evaluation Count:2 | yes Evaluation Count:66 |
| 2-66 |
| 1495 | return; executed: return;Execution Count:2 | 2 |
| 1496 | if (rowCount() < items.count()) evaluated: rowCount() < items.count()| yes Evaluation Count:33 | yes Evaluation Count:33 |
| 33 |
| 1497 | setRowCount(items.count()); executed: setRowCount(items.count());Execution Count:33 | 33 |
| 1498 | d->insertColumns(column, 1, items); executed (the execution status of this line is deduced): d->insertColumns(column, 1, items); | - |
| 1499 | } executed: }Execution Count:66 | 66 |
| 1500 | | - |
| 1501 | /*! | - |
| 1502 | Inserts \a count rows of child items at row \a row. | - |
| 1503 | | - |
| 1504 | \sa insertRow(), insertColumns() | - |
| 1505 | */ | - |
| 1506 | void QStandardItem::insertRows(int row, int count) | - |
| 1507 | { | - |
| 1508 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1509 | if (rowCount() < row) { partially evaluated: rowCount() < row| no Evaluation Count:0 | yes Evaluation Count:14229 |
| 0-14229 |
| 1510 | count += row - rowCount(); never executed (the execution status of this line is deduced): count += row - rowCount(); | - |
| 1511 | row = rowCount(); never executed (the execution status of this line is deduced): row = rowCount(); | - |
| 1512 | } | 0 |
| 1513 | d->insertRows(row, count, QList<QStandardItem*>()); executed (the execution status of this line is deduced): d->insertRows(row, count, QList<QStandardItem*>()); | - |
| 1514 | } executed: }Execution Count:14229 | 14229 |
| 1515 | | - |
| 1516 | /*! | - |
| 1517 | Inserts \a count columns of child items at column \a column. | - |
| 1518 | | - |
| 1519 | \sa insertColumn(), insertRows() | - |
| 1520 | */ | - |
| 1521 | void QStandardItem::insertColumns(int column, int count) | - |
| 1522 | { | - |
| 1523 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1524 | if (columnCount() < column) { partially evaluated: columnCount() < column| no Evaluation Count:0 | yes Evaluation Count:3085 |
| 0-3085 |
| 1525 | count += column - columnCount(); never executed (the execution status of this line is deduced): count += column - columnCount(); | - |
| 1526 | column = columnCount(); never executed (the execution status of this line is deduced): column = columnCount(); | - |
| 1527 | } | 0 |
| 1528 | d->insertColumns(column, count, QList<QStandardItem*>()); executed (the execution status of this line is deduced): d->insertColumns(column, count, QList<QStandardItem*>()); | - |
| 1529 | } executed: }Execution Count:3085 | 3085 |
| 1530 | | - |
| 1531 | /*! | - |
| 1532 | \fn void QStandardItem::appendRow(const QList<QStandardItem*> &items) | - |
| 1533 | | - |
| 1534 | Appends a row containing \a items. If necessary, the column count is | - |
| 1535 | increased to the size of \a items. | - |
| 1536 | | - |
| 1537 | \sa insertRow() | - |
| 1538 | */ | - |
| 1539 | | - |
| 1540 | /*! | - |
| 1541 | \fn void QStandardItem::appendRows(const QList<QStandardItem*> &items) | - |
| 1542 | | - |
| 1543 | Appends rows containing \a items. The column count will not change. | - |
| 1544 | | - |
| 1545 | \sa insertRow() | - |
| 1546 | */ | - |
| 1547 | | - |
| 1548 | /*! | - |
| 1549 | \fn void QStandardItem::appendColumn(const QList<QStandardItem*> &items) | - |
| 1550 | | - |
| 1551 | Appends a column containing \a items. If necessary, the row count is | - |
| 1552 | increased to the size of \a items. | - |
| 1553 | | - |
| 1554 | \sa insertColumn() | - |
| 1555 | */ | - |
| 1556 | | - |
| 1557 | /*! | - |
| 1558 | \fn bool QStandardItemModel::insertRow(int row, const QModelIndex &parent) | - |
| 1559 | | - |
| 1560 | Inserts a single row before the given \a row in the child items of the | - |
| 1561 | \a parent specified. Returns true if the row is inserted; otherwise | - |
| 1562 | returns false. | - |
| 1563 | | - |
| 1564 | \sa insertRows(), insertColumn(), removeRow() | - |
| 1565 | */ | - |
| 1566 | | - |
| 1567 | /*! | - |
| 1568 | \fn bool QStandardItemModel::insertColumn(int column, const QModelIndex &parent) | - |
| 1569 | | - |
| 1570 | Inserts a single column before the given \a column in the child items of | - |
| 1571 | the \a parent specified. Returns true if the column is inserted; otherwise | - |
| 1572 | returns false. | - |
| 1573 | | - |
| 1574 | \sa insertColumns(), insertRow(), removeColumn() | - |
| 1575 | */ | - |
| 1576 | | - |
| 1577 | /*! | - |
| 1578 | \fn QStandardItem::insertRow(int row, QStandardItem *item) | - |
| 1579 | \overload | - |
| 1580 | | - |
| 1581 | Inserts a row at \a row containing \a item. | - |
| 1582 | | - |
| 1583 | When building a list or a tree that has only one column, this function | - |
| 1584 | provides a convenient way to insert a single new item. | - |
| 1585 | */ | - |
| 1586 | | - |
| 1587 | /*! | - |
| 1588 | \fn QStandardItem::appendRow(QStandardItem *item) | - |
| 1589 | \overload | - |
| 1590 | | - |
| 1591 | Appends a row containing \a item. | - |
| 1592 | | - |
| 1593 | When building a list or a tree that has only one column, this function | - |
| 1594 | provides a convenient way to append a single new item. | - |
| 1595 | */ | - |
| 1596 | | - |
| 1597 | /*! | - |
| 1598 | Removes the given \a row. The items that were in the row are deleted. | - |
| 1599 | | - |
| 1600 | \sa takeRow(), removeRows(), removeColumn() | - |
| 1601 | */ | - |
| 1602 | void QStandardItem::removeRow(int row) | - |
| 1603 | { | - |
| 1604 | removeRows(row, 1); executed (the execution status of this line is deduced): removeRows(row, 1); | - |
| 1605 | } executed: }Execution Count:10 | 10 |
| 1606 | | - |
| 1607 | /*! | - |
| 1608 | Removes the given \a column. The items that were in the | - |
| 1609 | column are deleted. | - |
| 1610 | | - |
| 1611 | \sa takeColumn(), removeColumns(), removeRow() | - |
| 1612 | */ | - |
| 1613 | void QStandardItem::removeColumn(int column) | - |
| 1614 | { | - |
| 1615 | removeColumns(column, 1); never executed (the execution status of this line is deduced): removeColumns(column, 1); | - |
| 1616 | } | 0 |
| 1617 | | - |
| 1618 | /*! | - |
| 1619 | Removes \a count rows at row \a row. The items that were in those rows are | - |
| 1620 | deleted. | - |
| 1621 | | - |
| 1622 | \sa removeRow(), removeColumn() | - |
| 1623 | */ | - |
| 1624 | void QStandardItem::removeRows(int row, int count) | - |
| 1625 | { | - |
| 1626 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1627 | if ((count < 1) || (row < 0) || ((row + count) > rowCount())) partially evaluated: (count < 1)| no Evaluation Count:0 | yes Evaluation Count:459 |
partially evaluated: (row < 0)| no Evaluation Count:0 | yes Evaluation Count:459 |
evaluated: ((row + count) > rowCount())| yes Evaluation Count:2 | yes Evaluation Count:457 |
| 0-459 |
| 1628 | return; executed: return;Execution Count:2 | 2 |
| 1629 | if (d->model) evaluated: d->model| yes Evaluation Count:456 | yes Evaluation Count:1 |
| 1-456 |
| 1630 | d->model->d_func()->rowsAboutToBeRemoved(this, row, row + count - 1); executed: d->model->d_func()->rowsAboutToBeRemoved(this, row, row + count - 1);Execution Count:456 | 456 |
| 1631 | int i = d->childIndex(row, 0); executed (the execution status of this line is deduced): int i = d->childIndex(row, 0); | - |
| 1632 | int n = count * d->columnCount(); executed (the execution status of this line is deduced): int n = count * d->columnCount(); | - |
| 1633 | for (int j = i; j < n+i; ++j) { evaluated: j < n+i| yes Evaluation Count:38708 | yes Evaluation Count:457 |
| 457-38708 |
| 1634 | QStandardItem *oldItem = d->children.at(j); executed (the execution status of this line is deduced): QStandardItem *oldItem = d->children.at(j); | - |
| 1635 | if (oldItem) evaluated: oldItem| yes Evaluation Count:4777 | yes Evaluation Count:33931 |
| 4777-33931 |
| 1636 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0);Execution Count:4777 | 4777 |
| 1637 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
| 1638 | } executed: }Execution Count:38708 | 38708 |
| 1639 | d->children.remove(qMax(i, 0), n); executed (the execution status of this line is deduced): d->children.remove(qMax(i, 0), n); | - |
| 1640 | d->rows -= count; executed (the execution status of this line is deduced): d->rows -= count; | - |
| 1641 | if (d->model) evaluated: d->model| yes Evaluation Count:456 | yes Evaluation Count:1 |
| 1-456 |
| 1642 | d->model->d_func()->rowsRemoved(this, row, count); executed: d->model->d_func()->rowsRemoved(this, row, count);Execution Count:456 | 456 |
| 1643 | } executed: }Execution Count:457 | 457 |
| 1644 | | - |
| 1645 | /*! | - |
| 1646 | Removes \a count columns at column \a column. The items that were in those | - |
| 1647 | columns are deleted. | - |
| 1648 | | - |
| 1649 | \sa removeColumn(), removeRows() | - |
| 1650 | */ | - |
| 1651 | void QStandardItem::removeColumns(int column, int count) | - |
| 1652 | { | - |
| 1653 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1654 | if ((count < 1) || (column < 0) || ((column + count) > columnCount())) partially evaluated: (count < 1)| no Evaluation Count:0 | yes Evaluation Count:67 |
partially evaluated: (column < 0)| no Evaluation Count:0 | yes Evaluation Count:67 |
evaluated: ((column + count) > columnCount())| yes Evaluation Count:2 | yes Evaluation Count:65 |
| 0-67 |
| 1655 | return; executed: return;Execution Count:2 | 2 |
| 1656 | if (d->model) evaluated: d->model| yes Evaluation Count:64 | yes Evaluation Count:1 |
| 1-64 |
| 1657 | d->model->d_func()->columnsAboutToBeRemoved(this, column, column + count - 1); executed: d->model->d_func()->columnsAboutToBeRemoved(this, column, column + count - 1);Execution Count:64 | 64 |
| 1658 | for (int row = d->rowCount() - 1; row >= 0; --row) { evaluated: row >= 0| yes Evaluation Count:1280 | yes Evaluation Count:65 |
| 65-1280 |
| 1659 | int i = d->childIndex(row, column); executed (the execution status of this line is deduced): int i = d->childIndex(row, column); | - |
| 1660 | for (int j=i; j<i+count; ++j) { evaluated: j<i+count| yes Evaluation Count:5605 | yes Evaluation Count:1280 |
| 1280-5605 |
| 1661 | QStandardItem *oldItem = d->children.at(j); executed (the execution status of this line is deduced): QStandardItem *oldItem = d->children.at(j); | - |
| 1662 | if (oldItem) evaluated: oldItem| yes Evaluation Count:111 | yes Evaluation Count:5494 |
| 111-5494 |
| 1663 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0);Execution Count:111 | 111 |
| 1664 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
| 1665 | } executed: }Execution Count:5605 | 5605 |
| 1666 | d->children.remove(i, count); executed (the execution status of this line is deduced): d->children.remove(i, count); | - |
| 1667 | } executed: }Execution Count:1280 | 1280 |
| 1668 | d->columns -= count; executed (the execution status of this line is deduced): d->columns -= count; | - |
| 1669 | if (d->model) evaluated: d->model| yes Evaluation Count:64 | yes Evaluation Count:1 |
| 1-64 |
| 1670 | d->model->d_func()->columnsRemoved(this, column, count); executed: d->model->d_func()->columnsRemoved(this, column, count);Execution Count:64 | 64 |
| 1671 | } executed: }Execution Count:65 | 65 |
| 1672 | | - |
| 1673 | /*! | - |
| 1674 | Returns true if this item has any children; otherwise returns false. | - |
| 1675 | | - |
| 1676 | \sa rowCount(), columnCount(), child() | - |
| 1677 | */ | - |
| 1678 | bool QStandardItem::hasChildren() const | - |
| 1679 | { | - |
| 1680 | return (rowCount() > 0) && (columnCount() > 0); executed: return (rowCount() > 0) && (columnCount() > 0);Execution Count:12057 | 12057 |
| 1681 | } | - |
| 1682 | | - |
| 1683 | /*! | - |
| 1684 | Sets the child item at (\a row, \a column) to \a item. This item (the parent | - |
| 1685 | item) takes ownership of \a item. If necessary, the row count and column | - |
| 1686 | count are increased to fit the item. | - |
| 1687 | | - |
| 1688 | \sa child() | - |
| 1689 | */ | - |
| 1690 | void QStandardItem::setChild(int row, int column, QStandardItem *item) | - |
| 1691 | { | - |
| 1692 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1693 | d->setChild(row, column, item, true); executed (the execution status of this line is deduced): d->setChild(row, column, item, true); | - |
| 1694 | } executed: }Execution Count:3194 | 3194 |
| 1695 | | - |
| 1696 | /*! | - |
| 1697 | \fn QStandardItem::setChild(int row, QStandardItem *item) | - |
| 1698 | \overload | - |
| 1699 | | - |
| 1700 | Sets the child at \a row to \a item. | - |
| 1701 | */ | - |
| 1702 | | - |
| 1703 | /*! | - |
| 1704 | Returns the child item at (\a row, \a column) if one has been set; otherwise | - |
| 1705 | returns 0. | - |
| 1706 | | - |
| 1707 | \sa setChild(), takeChild(), parent() | - |
| 1708 | */ | - |
| 1709 | QStandardItem *QStandardItem::child(int row, int column) const | - |
| 1710 | { | - |
| 1711 | Q_D(const QStandardItem); executed (the execution status of this line is deduced): const QStandardItemPrivate * const d = d_func(); | - |
| 1712 | int index = d->childIndex(row, column); executed (the execution status of this line is deduced): int index = d->childIndex(row, column); | - |
| 1713 | if (index == -1) evaluated: index == -1| yes Evaluation Count:5 | yes Evaluation Count:25135100 |
| 5-25135100 |
| 1714 | return 0; executed: return 0;Execution Count:5 | 5 |
| 1715 | return d->children.at(index); executed: return d->children.at(index);Execution Count:25135100 | 25135100 |
| 1716 | } | - |
| 1717 | | - |
| 1718 | /*! | - |
| 1719 | Removes the child item at (\a row, \a column) without deleting it, and returns | - |
| 1720 | a pointer to the item. If there was no child at the given location, then | - |
| 1721 | this function returns 0. | - |
| 1722 | | - |
| 1723 | Note that this function, unlike takeRow() and takeColumn(), does not affect | - |
| 1724 | the dimensions of the child table. | - |
| 1725 | | - |
| 1726 | \sa child(), takeRow(), takeColumn() | - |
| 1727 | */ | - |
| 1728 | QStandardItem *QStandardItem::takeChild(int row, int column) | - |
| 1729 | { | - |
| 1730 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1731 | QStandardItem *item = 0; executed (the execution status of this line is deduced): QStandardItem *item = 0; | - |
| 1732 | int index = d->childIndex(row, column); executed (the execution status of this line is deduced): int index = d->childIndex(row, column); | - |
| 1733 | if (index != -1) { partially evaluated: index != -1| yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-21 |
| 1734 | item = d->children.at(index); executed (the execution status of this line is deduced): item = d->children.at(index); | - |
| 1735 | if (item) evaluated: item| yes Evaluation Count:11 | yes Evaluation Count:10 |
| 10-11 |
| 1736 | item->d_func()->setParentAndModel(0, 0); executed: item->d_func()->setParentAndModel(0, 0);Execution Count:11 | 11 |
| 1737 | d->children.replace(index, 0); executed (the execution status of this line is deduced): d->children.replace(index, 0); | - |
| 1738 | } executed: }Execution Count:21 | 21 |
| 1739 | return item; executed: return item;Execution Count:21 | 21 |
| 1740 | } | - |
| 1741 | | - |
| 1742 | /*! | - |
| 1743 | Removes \a row without deleting the row items, and returns a list of | - |
| 1744 | pointers to the removed items. For items in the row that have not been | - |
| 1745 | set, the corresponding pointers in the list will be 0. | - |
| 1746 | | - |
| 1747 | \sa removeRow(), insertRow(), takeColumn() | - |
| 1748 | */ | - |
| 1749 | QList<QStandardItem*> QStandardItem::takeRow(int row) | - |
| 1750 | { | - |
| 1751 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1752 | if ((row < 0) || (row >= rowCount())) evaluated: (row < 0)| yes Evaluation Count:1 | yes Evaluation Count:13 |
evaluated: (row >= rowCount())| yes Evaluation Count:6 | yes Evaluation Count:7 |
| 1-13 |
| 1753 | return QList<QStandardItem*>(); executed: return QList<QStandardItem*>();Execution Count:7 | 7 |
| 1754 | if (d->model) evaluated: d->model| yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
| 1755 | d->model->d_func()->rowsAboutToBeRemoved(this, row, row); executed: d->model->d_func()->rowsAboutToBeRemoved(this, row, row);Execution Count:2 | 2 |
| 1756 | QList<QStandardItem*> items; executed (the execution status of this line is deduced): QList<QStandardItem*> items; | - |
| 1757 | int index = d->childIndex(row, 0); // Will return -1 if there are no columns executed (the execution status of this line is deduced): int index = d->childIndex(row, 0); | - |
| 1758 | if (index != -1) { evaluated: index != -1| yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
| 1759 | int col_count = d->columnCount(); executed (the execution status of this line is deduced): int col_count = d->columnCount(); | - |
| 1760 | for (int column = 0; column < col_count; ++column) { evaluated: column < col_count| yes Evaluation Count:27 | yes Evaluation Count:6 |
| 6-27 |
| 1761 | QStandardItem *ch = d->children.at(index + column); executed (the execution status of this line is deduced): QStandardItem *ch = d->children.at(index + column); | - |
| 1762 | if (ch) partially evaluated: ch| yes Evaluation Count:27 | no Evaluation Count:0 |
| 0-27 |
| 1763 | ch->d_func()->setParentAndModel(0, 0); executed: ch->d_func()->setParentAndModel(0, 0);Execution Count:27 | 27 |
| 1764 | items.append(ch); executed (the execution status of this line is deduced): items.append(ch); | - |
| 1765 | } executed: }Execution Count:27 | 27 |
| 1766 | d->children.remove(index, col_count); executed (the execution status of this line is deduced): d->children.remove(index, col_count); | - |
| 1767 | } executed: }Execution Count:6 | 6 |
| 1768 | d->rows--; executed (the execution status of this line is deduced): d->rows--; | - |
| 1769 | if (d->model) evaluated: d->model| yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
| 1770 | d->model->d_func()->rowsRemoved(this, row, 1); executed: d->model->d_func()->rowsRemoved(this, row, 1);Execution Count:2 | 2 |
| 1771 | return items; executed: return items;Execution Count:7 | 7 |
| 1772 | } | - |
| 1773 | | - |
| 1774 | /*! | - |
| 1775 | Removes \a column without deleting the column items, and returns a list of | - |
| 1776 | pointers to the removed items. For items in the column that have not been | - |
| 1777 | set, the corresponding pointers in the list will be 0. | - |
| 1778 | | - |
| 1779 | \sa removeColumn(), insertColumn(), takeRow() | - |
| 1780 | */ | - |
| 1781 | QList<QStandardItem*> QStandardItem::takeColumn(int column) | - |
| 1782 | { | - |
| 1783 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1784 | if ((column < 0) || (column >= columnCount())) evaluated: (column < 0)| yes Evaluation Count:1 | yes Evaluation Count:12 |
evaluated: (column >= columnCount())| yes Evaluation Count:6 | yes Evaluation Count:6 |
| 1-12 |
| 1785 | return QList<QStandardItem*>(); executed: return QList<QStandardItem*>();Execution Count:7 | 7 |
| 1786 | if (d->model) evaluated: d->model| yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
| 1787 | d->model->d_func()->columnsAboutToBeRemoved(this, column, column); executed: d->model->d_func()->columnsAboutToBeRemoved(this, column, column);Execution Count:1 | 1 |
| 1788 | QList<QStandardItem*> items; executed (the execution status of this line is deduced): QList<QStandardItem*> items; | - |
| 1789 | | - |
| 1790 | for (int row = d->rowCount() - 1; row >= 0; --row) { evaluated: row >= 0| yes Evaluation Count:26 | yes Evaluation Count:6 |
| 6-26 |
| 1791 | int index = d->childIndex(row, column); executed (the execution status of this line is deduced): int index = d->childIndex(row, column); | - |
| 1792 | QStandardItem *ch = d->children.at(index); executed (the execution status of this line is deduced): QStandardItem *ch = d->children.at(index); | - |
| 1793 | if (ch) partially evaluated: ch| yes Evaluation Count:26 | no Evaluation Count:0 |
| 0-26 |
| 1794 | ch->d_func()->setParentAndModel(0, 0); executed: ch->d_func()->setParentAndModel(0, 0);Execution Count:26 | 26 |
| 1795 | d->children.remove(index); executed (the execution status of this line is deduced): d->children.remove(index); | - |
| 1796 | items.prepend(ch); executed (the execution status of this line is deduced): items.prepend(ch); | - |
| 1797 | } executed: }Execution Count:26 | 26 |
| 1798 | d->columns--; executed (the execution status of this line is deduced): d->columns--; | - |
| 1799 | if (d->model) evaluated: d->model| yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
| 1800 | d->model->d_func()->columnsRemoved(this, column, 1); executed: d->model->d_func()->columnsRemoved(this, column, 1);Execution Count:1 | 1 |
| 1801 | return items; executed: return items;Execution Count:6 | 6 |
| 1802 | } | - |
| 1803 | | - |
| 1804 | /*! | - |
| 1805 | Returns true if this item is less than \a other; otherwise returns false. | - |
| 1806 | | - |
| 1807 | The default implementation uses the data for the item's sort role (see | - |
| 1808 | QStandardItemModel::sortRole) to perform the comparison if the item | - |
| 1809 | belongs to a model; otherwise, the data for the item's Qt::DisplayRole | - |
| 1810 | (text()) is used to perform the comparison. | - |
| 1811 | | - |
| 1812 | sortChildren() and QStandardItemModel::sort() use this function when | - |
| 1813 | sorting items. If you want custom sorting, you can subclass QStandardItem | - |
| 1814 | and reimplement this function. | - |
| 1815 | */ | - |
| 1816 | bool QStandardItem::operator<(const QStandardItem &other) const | - |
| 1817 | { | - |
| 1818 | const int role = model() ? model()->sortRole() : Qt::DisplayRole; evaluated: model()| yes Evaluation Count:5296 | yes Evaluation Count:14 |
| 14-5296 |
| 1819 | const QVariant l = data(role), r = other.data(role); executed (the execution status of this line is deduced): const QVariant l = data(role), r = other.data(role); | - |
| 1820 | // this code is copied from QSortFilterProxyModel::lessThan() | - |
| 1821 | switch (l.userType()) { | - |
| 1822 | case QVariant::Invalid: | - |
| 1823 | return (r.type() == QVariant::Invalid); executed: return (r.type() == QVariant::Invalid);Execution Count:2 | 2 |
| 1824 | case QVariant::Int: | - |
| 1825 | return l.toInt() < r.toInt(); executed: return l.toInt() < r.toInt();Execution Count:26 | 26 |
| 1826 | case QVariant::UInt: | - |
| 1827 | return l.toUInt() < r.toUInt(); never executed: return l.toUInt() < r.toUInt(); | 0 |
| 1828 | case QVariant::LongLong: | - |
| 1829 | return l.toLongLong() < r.toLongLong(); never executed: return l.toLongLong() < r.toLongLong(); | 0 |
| 1830 | case QVariant::ULongLong: | - |
| 1831 | return l.toULongLong() < r.toULongLong(); never executed: return l.toULongLong() < r.toULongLong(); | 0 |
| 1832 | case QMetaType::Float: | - |
| 1833 | return l.toFloat() < r.toFloat(); never executed: return l.toFloat() < r.toFloat(); | 0 |
| 1834 | case QVariant::Double: | - |
| 1835 | return l.toDouble() < r.toDouble(); never executed: return l.toDouble() < r.toDouble(); | 0 |
| 1836 | case QVariant::Char: | - |
| 1837 | return l.toChar() < r.toChar(); never executed: return l.toChar() < r.toChar(); | 0 |
| 1838 | case QVariant::Date: | - |
| 1839 | return l.toDate() < r.toDate(); never executed: return l.toDate() < r.toDate(); | 0 |
| 1840 | case QVariant::Time: | - |
| 1841 | return l.toTime() < r.toTime(); never executed: return l.toTime() < r.toTime(); | 0 |
| 1842 | case QVariant::DateTime: | - |
| 1843 | return l.toDateTime() < r.toDateTime(); never executed: return l.toDateTime() < r.toDateTime(); | 0 |
| 1844 | case QVariant::String: | - |
| 1845 | default: | - |
| 1846 | return l.toString().compare(r.toString()) < 0; executed: return l.toString().compare(r.toString()) < 0;Execution Count:5282 | 5282 |
| 1847 | } | - |
| 1848 | } | 0 |
| 1849 | | - |
| 1850 | /*! | - |
| 1851 | Sorts the children of the item using the given \a order, by the values in | - |
| 1852 | the given \a column. | - |
| 1853 | | - |
| 1854 | \note This function is recursive, therefore it sorts the children of the | - |
| 1855 | item, its grandchildren, etc. | - |
| 1856 | | - |
| 1857 | \sa {operator<()} | - |
| 1858 | */ | - |
| 1859 | void QStandardItem::sortChildren(int column, Qt::SortOrder order) | - |
| 1860 | { | - |
| 1861 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1862 | if ((column < 0) || (rowCount() == 0)) evaluated: (column < 0)| yes Evaluation Count:1 | yes Evaluation Count:49 |
partially evaluated: (rowCount() == 0)| no Evaluation Count:0 | yes Evaluation Count:49 |
| 0-49 |
| 1863 | return; executed: return;Execution Count:1 | 1 |
| 1864 | | - |
| 1865 | QList<QPersistentModelIndex> parents; executed (the execution status of this line is deduced): QList<QPersistentModelIndex> parents; | - |
| 1866 | if (d->model) { evaluated: d->model| yes Evaluation Count:46 | yes Evaluation Count:3 |
| 3-46 |
| 1867 | parents << index(); executed (the execution status of this line is deduced): parents << index(); | - |
| 1868 | emit d->model->layoutAboutToBeChanged(parents, QAbstractItemModel::VerticalSortHint); executed (the execution status of this line is deduced): d->model->layoutAboutToBeChanged(parents, QAbstractItemModel::VerticalSortHint); | - |
| 1869 | } executed: }Execution Count:46 | 46 |
| 1870 | d->sortChildren(column, order); executed (the execution status of this line is deduced): d->sortChildren(column, order); | - |
| 1871 | if (d->model) evaluated: d->model| yes Evaluation Count:46 | yes Evaluation Count:3 |
| 3-46 |
| 1872 | emit d->model->layoutChanged(parents, QAbstractItemModel::VerticalSortHint); executed: d->model->layoutChanged(parents, QAbstractItemModel::VerticalSortHint);Execution Count:46 | 46 |
| 1873 | } executed: }Execution Count:49 | 49 |
| 1874 | | - |
| 1875 | /*! | - |
| 1876 | Returns a copy of this item. The item's children are not copied. | - |
| 1877 | | - |
| 1878 | When subclassing QStandardItem, you can reimplement this function | - |
| 1879 | to provide QStandardItemModel with a factory that it can use to | - |
| 1880 | create new items on demand. | - |
| 1881 | | - |
| 1882 | \sa QStandardItemModel::setItemPrototype(), operator=() | - |
| 1883 | */ | - |
| 1884 | QStandardItem *QStandardItem::clone() const | - |
| 1885 | { | - |
| 1886 | return new QStandardItem(*this); executed: return new QStandardItem(*this);Execution Count:1 | 1 |
| 1887 | } | - |
| 1888 | | - |
| 1889 | /*! | - |
| 1890 | Returns the type of this item. The type is used to distinguish custom | - |
| 1891 | items from the base class. When subclassing QStandardItem, you should | - |
| 1892 | reimplement this function and return a new value greater than or equal | - |
| 1893 | to \l UserType. | - |
| 1894 | | - |
| 1895 | \sa QStandardItem::Type | - |
| 1896 | */ | - |
| 1897 | int QStandardItem::type() const | - |
| 1898 | { | - |
| 1899 | return Type; never executed: return Type; | 0 |
| 1900 | } | - |
| 1901 | | - |
| 1902 | #ifndef QT_NO_DATASTREAM | - |
| 1903 | | - |
| 1904 | /*! | - |
| 1905 | Reads the item from stream \a in. Only the data and flags of the item are | - |
| 1906 | read, not the child items. | - |
| 1907 | | - |
| 1908 | \sa write() | - |
| 1909 | */ | - |
| 1910 | void QStandardItem::read(QDataStream &in) | - |
| 1911 | { | - |
| 1912 | Q_D(QStandardItem); executed (the execution status of this line is deduced): QStandardItemPrivate * const d = d_func(); | - |
| 1913 | in >> d->values; executed (the execution status of this line is deduced): in >> d->values; | - |
| 1914 | qint32 flags; executed (the execution status of this line is deduced): qint32 flags; | - |
| 1915 | in >> flags; executed (the execution status of this line is deduced): in >> flags; | - |
| 1916 | setFlags(Qt::ItemFlags(flags)); executed (the execution status of this line is deduced): setFlags(Qt::ItemFlags(flags)); | - |
| 1917 | } executed: }Execution Count:1 | 1 |
| 1918 | | - |
| 1919 | /*! | - |
| 1920 | Writes the item to stream \a out. Only the data and flags of the item | - |
| 1921 | are written, not the child items. | - |
| 1922 | | - |
| 1923 | \sa read() | - |
| 1924 | */ | - |
| 1925 | void QStandardItem::write(QDataStream &out) const | - |
| 1926 | { | - |
| 1927 | Q_D(const QStandardItem); executed (the execution status of this line is deduced): const QStandardItemPrivate * const d = d_func(); | - |
| 1928 | out << d->values; executed (the execution status of this line is deduced): out << d->values; | - |
| 1929 | out << flags(); executed (the execution status of this line is deduced): out << flags(); | - |
| 1930 | } executed: }Execution Count:1 | 1 |
| 1931 | | - |
| 1932 | /*! | - |
| 1933 | \relates QStandardItem | - |
| 1934 | \since 4.2 | - |
| 1935 | | - |
| 1936 | Reads a QStandardItem from stream \a in into \a item. | - |
| 1937 | | - |
| 1938 | This operator uses QStandardItem::read(). | - |
| 1939 | | - |
| 1940 | \sa {Serializing Qt Data Types} | - |
| 1941 | */ | - |
| 1942 | QDataStream &operator>>(QDataStream &in, QStandardItem &item) | - |
| 1943 | { | - |
| 1944 | item.read(in); executed (the execution status of this line is deduced): item.read(in); | - |
| 1945 | return in; executed: return in;Execution Count:1 | 1 |
| 1946 | } | - |
| 1947 | | - |
| 1948 | /*! | - |
| 1949 | \relates QStandardItem | - |
| 1950 | \since 4.2 | - |
| 1951 | | - |
| 1952 | Writes the QStandardItem \a item to stream \a out. | - |
| 1953 | | - |
| 1954 | This operator uses QStandardItem::write(). | - |
| 1955 | | - |
| 1956 | \sa {Serializing Qt Data Types} | - |
| 1957 | */ | - |
| 1958 | QDataStream &operator<<(QDataStream &out, const QStandardItem &item) | - |
| 1959 | { | - |
| 1960 | item.write(out); executed (the execution status of this line is deduced): item.write(out); | - |
| 1961 | return out; executed: return out;Execution Count:1 | 1 |
| 1962 | } | - |
| 1963 | | - |
| 1964 | #endif // QT_NO_DATASTREAM | - |
| 1965 | | - |
| 1966 | /*! | - |
| 1967 | \class QStandardItemModel | - |
| 1968 | \brief The QStandardItemModel class provides a generic model for storing custom data. | - |
| 1969 | \ingroup model-view | - |
| 1970 | \inmodule QtGui | - |
| 1971 | | - |
| 1972 | QStandardItemModel can be used as a repository for standard Qt | - |
| 1973 | data types. It is one of the \l {Model/View Classes} and is part | - |
| 1974 | of Qt's \l {Model/View Programming}{model/view} framework. | - |
| 1975 | | - |
| 1976 | QStandardItemModel provides a classic item-based approach to working with | - |
| 1977 | the model. The items in a QStandardItemModel are provided by | - |
| 1978 | QStandardItem. | - |
| 1979 | | - |
| 1980 | QStandardItemModel implements the QAbstractItemModel interface, which | - |
| 1981 | means that the model can be used to provide data in any view that supports | - |
| 1982 | that interface (such as QListView, QTableView and QTreeView, and your own | - |
| 1983 | custom views). For performance and flexibility, you may want to subclass | - |
| 1984 | QAbstractItemModel to provide support for different kinds of data | - |
| 1985 | repositories. For example, the QDirModel provides a model interface to the | - |
| 1986 | underlying file system. | - |
| 1987 | | - |
| 1988 | When you want a list or tree, you typically create an empty | - |
| 1989 | QStandardItemModel and use appendRow() to add items to the model, and | - |
| 1990 | item() to access an item. If your model represents a table, you typically | - |
| 1991 | pass the dimensions of the table to the QStandardItemModel constructor and | - |
| 1992 | use setItem() to position items into the table. You can also use setRowCount() | - |
| 1993 | and setColumnCount() to alter the dimensions of the model. To insert items, | - |
| 1994 | use insertRow() or insertColumn(), and to remove items, use removeRow() or | - |
| 1995 | removeColumn(). | - |
| 1996 | | - |
| 1997 | You can set the header labels of your model with setHorizontalHeaderLabels() | - |
| 1998 | and setVerticalHeaderLabels(). | - |
| 1999 | | - |
| 2000 | You can search for items in the model with findItems(), and sort the model by | - |
| 2001 | calling sort(). | - |
| 2002 | | - |
| 2003 | Call clear() to remove all items from the model. | - |
| 2004 | | - |
| 2005 | An example usage of QStandardItemModel to create a table: | - |
| 2006 | | - |
| 2007 | \snippet code/src_gui_itemviews_qstandarditemmodel.cpp 0 | - |
| 2008 | | - |
| 2009 | An example usage of QStandardItemModel to create a tree: | - |
| 2010 | | - |
| 2011 | \snippet code/src_gui_itemviews_qstandarditemmodel.cpp 1 | - |
| 2012 | | - |
| 2013 | After setting the model on a view, you typically want to react to user | - |
| 2014 | actions, such as an item being clicked. Since a QAbstractItemView provides | - |
| 2015 | QModelIndex-based signals and functions, you need a way to obtain the | - |
| 2016 | QStandardItem that corresponds to a given QModelIndex, and vice | - |
| 2017 | versa. itemFromIndex() and indexFromItem() provide this mapping. Typical | - |
| 2018 | usage of itemFromIndex() includes obtaining the item at the current index | - |
| 2019 | in a view, and obtaining the item that corresponds to an index carried by | - |
| 2020 | a QAbstractItemView signal, such as QAbstractItemView::clicked(). First | - |
| 2021 | you connect the view's signal to a slot in your class: | - |
| 2022 | | - |
| 2023 | \snippet code/src_gui_itemviews_qstandarditemmodel.cpp 2 | - |
| 2024 | | - |
| 2025 | When you receive the signal, you call itemFromIndex() on the given model | - |
| 2026 | index to get a pointer to the item: | - |
| 2027 | | - |
| 2028 | \snippet code/src_gui_itemviews_qstandarditemmodel.cpp 3 | - |
| 2029 | | - |
| 2030 | Conversely, you must obtain the QModelIndex of an item when you want to | - |
| 2031 | invoke a model/view function that takes an index as argument. You can | - |
| 2032 | obtain the index either by using the model's indexFromItem() function, or, | - |
| 2033 | equivalently, by calling QStandardItem::index(): | - |
| 2034 | | - |
| 2035 | \snippet code/src_gui_itemviews_qstandarditemmodel.cpp 4 | - |
| 2036 | | - |
| 2037 | You are, of course, not required to use the item-based approach; you could | - |
| 2038 | instead rely entirely on the QAbstractItemModel interface when working with | - |
| 2039 | the model, or use a combination of the two as appropriate. | - |
| 2040 | | - |
| 2041 | \sa QStandardItem, {Model/View Programming}, QAbstractItemModel, | - |
| 2042 | {itemviews/simpletreemodel}{Simple Tree Model example}, | - |
| 2043 | {Item View Convenience Classes} | - |
| 2044 | */ | - |
| 2045 | | - |
| 2046 | /*! | - |
| 2047 | \fn void QStandardItemModel::itemChanged(QStandardItem *item) | - |
| 2048 | \since 4.2 | - |
| 2049 | | - |
| 2050 | This signal is emitted whenever the data of \a item has changed. | - |
| 2051 | */ | - |
| 2052 | | - |
| 2053 | /*! | - |
| 2054 | Constructs a new item model with the given \a parent. | - |
| 2055 | */ | - |
| 2056 | QStandardItemModel::QStandardItemModel(QObject *parent) | - |
| 2057 | : QAbstractItemModel(*new QStandardItemModelPrivate, parent) | - |
| 2058 | { | - |
| 2059 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2060 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
| 2061 | d->root->d_func()->setModel(this); executed (the execution status of this line is deduced): d->root->d_func()->setModel(this); | - |
| 2062 | } executed: }Execution Count:1022 | 1022 |
| 2063 | | - |
| 2064 | /*! | - |
| 2065 | Constructs a new item model that initially has \a rows rows and \a columns | - |
| 2066 | columns, and that has the given \a parent. | - |
| 2067 | */ | - |
| 2068 | QStandardItemModel::QStandardItemModel(int rows, int columns, QObject *parent) | - |
| 2069 | : QAbstractItemModel(*new QStandardItemModelPrivate, parent) | - |
| 2070 | { | - |
| 2071 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2072 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
| 2073 | d->root->insertColumns(0, columns); executed (the execution status of this line is deduced): d->root->insertColumns(0, columns); | - |
| 2074 | d->columnHeaderItems.insert(0, columns, 0); executed (the execution status of this line is deduced): d->columnHeaderItems.insert(0, columns, 0); | - |
| 2075 | d->root->insertRows(0, rows); executed (the execution status of this line is deduced): d->root->insertRows(0, rows); | - |
| 2076 | d->rowHeaderItems.insert(0, rows, 0); executed (the execution status of this line is deduced): d->rowHeaderItems.insert(0, rows, 0); | - |
| 2077 | d->root->d_func()->setModel(this); executed (the execution status of this line is deduced): d->root->d_func()->setModel(this); | - |
| 2078 | } executed: }Execution Count:885 | 885 |
| 2079 | | - |
| 2080 | /*! | - |
| 2081 | \internal | - |
| 2082 | */ | - |
| 2083 | QStandardItemModel::QStandardItemModel(QStandardItemModelPrivate &dd, QObject *parent) | - |
| 2084 | : QAbstractItemModel(dd, parent) | - |
| 2085 | { | - |
| 2086 | Q_D(QStandardItemModel); never executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2087 | d->init(); never executed (the execution status of this line is deduced): d->init(); | - |
| 2088 | } | 0 |
| 2089 | | - |
| 2090 | /*! | - |
| 2091 | Destructs the model. The model destroys all its items. | - |
| 2092 | */ | - |
| 2093 | QStandardItemModel::~QStandardItemModel() | - |
| 2094 | { | - |
| 2095 | } | - |
| 2096 | | - |
| 2097 | /*! | - |
| 2098 | Sets the item role names to \a roleNames. | - |
| 2099 | */ | - |
| 2100 | void QStandardItemModel::setItemRoleNames(const QHash<int,QByteArray> &roleNames) | - |
| 2101 | { | - |
| 2102 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2103 | d->roleNames = roleNames; executed (the execution status of this line is deduced): d->roleNames = roleNames; | - |
| 2104 | } executed: }Execution Count:1 | 1 |
| 2105 | | - |
| 2106 | /*! | - |
| 2107 | Removes all items (including header items) from the model and sets the | - |
| 2108 | number of rows and columns to zero. | - |
| 2109 | | - |
| 2110 | \sa removeColumns(), removeRows() | - |
| 2111 | */ | - |
| 2112 | void QStandardItemModel::clear() | - |
| 2113 | { | - |
| 2114 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2115 | beginResetModel(); executed (the execution status of this line is deduced): beginResetModel(); | - |
| 2116 | d->root.reset(new QStandardItem); executed (the execution status of this line is deduced): d->root.reset(new QStandardItem); | - |
| 2117 | d->root->d_func()->setModel(this); executed (the execution status of this line is deduced): d->root->d_func()->setModel(this); | - |
| 2118 | qDeleteAll(d->columnHeaderItems); executed (the execution status of this line is deduced): qDeleteAll(d->columnHeaderItems); | - |
| 2119 | d->columnHeaderItems.clear(); executed (the execution status of this line is deduced): d->columnHeaderItems.clear(); | - |
| 2120 | qDeleteAll(d->rowHeaderItems); executed (the execution status of this line is deduced): qDeleteAll(d->rowHeaderItems); | - |
| 2121 | d->rowHeaderItems.clear(); executed (the execution status of this line is deduced): d->rowHeaderItems.clear(); | - |
| 2122 | endResetModel(); executed (the execution status of this line is deduced): endResetModel(); | - |
| 2123 | } executed: }Execution Count:541 | 541 |
| 2124 | | - |
| 2125 | /*! | - |
| 2126 | \since 4.2 | - |
| 2127 | | - |
| 2128 | Returns a pointer to the QStandardItem associated with the given \a index. | - |
| 2129 | | - |
| 2130 | Calling this function is typically the initial step when processing | - |
| 2131 | QModelIndex-based signals from a view, such as | - |
| 2132 | QAbstractItemView::activated(). In your slot, you call itemFromIndex(), | - |
| 2133 | with the QModelIndex carried by the signal as argument, to obtain a | - |
| 2134 | pointer to the corresponding QStandardItem. | - |
| 2135 | | - |
| 2136 | Note that this function will lazily create an item for the index (using | - |
| 2137 | itemPrototype()), and set it in the parent item's child table, if no item | - |
| 2138 | already exists at that index. | - |
| 2139 | | - |
| 2140 | If \a index is an invalid index, this function returns 0. | - |
| 2141 | | - |
| 2142 | \sa indexFromItem() | - |
| 2143 | */ | - |
| 2144 | QStandardItem *QStandardItemModel::itemFromIndex(const QModelIndex &index) const | - |
| 2145 | { | - |
| 2146 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2147 | if ((index.row() < 0) || (index.column() < 0) || (index.model() != this)) evaluated: (index.row() < 0)| yes Evaluation Count:14 | yes Evaluation Count:6904474 |
partially evaluated: (index.column() < 0)| no Evaluation Count:0 | yes Evaluation Count:6904474 |
partially evaluated: (index.model() != this)| no Evaluation Count:0 | yes Evaluation Count:6904474 |
| 0-6904474 |
| 2148 | return 0; executed: return 0;Execution Count:14 | 14 |
| 2149 | QStandardItem *parent = static_cast<QStandardItem*>(index.internalPointer()); executed (the execution status of this line is deduced): QStandardItem *parent = static_cast<QStandardItem*>(index.internalPointer()); | - |
| 2150 | if (parent == 0) partially evaluated: parent == 0| no Evaluation Count:0 | yes Evaluation Count:6904474 |
| 0-6904474 |
| 2151 | return 0; never executed: return 0; | 0 |
| 2152 | QStandardItem *item = parent->child(index.row(), index.column()); executed (the execution status of this line is deduced): QStandardItem *item = parent->child(index.row(), index.column()); | - |
| 2153 | // lazy part | - |
| 2154 | if (item == 0) { evaluated: item == 0| yes Evaluation Count:3474639 | yes Evaluation Count:3429835 |
| 3429835-3474639 |
| 2155 | item = d->createItem(); executed (the execution status of this line is deduced): item = d->createItem(); | - |
| 2156 | parent->d_func()->setChild(index.row(), index.column(), item); executed (the execution status of this line is deduced): parent->d_func()->setChild(index.row(), index.column(), item); | - |
| 2157 | } executed: }Execution Count:3474639 | 3474639 |
| 2158 | return item; executed: return item;Execution Count:6904474 | 6904474 |
| 2159 | } | - |
| 2160 | | - |
| 2161 | /*! | - |
| 2162 | \since 4.2 | - |
| 2163 | | - |
| 2164 | Returns the QModelIndex associated with the given \a item. | - |
| 2165 | | - |
| 2166 | Use this function when you want to perform an operation that requires the | - |
| 2167 | QModelIndex of the item, such as | - |
| 2168 | QAbstractItemView::scrollTo(). QStandardItem::index() is provided as | - |
| 2169 | convenience; it is equivalent to calling this function. | - |
| 2170 | | - |
| 2171 | \sa itemFromIndex(), QStandardItem::index() | - |
| 2172 | */ | - |
| 2173 | QModelIndex QStandardItemModel::indexFromItem(const QStandardItem *item) const | - |
| 2174 | { | - |
| 2175 | if (item && item->d_func()->parent) { evaluated: item| yes Evaluation Count:17514841 | yes Evaluation Count:1 |
evaluated: item->d_func()->parent| yes Evaluation Count:17068735 | yes Evaluation Count:446106 |
| 1-17514841 |
| 2176 | QPair<int, int> pos = item->d_func()->position(); executed (the execution status of this line is deduced): QPair<int, int> pos = item->d_func()->position(); | - |
| 2177 | return createIndex(pos.first, pos.second, item->d_func()->parent); executed: return createIndex(pos.first, pos.second, item->d_func()->parent);Execution Count:17068735 | 17068735 |
| 2178 | } | - |
| 2179 | return QModelIndex(); executed: return QModelIndex();Execution Count:446107 | 446107 |
| 2180 | } | - |
| 2181 | | - |
| 2182 | /*! | - |
| 2183 | \since 4.2 | - |
| 2184 | | - |
| 2185 | Sets the number of rows in this model to \a rows. If | - |
| 2186 | this is less than rowCount(), the data in the unwanted rows | - |
| 2187 | is discarded. | - |
| 2188 | | - |
| 2189 | \sa setColumnCount() | - |
| 2190 | */ | - |
| 2191 | void QStandardItemModel::setRowCount(int rows) | - |
| 2192 | { | - |
| 2193 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2194 | d->root->setRowCount(rows); executed (the execution status of this line is deduced): d->root->setRowCount(rows); | - |
| 2195 | } executed: }Execution Count:13095 | 13095 |
| 2196 | | - |
| 2197 | /*! | - |
| 2198 | \since 4.2 | - |
| 2199 | | - |
| 2200 | Sets the number of columns in this model to \a columns. If | - |
| 2201 | this is less than columnCount(), the data in the unwanted columns | - |
| 2202 | is discarded. | - |
| 2203 | | - |
| 2204 | \sa setRowCount() | - |
| 2205 | */ | - |
| 2206 | void QStandardItemModel::setColumnCount(int columns) | - |
| 2207 | { | - |
| 2208 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2209 | d->root->setColumnCount(columns); executed (the execution status of this line is deduced): d->root->setColumnCount(columns); | - |
| 2210 | } executed: }Execution Count:76 | 76 |
| 2211 | | - |
| 2212 | /*! | - |
| 2213 | \since 4.2 | - |
| 2214 | | - |
| 2215 | Sets the item for the given \a row and \a column to \a item. The model | - |
| 2216 | takes ownership of the item. If necessary, the row count and column count | - |
| 2217 | are increased to fit the item. The previous item at the given location (if | - |
| 2218 | there was one) is deleted. | - |
| 2219 | | - |
| 2220 | \sa item() | - |
| 2221 | */ | - |
| 2222 | void QStandardItemModel::setItem(int row, int column, QStandardItem *item) | - |
| 2223 | { | - |
| 2224 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2225 | d->root->d_func()->setChild(row, column, item, true); executed (the execution status of this line is deduced): d->root->d_func()->setChild(row, column, item, true); | - |
| 2226 | } executed: }Execution Count:1249 | 1249 |
| 2227 | | - |
| 2228 | /*! | - |
| 2229 | \fn QStandardItemModel::setItem(int row, QStandardItem *item) | - |
| 2230 | \overload | - |
| 2231 | */ | - |
| 2232 | | - |
| 2233 | /*! | - |
| 2234 | \since 4.2 | - |
| 2235 | | - |
| 2236 | Returns the item for the given \a row and \a column if one has been set; | - |
| 2237 | otherwise returns 0. | - |
| 2238 | | - |
| 2239 | \sa setItem(), takeItem(), itemFromIndex() | - |
| 2240 | */ | - |
| 2241 | QStandardItem *QStandardItemModel::item(int row, int column) const | - |
| 2242 | { | - |
| 2243 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2244 | return d->root->child(row, column); executed: return d->root->child(row, column);Execution Count:2945 | 2945 |
| 2245 | } | - |
| 2246 | | - |
| 2247 | /*! | - |
| 2248 | \since 4.2 | - |
| 2249 | | - |
| 2250 | Returns the model's invisible root item. | - |
| 2251 | | - |
| 2252 | The invisible root item provides access to the model's top-level items | - |
| 2253 | through the QStandardItem API, making it possible to write functions that | - |
| 2254 | can treat top-level items and their children in a uniform way; for | - |
| 2255 | example, recursive functions involving a tree model. | - |
| 2256 | | - |
| 2257 | \note Calling \l{QAbstractItemModel::index()}{index()} on the QStandardItem object | - |
| 2258 | retrieved from this function is not valid. | - |
| 2259 | */ | - |
| 2260 | QStandardItem *QStandardItemModel::invisibleRootItem() const | - |
| 2261 | { | - |
| 2262 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2263 | return d->root.data(); executed: return d->root.data();Execution Count:1071 | 1071 |
| 2264 | } | - |
| 2265 | | - |
| 2266 | /*! | - |
| 2267 | \since 4.2 | - |
| 2268 | | - |
| 2269 | Sets the horizontal header item for \a column to \a item. The model takes | - |
| 2270 | ownership of the item. If necessary, the column count is increased to fit | - |
| 2271 | the item. The previous header item (if there was one) is deleted. | - |
| 2272 | | - |
| 2273 | \sa horizontalHeaderItem(), setHorizontalHeaderLabels(), | - |
| 2274 | setVerticalHeaderItem() | - |
| 2275 | */ | - |
| 2276 | void QStandardItemModel::setHorizontalHeaderItem(int column, QStandardItem *item) | - |
| 2277 | { | - |
| 2278 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2279 | if (column < 0) partially evaluated: column < 0| no Evaluation Count:0 | yes Evaluation Count:62 |
| 0-62 |
| 2280 | return; | 0 |
| 2281 | if (columnCount() <= column) evaluated: columnCount() <= column| yes Evaluation Count:2 | yes Evaluation Count:60 |
| 2-60 |
| 2282 | setColumnCount(column + 1); executed: setColumnCount(column + 1);Execution Count:2 | 2 |
| 2283 | | - |
| 2284 | QStandardItem *oldItem = d->columnHeaderItems.at(column); executed (the execution status of this line is deduced): QStandardItem *oldItem = d->columnHeaderItems.at(column); | - |
| 2285 | if (item == oldItem) partially evaluated: item == oldItem| no Evaluation Count:0 | yes Evaluation Count:62 |
| 0-62 |
| 2286 | return; | 0 |
| 2287 | | - |
| 2288 | if (item) { evaluated: item| yes Evaluation Count:61 | yes Evaluation Count:1 |
| 1-61 |
| 2289 | if (item->model() == 0) { partially evaluated: item->model() == 0| yes Evaluation Count:61 | no Evaluation Count:0 |
| 0-61 |
| 2290 | item->d_func()->setModel(this); executed (the execution status of this line is deduced): item->d_func()->setModel(this); | - |
| 2291 | } else { executed: }Execution Count:61 | 61 |
| 2292 | qWarning("QStandardItem::setHorizontalHeaderItem: Ignoring duplicate insertion of item %p", never executed (the execution status of this line is deduced): QMessageLogger("itemmodels/qstandarditemmodel.cpp", 2292, __PRETTY_FUNCTION__).warning("QStandardItem::setHorizontalHeaderItem: Ignoring duplicate insertion of item %p", | - |
| 2293 | item); never executed (the execution status of this line is deduced): item); | - |
| 2294 | return; | 0 |
| 2295 | } | - |
| 2296 | } | - |
| 2297 | | - |
| 2298 | if (oldItem) evaluated: oldItem| yes Evaluation Count:1 | yes Evaluation Count:61 |
| 1-61 |
| 2299 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0);Execution Count:1 | 1 |
| 2300 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
| 2301 | | - |
| 2302 | d->columnHeaderItems.replace(column, item); executed (the execution status of this line is deduced): d->columnHeaderItems.replace(column, item); | - |
| 2303 | emit headerDataChanged(Qt::Horizontal, column, column); executed (the execution status of this line is deduced): headerDataChanged(Qt::Horizontal, column, column); | - |
| 2304 | } executed: }Execution Count:62 | 62 |
| 2305 | | - |
| 2306 | /*! | - |
| 2307 | \since 4.2 | - |
| 2308 | | - |
| 2309 | Returns the horizontal header item for \a column if one has been set; | - |
| 2310 | otherwise returns 0. | - |
| 2311 | | - |
| 2312 | \sa setHorizontalHeaderItem(), verticalHeaderItem() | - |
| 2313 | */ | - |
| 2314 | QStandardItem *QStandardItemModel::horizontalHeaderItem(int column) const | - |
| 2315 | { | - |
| 2316 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2317 | if ((column < 0) || (column >= columnCount())) partially evaluated: (column < 0)| no Evaluation Count:0 | yes Evaluation Count:91 |
evaluated: (column >= columnCount())| yes Evaluation Count:1 | yes Evaluation Count:90 |
| 0-91 |
| 2318 | return 0; executed: return 0;Execution Count:1 | 1 |
| 2319 | return d->columnHeaderItems.at(column); executed: return d->columnHeaderItems.at(column);Execution Count:90 | 90 |
| 2320 | } | - |
| 2321 | | - |
| 2322 | /*! | - |
| 2323 | \since 4.2 | - |
| 2324 | | - |
| 2325 | Sets the vertical header item for \a row to \a item. The model takes | - |
| 2326 | ownership of the item. If necessary, the row count is increased to fit the | - |
| 2327 | item. The previous header item (if there was one) is deleted. | - |
| 2328 | | - |
| 2329 | \sa verticalHeaderItem(), setVerticalHeaderLabels(), | - |
| 2330 | setHorizontalHeaderItem() | - |
| 2331 | */ | - |
| 2332 | void QStandardItemModel::setVerticalHeaderItem(int row, QStandardItem *item) | - |
| 2333 | { | - |
| 2334 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2335 | if (row < 0) partially evaluated: row < 0| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 2336 | return; | 0 |
| 2337 | if (rowCount() <= row) evaluated: rowCount() <= row| yes Evaluation Count:2 | yes Evaluation Count:11 |
| 2-11 |
| 2338 | setRowCount(row + 1); executed: setRowCount(row + 1);Execution Count:2 | 2 |
| 2339 | | - |
| 2340 | QStandardItem *oldItem = d->rowHeaderItems.at(row); executed (the execution status of this line is deduced): QStandardItem *oldItem = d->rowHeaderItems.at(row); | - |
| 2341 | if (item == oldItem) partially evaluated: item == oldItem| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 2342 | return; | 0 |
| 2343 | | - |
| 2344 | if (item) { evaluated: item| yes Evaluation Count:12 | yes Evaluation Count:1 |
| 1-12 |
| 2345 | if (item->model() == 0) { partially evaluated: item->model() == 0| yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
| 2346 | item->d_func()->setModel(this); executed (the execution status of this line is deduced): item->d_func()->setModel(this); | - |
| 2347 | } else { executed: }Execution Count:12 | 12 |
| 2348 | qWarning("QStandardItem::setVerticalHeaderItem: Ignoring duplicate insertion of item %p", never executed (the execution status of this line is deduced): QMessageLogger("itemmodels/qstandarditemmodel.cpp", 2348, __PRETTY_FUNCTION__).warning("QStandardItem::setVerticalHeaderItem: Ignoring duplicate insertion of item %p", | - |
| 2349 | item); never executed (the execution status of this line is deduced): item); | - |
| 2350 | return; | 0 |
| 2351 | } | - |
| 2352 | } | - |
| 2353 | | - |
| 2354 | if (oldItem) evaluated: oldItem| yes Evaluation Count:1 | yes Evaluation Count:12 |
| 1-12 |
| 2355 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0);Execution Count:1 | 1 |
| 2356 | delete oldItem; executed (the execution status of this line is deduced): delete oldItem; | - |
| 2357 | | - |
| 2358 | d->rowHeaderItems.replace(row, item); executed (the execution status of this line is deduced): d->rowHeaderItems.replace(row, item); | - |
| 2359 | emit headerDataChanged(Qt::Vertical, row, row); executed (the execution status of this line is deduced): headerDataChanged(Qt::Vertical, row, row); | - |
| 2360 | } executed: }Execution Count:13 | 13 |
| 2361 | | - |
| 2362 | /*! | - |
| 2363 | \since 4.2 | - |
| 2364 | | - |
| 2365 | Returns the vertical header item for row \a row if one has been set; | - |
| 2366 | otherwise returns 0. | - |
| 2367 | | - |
| 2368 | \sa setVerticalHeaderItem(), horizontalHeaderItem() | - |
| 2369 | */ | - |
| 2370 | QStandardItem *QStandardItemModel::verticalHeaderItem(int row) const | - |
| 2371 | { | - |
| 2372 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2373 | if ((row < 0) || (row >= rowCount())) partially evaluated: (row < 0)| no Evaluation Count:0 | yes Evaluation Count:13 |
evaluated: (row >= rowCount())| yes Evaluation Count:1 | yes Evaluation Count:12 |
| 0-13 |
| 2374 | return 0; executed: return 0;Execution Count:1 | 1 |
| 2375 | return d->rowHeaderItems.at(row); executed: return d->rowHeaderItems.at(row);Execution Count:12 | 12 |
| 2376 | } | - |
| 2377 | | - |
| 2378 | /*! | - |
| 2379 | \since 4.2 | - |
| 2380 | | - |
| 2381 | Sets the horizontal header labels using \a labels. If necessary, the | - |
| 2382 | column count is increased to the size of \a labels. | - |
| 2383 | | - |
| 2384 | \sa setHorizontalHeaderItem() | - |
| 2385 | */ | - |
| 2386 | void QStandardItemModel::setHorizontalHeaderLabels(const QStringList &labels) | - |
| 2387 | { | - |
| 2388 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2389 | if (columnCount() < labels.count()) evaluated: columnCount() < labels.count()| yes Evaluation Count:10 | yes Evaluation Count:2 |
| 2-10 |
| 2390 | setColumnCount(labels.count()); executed: setColumnCount(labels.count());Execution Count:10 | 10 |
| 2391 | for (int i = 0; i < labels.count(); ++i) { evaluated: i < labels.count()| yes Evaluation Count:55 | yes Evaluation Count:12 |
| 12-55 |
| 2392 | QStandardItem *item = horizontalHeaderItem(i); executed (the execution status of this line is deduced): QStandardItem *item = horizontalHeaderItem(i); | - |
| 2393 | if (!item) { partially evaluated: !item| yes Evaluation Count:55 | no Evaluation Count:0 |
| 0-55 |
| 2394 | item = d->createItem(); executed (the execution status of this line is deduced): item = d->createItem(); | - |
| 2395 | setHorizontalHeaderItem(i, item); executed (the execution status of this line is deduced): setHorizontalHeaderItem(i, item); | - |
| 2396 | } executed: }Execution Count:55 | 55 |
| 2397 | item->setText(labels.at(i)); executed (the execution status of this line is deduced): item->setText(labels.at(i)); | - |
| 2398 | } executed: }Execution Count:55 | 55 |
| 2399 | } executed: }Execution Count:12 | 12 |
| 2400 | | - |
| 2401 | /*! | - |
| 2402 | \since 4.2 | - |
| 2403 | | - |
| 2404 | Sets the vertical header labels using \a labels. If necessary, the row | - |
| 2405 | count is increased to the size of \a labels. | - |
| 2406 | | - |
| 2407 | \sa setVerticalHeaderItem() | - |
| 2408 | */ | - |
| 2409 | void QStandardItemModel::setVerticalHeaderLabels(const QStringList &labels) | - |
| 2410 | { | - |
| 2411 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2412 | if (rowCount() < labels.count()) evaluated: rowCount() < labels.count()| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
| 2413 | setRowCount(labels.count()); executed: setRowCount(labels.count());Execution Count:1 | 1 |
| 2414 | for (int i = 0; i < labels.count(); ++i) { evaluated: i < labels.count()| yes Evaluation Count:10 | yes Evaluation Count:3 |
| 3-10 |
| 2415 | QStandardItem *item = verticalHeaderItem(i); executed (the execution status of this line is deduced): QStandardItem *item = verticalHeaderItem(i); | - |
| 2416 | if (!item) { partially evaluated: !item| yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
| 2417 | item = d->createItem(); executed (the execution status of this line is deduced): item = d->createItem(); | - |
| 2418 | setVerticalHeaderItem(i, item); executed (the execution status of this line is deduced): setVerticalHeaderItem(i, item); | - |
| 2419 | } executed: }Execution Count:10 | 10 |
| 2420 | item->setText(labels.at(i)); executed (the execution status of this line is deduced): item->setText(labels.at(i)); | - |
| 2421 | } executed: }Execution Count:10 | 10 |
| 2422 | } executed: }Execution Count:3 | 3 |
| 2423 | | - |
| 2424 | /*! | - |
| 2425 | \since 4.2 | - |
| 2426 | | - |
| 2427 | Sets the item prototype for the model to the specified \a item. The model | - |
| 2428 | takes ownership of the prototype. | - |
| 2429 | | - |
| 2430 | The item prototype acts as a QStandardItem factory, by relying on the | - |
| 2431 | QStandardItem::clone() function. To provide your own prototype, subclass | - |
| 2432 | QStandardItem, reimplement QStandardItem::clone() and set the prototype to | - |
| 2433 | be an instance of your custom class. Whenever QStandardItemModel needs to | - |
| 2434 | create an item on demand (for instance, when a view or item delegate calls | - |
| 2435 | setData())), the new items will be instances of your custom class. | - |
| 2436 | | - |
| 2437 | \sa itemPrototype(), QStandardItem::clone() | - |
| 2438 | */ | - |
| 2439 | void QStandardItemModel::setItemPrototype(const QStandardItem *item) | - |
| 2440 | { | - |
| 2441 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2442 | if (d->itemPrototype != item) { partially evaluated: d->itemPrototype != item| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 2443 | delete d->itemPrototype; executed (the execution status of this line is deduced): delete d->itemPrototype; | - |
| 2444 | d->itemPrototype = item; executed (the execution status of this line is deduced): d->itemPrototype = item; | - |
| 2445 | } executed: }Execution Count:2 | 2 |
| 2446 | } executed: }Execution Count:2 | 2 |
| 2447 | | - |
| 2448 | /*! | - |
| 2449 | \since 4.2 | - |
| 2450 | | - |
| 2451 | Returns the item prototype used by the model. The model uses the item | - |
| 2452 | prototype as an item factory when it needs to construct new items on | - |
| 2453 | demand (for instance, when a view or item delegate calls setData()). | - |
| 2454 | | - |
| 2455 | \sa setItemPrototype() | - |
| 2456 | */ | - |
| 2457 | const QStandardItem *QStandardItemModel::itemPrototype() const | - |
| 2458 | { | - |
| 2459 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2460 | return d->itemPrototype; executed: return d->itemPrototype;Execution Count:3 | 3 |
| 2461 | } | - |
| 2462 | | - |
| 2463 | /*! | - |
| 2464 | \since 4.2 | - |
| 2465 | | - |
| 2466 | Returns a list of items that match the given \a text, using the given \a | - |
| 2467 | flags, in the given \a column. | - |
| 2468 | */ | - |
| 2469 | QList<QStandardItem*> QStandardItemModel::findItems(const QString &text, | - |
| 2470 | Qt::MatchFlags flags, int column) const | - |
| 2471 | { | - |
| 2472 | QModelIndexList indexes = match(index(0, column, QModelIndex()), executed (the execution status of this line is deduced): QModelIndexList indexes = match(index(0, column, QModelIndex()), | - |
| 2473 | Qt::DisplayRole, text, -1, flags); executed (the execution status of this line is deduced): Qt::DisplayRole, text, -1, flags); | - |
| 2474 | QList<QStandardItem*> items; executed (the execution status of this line is deduced): QList<QStandardItem*> items; | - |
| 2475 | for (int i = 0; i < indexes.size(); ++i) evaluated: i < indexes.size()| yes Evaluation Count:3 | yes Evaluation Count:5 |
| 3-5 |
| 2476 | items.append(itemFromIndex(indexes.at(i))); executed: items.append(itemFromIndex(indexes.at(i)));Execution Count:3 | 3 |
| 2477 | return items; executed: return items;Execution Count:5 | 5 |
| 2478 | } | - |
| 2479 | | - |
| 2480 | /*! | - |
| 2481 | \since 4.2 | - |
| 2482 | | - |
| 2483 | Appends a row containing \a items. If necessary, the column count is | - |
| 2484 | increased to the size of \a items. | - |
| 2485 | | - |
| 2486 | \sa insertRow(), appendColumn() | - |
| 2487 | */ | - |
| 2488 | void QStandardItemModel::appendRow(const QList<QStandardItem*> &items) | - |
| 2489 | { | - |
| 2490 | invisibleRootItem()->appendRow(items); executed (the execution status of this line is deduced): invisibleRootItem()->appendRow(items); | - |
| 2491 | } executed: }Execution Count:382 | 382 |
| 2492 | | - |
| 2493 | /*! | - |
| 2494 | \since 4.2 | - |
| 2495 | | - |
| 2496 | Appends a column containing \a items. If necessary, the row count is | - |
| 2497 | increased to the size of \a items. | - |
| 2498 | | - |
| 2499 | \sa insertColumn(), appendRow() | - |
| 2500 | */ | - |
| 2501 | void QStandardItemModel::appendColumn(const QList<QStandardItem*> &items) | - |
| 2502 | { | - |
| 2503 | invisibleRootItem()->appendColumn(items); executed (the execution status of this line is deduced): invisibleRootItem()->appendColumn(items); | - |
| 2504 | } executed: }Execution Count:10 | 10 |
| 2505 | | - |
| 2506 | /*! | - |
| 2507 | \since 4.2 | - |
| 2508 | \fn QStandardItemModel::appendRow(QStandardItem *item) | - |
| 2509 | \overload | - |
| 2510 | | - |
| 2511 | When building a list or a tree that has only one column, this function | - |
| 2512 | provides a convenient way to append a single new \a item. | - |
| 2513 | */ | - |
| 2514 | | - |
| 2515 | /*! | - |
| 2516 | \since 4.2 | - |
| 2517 | | - |
| 2518 | Inserts a row at \a row containing \a items. If necessary, the column | - |
| 2519 | count is increased to the size of \a items. | - |
| 2520 | | - |
| 2521 | \sa takeRow(), appendRow(), insertColumn() | - |
| 2522 | */ | - |
| 2523 | void QStandardItemModel::insertRow(int row, const QList<QStandardItem*> &items) | - |
| 2524 | { | - |
| 2525 | invisibleRootItem()->insertRow(row, items); executed (the execution status of this line is deduced): invisibleRootItem()->insertRow(row, items); | - |
| 2526 | } executed: }Execution Count:263 | 263 |
| 2527 | | - |
| 2528 | /*! | - |
| 2529 | \since 4.2 | - |
| 2530 | | - |
| 2531 | \fn void QStandardItemModel::insertRow(int row, QStandardItem *item) | - |
| 2532 | \overload | - |
| 2533 | | - |
| 2534 | Inserts a row at \a row containing \a item. | - |
| 2535 | | - |
| 2536 | When building a list or a tree that has only one column, this function | - |
| 2537 | provides a convenient way to append a single new item. | - |
| 2538 | */ | - |
| 2539 | | - |
| 2540 | /*! | - |
| 2541 | \since 4.2 | - |
| 2542 | | - |
| 2543 | Inserts a column at \a column containing \a items. If necessary, the row | - |
| 2544 | count is increased to the size of \a items. | - |
| 2545 | | - |
| 2546 | \sa takeColumn(), appendColumn(), insertRow() | - |
| 2547 | */ | - |
| 2548 | void QStandardItemModel::insertColumn(int column, const QList<QStandardItem*> &items) | - |
| 2549 | { | - |
| 2550 | invisibleRootItem()->insertColumn(column, items); executed (the execution status of this line is deduced): invisibleRootItem()->insertColumn(column, items); | - |
| 2551 | } executed: }Execution Count:2 | 2 |
| 2552 | | - |
| 2553 | /*! | - |
| 2554 | \since 4.2 | - |
| 2555 | | - |
| 2556 | Removes the item at (\a row, \a column) without deleting it. The model | - |
| 2557 | releases ownership of the item. | - |
| 2558 | | - |
| 2559 | \sa item(), takeRow(), takeColumn() | - |
| 2560 | */ | - |
| 2561 | QStandardItem *QStandardItemModel::takeItem(int row, int column) | - |
| 2562 | { | - |
| 2563 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2564 | return d->root->takeChild(row, column); executed: return d->root->takeChild(row, column);Execution Count:1 | 1 |
| 2565 | } | - |
| 2566 | | - |
| 2567 | /*! | - |
| 2568 | \since 4.2 | - |
| 2569 | | - |
| 2570 | Removes the given \a row without deleting the row items, and returns a | - |
| 2571 | list of pointers to the removed items. The model releases ownership of the | - |
| 2572 | items. For items in the row that have not been set, the corresponding | - |
| 2573 | pointers in the list will be 0. | - |
| 2574 | | - |
| 2575 | \sa takeColumn() | - |
| 2576 | */ | - |
| 2577 | QList<QStandardItem*> QStandardItemModel::takeRow(int row) | - |
| 2578 | { | - |
| 2579 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2580 | return d->root->takeRow(row); executed: return d->root->takeRow(row);Execution Count:1 | 1 |
| 2581 | } | - |
| 2582 | | - |
| 2583 | /*! | - |
| 2584 | \since 4.2 | - |
| 2585 | | - |
| 2586 | Removes the given \a column without deleting the column items, and returns | - |
| 2587 | a list of pointers to the removed items. The model releases ownership of | - |
| 2588 | the items. For items in the column that have not been set, the | - |
| 2589 | corresponding pointers in the list will be 0. | - |
| 2590 | | - |
| 2591 | \sa takeRow() | - |
| 2592 | */ | - |
| 2593 | QList<QStandardItem*> QStandardItemModel::takeColumn(int column) | - |
| 2594 | { | - |
| 2595 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2596 | return d->root->takeColumn(column); executed: return d->root->takeColumn(column);Execution Count:1 | 1 |
| 2597 | } | - |
| 2598 | | - |
| 2599 | /*! | - |
| 2600 | \since 4.2 | - |
| 2601 | | - |
| 2602 | Removes the horizontal header item at \a column from the header without | - |
| 2603 | deleting it, and returns a pointer to the item. The model releases | - |
| 2604 | ownership of the item. | - |
| 2605 | | - |
| 2606 | \sa horizontalHeaderItem(), takeVerticalHeaderItem() | - |
| 2607 | */ | - |
| 2608 | QStandardItem *QStandardItemModel::takeHorizontalHeaderItem(int column) | - |
| 2609 | { | - |
| 2610 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2611 | if ((column < 0) || (column >= columnCount())) partially evaluated: (column < 0)| no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: (column >= columnCount())| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 2612 | return 0; never executed: return 0; | 0 |
| 2613 | QStandardItem *headerItem = d->columnHeaderItems.at(column); executed (the execution status of this line is deduced): QStandardItem *headerItem = d->columnHeaderItems.at(column); | - |
| 2614 | if (headerItem) { evaluated: headerItem| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 2615 | headerItem->d_func()->setParentAndModel(0, 0); executed (the execution status of this line is deduced): headerItem->d_func()->setParentAndModel(0, 0); | - |
| 2616 | d->columnHeaderItems.replace(column, 0); executed (the execution status of this line is deduced): d->columnHeaderItems.replace(column, 0); | - |
| 2617 | } executed: }Execution Count:1 | 1 |
| 2618 | return headerItem; executed: return headerItem;Execution Count:2 | 2 |
| 2619 | } | - |
| 2620 | | - |
| 2621 | /*! | - |
| 2622 | \since 4.2 | - |
| 2623 | | - |
| 2624 | Removes the vertical header item at \a row from the header without | - |
| 2625 | deleting it, and returns a pointer to the item. The model releases | - |
| 2626 | ownership of the item. | - |
| 2627 | | - |
| 2628 | \sa verticalHeaderItem(), takeHorizontalHeaderItem() | - |
| 2629 | */ | - |
| 2630 | QStandardItem *QStandardItemModel::takeVerticalHeaderItem(int row) | - |
| 2631 | { | - |
| 2632 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2633 | if ((row < 0) || (row >= rowCount())) partially evaluated: (row < 0)| no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: (row >= rowCount())| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 2634 | return 0; never executed: return 0; | 0 |
| 2635 | QStandardItem *headerItem = d->rowHeaderItems.at(row); executed (the execution status of this line is deduced): QStandardItem *headerItem = d->rowHeaderItems.at(row); | - |
| 2636 | if (headerItem) { evaluated: headerItem| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 2637 | headerItem->d_func()->setParentAndModel(0, 0); executed (the execution status of this line is deduced): headerItem->d_func()->setParentAndModel(0, 0); | - |
| 2638 | d->rowHeaderItems.replace(row, 0); executed (the execution status of this line is deduced): d->rowHeaderItems.replace(row, 0); | - |
| 2639 | } executed: }Execution Count:1 | 1 |
| 2640 | return headerItem; executed: return headerItem;Execution Count:2 | 2 |
| 2641 | } | - |
| 2642 | | - |
| 2643 | /*! | - |
| 2644 | \since 4.2 | - |
| 2645 | \property QStandardItemModel::sortRole | - |
| 2646 | \brief the item role that is used to query the model's data when sorting items | - |
| 2647 | | - |
| 2648 | The default value is Qt::DisplayRole. | - |
| 2649 | | - |
| 2650 | \sa sort(), QStandardItem::sortChildren() | - |
| 2651 | */ | - |
| 2652 | int QStandardItemModel::sortRole() const | - |
| 2653 | { | - |
| 2654 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2655 | return d->sortRole; executed: return d->sortRole;Execution Count:5296 | 5296 |
| 2656 | } | - |
| 2657 | | - |
| 2658 | void QStandardItemModel::setSortRole(int role) | - |
| 2659 | { | - |
| 2660 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2661 | d->sortRole = role; executed (the execution status of this line is deduced): d->sortRole = role; | - |
| 2662 | } executed: }Execution Count:2 | 2 |
| 2663 | | - |
| 2664 | /*! | - |
| 2665 | \reimp | - |
| 2666 | */ | - |
| 2667 | int QStandardItemModel::columnCount(const QModelIndex &parent) const | - |
| 2668 | { | - |
| 2669 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2670 | QStandardItem *item = d->itemFromIndex(parent); executed (the execution status of this line is deduced): QStandardItem *item = d->itemFromIndex(parent); | - |
| 2671 | return item ? item->columnCount() : 0; executed: return item ? item->columnCount() : 0;Execution Count:3617246 | 3617246 |
| 2672 | } | - |
| 2673 | | - |
| 2674 | /*! | - |
| 2675 | \reimp | - |
| 2676 | */ | - |
| 2677 | QVariant QStandardItemModel::data(const QModelIndex &index, int role) const | - |
| 2678 | { | - |
| 2679 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2680 | QStandardItem *item = d->itemFromIndex(index); executed (the execution status of this line is deduced): QStandardItem *item = d->itemFromIndex(index); | - |
| 2681 | return item ? item->data(role) : QVariant(); executed: return item ? item->data(role) : QVariant();Execution Count:1122113 | 1122113 |
| 2682 | } | - |
| 2683 | | - |
| 2684 | /*! | - |
| 2685 | \reimp | - |
| 2686 | */ | - |
| 2687 | Qt::ItemFlags QStandardItemModel::flags(const QModelIndex &index) const | - |
| 2688 | { | - |
| 2689 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2690 | if (!d->indexValid(index)) evaluated: !d->indexValid(index)| yes Evaluation Count:34 | yes Evaluation Count:19943 |
| 34-19943 |
| 2691 | return d->root->flags(); executed: return d->root->flags();Execution Count:34 | 34 |
| 2692 | QStandardItem *item = d->itemFromIndex(index); executed (the execution status of this line is deduced): QStandardItem *item = d->itemFromIndex(index); | - |
| 2693 | if (item) evaluated: item| yes Evaluation Count:17418 | yes Evaluation Count:2525 |
| 2525-17418 |
| 2694 | return item->flags(); executed: return item->flags();Execution Count:17418 | 17418 |
| 2695 | return Qt::ItemIsSelectable executed: return Qt::ItemIsSelectable |Qt::ItemIsEnabled |Qt::ItemIsEditable |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled;Execution Count:2525 | 2525 |
| 2696 | |Qt::ItemIsEnabled executed: return Qt::ItemIsSelectable |Qt::ItemIsEnabled |Qt::ItemIsEditable |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled;Execution Count:2525 | 2525 |
| 2697 | |Qt::ItemIsEditable executed: return Qt::ItemIsSelectable |Qt::ItemIsEnabled |Qt::ItemIsEditable |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled;Execution Count:2525 | 2525 |
| 2698 | |Qt::ItemIsDragEnabled executed: return Qt::ItemIsSelectable |Qt::ItemIsEnabled |Qt::ItemIsEditable |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled;Execution Count:2525 | 2525 |
| 2699 | |Qt::ItemIsDropEnabled; executed: return Qt::ItemIsSelectable |Qt::ItemIsEnabled |Qt::ItemIsEditable |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled;Execution Count:2525 | 2525 |
| 2700 | } | - |
| 2701 | | - |
| 2702 | /*! | - |
| 2703 | \reimp | - |
| 2704 | */ | - |
| 2705 | bool QStandardItemModel::hasChildren(const QModelIndex &parent) const | - |
| 2706 | { | - |
| 2707 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2708 | QStandardItem *item = d->itemFromIndex(parent); executed (the execution status of this line is deduced): QStandardItem *item = d->itemFromIndex(parent); | - |
| 2709 | return item ? item->hasChildren() : false; executed: return item ? item->hasChildren() : false;Execution Count:15226 | 15226 |
| 2710 | } | - |
| 2711 | | - |
| 2712 | /*! | - |
| 2713 | \reimp | - |
| 2714 | */ | - |
| 2715 | QModelIndex QStandardItemModel::sibling(int row, int column, const QModelIndex &idx) const | - |
| 2716 | { | - |
| 2717 | return createIndex(row, column, idx.internalPointer()); executed: return createIndex(row, column, idx.internalPointer());Execution Count:25982 | 25982 |
| 2718 | } | - |
| 2719 | | - |
| 2720 | /*! | - |
| 2721 | \reimp | - |
| 2722 | */ | - |
| 2723 | QVariant QStandardItemModel::headerData(int section, Qt::Orientation orientation, int role) const | - |
| 2724 | { | - |
| 2725 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2726 | if ((section < 0) evaluated: (section < 0)| yes Evaluation Count:4 | yes Evaluation Count:61026 |
| 4-61026 |
| 2727 | || ((orientation == Qt::Horizontal) && (section >= columnCount())) evaluated: (orientation == Qt::Horizontal)| yes Evaluation Count:17980 | yes Evaluation Count:43046 |
evaluated: (section >= columnCount())| yes Evaluation Count:483 | yes Evaluation Count:17497 |
| 483-43046 |
| 2728 | || ((orientation == Qt::Vertical) && (section >= rowCount()))) { evaluated: (orientation == Qt::Vertical)| yes Evaluation Count:43046 | yes Evaluation Count:17497 |
evaluated: (section >= rowCount())| yes Evaluation Count:2 | yes Evaluation Count:43044 |
| 2-43046 |
| 2729 | return QVariant(); executed: return QVariant();Execution Count:489 | 489 |
| 2730 | } | - |
| 2731 | QStandardItem *headerItem = 0; executed (the execution status of this line is deduced): QStandardItem *headerItem = 0; | - |
| 2732 | if (orientation == Qt::Horizontal) evaluated: orientation == Qt::Horizontal| yes Evaluation Count:17497 | yes Evaluation Count:43044 |
| 17497-43044 |
| 2733 | headerItem = d->columnHeaderItems.at(section); executed: headerItem = d->columnHeaderItems.at(section);Execution Count:17497 | 17497 |
| 2734 | else if (orientation == Qt::Vertical) partially evaluated: orientation == Qt::Vertical| yes Evaluation Count:43044 | no Evaluation Count:0 |
| 0-43044 |
| 2735 | headerItem = d->rowHeaderItems.at(section); executed: headerItem = d->rowHeaderItems.at(section);Execution Count:43044 | 43044 |
| 2736 | return headerItem ? headerItem->data(role) executed: return headerItem ? headerItem->data(role) : QAbstractItemModel::headerData(section, orientation, role);Execution Count:60541 | 60541 |
| 2737 | : QAbstractItemModel::headerData(section, orientation, role); executed: return headerItem ? headerItem->data(role) : QAbstractItemModel::headerData(section, orientation, role);Execution Count:60541 | 60541 |
| 2738 | } | - |
| 2739 | | - |
| 2740 | /*! | - |
| 2741 | \reimp | - |
| 2742 | | - |
| 2743 | QStandardItemModel supports both copy and move. | - |
| 2744 | */ | - |
| 2745 | Qt::DropActions QStandardItemModel::supportedDropActions () const | - |
| 2746 | { | - |
| 2747 | return Qt::CopyAction | Qt::MoveAction; executed: return Qt::CopyAction | Qt::MoveAction;Execution Count:31 | 31 |
| 2748 | } | - |
| 2749 | | - |
| 2750 | /*! | - |
| 2751 | \reimp | - |
| 2752 | */ | - |
| 2753 | QModelIndex QStandardItemModel::index(int row, int column, const QModelIndex &parent) const | - |
| 2754 | { | - |
| 2755 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2756 | QStandardItem *parentItem = d->itemFromIndex(parent); executed (the execution status of this line is deduced): QStandardItem *parentItem = d->itemFromIndex(parent); | - |
| 2757 | if ((parentItem == 0) evaluated: (parentItem == 0)| yes Evaluation Count:27 | yes Evaluation Count:10859323 |
| 27-10859323 |
| 2758 | || (row < 0) evaluated: (row < 0)| yes Evaluation Count:1773 | yes Evaluation Count:10857550 |
| 1773-10857550 |
| 2759 | || (column < 0) evaluated: (column < 0)| yes Evaluation Count:198 | yes Evaluation Count:10857352 |
| 198-10857352 |
| 2760 | || (row >= parentItem->rowCount()) evaluated: (row >= parentItem->rowCount())| yes Evaluation Count:416 | yes Evaluation Count:10856936 |
| 416-10856936 |
| 2761 | || (column >= parentItem->columnCount())) { evaluated: (column >= parentItem->columnCount())| yes Evaluation Count:3705 | yes Evaluation Count:10853231 |
| 3705-10853231 |
| 2762 | return QModelIndex(); executed: return QModelIndex();Execution Count:6119 | 6119 |
| 2763 | } | - |
| 2764 | return createIndex(row, column, parentItem); executed: return createIndex(row, column, parentItem);Execution Count:10853231 | 10853231 |
| 2765 | } | - |
| 2766 | | - |
| 2767 | /*! | - |
| 2768 | \reimp | - |
| 2769 | */ | - |
| 2770 | bool QStandardItemModel::insertColumns(int column, int count, const QModelIndex &parent) | - |
| 2771 | { | - |
| 2772 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2773 | QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data(); evaluated: parent.isValid()| yes Evaluation Count:6353 | yes Evaluation Count:898 |
| 898-6353 |
| 2774 | if (item == 0) partially evaluated: item == 0| no Evaluation Count:0 | yes Evaluation Count:7251 |
| 0-7251 |
| 2775 | return false; never executed: return false; | 0 |
| 2776 | return item->d_func()->insertColumns(column, count, QList<QStandardItem*>()); executed: return item->d_func()->insertColumns(column, count, QList<QStandardItem*>());Execution Count:7251 | 7251 |
| 2777 | } | - |
| 2778 | | - |
| 2779 | /*! | - |
| 2780 | \reimp | - |
| 2781 | */ | - |
| 2782 | bool QStandardItemModel::insertRows(int row, int count, const QModelIndex &parent) | - |
| 2783 | { | - |
| 2784 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2785 | QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data(); evaluated: parent.isValid()| yes Evaluation Count:6362 | yes Evaluation Count:1467 |
| 1467-6362 |
| 2786 | if (item == 0) partially evaluated: item == 0| no Evaluation Count:0 | yes Evaluation Count:7829 |
| 0-7829 |
| 2787 | return false; never executed: return false; | 0 |
| 2788 | return item->d_func()->insertRows(row, count, QList<QStandardItem*>()); executed: return item->d_func()->insertRows(row, count, QList<QStandardItem*>());Execution Count:7829 | 7829 |
| 2789 | } | - |
| 2790 | | - |
| 2791 | /*! | - |
| 2792 | \reimp | - |
| 2793 | */ | - |
| 2794 | QMap<int, QVariant> QStandardItemModel::itemData(const QModelIndex &index) const | - |
| 2795 | { | - |
| 2796 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2797 | QStandardItem *item = d->itemFromIndex(index); executed (the execution status of this line is deduced): QStandardItem *item = d->itemFromIndex(index); | - |
| 2798 | return item ? item->d_func()->itemData() : QMap<int, QVariant>(); executed: return item ? item->d_func()->itemData() : QMap<int, QVariant>();Execution Count:32 | 32 |
| 2799 | } | - |
| 2800 | | - |
| 2801 | /*! | - |
| 2802 | \reimp | - |
| 2803 | */ | - |
| 2804 | QModelIndex QStandardItemModel::parent(const QModelIndex &child) const | - |
| 2805 | { | - |
| 2806 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2807 | if (!d->indexValid(child)) evaluated: !d->indexValid(child)| yes Evaluation Count:50 | yes Evaluation Count:7099450 |
| 50-7099450 |
| 2808 | return QModelIndex(); executed: return QModelIndex();Execution Count:50 | 50 |
| 2809 | QStandardItem *parentItem = static_cast<QStandardItem*>(child.internalPointer()); executed (the execution status of this line is deduced): QStandardItem *parentItem = static_cast<QStandardItem*>(child.internalPointer()); | - |
| 2810 | return indexFromItem(parentItem); executed: return indexFromItem(parentItem);Execution Count:7099450 | 7099450 |
| 2811 | } | - |
| 2812 | | - |
| 2813 | /*! | - |
| 2814 | \reimp | - |
| 2815 | */ | - |
| 2816 | bool QStandardItemModel::removeColumns(int column, int count, const QModelIndex &parent) | - |
| 2817 | { | - |
| 2818 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2819 | QStandardItem *item = d->itemFromIndex(parent); executed (the execution status of this line is deduced): QStandardItem *item = d->itemFromIndex(parent); | - |
| 2820 | if ((item == 0) || (count < 1) || (column < 0) || ((column + count) > item->columnCount())) partially evaluated: (item == 0)| no Evaluation Count:0 | yes Evaluation Count:93 |
evaluated: (count < 1)| yes Evaluation Count:16 | yes Evaluation Count:77 |
evaluated: (column < 0)| yes Evaluation Count:6 | yes Evaluation Count:71 |
evaluated: ((column + count) > item->columnCount())| yes Evaluation Count:8 | yes Evaluation Count:63 |
| 0-93 |
| 2821 | return false; executed: return false;Execution Count:30 | 30 |
| 2822 | item->removeColumns(column, count); executed (the execution status of this line is deduced): item->removeColumns(column, count); | - |
| 2823 | return true; executed: return true;Execution Count:63 | 63 |
| 2824 | } | - |
| 2825 | | - |
| 2826 | /*! | - |
| 2827 | \reimp | - |
| 2828 | */ | - |
| 2829 | bool QStandardItemModel::removeRows(int row, int count, const QModelIndex &parent) | - |
| 2830 | { | - |
| 2831 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2832 | QStandardItem *item = d->itemFromIndex(parent); executed (the execution status of this line is deduced): QStandardItem *item = d->itemFromIndex(parent); | - |
| 2833 | if ((item == 0) || (count < 1) || (row < 0) || ((row + count) > item->rowCount())) partially evaluated: (item == 0)| no Evaluation Count:0 | yes Evaluation Count:1036 |
evaluated: (count < 1)| yes Evaluation Count:590 | yes Evaluation Count:446 |
evaluated: (row < 0)| yes Evaluation Count:6 | yes Evaluation Count:440 |
evaluated: ((row + count) > item->rowCount())| yes Evaluation Count:10 | yes Evaluation Count:430 |
| 0-1036 |
| 2834 | return false; executed: return false;Execution Count:606 | 606 |
| 2835 | item->removeRows(row, count); executed (the execution status of this line is deduced): item->removeRows(row, count); | - |
| 2836 | return true; executed: return true;Execution Count:430 | 430 |
| 2837 | } | - |
| 2838 | | - |
| 2839 | /*! | - |
| 2840 | \reimp | - |
| 2841 | */ | - |
| 2842 | int QStandardItemModel::rowCount(const QModelIndex &parent) const | - |
| 2843 | { | - |
| 2844 | Q_D(const QStandardItemModel); executed (the execution status of this line is deduced): const QStandardItemModelPrivate * const d = d_func(); | - |
| 2845 | QStandardItem *item = d->itemFromIndex(parent); executed (the execution status of this line is deduced): QStandardItem *item = d->itemFromIndex(parent); | - |
| 2846 | return item ? item->rowCount() : 0; executed: return item ? item->rowCount() : 0;Execution Count:293564 | 293564 |
| 2847 | } | - |
| 2848 | | - |
| 2849 | /*! | - |
| 2850 | \reimp | - |
| 2851 | */ | - |
| 2852 | bool QStandardItemModel::setData(const QModelIndex &index, const QVariant &value, int role) | - |
| 2853 | { | - |
| 2854 | if (!index.isValid()) evaluated: !index.isValid()| yes Evaluation Count:66 | yes Evaluation Count:6886257 |
| 66-6886257 |
| 2855 | return false; executed: return false;Execution Count:66 | 66 |
| 2856 | QStandardItem *item = itemFromIndex(index); executed (the execution status of this line is deduced): QStandardItem *item = itemFromIndex(index); | - |
| 2857 | if (item == 0) partially evaluated: item == 0| no Evaluation Count:0 | yes Evaluation Count:6886257 |
| 0-6886257 |
| 2858 | return false; never executed: return false; | 0 |
| 2859 | item->setData(value, role); executed (the execution status of this line is deduced): item->setData(value, role); | - |
| 2860 | return true; executed: return true;Execution Count:6886257 | 6886257 |
| 2861 | } | - |
| 2862 | | - |
| 2863 | /*! | - |
| 2864 | \reimp | - |
| 2865 | */ | - |
| 2866 | bool QStandardItemModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) | - |
| 2867 | { | - |
| 2868 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2869 | if ((section < 0) evaluated: (section < 0)| yes Evaluation Count:55 | yes Evaluation Count:82 |
| 55-82 |
| 2870 | || ((orientation == Qt::Horizontal) && (section >= columnCount())) evaluated: (orientation == Qt::Horizontal)| yes Evaluation Count:60 | yes Evaluation Count:22 |
evaluated: (section >= columnCount())| yes Evaluation Count:17 | yes Evaluation Count:43 |
| 17-60 |
| 2871 | || ((orientation == Qt::Vertical) && (section >= rowCount()))) { evaluated: (orientation == Qt::Vertical)| yes Evaluation Count:22 | yes Evaluation Count:43 |
evaluated: (section >= rowCount())| yes Evaluation Count:1 | yes Evaluation Count:21 |
| 1-43 |
| 2872 | return false; executed: return false;Execution Count:73 | 73 |
| 2873 | } | - |
| 2874 | QStandardItem *headerItem = 0; executed (the execution status of this line is deduced): QStandardItem *headerItem = 0; | - |
| 2875 | if (orientation == Qt::Horizontal) { evaluated: orientation == Qt::Horizontal| yes Evaluation Count:43 | yes Evaluation Count:21 |
| 21-43 |
| 2876 | headerItem = d->columnHeaderItems.at(section); executed (the execution status of this line is deduced): headerItem = d->columnHeaderItems.at(section); | - |
| 2877 | if (headerItem == 0) { evaluated: headerItem == 0| yes Evaluation Count:40 | yes Evaluation Count:3 |
| 3-40 |
| 2878 | headerItem = d->createItem(); executed (the execution status of this line is deduced): headerItem = d->createItem(); | - |
| 2879 | headerItem->d_func()->setModel(this); executed (the execution status of this line is deduced): headerItem->d_func()->setModel(this); | - |
| 2880 | d->columnHeaderItems.replace(section, headerItem); executed (the execution status of this line is deduced): d->columnHeaderItems.replace(section, headerItem); | - |
| 2881 | } executed: }Execution Count:40 | 40 |
| 2882 | } else if (orientation == Qt::Vertical) { executed: }Execution Count:43 partially evaluated: orientation == Qt::Vertical| yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-43 |
| 2883 | headerItem = d->rowHeaderItems.at(section); executed (the execution status of this line is deduced): headerItem = d->rowHeaderItems.at(section); | - |
| 2884 | if (headerItem == 0) { evaluated: headerItem == 0| yes Evaluation Count:18 | yes Evaluation Count:3 |
| 3-18 |
| 2885 | headerItem = d->createItem(); executed (the execution status of this line is deduced): headerItem = d->createItem(); | - |
| 2886 | headerItem->d_func()->setModel(this); executed (the execution status of this line is deduced): headerItem->d_func()->setModel(this); | - |
| 2887 | d->rowHeaderItems.replace(section, headerItem); executed (the execution status of this line is deduced): d->rowHeaderItems.replace(section, headerItem); | - |
| 2888 | } executed: }Execution Count:18 | 18 |
| 2889 | } executed: }Execution Count:21 | 21 |
| 2890 | if (headerItem) { partially evaluated: headerItem| yes Evaluation Count:64 | no Evaluation Count:0 |
| 0-64 |
| 2891 | headerItem->setData(value, role); executed (the execution status of this line is deduced): headerItem->setData(value, role); | - |
| 2892 | return true; executed: return true;Execution Count:64 | 64 |
| 2893 | } | - |
| 2894 | return false; never executed: return false; | 0 |
| 2895 | } | - |
| 2896 | | - |
| 2897 | /*! | - |
| 2898 | \reimp | - |
| 2899 | */ | - |
| 2900 | bool QStandardItemModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) | - |
| 2901 | { | - |
| 2902 | QStandardItem *item = itemFromIndex(index); executed (the execution status of this line is deduced): QStandardItem *item = itemFromIndex(index); | - |
| 2903 | if (item == 0) evaluated: item == 0| yes Evaluation Count:5 | yes Evaluation Count:2 |
| 2-5 |
| 2904 | return false; executed: return false;Execution Count:5 | 5 |
| 2905 | item->d_func()->setItemData(roles); executed (the execution status of this line is deduced): item->d_func()->setItemData(roles); | - |
| 2906 | return true; executed: return true;Execution Count:2 | 2 |
| 2907 | } | - |
| 2908 | | - |
| 2909 | /*! | - |
| 2910 | \reimp | - |
| 2911 | */ | - |
| 2912 | void QStandardItemModel::sort(int column, Qt::SortOrder order) | - |
| 2913 | { | - |
| 2914 | Q_D(QStandardItemModel); executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 2915 | d->root->sortChildren(column, order); executed (the execution status of this line is deduced): d->root->sortChildren(column, order); | - |
| 2916 | } executed: }Execution Count:41 | 41 |
| 2917 | | - |
| 2918 | /*! | - |
| 2919 | \fn QObject *QStandardItemModel::parent() const | - |
| 2920 | \internal | - |
| 2921 | */ | - |
| 2922 | | - |
| 2923 | | - |
| 2924 | /*! | - |
| 2925 | \reimp | - |
| 2926 | */ | - |
| 2927 | QStringList QStandardItemModel::mimeTypes() const | - |
| 2928 | { | - |
| 2929 | return QAbstractItemModel::mimeTypes() << QLatin1String("application/x-qstandarditemmodeldatalist"); executed: return QAbstractItemModel::mimeTypes() << QLatin1String("application/x-qstandarditemmodeldatalist");Execution Count:31 | 31 |
| 2930 | } | - |
| 2931 | | - |
| 2932 | /*! | - |
| 2933 | \reimp | - |
| 2934 | */ | - |
| 2935 | QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const | - |
| 2936 | { | - |
| 2937 | QMimeData *data = QAbstractItemModel::mimeData(indexes); never executed (the execution status of this line is deduced): QMimeData *data = QAbstractItemModel::mimeData(indexes); | - |
| 2938 | if(!data) | 0 |
| 2939 | return 0; never executed: return 0; | 0 |
| 2940 | | - |
| 2941 | QString format = QLatin1String("application/x-qstandarditemmodeldatalist"); never executed (the execution status of this line is deduced): QString format = QLatin1String("application/x-qstandarditemmodeldatalist"); | - |
| 2942 | if (!mimeTypes().contains(format)) never evaluated: !mimeTypes().contains(format) | 0 |
| 2943 | return data; never executed: return data; | 0 |
| 2944 | QByteArray encoded; never executed (the execution status of this line is deduced): QByteArray encoded; | - |
| 2945 | QDataStream stream(&encoded, QIODevice::WriteOnly); never executed (the execution status of this line is deduced): QDataStream stream(&encoded, QIODevice::WriteOnly); | - |
| 2946 | | - |
| 2947 | QSet<QStandardItem*> itemsSet; never executed (the execution status of this line is deduced): QSet<QStandardItem*> itemsSet; | - |
| 2948 | QStack<QStandardItem*> stack; never executed (the execution status of this line is deduced): QStack<QStandardItem*> stack; | - |
| 2949 | itemsSet.reserve(indexes.count()); never executed (the execution status of this line is deduced): itemsSet.reserve(indexes.count()); | - |
| 2950 | stack.reserve(indexes.count()); never executed (the execution status of this line is deduced): stack.reserve(indexes.count()); | - |
| 2951 | for (int i = 0; i < indexes.count(); ++i) { never evaluated: i < indexes.count() | 0 |
| 2952 | QStandardItem *item = itemFromIndex(indexes.at(i)); never executed (the execution status of this line is deduced): QStandardItem *item = itemFromIndex(indexes.at(i)); | - |
| 2953 | itemsSet << item; never executed (the execution status of this line is deduced): itemsSet << item; | - |
| 2954 | stack.push(item); never executed (the execution status of this line is deduced): stack.push(item); | - |
| 2955 | } | 0 |
| 2956 | | - |
| 2957 | //remove duplicates childrens | - |
| 2958 | { | - |
| 2959 | QSet<QStandardItem *> seen; never executed (the execution status of this line is deduced): QSet<QStandardItem *> seen; | - |
| 2960 | while (!stack.isEmpty()) { never evaluated: !stack.isEmpty() | 0 |
| 2961 | QStandardItem *itm = stack.pop(); never executed (the execution status of this line is deduced): QStandardItem *itm = stack.pop(); | - |
| 2962 | if (seen.contains(itm)) never evaluated: seen.contains(itm) | 0 |
| 2963 | continue; never executed: continue; | 0 |
| 2964 | seen.insert(itm); never executed (the execution status of this line is deduced): seen.insert(itm); | - |
| 2965 | | - |
| 2966 | const QVector<QStandardItem*> &childList = itm->d_func()->children; never executed (the execution status of this line is deduced): const QVector<QStandardItem*> &childList = itm->d_func()->children; | - |
| 2967 | for (int i = 0; i < childList.count(); ++i) { never evaluated: i < childList.count() | 0 |
| 2968 | QStandardItem *chi = childList.at(i); never executed (the execution status of this line is deduced): QStandardItem *chi = childList.at(i); | - |
| 2969 | if (chi) { | 0 |
| 2970 | QSet<QStandardItem *>::iterator it = itemsSet.find(chi); never executed (the execution status of this line is deduced): QSet<QStandardItem *>::iterator it = itemsSet.find(chi); | - |
| 2971 | if (it != itemsSet.end()) { never evaluated: it != itemsSet.end() | 0 |
| 2972 | itemsSet.erase(it); never executed (the execution status of this line is deduced): itemsSet.erase(it); | - |
| 2973 | } | 0 |
| 2974 | stack.push(chi); never executed (the execution status of this line is deduced): stack.push(chi); | - |
| 2975 | } | 0 |
| 2976 | } | 0 |
| 2977 | } | 0 |
| 2978 | } | - |
| 2979 | | - |
| 2980 | stack.reserve(itemsSet.count()); never executed (the execution status of this line is deduced): stack.reserve(itemsSet.count()); | - |
| 2981 | foreach (QStandardItem *item, itemsSet) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(itemsSet)> _container_(itemsSet); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QStandardItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 2982 | stack.push(item); never executed (the execution status of this line is deduced): stack.push(item); | - |
| 2983 | } | 0 |
| 2984 | | - |
| 2985 | //stream everything recursively | - |
| 2986 | while (!stack.isEmpty()) { never evaluated: !stack.isEmpty() | 0 |
| 2987 | QStandardItem *item = stack.pop(); never executed (the execution status of this line is deduced): QStandardItem *item = stack.pop(); | - |
| 2988 | if(itemsSet.contains(item)) { //if the item is selection 'top-level', strem its position never evaluated: itemsSet.contains(item) | 0 |
| 2989 | stream << item->row() << item->column(); never executed (the execution status of this line is deduced): stream << item->row() << item->column(); | - |
| 2990 | } | 0 |
| 2991 | if(item) { | 0 |
| 2992 | stream << *item << item->columnCount() << item->d_ptr->children.count(); never executed (the execution status of this line is deduced): stream << *item << item->columnCount() << item->d_ptr->children.count(); | - |
| 2993 | stack += item->d_ptr->children; never executed (the execution status of this line is deduced): stack += item->d_ptr->children; | - |
| 2994 | } else { | 0 |
| 2995 | QStandardItem dummy; never executed (the execution status of this line is deduced): QStandardItem dummy; | - |
| 2996 | stream << dummy << 0 << 0; never executed (the execution status of this line is deduced): stream << dummy << 0 << 0; | - |
| 2997 | } | 0 |
| 2998 | } | - |
| 2999 | | - |
| 3000 | data->setData(format, encoded); never executed (the execution status of this line is deduced): data->setData(format, encoded); | - |
| 3001 | return data; never executed: return data; | 0 |
| 3002 | } | - |
| 3003 | | - |
| 3004 | | - |
| 3005 | /* \internal | - |
| 3006 | Used by QStandardItemModel::dropMimeData | - |
| 3007 | stream out an item and his children | - |
| 3008 | */ | - |
| 3009 | void QStandardItemModelPrivate::decodeDataRecursive(QDataStream &stream, QStandardItem *item) | - |
| 3010 | { | - |
| 3011 | int colCount, childCount; never executed (the execution status of this line is deduced): int colCount, childCount; | - |
| 3012 | stream >> *item; never executed (the execution status of this line is deduced): stream >> *item; | - |
| 3013 | stream >> colCount >> childCount; never executed (the execution status of this line is deduced): stream >> colCount >> childCount; | - |
| 3014 | item->setColumnCount(colCount); never executed (the execution status of this line is deduced): item->setColumnCount(colCount); | - |
| 3015 | | - |
| 3016 | int childPos = childCount; never executed (the execution status of this line is deduced): int childPos = childCount; | - |
| 3017 | | - |
| 3018 | while(childPos > 0) { never evaluated: childPos > 0 | 0 |
| 3019 | childPos--; never executed (the execution status of this line is deduced): childPos--; | - |
| 3020 | QStandardItem *child = createItem(); never executed (the execution status of this line is deduced): QStandardItem *child = createItem(); | - |
| 3021 | decodeDataRecursive(stream, child); never executed (the execution status of this line is deduced): decodeDataRecursive(stream, child); | - |
| 3022 | item->setChild( childPos / colCount, childPos % colCount, child); never executed (the execution status of this line is deduced): item->setChild( childPos / colCount, childPos % colCount, child); | - |
| 3023 | } | 0 |
| 3024 | } | 0 |
| 3025 | | - |
| 3026 | | - |
| 3027 | /*! | - |
| 3028 | \reimp | - |
| 3029 | */ | - |
| 3030 | bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action, | - |
| 3031 | int row, int column, const QModelIndex &parent) | - |
| 3032 | { | - |
| 3033 | Q_D(QStandardItemModel); never executed (the execution status of this line is deduced): QStandardItemModelPrivate * const d = d_func(); | - |
| 3034 | // check if the action is supported | - |
| 3035 | if (!data || !(action == Qt::CopyAction || action == Qt::MoveAction)) never evaluated: !data never evaluated: action == Qt::CopyAction never evaluated: action == Qt::MoveAction | 0 |
| 3036 | return false; never executed: return false; | 0 |
| 3037 | // check if the format is supported | - |
| 3038 | QString format = QLatin1String("application/x-qstandarditemmodeldatalist"); never executed (the execution status of this line is deduced): QString format = QLatin1String("application/x-qstandarditemmodeldatalist"); | - |
| 3039 | if (!data->hasFormat(format)) never evaluated: !data->hasFormat(format) | 0 |
| 3040 | return QAbstractItemModel::dropMimeData(data, action, row, column, parent); never executed: return QAbstractItemModel::dropMimeData(data, action, row, column, parent); | 0 |
| 3041 | | - |
| 3042 | if (row > rowCount(parent)) never evaluated: row > rowCount(parent) | 0 |
| 3043 | row = rowCount(parent); never executed: row = rowCount(parent); | 0 |
| 3044 | if (row == -1) never evaluated: row == -1 | 0 |
| 3045 | row = rowCount(parent); never executed: row = rowCount(parent); | 0 |
| 3046 | if (column == -1) never evaluated: column == -1 | 0 |
| 3047 | column = 0; never executed: column = 0; | 0 |
| 3048 | | - |
| 3049 | // decode and insert | - |
| 3050 | QByteArray encoded = data->data(format); never executed (the execution status of this line is deduced): QByteArray encoded = data->data(format); | - |
| 3051 | QDataStream stream(&encoded, QIODevice::ReadOnly); never executed (the execution status of this line is deduced): QDataStream stream(&encoded, QIODevice::ReadOnly); | - |
| 3052 | | - |
| 3053 | | - |
| 3054 | //code based on QAbstractItemModel::decodeData | - |
| 3055 | // adapted to work with QStandardItem | - |
| 3056 | int top = INT_MAX; never executed (the execution status of this line is deduced): int top = 2147483647; | - |
| 3057 | int left = INT_MAX; never executed (the execution status of this line is deduced): int left = 2147483647; | - |
| 3058 | int bottom = 0; never executed (the execution status of this line is deduced): int bottom = 0; | - |
| 3059 | int right = 0; never executed (the execution status of this line is deduced): int right = 0; | - |
| 3060 | QVector<int> rows, columns; never executed (the execution status of this line is deduced): QVector<int> rows, columns; | - |
| 3061 | QVector<QStandardItem *> items; never executed (the execution status of this line is deduced): QVector<QStandardItem *> items; | - |
| 3062 | | - |
| 3063 | while (!stream.atEnd()) { never evaluated: !stream.atEnd() | 0 |
| 3064 | int r, c; never executed (the execution status of this line is deduced): int r, c; | - |
| 3065 | QStandardItem *item = d->createItem(); never executed (the execution status of this line is deduced): QStandardItem *item = d->createItem(); | - |
| 3066 | stream >> r >> c; never executed (the execution status of this line is deduced): stream >> r >> c; | - |
| 3067 | d->decodeDataRecursive(stream, item); never executed (the execution status of this line is deduced): d->decodeDataRecursive(stream, item); | - |
| 3068 | | - |
| 3069 | rows.append(r); never executed (the execution status of this line is deduced): rows.append(r); | - |
| 3070 | columns.append(c); never executed (the execution status of this line is deduced): columns.append(c); | - |
| 3071 | items.append(item); never executed (the execution status of this line is deduced): items.append(item); | - |
| 3072 | top = qMin(r, top); never executed (the execution status of this line is deduced): top = qMin(r, top); | - |
| 3073 | left = qMin(c, left); never executed (the execution status of this line is deduced): left = qMin(c, left); | - |
| 3074 | bottom = qMax(r, bottom); never executed (the execution status of this line is deduced): bottom = qMax(r, bottom); | - |
| 3075 | right = qMax(c, right); never executed (the execution status of this line is deduced): right = qMax(c, right); | - |
| 3076 | } | 0 |
| 3077 | | - |
| 3078 | // insert the dragged items into the table, use a bit array to avoid overwriting items, | - |
| 3079 | // since items from different tables can have the same row and column | - |
| 3080 | int dragRowCount = 0; never executed (the execution status of this line is deduced): int dragRowCount = 0; | - |
| 3081 | int dragColumnCount = right - left + 1; never executed (the execution status of this line is deduced): int dragColumnCount = right - left + 1; | - |
| 3082 | | - |
| 3083 | // Compute the number of continuous rows upon insertion and modify the rows to match | - |
| 3084 | QVector<int> rowsToInsert(bottom + 1); never executed (the execution status of this line is deduced): QVector<int> rowsToInsert(bottom + 1); | - |
| 3085 | for (int i = 0; i < rows.count(); ++i) never evaluated: i < rows.count() | 0 |
| 3086 | rowsToInsert[rows.at(i)] = 1; never executed: rowsToInsert[rows.at(i)] = 1; | 0 |
| 3087 | for (int i = 0; i < rowsToInsert.count(); ++i) { never evaluated: i < rowsToInsert.count() | 0 |
| 3088 | if (rowsToInsert[i] == 1){ never evaluated: rowsToInsert[i] == 1 | 0 |
| 3089 | rowsToInsert[i] = dragRowCount; never executed (the execution status of this line is deduced): rowsToInsert[i] = dragRowCount; | - |
| 3090 | ++dragRowCount; never executed (the execution status of this line is deduced): ++dragRowCount; | - |
| 3091 | } | 0 |
| 3092 | } | 0 |
| 3093 | for (int i = 0; i < rows.count(); ++i) never evaluated: i < rows.count() | 0 |
| 3094 | rows[i] = top + rowsToInsert[rows[i]]; never executed: rows[i] = top + rowsToInsert[rows[i]]; | 0 |
| 3095 | | - |
| 3096 | QBitArray isWrittenTo(dragRowCount * dragColumnCount); never executed (the execution status of this line is deduced): QBitArray isWrittenTo(dragRowCount * dragColumnCount); | - |
| 3097 | | - |
| 3098 | // make space in the table for the dropped data | - |
| 3099 | int colCount = columnCount(parent); never executed (the execution status of this line is deduced): int colCount = columnCount(parent); | - |
| 3100 | if (colCount < dragColumnCount + column) { never evaluated: colCount < dragColumnCount + column | 0 |
| 3101 | insertColumns(colCount, dragColumnCount + column - colCount, parent); never executed (the execution status of this line is deduced): insertColumns(colCount, dragColumnCount + column - colCount, parent); | - |
| 3102 | colCount = columnCount(parent); never executed (the execution status of this line is deduced): colCount = columnCount(parent); | - |
| 3103 | } | 0 |
| 3104 | insertRows(row, dragRowCount, parent); never executed (the execution status of this line is deduced): insertRows(row, dragRowCount, parent); | - |
| 3105 | | - |
| 3106 | row = qMax(0, row); never executed (the execution status of this line is deduced): row = qMax(0, row); | - |
| 3107 | column = qMax(0, column); never executed (the execution status of this line is deduced): column = qMax(0, column); | - |
| 3108 | | - |
| 3109 | QStandardItem *parentItem = itemFromIndex (parent); never executed (the execution status of this line is deduced): QStandardItem *parentItem = itemFromIndex (parent); | - |
| 3110 | if (!parentItem) never evaluated: !parentItem | 0 |
| 3111 | parentItem = invisibleRootItem(); never executed: parentItem = invisibleRootItem(); | 0 |
| 3112 | | - |
| 3113 | QVector<QPersistentModelIndex> newIndexes(items.size()); never executed (the execution status of this line is deduced): QVector<QPersistentModelIndex> newIndexes(items.size()); | - |
| 3114 | // set the data in the table | - |
| 3115 | for (int j = 0; j < items.size(); ++j) { never evaluated: j < items.size() | 0 |
| 3116 | int relativeRow = rows.at(j) - top; never executed (the execution status of this line is deduced): int relativeRow = rows.at(j) - top; | - |
| 3117 | int relativeColumn = columns.at(j) - left; never executed (the execution status of this line is deduced): int relativeColumn = columns.at(j) - left; | - |
| 3118 | int destinationRow = relativeRow + row; never executed (the execution status of this line is deduced): int destinationRow = relativeRow + row; | - |
| 3119 | int destinationColumn = relativeColumn + column; never executed (the execution status of this line is deduced): int destinationColumn = relativeColumn + column; | - |
| 3120 | int flat = (relativeRow * dragColumnCount) + relativeColumn; never executed (the execution status of this line is deduced): int flat = (relativeRow * dragColumnCount) + relativeColumn; | - |
| 3121 | // if the item was already written to, or we just can't fit it in the table, create a new row | - |
| 3122 | if (destinationColumn >= colCount || isWrittenTo.testBit(flat)) { never evaluated: destinationColumn >= colCount never evaluated: isWrittenTo.testBit(flat) | 0 |
| 3123 | destinationColumn = qBound(column, destinationColumn, colCount - 1); never executed (the execution status of this line is deduced): destinationColumn = qBound(column, destinationColumn, colCount - 1); | - |
| 3124 | destinationRow = row + dragRowCount; never executed (the execution status of this line is deduced): destinationRow = row + dragRowCount; | - |
| 3125 | insertRows(row + dragRowCount, 1, parent); never executed (the execution status of this line is deduced): insertRows(row + dragRowCount, 1, parent); | - |
| 3126 | flat = (dragRowCount * dragColumnCount) + relativeColumn; never executed (the execution status of this line is deduced): flat = (dragRowCount * dragColumnCount) + relativeColumn; | - |
| 3127 | isWrittenTo.resize(++dragRowCount * dragColumnCount); never executed (the execution status of this line is deduced): isWrittenTo.resize(++dragRowCount * dragColumnCount); | - |
| 3128 | } | 0 |
| 3129 | if (!isWrittenTo.testBit(flat)) { never evaluated: !isWrittenTo.testBit(flat) | 0 |
| 3130 | newIndexes[j] = index(destinationRow, destinationColumn, parentItem->index()); never executed (the execution status of this line is deduced): newIndexes[j] = index(destinationRow, destinationColumn, parentItem->index()); | - |
| 3131 | isWrittenTo.setBit(flat); never executed (the execution status of this line is deduced): isWrittenTo.setBit(flat); | - |
| 3132 | } | 0 |
| 3133 | } | 0 |
| 3134 | | - |
| 3135 | for(int k = 0; k < newIndexes.size(); k++) { never evaluated: k < newIndexes.size() | 0 |
| 3136 | if (newIndexes.at(k).isValid()) { never evaluated: newIndexes.at(k).isValid() | 0 |
| 3137 | parentItem->setChild(newIndexes.at(k).row(), newIndexes.at(k).column(), items.at(k)); never executed (the execution status of this line is deduced): parentItem->setChild(newIndexes.at(k).row(), newIndexes.at(k).column(), items.at(k)); | - |
| 3138 | } else { | 0 |
| 3139 | delete items.at(k); never executed (the execution status of this line is deduced): delete items.at(k); | - |
| 3140 | } | 0 |
| 3141 | } | - |
| 3142 | | - |
| 3143 | return true; never executed: return true; | 0 |
| 3144 | } | - |
| 3145 | | - |
| 3146 | QT_END_NAMESPACE | - |
| 3147 | | - |
| 3148 | #include "moc_qstandarditemmodel.cpp" | - |
| 3149 | | - |
| 3150 | #endif // QT_NO_STANDARDITEMMODEL | - |
| 3151 | | - |
| | |