Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | class QStandardItemModelLessThan | - |
9 | { | - |
10 | public: | - |
11 | inline QStandardItemModelLessThan() | - |
12 | { } | - |
13 | | - |
14 | inline bool operator()(const QPair<QStandardItem*, int> &l, | - |
15 | const QPair<QStandardItem*, int> &r) const | - |
16 | { | - |
17 | return *(l.first) < *(r.first); executed: return *(l.first) < *(r.first); Execution Count:5054 | 5054 |
18 | } | - |
19 | }; | - |
20 | | - |
21 | class QStandardItemModelGreaterThan | - |
22 | { | - |
23 | public: | - |
24 | inline QStandardItemModelGreaterThan() | - |
25 | { } | - |
26 | | - |
27 | inline bool operator()(const QPair<QStandardItem*, int> &l, | - |
28 | const QPair<QStandardItem*, int> &r) const | - |
29 | { | - |
30 | return *(r.first) < *(l.first); executed: return *(r.first) < *(l.first); Execution Count:258 | 258 |
31 | } | - |
32 | }; | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | QStandardItemPrivate::~QStandardItemPrivate() | - |
38 | { | - |
39 | QVector<QStandardItem*>::const_iterator it; | - |
40 | for (it = children.constBegin(); it != children.constEnd(); ++it) { evaluated: it != children.constEnd() yes Evaluation Count:11936835 | yes Evaluation Count:3490082 |
| 3490082-11936835 |
41 | QStandardItem *child = *it; | - |
42 | if (child) evaluated: child yes Evaluation Count:3482528 | yes Evaluation Count:8454307 |
| 3482528-8454307 |
43 | child->d_func()->setModel(0); executed: child->d_func()->setModel(0); Execution Count:3482528 | 3482528 |
44 | delete child; | - |
45 | } executed: } Execution Count:11936835 | 11936835 |
46 | children.clear(); | - |
47 | 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 |
48 | parent->d_func()->childDeleted(q_func()); executed: parent->d_func()->childDeleted(q_func()); Execution Count:74 | 74 |
49 | } executed: } Execution Count:3490082 | 3490082 |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | QPair<int, int> QStandardItemPrivate::position() const | - |
55 | { | - |
56 | if (QStandardItem *par = parent) { partially evaluated: QStandardItem *par = parent yes Evaluation Count:17074275 | no Evaluation Count:0 |
| 0-17074275 |
57 | int idx = par->d_func()->childIndex(q_func()); | - |
58 | if (idx == -1) partially evaluated: idx == -1 no Evaluation Count:0 | yes Evaluation Count:17074275 |
| 0-17074275 |
59 | return QPair<int, int>(-1, -1); never executed: return QPair<int, int>(-1, -1); | 0 |
60 | 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 |
61 | } | - |
62 | | - |
63 | return QPair<int, int>(-1, -1); never executed: return QPair<int, int>(-1, -1); | 0 |
64 | } | - |
65 | | - |
66 | | - |
67 | | - |
68 | | - |
69 | void QStandardItemPrivate::setChild(int row, int column, QStandardItem *item, | - |
70 | bool emitChanged) | - |
71 | { | - |
72 | QStandardItem * const q = q_func(); | - |
73 | if (item == q) { partially evaluated: item == q no Evaluation Count:0 | yes Evaluation Count:3479082 |
| 0-3479082 |
74 | QMessageLogger("itemmodels/qstandarditemmodel.cpp", 127, __PRETTY_FUNCTION__).warning("QStandardItem::setChild: Can't make an item a child of itself %p", | - |
75 | item); | - |
76 | return; | 0 |
77 | } | - |
78 | 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 |
79 | return; executed: return; Execution Count:1 | 1 |
80 | if (rows <= row) evaluated: rows <= row yes Evaluation Count:161 | yes Evaluation Count:3478920 |
| 161-3478920 |
81 | q->setRowCount(row + 1); executed: q->setRowCount(row + 1); Execution Count:161 | 161 |
82 | if (columns <= column) evaluated: columns <= column yes Evaluation Count:122 | yes Evaluation Count:3478959 |
| 122-3478959 |
83 | q->setColumnCount(column + 1); executed: q->setColumnCount(column + 1); Execution Count:122 | 122 |
84 | int index = childIndex(row, column); | - |
85 | qt_noop(); | - |
86 | QStandardItem *oldItem = children.at(index); | - |
87 | if (item == oldItem) partially evaluated: item == oldItem no Evaluation Count:0 | yes Evaluation Count:3479081 |
| 0-3479081 |
88 | return; | 0 |
89 | | - |
90 | 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 |
91 | model->layoutAboutToBeChanged(); | - |
92 | } executed: } Execution Count:4020 | 4020 |
93 | | - |
94 | if (item) { evaluated: item yes Evaluation Count:3479080 | yes Evaluation Count:1 |
| 1-3479080 |
95 | if (item->d_func()->parent == 0) { partially evaluated: item->d_func()->parent == 0 yes Evaluation Count:3479080 | no Evaluation Count:0 |
| 0-3479080 |
96 | item->d_func()->setParentAndModel(q, model); | - |
97 | } else { executed: } Execution Count:3479080 | 3479080 |
98 | QMessageLogger("itemmodels/qstandarditemmodel.cpp", 151, __PRETTY_FUNCTION__).warning("QStandardItem::setChild: Ignoring duplicate insertion of item %p", | - |
99 | item); | - |
100 | return; | 0 |
101 | } | - |
102 | } | - |
103 | if (oldItem) evaluated: oldItem yes Evaluation Count:3 | yes Evaluation Count:3479078 |
| 3-3479078 |
104 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0); Execution Count:3 | 3 |
105 | delete oldItem; | - |
106 | children.replace(index, item); | - |
107 | | - |
108 | 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 |
109 | model->layoutChanged(); executed: model->layoutChanged(); Execution Count:4020 | 4020 |
110 | | - |
111 | 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 |
112 | model->d_func()->itemChanged(item); executed: model->d_func()->itemChanged(item); Execution Count:4020 | 4020 |
113 | } executed: } Execution Count:3479081 | 3479081 |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | void QStandardItemPrivate::changeFlags(bool enable, Qt::ItemFlags f) | - |
120 | { | - |
121 | QStandardItem * const q = q_func(); | - |
122 | Qt::ItemFlags flags = q->flags(); | - |
123 | if (enable) evaluated: enable yes Evaluation Count:72 | yes Evaluation Count:108 |
| 72-108 |
124 | flags |= f; executed: flags |= f; Execution Count:72 | 72 |
125 | else | - |
126 | flags &= ~f; executed: flags &= ~f; Execution Count:108 | 108 |
127 | q->setFlags(flags); | - |
128 | } executed: } Execution Count:180 | 180 |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | void QStandardItemPrivate::childDeleted(QStandardItem *child) | - |
134 | { | - |
135 | int index = childIndex(child); | - |
136 | qt_noop(); | - |
137 | children.replace(index, 0); | - |
138 | } executed: } Execution Count:74 | 74 |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | void QStandardItemPrivate::setItemData(const QMap<int, QVariant> &roles) | - |
144 | { | - |
145 | QStandardItem * const q = q_func(); | - |
146 | | - |
147 | | - |
148 | QVector<QStandardItemData> newValues; | - |
149 | QMap<int, QVariant>::const_iterator it; | - |
150 | for (it = roles.begin(); it != roles.end(); ++it) { evaluated: it != roles.end() yes Evaluation Count:24 | yes Evaluation Count:2 |
| 2-24 |
151 | QVariant value = it.value(); | - |
152 | if (value.isValid()) { partially evaluated: value.isValid() yes Evaluation Count:24 | no Evaluation Count:0 |
| 0-24 |
153 | int role = it.key(); | - |
154 | role = (role == Qt::EditRole) ? Qt::DisplayRole : role; partially evaluated: (role == Qt::EditRole) no Evaluation Count:0 | yes Evaluation Count:24 |
| 0-24 |
155 | QStandardItemData wid(role,it.value()); | - |
156 | newValues.append(wid); | - |
157 | } executed: } Execution Count:24 | 24 |
158 | } executed: } Execution Count:24 | 24 |
159 | | - |
160 | if (values!=newValues) { evaluated: values!=newValues yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
161 | values=newValues; | - |
162 | if (model) partially evaluated: model yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
163 | model->d_func()->itemChanged(q); executed: model->d_func()->itemChanged(q); Execution Count:1 | 1 |
164 | } executed: } Execution Count:1 | 1 |
165 | } executed: } Execution Count:2 | 2 |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | const QMap<int, QVariant> QStandardItemPrivate::itemData() const | - |
171 | { | - |
172 | QMap<int, QVariant> result; | - |
173 | QVector<QStandardItemData>::const_iterator it; | - |
174 | for (it = values.begin(); it != values.end(); ++it) evaluated: it != values.end() yes Evaluation Count:43 | yes Evaluation Count:32 |
| 32-43 |
175 | result.insert((*it).role, (*it).value); executed: result.insert((*it).role, (*it).value); Execution Count:43 | 43 |
176 | return result; executed: return result; Execution Count:32 | 32 |
177 | } | - |
178 | | - |
179 | | - |
180 | | - |
181 | | - |
182 | void QStandardItemPrivate::sortChildren(int column, Qt::SortOrder order) | - |
183 | { | - |
184 | QStandardItem * const q = q_func(); | - |
185 | if (column >= columnCount()) evaluated: column >= columnCount() yes Evaluation Count:1331 | yes Evaluation Count:114 |
| 114-1331 |
186 | return; executed: return; Execution Count:1331 | 1331 |
187 | | - |
188 | QVector<QPair<QStandardItem*, int> > sortable; | - |
189 | QVector<int> unsortable; | - |
190 | | - |
191 | sortable.reserve(rowCount()); | - |
192 | unsortable.reserve(rowCount()); | - |
193 | | - |
194 | for (int row = 0; row < rowCount(); ++row) { evaluated: row < rowCount() yes Evaluation Count:3432 | yes Evaluation Count:114 |
| 114-3432 |
195 | QStandardItem *itm = q->child(row, column); | - |
196 | if (itm) evaluated: itm yes Evaluation Count:1225 | yes Evaluation Count:2207 |
| 1225-2207 |
197 | sortable.append(QPair<QStandardItem*,int>(itm, row)); executed: sortable.append(QPair<QStandardItem*,int>(itm, row)); Execution Count:1225 | 1225 |
198 | else | - |
199 | unsortable.append(row); executed: unsortable.append(row); Execution Count:2207 | 2207 |
200 | } | - |
201 | | - |
202 | if (order == Qt::AscendingOrder) { evaluated: order == Qt::AscendingOrder yes Evaluation Count:98 | yes Evaluation Count:16 |
| 16-98 |
203 | QStandardItemModelLessThan lt; | - |
204 | qStableSort(sortable.begin(), sortable.end(), lt); | - |
205 | } else { executed: } Execution Count:98 | 98 |
206 | QStandardItemModelGreaterThan gt; | - |
207 | qStableSort(sortable.begin(), sortable.end(), gt); | - |
208 | } executed: } Execution Count:16 | 16 |
209 | | - |
210 | QModelIndexList changedPersistentIndexesFrom, changedPersistentIndexesTo; | - |
211 | QVector<QStandardItem*> sorted_children(children.count()); | - |
212 | for (int i = 0; i < rowCount(); ++i) { evaluated: i < rowCount() yes Evaluation Count:3432 | yes Evaluation Count:114 |
| 114-3432 |
213 | int r = (i < sortable.count() evaluated: i < sortable.count() yes Evaluation Count:1225 | yes Evaluation Count:2207 |
| 1225-2207 |
214 | ? sortable.at(i).second | - |
215 | : unsortable.at(i - sortable.count())); | - |
216 | for (int c = 0; c < columnCount(); ++c) { evaluated: c < columnCount() yes Evaluation Count:76078 | yes Evaluation Count:3432 |
| 3432-76078 |
217 | QStandardItem *itm = q->child(r, c); | - |
218 | sorted_children[childIndex(i, c)] = itm; | - |
219 | if (model) { evaluated: model yes Evaluation Count:76064 | yes Evaluation Count:14 |
| 14-76064 |
220 | QModelIndex from = model->createIndex(r, c, q); | - |
221 | 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 |
222 | QModelIndex to = model->createIndex(i, c, q); | - |
223 | changedPersistentIndexesFrom.append(from); | - |
224 | changedPersistentIndexesTo.append(to); | - |
225 | } executed: } Execution Count:37 | 37 |
226 | } executed: } Execution Count:76064 | 76064 |
227 | } executed: } Execution Count:76078 | 76078 |
228 | } executed: } Execution Count:3432 | 3432 |
229 | | - |
230 | children = sorted_children; | - |
231 | | - |
232 | if (model) { evaluated: model yes Evaluation Count:109 | yes Evaluation Count:5 |
| 5-109 |
233 | model->changePersistentIndexList(changedPersistentIndexesFrom, changedPersistentIndexesTo); | - |
234 | } executed: } Execution Count:109 | 109 |
235 | | - |
236 | QVector<QStandardItem*>::iterator it; | - |
237 | for (it = children.begin(); it != children.end(); ++it) { evaluated: it != children.end() yes Evaluation Count:76078 | yes Evaluation Count:114 |
| 114-76078 |
238 | if (*it) evaluated: *it yes Evaluation Count:1396 | yes Evaluation Count:74682 |
| 1396-74682 |
239 | (*it)->d_func()->sortChildren(column, order); executed: (*it)->d_func()->sortChildren(column, order); Execution Count:1396 | 1396 |
240 | } executed: } Execution Count:76078 | 76078 |
241 | } executed: } Execution Count:114 | 114 |
242 | | - |
243 | | - |
244 | | - |
245 | | - |
246 | | - |
247 | void QStandardItemPrivate::setModel(QStandardItemModel *mod) | - |
248 | { | - |
249 | if (children.isEmpty()) { evaluated: children.isEmpty() yes Evaluation Count:6967404 | yes Evaluation Count:6659 |
| 6659-6967404 |
250 | if (model) evaluated: model yes Evaluation Count:155055 | yes Evaluation Count:6812349 |
| 155055-6812349 |
251 | model->d_func()->invalidatePersistentIndex(model->indexFromItem(q_ptr)); executed: model->d_func()->invalidatePersistentIndex(model->indexFromItem(q_ptr)); Execution Count:155055 | 155055 |
252 | model = mod; | - |
253 | } else { executed: } Execution Count:6967404 | 6967404 |
254 | QStack<QStandardItem*> stack; | - |
255 | stack.push(q_ptr); | - |
256 | while (!stack.isEmpty()) { evaluated: !stack.isEmpty() yes Evaluation Count:66473281 | yes Evaluation Count:6659 |
| 6659-66473281 |
257 | QStandardItem *itm = stack.pop(); | - |
258 | if (itm->d_func()->model) { evaluated: itm->d_func()->model yes Evaluation Count:3331832 | yes Evaluation Count:63141449 |
| 3331832-63141449 |
259 | itm->d_func()->model->d_func()->invalidatePersistentIndex(itm->d_func()->model->indexFromItem(itm)); | - |
260 | } executed: } Execution Count:3331832 | 3331832 |
261 | itm->d_func()->model = mod; | - |
262 | const QVector<QStandardItem*> &childList = itm->d_func()->children; | - |
263 | for (int i = 0; i < childList.count(); ++i) { evaluated: i < childList.count() yes Evaluation Count:278605762 | yes Evaluation Count:66473281 |
| 66473281-278605762 |
264 | QStandardItem *chi = childList.at(i); | - |
265 | if (chi) evaluated: chi yes Evaluation Count:66466622 | yes Evaluation Count:212139140 |
| 66466622-212139140 |
266 | stack.push(chi); executed: stack.push(chi); Execution Count:66466622 | 66466622 |
267 | } executed: } Execution Count:278605762 | 278605762 |
268 | } executed: } Execution Count:66473281 | 66473281 |
269 | } executed: } Execution Count:6659 | 6659 |
270 | } | - |
271 | | - |
272 | | - |
273 | | - |
274 | | - |
275 | QStandardItemModelPrivate::QStandardItemModelPrivate() | - |
276 | : root(new QStandardItem), | - |
277 | itemPrototype(0), | - |
278 | sortRole(Qt::DisplayRole) | - |
279 | { | - |
280 | root->setFlags(Qt::ItemIsDropEnabled); | - |
281 | } executed: } Execution Count:1907 | 1907 |
282 | | - |
283 | | - |
284 | | - |
285 | | - |
286 | QStandardItemModelPrivate::~QStandardItemModelPrivate() | - |
287 | { | - |
288 | delete itemPrototype; | - |
289 | qDeleteAll(columnHeaderItems); | - |
290 | qDeleteAll(rowHeaderItems); | - |
291 | } executed: } Execution Count:1749 | 1749 |
292 | | - |
293 | | - |
294 | | - |
295 | | - |
296 | void QStandardItemModelPrivate::init() | - |
297 | { | - |
298 | QStandardItemModel * const q = q_func(); | - |
299 | QObject::connect(q, "2""dataChanged(QModelIndex,QModelIndex)", | - |
300 | q, "1""_q_emitItemChanged(QModelIndex,QModelIndex)"); | - |
301 | } executed: } Execution Count:1907 | 1907 |
302 | | - |
303 | | - |
304 | | - |
305 | | - |
306 | void QStandardItemModelPrivate::_q_emitItemChanged(const QModelIndex &topLeft, | - |
307 | const QModelIndex &bottomRight) | - |
308 | { | - |
309 | QStandardItemModel * const q = q_func(); | - |
310 | QModelIndex parent = topLeft.parent(); | - |
311 | for (int row = topLeft.row(); row <= bottomRight.row(); ++row) { evaluated: row <= bottomRight.row() yes Evaluation Count:6888989 | yes Evaluation Count:6888989 |
| 6888989 |
312 | for (int column = topLeft.column(); column <= bottomRight.column(); ++column) { evaluated: column <= bottomRight.column() yes Evaluation Count:6888990 | yes Evaluation Count:6888989 |
| 6888989-6888990 |
313 | QModelIndex index = q->index(row, column, parent); | - |
314 | if (QStandardItem *item = itemFromIndex(index)) partially evaluated: QStandardItem *item = itemFromIndex(index) yes Evaluation Count:6888990 | no Evaluation Count:0 |
| 0-6888990 |
315 | q->itemChanged(item); executed: q->itemChanged(item); Execution Count:6888990 | 6888990 |
316 | } executed: } Execution Count:6888990 | 6888990 |
317 | } executed: } Execution Count:6888989 | 6888989 |
318 | } executed: } Execution Count:6888989 | 6888989 |
319 | | - |
320 | | - |
321 | | - |
322 | | - |
323 | bool QStandardItemPrivate::insertRows(int row, const QList<QStandardItem*> &items) | - |
324 | { | - |
325 | QStandardItem * const q = q_func(); | - |
326 | 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 |
327 | return false; never executed: return false; | 0 |
328 | int count = items.count(); | - |
329 | if (model) evaluated: model yes Evaluation Count:231 | yes Evaluation Count:1 |
| 1-231 |
330 | model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1); executed: model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1); Execution Count:231 | 231 |
331 | if (rowCount() == 0) { evaluated: rowCount() == 0 yes Evaluation Count:231 | yes Evaluation Count:1 |
| 1-231 |
332 | if (columnCount() == 0) evaluated: columnCount() == 0 yes Evaluation Count:1 | yes Evaluation Count:230 |
| 1-230 |
333 | q->setColumnCount(1); executed: q->setColumnCount(1); Execution Count:1 | 1 |
334 | children.resize(columnCount() * count); | - |
335 | rows = count; | - |
336 | } else { executed: } Execution Count:231 | 231 |
337 | rows += count; | - |
338 | int index = childIndex(row, 0); | - |
339 | if (index != -1) partially evaluated: index != -1 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
340 | children.insert(index, columnCount() * count, 0); executed: children.insert(index, columnCount() * count, 0); Execution Count:1 | 1 |
341 | } executed: } Execution Count:1 | 1 |
342 | for (int i = 0; i < items.count(); ++i) { evaluated: i < items.count() yes Evaluation Count:10346 | yes Evaluation Count:232 |
| 232-10346 |
343 | QStandardItem *item = items.at(i); | - |
344 | item->d_func()->model = model; | - |
345 | item->d_func()->parent = q; | - |
346 | int index = childIndex(i + row, 0); | - |
347 | children.replace(index, item); | - |
348 | } executed: } Execution Count:10346 | 10346 |
349 | if (model) evaluated: model yes Evaluation Count:231 | yes Evaluation Count:1 |
| 1-231 |
350 | model->d_func()->rowsInserted(q, row, count); executed: model->d_func()->rowsInserted(q, row, count); Execution Count:231 | 231 |
351 | return true; executed: return true; Execution Count:232 | 232 |
352 | } | - |
353 | | - |
354 | bool QStandardItemPrivate::insertRows(int row, int count, const QList<QStandardItem*> &items) | - |
355 | { | - |
356 | QStandardItem * const q = q_func(); | - |
357 | 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 |
358 | return false; executed: return false; Execution Count:595 | 595 |
359 | if (model) evaluated: model yes Evaluation Count:23971 | yes Evaluation Count:691 |
| 691-23971 |
360 | model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1); executed: model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1); Execution Count:23971 | 23971 |
361 | if (rowCount() == 0) { evaluated: rowCount() == 0 yes Evaluation Count:8674 | yes Evaluation Count:15988 |
| 8674-15988 |
362 | children.resize(columnCount() * count); | - |
363 | rows = count; | - |
364 | } else { executed: } Execution Count:8674 | 8674 |
365 | rows += count; | - |
366 | int index = childIndex(row, 0); | - |
367 | if (index != -1) evaluated: index != -1 yes Evaluation Count:3012 | yes Evaluation Count:12976 |
| 3012-12976 |
368 | children.insert(index, columnCount() * count, 0); executed: children.insert(index, columnCount() * count, 0); Execution Count:3012 | 3012 |
369 | } executed: } Execution Count:15988 | 15988 |
370 | if (!items.isEmpty()) { evaluated: !items.isEmpty() yes Evaluation Count:1830 | yes Evaluation Count:22832 |
| 1830-22832 |
371 | int index = childIndex(row, 0); | - |
372 | int limit = qMin(items.count(), columnCount() * count); | - |
373 | for (int i = 0; i < limit; ++i) { evaluated: i < limit yes Evaluation Count:4545 | yes Evaluation Count:1830 |
| 1830-4545 |
374 | QStandardItem *item = items.at(i); | - |
375 | if (item) { partially evaluated: item yes Evaluation Count:4545 | no Evaluation Count:0 |
| 0-4545 |
376 | if (item->d_func()->parent == 0) { partially evaluated: item->d_func()->parent == 0 yes Evaluation Count:4545 | no Evaluation Count:0 |
| 0-4545 |
377 | item->d_func()->setParentAndModel(q, model); | - |
378 | } else { executed: } Execution Count:4545 | 4545 |
379 | QMessageLogger("itemmodels/qstandarditemmodel.cpp", 432, __PRETTY_FUNCTION__).warning("QStandardItem::insertRows: Ignoring duplicate insertion of item %p", | - |
380 | item); | - |
381 | item = 0; | - |
382 | } | 0 |
383 | } | - |
384 | children.replace(index, item); | - |
385 | ++index; | - |
386 | } executed: } Execution Count:4545 | 4545 |
387 | } executed: } Execution Count:1830 | 1830 |
388 | if (model) evaluated: model yes Evaluation Count:23971 | yes Evaluation Count:691 |
| 691-23971 |
389 | model->d_func()->rowsInserted(q, row, count); executed: model->d_func()->rowsInserted(q, row, count); Execution Count:23971 | 23971 |
390 | return true; executed: return true; Execution Count:24662 | 24662 |
391 | } | - |
392 | | - |
393 | | - |
394 | | - |
395 | | - |
396 | bool QStandardItemPrivate::insertColumns(int column, int count, const QList<QStandardItem*> &items) | - |
397 | { | - |
398 | QStandardItem * const q = q_func(); | - |
399 | 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 |
400 | return false; executed: return false; Execution Count:29 | 29 |
401 | if (model) evaluated: model yes Evaluation Count:9170 | yes Evaluation Count:1203 |
| 1203-9170 |
402 | model->d_func()->columnsAboutToBeInserted(q, column, column + count - 1); executed: model->d_func()->columnsAboutToBeInserted(q, column, column + count - 1); Execution Count:9170 | 9170 |
403 | if (columnCount() == 0) { evaluated: columnCount() == 0 yes Evaluation Count:10079 | yes Evaluation Count:294 |
| 294-10079 |
404 | children.resize(rowCount() * count); | - |
405 | columns = count; | - |
406 | } else { executed: } Execution Count:10079 | 10079 |
407 | columns += count; | - |
408 | int index = childIndex(0, column); | - |
409 | for (int row = 0; row < rowCount(); ++row) { evaluated: row < rowCount() yes Evaluation Count:9885 | yes Evaluation Count:294 |
| 294-9885 |
410 | children.insert(index, count, 0); | - |
411 | index += columnCount(); | - |
412 | } executed: } Execution Count:9885 | 9885 |
413 | } executed: } Execution Count:294 | 294 |
414 | if (!items.isEmpty()) { evaluated: !items.isEmpty() yes Evaluation Count:61 | yes Evaluation Count:10312 |
| 61-10312 |
415 | int limit = qMin(items.count(), rowCount() * count); | - |
416 | for (int i = 0; i < limit; ++i) { evaluated: i < limit yes Evaluation Count:358 | yes Evaluation Count:61 |
| 61-358 |
417 | QStandardItem *item = items.at(i); | - |
418 | if (item) { partially evaluated: item yes Evaluation Count:358 | no Evaluation Count:0 |
| 0-358 |
419 | if (item->d_func()->parent == 0) { partially evaluated: item->d_func()->parent == 0 yes Evaluation Count:358 | no Evaluation Count:0 |
| 0-358 |
420 | item->d_func()->setParentAndModel(q, model); | - |
421 | } else { executed: } Execution Count:358 | 358 |
422 | QMessageLogger("itemmodels/qstandarditemmodel.cpp", 475, __PRETTY_FUNCTION__).warning("QStandardItem::insertColumns: Ignoring duplicate insertion of item %p", | - |
423 | item); | - |
424 | item = 0; | - |
425 | } | 0 |
426 | } | - |
427 | int r = i / count; | - |
428 | int c = column + (i % count); | - |
429 | int index = childIndex(r, c); | - |
430 | children.replace(index, item); | - |
431 | } executed: } Execution Count:358 | 358 |
432 | } executed: } Execution Count:61 | 61 |
433 | if (model) evaluated: model yes Evaluation Count:9170 | yes Evaluation Count:1203 |
| 1203-9170 |
434 | model->d_func()->columnsInserted(q, column, count); executed: model->d_func()->columnsInserted(q, column, count); Execution Count:9170 | 9170 |
435 | return true; executed: return true; Execution Count:10373 | 10373 |
436 | } | - |
437 | | - |
438 | | - |
439 | | - |
440 | | - |
441 | void QStandardItemModelPrivate::itemChanged(QStandardItem *item) | - |
442 | { | - |
443 | QStandardItemModel * const q = q_func(); | - |
444 | if (item->d_func()->parent == 0) { evaluated: item->d_func()->parent == 0 yes Evaluation Count:125 | yes Evaluation Count:6888988 |
| 125-6888988 |
445 | | - |
446 | int idx = columnHeaderItems.indexOf(item); | - |
447 | if (idx != -1) { evaluated: idx != -1 yes Evaluation Count:95 | yes Evaluation Count:30 |
| 30-95 |
448 | q->headerDataChanged(Qt::Horizontal, idx, idx); | - |
449 | } else { executed: } Execution Count:95 | 95 |
450 | idx = rowHeaderItems.indexOf(item); | - |
451 | if (idx != -1) evaluated: idx != -1 yes Evaluation Count:28 | yes Evaluation Count:2 |
| 2-28 |
452 | q->headerDataChanged(Qt::Vertical, idx, idx); executed: q->headerDataChanged(Qt::Vertical, idx, idx); Execution Count:28 | 28 |
453 | } executed: } Execution Count:30 | 30 |
454 | } else { | - |
455 | | - |
456 | QModelIndex index = q->indexFromItem(item); | - |
457 | q->dataChanged(index, index); | - |
458 | } executed: } Execution Count:6888988 | 6888988 |
459 | } | - |
460 | | - |
461 | | - |
462 | | - |
463 | | - |
464 | void QStandardItemModelPrivate::rowsAboutToBeInserted(QStandardItem *parent, | - |
465 | int start, int end) | - |
466 | { | - |
467 | QStandardItemModel * const q = q_func(); | - |
468 | QModelIndex index = q->indexFromItem(parent); | - |
469 | q->beginInsertRows(index, start, end); | - |
470 | } executed: } Execution Count:24202 | 24202 |
471 | | - |
472 | | - |
473 | | - |
474 | | - |
475 | void QStandardItemModelPrivate::columnsAboutToBeInserted(QStandardItem *parent, | - |
476 | int start, int end) | - |
477 | { | - |
478 | QStandardItemModel * const q = q_func(); | - |
479 | QModelIndex index = q->indexFromItem(parent); | - |
480 | q->beginInsertColumns(index, start, end); | - |
481 | } executed: } Execution Count:9170 | 9170 |
482 | | - |
483 | | - |
484 | | - |
485 | | - |
486 | void QStandardItemModelPrivate::rowsAboutToBeRemoved(QStandardItem *parent, | - |
487 | int start, int end) | - |
488 | { | - |
489 | QStandardItemModel * const q = q_func(); | - |
490 | QModelIndex index = q->indexFromItem(parent); | - |
491 | q->beginRemoveRows(index, start, end); | - |
492 | } executed: } Execution Count:458 | 458 |
493 | | - |
494 | | - |
495 | | - |
496 | | - |
497 | void QStandardItemModelPrivate::columnsAboutToBeRemoved(QStandardItem *parent, | - |
498 | int start, int end) | - |
499 | { | - |
500 | QStandardItemModel * const q = q_func(); | - |
501 | QModelIndex index = q->indexFromItem(parent); | - |
502 | q->beginRemoveColumns(index, start, end); | - |
503 | } executed: } Execution Count:65 | 65 |
504 | | - |
505 | | - |
506 | | - |
507 | | - |
508 | void QStandardItemModelPrivate::rowsInserted(QStandardItem *parent, | - |
509 | int row, int count) | - |
510 | { | - |
511 | QStandardItemModel * const q = q_func(); | - |
512 | if (parent == root.data()) evaluated: parent == root.data() yes Evaluation Count:15695 | yes Evaluation Count:8507 |
| 8507-15695 |
513 | rowHeaderItems.insert(row, count, 0); executed: rowHeaderItems.insert(row, count, 0); Execution Count:15695 | 15695 |
514 | q->endInsertRows(); | - |
515 | } executed: } Execution Count:24202 | 24202 |
516 | | - |
517 | | - |
518 | | - |
519 | | - |
520 | void QStandardItemModelPrivate::columnsInserted(QStandardItem *parent, | - |
521 | int column, int count) | - |
522 | { | - |
523 | QStandardItemModel * const q = q_func(); | - |
524 | if (parent == root.data()) evaluated: parent == root.data() yes Evaluation Count:1223 | yes Evaluation Count:7947 |
| 1223-7947 |
525 | columnHeaderItems.insert(column, count, 0); executed: columnHeaderItems.insert(column, count, 0); Execution Count:1223 | 1223 |
526 | q->endInsertColumns(); | - |
527 | } executed: } Execution Count:9170 | 9170 |
528 | | - |
529 | | - |
530 | | - |
531 | | - |
532 | void QStandardItemModelPrivate::rowsRemoved(QStandardItem *parent, | - |
533 | int row, int count) | - |
534 | { | - |
535 | QStandardItemModel * const q = q_func(); | - |
536 | if (parent == root.data()) { evaluated: parent == root.data() yes Evaluation Count:405 | yes Evaluation Count:53 |
| 53-405 |
537 | for (int i = row; i < row + count; ++i) { evaluated: i < row + count yes Evaluation Count:2688 | yes Evaluation Count:405 |
| 405-2688 |
538 | QStandardItem *oldItem = rowHeaderItems.at(i); | - |
539 | if (oldItem) evaluated: oldItem yes Evaluation Count:1 | yes Evaluation Count:2687 |
| 1-2687 |
540 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0); Execution Count:1 | 1 |
541 | delete oldItem; | - |
542 | } executed: } Execution Count:2688 | 2688 |
543 | rowHeaderItems.remove(row, count); | - |
544 | } executed: } Execution Count:405 | 405 |
545 | q->endRemoveRows(); | - |
546 | } executed: } Execution Count:458 | 458 |
547 | | - |
548 | | - |
549 | | - |
550 | | - |
551 | void QStandardItemModelPrivate::columnsRemoved(QStandardItem *parent, | - |
552 | int column, int count) | - |
553 | { | - |
554 | QStandardItemModel * const q = q_func(); | - |
555 | if (parent == root.data()) { evaluated: parent == root.data() yes Evaluation Count:29 | yes Evaluation Count:36 |
| 29-36 |
556 | for (int i = column; i < column + count; ++i) { evaluated: i < column + count yes Evaluation Count:45 | yes Evaluation Count:29 |
| 29-45 |
557 | QStandardItem *oldItem = columnHeaderItems.at(i); | - |
558 | if (oldItem) evaluated: oldItem yes Evaluation Count:13 | yes Evaluation Count:32 |
| 13-32 |
559 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0); Execution Count:13 | 13 |
560 | delete oldItem; | - |
561 | } executed: } Execution Count:45 | 45 |
562 | columnHeaderItems.remove(column, count); | - |
563 | } executed: } Execution Count:29 | 29 |
564 | q->endRemoveColumns(); | - |
565 | } executed: } Execution Count:65 | 65 |
566 | QStandardItem::QStandardItem() | - |
567 | : d_ptr(new QStandardItemPrivate) | - |
568 | { | - |
569 | QStandardItemPrivate * const d = d_func(); | - |
570 | d->q_ptr = this; | - |
571 | } executed: } Execution Count:3480661 | 3480661 |
572 | | - |
573 | | - |
574 | | - |
575 | | - |
576 | QStandardItem::QStandardItem(const QString &text) | - |
577 | : d_ptr(new QStandardItemPrivate) | - |
578 | { | - |
579 | QStandardItemPrivate * const d = d_func(); | - |
580 | d->q_ptr = this; | - |
581 | setText(text); | - |
582 | } executed: } Execution Count:16259 | 16259 |
583 | | - |
584 | | - |
585 | | - |
586 | | - |
587 | QStandardItem::QStandardItem(const QIcon &icon, const QString &text) | - |
588 | : d_ptr(new QStandardItemPrivate) | - |
589 | { | - |
590 | QStandardItemPrivate * const d = d_func(); | - |
591 | d->q_ptr = this; | - |
592 | setIcon(icon); | - |
593 | setText(text); | - |
594 | } executed: } Execution Count:3 | 3 |
595 | | - |
596 | | - |
597 | | - |
598 | | - |
599 | QStandardItem::QStandardItem(int rows, int columns) | - |
600 | : d_ptr(new QStandardItemPrivate) | - |
601 | { | - |
602 | QStandardItemPrivate * const d = d_func(); | - |
603 | d->q_ptr = this; | - |
604 | setRowCount(rows); | - |
605 | setColumnCount(columns); | - |
606 | } executed: } Execution Count:134 | 134 |
607 | | - |
608 | | - |
609 | | - |
610 | | - |
611 | QStandardItem::QStandardItem(QStandardItemPrivate &dd) | - |
612 | : d_ptr(&dd) | - |
613 | { | - |
614 | QStandardItemPrivate * const d = d_func(); | - |
615 | d->q_ptr = this; | - |
616 | } | 0 |
617 | | - |
618 | | - |
619 | | - |
620 | | - |
621 | | - |
622 | | - |
623 | | - |
624 | QStandardItem::QStandardItem(const QStandardItem &other) | - |
625 | : d_ptr(new QStandardItemPrivate) | - |
626 | { | - |
627 | QStandardItemPrivate * const d = d_func(); | - |
628 | d->q_ptr = this; | - |
629 | operator=(other); | - |
630 | } executed: } Execution Count:1 | 1 |
631 | | - |
632 | | - |
633 | | - |
634 | | - |
635 | | - |
636 | | - |
637 | | - |
638 | QStandardItem &QStandardItem::operator=(const QStandardItem &other) | - |
639 | { | - |
640 | QStandardItemPrivate * const d = d_func(); | - |
641 | d->values = other.d_func()->values; | - |
642 | return *this; executed: return *this; Execution Count:1 | 1 |
643 | } | - |
644 | | - |
645 | | - |
646 | | - |
647 | | - |
648 | | - |
649 | QStandardItem::~QStandardItem() | - |
650 | { | - |
651 | } | - |
652 | QStandardItem *QStandardItem::parent() const | - |
653 | { | - |
654 | const QStandardItemPrivate * const d = d_func(); | - |
655 | 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 |
656 | return d->parent; executed: return d->parent; Execution Count:202 | 202 |
657 | return 0; executed: return 0; Execution Count:2 | 2 |
658 | } | - |
659 | void QStandardItem::setData(const QVariant &value, int role) | - |
660 | { | - |
661 | QStandardItemPrivate * const d = d_func(); | - |
662 | role = (role == Qt::EditRole) ? Qt::DisplayRole : role; evaluated: (role == Qt::EditRole) yes Evaluation Count:3473084 | yes Evaluation Count:3431963 |
| 3431963-3473084 |
663 | QVector<QStandardItemData>::iterator it; | - |
664 | 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 |
665 | if ((*it).role == role) { evaluated: (*it).role == role yes Evaluation Count:2668 | yes Evaluation Count:3418299 |
| 2668-3418299 |
666 | if (value.isValid()) { evaluated: value.isValid() yes Evaluation Count:2642 | yes Evaluation Count:26 |
| 26-2642 |
667 | 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 |
668 | return; executed: return; Execution Count:1437 | 1437 |
669 | (*it).value = value; | - |
670 | } else { executed: } Execution Count:1205 | 1205 |
671 | d->values.erase(it); | - |
672 | } executed: } Execution Count:26 | 26 |
673 | if (d->model) evaluated: d->model yes Evaluation Count:1163 | yes Evaluation Count:68 |
| 68-1163 |
674 | d->model->d_func()->itemChanged(this); executed: d->model->d_func()->itemChanged(this); Execution Count:1163 | 1163 |
675 | return; executed: return; Execution Count:1231 | 1231 |
676 | } | - |
677 | } executed: } Execution Count:3418299 | 3418299 |
678 | d->values.append(QStandardItemData(role, value)); | - |
679 | if (d->model) evaluated: d->model yes Evaluation Count:6883928 | yes Evaluation Count:18451 |
| 18451-6883928 |
680 | d->model->d_func()->itemChanged(this); executed: d->model->d_func()->itemChanged(this); Execution Count:6883928 | 6883928 |
681 | } executed: } Execution Count:6902379 | 6902379 |
682 | QVariant QStandardItem::data(int role) const | - |
683 | { | - |
684 | const QStandardItemPrivate * const d = d_func(); | - |
685 | role = (role == Qt::EditRole) ? Qt::DisplayRole : role; evaluated: (role == Qt::EditRole) yes Evaluation Count:306 | yes Evaluation Count:807266 |
| 306-807266 |
686 | QVector<QStandardItemData>::const_iterator it; | - |
687 | 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 |
688 | if ((*it).role == role) evaluated: (*it).role == role yes Evaluation Count:351119 | yes Evaluation Count:907210 |
| 351119-907210 |
689 | return (*it).value; executed: return (*it).value; Execution Count:351119 | 351119 |
690 | } executed: } Execution Count:907210 | 907210 |
691 | return QVariant(); executed: return QVariant(); Execution Count:456453 | 456453 |
692 | } | - |
693 | void QStandardItem::emitDataChanged() | - |
694 | { | - |
695 | QStandardItemPrivate * const d = d_func(); | - |
696 | if (d->model) evaluated: d->model yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
697 | d->model->d_func()->itemChanged(this); executed: d->model->d_func()->itemChanged(this); Execution Count:1 | 1 |
698 | } executed: } Execution Count:2 | 2 |
699 | void QStandardItem::setFlags(Qt::ItemFlags flags) | - |
700 | { | - |
701 | setData((int)flags, Qt::UserRole - 1); | - |
702 | } executed: } Execution Count:2144 | 2144 |
703 | Qt::ItemFlags QStandardItem::flags() const | - |
704 | { | - |
705 | QVariant v = data(Qt::UserRole - 1); | - |
706 | if (!v.isValid()) evaluated: !v.isValid() yes Evaluation Count:17362 | yes Evaluation Count:369 |
| 369-17362 |
707 | return (Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable | 17362 |
708 | |Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled); executed: return (Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable |Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled); Execution Count:17362 | 17362 |
709 | return Qt::ItemFlags(v.toInt()); executed: return Qt::ItemFlags(v.toInt()); Execution Count:369 | 369 |
710 | } | - |
711 | void QStandardItem::setEnabled(bool enabled) | - |
712 | { | - |
713 | QStandardItemPrivate * const d = d_func(); | - |
714 | d->changeFlags(enabled, Qt::ItemIsEnabled); | - |
715 | } executed: } Execution Count:116 | 116 |
716 | void QStandardItem::setEditable(bool editable) | - |
717 | { | - |
718 | QStandardItemPrivate * const d = d_func(); | - |
719 | d->changeFlags(editable, Qt::ItemIsEditable); | - |
720 | } executed: } Execution Count:4 | 4 |
721 | void QStandardItem::setSelectable(bool selectable) | - |
722 | { | - |
723 | QStandardItemPrivate * const d = d_func(); | - |
724 | d->changeFlags(selectable, Qt::ItemIsSelectable); | - |
725 | } executed: } Execution Count:2 | 2 |
726 | void QStandardItem::setCheckable(bool checkable) | - |
727 | { | - |
728 | QStandardItemPrivate * const d = d_func(); | - |
729 | 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 |
730 | | - |
731 | if (!data(Qt::CheckStateRole).isValid()) evaluated: !data(Qt::CheckStateRole).isValid() yes Evaluation Count:48 | yes Evaluation Count:1 |
| 1-48 |
732 | setData(Qt::Unchecked, Qt::CheckStateRole); executed: setData(Qt::Unchecked, Qt::CheckStateRole); Execution Count:48 | 48 |
733 | } executed: } Execution Count:49 | 49 |
734 | d->changeFlags(checkable, Qt::ItemIsUserCheckable); | - |
735 | } executed: } Execution Count:51 | 51 |
736 | void QStandardItem::setTristate(bool tristate) | - |
737 | { | - |
738 | QStandardItemPrivate * const d = d_func(); | - |
739 | d->changeFlags(tristate, Qt::ItemIsTristate); | - |
740 | } executed: } Execution Count:2 | 2 |
741 | void QStandardItem::setDragEnabled(bool dragEnabled) | - |
742 | { | - |
743 | QStandardItemPrivate * const d = d_func(); | - |
744 | d->changeFlags(dragEnabled, Qt::ItemIsDragEnabled); | - |
745 | } executed: } Execution Count:2 | 2 |
746 | void QStandardItem::setDropEnabled(bool dropEnabled) | - |
747 | { | - |
748 | QStandardItemPrivate * const d = d_func(); | - |
749 | d->changeFlags(dropEnabled, Qt::ItemIsDropEnabled); | - |
750 | } executed: } Execution Count:3 | 3 |
751 | int QStandardItem::row() const | - |
752 | { | - |
753 | const QStandardItemPrivate * const d = d_func(); | - |
754 | QPair<int, int> pos = d->position(); | - |
755 | return pos.first; executed: return pos.first; Execution Count:2770 | 2770 |
756 | } | - |
757 | | - |
758 | | - |
759 | | - |
760 | | - |
761 | | - |
762 | | - |
763 | | - |
764 | int QStandardItem::column() const | - |
765 | { | - |
766 | const QStandardItemPrivate * const d = d_func(); | - |
767 | QPair<int, int> pos = d->position(); | - |
768 | return pos.second; executed: return pos.second; Execution Count:2770 | 2770 |
769 | } | - |
770 | QModelIndex QStandardItem::index() const | - |
771 | { | - |
772 | const QStandardItemPrivate * const d = d_func(); | - |
773 | return d->model ? d->model->indexFromItem(this) : QModelIndex(); executed: return d->model ? d->model->indexFromItem(this) : QModelIndex(); Execution Count:104 | 104 |
774 | } | - |
775 | QStandardItemModel *QStandardItem::model() const | - |
776 | { | - |
777 | const QStandardItemPrivate * const d = d_func(); | - |
778 | return d->model; executed: return d->model; Execution Count:10927 | 10927 |
779 | } | - |
780 | | - |
781 | | - |
782 | | - |
783 | | - |
784 | | - |
785 | | - |
786 | | - |
787 | void QStandardItem::setRowCount(int rows) | - |
788 | { | - |
789 | int rc = rowCount(); | - |
790 | if (rc == rows) evaluated: rc == rows yes Evaluation Count:65 | yes Evaluation Count:13363 |
| 65-13363 |
791 | return; executed: return; Execution Count:65 | 65 |
792 | if (rc < rows) evaluated: rc < rows yes Evaluation Count:13344 | yes Evaluation Count:19 |
| 19-13344 |
793 | insertRows(qMax(rc, 0), rows - rc); executed: insertRows(qMax(rc, 0), rows - rc); Execution Count:13344 | 13344 |
794 | else | - |
795 | removeRows(qMax(rows, 0), rc - rows); executed: removeRows(qMax(rows, 0), rc - rows); Execution Count:19 | 19 |
796 | } | - |
797 | | - |
798 | | - |
799 | | - |
800 | | - |
801 | | - |
802 | | - |
803 | int QStandardItem::rowCount() const | - |
804 | { | - |
805 | const QStandardItemPrivate * const d = d_func(); | - |
806 | return d->rowCount(); executed: return d->rowCount(); Execution Count:11196220 | 11196220 |
807 | } | - |
808 | | - |
809 | | - |
810 | | - |
811 | | - |
812 | | - |
813 | | - |
814 | | - |
815 | void QStandardItem::setColumnCount(int columns) | - |
816 | { | - |
817 | int cc = columnCount(); | - |
818 | if (cc == columns) evaluated: cc == columns yes Evaluation Count:35 | yes Evaluation Count:2204 |
| 35-2204 |
819 | return; executed: return; Execution Count:35 | 35 |
820 | if (cc < columns) evaluated: cc < columns yes Evaluation Count:2200 | yes Evaluation Count:4 |
| 4-2200 |
821 | insertColumns(qMax(cc, 0), columns - cc); executed: insertColumns(qMax(cc, 0), columns - cc); Execution Count:2200 | 2200 |
822 | else | - |
823 | removeColumns(qMax(columns, 0), cc - columns); executed: removeColumns(qMax(columns, 0), cc - columns); Execution Count:4 | 4 |
824 | } | - |
825 | | - |
826 | | - |
827 | | - |
828 | | - |
829 | | - |
830 | | - |
831 | int QStandardItem::columnCount() const | - |
832 | { | - |
833 | const QStandardItemPrivate * const d = d_func(); | - |
834 | return d->columnCount(); executed: return d->columnCount(); Execution Count:48638556 | 48638556 |
835 | } | - |
836 | | - |
837 | | - |
838 | | - |
839 | | - |
840 | | - |
841 | | - |
842 | | - |
843 | void QStandardItem::insertRow(int row, const QList<QStandardItem*> &items) | - |
844 | { | - |
845 | QStandardItemPrivate * const d = d_func(); | - |
846 | if (row < 0) evaluated: row < 0 yes Evaluation Count:2 | yes Evaluation Count:3199 |
| 2-3199 |
847 | return; executed: return; Execution Count:2 | 2 |
848 | if (columnCount() < items.count()) evaluated: columnCount() < items.count() yes Evaluation Count:537 | yes Evaluation Count:2662 |
| 537-2662 |
849 | setColumnCount(items.count()); executed: setColumnCount(items.count()); Execution Count:537 | 537 |
850 | d->insertRows(row, 1, items); | - |
851 | } executed: } Execution Count:3199 | 3199 |
852 | | - |
853 | | - |
854 | | - |
855 | | - |
856 | | - |
857 | | - |
858 | void QStandardItem::insertRows(int row, const QList<QStandardItem*> &items) | - |
859 | { | - |
860 | QStandardItemPrivate * const d = d_func(); | - |
861 | if (row < 0) partially evaluated: row < 0 no Evaluation Count:0 | yes Evaluation Count:232 |
| 0-232 |
862 | return; | 0 |
863 | d->insertRows(row, items); | - |
864 | } executed: } Execution Count:232 | 232 |
865 | | - |
866 | | - |
867 | | - |
868 | | - |
869 | | - |
870 | | - |
871 | | - |
872 | void QStandardItem::insertColumn(int column, const QList<QStandardItem*> &items) | - |
873 | { | - |
874 | QStandardItemPrivate * const d = d_func(); | - |
875 | if (column < 0) evaluated: column < 0 yes Evaluation Count:2 | yes Evaluation Count:66 |
| 2-66 |
876 | return; executed: return; Execution Count:2 | 2 |
877 | if (rowCount() < items.count()) evaluated: rowCount() < items.count() yes Evaluation Count:33 | yes Evaluation Count:33 |
| 33 |
878 | setRowCount(items.count()); executed: setRowCount(items.count()); Execution Count:33 | 33 |
879 | d->insertColumns(column, 1, items); | - |
880 | } executed: } Execution Count:66 | 66 |
881 | | - |
882 | | - |
883 | | - |
884 | | - |
885 | | - |
886 | | - |
887 | void QStandardItem::insertRows(int row, int count) | - |
888 | { | - |
889 | QStandardItemPrivate * const d = d_func(); | - |
890 | if (rowCount() < row) { partially evaluated: rowCount() < row no Evaluation Count:0 | yes Evaluation Count:14229 |
| 0-14229 |
891 | count += row - rowCount(); | - |
892 | row = rowCount(); | - |
893 | } | 0 |
894 | d->insertRows(row, count, QList<QStandardItem*>()); | - |
895 | } executed: } Execution Count:14229 | 14229 |
896 | | - |
897 | | - |
898 | | - |
899 | | - |
900 | | - |
901 | | - |
902 | void QStandardItem::insertColumns(int column, int count) | - |
903 | { | - |
904 | QStandardItemPrivate * const d = d_func(); | - |
905 | if (columnCount() < column) { partially evaluated: columnCount() < column no Evaluation Count:0 | yes Evaluation Count:3085 |
| 0-3085 |
906 | count += column - columnCount(); | - |
907 | column = columnCount(); | - |
908 | } | 0 |
909 | d->insertColumns(column, count, QList<QStandardItem*>()); | - |
910 | } executed: } Execution Count:3085 | 3085 |
911 | void QStandardItem::removeRow(int row) | - |
912 | { | - |
913 | removeRows(row, 1); | - |
914 | } executed: } Execution Count:10 | 10 |
915 | | - |
916 | | - |
917 | | - |
918 | | - |
919 | | - |
920 | | - |
921 | | - |
922 | void QStandardItem::removeColumn(int column) | - |
923 | { | - |
924 | removeColumns(column, 1); | - |
925 | } | 0 |
926 | | - |
927 | | - |
928 | | - |
929 | | - |
930 | | - |
931 | | - |
932 | | - |
933 | void QStandardItem::removeRows(int row, int count) | - |
934 | { | - |
935 | QStandardItemPrivate * const d = d_func(); | - |
936 | 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 |
937 | return; executed: return; Execution Count:2 | 2 |
938 | if (d->model) evaluated: d->model yes Evaluation Count:456 | yes Evaluation Count:1 |
| 1-456 |
939 | 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 |
940 | int i = d->childIndex(row, 0); | - |
941 | int n = count * d->columnCount(); | - |
942 | for (int j = i; j < n+i; ++j) { evaluated: j < n+i yes Evaluation Count:38708 | yes Evaluation Count:457 |
| 457-38708 |
943 | QStandardItem *oldItem = d->children.at(j); | - |
944 | if (oldItem) evaluated: oldItem yes Evaluation Count:4777 | yes Evaluation Count:33931 |
| 4777-33931 |
945 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0); Execution Count:4777 | 4777 |
946 | delete oldItem; | - |
947 | } executed: } Execution Count:38708 | 38708 |
948 | d->children.remove(qMax(i, 0), n); | - |
949 | d->rows -= count; | - |
950 | if (d->model) evaluated: d->model yes Evaluation Count:456 | yes Evaluation Count:1 |
| 1-456 |
951 | d->model->d_func()->rowsRemoved(this, row, count); executed: d->model->d_func()->rowsRemoved(this, row, count); Execution Count:456 | 456 |
952 | } executed: } Execution Count:457 | 457 |
953 | | - |
954 | | - |
955 | | - |
956 | | - |
957 | | - |
958 | | - |
959 | | - |
960 | void QStandardItem::removeColumns(int column, int count) | - |
961 | { | - |
962 | QStandardItemPrivate * const d = d_func(); | - |
963 | 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 |
964 | return; executed: return; Execution Count:2 | 2 |
965 | if (d->model) evaluated: d->model yes Evaluation Count:64 | yes Evaluation Count:1 |
| 1-64 |
966 | 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 |
967 | for (int row = d->rowCount() - 1; row >= 0; --row) { evaluated: row >= 0 yes Evaluation Count:1280 | yes Evaluation Count:65 |
| 65-1280 |
968 | int i = d->childIndex(row, column); | - |
969 | for (int j=i; j<i+count; ++j) { evaluated: j<i+count yes Evaluation Count:5605 | yes Evaluation Count:1280 |
| 1280-5605 |
970 | QStandardItem *oldItem = d->children.at(j); | - |
971 | if (oldItem) evaluated: oldItem yes Evaluation Count:111 | yes Evaluation Count:5494 |
| 111-5494 |
972 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0); Execution Count:111 | 111 |
973 | delete oldItem; | - |
974 | } executed: } Execution Count:5605 | 5605 |
975 | d->children.remove(i, count); | - |
976 | } executed: } Execution Count:1280 | 1280 |
977 | d->columns -= count; | - |
978 | if (d->model) evaluated: d->model yes Evaluation Count:64 | yes Evaluation Count:1 |
| 1-64 |
979 | d->model->d_func()->columnsRemoved(this, column, count); executed: d->model->d_func()->columnsRemoved(this, column, count); Execution Count:64 | 64 |
980 | } executed: } Execution Count:65 | 65 |
981 | | - |
982 | | - |
983 | | - |
984 | | - |
985 | | - |
986 | | - |
987 | bool QStandardItem::hasChildren() const | - |
988 | { | - |
989 | return (rowCount() > 0) && (columnCount() > 0); executed: return (rowCount() > 0) && (columnCount() > 0); Execution Count:12057 | 12057 |
990 | } | - |
991 | void QStandardItem::setChild(int row, int column, QStandardItem *item) | - |
992 | { | - |
993 | QStandardItemPrivate * const d = d_func(); | - |
994 | d->setChild(row, column, item, true); | - |
995 | } executed: } Execution Count:3194 | 3194 |
996 | QStandardItem *QStandardItem::child(int row, int column) const | - |
997 | { | - |
998 | const QStandardItemPrivate * const d = d_func(); | - |
999 | int index = d->childIndex(row, column); | - |
1000 | if (index == -1) evaluated: index == -1 yes Evaluation Count:5 | yes Evaluation Count:25135100 |
| 5-25135100 |
1001 | return 0; executed: return 0; Execution Count:5 | 5 |
1002 | return d->children.at(index); executed: return d->children.at(index); Execution Count:25135100 | 25135100 |
1003 | } | - |
1004 | QStandardItem *QStandardItem::takeChild(int row, int column) | - |
1005 | { | - |
1006 | QStandardItemPrivate * const d = d_func(); | - |
1007 | QStandardItem *item = 0; | - |
1008 | int index = d->childIndex(row, column); | - |
1009 | if (index != -1) { partially evaluated: index != -1 yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-21 |
1010 | item = d->children.at(index); | - |
1011 | if (item) evaluated: item yes Evaluation Count:11 | yes Evaluation Count:10 |
| 10-11 |
1012 | item->d_func()->setParentAndModel(0, 0); executed: item->d_func()->setParentAndModel(0, 0); Execution Count:11 | 11 |
1013 | d->children.replace(index, 0); | - |
1014 | } executed: } Execution Count:21 | 21 |
1015 | return item; executed: return item; Execution Count:21 | 21 |
1016 | } | - |
1017 | QList<QStandardItem*> QStandardItem::takeRow(int row) | - |
1018 | { | - |
1019 | QStandardItemPrivate * const d = d_func(); | - |
1020 | 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 |
1021 | return QList<QStandardItem*>(); executed: return QList<QStandardItem*>(); Execution Count:7 | 7 |
1022 | if (d->model) evaluated: d->model yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
1023 | d->model->d_func()->rowsAboutToBeRemoved(this, row, row); executed: d->model->d_func()->rowsAboutToBeRemoved(this, row, row); Execution Count:2 | 2 |
1024 | QList<QStandardItem*> items; | - |
1025 | int index = d->childIndex(row, 0); | - |
1026 | if (index != -1) { evaluated: index != -1 yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
1027 | int col_count = d->columnCount(); | - |
1028 | for (int column = 0; column < col_count; ++column) { evaluated: column < col_count yes Evaluation Count:27 | yes Evaluation Count:6 |
| 6-27 |
1029 | QStandardItem *ch = d->children.at(index + column); | - |
1030 | if (ch) partially evaluated: ch yes Evaluation Count:27 | no Evaluation Count:0 |
| 0-27 |
1031 | ch->d_func()->setParentAndModel(0, 0); executed: ch->d_func()->setParentAndModel(0, 0); Execution Count:27 | 27 |
1032 | items.append(ch); | - |
1033 | } executed: } Execution Count:27 | 27 |
1034 | d->children.remove(index, col_count); | - |
1035 | } executed: } Execution Count:6 | 6 |
1036 | d->rows--; | - |
1037 | if (d->model) evaluated: d->model yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
1038 | d->model->d_func()->rowsRemoved(this, row, 1); executed: d->model->d_func()->rowsRemoved(this, row, 1); Execution Count:2 | 2 |
1039 | return items; executed: return items; Execution Count:7 | 7 |
1040 | } | - |
1041 | QList<QStandardItem*> QStandardItem::takeColumn(int column) | - |
1042 | { | - |
1043 | QStandardItemPrivate * const d = d_func(); | - |
1044 | 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 |
1045 | return QList<QStandardItem*>(); executed: return QList<QStandardItem*>(); Execution Count:7 | 7 |
1046 | if (d->model) evaluated: d->model yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
1047 | d->model->d_func()->columnsAboutToBeRemoved(this, column, column); executed: d->model->d_func()->columnsAboutToBeRemoved(this, column, column); Execution Count:1 | 1 |
1048 | QList<QStandardItem*> items; | - |
1049 | | - |
1050 | for (int row = d->rowCount() - 1; row >= 0; --row) { evaluated: row >= 0 yes Evaluation Count:26 | yes Evaluation Count:6 |
| 6-26 |
1051 | int index = d->childIndex(row, column); | - |
1052 | QStandardItem *ch = d->children.at(index); | - |
1053 | if (ch) partially evaluated: ch yes Evaluation Count:26 | no Evaluation Count:0 |
| 0-26 |
1054 | ch->d_func()->setParentAndModel(0, 0); executed: ch->d_func()->setParentAndModel(0, 0); Execution Count:26 | 26 |
1055 | d->children.remove(index); | - |
1056 | items.prepend(ch); | - |
1057 | } executed: } Execution Count:26 | 26 |
1058 | d->columns--; | - |
1059 | if (d->model) evaluated: d->model yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
1060 | d->model->d_func()->columnsRemoved(this, column, 1); executed: d->model->d_func()->columnsRemoved(this, column, 1); Execution Count:1 | 1 |
1061 | return items; executed: return items; Execution Count:6 | 6 |
1062 | } | - |
1063 | bool QStandardItem::operator<(const QStandardItem &other) const | - |
1064 | { | - |
1065 | const int role = model() ? model()->sortRole() : Qt::DisplayRole; evaluated: model() yes Evaluation Count:5296 | yes Evaluation Count:14 |
| 14-5296 |
1066 | const QVariant l = data(role), r = other.data(role); | - |
1067 | | - |
1068 | switch (l.userType()) { | - |
1069 | case QVariant::Invalid: | - |
1070 | return (r.type() == QVariant::Invalid); executed: return (r.type() == QVariant::Invalid); Execution Count:2 | 2 |
1071 | case QVariant::Int: | - |
1072 | return l.toInt() < r.toInt(); executed: return l.toInt() < r.toInt(); Execution Count:26 | 26 |
1073 | case QVariant::UInt: | - |
1074 | return l.toUInt() < r.toUInt(); never executed: return l.toUInt() < r.toUInt(); | 0 |
1075 | case QVariant::LongLong: | - |
1076 | return l.toLongLong() < r.toLongLong(); never executed: return l.toLongLong() < r.toLongLong(); | 0 |
1077 | case QVariant::ULongLong: | - |
1078 | return l.toULongLong() < r.toULongLong(); never executed: return l.toULongLong() < r.toULongLong(); | 0 |
1079 | case QMetaType::Float: | - |
1080 | return l.toFloat() < r.toFloat(); never executed: return l.toFloat() < r.toFloat(); | 0 |
1081 | case QVariant::Double: | - |
1082 | return l.toDouble() < r.toDouble(); never executed: return l.toDouble() < r.toDouble(); | 0 |
1083 | case QVariant::Char: | - |
1084 | return l.toChar() < r.toChar(); never executed: return l.toChar() < r.toChar(); | 0 |
1085 | case QVariant::Date: | - |
1086 | return l.toDate() < r.toDate(); never executed: return l.toDate() < r.toDate(); | 0 |
1087 | case QVariant::Time: | - |
1088 | return l.toTime() < r.toTime(); never executed: return l.toTime() < r.toTime(); | 0 |
1089 | case QVariant::DateTime: | - |
1090 | return l.toDateTime() < r.toDateTime(); never executed: return l.toDateTime() < r.toDateTime(); | 0 |
1091 | case QVariant::String: | - |
1092 | default: | - |
1093 | return l.toString().compare(r.toString()) < 0; executed: return l.toString().compare(r.toString()) < 0; Execution Count:5282 | 5282 |
1094 | } | - |
1095 | } | 0 |
1096 | void QStandardItem::sortChildren(int column, Qt::SortOrder order) | - |
1097 | { | - |
1098 | QStandardItemPrivate * const d = d_func(); | - |
1099 | 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 |
1100 | return; executed: return; Execution Count:1 | 1 |
1101 | | - |
1102 | QList<QPersistentModelIndex> parents; | - |
1103 | if (d->model) { evaluated: d->model yes Evaluation Count:46 | yes Evaluation Count:3 |
| 3-46 |
1104 | parents << index(); | - |
1105 | d->model->layoutAboutToBeChanged(parents, QAbstractItemModel::VerticalSortHint); | - |
1106 | } executed: } Execution Count:46 | 46 |
1107 | d->sortChildren(column, order); | - |
1108 | if (d->model) evaluated: d->model yes Evaluation Count:46 | yes Evaluation Count:3 |
| 3-46 |
1109 | d->model->layoutChanged(parents, QAbstractItemModel::VerticalSortHint); executed: d->model->layoutChanged(parents, QAbstractItemModel::VerticalSortHint); Execution Count:46 | 46 |
1110 | } executed: } Execution Count:49 | 49 |
1111 | QStandardItem *QStandardItem::clone() const | - |
1112 | { | - |
1113 | return new QStandardItem(*this); executed: return new QStandardItem(*this); Execution Count:1 | 1 |
1114 | } | - |
1115 | int QStandardItem::type() const | - |
1116 | { | - |
1117 | return Type; never executed: return Type; | 0 |
1118 | } | - |
1119 | void QStandardItem::read(QDataStream &in) | - |
1120 | { | - |
1121 | QStandardItemPrivate * const d = d_func(); | - |
1122 | in >> d->values; | - |
1123 | qint32 flags; | - |
1124 | in >> flags; | - |
1125 | setFlags(Qt::ItemFlags(flags)); | - |
1126 | } executed: } Execution Count:1 | 1 |
1127 | | - |
1128 | | - |
1129 | | - |
1130 | | - |
1131 | | - |
1132 | | - |
1133 | | - |
1134 | void QStandardItem::write(QDataStream &out) const | - |
1135 | { | - |
1136 | const QStandardItemPrivate * const d = d_func(); | - |
1137 | out << d->values; | - |
1138 | out << flags(); | - |
1139 | } executed: } Execution Count:1 | 1 |
1140 | QDataStream &operator>>(QDataStream &in, QStandardItem &item) | - |
1141 | { | - |
1142 | item.read(in); | - |
1143 | return in; executed: return in; Execution Count:1 | 1 |
1144 | } | - |
1145 | QDataStream &operator<<(QDataStream &out, const QStandardItem &item) | - |
1146 | { | - |
1147 | item.write(out); | - |
1148 | return out; executed: return out; Execution Count:1 | 1 |
1149 | } | - |
1150 | QStandardItemModel::QStandardItemModel(QObject *parent) | - |
1151 | : QAbstractItemModel(*new QStandardItemModelPrivate, parent) | - |
1152 | { | - |
1153 | QStandardItemModelPrivate * const d = d_func(); | - |
1154 | d->init(); | - |
1155 | d->root->d_func()->setModel(this); | - |
1156 | } executed: } Execution Count:1022 | 1022 |
1157 | | - |
1158 | | - |
1159 | | - |
1160 | | - |
1161 | | - |
1162 | QStandardItemModel::QStandardItemModel(int rows, int columns, QObject *parent) | - |
1163 | : QAbstractItemModel(*new QStandardItemModelPrivate, parent) | - |
1164 | { | - |
1165 | QStandardItemModelPrivate * const d = d_func(); | - |
1166 | d->init(); | - |
1167 | d->root->insertColumns(0, columns); | - |
1168 | d->columnHeaderItems.insert(0, columns, 0); | - |
1169 | d->root->insertRows(0, rows); | - |
1170 | d->rowHeaderItems.insert(0, rows, 0); | - |
1171 | d->root->d_func()->setModel(this); | - |
1172 | } executed: } Execution Count:885 | 885 |
1173 | | - |
1174 | | - |
1175 | | - |
1176 | | - |
1177 | QStandardItemModel::QStandardItemModel(QStandardItemModelPrivate &dd, QObject *parent) | - |
1178 | : QAbstractItemModel(dd, parent) | - |
1179 | { | - |
1180 | QStandardItemModelPrivate * const d = d_func(); | - |
1181 | d->init(); | - |
1182 | } | 0 |
1183 | | - |
1184 | | - |
1185 | | - |
1186 | | - |
1187 | QStandardItemModel::~QStandardItemModel() | - |
1188 | { | - |
1189 | } | - |
1190 | | - |
1191 | | - |
1192 | | - |
1193 | | - |
1194 | void QStandardItemModel::setItemRoleNames(const QHash<int,QByteArray> &roleNames) | - |
1195 | { | - |
1196 | QStandardItemModelPrivate * const d = d_func(); | - |
1197 | d->roleNames = roleNames; | - |
1198 | } executed: } Execution Count:1 | 1 |
1199 | | - |
1200 | | - |
1201 | | - |
1202 | | - |
1203 | | - |
1204 | | - |
1205 | | - |
1206 | void QStandardItemModel::clear() | - |
1207 | { | - |
1208 | QStandardItemModelPrivate * const d = d_func(); | - |
1209 | beginResetModel(); | - |
1210 | d->root.reset(new QStandardItem); | - |
1211 | d->root->d_func()->setModel(this); | - |
1212 | qDeleteAll(d->columnHeaderItems); | - |
1213 | d->columnHeaderItems.clear(); | - |
1214 | qDeleteAll(d->rowHeaderItems); | - |
1215 | d->rowHeaderItems.clear(); | - |
1216 | endResetModel(); | - |
1217 | } executed: } Execution Count:541 | 541 |
1218 | QStandardItem *QStandardItemModel::itemFromIndex(const QModelIndex &index) const | - |
1219 | { | - |
1220 | const QStandardItemModelPrivate * const d = d_func(); | - |
1221 | 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 |
1222 | return 0; executed: return 0; Execution Count:14 | 14 |
1223 | QStandardItem *parent = static_cast<QStandardItem*>(index.internalPointer()); | - |
1224 | if (parent == 0) partially evaluated: parent == 0 no Evaluation Count:0 | yes Evaluation Count:6904474 |
| 0-6904474 |
1225 | return 0; never executed: return 0; | 0 |
1226 | QStandardItem *item = parent->child(index.row(), index.column()); | - |
1227 | | - |
1228 | if (item == 0) { evaluated: item == 0 yes Evaluation Count:3474639 | yes Evaluation Count:3429835 |
| 3429835-3474639 |
1229 | item = d->createItem(); | - |
1230 | parent->d_func()->setChild(index.row(), index.column(), item); | - |
1231 | } executed: } Execution Count:3474639 | 3474639 |
1232 | return item; executed: return item; Execution Count:6904474 | 6904474 |
1233 | } | - |
1234 | QModelIndex QStandardItemModel::indexFromItem(const QStandardItem *item) const | - |
1235 | { | - |
1236 | 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 |
1237 | QPair<int, int> pos = item->d_func()->position(); | - |
1238 | 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 |
1239 | } | - |
1240 | return QModelIndex(); executed: return QModelIndex(); Execution Count:446107 | 446107 |
1241 | } | - |
1242 | void QStandardItemModel::setRowCount(int rows) | - |
1243 | { | - |
1244 | QStandardItemModelPrivate * const d = d_func(); | - |
1245 | d->root->setRowCount(rows); | - |
1246 | } executed: } Execution Count:13095 | 13095 |
1247 | void QStandardItemModel::setColumnCount(int columns) | - |
1248 | { | - |
1249 | QStandardItemModelPrivate * const d = d_func(); | - |
1250 | d->root->setColumnCount(columns); | - |
1251 | } executed: } Execution Count:76 | 76 |
1252 | void QStandardItemModel::setItem(int row, int column, QStandardItem *item) | - |
1253 | { | - |
1254 | QStandardItemModelPrivate * const d = d_func(); | - |
1255 | d->root->d_func()->setChild(row, column, item, true); | - |
1256 | } executed: } Execution Count:1249 | 1249 |
1257 | QStandardItem *QStandardItemModel::item(int row, int column) const | - |
1258 | { | - |
1259 | const QStandardItemModelPrivate * const d = d_func(); | - |
1260 | return d->root->child(row, column); executed: return d->root->child(row, column); Execution Count:2945 | 2945 |
1261 | } | - |
1262 | QStandardItem *QStandardItemModel::invisibleRootItem() const | - |
1263 | { | - |
1264 | const QStandardItemModelPrivate * const d = d_func(); | - |
1265 | return d->root.data(); executed: return d->root.data(); Execution Count:1071 | 1071 |
1266 | } | - |
1267 | void QStandardItemModel::setHorizontalHeaderItem(int column, QStandardItem *item) | - |
1268 | { | - |
1269 | QStandardItemModelPrivate * const d = d_func(); | - |
1270 | if (column < 0) partially evaluated: column < 0 no Evaluation Count:0 | yes Evaluation Count:62 |
| 0-62 |
1271 | return; | 0 |
1272 | if (columnCount() <= column) evaluated: columnCount() <= column yes Evaluation Count:2 | yes Evaluation Count:60 |
| 2-60 |
1273 | setColumnCount(column + 1); executed: setColumnCount(column + 1); Execution Count:2 | 2 |
1274 | | - |
1275 | QStandardItem *oldItem = d->columnHeaderItems.at(column); | - |
1276 | if (item == oldItem) partially evaluated: item == oldItem no Evaluation Count:0 | yes Evaluation Count:62 |
| 0-62 |
1277 | return; | 0 |
1278 | | - |
1279 | if (item) { evaluated: item yes Evaluation Count:61 | yes Evaluation Count:1 |
| 1-61 |
1280 | if (item->model() == 0) { partially evaluated: item->model() == 0 yes Evaluation Count:61 | no Evaluation Count:0 |
| 0-61 |
1281 | item->d_func()->setModel(this); | - |
1282 | } else { executed: } Execution Count:61 | 61 |
1283 | QMessageLogger("itemmodels/qstandarditemmodel.cpp", 2292, __PRETTY_FUNCTION__).warning("QStandardItem::setHorizontalHeaderItem: Ignoring duplicate insertion of item %p", | - |
1284 | item); | - |
1285 | return; | 0 |
1286 | } | - |
1287 | } | - |
1288 | | - |
1289 | if (oldItem) evaluated: oldItem yes Evaluation Count:1 | yes Evaluation Count:61 |
| 1-61 |
1290 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0); Execution Count:1 | 1 |
1291 | delete oldItem; | - |
1292 | | - |
1293 | d->columnHeaderItems.replace(column, item); | - |
1294 | headerDataChanged(Qt::Horizontal, column, column); | - |
1295 | } executed: } Execution Count:62 | 62 |
1296 | QStandardItem *QStandardItemModel::horizontalHeaderItem(int column) const | - |
1297 | { | - |
1298 | const QStandardItemModelPrivate * const d = d_func(); | - |
1299 | 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 |
1300 | return 0; executed: return 0; Execution Count:1 | 1 |
1301 | return d->columnHeaderItems.at(column); executed: return d->columnHeaderItems.at(column); Execution Count:90 | 90 |
1302 | } | - |
1303 | void QStandardItemModel::setVerticalHeaderItem(int row, QStandardItem *item) | - |
1304 | { | - |
1305 | QStandardItemModelPrivate * const d = d_func(); | - |
1306 | if (row < 0) partially evaluated: row < 0 no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
1307 | return; | 0 |
1308 | if (rowCount() <= row) evaluated: rowCount() <= row yes Evaluation Count:2 | yes Evaluation Count:11 |
| 2-11 |
1309 | setRowCount(row + 1); executed: setRowCount(row + 1); Execution Count:2 | 2 |
1310 | | - |
1311 | QStandardItem *oldItem = d->rowHeaderItems.at(row); | - |
1312 | if (item == oldItem) partially evaluated: item == oldItem no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
1313 | return; | 0 |
1314 | | - |
1315 | if (item) { evaluated: item yes Evaluation Count:12 | yes Evaluation Count:1 |
| 1-12 |
1316 | if (item->model() == 0) { partially evaluated: item->model() == 0 yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
1317 | item->d_func()->setModel(this); | - |
1318 | } else { executed: } Execution Count:12 | 12 |
1319 | QMessageLogger("itemmodels/qstandarditemmodel.cpp", 2348, __PRETTY_FUNCTION__).warning("QStandardItem::setVerticalHeaderItem: Ignoring duplicate insertion of item %p", | - |
1320 | item); | - |
1321 | return; | 0 |
1322 | } | - |
1323 | } | - |
1324 | | - |
1325 | if (oldItem) evaluated: oldItem yes Evaluation Count:1 | yes Evaluation Count:12 |
| 1-12 |
1326 | oldItem->d_func()->setModel(0); executed: oldItem->d_func()->setModel(0); Execution Count:1 | 1 |
1327 | delete oldItem; | - |
1328 | | - |
1329 | d->rowHeaderItems.replace(row, item); | - |
1330 | headerDataChanged(Qt::Vertical, row, row); | - |
1331 | } executed: } Execution Count:13 | 13 |
1332 | QStandardItem *QStandardItemModel::verticalHeaderItem(int row) const | - |
1333 | { | - |
1334 | const QStandardItemModelPrivate * const d = d_func(); | - |
1335 | 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 |
1336 | return 0; executed: return 0; Execution Count:1 | 1 |
1337 | return d->rowHeaderItems.at(row); executed: return d->rowHeaderItems.at(row); Execution Count:12 | 12 |
1338 | } | - |
1339 | void QStandardItemModel::setHorizontalHeaderLabels(const QStringList &labels) | - |
1340 | { | - |
1341 | QStandardItemModelPrivate * const d = d_func(); | - |
1342 | if (columnCount() < labels.count()) evaluated: columnCount() < labels.count() yes Evaluation Count:10 | yes Evaluation Count:2 |
| 2-10 |
1343 | setColumnCount(labels.count()); executed: setColumnCount(labels.count()); Execution Count:10 | 10 |
1344 | for (int i = 0; i < labels.count(); ++i) { evaluated: i < labels.count() yes Evaluation Count:55 | yes Evaluation Count:12 |
| 12-55 |
1345 | QStandardItem *item = horizontalHeaderItem(i); | - |
1346 | if (!item) { partially evaluated: !item yes Evaluation Count:55 | no Evaluation Count:0 |
| 0-55 |
1347 | item = d->createItem(); | - |
1348 | setHorizontalHeaderItem(i, item); | - |
1349 | } executed: } Execution Count:55 | 55 |
1350 | item->setText(labels.at(i)); | - |
1351 | } executed: } Execution Count:55 | 55 |
1352 | } executed: } Execution Count:12 | 12 |
1353 | void QStandardItemModel::setVerticalHeaderLabels(const QStringList &labels) | - |
1354 | { | - |
1355 | QStandardItemModelPrivate * const d = d_func(); | - |
1356 | if (rowCount() < labels.count()) evaluated: rowCount() < labels.count() yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
1357 | setRowCount(labels.count()); executed: setRowCount(labels.count()); Execution Count:1 | 1 |
1358 | for (int i = 0; i < labels.count(); ++i) { evaluated: i < labels.count() yes Evaluation Count:10 | yes Evaluation Count:3 |
| 3-10 |
1359 | QStandardItem *item = verticalHeaderItem(i); | - |
1360 | if (!item) { partially evaluated: !item yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
1361 | item = d->createItem(); | - |
1362 | setVerticalHeaderItem(i, item); | - |
1363 | } executed: } Execution Count:10 | 10 |
1364 | item->setText(labels.at(i)); | - |
1365 | } executed: } Execution Count:10 | 10 |
1366 | } executed: } Execution Count:3 | 3 |
1367 | void QStandardItemModel::setItemPrototype(const QStandardItem *item) | - |
1368 | { | - |
1369 | QStandardItemModelPrivate * const d = d_func(); | - |
1370 | if (d->itemPrototype != item) { partially evaluated: d->itemPrototype != item yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1371 | delete d->itemPrototype; | - |
1372 | d->itemPrototype = item; | - |
1373 | } executed: } Execution Count:2 | 2 |
1374 | } executed: } Execution Count:2 | 2 |
1375 | const QStandardItem *QStandardItemModel::itemPrototype() const | - |
1376 | { | - |
1377 | const QStandardItemModelPrivate * const d = d_func(); | - |
1378 | return d->itemPrototype; executed: return d->itemPrototype; Execution Count:3 | 3 |
1379 | } | - |
1380 | | - |
1381 | | - |
1382 | | - |
1383 | | - |
1384 | | - |
1385 | | - |
1386 | | - |
1387 | QList<QStandardItem*> QStandardItemModel::findItems(const QString &text, | - |
1388 | Qt::MatchFlags flags, int column) const | - |
1389 | { | - |
1390 | QModelIndexList indexes = match(index(0, column, QModelIndex()), | - |
1391 | Qt::DisplayRole, text, -1, flags); | - |
1392 | QList<QStandardItem*> items; | - |
1393 | for (int i = 0; i < indexes.size(); ++i) evaluated: i < indexes.size() yes Evaluation Count:3 | yes Evaluation Count:5 |
| 3-5 |
1394 | items.append(itemFromIndex(indexes.at(i))); executed: items.append(itemFromIndex(indexes.at(i))); Execution Count:3 | 3 |
1395 | return items; executed: return items; Execution Count:5 | 5 |
1396 | } | - |
1397 | void QStandardItemModel::appendRow(const QList<QStandardItem*> &items) | - |
1398 | { | - |
1399 | invisibleRootItem()->appendRow(items); | - |
1400 | } executed: } Execution Count:382 | 382 |
1401 | void QStandardItemModel::appendColumn(const QList<QStandardItem*> &items) | - |
1402 | { | - |
1403 | invisibleRootItem()->appendColumn(items); | - |
1404 | } executed: } Execution Count:10 | 10 |
1405 | void QStandardItemModel::insertRow(int row, const QList<QStandardItem*> &items) | - |
1406 | { | - |
1407 | invisibleRootItem()->insertRow(row, items); | - |
1408 | } executed: } Execution Count:263 | 263 |
1409 | void QStandardItemModel::insertColumn(int column, const QList<QStandardItem*> &items) | - |
1410 | { | - |
1411 | invisibleRootItem()->insertColumn(column, items); | - |
1412 | } executed: } Execution Count:2 | 2 |
1413 | QStandardItem *QStandardItemModel::takeItem(int row, int column) | - |
1414 | { | - |
1415 | QStandardItemModelPrivate * const d = d_func(); | - |
1416 | return d->root->takeChild(row, column); executed: return d->root->takeChild(row, column); Execution Count:1 | 1 |
1417 | } | - |
1418 | QList<QStandardItem*> QStandardItemModel::takeRow(int row) | - |
1419 | { | - |
1420 | QStandardItemModelPrivate * const d = d_func(); | - |
1421 | return d->root->takeRow(row); executed: return d->root->takeRow(row); Execution Count:1 | 1 |
1422 | } | - |
1423 | QList<QStandardItem*> QStandardItemModel::takeColumn(int column) | - |
1424 | { | - |
1425 | QStandardItemModelPrivate * const d = d_func(); | - |
1426 | return d->root->takeColumn(column); executed: return d->root->takeColumn(column); Execution Count:1 | 1 |
1427 | } | - |
1428 | QStandardItem *QStandardItemModel::takeHorizontalHeaderItem(int column) | - |
1429 | { | - |
1430 | QStandardItemModelPrivate * const d = d_func(); | - |
1431 | 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 |
1432 | return 0; never executed: return 0; | 0 |
1433 | QStandardItem *headerItem = d->columnHeaderItems.at(column); | - |
1434 | if (headerItem) { evaluated: headerItem yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1435 | headerItem->d_func()->setParentAndModel(0, 0); | - |
1436 | d->columnHeaderItems.replace(column, 0); | - |
1437 | } executed: } Execution Count:1 | 1 |
1438 | return headerItem; executed: return headerItem; Execution Count:2 | 2 |
1439 | } | - |
1440 | QStandardItem *QStandardItemModel::takeVerticalHeaderItem(int row) | - |
1441 | { | - |
1442 | QStandardItemModelPrivate * const d = d_func(); | - |
1443 | 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 |
1444 | return 0; never executed: return 0; | 0 |
1445 | QStandardItem *headerItem = d->rowHeaderItems.at(row); | - |
1446 | if (headerItem) { evaluated: headerItem yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1447 | headerItem->d_func()->setParentAndModel(0, 0); | - |
1448 | d->rowHeaderItems.replace(row, 0); | - |
1449 | } executed: } Execution Count:1 | 1 |
1450 | return headerItem; executed: return headerItem; Execution Count:2 | 2 |
1451 | } | - |
1452 | int QStandardItemModel::sortRole() const | - |
1453 | { | - |
1454 | const QStandardItemModelPrivate * const d = d_func(); | - |
1455 | return d->sortRole; executed: return d->sortRole; Execution Count:5296 | 5296 |
1456 | } | - |
1457 | | - |
1458 | void QStandardItemModel::setSortRole(int role) | - |
1459 | { | - |
1460 | QStandardItemModelPrivate * const d = d_func(); | - |
1461 | d->sortRole = role; | - |
1462 | } executed: } Execution Count:2 | 2 |
1463 | | - |
1464 | | - |
1465 | | - |
1466 | | - |
1467 | int QStandardItemModel::columnCount(const QModelIndex &parent) const | - |
1468 | { | - |
1469 | const QStandardItemModelPrivate * const d = d_func(); | - |
1470 | QStandardItem *item = d->itemFromIndex(parent); | - |
1471 | return item ? item->columnCount() : 0; executed: return item ? item->columnCount() : 0; Execution Count:3617246 | 3617246 |
1472 | } | - |
1473 | | - |
1474 | | - |
1475 | | - |
1476 | | - |
1477 | QVariant QStandardItemModel::data(const QModelIndex &index, int role) const | - |
1478 | { | - |
1479 | const QStandardItemModelPrivate * const d = d_func(); | - |
1480 | QStandardItem *item = d->itemFromIndex(index); | - |
1481 | return item ? item->data(role) : QVariant(); executed: return item ? item->data(role) : QVariant(); Execution Count:1122113 | 1122113 |
1482 | } | - |
1483 | | - |
1484 | | - |
1485 | | - |
1486 | | - |
1487 | Qt::ItemFlags QStandardItemModel::flags(const QModelIndex &index) const | - |
1488 | { | - |
1489 | const QStandardItemModelPrivate * const d = d_func(); | - |
1490 | if (!d->indexValid(index)) evaluated: !d->indexValid(index) yes Evaluation Count:34 | yes Evaluation Count:19943 |
| 34-19943 |
1491 | return d->root->flags(); executed: return d->root->flags(); Execution Count:34 | 34 |
1492 | QStandardItem *item = d->itemFromIndex(index); | - |
1493 | if (item) evaluated: item yes Evaluation Count:17418 | yes Evaluation Count:2525 |
| 2525-17418 |
1494 | return item->flags(); executed: return item->flags(); Execution Count:17418 | 17418 |
1495 | return Qt::ItemIsSelectable | 2525 |
1496 | |Qt::ItemIsEnabled | 2525 |
1497 | |Qt::ItemIsEditable | 2525 |
1498 | |Qt::ItemIsDragEnabled | 2525 |
1499 | |Qt::ItemIsDropEnabled; executed: return Qt::ItemIsSelectable |Qt::ItemIsEnabled |Qt::ItemIsEditable |Qt::ItemIsDragEnabled |Qt::ItemIsDropEnabled; Execution Count:2525 | 2525 |
1500 | } | - |
1501 | | - |
1502 | | - |
1503 | | - |
1504 | | - |
1505 | bool QStandardItemModel::hasChildren(const QModelIndex &parent) const | - |
1506 | { | - |
1507 | const QStandardItemModelPrivate * const d = d_func(); | - |
1508 | QStandardItem *item = d->itemFromIndex(parent); | - |
1509 | return item ? item->hasChildren() : false; executed: return item ? item->hasChildren() : false; Execution Count:15226 | 15226 |
1510 | } | - |
1511 | | - |
1512 | | - |
1513 | | - |
1514 | | - |
1515 | QModelIndex QStandardItemModel::sibling(int row, int column, const QModelIndex &idx) const | - |
1516 | { | - |
1517 | return createIndex(row, column, idx.internalPointer()); executed: return createIndex(row, column, idx.internalPointer()); Execution Count:25982 | 25982 |
1518 | } | - |
1519 | | - |
1520 | | - |
1521 | | - |
1522 | | - |
1523 | QVariant QStandardItemModel::headerData(int section, Qt::Orientation orientation, int role) const | - |
1524 | { | - |
1525 | const QStandardItemModelPrivate * const d = d_func(); | - |
1526 | if ((section < 0) evaluated: (section < 0) yes Evaluation Count:4 | yes Evaluation Count:61026 |
| 4-61026 |
1527 | || ((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 |
1528 | || ((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 |
1529 | return QVariant(); executed: return QVariant(); Execution Count:489 | 489 |
1530 | } | - |
1531 | QStandardItem *headerItem = 0; | - |
1532 | if (orientation == Qt::Horizontal) evaluated: orientation == Qt::Horizontal yes Evaluation Count:17497 | yes Evaluation Count:43044 |
| 17497-43044 |
1533 | headerItem = d->columnHeaderItems.at(section); executed: headerItem = d->columnHeaderItems.at(section); Execution Count:17497 | 17497 |
1534 | else if (orientation == Qt::Vertical) partially evaluated: orientation == Qt::Vertical yes Evaluation Count:43044 | no Evaluation Count:0 |
| 0-43044 |
1535 | headerItem = d->rowHeaderItems.at(section); executed: headerItem = d->rowHeaderItems.at(section); Execution Count:43044 | 43044 |
1536 | return headerItem ? headerItem->data(role) | 60541 |
1537 | : QAbstractItemModel::headerData(section, orientation, role); executed: return headerItem ? headerItem->data(role) : QAbstractItemModel::headerData(section, orientation, role); Execution Count:60541 | 60541 |
1538 | } | - |
1539 | | - |
1540 | | - |
1541 | | - |
1542 | | - |
1543 | | - |
1544 | | - |
1545 | Qt::DropActions QStandardItemModel::supportedDropActions () const | - |
1546 | { | - |
1547 | return Qt::CopyAction | Qt::MoveAction; executed: return Qt::CopyAction | Qt::MoveAction; Execution Count:31 | 31 |
1548 | } | - |
1549 | | - |
1550 | | - |
1551 | | - |
1552 | | - |
1553 | QModelIndex QStandardItemModel::index(int row, int column, const QModelIndex &parent) const | - |
1554 | { | - |
1555 | const QStandardItemModelPrivate * const d = d_func(); | - |
1556 | QStandardItem *parentItem = d->itemFromIndex(parent); | - |
1557 | if ((parentItem == 0) evaluated: (parentItem == 0) yes Evaluation Count:27 | yes Evaluation Count:10859323 |
| 27-10859323 |
1558 | || (row < 0) evaluated: (row < 0) yes Evaluation Count:1773 | yes Evaluation Count:10857550 |
| 1773-10857550 |
1559 | || (column < 0) evaluated: (column < 0) yes Evaluation Count:198 | yes Evaluation Count:10857352 |
| 198-10857352 |
1560 | || (row >= parentItem->rowCount()) evaluated: (row >= parentItem->rowCount()) yes Evaluation Count:416 | yes Evaluation Count:10856936 |
| 416-10856936 |
1561 | || (column >= parentItem->columnCount())) { evaluated: (column >= parentItem->columnCount()) yes Evaluation Count:3705 | yes Evaluation Count:10853231 |
| 3705-10853231 |
1562 | return QModelIndex(); executed: return QModelIndex(); Execution Count:6119 | 6119 |
1563 | } | - |
1564 | return createIndex(row, column, parentItem); executed: return createIndex(row, column, parentItem); Execution Count:10853231 | 10853231 |
1565 | } | - |
1566 | | - |
1567 | | - |
1568 | | - |
1569 | | - |
1570 | bool QStandardItemModel::insertColumns(int column, int count, const QModelIndex &parent) | - |
1571 | { | - |
1572 | QStandardItemModelPrivate * const d = d_func(); | - |
1573 | QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data(); evaluated: parent.isValid() yes Evaluation Count:6353 | yes Evaluation Count:898 |
| 898-6353 |
1574 | if (item == 0) partially evaluated: item == 0 no Evaluation Count:0 | yes Evaluation Count:7251 |
| 0-7251 |
1575 | return false; never executed: return false; | 0 |
1576 | return item->d_func()->insertColumns(column, count, QList<QStandardItem*>()); executed: return item->d_func()->insertColumns(column, count, QList<QStandardItem*>()); Execution Count:7251 | 7251 |
1577 | } | - |
1578 | | - |
1579 | | - |
1580 | | - |
1581 | | - |
1582 | bool QStandardItemModel::insertRows(int row, int count, const QModelIndex &parent) | - |
1583 | { | - |
1584 | QStandardItemModelPrivate * const d = d_func(); | - |
1585 | QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data(); evaluated: parent.isValid() yes Evaluation Count:6362 | yes Evaluation Count:1467 |
| 1467-6362 |
1586 | if (item == 0) partially evaluated: item == 0 no Evaluation Count:0 | yes Evaluation Count:7829 |
| 0-7829 |
1587 | return false; never executed: return false; | 0 |
1588 | return item->d_func()->insertRows(row, count, QList<QStandardItem*>()); executed: return item->d_func()->insertRows(row, count, QList<QStandardItem*>()); Execution Count:7829 | 7829 |
1589 | } | - |
1590 | | - |
1591 | | - |
1592 | | - |
1593 | | - |
1594 | QMap<int, QVariant> QStandardItemModel::itemData(const QModelIndex &index) const | - |
1595 | { | - |
1596 | const QStandardItemModelPrivate * const d = d_func(); | - |
1597 | QStandardItem *item = d->itemFromIndex(index); | - |
1598 | return item ? item->d_func()->itemData() : QMap<int, QVariant>(); executed: return item ? item->d_func()->itemData() : QMap<int, QVariant>(); Execution Count:32 | 32 |
1599 | } | - |
1600 | | - |
1601 | | - |
1602 | | - |
1603 | | - |
1604 | QModelIndex QStandardItemModel::parent(const QModelIndex &child) const | - |
1605 | { | - |
1606 | const QStandardItemModelPrivate * const d = d_func(); | - |
1607 | if (!d->indexValid(child)) evaluated: !d->indexValid(child) yes Evaluation Count:50 | yes Evaluation Count:7099450 |
| 50-7099450 |
1608 | return QModelIndex(); executed: return QModelIndex(); Execution Count:50 | 50 |
1609 | QStandardItem *parentItem = static_cast<QStandardItem*>(child.internalPointer()); | - |
1610 | return indexFromItem(parentItem); executed: return indexFromItem(parentItem); Execution Count:7099450 | 7099450 |
1611 | } | - |
1612 | | - |
1613 | | - |
1614 | | - |
1615 | | - |
1616 | bool QStandardItemModel::removeColumns(int column, int count, const QModelIndex &parent) | - |
1617 | { | - |
1618 | QStandardItemModelPrivate * const d = d_func(); | - |
1619 | QStandardItem *item = d->itemFromIndex(parent); | - |
1620 | 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 |
1621 | return false; executed: return false; Execution Count:30 | 30 |
1622 | item->removeColumns(column, count); | - |
1623 | return true; executed: return true; Execution Count:63 | 63 |
1624 | } | - |
1625 | | - |
1626 | | - |
1627 | | - |
1628 | | - |
1629 | bool QStandardItemModel::removeRows(int row, int count, const QModelIndex &parent) | - |
1630 | { | - |
1631 | QStandardItemModelPrivate * const d = d_func(); | - |
1632 | QStandardItem *item = d->itemFromIndex(parent); | - |
1633 | 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 |
1634 | return false; executed: return false; Execution Count:606 | 606 |
1635 | item->removeRows(row, count); | - |
1636 | return true; executed: return true; Execution Count:430 | 430 |
1637 | } | - |
1638 | | - |
1639 | | - |
1640 | | - |
1641 | | - |
1642 | int QStandardItemModel::rowCount(const QModelIndex &parent) const | - |
1643 | { | - |
1644 | const QStandardItemModelPrivate * const d = d_func(); | - |
1645 | QStandardItem *item = d->itemFromIndex(parent); | - |
1646 | return item ? item->rowCount() : 0; executed: return item ? item->rowCount() : 0; Execution Count:293564 | 293564 |
1647 | } | - |
1648 | | - |
1649 | | - |
1650 | | - |
1651 | | - |
1652 | bool QStandardItemModel::setData(const QModelIndex &index, const QVariant &value, int role) | - |
1653 | { | - |
1654 | if (!index.isValid()) evaluated: !index.isValid() yes Evaluation Count:66 | yes Evaluation Count:6886257 |
| 66-6886257 |
1655 | return false; executed: return false; Execution Count:66 | 66 |
1656 | QStandardItem *item = itemFromIndex(index); | - |
1657 | if (item == 0) partially evaluated: item == 0 no Evaluation Count:0 | yes Evaluation Count:6886257 |
| 0-6886257 |
1658 | return false; never executed: return false; | 0 |
1659 | item->setData(value, role); | - |
1660 | return true; executed: return true; Execution Count:6886257 | 6886257 |
1661 | } | - |
1662 | | - |
1663 | | - |
1664 | | - |
1665 | | - |
1666 | bool QStandardItemModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) | - |
1667 | { | - |
1668 | QStandardItemModelPrivate * const d = d_func(); | - |
1669 | if ((section < 0) evaluated: (section < 0) yes Evaluation Count:55 | yes Evaluation Count:82 |
| 55-82 |
1670 | || ((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 |
1671 | || ((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 |
1672 | return false; executed: return false; Execution Count:73 | 73 |
1673 | } | - |
1674 | QStandardItem *headerItem = 0; | - |
1675 | if (orientation == Qt::Horizontal) { evaluated: orientation == Qt::Horizontal yes Evaluation Count:43 | yes Evaluation Count:21 |
| 21-43 |
1676 | headerItem = d->columnHeaderItems.at(section); | - |
1677 | if (headerItem == 0) { evaluated: headerItem == 0 yes Evaluation Count:40 | yes Evaluation Count:3 |
| 3-40 |
1678 | headerItem = d->createItem(); | - |
1679 | headerItem->d_func()->setModel(this); | - |
1680 | d->columnHeaderItems.replace(section, headerItem); | - |
1681 | } executed: } Execution Count:40 | 40 |
1682 | } else if (orientation == Qt::Vertical) { executed: } Execution Count:43 partially evaluated: orientation == Qt::Vertical yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-43 |
1683 | headerItem = d->rowHeaderItems.at(section); | - |
1684 | if (headerItem == 0) { evaluated: headerItem == 0 yes Evaluation Count:18 | yes Evaluation Count:3 |
| 3-18 |
1685 | headerItem = d->createItem(); | - |
1686 | headerItem->d_func()->setModel(this); | - |
1687 | d->rowHeaderItems.replace(section, headerItem); | - |
1688 | } executed: } Execution Count:18 | 18 |
1689 | } executed: } Execution Count:21 | 21 |
1690 | if (headerItem) { partially evaluated: headerItem yes Evaluation Count:64 | no Evaluation Count:0 |
| 0-64 |
1691 | headerItem->setData(value, role); | - |
1692 | return true; executed: return true; Execution Count:64 | 64 |
1693 | } | - |
1694 | return false; never executed: return false; | 0 |
1695 | } | - |
1696 | | - |
1697 | | - |
1698 | | - |
1699 | | - |
1700 | bool QStandardItemModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) | - |
1701 | { | - |
1702 | QStandardItem *item = itemFromIndex(index); | - |
1703 | if (item == 0) evaluated: item == 0 yes Evaluation Count:5 | yes Evaluation Count:2 |
| 2-5 |
1704 | return false; executed: return false; Execution Count:5 | 5 |
1705 | item->d_func()->setItemData(roles); | - |
1706 | return true; executed: return true; Execution Count:2 | 2 |
1707 | } | - |
1708 | | - |
1709 | | - |
1710 | | - |
1711 | | - |
1712 | void QStandardItemModel::sort(int column, Qt::SortOrder order) | - |
1713 | { | - |
1714 | QStandardItemModelPrivate * const d = d_func(); | - |
1715 | d->root->sortChildren(column, order); | - |
1716 | } executed: } Execution Count:41 | 41 |
1717 | QStringList QStandardItemModel::mimeTypes() const | - |
1718 | { | - |
1719 | return QAbstractItemModel::mimeTypes() << QLatin1String("application/x-qstandarditemmodeldatalist"); executed: return QAbstractItemModel::mimeTypes() << QLatin1String("application/x-qstandarditemmodeldatalist"); Execution Count:31 | 31 |
1720 | } | - |
1721 | | - |
1722 | | - |
1723 | | - |
1724 | | - |
1725 | QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const | - |
1726 | { | - |
1727 | QMimeData *data = QAbstractItemModel::mimeData(indexes); | - |
1728 | if(!data) | 0 |
1729 | return 0; never executed: return 0; | 0 |
1730 | | - |
1731 | QString format = QLatin1String("application/x-qstandarditemmodeldatalist"); | - |
1732 | if (!mimeTypes().contains(format)) never evaluated: !mimeTypes().contains(format) | 0 |
1733 | return data; never executed: return data; | 0 |
1734 | QByteArray encoded; | - |
1735 | QDataStream stream(&encoded, QIODevice::WriteOnly); | - |
1736 | | - |
1737 | QSet<QStandardItem*> itemsSet; | - |
1738 | QStack<QStandardItem*> stack; | - |
1739 | itemsSet.reserve(indexes.count()); | - |
1740 | stack.reserve(indexes.count()); | - |
1741 | for (int i = 0; i < indexes.count(); ++i) { never evaluated: i < indexes.count() | 0 |
1742 | QStandardItem *item = itemFromIndex(indexes.at(i)); | - |
1743 | itemsSet << item; | - |
1744 | stack.push(item); | - |
1745 | } | 0 |
1746 | | - |
1747 | | - |
1748 | { | - |
1749 | QSet<QStandardItem *> seen; | - |
1750 | while (!stack.isEmpty()) { never evaluated: !stack.isEmpty() | 0 |
1751 | QStandardItem *itm = stack.pop(); | - |
1752 | if (seen.contains(itm)) never evaluated: seen.contains(itm) | 0 |
1753 | continue; never executed: continue; | 0 |
1754 | seen.insert(itm); | - |
1755 | | - |
1756 | const QVector<QStandardItem*> &childList = itm->d_func()->children; | - |
1757 | for (int i = 0; i < childList.count(); ++i) { never evaluated: i < childList.count() | 0 |
1758 | QStandardItem *chi = childList.at(i); | - |
1759 | if (chi) { | 0 |
1760 | QSet<QStandardItem *>::iterator it = itemsSet.find(chi); | - |
1761 | if (it != itemsSet.end()) { never evaluated: it != itemsSet.end() | 0 |
1762 | itemsSet.erase(it); | - |
1763 | } | 0 |
1764 | stack.push(chi); | - |
1765 | } | 0 |
1766 | } | 0 |
1767 | } | 0 |
1768 | } | - |
1769 | | - |
1770 | stack.reserve(itemsSet.count()); | - |
1771 | 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;})) { | - |
1772 | stack.push(item); | - |
1773 | } | 0 |
1774 | | - |
1775 | | - |
1776 | while (!stack.isEmpty()) { never evaluated: !stack.isEmpty() | 0 |
1777 | QStandardItem *item = stack.pop(); | - |
1778 | if(itemsSet.contains(item)) { never evaluated: itemsSet.contains(item) | 0 |
1779 | stream << item->row() << item->column(); | - |
1780 | } | 0 |
1781 | if(item) { | 0 |
1782 | stream << *item << item->columnCount() << item->d_ptr->children.count(); | - |
1783 | stack += item->d_ptr->children; | - |
1784 | } else { | 0 |
1785 | QStandardItem dummy; | - |
1786 | stream << dummy << 0 << 0; | - |
1787 | } | 0 |
1788 | } | - |
1789 | | - |
1790 | data->setData(format, encoded); | - |
1791 | return data; never executed: return data; | 0 |
1792 | } | - |
1793 | | - |
1794 | | - |
1795 | | - |
1796 | | - |
1797 | | - |
1798 | | - |
1799 | void QStandardItemModelPrivate::decodeDataRecursive(QDataStream &stream, QStandardItem *item) | - |
1800 | { | - |
1801 | int colCount, childCount; | - |
1802 | stream >> *item; | - |
1803 | stream >> colCount >> childCount; | - |
1804 | item->setColumnCount(colCount); | - |
1805 | | - |
1806 | int childPos = childCount; | - |
1807 | | - |
1808 | while(childPos > 0) { never evaluated: childPos > 0 | 0 |
1809 | childPos--; | - |
1810 | QStandardItem *child = createItem(); | - |
1811 | decodeDataRecursive(stream, child); | - |
1812 | item->setChild( childPos / colCount, childPos % colCount, child); | - |
1813 | } | 0 |
1814 | } | 0 |
1815 | | - |
1816 | | - |
1817 | | - |
1818 | | - |
1819 | | - |
1820 | bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action, | - |
1821 | int row, int column, const QModelIndex &parent) | - |
1822 | { | - |
1823 | QStandardItemModelPrivate * const d = d_func(); | - |
1824 | | - |
1825 | if (!data || !(action == Qt::CopyAction || action == Qt::MoveAction)) never evaluated: action == Qt::CopyAction never evaluated: action == Qt::MoveAction | 0 |
1826 | return false; never executed: return false; | 0 |
1827 | | - |
1828 | QString format = QLatin1String("application/x-qstandarditemmodeldatalist"); | - |
1829 | if (!data->hasFormat(format)) never evaluated: !data->hasFormat(format) | 0 |
1830 | return QAbstractItemModel::dropMimeData(data, action, row, column, parent); never executed: return QAbstractItemModel::dropMimeData(data, action, row, column, parent); | 0 |
1831 | | - |
1832 | if (row > rowCount(parent)) never evaluated: row > rowCount(parent) | 0 |
1833 | row = rowCount(parent); never executed: row = rowCount(parent); | 0 |
1834 | if (row == -1) never evaluated: row == -1 | 0 |
1835 | row = rowCount(parent); never executed: row = rowCount(parent); | 0 |
1836 | if (column == -1) never evaluated: column == -1 | 0 |
1837 | column = 0; never executed: column = 0; | 0 |
1838 | | - |
1839 | | - |
1840 | QByteArray encoded = data->data(format); | - |
1841 | QDataStream stream(&encoded, QIODevice::ReadOnly); | - |
1842 | | - |
1843 | | - |
1844 | | - |
1845 | | - |
1846 | int top = 2147483647; | - |
1847 | int left = 2147483647; | - |
1848 | int bottom = 0; | - |
1849 | int right = 0; | - |
1850 | QVector<int> rows, columns; | - |
1851 | QVector<QStandardItem *> items; | - |
1852 | | - |
1853 | while (!stream.atEnd()) { never evaluated: !stream.atEnd() | 0 |
1854 | int r, c; | - |
1855 | QStandardItem *item = d->createItem(); | - |
1856 | stream >> r >> c; | - |
1857 | d->decodeDataRecursive(stream, item); | - |
1858 | | - |
1859 | rows.append(r); | - |
1860 | columns.append(c); | - |
1861 | items.append(item); | - |
1862 | top = qMin(r, top); | - |
1863 | left = qMin(c, left); | - |
1864 | bottom = qMax(r, bottom); | - |
1865 | right = qMax(c, right); | - |
1866 | } | 0 |
1867 | | - |
1868 | | - |
1869 | | - |
1870 | int dragRowCount = 0; | - |
1871 | int dragColumnCount = right - left + 1; | - |
1872 | | - |
1873 | | - |
1874 | QVector<int> rowsToInsert(bottom + 1); | - |
1875 | for (int i = 0; i < rows.count(); ++i) never evaluated: i < rows.count() | 0 |
1876 | rowsToInsert[rows.at(i)] = 1; never executed: rowsToInsert[rows.at(i)] = 1; | 0 |
1877 | for (int i = 0; i < rowsToInsert.count(); ++i) { never evaluated: i < rowsToInsert.count() | 0 |
1878 | if (rowsToInsert[i] == 1){ never evaluated: rowsToInsert[i] == 1 | 0 |
1879 | rowsToInsert[i] = dragRowCount; | - |
1880 | ++dragRowCount; | - |
1881 | } | 0 |
1882 | } | 0 |
1883 | for (int i = 0; i < rows.count(); ++i) never evaluated: i < rows.count() | 0 |
1884 | rows[i] = top + rowsToInsert[rows[i]]; never executed: rows[i] = top + rowsToInsert[rows[i]]; | 0 |
1885 | | - |
1886 | QBitArray isWrittenTo(dragRowCount * dragColumnCount); | - |
1887 | | - |
1888 | | - |
1889 | int colCount = columnCount(parent); | - |
1890 | if (colCount < dragColumnCount + column) { never evaluated: colCount < dragColumnCount + column | 0 |
1891 | insertColumns(colCount, dragColumnCount + column - colCount, parent); | - |
1892 | colCount = columnCount(parent); | - |
1893 | } | 0 |
1894 | insertRows(row, dragRowCount, parent); | - |
1895 | | - |
1896 | row = qMax(0, row); | - |
1897 | column = qMax(0, column); | - |
1898 | | - |
1899 | QStandardItem *parentItem = itemFromIndex (parent); | - |
1900 | if (!parentItem) never evaluated: !parentItem | 0 |
1901 | parentItem = invisibleRootItem(); never executed: parentItem = invisibleRootItem(); | 0 |
1902 | | - |
1903 | QVector<QPersistentModelIndex> newIndexes(items.size()); | - |
1904 | | - |
1905 | for (int j = 0; j < items.size(); ++j) { never evaluated: j < items.size() | 0 |
1906 | int relativeRow = rows.at(j) - top; | - |
1907 | int relativeColumn = columns.at(j) - left; | - |
1908 | int destinationRow = relativeRow + row; | - |
1909 | int destinationColumn = relativeColumn + column; | - |
1910 | int flat = (relativeRow * dragColumnCount) + relativeColumn; | - |
1911 | | - |
1912 | if (destinationColumn >= colCount || isWrittenTo.testBit(flat)) { never evaluated: destinationColumn >= colCount never evaluated: isWrittenTo.testBit(flat) | 0 |
1913 | destinationColumn = qBound(column, destinationColumn, colCount - 1); | - |
1914 | destinationRow = row + dragRowCount; | - |
1915 | insertRows(row + dragRowCount, 1, parent); | - |
1916 | flat = (dragRowCount * dragColumnCount) + relativeColumn; | - |
1917 | isWrittenTo.resize(++dragRowCount * dragColumnCount); | - |
1918 | } | 0 |
1919 | if (!isWrittenTo.testBit(flat)) { never evaluated: !isWrittenTo.testBit(flat) | 0 |
1920 | newIndexes[j] = index(destinationRow, destinationColumn, parentItem->index()); | - |
1921 | isWrittenTo.setBit(flat); | - |
1922 | } | 0 |
1923 | } | 0 |
1924 | | - |
1925 | for(int k = 0; k < newIndexes.size(); k++) { never evaluated: k < newIndexes.size() | 0 |
1926 | if (newIndexes.at(k).isValid()) { never evaluated: newIndexes.at(k).isValid() | 0 |
1927 | parentItem->setChild(newIndexes.at(k).row(), newIndexes.at(k).column(), items.at(k)); | - |
1928 | } else { | 0 |
1929 | delete items.at(k); | - |
1930 | } | 0 |
1931 | } | - |
1932 | | - |
1933 | return true; never executed: return true; | 0 |
1934 | } | - |
1935 | | - |
1936 | | - |
1937 | | - |
1938 | | - |
| | |