itemviews/qtreewidgetitemiterator.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include <private/qtreewidgetitemiterator_p.h> -
43#include "qtreewidget.h" -
44#include "qtreewidget_p.h" -
45#include "qwidgetitemdata_p.h" -
46 -
47#ifndef QT_NO_TREEWIDGET -
48 -
49QT_BEGIN_NAMESPACE -
50 -
51/*! -
52 \class QTreeWidgetItemIterator -
53 \ingroup model-view -
54 \inmodule QtWidgets -
55 -
56 \brief The QTreeWidgetItemIterator class provides a way to iterate over the -
57 items in a QTreeWidget instance. -
58 -
59 The iterator will walk the items in a pre-order traversal order, thus visiting the -
60 parent node \e before it continues to the child nodes. -
61 -
62 For example, the following code examples each item in a tree, checking the -
63 text in the first column against a user-specified search string: -
64 -
65 \snippet qtreewidgetitemiterator-using/mainwindow.cpp 0 -
66 -
67 It is also possible to filter out certain types of node by passing certain -
68 \l{IteratorFlag}{flags} to the constructor of QTreeWidgetItemIterator. -
69 -
70 \sa QTreeWidget, {Model/View Programming}, QTreeWidgetItem -
71*/ -
72 -
73/*! -
74 Constructs an iterator for the same QTreeWidget as \a it. The -
75 current iterator item is set to point on the current item of \a it. -
76*/ -
77 -
78QTreeWidgetItemIterator::QTreeWidgetItemIterator(const QTreeWidgetItemIterator &it) -
79 : d_ptr(new QTreeWidgetItemIteratorPrivate(*(it.d_ptr))), -
80 current(it.current), flags(it.flags) -
81{ -
82 Q_D(QTreeWidgetItemIterator);
executed (the execution status of this line is deduced): QTreeWidgetItemIteratorPrivate * const d = d_func();
-
83 Q_ASSERT(d->m_model);
executed (the execution status of this line is deduced): qt_noop();
-
84 d->m_model->iterators.append(this);
executed (the execution status of this line is deduced): d->m_model->iterators.append(this);
-
85}
executed: }
Execution Count:56
56
86 -
87/*! -
88 Constructs an iterator for the given \a widget that uses the specified \a flags -
89 to determine which items are found during iteration. -
90 The iterator is set to point to the first top-level item contained in the widget, -
91 or the next matching item if the top-level item doesn't match the flags. -
92 -
93 \sa QTreeWidgetItemIterator::IteratorFlag -
94*/ -
95 -
96QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidget *widget, IteratorFlags flags) -
97: current(0), flags(flags) -
98{ -
99 Q_ASSERT(widget);
executed (the execution status of this line is deduced): qt_noop();
-
100 QTreeModel *model = qobject_cast<QTreeModel*>(widget->model());
executed (the execution status of this line is deduced): QTreeModel *model = qobject_cast<QTreeModel*>(widget->model());
-
101 Q_ASSERT(model);
executed (the execution status of this line is deduced): qt_noop();
-
102 d_ptr.reset(new QTreeWidgetItemIteratorPrivate(this, model));
executed (the execution status of this line is deduced): d_ptr.reset(new QTreeWidgetItemIteratorPrivate(this, model));
-
103 model->iterators.append(this);
executed (the execution status of this line is deduced): model->iterators.append(this);
-
104 if (!model->rootItem->children.isEmpty()) current = model->rootItem->children.first();
executed: current = model->rootItem->children.first();
Execution Count:97
evaluated: !model->rootItem->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:1
1-97
105 if (current && !matchesFlags(current))
evaluated: current
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:1
evaluated: !matchesFlags(current)
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:82
1-97
106 ++(*this);
executed: ++(*this);
Execution Count:15
15
107}
executed: }
Execution Count:98
98
108 -
109/*! -
110 Constructs an iterator for the given \a item that uses the specified \a flags -
111 to determine which items are found during iteration. -
112 The iterator is set to point to \a item, or the next matching item if \a item -
113 doesn't match the flags. -
114 -
115 \sa QTreeWidgetItemIterator::IteratorFlag -
116*/ -
117 -
118QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidgetItem *item, IteratorFlags flags) -
119 : d_ptr(new QTreeWidgetItemIteratorPrivate( -
120 this, qobject_cast<QTreeModel*>(item->view->model()))), -
121 current(item), flags(flags) -
122{ -
123 Q_D(QTreeWidgetItemIterator);
executed (the execution status of this line is deduced): QTreeWidgetItemIteratorPrivate * const d = d_func();
-
124 Q_ASSERT(item);
executed (the execution status of this line is deduced): qt_noop();
-
125 QTreeModel *model = qobject_cast<QTreeModel*>(item->view->model());
executed (the execution status of this line is deduced): QTreeModel *model = qobject_cast<QTreeModel*>(item->view->model());
-
126 Q_ASSERT(model);
executed (the execution status of this line is deduced): qt_noop();
-
127 model->iterators.append(this);
executed (the execution status of this line is deduced): model->iterators.append(this);
-
128 -
129 // Initialize m_currentIndex and m_parentIndex as it would be if we had traversed from -
130 // the beginning. -
131 QTreeWidgetItem *parent = item;
executed (the execution status of this line is deduced): QTreeWidgetItem *parent = item;
-
132 parent = parent->parent();
executed (the execution status of this line is deduced): parent = parent->parent();
-
133 QList<QTreeWidgetItem *> children = parent ? parent->children : d->m_model->rootItem->children;
evaluated: parent
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:20
18-20
134 d->m_currentIndex = children.indexOf(item);
executed (the execution status of this line is deduced): d->m_currentIndex = children.indexOf(item);
-
135 -
136 while (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:38
18-38
137 QTreeWidgetItem *itm = parent;
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = parent;
-
138 parent = parent->parent();
executed (the execution status of this line is deduced): parent = parent->parent();
-
139 QList<QTreeWidgetItem *> children = parent ? parent->children : d->m_model->rootItem->children;
partially evaluated: parent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
140 int index = children.indexOf(itm);
executed (the execution status of this line is deduced): int index = children.indexOf(itm);
-
141 d->m_parentIndex.prepend(index);
executed (the execution status of this line is deduced): d->m_parentIndex.prepend(index);
-
142 }
executed: }
Execution Count:18
18
143 -
144 if (current && !matchesFlags(current))
partially evaluated: current
TRUEFALSE
yes
Evaluation Count:38
no
Evaluation Count:0
evaluated: !matchesFlags(current)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:37
0-38
145 ++(*this);
executed: ++(*this);
Execution Count:1
1
146}
executed: }
Execution Count:38
38
147 -
148/*! -
149 Destroys the iterator. -
150*/ -
151 -
152QTreeWidgetItemIterator::~QTreeWidgetItemIterator() -
153{ -
154 d_func()->m_model->iterators.removeAll(this);
executed (the execution status of this line is deduced): d_func()->m_model->iterators.removeAll(this);
-
155}
executed: }
Execution Count:192
192
156 -
157/*! -
158 Assignment. Makes a copy of \a it and returns a reference to its -
159 iterator. -
160*/ -
161 -
162QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator=(const QTreeWidgetItemIterator &it) -
163{ -
164 Q_D(QTreeWidgetItemIterator);
executed (the execution status of this line is deduced): QTreeWidgetItemIteratorPrivate * const d = d_func();
-
165 if (d_func()->m_model != it.d_func()->m_model) {
partially evaluated: d_func()->m_model != it.d_func()->m_model
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
166 d_func()->m_model->iterators.removeAll(this);
never executed (the execution status of this line is deduced): d_func()->m_model->iterators.removeAll(this);
-
167 it.d_func()->m_model->iterators.append(this);
never executed (the execution status of this line is deduced): it.d_func()->m_model->iterators.append(this);
-
168 }
never executed: }
0
169 current = it.current;
executed (the execution status of this line is deduced): current = it.current;
-
170 flags = it.flags;
executed (the execution status of this line is deduced): flags = it.flags;
-
171 d->operator=(*it.d_func());
executed (the execution status of this line is deduced): d->operator=(*it.d_func());
-
172 return *this;
executed: return *this;
Execution Count:32
32
173} -
174 -
175/*! -
176 The prefix ++ operator (++it) advances the iterator to the next matching item -
177 and returns a reference to the resulting iterator. -
178 Sets the current pointer to 0 if the current item is the last matching item. -
179*/ -
180 -
181QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator++() -
182{ -
183 if (current)
evaluated: current
TRUEFALSE
yes
Evaluation Count:2257
yes
Evaluation Count:7
7-2257
184 do { -
185 current = d_func()->next(current);
executed (the execution status of this line is deduced): current = d_func()->next(current);
-
186 } while (current && !matchesFlags(current));
executed: }
Execution Count:7376
evaluated: current
TRUEFALSE
yes
Evaluation Count:7347
yes
Evaluation Count:29
evaluated: !matchesFlags(current)
TRUEFALSE
yes
Evaluation Count:5119
yes
Evaluation Count:2228
29-7376
187 return *this;
executed: return *this;
Execution Count:2264
2264
188} -
189 -
190/*! -
191 The prefix -- operator (--it) advances the iterator to the previous matching item -
192 and returns a reference to the resulting iterator. -
193 Sets the current pointer to 0 if the current item is the first matching item. -
194*/ -
195 -
196QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator--() -
197{ -
198 if (current)
partially evaluated: current
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
199 do { -
200 current = d_func()->previous(current);
executed (the execution status of this line is deduced): current = d_func()->previous(current);
-
201 } while (current && !matchesFlags(current));
executed: }
Execution Count:13
evaluated: current
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
partially evaluated: !matchesFlags(current)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-13
202 return *this;
executed: return *this;
Execution Count:13
13
203} -
204 -
205/*! -
206 \internal -
207*/ -
208bool QTreeWidgetItemIterator::matchesFlags(const QTreeWidgetItem *item) const -
209{ -
210 if (!item)
partially evaluated: !item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7526
0-7526
211 return false;
never executed: return false;
0
212 -
213 if (flags == All)
evaluated: flags == All
TRUEFALSE
yes
Evaluation Count:1097
yes
Evaluation Count:6429
1097-6429
214 return true;
executed: return true;
Execution Count:1097
1097
215 -
216 { -
217 Qt::ItemFlags itemFlags = item->flags();
executed (the execution status of this line is deduced): Qt::ItemFlags itemFlags = item->flags();
-
218 if ((flags & Selectable) && !(itemFlags & Qt::ItemIsSelectable))
evaluated: (flags & Selectable)
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:5817
evaluated: !(itemFlags & Qt::ItemIsSelectable)
TRUEFALSE
yes
Evaluation Count:324
yes
Evaluation Count:288
288-5817
219 return false;
executed: return false;
Execution Count:324
324
220 if ((flags & NotSelectable) && (itemFlags & Qt::ItemIsSelectable))
evaluated: (flags & NotSelectable)
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:5961
partially evaluated: (itemFlags & Qt::ItemIsSelectable)
TRUEFALSE
yes
Evaluation Count:144
no
Evaluation Count:0
0-5961
221 return false;
executed: return false;
Execution Count:144
144
222 if ((flags & DragEnabled) && !(itemFlags & Qt::ItemIsDragEnabled))
evaluated: (flags & DragEnabled)
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:5349
evaluated: !(itemFlags & Qt::ItemIsDragEnabled)
TRUEFALSE
yes
Evaluation Count:324
yes
Evaluation Count:288
288-5349
223 return false;
executed: return false;
Execution Count:324
324
224 if ((flags & DragDisabled) && (itemFlags & Qt::ItemIsDragEnabled))
evaluated: (flags & DragDisabled)
TRUEFALSE
yes
Evaluation Count:450
yes
Evaluation Count:5187
evaluated: (itemFlags & Qt::ItemIsDragEnabled)
TRUEFALSE
yes
Evaluation Count:288
yes
Evaluation Count:162
162-5187
225 return false;
executed: return false;
Execution Count:288
288
226 if ((flags & DropEnabled) && !(itemFlags & Qt::ItemIsDropEnabled))
evaluated: (flags & DropEnabled)
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:4737
evaluated: !(itemFlags & Qt::ItemIsDropEnabled)
TRUEFALSE
yes
Evaluation Count:324
yes
Evaluation Count:288
288-4737
227 return false;
executed: return false;
Execution Count:324
324
228 if ((flags & DropDisabled) && (itemFlags & Qt::ItemIsDropEnabled))
evaluated: (flags & DropDisabled)
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:4881
partially evaluated: (itemFlags & Qt::ItemIsDropEnabled)
TRUEFALSE
yes
Evaluation Count:144
no
Evaluation Count:0
0-4881
229 return false;
executed: return false;
Execution Count:144
144
230 if ((flags & Enabled) && !(itemFlags & Qt::ItemIsEnabled))
evaluated: (flags & Enabled)
TRUEFALSE
yes
Evaluation Count:306
yes
Evaluation Count:4575
evaluated: !(itemFlags & Qt::ItemIsEnabled)
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:272
34-4575
231 return false;
executed: return false;
Execution Count:34
34
232 if ((flags & Disabled) && (itemFlags & Qt::ItemIsEnabled))
evaluated: (flags & Disabled)
TRUEFALSE
yes
Evaluation Count:578
yes
Evaluation Count:4269
evaluated: (itemFlags & Qt::ItemIsEnabled)
TRUEFALSE
yes
Evaluation Count:544
yes
Evaluation Count:34
34-4269
233 return false;
executed: return false;
Execution Count:544
544
234 if ((flags & Editable) && !(itemFlags & Qt::ItemIsEditable))
evaluated: (flags & Editable)
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:3691
evaluated: !(itemFlags & Qt::ItemIsEditable)
TRUEFALSE
yes
Evaluation Count:576
yes
Evaluation Count:36
36-3691
235 return false;
executed: return false;
Execution Count:576
576
236 if ((flags & NotEditable) && (itemFlags & Qt::ItemIsEditable))
evaluated: (flags & NotEditable)
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:3709
partially evaluated: (itemFlags & Qt::ItemIsEditable)
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-3709
237 return false;
executed: return false;
Execution Count:18
18
238 } -
239 -
240 if (flags & (Checked|NotChecked)) {
evaluated: flags & (Checked|NotChecked)
TRUEFALSE
yes
Evaluation Count:918
yes
Evaluation Count:2791
918-2791
241 // ### We only test the check state for column 0 -
242 Qt::CheckState check = item->checkState(0);
executed (the execution status of this line is deduced): Qt::CheckState check = item->checkState(0);
-
243 // PartiallyChecked matches as Checked. -
244 if ((flags & Checked) && (check == Qt::Unchecked))
evaluated: (flags & Checked)
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:306
evaluated: (check == Qt::Unchecked)
TRUEFALSE
yes
Evaluation Count:540
yes
Evaluation Count:72
72-612
245 return false;
executed: return false;
Execution Count:540
540
246 if ((flags & NotChecked) && (check != Qt::Unchecked))
evaluated: (flags & NotChecked)
TRUEFALSE
yes
Evaluation Count:342
yes
Evaluation Count:36
evaluated: (check != Qt::Unchecked)
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:270
36-342
247 return false;
executed: return false;
Execution Count:72
72
248 }
executed: }
Execution Count:306
306
249 -
250 if ((flags & HasChildren) && !item->childCount())
evaluated: (flags & HasChildren)
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:2485
evaluated: !item->childCount()
TRUEFALSE
yes
Evaluation Count:578
yes
Evaluation Count:34
34-2485
251 return false;
executed: return false;
Execution Count:578
578
252 if ((flags & NoChildren) && item->childCount())
evaluated: (flags & NoChildren)
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:2502
partially evaluated: item->childCount()
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-2502
253 return false;
executed: return false;
Execution Count:17
17
254 -
255 if ((flags & Hidden) && !item->isHidden())
evaluated: (flags & Hidden)
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:1890
evaluated: !item->isHidden()
TRUEFALSE
yes
Evaluation Count:576
yes
Evaluation Count:36
36-1890
256 return false;
executed: return false;
Execution Count:576
576
257 if ((flags & NotHidden) && item->isHidden())
evaluated: (flags & NotHidden)
TRUEFALSE
yes
Evaluation Count:327
yes
Evaluation Count:1599
evaluated: item->isHidden()
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:289
38-1599
258 return false;
executed: return false;
Execution Count:38
38
259 -
260 if ((flags & Selected) && !item->isSelected())
evaluated: (flags & Selected)
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:1276
evaluated: !item->isSelected()
TRUEFALSE
yes
Evaluation Count:576
yes
Evaluation Count:36
36-1276
261 return false;
executed: return false;
Execution Count:576
576
262 if ((flags & Unselected) && item->isSelected())
evaluated: (flags & Unselected)
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:1294
partially evaluated: item->isSelected()
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-1294
263 return false;
executed: return false;
Execution Count:18
18
264 -
265 return true;
executed: return true;
Execution Count:1294
1294
266} -
267 -
268/* -
269 * Implementation of QTreeWidgetItemIteratorPrivate -
270 */ -
271QTreeWidgetItem* QTreeWidgetItemIteratorPrivate::nextSibling(const QTreeWidgetItem* item) const -
272{ -
273 Q_ASSERT(item);
executed (the execution status of this line is deduced): qt_noop();
-
274 QTreeWidgetItem *next = 0;
executed (the execution status of this line is deduced): QTreeWidgetItem *next = 0;
-
275 if (QTreeWidgetItem *par = item->parent()) {
evaluated: QTreeWidgetItem *par = item->parent()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:22
15-22
276 int i = par->indexOfChild(const_cast<QTreeWidgetItem*>(item));
executed (the execution status of this line is deduced): int i = par->indexOfChild(const_cast<QTreeWidgetItem*>(item));
-
277 next = par->child(i + 1);
executed (the execution status of this line is deduced): next = par->child(i + 1);
-
278 } else {
executed: }
Execution Count:15
15
279 QTreeWidget *tw = item->treeWidget();
executed (the execution status of this line is deduced): QTreeWidget *tw = item->treeWidget();
-
280 int i = tw->indexOfTopLevelItem(const_cast<QTreeWidgetItem*>(item));
executed (the execution status of this line is deduced): int i = tw->indexOfTopLevelItem(const_cast<QTreeWidgetItem*>(item));
-
281 next = tw->topLevelItem(i + 1);
executed (the execution status of this line is deduced): next = tw->topLevelItem(i + 1);
-
282 }
executed: }
Execution Count:22
22
283 return next;
executed: return next;
Execution Count:37
37
284} -
285 -
286QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::next(const QTreeWidgetItem *current) -
287{ -
288 if (!current) return 0;
never executed: return 0;
partially evaluated: !current
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7376
0-7376
289 -
290 QTreeWidgetItem *next = 0;
executed (the execution status of this line is deduced): QTreeWidgetItem *next = 0;
-
291 if (current->childCount()) {
evaluated: current->childCount()
TRUEFALSE
yes
Evaluation Count:490
yes
Evaluation Count:6886
490-6886
292 // walk the child -
293 m_parentIndex.push(m_currentIndex);
executed (the execution status of this line is deduced): m_parentIndex.push(m_currentIndex);
-
294 m_currentIndex = 0;
executed (the execution status of this line is deduced): m_currentIndex = 0;
-
295 next = current->child(0);
executed (the execution status of this line is deduced): next = current->child(0);
-
296 } else {
executed: }
Execution Count:490
490
297 // walk the sibling -
298 QTreeWidgetItem *parent = current->parent();
executed (the execution status of this line is deduced): QTreeWidgetItem *parent = current->parent();
-
299 next = parent ? parent->child(m_currentIndex + 1)
evaluated: parent
TRUEFALSE
yes
Evaluation Count:6839
yes
Evaluation Count:47
47-6839
300 : m_model->rootItem->child(m_currentIndex + 1);
executed (the execution status of this line is deduced): : m_model->rootItem->child(m_currentIndex + 1);
-
301 while (!next && parent) {
evaluated: !next
TRUEFALSE
yes
Evaluation Count:472
yes
Evaluation Count:6857
evaluated: parent
TRUEFALSE
yes
Evaluation Count:443
yes
Evaluation Count:29
29-6857
302 // if we had no sibling walk up the parent and try the sibling of that -
303 parent = parent->parent();
executed (the execution status of this line is deduced): parent = parent->parent();
-
304 m_currentIndex = m_parentIndex.pop();
executed (the execution status of this line is deduced): m_currentIndex = m_parentIndex.pop();
-
305 next = parent ? parent->child(m_currentIndex + 1)
evaluated: parent
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:406
37-406
306 : m_model->rootItem->child(m_currentIndex + 1);
executed (the execution status of this line is deduced): : m_model->rootItem->child(m_currentIndex + 1);
-
307 }
executed: }
Execution Count:443
443
308 if (next) ++(m_currentIndex);
executed: ++(m_currentIndex);
Execution Count:6857
evaluated: next
TRUEFALSE
yes
Evaluation Count:6857
yes
Evaluation Count:29
29-6857
309 }
executed: }
Execution Count:6886
6886
310 return next;
executed: return next;
Execution Count:7376
7376
311} -
312 -
313QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::previous(const QTreeWidgetItem *current) -
314{ -
315 if (!current) return 0;
never executed: return 0;
partially evaluated: !current
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
316 -
317 QTreeWidgetItem *prev = 0;
executed (the execution status of this line is deduced): QTreeWidgetItem *prev = 0;
-
318 // walk the previous sibling -
319 QTreeWidgetItem *parent = current->parent();
executed (the execution status of this line is deduced): QTreeWidgetItem *parent = current->parent();
-
320 prev = parent ? parent->child(m_currentIndex - 1)
evaluated: parent
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:3
3-10
321 : m_model->rootItem->child(m_currentIndex - 1);
executed (the execution status of this line is deduced): : m_model->rootItem->child(m_currentIndex - 1);
-
322 if (prev) {
evaluated: prev
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:6
6-7
323 // Yes, we had a previous sibling but we need go down to the last leafnode. -
324 --m_currentIndex;
executed (the execution status of this line is deduced): --m_currentIndex;
-
325 while (prev && prev->childCount()) {
partially evaluated: prev
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
evaluated: prev->childCount()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
0-10
326 m_parentIndex.push(m_currentIndex);
executed (the execution status of this line is deduced): m_parentIndex.push(m_currentIndex);
-
327 m_currentIndex = prev->childCount() - 1;
executed (the execution status of this line is deduced): m_currentIndex = prev->childCount() - 1;
-
328 prev = prev->child(m_currentIndex);
executed (the execution status of this line is deduced): prev = prev->child(m_currentIndex);
-
329 }
executed: }
Execution Count:3
3
330 } else if (parent) {
executed: }
Execution Count:7
evaluated: parent
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-7
331 m_currentIndex = m_parentIndex.pop();
executed (the execution status of this line is deduced): m_currentIndex = m_parentIndex.pop();
-
332 prev = parent;
executed (the execution status of this line is deduced): prev = parent;
-
333 }
executed: }
Execution Count:5
5
334 return prev;
executed: return prev;
Execution Count:13
13
335} -
336 -
337void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem *itemToBeRemoved) -
338{ -
339 Q_Q(QTreeWidgetItemIterator);
executed (the execution status of this line is deduced): QTreeWidgetItemIterator * const q = q_func();
-
340 Q_ASSERT(itemToBeRemoved);
executed (the execution status of this line is deduced): qt_noop();
-
341 -
342 if (!q->current) return;
never executed: return;
partially evaluated: !q->current
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
343 QTreeWidgetItem *nextItem = q->current;
executed (the execution status of this line is deduced): QTreeWidgetItem *nextItem = q->current;
-
344 -
345 // Do not walk to the ancestor to find the other item if they have the same parent. -
346 if (nextItem->parent() != itemToBeRemoved->parent()) {
evaluated: nextItem->parent() != itemToBeRemoved->parent()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:40
6-40
347 while (nextItem->parent() && nextItem != itemToBeRemoved) {
evaluated: nextItem->parent()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:5
evaluated: nextItem != itemToBeRemoved
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1
1-10
348 nextItem = nextItem->parent();
executed (the execution status of this line is deduced): nextItem = nextItem->parent();
-
349 }
executed: }
Execution Count:9
9
350 }
executed: }
Execution Count:6
6
351 // If the item to be removed is an ancestor of the current iterator item, -
352 // we need to adjust the iterator. -
353 if (nextItem == itemToBeRemoved) {
evaluated: nextItem == itemToBeRemoved
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:10
10-36
354 QTreeWidgetItem *parent = nextItem;
executed (the execution status of this line is deduced): QTreeWidgetItem *parent = nextItem;
-
355 nextItem = 0;
executed (the execution status of this line is deduced): nextItem = 0;
-
356 while (parent && !nextItem) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:22
evaluated: !nextItem
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:14
14-51
357 nextItem = nextSibling(parent);
executed (the execution status of this line is deduced): nextItem = nextSibling(parent);
-
358 parent = parent->parent();
executed (the execution status of this line is deduced): parent = parent->parent();
-
359 }
executed: }
Execution Count:37
37
360 if (nextItem) {
evaluated: nextItem
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:4
4-32
361 // Ooooh... Set the iterator to the next valid item -
362 *q = QTreeWidgetItemIterator(nextItem, q->flags);
executed (the execution status of this line is deduced): *q = QTreeWidgetItemIterator(nextItem, q->flags);
-
363 if (!(q->matchesFlags(nextItem))) ++(*q);
never executed: ++(*q);
partially evaluated: !(q->matchesFlags(nextItem))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
364 } else {
executed: }
Execution Count:32
32
365 // set it to null. -
366 q->current = 0;
executed (the execution status of this line is deduced): q->current = 0;
-
367 m_parentIndex.clear();
executed (the execution status of this line is deduced): m_parentIndex.clear();
-
368 return;
executed: return;
Execution Count:4
4
369 } -
370 } -
371 if (nextItem->parent() == itemToBeRemoved->parent()) {
evaluated: nextItem->parent() == itemToBeRemoved->parent()
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:2
2-40
372 // They have the same parent, i.e. we have to adjust the m_currentIndex member of the iterator -
373 // if the deleted item is to the left of the nextItem. -
374 -
375 QTreeWidgetItem *par = itemToBeRemoved->parent(); // We know they both have the same parent.
executed (the execution status of this line is deduced): QTreeWidgetItem *par = itemToBeRemoved->parent();
-
376 QTreeWidget *tw = itemToBeRemoved->treeWidget(); // ..and widget
executed (the execution status of this line is deduced): QTreeWidget *tw = itemToBeRemoved->treeWidget();
-
377 int indexOfItemToBeRemoved = par ? par->indexOfChild(const_cast<QTreeWidgetItem *>(itemToBeRemoved))
evaluated: par
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:22
18-22
378 : tw->indexOfTopLevelItem(const_cast<QTreeWidgetItem *>(itemToBeRemoved));
executed (the execution status of this line is deduced): : tw->indexOfTopLevelItem(const_cast<QTreeWidgetItem *>(itemToBeRemoved));
-
379 int indexOfNextItem = par ? par->indexOfChild(nextItem) : tw->indexOfTopLevelItem(nextItem);
evaluated: par
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:22
18-22
380 -
381 if (indexOfItemToBeRemoved <= indexOfNextItem) {
evaluated: indexOfItemToBeRemoved <= indexOfNextItem
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:3
3-37
382 // A sibling to the left of us was deleted, adjust the m_currentIndex member of the iterator. -
383 // Note that the m_currentIndex will be wrong until the item is actually removed! -
384 m_currentIndex--;
executed (the execution status of this line is deduced): m_currentIndex--;
-
385 }
executed: }
Execution Count:37
37
386 }
executed: }
Execution Count:40
40
387}
executed: }
Execution Count:42
42
388 -
389/*! -
390 \fn const QTreeWidgetItemIterator QTreeWidgetItemIterator::operator++(int) -
391 -
392 The postfix ++ operator (it++) advances the iterator to the next matching item -
393 and returns an iterator to the previously current item. -
394*/ -
395 -
396/*! -
397 \fn QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator+=(int n) -
398 -
399 Makes the iterator go forward by \a n matching items. (If n is negative, the -
400 iterator goes backward.) -
401 -
402 If the current item is beyond the last item, the current item pointer is -
403 set to 0. Returns the resulting iterator. -
404*/ -
405 -
406/*! -
407 \fn const QTreeWidgetItemIterator QTreeWidgetItemIterator::operator--(int) -
408 -
409 The postfix -- operator (it--) makes the preceding matching item current and returns an iterator to the previously current item. -
410*/ -
411 -
412/*! -
413 \fn QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator-=(int n) -
414 -
415 Makes the iterator go backward by \a n matching items. (If n is negative, the -
416 iterator goes forward.) -
417 -
418 If the current item is ahead of the last item, the current item pointer is -
419 set to 0. Returns the resulting iterator. -
420*/ -
421 -
422/*! -
423 \fn QTreeWidgetItem *QTreeWidgetItemIterator::operator*() const -
424 -
425 Dereference operator. Returns a pointer to the current item. -
426*/ -
427 -
428 -
429/*! -
430 \enum QTreeWidgetItemIterator::IteratorFlag -
431 -
432 These flags can be passed to a QTreeWidgetItemIterator constructor -
433 (OR-ed together if more than one is used), so that the iterator -
434 will only iterate over items that match the given flags. -
435 -
436 \value All -
437 \value Hidden -
438 \value NotHidden -
439 \value Selected -
440 \value Unselected -
441 \value Selectable -
442 \value NotSelectable -
443 \value DragEnabled -
444 \value DragDisabled -
445 \value DropEnabled -
446 \value DropDisabled -
447 \value HasChildren -
448 \value NoChildren -
449 \value Checked -
450 \value NotChecked -
451 \value Enabled -
452 \value Disabled -
453 \value Editable -
454 \value NotEditable -
455 \value UserFlag -
456*/ -
457 -
458QT_END_NAMESPACE -
459 -
460#endif // QT_NO_TREEWIDGET -
461 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial