itemviews/qtreewidget.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 "qtreewidget.h" -
43 -
44#ifndef QT_NO_TREEWIDGET -
45#include <qheaderview.h> -
46#include <qpainter.h> -
47#include <qitemdelegate.h> -
48#include <qstack.h> -
49#include <qdebug.h> -
50#include <private/qtreewidget_p.h> -
51#include <private/qwidgetitemdata_p.h> -
52#include <private/qtreewidgetitemiterator_p.h> -
53 -
54#include <algorithm> -
55 -
56QT_BEGIN_NAMESPACE -
57 -
58// workaround for VC++ 6.0 linker bug (?) -
59typedef bool(*LessThan)(const QPair<QTreeWidgetItem*,int>&,const QPair<QTreeWidgetItem*,int>&); -
60 -
61class QTreeModelLessThan -
62{ -
63public: -
64 inline bool operator()(QTreeWidgetItem *i1, QTreeWidgetItem *i2) const -
65 { return *i1 < *i2; }
executed: return *i1 < *i2;
Execution Count:39
39
66}; -
67 -
68class QTreeModelGreaterThan -
69{ -
70public: -
71 inline bool operator()(QTreeWidgetItem *i1, QTreeWidgetItem *i2) const -
72 { return *i2 < *i1; }
executed: return *i2 < *i1;
Execution Count:8
8
73}; -
74 -
75/* -
76 \class QTreeModel -
77 \brief The QTreeModel class manages the items stored in a tree view. -
78 -
79 \ingroup model-view -
80 \inmodule QtWidgets -
81 -
82*/ -
83 -
84/*! -
85 \enum QTreeWidgetItem::ChildIndicatorPolicy -
86 \since 4.3 -
87 -
88 \value ShowIndicator The controls for expanding and collapsing will be shown for this item even if there are no children. -
89 \value DontShowIndicator The controls for expanding and collapsing will never be shown even if there are children. If the node is forced open the user will not be able to expand or collapse the item. -
90 \value DontShowIndicatorWhenChildless The controls for expanding and collapsing will be shown if the item contains children. -
91*/ -
92 -
93/*! -
94 \fn void QTreeWidgetItem::setDisabled(bool disabled) -
95 \since 4.3 -
96 -
97 Disables the item if \a disabled is true; otherwise enables the item. -
98 -
99 \sa setFlags() -
100*/ -
101 -
102/*! -
103 \fn bool QTreeWidgetItem::isDisabled() const -
104 \since 4.3 -
105 -
106 Returns true if the item is disabled; otherwise returns false. -
107 -
108 \sa setFlags() -
109*/ -
110 -
111/*! -
112 \internal -
113 -
114 Constructs a tree model with a \a parent object and the given -
115 number of \a columns. -
116*/ -
117 -
118QTreeModel::QTreeModel(int columns, QTreeWidget *parent) -
119 : QAbstractItemModel(parent), rootItem(new QTreeWidgetItem), -
120 headerItem(new QTreeWidgetItem), skipPendingSort(false) -
121{ -
122 rootItem->view = parent;
executed (the execution status of this line is deduced): rootItem->view = parent;
-
123 rootItem->itemFlags = Qt::ItemIsDropEnabled;
executed (the execution status of this line is deduced): rootItem->itemFlags = Qt::ItemIsDropEnabled;
-
124 headerItem->view = parent;
executed (the execution status of this line is deduced): headerItem->view = parent;
-
125 setColumnCount(columns);
executed (the execution status of this line is deduced): setColumnCount(columns);
-
126}
executed: }
Execution Count:264
264
127 -
128/*! -
129 \internal -
130 -
131*/ -
132 -
133QTreeModel::QTreeModel(QTreeModelPrivate &dd, QTreeWidget *parent) -
134 : QAbstractItemModel(dd, parent), rootItem(new QTreeWidgetItem), -
135 headerItem(new QTreeWidgetItem), skipPendingSort(false) -
136{ -
137 rootItem->view = parent;
never executed (the execution status of this line is deduced): rootItem->view = parent;
-
138 rootItem->itemFlags = Qt::ItemIsDropEnabled;
never executed (the execution status of this line is deduced): rootItem->itemFlags = Qt::ItemIsDropEnabled;
-
139 headerItem->view = parent;
never executed (the execution status of this line is deduced): headerItem->view = parent;
-
140}
never executed: }
0
141 -
142/*! -
143 \internal -
144 -
145 Destroys this tree model. -
146*/ -
147 -
148QTreeModel::~QTreeModel() -
149{ -
150 clear();
executed (the execution status of this line is deduced): clear();
-
151 delete headerItem;
executed (the execution status of this line is deduced): delete headerItem;
-
152 rootItem->view = 0;
executed (the execution status of this line is deduced): rootItem->view = 0;
-
153 delete rootItem;
executed (the execution status of this line is deduced): delete rootItem;
-
154}
executed: }
Execution Count:263
263
155 -
156/*! -
157 \internal -
158 -
159 Removes all items in the model. -
160*/ -
161 -
162void QTreeModel::clear() -
163{ -
164 SkipSorting skipSorting(this);
executed (the execution status of this line is deduced): SkipSorting skipSorting(this);
-
165 beginResetModel();
executed (the execution status of this line is deduced): beginResetModel();
-
166 for (int i = 0; i < rootItem->childCount(); ++i) {
evaluated: i < rootItem->childCount()
TRUEFALSE
yes
Evaluation Count:4182
yes
Evaluation Count:429
429-4182
167 QTreeWidgetItem *item = rootItem->children.at(i);
executed (the execution status of this line is deduced): QTreeWidgetItem *item = rootItem->children.at(i);
-
168 item->par = 0;
executed (the execution status of this line is deduced): item->par = 0;
-
169 item->view = 0;
executed (the execution status of this line is deduced): item->view = 0;
-
170 delete item;
executed (the execution status of this line is deduced): delete item;
-
171 }
executed: }
Execution Count:4182
4182
172 rootItem->children.clear();
executed (the execution status of this line is deduced): rootItem->children.clear();
-
173 sortPendingTimer.stop();
executed (the execution status of this line is deduced): sortPendingTimer.stop();
-
174 endResetModel();
executed (the execution status of this line is deduced): endResetModel();
-
175}
executed: }
Execution Count:429
429
176 -
177/*! -
178 \internal -
179 -
180 Sets the number of \a columns in the tree model. -
181*/ -
182 -
183void QTreeModel::setColumnCount(int columns) -
184{ -
185 SkipSorting skipSorting(this);
executed (the execution status of this line is deduced): SkipSorting skipSorting(this);
-
186 if (columns < 0)
partially evaluated: columns < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:575
0-575
187 return;
never executed: return;
0
188 if (!headerItem) {
evaluated: !headerItem
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:574
1-574
189 headerItem = new QTreeWidgetItem();
executed (the execution status of this line is deduced): headerItem = new QTreeWidgetItem();
-
190 headerItem->view = view();
executed (the execution status of this line is deduced): headerItem->view = view();
-
191 }
executed: }
Execution Count:1
1
192 int count = columnCount();
executed (the execution status of this line is deduced): int count = columnCount();
-
193 if (count == columns)
evaluated: count == columns
TRUEFALSE
yes
Evaluation Count:260
yes
Evaluation Count:315
260-315
194 return;
executed: return;
Execution Count:260
260
195 -
196 if (columns < count) {
evaluated: columns < count
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:308
7-308
197 beginRemoveColumns(QModelIndex(), columns, count - 1);
executed (the execution status of this line is deduced): beginRemoveColumns(QModelIndex(), columns, count - 1);
-
198 headerItem->values.resize(columns);
executed (the execution status of this line is deduced): headerItem->values.resize(columns);
-
199 endRemoveColumns();
executed (the execution status of this line is deduced): endRemoveColumns();
-
200 } else {
executed: }
Execution Count:7
7
201 beginInsertColumns(QModelIndex(), count, columns - 1);
executed (the execution status of this line is deduced): beginInsertColumns(QModelIndex(), count, columns - 1);
-
202 headerItem->values.resize(columns);
executed (the execution status of this line is deduced): headerItem->values.resize(columns);
-
203 for (int i = count; i < columns; ++i) {// insert data without emitting the dataChanged signal
evaluated: i < columns
TRUEFALSE
yes
Evaluation Count:441
yes
Evaluation Count:308
308-441
204 headerItem->values[i].append(QWidgetItemData(Qt::DisplayRole, QString::number(i + 1)));
executed (the execution status of this line is deduced): headerItem->values[i].append(QWidgetItemData(Qt::DisplayRole, QString::number(i + 1)));
-
205 headerItem->d->display.append(QString::number(i + 1));
executed (the execution status of this line is deduced): headerItem->d->display.append(QString::number(i + 1));
-
206 }
executed: }
Execution Count:441
441
207 endInsertColumns();
executed (the execution status of this line is deduced): endInsertColumns();
-
208 }
executed: }
Execution Count:308
308
209} -
210 -
211/*! -
212 \internal -
213 -
214 Returns the tree view item corresponding to the \a index given. -
215 -
216 \sa QModelIndex -
217*/ -
218 -
219QTreeWidgetItem *QTreeModel::item(const QModelIndex &index) const -
220{ -
221 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:130
yes
Evaluation Count:115373
130-115373
222 return 0;
executed: return 0;
Execution Count:130
130
223 return static_cast<QTreeWidgetItem*>(index.internalPointer());
executed: return static_cast<QTreeWidgetItem*>(index.internalPointer());
Execution Count:115373
115373
224} -
225 -
226/*! -
227 \internal -
228 -
229 Returns the model index that refers to the -
230 tree view \a item and \a column. -
231*/ -
232 -
233QModelIndex QTreeModel::index(const QTreeWidgetItem *item, int column) const -
234{ -
235 executePendingSort();
executed (the execution status of this line is deduced): executePendingSort();
-
236 -
237 if (!item || (item == rootItem))
evaluated: !item
TRUEFALSE
yes
Evaluation Count:23713
yes
Evaluation Count:98752
evaluated: (item == rootItem)
TRUEFALSE
yes
Evaluation Count:5235
yes
Evaluation Count:93517
5235-98752
238 return QModelIndex();
executed: return QModelIndex();
Execution Count:28948
28948
239 const QTreeWidgetItem *par = item->parent();
executed (the execution status of this line is deduced): const QTreeWidgetItem *par = item->parent();
-
240 QTreeWidgetItem *itm = const_cast<QTreeWidgetItem*>(item);
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = const_cast<QTreeWidgetItem*>(item);
-
241 if (!par)
evaluated: !par
TRUEFALSE
yes
Evaluation Count:83007
yes
Evaluation Count:10510
10510-83007
242 par = rootItem;
executed: par = rootItem;
Execution Count:83007
83007
243 int row;
executed (the execution status of this line is deduced): int row;
-
244 int guess = item->d->rowGuess;
executed (the execution status of this line is deduced): int guess = item->d->rowGuess;
-
245 if (guess >= 0
evaluated: guess >= 0
TRUEFALSE
yes
Evaluation Count:91323
yes
Evaluation Count:2194
2194-91323
246 && par->children.count() > guess
partially evaluated: par->children.count() > guess
TRUEFALSE
yes
Evaluation Count:91323
no
Evaluation Count:0
0-91323
247 && par->children.at(guess) == itm) {
evaluated: par->children.at(guess) == itm
TRUEFALSE
yes
Evaluation Count:91258
yes
Evaluation Count:65
65-91258
248 row = guess;
executed (the execution status of this line is deduced): row = guess;
-
249 } else {
executed: }
Execution Count:91258
91258
250 row = par->children.lastIndexOf(itm);
executed (the execution status of this line is deduced): row = par->children.lastIndexOf(itm);
-
251 itm->d->rowGuess = row;
executed (the execution status of this line is deduced): itm->d->rowGuess = row;
-
252 }
executed: }
Execution Count:2259
2259
253 return createIndex(row, column, itm);
executed: return createIndex(row, column, itm);
Execution Count:93517
93517
254} -
255 -
256/*! -
257 \internal -
258 \reimp -
259 -
260 Returns the model index with the given \a row, -
261 \a column and \a parent. -
262*/ -
263 -
264QModelIndex QTreeModel::index(int row, int column, const QModelIndex &parent) const -
265{ -
266 executePendingSort();
executed (the execution status of this line is deduced): executePendingSort();
-
267 -
268 int c = columnCount(parent);
executed (the execution status of this line is deduced): int c = columnCount(parent);
-
269 if (row < 0 || column < 0 || column >= c)
evaluated: row < 0
TRUEFALSE
yes
Evaluation Count:196
yes
Evaluation Count:26186
evaluated: column < 0
TRUEFALSE
yes
Evaluation Count:129
yes
Evaluation Count:26057
evaluated: column >= c
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:25952
105-26186
270 return QModelIndex();
executed: return QModelIndex();
Execution Count:430
430
271 -
272 QTreeWidgetItem *parentItem = parent.isValid() ? item(parent) : rootItem;
evaluated: parent.isValid()
TRUEFALSE
yes
Evaluation Count:7233
yes
Evaluation Count:18719
7233-18719
273 if (parentItem && row < parentItem->childCount()) {
partially evaluated: parentItem
TRUEFALSE
yes
Evaluation Count:25952
no
Evaluation Count:0
evaluated: row < parentItem->childCount()
TRUEFALSE
yes
Evaluation Count:25815
yes
Evaluation Count:137
0-25952
274 QTreeWidgetItem *itm = parentItem->child(row);
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = parentItem->child(row);
-
275 if (itm)
partially evaluated: itm
TRUEFALSE
yes
Evaluation Count:25815
no
Evaluation Count:0
0-25815
276 return createIndex(row, column, itm);
executed: return createIndex(row, column, itm);
Execution Count:25815
25815
277 return QModelIndex();
never executed: return QModelIndex();
0
278 } -
279 -
280 return QModelIndex();
executed: return QModelIndex();
Execution Count:137
137
281} -
282 -
283/*! -
284 \internal -
285 \reimp -
286 -
287 Returns the parent model index of the index given as -
288 the \a child. -
289*/ -
290 -
291QModelIndex QTreeModel::parent(const QModelIndex &child) const -
292{ -
293 SkipSorting skipSorting(this); //The reason we don't sort here is that this might be called from a valid QPersistentModelIndex
executed (the execution status of this line is deduced): SkipSorting skipSorting(this);
-
294 //We don't want it to become suddenly invalid -
295 -
296 if (!child.isValid())
evaluated: !child.isValid()
TRUEFALSE
yes
Evaluation Count:213
yes
Evaluation Count:44625
213-44625
297 return QModelIndex();
executed: return QModelIndex();
Execution Count:213
213
298 QTreeWidgetItem *itm = static_cast<QTreeWidgetItem *>(child.internalPointer());
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = static_cast<QTreeWidgetItem *>(child.internalPointer());
-
299 if (!itm || itm == rootItem)
partially evaluated: !itm
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44625
partially evaluated: itm == rootItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44625
0-44625
300 return QModelIndex();
never executed: return QModelIndex();
0
301 QTreeWidgetItem *parent = itm->parent();
executed (the execution status of this line is deduced): QTreeWidgetItem *parent = itm->parent();
-
302 return index(parent, 0);
executed: return index(parent, 0);
Execution Count:44625
44625
303} -
304 -
305/*! -
306 \internal -
307 \reimp -
308 -
309 Returns the number of rows in the \a parent model index. -
310*/ -
311 -
312int QTreeModel::rowCount(const QModelIndex &parent) const -
313{ -
314 if (!parent.isValid())
evaluated: !parent.isValid()
TRUEFALSE
yes
Evaluation Count:8887
yes
Evaluation Count:65022
8887-65022
315 return rootItem->childCount();
executed: return rootItem->childCount();
Execution Count:8887
8887
316 -
317 QTreeWidgetItem *parentItem = item(parent);
executed (the execution status of this line is deduced): QTreeWidgetItem *parentItem = item(parent);
-
318 if (parentItem)
partially evaluated: parentItem
TRUEFALSE
yes
Evaluation Count:65022
no
Evaluation Count:0
0-65022
319 return parentItem->childCount();
executed: return parentItem->childCount();
Execution Count:65022
65022
320 return 0;
never executed: return 0;
0
321} -
322 -
323/*! -
324 \internal -
325 \reimp -
326 -
327 Returns the number of columns in the item referred to by -
328 the given \a index. -
329*/ -
330 -
331int QTreeModel::columnCount(const QModelIndex &index) const -
332{ -
333 Q_UNUSED(index);
executed (the execution status of this line is deduced): (void)index;;
-
334 if (!headerItem)
partially evaluated: !headerItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104566
0-104566
335 return 0;
never executed: return 0;
0
336 return headerItem->columnCount();
executed: return headerItem->columnCount();
Execution Count:104566
104566
337} -
338 -
339bool QTreeModel::hasChildren(const QModelIndex &parent) const -
340{ -
341 if (!parent.isValid())
evaluated: !parent.isValid()
TRUEFALSE
yes
Evaluation Count:753
yes
Evaluation Count:6636
753-6636
342 return (rootItem->childCount() > 0);
executed: return (rootItem->childCount() > 0);
Execution Count:753
753
343 -
344 QTreeWidgetItem *itm = item(parent);
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = item(parent);
-
345 if (!itm)
partially evaluated: !itm
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6636
0-6636
346 return false;
never executed: return false;
0
347 switch (itm->d->policy) { -
348 case QTreeWidgetItem::ShowIndicator: -
349 return true;
executed: return true;
Execution Count:1
1
350 case QTreeWidgetItem::DontShowIndicator: -
351 return false;
executed: return false;
Execution Count:1
1
352 case QTreeWidgetItem::DontShowIndicatorWhenChildless: -
353 return (itm->childCount() > 0);
executed: return (itm->childCount() > 0);
Execution Count:6634
6634
354 } -
355 return false;
never executed: return false;
0
356} -
357 -
358/*! -
359 \internal -
360 \reimp -
361 -
362 Returns the data corresponding to the given model \a index -
363 and \a role. -
364*/ -
365 -
366QVariant QTreeModel::data(const QModelIndex &index, int role) const -
367{ -
368 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:181
yes
Evaluation Count:18369
181-18369
369 return QVariant();
executed: return QVariant();
Execution Count:181
181
370 QTreeWidgetItem *itm = item(index);
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = item(index);
-
371 if (itm)
partially evaluated: itm
TRUEFALSE
yes
Evaluation Count:18369
no
Evaluation Count:0
0-18369
372 return itm->data(index.column(), role);
executed: return itm->data(index.column(), role);
Execution Count:18369
18369
373 return QVariant();
never executed: return QVariant();
0
374} -
375 -
376/*! -
377 \internal -
378 \reimp -
379 -
380 Sets the data for the item specified by the \a index and \a role -
381 to that referred to by the \a value. -
382 -
383 Returns true if successful; otherwise returns false. -
384*/ -
385 -
386bool QTreeModel::setData(const QModelIndex &index, const QVariant &value, int role) -
387{ -
388 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:132
105-132
389 return false;
executed: return false;
Execution Count:105
105
390 QTreeWidgetItem *itm = item(index);
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = item(index);
-
391 if (itm) {
partially evaluated: itm
TRUEFALSE
yes
Evaluation Count:132
no
Evaluation Count:0
0-132
392 itm->setData(index.column(), role, value);
executed (the execution status of this line is deduced): itm->setData(index.column(), role, value);
-
393 return true;
executed: return true;
Execution Count:132
132
394 } -
395 return false;
never executed: return false;
0
396} -
397 -
398QMap<int, QVariant> QTreeModel::itemData(const QModelIndex &index) const -
399{ -
400 QMap<int, QVariant> roles;
executed (the execution status of this line is deduced): QMap<int, QVariant> roles;
-
401 QTreeWidgetItem *itm = item(index);
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = item(index);
-
402 if (itm) {
evaluated: itm
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:53
2-53
403 int column = index.column();
executed (the execution status of this line is deduced): int column = index.column();
-
404 if (column < itm->values.count()) {
evaluated: column < itm->values.count()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
405 for (int i = 0; i < itm->values.at(column).count(); ++i) {
evaluated: i < itm->values.at(column).count()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
406 roles.insert(itm->values.at(column).at(i).role,
executed (the execution status of this line is deduced): roles.insert(itm->values.at(column).at(i).role,
-
407 itm->values.at(column).at(i).value);
executed (the execution status of this line is deduced): itm->values.at(column).at(i).value);
-
408 }
executed: }
Execution Count:5
5
409 }
executed: }
Execution Count:1
1
410 -
411 // the two special cases -
412 QVariant displayValue = itm->data(column, Qt::DisplayRole);
executed (the execution status of this line is deduced): QVariant displayValue = itm->data(column, Qt::DisplayRole);
-
413 if (displayValue.isValid())
evaluated: displayValue.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
414 roles.insert(Qt::DisplayRole, displayValue);
executed: roles.insert(Qt::DisplayRole, displayValue);
Execution Count:1
1
415 -
416 QVariant checkValue = itm->data(column, Qt::CheckStateRole);
executed (the execution status of this line is deduced): QVariant checkValue = itm->data(column, Qt::CheckStateRole);
-
417 if (checkValue.isValid())
evaluated: checkValue.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
418 roles.insert(Qt::CheckStateRole, checkValue);
executed: roles.insert(Qt::CheckStateRole, checkValue);
Execution Count:1
1
419 }
executed: }
Execution Count:2
2
420 return roles;
executed: return roles;
Execution Count:55
55
421} -
422 -
423/*! -
424 \internal -
425 \reimp -
426*/ -
427bool QTreeModel::insertRows(int row, int count, const QModelIndex &parent) -
428{ -
429 SkipSorting skipSorting(this);
executed (the execution status of this line is deduced): SkipSorting skipSorting(this);
-
430 if (count < 1 || row < 0 || row > rowCount(parent) || parent.column() > 0)
evaluated: count < 1
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:22
evaluated: row < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:18
evaluated: row > rowCount(parent)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:14
partially evaluated: parent.column() > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-22
431 return false;
executed: return false;
Execution Count:24
24
432 -
433 beginInsertRows(parent, row, row + count - 1);
executed (the execution status of this line is deduced): beginInsertRows(parent, row, row + count - 1);
-
434 QTreeWidgetItem *par = item(parent);
executed (the execution status of this line is deduced): QTreeWidgetItem *par = item(parent);
-
435 while (count > 0) {
evaluated: count > 0
TRUEFALSE
yes
Evaluation Count:120
yes
Evaluation Count:14
14-120
436 QTreeWidgetItem *item = new QTreeWidgetItem();
executed (the execution status of this line is deduced): QTreeWidgetItem *item = new QTreeWidgetItem();
-
437 item->view = view();
executed (the execution status of this line is deduced): item->view = view();
-
438 item->par = par;
executed (the execution status of this line is deduced): item->par = par;
-
439 if (par)
partially evaluated: par
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
440 par->children.insert(row++, item);
never executed: par->children.insert(row++, item);
0
441 else -
442 rootItem->children.insert(row++, item);
executed: rootItem->children.insert(row++, item);
Execution Count:120
120
443 --count;
executed (the execution status of this line is deduced): --count;
-
444 }
executed: }
Execution Count:120
120
445 endInsertRows();
executed (the execution status of this line is deduced): endInsertRows();
-
446 return true;
executed: return true;
Execution Count:14
14
447} -
448 -
449/*! -
450 \internal -
451 \reimp -
452*/ -
453bool QTreeModel::insertColumns(int column, int count, const QModelIndex &parent) -
454{ -
455 SkipSorting skipSorting(this);
executed (the execution status of this line is deduced): SkipSorting skipSorting(this);
-
456 if (count < 1 || column < 0 || column > columnCount(parent) || parent.column() > 0 || !headerItem)
evaluated: count < 1
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:23
evaluated: column < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:19
evaluated: column > columnCount(parent)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:7
partially evaluated: parent.column() > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
partially evaluated: !headerItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-23
457 return false;
executed: return false;
Execution Count:32
32
458 -
459 beginInsertColumns(parent, column, column + count - 1);
executed (the execution status of this line is deduced): beginInsertColumns(parent, column, column + count - 1);
-
460 -
461 int oldCount = columnCount(parent);
executed (the execution status of this line is deduced): int oldCount = columnCount(parent);
-
462 column = qBound(0, column, oldCount);
executed (the execution status of this line is deduced): column = qBound(0, column, oldCount);
-
463 headerItem->values.resize(oldCount + count);
executed (the execution status of this line is deduced): headerItem->values.resize(oldCount + count);
-
464 for (int i = oldCount; i < oldCount + count; ++i) {
evaluated: i < oldCount + count
TRUEFALSE
yes
Evaluation Count:85
yes
Evaluation Count:7
7-85
465 headerItem->values[i].append(QWidgetItemData(Qt::DisplayRole, QString::number(i + 1)));
executed (the execution status of this line is deduced): headerItem->values[i].append(QWidgetItemData(Qt::DisplayRole, QString::number(i + 1)));
-
466 headerItem->d->display.append(QString::number(i + 1));
executed (the execution status of this line is deduced): headerItem->d->display.append(QString::number(i + 1));
-
467 }
executed: }
Execution Count:85
85
468 -
469 QStack<QTreeWidgetItem*> itemstack;
executed (the execution status of this line is deduced): QStack<QTreeWidgetItem*> itemstack;
-
470 itemstack.push(0);
executed (the execution status of this line is deduced): itemstack.push(0);
-
471 while (!itemstack.isEmpty()) {
evaluated: !itemstack.isEmpty()
TRUEFALSE
yes
Evaluation Count:187
yes
Evaluation Count:7
7-187
472 QTreeWidgetItem *par = itemstack.pop();
executed (the execution status of this line is deduced): QTreeWidgetItem *par = itemstack.pop();
-
473 QList<QTreeWidgetItem*> children = par ? par->children : rootItem->children;
evaluated: par
TRUEFALSE
yes
Evaluation Count:180
yes
Evaluation Count:7
7-180
474 for (int row = 0; row < children.count(); ++row) {
evaluated: row < children.count()
TRUEFALSE
yes
Evaluation Count:3860
yes
Evaluation Count:187
187-3860
475 QTreeWidgetItem *child = children.at(row);
executed (the execution status of this line is deduced): QTreeWidgetItem *child = children.at(row);
-
476 if (child->children.count())
evaluated: child->children.count()
TRUEFALSE
yes
Evaluation Count:180
yes
Evaluation Count:3680
180-3680
477 itemstack.push(child);
executed: itemstack.push(child);
Execution Count:180
180
478 child->values.insert(column, count, QVector<QWidgetItemData>());
executed (the execution status of this line is deduced): child->values.insert(column, count, QVector<QWidgetItemData>());
-
479 }
executed: }
Execution Count:3860
3860
480 }
executed: }
Execution Count:187
187
481 -
482 endInsertColumns();
executed (the execution status of this line is deduced): endInsertColumns();
-
483 return true;
executed: return true;
Execution Count:7
7
484} -
485 -
486/*! -
487 \internal -
488 \reimp -
489*/ -
490bool QTreeModel::removeRows(int row, int count, const QModelIndex &parent) { -
491 if (count < 1 || row < 0 || (row + count) > rowCount(parent))
evaluated: count < 1
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:28
evaluated: row < 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:22
evaluated: (row + count) > rowCount(parent)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:14
6-28
492 return false;
executed: return false;
Execution Count:30
30
493 -
494 beginRemoveRows(parent, row, row + count - 1);
executed (the execution status of this line is deduced): beginRemoveRows(parent, row, row + count - 1);
-
495 -
496 bool blockSignal = signalsBlocked();
executed (the execution status of this line is deduced): bool blockSignal = signalsBlocked();
-
497 blockSignals(true);
executed (the execution status of this line is deduced): blockSignals(true);
-
498 -
499 QTreeWidgetItem *itm = item(parent);
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = item(parent);
-
500 for (int i = row + count - 1; i >= row; --i) {
evaluated: i >= row
TRUEFALSE
yes
Evaluation Count:120
yes
Evaluation Count:14
14-120
501 QTreeWidgetItem *child = itm ? itm->takeChild(i) : rootItem->children.takeAt(i);
partially evaluated: itm
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
502 Q_ASSERT(child);
executed (the execution status of this line is deduced): qt_noop();
-
503 child->view = 0;
executed (the execution status of this line is deduced): child->view = 0;
-
504 delete child;
executed (the execution status of this line is deduced): delete child;
-
505 child = 0;
executed (the execution status of this line is deduced): child = 0;
-
506 }
executed: }
Execution Count:120
120
507 blockSignals(blockSignal);
executed (the execution status of this line is deduced): blockSignals(blockSignal);
-
508 -
509 endRemoveRows();
executed (the execution status of this line is deduced): endRemoveRows();
-
510 return true;
executed: return true;
Execution Count:14
14
511} -
512 -
513/*! -
514 \internal -
515 \reimp -
516 -
517 Returns the header data corresponding to the given header \a section, -
518 \a orientation and data \a role. -
519*/ -
520 -
521QVariant QTreeModel::headerData(int section, Qt::Orientation orientation, int role) const -
522{ -
523 if (orientation != Qt::Horizontal)
partially evaluated: orientation != Qt::Horizontal
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2895
0-2895
524 return QVariant();
never executed: return QVariant();
0
525 -
526 if (headerItem)
partially evaluated: headerItem
TRUEFALSE
yes
Evaluation Count:2895
no
Evaluation Count:0
0-2895
527 return headerItem->data(section, role);
executed: return headerItem->data(section, role);
Execution Count:2895
2895
528 if (role == Qt::DisplayRole)
never evaluated: role == Qt::DisplayRole
0
529 return QString::number(section + 1);
never executed: return QString::number(section + 1);
0
530 return QVariant();
never executed: return QVariant();
0
531} -
532 -
533/*! -
534 \internal -
535 \reimp -
536 -
537 Sets the header data for the item specified by the header \a section, -
538 \a orientation and data \a role to the given \a value. -
539 -
540 Returns true if successful; otherwise returns false. -
541*/ -
542 -
543bool QTreeModel::setHeaderData(int section, Qt::Orientation orientation, -
544 const QVariant &value, int role) -
545{ -
546 if (section < 0 || orientation != Qt::Horizontal || !headerItem || section >= columnCount())
evaluated: section < 0
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:64
evaluated: orientation != Qt::Horizontal
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:60
partially evaluated: !headerItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:60
evaluated: section >= columnCount()
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:3
0-64
547 return false;
executed: return false;
Execution Count:118
118
548 -
549 headerItem->setData(section, role, value);
executed (the execution status of this line is deduced): headerItem->setData(section, role, value);
-
550 return true;
executed: return true;
Execution Count:3
3
551} -
552 -
553/*! -
554 \reimp -
555 -
556 Returns the flags for the item referred to the given \a index. -
557 -
558*/ -
559 -
560Qt::ItemFlags QTreeModel::flags(const QModelIndex &index) const -
561{ -
562 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:10738
53-10738
563 return rootItem->flags();
executed: return rootItem->flags();
Execution Count:53
53
564 QTreeWidgetItem *itm = item(index);
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = item(index);
-
565 Q_ASSERT(itm);
executed (the execution status of this line is deduced): qt_noop();
-
566 return itm->flags();
executed: return itm->flags();
Execution Count:10738
10738
567} -
568 -
569/*! -
570 \internal -
571 -
572 Sorts the entire tree in the model in the given \a order, -
573 by the values in the given \a column. -
574*/ -
575 -
576void QTreeModel::sort(int column, Qt::SortOrder order) -
577{ -
578 SkipSorting skipSorting(this);
executed (the execution status of this line is deduced): SkipSorting skipSorting(this);
-
579 sortPendingTimer.stop();
executed (the execution status of this line is deduced): sortPendingTimer.stop();
-
580 -
581 if (column < 0 || column >= columnCount())
evaluated: column < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:465
evaluated: column >= columnCount()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:455
1-465
582 return;
executed: return;
Execution Count:11
11
583 -
584 //layoutAboutToBeChanged and layoutChanged will be called by sortChildren -
585 rootItem->sortChildren(column, order, true);
executed (the execution status of this line is deduced): rootItem->sortChildren(column, order, true);
-
586}
executed: }
Execution Count:455
455
587 -
588/*! -
589 \internal -
590*/ -
591void QTreeModel::ensureSorted(int column, Qt::SortOrder order, -
592 int start, int end, const QModelIndex &parent) -
593{ -
594 if (isChanging())
partially evaluated: isChanging()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
595 return;
never executed: return;
0
596 -
597 sortPendingTimer.stop();
executed (the execution status of this line is deduced): sortPendingTimer.stop();
-
598 -
599 if (column < 0 || column >= columnCount())
partially evaluated: column < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
partially evaluated: column >= columnCount()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
600 return;
never executed: return;
0
601 -
602 SkipSorting skipSorting(this);
executed (the execution status of this line is deduced): SkipSorting skipSorting(this);
-
603 -
604 QTreeWidgetItem *itm = item(parent);
executed (the execution status of this line is deduced): QTreeWidgetItem *itm = item(parent);
-
605 if (!itm)
partially evaluated: !itm
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
606 itm = rootItem;
executed: itm = rootItem;
Execution Count:21
21
607 QList<QTreeWidgetItem*> lst = itm->children;
executed (the execution status of this line is deduced): QList<QTreeWidgetItem*> lst = itm->children;
-
608 -
609 int count = end - start + 1;
executed (the execution status of this line is deduced): int count = end - start + 1;
-
610 QVector < QPair<QTreeWidgetItem*,int> > sorting(count);
executed (the execution status of this line is deduced): QVector < QPair<QTreeWidgetItem*,int> > sorting(count);
-
611 for (int i = 0; i < count; ++i) {
evaluated: i < count
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:21
21
612 sorting[i].first = lst.at(start + i);
executed (the execution status of this line is deduced): sorting[i].first = lst.at(start + i);
-
613 sorting[i].second = start + i;
executed (the execution status of this line is deduced): sorting[i].second = start + i;
-
614 }
executed: }
Execution Count:21
21
615 -
616 LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan);
evaluated: order == Qt::AscendingOrder
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:4
4-17
617 qStableSort(sorting.begin(), sorting.end(), compare);
executed (the execution status of this line is deduced): qStableSort(sorting.begin(), sorting.end(), compare);
-
618 -
619 QModelIndexList oldPersistentIndexes;
executed (the execution status of this line is deduced): QModelIndexList oldPersistentIndexes;
-
620 QModelIndexList newPersistentIndexes;
executed (the execution status of this line is deduced): QModelIndexList newPersistentIndexes;
-
621 QList<QTreeWidgetItem*>::iterator lit = lst.begin();
executed (the execution status of this line is deduced): QList<QTreeWidgetItem*>::iterator lit = lst.begin();
-
622 bool changed = false;
executed (the execution status of this line is deduced): bool changed = false;
-
623 -
624 for (int i = 0; i < count; ++i) {
evaluated: i < count
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:21
21
625 int oldRow = sorting.at(i).second;
executed (the execution status of this line is deduced): int oldRow = sorting.at(i).second;
-
626 QTreeWidgetItem *item = lst.takeAt(oldRow);
executed (the execution status of this line is deduced): QTreeWidgetItem *item = lst.takeAt(oldRow);
-
627 lit = sortedInsertionIterator(lit, lst.end(), order, item);
executed (the execution status of this line is deduced): lit = sortedInsertionIterator(lit, lst.end(), order, item);
-
628 int newRow = qMax(lit - lst.begin(), 0);
executed (the execution status of this line is deduced): int newRow = qMax(lit - lst.begin(), 0);
-
629 -
630 if ((newRow < oldRow) && !(*item < *lst.at(oldRow - 1)) && !(*lst.at(oldRow - 1) < *item ))
evaluated: (newRow < oldRow)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:13
evaluated: !(*item < *lst.at(oldRow - 1))
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:3
partially evaluated: !(*lst.at(oldRow - 1) < *item )
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-13
631 newRow = oldRow;
executed: newRow = oldRow;
Execution Count:5
5
632 -
633 lit = lst.insert(lit, item);
executed (the execution status of this line is deduced): lit = lst.insert(lit, item);
-
634 if (newRow != oldRow) {
evaluated: newRow != oldRow
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:13
8-13
635 // we are going to change the persistent indexes, so we need to prepare -
636 if (!changed) { // this will only happen once
partially evaluated: !changed
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
637 changed = true;
executed (the execution status of this line is deduced): changed = true;
-
638 emit layoutAboutToBeChanged(); // the selection model needs to know
executed (the execution status of this line is deduced): layoutAboutToBeChanged();
-
639 oldPersistentIndexes = persistentIndexList();
executed (the execution status of this line is deduced): oldPersistentIndexes = persistentIndexList();
-
640 newPersistentIndexes = oldPersistentIndexes;
executed (the execution status of this line is deduced): newPersistentIndexes = oldPersistentIndexes;
-
641 }
executed: }
Execution Count:8
8
642 for (int j = i + 1; j < count; ++j) {
partially evaluated: j < count
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
643 int otherRow = sorting.at(j).second;
never executed (the execution status of this line is deduced): int otherRow = sorting.at(j).second;
-
644 if (oldRow < otherRow && newRow >= otherRow)
never evaluated: oldRow < otherRow
never evaluated: newRow >= otherRow
0
645 --sorting[j].second;
never executed: --sorting[j].second;
0
646 else if (oldRow > otherRow && newRow <= otherRow)
never evaluated: oldRow > otherRow
never evaluated: newRow <= otherRow
0
647 ++sorting[j].second;
never executed: ++sorting[j].second;
0
648 } -
649 for (int k = 0; k < newPersistentIndexes.count(); ++k) {
evaluated: k < newPersistentIndexes.count()
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:8
8-32
650 QModelIndex pi = newPersistentIndexes.at(k);
executed (the execution status of this line is deduced): QModelIndex pi = newPersistentIndexes.at(k);
-
651 if (pi.parent() != parent)
partially evaluated: pi.parent() != parent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
652 continue;
never executed: continue;
0
653 int oldPersistentRow = pi.row();
executed (the execution status of this line is deduced): int oldPersistentRow = pi.row();
-
654 int newPersistentRow = oldPersistentRow;
executed (the execution status of this line is deduced): int newPersistentRow = oldPersistentRow;
-
655 if (oldPersistentRow == oldRow)
evaluated: oldPersistentRow == oldRow
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:24
8-24
656 newPersistentRow = newRow;
executed: newPersistentRow = newRow;
Execution Count:8
8
657 else if (oldRow < oldPersistentRow && newRow >= oldPersistentRow)
evaluated: oldRow < oldPersistentRow
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:11
evaluated: newRow >= oldPersistentRow
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:7
6-13
658 newPersistentRow = oldPersistentRow - 1;
executed: newPersistentRow = oldPersistentRow - 1;
Execution Count:6
6
659 else if (oldRow > oldPersistentRow && newRow <= oldPersistentRow)
evaluated: oldRow > oldPersistentRow
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:7
evaluated: newRow <= oldPersistentRow
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:7
4-11
660 newPersistentRow = oldPersistentRow + 1;
executed: newPersistentRow = oldPersistentRow + 1;
Execution Count:4
4
661 if (newPersistentRow != oldPersistentRow)
evaluated: newPersistentRow != oldPersistentRow
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:14
14-18
662 newPersistentIndexes[k] = createIndex(newPersistentRow,
executed: newPersistentIndexes[k] = createIndex(newPersistentRow, pi.column(), pi.internalPointer());
Execution Count:18
18
663 pi.column(), pi.internalPointer());
executed: newPersistentIndexes[k] = createIndex(newPersistentRow, pi.column(), pi.internalPointer());
Execution Count:18
18
664 }
executed: }
Execution Count:32
32
665 }
executed: }
Execution Count:8
8
666 }
executed: }
Execution Count:21
21
667 -
668 if (changed) {
evaluated: changed
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:13
8-13
669 itm->children = lst;
executed (the execution status of this line is deduced): itm->children = lst;
-
670 changePersistentIndexList(oldPersistentIndexes, newPersistentIndexes);
executed (the execution status of this line is deduced): changePersistentIndexList(oldPersistentIndexes, newPersistentIndexes);
-
671 emit layoutChanged();
executed (the execution status of this line is deduced): layoutChanged();
-
672 }
executed: }
Execution Count:8
8
673}
executed: }
Execution Count:21
21
674 -
675/*! -
676 \internal -
677 -
678 Returns true if the value of the \a left item is -
679 less than the value of the \a right item. -
680 -
681 Used by the sorting functions. -
682*/ -
683 -
684bool QTreeModel::itemLessThan(const QPair<QTreeWidgetItem*,int> &left, -
685 const QPair<QTreeWidgetItem*,int> &right) -
686{ -
687 return *(left.first) < *(right.first);
executed: return *(left.first) < *(right.first);
Execution Count:4167
4167
688} -
689 -
690/*! -
691 \internal -
692 -
693 Returns true if the value of the \a left item is -
694 greater than the value of the \a right item. -
695 -
696 Used by the sorting functions. -
697*/ -
698 -
699bool QTreeModel::itemGreaterThan(const QPair<QTreeWidgetItem*,int> &left, -
700 const QPair<QTreeWidgetItem*,int> &right) -
701{ -
702 return *(right.first) < *(left.first);
executed: return *(right.first) < *(left.first);
Execution Count:3365
3365
703} -
704 -
705/*! -
706 \internal -
707*/ -
708QList<QTreeWidgetItem*>::iterator QTreeModel::sortedInsertionIterator( -
709 const QList<QTreeWidgetItem*>::iterator &begin, -
710 const QList<QTreeWidgetItem*>::iterator &end, -
711 Qt::SortOrder order, QTreeWidgetItem *item) -
712{ -
713 if (order == Qt::AscendingOrder)
evaluated: order == Qt::AscendingOrder
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:4
4-17
714 return std::lower_bound(begin, end, item, QTreeModelLessThan());
executed: return std::lower_bound(begin, end, item, QTreeModelLessThan());
Execution Count:17
17
715 return std::lower_bound(begin, end, item, QTreeModelGreaterThan());
executed: return std::lower_bound(begin, end, item, QTreeModelGreaterThan());
Execution Count:4
4
716} -
717 -
718QStringList QTreeModel::mimeTypes() const -
719{ -
720 return view()->mimeTypes();
executed: return view()->mimeTypes();
Execution Count:53
53
721} -
722 -
723QMimeData *QTreeModel::internalMimeData() const -
724{ -
725 return QAbstractItemModel::mimeData(cachedIndexes);
never executed: return QAbstractItemModel::mimeData(cachedIndexes);
0
726} -
727 -
728QMimeData *QTreeModel::mimeData(const QModelIndexList &indexes) const -
729{ -
730 QList<QTreeWidgetItem*> items;
never executed (the execution status of this line is deduced): QList<QTreeWidgetItem*> items;
-
731 for (int i = 0; i < indexes.count(); ++i) {
never evaluated: i < indexes.count()
0
732 if (indexes.at(i).column() == 0) // only one item per row
never evaluated: indexes.at(i).column() == 0
0
733 items << item(indexes.at(i));
never executed: items << item(indexes.at(i));
0
734 }
never executed: }
0
735 -
736 // cachedIndexes is a little hack to avoid copying from QModelIndexList to -
737 // QList<QTreeWidgetItem*> and back again in the view -
738 cachedIndexes = indexes;
never executed (the execution status of this line is deduced): cachedIndexes = indexes;
-
739 QMimeData *mimeData = view()->mimeData(items);
never executed (the execution status of this line is deduced): QMimeData *mimeData = view()->mimeData(items);
-
740 cachedIndexes.clear();
never executed (the execution status of this line is deduced): cachedIndexes.clear();
-
741 return mimeData;
never executed: return mimeData;
0
742} -
743 -
744bool QTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, -
745 int row, int column, const QModelIndex &parent) -
746{ -
747 if (row == -1 && column == -1)
never evaluated: row == -1
never evaluated: column == -1
0
748 row = rowCount(parent); // append
never executed: row = rowCount(parent);
0
749 return view()->dropMimeData(item(parent), row, data, action);
never executed: return view()->dropMimeData(item(parent), row, data, action);
0
750} -
751 -
752Qt::DropActions QTreeModel::supportedDropActions() const -
753{ -
754 return view()->supportedDropActions();
executed: return view()->supportedDropActions();
Execution Count:53
53
755} -
756 -
757void QTreeModel::itemChanged(QTreeWidgetItem *item) -
758{ -
759 SkipSorting skipSorting(this); //this is kind of wrong, but not doing this would kill performence
executed (the execution status of this line is deduced): SkipSorting skipSorting(this);
-
760 QModelIndex left = index(item, 0);
executed (the execution status of this line is deduced): QModelIndex left = index(item, 0);
-
761 QModelIndex right = index(item, item->columnCount() - 1);
executed (the execution status of this line is deduced): QModelIndex right = index(item, item->columnCount() - 1);
-
762 emit dataChanged(left, right);
executed (the execution status of this line is deduced): dataChanged(left, right);
-
763}
executed: }
Execution Count:231
231
764 -
765bool QTreeModel::isChanging() const -
766{ -
767 Q_D(const QTreeModel);
executed (the execution status of this line is deduced): const QTreeModelPrivate * const d = d_func();
-
768 return !d->changes.isEmpty();
executed: return !d->changes.isEmpty();
Execution Count:4063
4063
769} -
770 -
771/*! -
772 \internal -
773 Emits the dataChanged() signal for the given \a item. -
774 if column is -1 then all columns have changed -
775*/ -
776 -
777void QTreeModel::emitDataChanged(QTreeWidgetItem *item, int column) -
778{ -
779 if (signalsBlocked())
partially evaluated: signalsBlocked()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6187
0-6187
780 return;
never executed: return;
0
781 -
782 if (headerItem == item && column < item->columnCount()) {
evaluated: headerItem == item
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:6150
partially evaluated: column < item->columnCount()
TRUEFALSE
yes
Evaluation Count:37
no
Evaluation Count:0
0-6150
783 if (column == -1)
partially evaluated: column == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
0-37
784 emit headerDataChanged(Qt::Horizontal, 0, columnCount() - 1);
never executed: headerDataChanged(Qt::Horizontal, 0, columnCount() - 1);
0
785 else -
786 emit headerDataChanged(Qt::Horizontal, column, column);
executed: headerDataChanged(Qt::Horizontal, column, column);
Execution Count:37
37
787 return;
executed: return;
Execution Count:37
37
788 } -
789 -
790 SkipSorting skipSorting(this); //This is a little bit wrong, but not doing it would kill performence
executed (the execution status of this line is deduced): SkipSorting skipSorting(this);
-
791 -
792 QModelIndex bottomRight, topLeft;
executed (the execution status of this line is deduced): QModelIndex bottomRight, topLeft;
-
793 if (column == -1) {
partially evaluated: column == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6150
0-6150
794 topLeft = index(item, 0);
never executed (the execution status of this line is deduced): topLeft = index(item, 0);
-
795 bottomRight = createIndex(topLeft.row(), columnCount() - 1, item);
never executed (the execution status of this line is deduced): bottomRight = createIndex(topLeft.row(), columnCount() - 1, item);
-
796 } else {
never executed: }
0
797 topLeft = index(item, column);
executed (the execution status of this line is deduced): topLeft = index(item, column);
-
798 bottomRight = topLeft;
executed (the execution status of this line is deduced): bottomRight = topLeft;
-
799 }
executed: }
Execution Count:6150
6150
800 emit dataChanged(topLeft, bottomRight);
executed (the execution status of this line is deduced): dataChanged(topLeft, bottomRight);
-
801}
executed: }
Execution Count:6150
6150
802 -
803void QTreeModel::beginInsertItems(QTreeWidgetItem *parent, int row, int count) -
804{ -
805 QModelIndex par = index(parent, 0);
executed (the execution status of this line is deduced): QModelIndex par = index(parent, 0);
-
806 beginInsertRows(par, row, row + count - 1);
executed (the execution status of this line is deduced): beginInsertRows(par, row, row + count - 1);
-
807}
executed: }
Execution Count:68119
68119
808 -
809void QTreeModel::endInsertItems() -
810{ -
811 endInsertRows();
executed (the execution status of this line is deduced): endInsertRows();
-
812}
executed: }
Execution Count:68119
68119
813 -
814void QTreeModel::beginRemoveItems(QTreeWidgetItem *parent, int row, int count) -
815{ -
816 Q_ASSERT(row >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
817 Q_ASSERT(count > 0);
executed (the execution status of this line is deduced): qt_noop();
-
818 beginRemoveRows(index(parent, 0), row, row + count - 1);
executed (the execution status of this line is deduced): beginRemoveRows(index(parent, 0), row, row + count - 1);
-
819 if (!parent)
evaluated: !parent
TRUEFALSE
yes
Evaluation Count:1146
yes
Evaluation Count:83
83-1146
820 parent = rootItem;
executed: parent = rootItem;
Execution Count:1146
1146
821 // now update the iterators -
822 for (int i = 0; i < iterators.count(); ++i) {
evaluated: i < iterators.count()
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:1229
46-1229
823 for (int j = 0; j < count; j++) {
evaluated: j < count
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:46
46
824 QTreeWidgetItem *c = parent->child(row + j);
executed (the execution status of this line is deduced): QTreeWidgetItem *c = parent->child(row + j);
-
825 iterators[i]->d_func()->ensureValidIterator(c);
executed (the execution status of this line is deduced): iterators[i]->d_func()->ensureValidIterator(c);
-
826 }
executed: }
Execution Count:46
46
827 }
executed: }
Execution Count:46
46
828}
executed: }
Execution Count:1229
1229
829 -
830void QTreeModel::endRemoveItems() -
831{ -
832 endRemoveRows();
executed (the execution status of this line is deduced): endRemoveRows();
-
833}
executed: }
Execution Count:1217
1217
834 -
835void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortOrder order) -
836{ -
837 // see QTreeViewItem::operator< -
838 Q_UNUSED(column);
executed (the execution status of this line is deduced): (void)column;;
-
839 if (isChanging())
partially evaluated: isChanging()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3360
0-3360
840 return;
never executed: return;
0
841 -
842 // store the original order of indexes -
843 QVector< QPair<QTreeWidgetItem*,int> > sorting(items->count());
executed (the execution status of this line is deduced): QVector< QPair<QTreeWidgetItem*,int> > sorting(items->count());
-
844 for (int i = 0; i < sorting.count(); ++i) {
evaluated: i < sorting.count()
TRUEFALSE
yes
Evaluation Count:2912
yes
Evaluation Count:3360
2912-3360
845 sorting[i].first = items->at(i);
executed (the execution status of this line is deduced): sorting[i].first = items->at(i);
-
846 sorting[i].second = i;
executed (the execution status of this line is deduced): sorting[i].second = i;
-
847 }
executed: }
Execution Count:2912
2912
848 -
849 // do the sorting -
850 LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan);
evaluated: order == Qt::AscendingOrder
TRUEFALSE
yes
Evaluation Count:1579
yes
Evaluation Count:1781
1579-1781
851 qStableSort(sorting.begin(), sorting.end(), compare);
executed (the execution status of this line is deduced): qStableSort(sorting.begin(), sorting.end(), compare);
-
852 -
853 QModelIndexList fromList;
executed (the execution status of this line is deduced): QModelIndexList fromList;
-
854 QModelIndexList toList;
executed (the execution status of this line is deduced): QModelIndexList toList;
-
855 int colCount = columnCount();
executed (the execution status of this line is deduced): int colCount = columnCount();
-
856 for (int r = 0; r < sorting.count(); ++r) {
evaluated: r < sorting.count()
TRUEFALSE
yes
Evaluation Count:2912
yes
Evaluation Count:3360
2912-3360
857 int oldRow = sorting.at(r).second;
executed (the execution status of this line is deduced): int oldRow = sorting.at(r).second;
-
858 if (oldRow == r)
evaluated: oldRow == r
TRUEFALSE
yes
Evaluation Count:2339
yes
Evaluation Count:573
573-2339
859 continue;
executed: continue;
Execution Count:2339
2339
860 QTreeWidgetItem *item = sorting.at(r).first;
executed (the execution status of this line is deduced): QTreeWidgetItem *item = sorting.at(r).first;
-
861 items->replace(r, item);
executed (the execution status of this line is deduced): items->replace(r, item);
-
862 for (int c = 0; c < colCount; ++c) {
evaluated: c < colCount
TRUEFALSE
yes
Evaluation Count:694
yes
Evaluation Count:573
573-694
863 QModelIndex from = createIndex(oldRow, c, item);
executed (the execution status of this line is deduced): QModelIndex from = createIndex(oldRow, c, item);
-
864 if (static_cast<QAbstractItemModelPrivate *>(d_ptr.data())->persistent.indexes.contains(from)) {
evaluated: static_cast<QAbstractItemModelPrivate *>(d_ptr.data())->persistent.indexes.contains(from)
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:651
43-651
865 QModelIndex to = createIndex(r, c, item);
executed (the execution status of this line is deduced): QModelIndex to = createIndex(r, c, item);
-
866 fromList << from;
executed (the execution status of this line is deduced): fromList << from;
-
867 toList << to;
executed (the execution status of this line is deduced): toList << to;
-
868 }
executed: }
Execution Count:43
43
869 }
executed: }
Execution Count:694
694
870 }
executed: }
Execution Count:573
573
871 changePersistentIndexList(fromList, toList);
executed (the execution status of this line is deduced): changePersistentIndexList(fromList, toList);
-
872}
executed: }
Execution Count:3360
3360
873 -
874void QTreeModel::timerEvent(QTimerEvent *ev) -
875{ -
876 if (ev->timerId() == sortPendingTimer.timerId()) {
partially evaluated: ev->timerId() == sortPendingTimer.timerId()
TRUEFALSE
yes
Evaluation Count:51
no
Evaluation Count:0
0-51
877 executePendingSort();
executed (the execution status of this line is deduced): executePendingSort();
-
878 } else {
executed: }
Execution Count:51
51
879 QAbstractItemModel::timerEvent(ev);
never executed (the execution status of this line is deduced): QAbstractItemModel::timerEvent(ev);
-
880 }
never executed: }
0
881} -
882 -
883/*! -
884 \class QTreeWidgetItem -
885 -
886 \brief The QTreeWidgetItem class provides an item for use with the -
887 QTreeWidget convenience class. -
888 -
889 \ingroup model-view -
890 \inmodule QtWidgets -
891 -
892 Tree widget items are used to hold rows of information for tree widgets. -
893 Rows usually contain several columns of data, each of which can contain -
894 a text label and an icon. -
895 -
896 The QTreeWidgetItem class is a convenience class that replaces the -
897 QListViewItem class in Qt 3. It provides an item for use with -
898 the QTreeWidget class. -
899 -
900 Items are usually constructed with a parent that is either a QTreeWidget -
901 (for top-level items) or a QTreeWidgetItem (for items on lower levels of -
902 the tree). For example, the following code constructs a top-level item -
903 to represent cities of the world, and adds a entry for Oslo as a child -
904 item: -
905 -
906 \snippet qtreewidget-using/mainwindow.cpp 3 -
907 -
908 Items can be added in a particular order by specifying the item they -
909 follow when they are constructed: -
910 -
911 \snippet qtreewidget-using/mainwindow.cpp 5 -
912 -
913 Each column in an item can have its own background brush which is set with -
914 the setBackground() function. The current background brush can be -
915 found with background(). -
916 The text label for each column can be rendered with its own font and brush. -
917 These are specified with the setFont() and setForeground() functions, -
918 and read with font() and foreground(). -
919 -
920 The main difference between top-level items and those in lower levels of -
921 the tree is that a top-level item has no parent(). This information -
922 can be used to tell the difference between items, and is useful to know -
923 when inserting and removing items from the tree. -
924 Children of an item can be removed with takeChild() and inserted at a -
925 given index in the list of children with the insertChild() function. -
926 -
927 By default, items are enabled, selectable, checkable, and can be the source -
928 of a drag and drop operation. -
929 Each item's flags can be changed by calling setFlags() with the appropriate -
930 value (see \l{Qt::ItemFlags}). Checkable items can be checked and unchecked -
931 with the setCheckState() function. The corresponding checkState() function -
932 indicates whether the item is currently checked. -
933 -
934 \section1 Subclassing -
935 -
936 When subclassing QTreeWidgetItem to provide custom items, it is possible to -
937 define new types for them so that they can be distinguished from standard -
938 items. The constructors for subclasses that require this feature need to -
939 call the base class constructor with a new type value equal to or greater -
940 than \l UserType. -
941 -
942 \sa QTreeWidget, QTreeWidgetItemIterator, {Model/View Programming}, -
943 QListWidgetItem, QTableWidgetItem -
944*/ -
945 -
946/*! -
947 \enum QTreeWidgetItem::ItemType -
948 -
949 This enum describes the types that are used to describe tree widget items. -
950 -
951 \value Type The default type for tree widget items. -
952 \value UserType The minimum value for custom types. Values below UserType are -
953 reserved by Qt. -
954 -
955 You can define new user types in QTreeWidgetItem subclasses to ensure that -
956 custom items are treated specially; for example, when items are sorted. -
957 -
958 \sa type() -
959*/ -
960 -
961/*! -
962 \fn int QTreeWidgetItem::type() const -
963 -
964 Returns the type passed to the QTreeWidgetItem constructor. -
965*/ -
966 -
967/*! -
968 \fn void QTreeWidgetItem::sortChildren(int column, Qt::SortOrder order) -
969 \since 4.2 -
970 -
971 Sorts the children of the item using the given \a order, -
972 by the values in the given \a column. -
973 -
974 \note This function does nothing if the item is not associated with a -
975 QTreeWidget. -
976*/ -
977 -
978/*! -
979 \fn QTreeWidget *QTreeWidgetItem::treeWidget() const -
980 -
981 Returns the tree widget that contains the item. -
982*/ -
983 -
984/*! -
985 \fn void QTreeWidgetItem::setSelected(bool select) -
986 \since 4.2 -
987 -
988 Sets the selected state of the item to \a select. -
989 -
990 \sa isSelected() -
991 -
992*/ -
993 -
994/*! -
995 \fn bool QTreeWidgetItem::isSelected() const -
996 \since 4.2 -
997 -
998 Returns true if the item is selected, otherwise returns false. -
999 -
1000 \sa setSelected() -
1001*/ -
1002 -
1003/*! -
1004 \fn void QTreeWidgetItem::setHidden(bool hide) -
1005 \since 4.2 -
1006 -
1007 Hides the item if \a hide is true, otherwise shows the item. -
1008 -
1009 \sa isHidden() -
1010*/ -
1011 -
1012/*! -
1013 \fn bool QTreeWidgetItem::isHidden() const -
1014 \since 4.2 -
1015 -
1016 Returns true if the item is hidden, otherwise returns false. -
1017 -
1018 \sa setHidden() -
1019*/ -
1020 -
1021/*! -
1022 \fn void QTreeWidgetItem::setExpanded(bool expand) -
1023 \since 4.2 -
1024 -
1025 Expands the item if \a expand is true, otherwise collapses the item. -
1026 \warning The QTreeWidgetItem must be added to the QTreeWidget before calling this function. -
1027 -
1028 \sa isExpanded() -
1029*/ -
1030 -
1031/*! -
1032 \fn bool QTreeWidgetItem::isExpanded() const -
1033 \since 4.2 -
1034 -
1035 Returns true if the item is expanded, otherwise returns false. -
1036 -
1037 \sa setExpanded() -
1038*/ -
1039 -
1040/*! -
1041 \fn void QTreeWidgetItem::setFirstColumnSpanned(bool span) -
1042 \since 4.3 -
1043 -
1044 Sets the first section to span all columns if \a span is true; -
1045 otherwise all item sections are shown. -
1046 -
1047 \sa isFirstColumnSpanned() -
1048*/ -
1049 -
1050/*! -
1051 \fn bool QTreeWidgetItem::isFirstColumnSpanned() const -
1052 \since 4.3 -
1053 -
1054 Returns true if the item is spanning all the columns in a row; otherwise returns false. -
1055 -
1056 \sa setFirstColumnSpanned() -
1057*/ -
1058 -
1059/*! -
1060 \fn QString QTreeWidgetItem::text(int column) const -
1061 -
1062 Returns the text in the specified \a column. -
1063 -
1064 \sa setText() -
1065*/ -
1066 -
1067/*! -
1068 \fn void QTreeWidgetItem::setText(int column, const QString &text) -
1069 -
1070 Sets the text to be displayed in the given \a column to the given \a text. -
1071 -
1072 \sa text(), setFont(), setForeground() -
1073*/ -
1074 -
1075/*! -
1076 \fn QIcon QTreeWidgetItem::icon(int column) const -
1077 -
1078 Returns the icon that is displayed in the specified \a column. -
1079 -
1080 \sa setIcon(), {QAbstractItemView::iconSize}{iconSize} -
1081*/ -
1082 -
1083/*! -
1084 \fn void QTreeWidgetItem::setIcon(int column, const QIcon &icon) -
1085 -
1086 Sets the icon to be displayed in the given \a column to \a icon. -
1087 -
1088 \sa icon(), setText(), {QAbstractItemView::iconSize}{iconSize} -
1089*/ -
1090 -
1091/*! -
1092 \fn QString QTreeWidgetItem::statusTip(int column) const -
1093 -
1094 Returns the status tip for the contents of the given \a column. -
1095 -
1096 \sa setStatusTip() -
1097*/ -
1098 -
1099/*! -
1100 \fn void QTreeWidgetItem::setStatusTip(int column, const QString &statusTip) -
1101 -
1102 Sets the status tip for the given \a column to the given \a statusTip. -
1103 QTreeWidget mouse tracking needs to be enabled for this feature to work. -
1104 -
1105 \sa statusTip(), setToolTip(), setWhatsThis() -
1106*/ -
1107 -
1108/*! -
1109 \fn QString QTreeWidgetItem::toolTip(int column) const -
1110 -
1111 Returns the tool tip for the given \a column. -
1112 -
1113 \sa setToolTip() -
1114*/ -
1115 -
1116/*! -
1117 \fn void QTreeWidgetItem::setToolTip(int column, const QString &toolTip) -
1118 -
1119 Sets the tooltip for the given \a column to \a toolTip. -
1120 -
1121 \sa toolTip(), setStatusTip(), setWhatsThis() -
1122*/ -
1123 -
1124/*! -
1125 \fn QString QTreeWidgetItem::whatsThis(int column) const -
1126 -
1127 Returns the "What's This?" help for the contents of the given \a column. -
1128 -
1129 \sa setWhatsThis() -
1130*/ -
1131 -
1132/*! -
1133 \fn void QTreeWidgetItem::setWhatsThis(int column, const QString &whatsThis) -
1134 -
1135 Sets the "What's This?" help for the given \a column to \a whatsThis. -
1136 -
1137 \sa whatsThis(), setStatusTip(), setToolTip() -
1138*/ -
1139 -
1140/*! -
1141 \fn QFont QTreeWidgetItem::font(int column) const -
1142 -
1143 Returns the font used to render the text in the specified \a column. -
1144 -
1145 \sa setFont() -
1146*/ -
1147 -
1148/*! -
1149 \fn void QTreeWidgetItem::setFont(int column, const QFont &font) -
1150 -
1151 Sets the font used to display the text in the given \a column to the given -
1152 \a font. -
1153 -
1154 \sa font(), setText(), setForeground() -
1155*/ -
1156 -
1157/*! -
1158 \fn QColor QTreeWidgetItem::backgroundColor(int column) const -
1159 \obsolete -
1160 -
1161 This function is deprecated. Use background() instead. -
1162*/ -
1163 -
1164/*! -
1165 \fn void QTreeWidgetItem::setBackgroundColor(int column, const QColor &color) -
1166 \obsolete -
1167 -
1168 This function is deprecated. Use setBackground() instead. -
1169*/ -
1170 -
1171/*! -
1172 \fn QBrush QTreeWidgetItem::background(int column) const -
1173 \since 4.2 -
1174 -
1175 Returns the brush used to render the background of the specified \a column. -
1176 -
1177 \sa foreground() -
1178*/ -
1179 -
1180/*! -
1181 \fn void QTreeWidgetItem::setBackground(int column, const QBrush &brush) -
1182 \since 4.2 -
1183 -
1184 Sets the background brush of the label in the given \a column to the -
1185 specified \a brush. -
1186 -
1187 \sa setForeground() -
1188*/ -
1189 -
1190/*! -
1191 \fn QColor QTreeWidgetItem::textColor(int column) const -
1192 \obsolete -
1193 -
1194 This function is deprecated. Use foreground() instead. -
1195*/ -
1196 -
1197/*! -
1198 \fn void QTreeWidgetItem::setTextColor(int column, const QColor &color) -
1199 \obsolete -
1200 -
1201 This function is deprecated. Use setForeground() instead. -
1202*/ -
1203 -
1204/*! -
1205 \fn QBrush QTreeWidgetItem::foreground(int column) const -
1206 \since 4.2 -
1207 -
1208 Returns the brush used to render the foreground (e.g. text) of the -
1209 specified \a column. -
1210 -
1211 \sa background() -
1212*/ -
1213 -
1214/*! -
1215 \fn void QTreeWidgetItem::setForeground(int column, const QBrush &brush) -
1216 \since 4.2 -
1217 -
1218 Sets the foreground brush of the label in the given \a column to the -
1219 specified \a brush. -
1220 -
1221 \sa setBackground() -
1222*/ -
1223 -
1224/*! -
1225 \fn Qt::CheckState QTreeWidgetItem::checkState(int column) const -
1226 -
1227 Returns the check state of the label in the given \a column. -
1228 -
1229 \sa Qt::CheckState -
1230*/ -
1231 -
1232/*! -
1233 \fn void QTreeWidgetItem::setCheckState(int column, Qt::CheckState state) -
1234 -
1235 Sets the item in the given \a column check state to be \a state. -
1236 -
1237 \sa checkState() -
1238*/ -
1239 -
1240/*! -
1241 \fn QSize QTreeWidgetItem::sizeHint(int column) const -
1242 \since 4.1 -
1243 -
1244 Returns the size hint set for the tree item in the given -
1245 \a column (see \l{QSize}). -
1246*/ -
1247 -
1248/*! -
1249 \fn void QTreeWidgetItem::setSizeHint(int column, const QSize &size) -
1250 \since 4.1 -
1251 -
1252 Sets the size hint for the tree item in the given \a column to be \a size. -
1253 If no size hint is set, the item delegate will compute the size hint based -
1254 on the item data. -
1255*/ -
1256 -
1257/*! -
1258 \fn QTreeWidgetItem *QTreeWidgetItem::parent() const -
1259 -
1260 Returns the item's parent. -
1261 -
1262 \sa child() -
1263*/ -
1264 -
1265/*! -
1266 \fn QTreeWidgetItem *QTreeWidgetItem::child(int index) const -
1267 -
1268 Returns the item at the given \a index in the list of the item's children. -
1269 -
1270 \sa parent() -
1271*/ -
1272 -
1273/*! -
1274 \fn int QTreeWidgetItem::childCount() const -
1275 -
1276 Returns the number of child items. -
1277*/ -
1278 -
1279/*! -
1280 \fn int QTreeWidgetItem::columnCount() const -
1281 -
1282 Returns the number of columns in the item. -
1283*/ -
1284 -
1285/*! -
1286 \fn int QTreeWidgetItem::textAlignment(int column) const -
1287 -
1288 Returns the text alignment for the label in the given \a column -
1289 (see \l{Qt::AlignmentFlag}). -
1290*/ -
1291 -
1292/*! -
1293 \fn void QTreeWidgetItem::setTextAlignment(int column, int alignment) -
1294 -
1295 Sets the text alignment for the label in the given \a column to -
1296 the \a alignment specified (see \l{Qt::AlignmentFlag}). -
1297*/ -
1298 -
1299/*! -
1300 \fn int QTreeWidgetItem::indexOfChild(QTreeWidgetItem *child) const -
1301 -
1302 Returns the index of the given \a child in the item's list of children. -
1303*/ -
1304 -
1305/*! -
1306 Constructs a tree widget item of the specified \a type. The item -
1307 must be inserted into a tree widget. -
1308 -
1309 \sa type() -
1310*/ -
1311QTreeWidgetItem::QTreeWidgetItem(int type) -
1312 : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), -
1313 itemFlags(Qt::ItemIsSelectable -
1314 |Qt::ItemIsUserCheckable -
1315 |Qt::ItemIsEnabled -
1316 |Qt::ItemIsDragEnabled -
1317 |Qt::ItemIsDropEnabled) -
1318{ -
1319}
executed: }
Execution Count:829
829
1320 -
1321 -
1322/*! -
1323 Constructs a tree widget item of the specified \a type. The item -
1324 must be inserted into a tree widget. -
1325 The given list of \a strings will be set as the item text for each -
1326 column in the item. -
1327 -
1328 \sa type() -
1329*/ -
1330QTreeWidgetItem::QTreeWidgetItem(const QStringList &strings, int type) -
1331 : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), -
1332 itemFlags(Qt::ItemIsSelectable -
1333 |Qt::ItemIsUserCheckable -
1334 |Qt::ItemIsEnabled -
1335 |Qt::ItemIsDragEnabled -
1336 |Qt::ItemIsDropEnabled) -
1337{ -
1338 for (int i = 0; i < strings.count(); ++i)
evaluated: i < strings.count()
TRUEFALSE
yes
Evaluation Count:1270
yes
Evaluation Count:1234
1234-1270
1339 setText(i, strings.at(i));
executed: setText(i, strings.at(i));
Execution Count:1270
1270
1340}
executed: }
Execution Count:1234
1234
1341 -
1342/*! -
1343 \fn QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *parent, int type) -
1344 -
1345 Constructs a tree widget item of the specified \a type and appends it -
1346 to the items in the given \a parent. -
1347 -
1348 \sa type() -
1349*/ -
1350 -
1351QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, int type) -
1352 : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), -
1353 itemFlags(Qt::ItemIsSelectable -
1354 |Qt::ItemIsUserCheckable -
1355 |Qt::ItemIsEnabled -
1356 |Qt::ItemIsDragEnabled -
1357 |Qt::ItemIsDropEnabled) -
1358{ -
1359 if (view && view->model()) {
evaluated: view
TRUEFALSE
yes
Evaluation Count:361
yes
Evaluation Count:1
partially evaluated: view->model()
TRUEFALSE
yes
Evaluation Count:361
no
Evaluation Count:0
0-361
1360 QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
executed (the execution status of this line is deduced): QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
-
1361 model->rootItem->addChild(this);
executed (the execution status of this line is deduced): model->rootItem->addChild(this);
-
1362 values.reserve(model->headerItem->columnCount());
executed (the execution status of this line is deduced): values.reserve(model->headerItem->columnCount());
-
1363 }
executed: }
Execution Count:361
361
1364}
executed: }
Execution Count:362
362
1365 -
1366/*! -
1367 \fn QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *parent, const QStringList &strings, int type) -
1368 -
1369 Constructs a tree widget item of the specified \a type and appends it -
1370 to the items in the given \a parent. The given list of \a strings will be set as -
1371 the item text for each column in the item. -
1372 -
1373 \sa type() -
1374*/ -
1375 -
1376QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, const QStringList &strings, int type) -
1377 : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), -
1378 itemFlags(Qt::ItemIsSelectable -
1379 |Qt::ItemIsUserCheckable -
1380 |Qt::ItemIsEnabled -
1381 |Qt::ItemIsDragEnabled -
1382 |Qt::ItemIsDropEnabled) -
1383{ -
1384 for (int i = 0; i < strings.count(); ++i)
evaluated: i < strings.count()
TRUEFALSE
yes
Evaluation Count:2828
yes
Evaluation Count:2828
2828
1385 setText(i, strings.at(i));
executed: setText(i, strings.at(i));
Execution Count:2828
2828
1386 if (view && view->model()) {
evaluated: view
TRUEFALSE
yes
Evaluation Count:2808
yes
Evaluation Count:20
partially evaluated: view->model()
TRUEFALSE
yes
Evaluation Count:2808
no
Evaluation Count:0
0-2808
1387 QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
executed (the execution status of this line is deduced): QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
-
1388 model->rootItem->addChild(this);
executed (the execution status of this line is deduced): model->rootItem->addChild(this);
-
1389 values.reserve(model->headerItem->columnCount());
executed (the execution status of this line is deduced): values.reserve(model->headerItem->columnCount());
-
1390 }
executed: }
Execution Count:2808
2808
1391}
executed: }
Execution Count:2828
2828
1392 -
1393/*! -
1394 \fn QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *parent, QTreeWidgetItem *preceding, int type) -
1395 -
1396 Constructs a tree widget item of the specified \a type and inserts it into -
1397 the given \a parent after the \a preceding item. -
1398 -
1399 \sa type() -
1400*/ -
1401QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, QTreeWidgetItem *after, int type) -
1402 : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), -
1403 itemFlags(Qt::ItemIsSelectable -
1404 |Qt::ItemIsUserCheckable -
1405 |Qt::ItemIsEnabled -
1406 |Qt::ItemIsDragEnabled -
1407 |Qt::ItemIsDropEnabled) -
1408{ -
1409 if (view) {
partially evaluated: view
TRUEFALSE
yes
Evaluation Count:1103
no
Evaluation Count:0
0-1103
1410 QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
executed (the execution status of this line is deduced): QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
-
1411 if (model) {
partially evaluated: model
TRUEFALSE
yes
Evaluation Count:1103
no
Evaluation Count:0
0-1103
1412 int i = model->rootItem->children.indexOf(after) + 1;
executed (the execution status of this line is deduced): int i = model->rootItem->children.indexOf(after) + 1;
-
1413 model->rootItem->insertChild(i, this);
executed (the execution status of this line is deduced): model->rootItem->insertChild(i, this);
-
1414 values.reserve(model->headerItem->columnCount());
executed (the execution status of this line is deduced): values.reserve(model->headerItem->columnCount());
-
1415 }
executed: }
Execution Count:1103
1103
1416 }
executed: }
Execution Count:1103
1103
1417}
executed: }
Execution Count:1103
1103
1418 -
1419/*! -
1420 Constructs a tree widget item and append it to the given \a parent. -
1421 -
1422 \sa type() -
1423*/ -
1424QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, int type) -
1425 : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), -
1426 itemFlags(Qt::ItemIsSelectable -
1427 |Qt::ItemIsUserCheckable -
1428 |Qt::ItemIsEnabled -
1429 |Qt::ItemIsDragEnabled -
1430 |Qt::ItemIsDropEnabled) -
1431{ -
1432 if (parent)
partially evaluated: parent
TRUEFALSE
yes
Evaluation Count:7198
no
Evaluation Count:0
0-7198
1433 parent->addChild(this);
executed: parent->addChild(this);
Execution Count:7198
7198
1434}
executed: }
Execution Count:7198
7198
1435 -
1436/*! -
1437 Constructs a tree widget item and append it to the given \a parent. -
1438 The given list of \a strings will be set as the item text for each column in the item. -
1439 -
1440 \sa type() -
1441*/ -
1442QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, const QStringList &strings, int type) -
1443 : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), -
1444 itemFlags(Qt::ItemIsSelectable -
1445 |Qt::ItemIsUserCheckable -
1446 |Qt::ItemIsEnabled -
1447 |Qt::ItemIsDragEnabled -
1448 |Qt::ItemIsDropEnabled) -
1449{ -
1450 for (int i = 0; i < strings.count(); ++i)
evaluated: i < strings.count()
TRUEFALSE
yes
Evaluation Count:54580
yes
Evaluation Count:54575
54575-54580
1451 setText(i, strings.at(i));
executed: setText(i, strings.at(i));
Execution Count:54580
54580
1452 if (parent)
partially evaluated: parent
TRUEFALSE
yes
Evaluation Count:54575
no
Evaluation Count:0
0-54575
1453 parent->addChild(this);
executed: parent->addChild(this);
Execution Count:54575
54575
1454}
executed: }
Execution Count:54575
54575
1455 -
1456/*! -
1457 \fn QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *preceding, int type) -
1458 -
1459 Constructs a tree widget item of the specified \a type that is inserted -
1460 into the \a parent after the \a preceding child item. -
1461 -
1462 \sa type() -
1463*/ -
1464QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after, int type) -
1465 : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), -
1466 itemFlags(Qt::ItemIsSelectable -
1467 |Qt::ItemIsUserCheckable -
1468 |Qt::ItemIsEnabled -
1469 |Qt::ItemIsDragEnabled -
1470 |Qt::ItemIsDropEnabled) -
1471{ -
1472 if (parent) {
partially evaluated: parent
TRUEFALSE
yes
Evaluation Count:1000
no
Evaluation Count:0
0-1000
1473 int i = parent->children.indexOf(after) + 1;
executed (the execution status of this line is deduced): int i = parent->children.indexOf(after) + 1;
-
1474 parent->insertChild(i, this);
executed (the execution status of this line is deduced): parent->insertChild(i, this);
-
1475 }
executed: }
Execution Count:1000
1000
1476}
executed: }
Execution Count:1000
1000
1477 -
1478/*! -
1479 Destroys this tree widget item. -
1480 -
1481 The item will be removed from \l{QTreeWidget}s to which it has -
1482 been added. This makes it safe to delete an item at any time. -
1483 -
1484*/ -
1485 -
1486QTreeWidgetItem::~QTreeWidgetItem() -
1487{ -
1488 QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
evaluated: view
TRUEFALSE
yes
Evaluation Count:1488
yes
Evaluation Count:67614
1488-67614
1489 bool wasSkipSort = false;
executed (the execution status of this line is deduced): bool wasSkipSort = false;
-
1490 if (model) {
evaluated: model
TRUEFALSE
yes
Evaluation Count:1488
yes
Evaluation Count:67614
1488-67614
1491 wasSkipSort = model->skipPendingSort;
executed (the execution status of this line is deduced): wasSkipSort = model->skipPendingSort;
-
1492 model->skipPendingSort = true;
executed (the execution status of this line is deduced): model->skipPendingSort = true;
-
1493 }
executed: }
Execution Count:1488
1488
1494 if (par) {
evaluated: par
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:69021
81-69021
1495 int i = par->children.indexOf(this);
executed (the execution status of this line is deduced): int i = par->children.indexOf(this);
-
1496 if (i >= 0) {
partially evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:81
no
Evaluation Count:0
0-81
1497 if (model) model->beginRemoveItems(par, i, 1);
executed: model->beginRemoveItems(par, i, 1);
Execution Count:69
evaluated: model
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:12
12-69
1498 // users _could_ do changes when connected to rowsAboutToBeRemoved, -
1499 // so we check again to make sure 'i' is valid -
1500 if (!par->children.isEmpty() && par->children.at(i) == this)
partially evaluated: !par->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:81
no
Evaluation Count:0
partially evaluated: par->children.at(i) == this
TRUEFALSE
yes
Evaluation Count:81
no
Evaluation Count:0
0-81
1501 par->children.takeAt(i);
executed: par->children.takeAt(i);
Execution Count:81
81
1502 if (model) model->endRemoveItems();
executed: model->endRemoveItems();
Execution Count:69
evaluated: model
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:12
12-69
1503 }
executed: }
Execution Count:81
81
1504 } else if (model) {
executed: }
Execution Count:81
evaluated: model
TRUEFALSE
yes
Evaluation Count:1419
yes
Evaluation Count:67602
81-67602
1505 if (this == model->headerItem) {
evaluated: this == model->headerItem
TRUEFALSE
yes
Evaluation Count:273
yes
Evaluation Count:1146
273-1146
1506 model->headerItem = 0;
executed (the execution status of this line is deduced): model->headerItem = 0;
-
1507 } else {
executed: }
Execution Count:273
273
1508 int i = model->rootItem->children.indexOf(this);
executed (the execution status of this line is deduced): int i = model->rootItem->children.indexOf(this);
-
1509 if (i >= 0) {
partially evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:1146
no
Evaluation Count:0
0-1146
1510 model->beginRemoveItems(0, i, 1);
executed (the execution status of this line is deduced): model->beginRemoveItems(0, i, 1);
-
1511 // users _could_ do changes when connected to rowsAboutToBeRemoved, -
1512 // so we check again to make sure 'i' is valid -
1513 if (!model->rootItem->children.isEmpty() && model->rootItem->children.at(i) == this)
partially evaluated: !model->rootItem->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:1146
no
Evaluation Count:0
partially evaluated: model->rootItem->children.at(i) == this
TRUEFALSE
yes
Evaluation Count:1146
no
Evaluation Count:0
0-1146
1514 model->rootItem->children.takeAt(i);
executed: model->rootItem->children.takeAt(i);
Execution Count:1146
1146
1515 model->endRemoveItems();
executed (the execution status of this line is deduced): model->endRemoveItems();
-
1516 }
executed: }
Execution Count:1146
1146
1517 }
executed: }
Execution Count:1146
1146
1518 } -
1519 // at this point the persistent indexes for the children should also be invalidated -
1520 // since we invalidated the parent -
1521 for (int i = 0; i < children.count(); ++i) {
evaluated: i < children.count()
TRUEFALSE
yes
Evaluation Count:63018
yes
Evaluation Count:69102
63018-69102
1522 QTreeWidgetItem *child = children.at(i);
executed (the execution status of this line is deduced): QTreeWidgetItem *child = children.at(i);
-
1523 // make sure the child does not try to remove itself from our children list -
1524 child->par = 0;
executed (the execution status of this line is deduced): child->par = 0;
-
1525 // make sure the child does not try to remove itself from the top level list -
1526 child->view = 0;
executed (the execution status of this line is deduced): child->view = 0;
-
1527 delete child;
executed (the execution status of this line is deduced): delete child;
-
1528 }
executed: }
Execution Count:63018
63018
1529 -
1530 children.clear();
executed (the execution status of this line is deduced): children.clear();
-
1531 delete d;
executed (the execution status of this line is deduced): delete d;
-
1532 if (model) {
evaluated: model
TRUEFALSE
yes
Evaluation Count:1488
yes
Evaluation Count:67614
1488-67614
1533 model->skipPendingSort = wasSkipSort;
executed (the execution status of this line is deduced): model->skipPendingSort = wasSkipSort;
-
1534 }
executed: }
Execution Count:1488
1488
1535}
executed: }
Execution Count:69102
69102
1536 -
1537/*! -
1538 Creates a deep copy of the item and of its children. -
1539*/ -
1540QTreeWidgetItem *QTreeWidgetItem::clone() const -
1541{ -
1542 QTreeWidgetItem *copy = 0;
executed (the execution status of this line is deduced): QTreeWidgetItem *copy = 0;
-
1543 -
1544 QStack<const QTreeWidgetItem*> stack;
executed (the execution status of this line is deduced): QStack<const QTreeWidgetItem*> stack;
-
1545 QStack<QTreeWidgetItem*> parentStack;
executed (the execution status of this line is deduced): QStack<QTreeWidgetItem*> parentStack;
-
1546 stack.push(this);
executed (the execution status of this line is deduced): stack.push(this);
-
1547 parentStack.push(0);
executed (the execution status of this line is deduced): parentStack.push(0);
-
1548 -
1549 QTreeWidgetItem *root = 0;
executed (the execution status of this line is deduced): QTreeWidgetItem *root = 0;
-
1550 const QTreeWidgetItem *item = 0;
executed (the execution status of this line is deduced): const QTreeWidgetItem *item = 0;
-
1551 QTreeWidgetItem *parent = 0;
executed (the execution status of this line is deduced): QTreeWidgetItem *parent = 0;
-
1552 while (!stack.isEmpty()) {
evaluated: !stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:3
3-5
1553 // get current item, and copied parent -
1554 item = stack.pop();
executed (the execution status of this line is deduced): item = stack.pop();
-
1555 parent = parentStack.pop();
executed (the execution status of this line is deduced): parent = parentStack.pop();
-
1556 -
1557 // copy item -
1558 copy = new QTreeWidgetItem(*item);
executed (the execution status of this line is deduced): copy = new QTreeWidgetItem(*item);
-
1559 if (!root)
evaluated: !root
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
1560 root = copy;
executed: root = copy;
Execution Count:3
3
1561 -
1562 // set parent and add to parents children list -
1563 if (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-3
1564 copy->par = parent;
executed (the execution status of this line is deduced): copy->par = parent;
-
1565 parent->children.insert(0, copy);
executed (the execution status of this line is deduced): parent->children.insert(0, copy);
-
1566 }
executed: }
Execution Count:2
2
1567 -
1568 for (int i = 0; i < item->childCount(); ++i) {
evaluated: i < item->childCount()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
1569 stack.push(item->child(i));
executed (the execution status of this line is deduced): stack.push(item->child(i));
-
1570 parentStack.push(copy);
executed (the execution status of this line is deduced): parentStack.push(copy);
-
1571 }
executed: }
Execution Count:2
2
1572 }
executed: }
Execution Count:5
5
1573 return root;
executed: return root;
Execution Count:3
3
1574} -
1575 -
1576/*! -
1577 Sets the item indicator \a policy. This policy decides when the -
1578 tree branch expand/collapse indicator is shown. -
1579 The default value is ShowForChildren. -
1580 -
1581 \sa childIndicatorPolicy() -
1582*/ -
1583void QTreeWidgetItem::setChildIndicatorPolicy(QTreeWidgetItem::ChildIndicatorPolicy policy) -
1584{ -
1585 if (d->policy == policy)
partially evaluated: d->policy == policy
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1586 return;
never executed: return;
0
1587 d->policy = policy;
executed (the execution status of this line is deduced): d->policy = policy;
-
1588 -
1589 if (!view)
partially evaluated: !view
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1590 return;
never executed: return;
0
1591 -
1592 view->scheduleDelayedItemsLayout();
executed (the execution status of this line is deduced): view->scheduleDelayedItemsLayout();
-
1593}
executed: }
Execution Count:3
3
1594 -
1595/*! -
1596 Returns the item indicator policy. This policy decides when the -
1597 tree branch expand/collapse indicator is shown. -
1598 -
1599 \sa setChildIndicatorPolicy() -
1600*/ -
1601QTreeWidgetItem::ChildIndicatorPolicy QTreeWidgetItem::childIndicatorPolicy() const -
1602{ -
1603 return d->policy;
never executed: return d->policy;
0
1604} -
1605 -
1606/*! -
1607 \fn void QTreeWidgetItem::setFlags(Qt::ItemFlags flags) -
1608 -
1609 Sets the flags for the item to the given \a flags. These determine whether -
1610 the item can be selected or modified. This is often used to disable an item. -
1611 -
1612 \sa flags() -
1613*/ -
1614void QTreeWidgetItem::setFlags(Qt::ItemFlags flags) -
1615{ -
1616 const bool enable = (flags & Qt::ItemIsEnabled);
executed (the execution status of this line is deduced): const bool enable = (flags & Qt::ItemIsEnabled);
-
1617 const bool changedState = bool(itemFlags & Qt::ItemIsEnabled) != enable;
executed (the execution status of this line is deduced): const bool changedState = bool(itemFlags & Qt::ItemIsEnabled) != enable;
-
1618 const bool changedExplicit = d->disabled != !enable;
executed (the execution status of this line is deduced): const bool changedExplicit = d->disabled != !enable;
-
1619 -
1620 d->disabled = !enable;
executed (the execution status of this line is deduced): d->disabled = !enable;
-
1621 -
1622 if (enable && par && !(par->itemFlags & Qt::ItemIsEnabled)) // inherit from parent
evaluated: enable
TRUEFALSE
yes
Evaluation Count:191
yes
Evaluation Count:33
evaluated: par
TRUEFALSE
yes
Evaluation Count:153
yes
Evaluation Count:38
evaluated: !(par->itemFlags & Qt::ItemIsEnabled)
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:144
9-191
1623 itemFlags = flags & ~Qt::ItemIsEnabled;
executed: itemFlags = flags & ~Qt::ItemIsEnabled;
Execution Count:9
9
1624 else // this item is explicitly disabled or has no parent -
1625 itemFlags = flags;
executed: itemFlags = flags;
Execution Count:215
215
1626 -
1627 if (changedState && changedExplicit) { // if the propagate the change to the children
evaluated: changedState
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:183
evaluated: changedExplicit
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:9
9-183
1628 QStack<QTreeWidgetItem*> parents;
executed (the execution status of this line is deduced): QStack<QTreeWidgetItem*> parents;
-
1629 parents.push(this);
executed (the execution status of this line is deduced): parents.push(this);
-
1630 while (!parents.isEmpty()) {
evaluated: !parents.isEmpty()
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:32
32-57
1631 QTreeWidgetItem *parent = parents.pop();
executed (the execution status of this line is deduced): QTreeWidgetItem *parent = parents.pop();
-
1632 for (int i = 0; i < parent->children.count(); ++i) {
evaluated: i < parent->children.count()
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:57
26-57
1633 QTreeWidgetItem *child = parent->children.at(i);
executed (the execution status of this line is deduced): QTreeWidgetItem *child = parent->children.at(i);
-
1634 if (!child->d->disabled) { // if not explicitly disabled
evaluated: !child->d->disabled
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:1
1-25
1635 parents.push(child);
executed (the execution status of this line is deduced): parents.push(child);
-
1636 if (enable)
evaluated: enable
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:13
12-13
1637 child->itemFlags = child->itemFlags | Qt::ItemIsEnabled;
executed: child->itemFlags = child->itemFlags | Qt::ItemIsEnabled;
Execution Count:12
12
1638 else -
1639 child->itemFlags = child->itemFlags & ~Qt::ItemIsEnabled;
executed: child->itemFlags = child->itemFlags & ~Qt::ItemIsEnabled;
Execution Count:13
13
1640 child->itemChanged(); // ### we may want to optimize this
executed (the execution status of this line is deduced): child->itemChanged();
-
1641 }
executed: }
Execution Count:25
25
1642 }
executed: }
Execution Count:26
26
1643 }
executed: }
Execution Count:57
57
1644 }
executed: }
Execution Count:32
32
1645 itemChanged();
executed (the execution status of this line is deduced): itemChanged();
-
1646}
executed: }
Execution Count:224
224
1647 -
1648void QTreeWidgetItemPrivate::propagateDisabled(QTreeWidgetItem *item) -
1649{ -
1650 Q_ASSERT(item);
executed (the execution status of this line is deduced): qt_noop();
-
1651 const bool enable = item->par ? (item->par->itemFlags.testFlag(Qt::ItemIsEnabled)) : true;
evaluated: item->par
TRUEFALSE
yes
Evaluation Count:63139
yes
Evaluation Count:36
36-63139
1652 -
1653 QStack<QTreeWidgetItem*> parents;
executed (the execution status of this line is deduced): QStack<QTreeWidgetItem*> parents;
-
1654 parents.push(item);
executed (the execution status of this line is deduced): parents.push(item);
-
1655 while (!parents.isEmpty()) {
evaluated: !parents.isEmpty()
TRUEFALSE
yes
Evaluation Count:63192
yes
Evaluation Count:63175
63175-63192
1656 QTreeWidgetItem *parent = parents.pop();
executed (the execution status of this line is deduced): QTreeWidgetItem *parent = parents.pop();
-
1657 if (!parent->d->disabled) { // if not explicitly disabled
partially evaluated: !parent->d->disabled
TRUEFALSE
yes
Evaluation Count:63192
no
Evaluation Count:0
0-63192
1658 Qt::ItemFlags oldFlags = parent->itemFlags;
executed (the execution status of this line is deduced): Qt::ItemFlags oldFlags = parent->itemFlags;
-
1659 if (enable)
evaluated: enable
TRUEFALSE
yes
Evaluation Count:63169
yes
Evaluation Count:23
23-63169
1660 parent->itemFlags = parent->itemFlags | Qt::ItemIsEnabled;
executed: parent->itemFlags = parent->itemFlags | Qt::ItemIsEnabled;
Execution Count:63169
63169
1661 else -
1662 parent->itemFlags = parent->itemFlags & ~Qt::ItemIsEnabled;
executed: parent->itemFlags = parent->itemFlags & ~Qt::ItemIsEnabled;
Execution Count:23
23
1663 if (parent->itemFlags != oldFlags)
evaluated: parent->itemFlags != oldFlags
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:63163
29-63163
1664 parent->itemChanged();
executed: parent->itemChanged();
Execution Count:29
29
1665 }
executed: }
Execution Count:63192
63192
1666 -
1667 for (int i = 0; i < parent->children.count(); ++i) {
evaluated: i < parent->children.count()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:63192
17-63192
1668 QTreeWidgetItem *child = parent->children.at(i);
executed (the execution status of this line is deduced): QTreeWidgetItem *child = parent->children.at(i);
-
1669 parents.push(child);
executed (the execution status of this line is deduced): parents.push(child);
-
1670 }
executed: }
Execution Count:17
17
1671 }
executed: }
Execution Count:63192
63192
1672}
executed: }
Execution Count:63175
63175
1673/*! -
1674 \fn Qt::ItemFlags QTreeWidgetItem::flags() const -
1675 -
1676 Returns the flags used to describe the item. These determine whether -
1677 the item can be checked, edited, and selected. -
1678 -
1679 The default value for flags is -
1680 Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled. -
1681 If the item was constructed with a parent, flags will in addition contain Qt::ItemIsDropEnabled. -
1682 -
1683 \sa setFlags() -
1684*/ -
1685Qt::ItemFlags QTreeWidgetItem::flags() const -
1686{ -
1687 return itemFlags;
executed: return itemFlags;
Execution Count:17359
17359
1688} -
1689 -
1690/*! -
1691 Sets the value for the item's \a column and \a role to the given -
1692 \a value. -
1693 -
1694 The \a role describes the type of data specified by \a value, and is defined by -
1695 the Qt::ItemDataRole enum. -
1696*/ -
1697void QTreeWidgetItem::setData(int column, int role, const QVariant &value) -
1698{ -
1699 if (column < 0)
evaluated: column < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:65150
1-65150
1700 return;
executed: return;
Execution Count:1
1
1701 -
1702 QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
evaluated: view
TRUEFALSE
yes
Evaluation Count:6410
yes
Evaluation Count:58740
6410-58740
1703 switch (role) { -
1704 case Qt::EditRole: -
1705 case Qt::DisplayRole: { -
1706 if (values.count() <= column) {
evaluated: values.count() <= column
TRUEFALSE
yes
Evaluation Count:64174
yes
Evaluation Count:253
253-64174
1707 if (model && this == model->headerItem)
evaluated: model
TRUEFALSE
yes
Evaluation Count:5438
yes
Evaluation Count:58736
evaluated: this == model->headerItem
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5437
1-58736
1708 model->setColumnCount(column + 1);
executed: model->setColumnCount(column + 1);
Execution Count:1
1
1709 else -
1710 values.resize(column + 1);
executed: values.resize(column + 1);
Execution Count:64173
64173
1711 } -
1712 if (d->display.count() <= column) {
evaluated: d->display.count() <= column
TRUEFALSE
yes
Evaluation Count:64173
yes
Evaluation Count:254
254-64173
1713 for (int i = d->display.count() - 1; i < column - 1; ++i)
evaluated: i < column - 1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:64173
6-64173
1714 d->display.append(QVariant());
executed: d->display.append(QVariant());
Execution Count:6
6
1715 d->display.append(value);
executed (the execution status of this line is deduced): d->display.append(value);
-
1716 } else if (d->display[column] != value) {
executed: }
Execution Count:64173
evaluated: d->display[column] != value
TRUEFALSE
yes
Evaluation Count:228
yes
Evaluation Count:26
26-64173
1717 d->display[column] = value;
executed (the execution status of this line is deduced): d->display[column] = value;
-
1718 } else {
executed: }
Execution Count:228
228
1719 return; // value is unchanged
executed: return;
Execution Count:26
26
1720 } -
1721 } break;
executed: break;
Execution Count:64401
64401
1722 case Qt::CheckStateRole: -
1723 if (itemFlags & Qt::ItemIsTristate) {
evaluated: itemFlags & Qt::ItemIsTristate
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:124
4-124
1724 for (int i = 0; i < children.count(); ++i) {
partially evaluated: i < children.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1725 QTreeWidgetItem *child = children.at(i);
never executed (the execution status of this line is deduced): QTreeWidgetItem *child = children.at(i);
-
1726 if (child->data(column, role).isValid()) {// has a CheckState
never evaluated: child->data(column, role).isValid()
0
1727 Qt::ItemFlags f = itemFlags; // a little hack to avoid multiple dataChanged signals
never executed (the execution status of this line is deduced): Qt::ItemFlags f = itemFlags;
-
1728 itemFlags &= ~Qt::ItemIsTristate;
never executed (the execution status of this line is deduced): itemFlags &= ~Qt::ItemIsTristate;
-
1729 child->setData(column, role, value);
never executed (the execution status of this line is deduced): child->setData(column, role, value);
-
1730 itemFlags = f;
never executed (the execution status of this line is deduced): itemFlags = f;
-
1731 }
never executed: }
0
1732 }
never executed: }
0
1733 }
executed: }
Execution Count:4
4
1734 // Don't break, but fall through -
1735 default:
code before this statement executed: default:
Execution Count:128
128
1736 if (column < values.count()) {
evaluated: column < values.count()
TRUEFALSE
yes
Evaluation Count:708
yes
Evaluation Count:15
15-708
1737 bool found = false;
executed (the execution status of this line is deduced): bool found = false;
-
1738 QVector<QWidgetItemData> column_values = values.at(column);
executed (the execution status of this line is deduced): QVector<QWidgetItemData> column_values = values.at(column);
-
1739 for (int i = 0; i < column_values.count(); ++i) {
evaluated: i < column_values.count()
TRUEFALSE
yes
Evaluation Count:3587
yes
Evaluation Count:111
111-3587
1740 if (column_values.at(i).role == role) {
evaluated: column_values.at(i).role == role
TRUEFALSE
yes
Evaluation Count:597
yes
Evaluation Count:2990
597-2990
1741 if (column_values.at(i).value == value)
evaluated: column_values.at(i).value == value
TRUEFALSE
yes
Evaluation Count:200
yes
Evaluation Count:397
200-397
1742 return; // value is unchanged
executed: return;
Execution Count:200
200
1743 values[column][i].value = value;
executed (the execution status of this line is deduced): values[column][i].value = value;
-
1744 found = true;
executed (the execution status of this line is deduced): found = true;
-
1745 break;
executed: break;
Execution Count:397
397
1746 } -
1747 }
executed: }
Execution Count:2990
2990
1748 if (!found)
evaluated: !found
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:397
111-397
1749 values[column].append(QWidgetItemData(role, value));
executed: values[column].append(QWidgetItemData(role, value));
Execution Count:111
111
1750 } else {
executed: }
Execution Count:508
508
1751 if (model && this == model->headerItem)
evaluated: model
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:2
partially evaluated: this == model->headerItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
1752 model->setColumnCount(column + 1);
never executed: model->setColumnCount(column + 1);
0
1753 else -
1754 values.resize(column + 1);
executed: values.resize(column + 1);
Execution Count:15
15
1755 values[column].append(QWidgetItemData(role, value));
executed (the execution status of this line is deduced): values[column].append(QWidgetItemData(role, value));
-
1756 }
executed: }
Execution Count:15
15
1757 } -
1758 -
1759 if (model) {
evaluated: model
TRUEFALSE
yes
Evaluation Count:6184
yes
Evaluation Count:58740
6184-58740
1760 model->emitDataChanged(this, column);
executed (the execution status of this line is deduced): model->emitDataChanged(this, column);
-
1761 if (role == Qt::CheckStateRole) {
evaluated: role == Qt::CheckStateRole
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:6080
104-6080
1762 QTreeWidgetItem *p;
executed (the execution status of this line is deduced): QTreeWidgetItem *p;
-
1763 for (p = par; p && (p->itemFlags & Qt::ItemIsTristate); p = p->par)
evaluated: p
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:50
evaluated: (p->itemFlags & Qt::ItemIsTristate)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:54
3-57
1764 model->emitDataChanged(p, column);
executed: model->emitDataChanged(p, column);
Execution Count:3
3
1765 }
executed: }
Execution Count:104
104
1766 }
executed: }
Execution Count:6184
6184
1767}
executed: }
Execution Count:64924
64924
1768 -
1769/*! -
1770 Returns the value for the item's \a column and \a role. -
1771*/ -
1772QVariant QTreeWidgetItem::data(int column, int role) const -
1773{ -
1774 switch (role) { -
1775 case Qt::EditRole: -
1776 case Qt::DisplayRole: -
1777 if (column >= 0 && column < d->display.count())
partially evaluated: column >= 0
TRUEFALSE
yes
Evaluation Count:21885
no
Evaluation Count:0
evaluated: column < d->display.count()
TRUEFALSE
yes
Evaluation Count:21666
yes
Evaluation Count:219
0-21885
1778 return d->display.at(column);
executed: return d->display.at(column);
Execution Count:21666
21666
1779 break;
executed: break;
Execution Count:219
219
1780 case Qt::CheckStateRole: -
1781 // special case for check state in tristate -
1782 if (children.count() && (itemFlags & Qt::ItemIsTristate))
evaluated: children.count()
TRUEFALSE
yes
Evaluation Count:708
yes
Evaluation Count:6278
evaluated: (itemFlags & Qt::ItemIsTristate)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:702
6-6278
1783 return childrenCheckState(column);
executed: return childrenCheckState(column);
Execution Count:6
6
1784 // fallthrough intended -
1785 default:
code before this statement executed: default:
Execution Count:6980
6980
1786 if (column >= 0 && column < values.size()) {
partially evaluated: column >= 0
TRUEFALSE
yes
Evaluation Count:19151
no
Evaluation Count:0
evaluated: column < values.size()
TRUEFALSE
yes
Evaluation Count:17818
yes
Evaluation Count:1333
0-19151
1787 const QVector<QWidgetItemData> &column_values = values.at(column);
executed (the execution status of this line is deduced): const QVector<QWidgetItemData> &column_values = values.at(column);
-
1788 for (int i = 0; i < column_values.count(); ++i)
evaluated: i < column_values.count()
TRUEFALSE
yes
Evaluation Count:7240
yes
Evaluation Count:16727
7240-16727
1789 if (column_values.at(i).role == role)
evaluated: column_values.at(i).role == role
TRUEFALSE
yes
Evaluation Count:1091
yes
Evaluation Count:6149
1091-6149
1790 return column_values.at(i).value;
executed: return column_values.at(i).value;
Execution Count:1091
1091
1791 }
executed: }
Execution Count:16727
16727
1792 }
executed: }
Execution Count:18060
18060
1793 return QVariant();
executed: return QVariant();
Execution Count:18279
18279
1794} -
1795 -
1796/*! -
1797 Returns true if the text in the item is less than the text in the -
1798 \a other item, otherwise returns false. -
1799*/ -
1800 -
1801bool QTreeWidgetItem::operator<(const QTreeWidgetItem &other) const -
1802{ -
1803 int column = view ? view->sortColumn() : 0;
partially evaluated: view
TRUEFALSE
yes
Evaluation Count:7597
no
Evaluation Count:0
0-7597
1804 const QVariant v1 = data(column, Qt::DisplayRole);
executed (the execution status of this line is deduced): const QVariant v1 = data(column, Qt::DisplayRole);
-
1805 const QVariant v2 = other.data(column, Qt::DisplayRole);
executed (the execution status of this line is deduced): const QVariant v2 = other.data(column, Qt::DisplayRole);
-
1806 return QAbstractItemModelPrivate::variantLessThan(v1, v2);
executed: return QAbstractItemModelPrivate::variantLessThan(v1, v2);
Execution Count:7597
7597
1807} -
1808 -
1809#ifndef QT_NO_DATASTREAM -
1810 -
1811/*! -
1812 Reads the item from stream \a in. This only reads data into a single item. -
1813 -
1814 \sa write() -
1815*/ -
1816void QTreeWidgetItem::read(QDataStream &in) -
1817{ -
1818 // convert from streams written before we introduced display (4.2.0) -
1819 if (in.version() < QDataStream::Qt_4_2) {
partially evaluated: in.version() < QDataStream::Qt_4_2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1820 d->display.clear();
never executed (the execution status of this line is deduced): d->display.clear();
-
1821 in >> values;
never executed (the execution status of this line is deduced): in >> values;
-
1822 // move the display value over to the display string list -
1823 for (int column = 0; column < values.count(); ++column) {
never evaluated: column < values.count()
0
1824 d->display << QVariant();
never executed (the execution status of this line is deduced): d->display << QVariant();
-
1825 for (int i = 0; i < values.at(column).count(); ++i) {
never evaluated: i < values.at(column).count()
0
1826 if (values.at(column).at(i).role == Qt::DisplayRole) {
never evaluated: values.at(column).at(i).role == Qt::DisplayRole
0
1827 d->display[column] = values.at(column).at(i).value;
never executed (the execution status of this line is deduced): d->display[column] = values.at(column).at(i).value;
-
1828 values[column].remove(i--);
never executed (the execution status of this line is deduced): values[column].remove(i--);
-
1829 }
never executed: }
0
1830 }
never executed: }
0
1831 }
never executed: }
0
1832 } else {
never executed: }
0
1833 in >> values >> d->display;
executed (the execution status of this line is deduced): in >> values >> d->display;
-
1834 }
executed: }
Execution Count:1
1
1835} -
1836 -
1837/*! -
1838 Writes the item to stream \a out. This only writes data from one single item. -
1839 -
1840 \sa read() -
1841*/ -
1842void QTreeWidgetItem::write(QDataStream &out) const -
1843{ -
1844 out << values << d->display;
executed (the execution status of this line is deduced): out << values << d->display;
-
1845}
executed: }
Execution Count:1
1
1846#endif // QT_NO_DATASTREAM -
1847 -
1848/*! -
1849 \since 4.1 -
1850 -
1851 Constructs a copy of \a other. Note that type() and treeWidget() -
1852 are not copied. -
1853 -
1854 This function is useful when reimplementing clone(). -
1855 -
1856 \sa data(), flags() -
1857*/ -
1858QTreeWidgetItem::QTreeWidgetItem(const QTreeWidgetItem &other) -
1859 : rtti(Type), values(other.values), view(0), -
1860 d(new QTreeWidgetItemPrivate(this)), par(0), -
1861 itemFlags(other.itemFlags) -
1862{ -
1863 d->display = other.d->display;
executed (the execution status of this line is deduced): d->display = other.d->display;
-
1864}
executed: }
Execution Count:5
5
1865 -
1866/*! -
1867 Assigns \a other's data and flags to this item. Note that type() -
1868 and treeWidget() are not copied. -
1869 -
1870 This function is useful when reimplementing clone(). -
1871 -
1872 \sa data(), flags() -
1873*/ -
1874QTreeWidgetItem &QTreeWidgetItem::operator=(const QTreeWidgetItem &other) -
1875{ -
1876 values = other.values;
executed (the execution status of this line is deduced): values = other.values;
-
1877 d->display = other.d->display;
executed (the execution status of this line is deduced): d->display = other.d->display;
-
1878 d->policy = other.d->policy;
executed (the execution status of this line is deduced): d->policy = other.d->policy;
-
1879 itemFlags = other.itemFlags;
executed (the execution status of this line is deduced): itemFlags = other.itemFlags;
-
1880 return *this;
executed: return *this;
Execution Count:1
1
1881} -
1882 -
1883/*! -
1884 Appends the \a child item to the list of children. -
1885 -
1886 \sa insertChild(), takeChild() -
1887*/ -
1888void QTreeWidgetItem::addChild(QTreeWidgetItem *child) -
1889{ -
1890 if (child) {
evaluated: child
TRUEFALSE
yes
Evaluation Count:65123
yes
Evaluation Count:2
2-65123
1891 insertChild(children.count(), child);
executed (the execution status of this line is deduced): insertChild(children.count(), child);
-
1892 child->d->rowGuess = children.count() - 1;
executed (the execution status of this line is deduced): child->d->rowGuess = children.count() - 1;
-
1893 }
executed: }
Execution Count:65123
65123
1894}
executed: }
Execution Count:65125
65125
1895 -
1896/*! -
1897 Inserts the \a child item at \a index in the list of children. -
1898 -
1899 If the child has already been inserted somewhere else it won't be inserted again. -
1900*/ -
1901void QTreeWidgetItem::insertChild(int index, QTreeWidgetItem *child) -
1902{ -
1903 if (index < 0 || index > children.count() || child == 0 || child->view != 0 || child->par != 0)
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:68183
evaluated: index > children.count()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:68181
evaluated: child == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:68180
evaluated: child->view != 0
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:68160
evaluated: child->par != 0
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:68150
1-68183
1904 return;
executed: return;
Execution Count:35
35
1905 -
1906 if (QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0)) {
evaluated: view
TRUEFALSE
yes
Evaluation Count:68095
yes
Evaluation Count:55
55-68095
1907 const bool wasSkipSort = model->skipPendingSort;
executed (the execution status of this line is deduced): const bool wasSkipSort = model->skipPendingSort;
-
1908 model->skipPendingSort = true;
executed (the execution status of this line is deduced): model->skipPendingSort = true;
-
1909 if (model->rootItem == this)
evaluated: model->rootItem == this
TRUEFALSE
yes
Evaluation Count:5214
yes
Evaluation Count:62881
5214-62881
1910 child->par = 0;
executed: child->par = 0;
Execution Count:5214
5214
1911 else -
1912 child->par = this;
executed: child->par = this;
Execution Count:62881
62881
1913 if (view->isSortingEnabled()) {
evaluated: view->isSortingEnabled()
TRUEFALSE
yes
Evaluation Count:1067
yes
Evaluation Count:67028
1067-67028
1914 // do a delayed sort instead -
1915 if (!model->sortPendingTimer.isActive())
evaluated: !model->sortPendingTimer.isActive()
TRUEFALSE
yes
Evaluation Count:229
yes
Evaluation Count:838
229-838
1916 model->sortPendingTimer.start(0, model);
executed: model->sortPendingTimer.start(0, model);
Execution Count:229
229
1917 }
executed: }
Execution Count:1067
1067
1918 model->beginInsertItems(this, index, 1);
executed (the execution status of this line is deduced): model->beginInsertItems(this, index, 1);
-
1919 int cols = model->columnCount();
executed (the execution status of this line is deduced): int cols = model->columnCount();
-
1920 QStack<QTreeWidgetItem*> stack;
executed (the execution status of this line is deduced): QStack<QTreeWidgetItem*> stack;
-
1921 stack.push(child);
executed (the execution status of this line is deduced): stack.push(child);
-
1922 while (!stack.isEmpty()) {
evaluated: !stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:68104
yes
Evaluation Count:68095
68095-68104
1923 QTreeWidgetItem *i = stack.pop();
executed (the execution status of this line is deduced): QTreeWidgetItem *i = stack.pop();
-
1924 i->view = view;
executed (the execution status of this line is deduced): i->view = view;
-
1925 i->values.reserve(cols);
executed (the execution status of this line is deduced): i->values.reserve(cols);
-
1926 for (int c = 0; c < i->children.count(); ++c)
evaluated: c < i->children.count()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:68104
9-68104
1927 stack.push(i->children.at(c));
executed: stack.push(i->children.at(c));
Execution Count:9
9
1928 }
executed: }
Execution Count:68104
68104
1929 children.insert(index, child);
executed (the execution status of this line is deduced): children.insert(index, child);
-
1930 model->endInsertItems();
executed (the execution status of this line is deduced): model->endInsertItems();
-
1931 model->skipPendingSort = wasSkipSort;
executed (the execution status of this line is deduced): model->skipPendingSort = wasSkipSort;
-
1932 } else {
executed: }
Execution Count:68095
68095
1933 child->par = this;
executed (the execution status of this line is deduced): child->par = this;
-
1934 children.insert(index, child);
executed (the execution status of this line is deduced): children.insert(index, child);
-
1935 }
executed: }
Execution Count:55
55
1936 if (child->par)
evaluated: child->par
TRUEFALSE
yes
Evaluation Count:62936
yes
Evaluation Count:5214
5214-62936
1937 d->propagateDisabled(child);
executed: d->propagateDisabled(child);
Execution Count:62936
62936
1938}
executed: }
Execution Count:68150
68150
1939 -
1940/*! -
1941 Removes the given item indicated by \a child. -
1942 The removed item will not be deleted. -
1943*/ -
1944void QTreeWidgetItem::removeChild(QTreeWidgetItem *child) -
1945{ -
1946 (void)takeChild(children.indexOf(child));
executed (the execution status of this line is deduced): (void)takeChild(children.indexOf(child));
-
1947}
executed: }
Execution Count:2
2
1948 -
1949/*! -
1950 Removes the item at \a index and returns it, otherwise return 0. -
1951*/ -
1952QTreeWidgetItem *QTreeWidgetItem::takeChild(int index) -
1953{ -
1954 // we move this outside the check of the index to allow executing -
1955 // pending sorts from inline functions, using this function (hack) -
1956 QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
evaluated: view
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:1
1-16
1957 if (model) {
evaluated: model
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:1
1-16
1958 // This will trigger a layoutChanged signal, thus we might want to optimize -
1959 // this function by not emitting the rowsRemoved signal etc to the view. -
1960 // On the other hand we also need to make sure that the selectionmodel -
1961 // is updated in case we take an item that is selected. -
1962 model->skipPendingSort = false;
executed (the execution status of this line is deduced): model->skipPendingSort = false;
-
1963 model->executePendingSort();
executed (the execution status of this line is deduced): model->executePendingSort();
-
1964 }
executed: }
Execution Count:16
16
1965 if (index >= 0 && index < children.count()) {
evaluated: index >= 0
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:2
evaluated: index < children.count()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:2
2-15
1966 if (model) model->beginRemoveItems(this, index, 1);
executed: model->beginRemoveItems(this, index, 1);
Execution Count:12
evaluated: model
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
1967 QTreeWidgetItem *item = children.takeAt(index);
executed (the execution status of this line is deduced): QTreeWidgetItem *item = children.takeAt(index);
-
1968 item->par = 0;
executed (the execution status of this line is deduced): item->par = 0;
-
1969 QStack<QTreeWidgetItem*> stack;
executed (the execution status of this line is deduced): QStack<QTreeWidgetItem*> stack;
-
1970 stack.push(item);
executed (the execution status of this line is deduced): stack.push(item);
-
1971 while (!stack.isEmpty()) {
evaluated: !stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:13
13-26
1972 QTreeWidgetItem *i = stack.pop();
executed (the execution status of this line is deduced): QTreeWidgetItem *i = stack.pop();
-
1973 i->view = 0;
executed (the execution status of this line is deduced): i->view = 0;
-
1974 for (int c = 0; c < i->children.count(); ++c)
evaluated: c < i->children.count()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:26
13-26
1975 stack.push(i->children.at(c));
executed: stack.push(i->children.at(c));
Execution Count:13
13
1976 }
executed: }
Execution Count:26
26
1977 d->propagateDisabled(item);
executed (the execution status of this line is deduced): d->propagateDisabled(item);
-
1978 if (model) model->endRemoveRows();
executed: model->endRemoveRows();
Execution Count:12
evaluated: model
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
1979 return item;
executed: return item;
Execution Count:13
13
1980 } -
1981 return 0;
executed: return 0;
Execution Count:4
4
1982} -
1983 -
1984/*! -
1985 \since 4.1 -
1986 -
1987 Appends the given list of \a children to the item. -
1988 -
1989 \sa insertChildren(), takeChildren() -
1990*/ -
1991void QTreeWidgetItem::addChildren(const QList<QTreeWidgetItem*> &children) -
1992{ -
1993 insertChildren(this->children.count(), children);
executed (the execution status of this line is deduced): insertChildren(this->children.count(), children);
-
1994}
executed: }
Execution Count:43
43
1995 -
1996/*! -
1997 \since 4.1 -
1998 -
1999 Inserts the given list of \a children into the list of the item children at \a index . -
2000 -
2001 Children that have already been inserted somewhere else won't be inserted. -
2002*/ -
2003void QTreeWidgetItem::insertChildren(int index, const QList<QTreeWidgetItem*> &children) -
2004{ -
2005 if (view && view->isSortingEnabled()) {
evaluated: view
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:21
evaluated: view->isSortingEnabled()
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:46
21-70
2006 for (int n = 0; n < children.count(); ++n)
evaluated: n < children.count()
TRUEFALSE
yes
Evaluation Count:126
yes
Evaluation Count:24
24-126
2007 insertChild(index, children.at(n));
executed: insertChild(index, children.at(n));
Execution Count:126
126
2008 return;
executed: return;
Execution Count:24
24
2009 } -
2010 QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
evaluated: view
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:21
21-46
2011 QStack<QTreeWidgetItem*> stack;
executed (the execution status of this line is deduced): QStack<QTreeWidgetItem*> stack;
-
2012 QList<QTreeWidgetItem*> itemsToInsert;
executed (the execution status of this line is deduced): QList<QTreeWidgetItem*> itemsToInsert;
-
2013 for (int n = 0; n < children.count(); ++n) {
evaluated: n < children.count()
TRUEFALSE
yes
Evaluation Count:633
yes
Evaluation Count:67
67-633
2014 QTreeWidgetItem *child = children.at(n);
executed (the execution status of this line is deduced): QTreeWidgetItem *child = children.at(n);
-
2015 if (child->view || child->par)
evaluated: child->view
TRUEFALSE
yes
Evaluation Count:200
yes
Evaluation Count:433
evaluated: child->par
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:333
100-433
2016 continue;
executed: continue;
Execution Count:300
300
2017 itemsToInsert.append(child);
executed (the execution status of this line is deduced): itemsToInsert.append(child);
-
2018 if (view && model) {
evaluated: view
TRUEFALSE
yes
Evaluation Count:233
yes
Evaluation Count:100
partially evaluated: model
TRUEFALSE
yes
Evaluation Count:233
no
Evaluation Count:0
0-233
2019 if (child->childCount() == 0)
partially evaluated: child->childCount() == 0
TRUEFALSE
yes
Evaluation Count:233
no
Evaluation Count:0
0-233
2020 child->view = view;
executed: child->view = view;
Execution Count:233
233
2021 else -
2022 stack.push(child);
never executed: stack.push(child);
0
2023 } -
2024 if (model && (model->rootItem == this))
evaluated: model
TRUEFALSE
yes
Evaluation Count:233
yes
Evaluation Count:100
evaluated: (model->rootItem == this)
TRUEFALSE
yes
Evaluation Count:130
yes
Evaluation Count:103
100-233
2025 child->par = 0;
executed: child->par = 0;
Execution Count:130
130
2026 else -
2027 child->par = this;
executed: child->par = this;
Execution Count:203
203
2028 } -
2029 if (!itemsToInsert.isEmpty()) {
evaluated: !itemsToInsert.isEmpty()
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:33
33-34
2030 while (!stack.isEmpty()) {
partially evaluated: !stack.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-34
2031 QTreeWidgetItem *i = stack.pop();
never executed (the execution status of this line is deduced): QTreeWidgetItem *i = stack.pop();
-
2032 i->view = view;
never executed (the execution status of this line is deduced): i->view = view;
-
2033 for (int c = 0; c < i->children.count(); ++c)
never evaluated: c < i->children.count()
0
2034 stack.push(i->children.at(c));
never executed: stack.push(i->children.at(c));
0
2035 }
never executed: }
0
2036 if (model) model->beginInsertItems(this, index, itemsToInsert.count());
executed: model->beginInsertItems(this, index, itemsToInsert.count());
Execution Count:24
evaluated: model
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:10
10-24
2037 for (int n = 0; n < itemsToInsert.count(); ++n) {
evaluated: n < itemsToInsert.count()
TRUEFALSE
yes
Evaluation Count:333
yes
Evaluation Count:34
34-333
2038 QTreeWidgetItem *child = itemsToInsert.at(n);
executed (the execution status of this line is deduced): QTreeWidgetItem *child = itemsToInsert.at(n);
-
2039 this->children.insert(index + n, child);
executed (the execution status of this line is deduced): this->children.insert(index + n, child);
-
2040 if (child->par)
evaluated: child->par
TRUEFALSE
yes
Evaluation Count:203
yes
Evaluation Count:130
130-203
2041 d->propagateDisabled(child);
executed: d->propagateDisabled(child);
Execution Count:203
203
2042 }
executed: }
Execution Count:333
333
2043 if (model) model->endInsertItems();
executed: model->endInsertItems();
Execution Count:24
evaluated: model
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:10
10-24
2044 }
executed: }
Execution Count:34
34
2045}
executed: }
Execution Count:67
67
2046 -
2047/*! -
2048 \since 4.1 -
2049 -
2050 Removes the list of children and returns it, otherwise returns an empty list. -
2051*/ -
2052QList<QTreeWidgetItem*> QTreeWidgetItem::takeChildren() -
2053{ -
2054 QList<QTreeWidgetItem*> removed;
executed (the execution status of this line is deduced): QList<QTreeWidgetItem*> removed;
-
2055 if (children.count() > 0) {
partially evaluated: children.count() > 0
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2056 QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
evaluated: view
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
2057 if (model) {
evaluated: model
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
2058 // This will trigger a layoutChanged signal, thus we might want to optimize -
2059 // this function by not emitting the rowsRemoved signal etc to the view. -
2060 // On the other hand we also need to make sure that the selectionmodel -
2061 // is updated in case we take an item that is selected. -
2062 model->executePendingSort();
executed (the execution status of this line is deduced): model->executePendingSort();
-
2063 }
executed: }
Execution Count:2
2
2064 if (model) model->beginRemoveItems(this, 0, children.count());
executed: model->beginRemoveItems(this, 0, children.count());
Execution Count:2
evaluated: model
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
2065 for (int n = 0; n < children.count(); ++n) {
evaluated: n < children.count()
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:3
3-23
2066 QTreeWidgetItem *item = children.at(n);
executed (the execution status of this line is deduced): QTreeWidgetItem *item = children.at(n);
-
2067 item->par = 0;
executed (the execution status of this line is deduced): item->par = 0;
-
2068 QStack<QTreeWidgetItem*> stack;
executed (the execution status of this line is deduced): QStack<QTreeWidgetItem*> stack;
-
2069 stack.push(item);
executed (the execution status of this line is deduced): stack.push(item);
-
2070 while (!stack.isEmpty()) {
evaluated: !stack.isEmpty()
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:23
23
2071 QTreeWidgetItem *i = stack.pop();
executed (the execution status of this line is deduced): QTreeWidgetItem *i = stack.pop();
-
2072 i->view = 0;
executed (the execution status of this line is deduced): i->view = 0;
-
2073 for (int c = 0; c < i->children.count(); ++c)
partially evaluated: c < i->children.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
2074 stack.push(i->children.at(c));
never executed: stack.push(i->children.at(c));
0
2075 }
executed: }
Execution Count:23
23
2076 d->propagateDisabled(item);
executed (the execution status of this line is deduced): d->propagateDisabled(item);
-
2077 }
executed: }
Execution Count:23
23
2078 removed = children;
executed (the execution status of this line is deduced): removed = children;
-
2079 children.clear(); // detach
executed (the execution status of this line is deduced): children.clear();
-
2080 if (model) model->endRemoveItems();
executed: model->endRemoveItems();
Execution Count:2
evaluated: model
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
2081 }
executed: }
Execution Count:3
3
2082 return removed;
executed: return removed;
Execution Count:3
3
2083} -
2084 -
2085 -
2086void QTreeWidgetItemPrivate::sortChildren(int column, Qt::SortOrder order, bool climb) -
2087{ -
2088 QTreeModel *model = (q->view ? qobject_cast<QTreeModel*>(q->view->model()) : 0);
partially evaluated: q->view
TRUEFALSE
yes
Evaluation Count:3360
no
Evaluation Count:0
0-3360
2089 if (!model)
partially evaluated: !model
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3360
0-3360
2090 return;
never executed: return;
0
2091 model->sortItems(&q->children, column, order);
executed (the execution status of this line is deduced): model->sortItems(&q->children, column, order);
-
2092 if (climb) {
evaluated: climb
TRUEFALSE
yes
Evaluation Count:3358
yes
Evaluation Count:2
2-3358
2093 QList<QTreeWidgetItem*>::iterator it = q->children.begin();
executed (the execution status of this line is deduced): QList<QTreeWidgetItem*>::iterator it = q->children.begin();
-
2094 for (; it != q->children.end(); ++it) {
evaluated: it != q->children.end()
TRUEFALSE
yes
Evaluation Count:2903
yes
Evaluation Count:3358
2903-3358
2095 //here we call the private object's method to avoid emitting -
2096 //the layoutAboutToBeChanged and layoutChanged signals -
2097 (*it)->d->sortChildren(column, order, climb);
executed (the execution status of this line is deduced): (*it)->d->sortChildren(column, order, climb);
-
2098 }
executed: }
Execution Count:2903
2903
2099 }
executed: }
Execution Count:3358
3358
2100}
executed: }
Execution Count:3360
3360
2101 -
2102/*! -
2103 \internal -
2104 -
2105 Sorts the children by the value in the given \a column, in the \a order -
2106 specified. If \a climb is true, the items below each of the children will -
2107 also be sorted. -
2108*/ -
2109void QTreeWidgetItem::sortChildren(int column, Qt::SortOrder order, bool climb) -
2110{ -
2111 QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0);
partially evaluated: view
TRUEFALSE
yes
Evaluation Count:457
no
Evaluation Count:0
0-457
2112 if (!model)
partially evaluated: !model
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:457
0-457
2113 return;
never executed: return;
0
2114 if (model->isChanging())
partially evaluated: model->isChanging()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:457
0-457
2115 return;
never executed: return;
0
2116 QTreeModel::SkipSorting skipSorting(model);
executed (the execution status of this line is deduced): QTreeModel::SkipSorting skipSorting(model);
-
2117 int oldSortColumn = view->d_func()->explicitSortColumn;
executed (the execution status of this line is deduced): int oldSortColumn = view->d_func()->explicitSortColumn;
-
2118 view->d_func()->explicitSortColumn = column;
executed (the execution status of this line is deduced): view->d_func()->explicitSortColumn = column;
-
2119 emit model->layoutAboutToBeChanged();
executed (the execution status of this line is deduced): model->layoutAboutToBeChanged();
-
2120 d->sortChildren(column, order, climb);
executed (the execution status of this line is deduced): d->sortChildren(column, order, climb);
-
2121 emit model->layoutChanged();
executed (the execution status of this line is deduced): model->layoutChanged();
-
2122 view->d_func()->explicitSortColumn = oldSortColumn;
executed (the execution status of this line is deduced): view->d_func()->explicitSortColumn = oldSortColumn;
-
2123}
executed: }
Execution Count:457
457
2124 -
2125/*! -
2126 \internal -
2127 -
2128 Calculates the checked state of the item based on the checked state -
2129 of its children. E.g. if all children checked => this item is also -
2130 checked; if some children checked => this item is partially checked; -
2131 if no children checked => this item is unchecked. -
2132*/ -
2133QVariant QTreeWidgetItem::childrenCheckState(int column) const -
2134{ -
2135 if (column < 0)
partially evaluated: column < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2136 return QVariant();
never executed: return QVariant();
0
2137 bool checkedChildren = false;
executed (the execution status of this line is deduced): bool checkedChildren = false;
-
2138 bool uncheckedChildren = false;
executed (the execution status of this line is deduced): bool uncheckedChildren = false;
-
2139 for (int i = 0; i < children.count(); ++i) {
evaluated: i < children.count()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:5
5-12
2140 QVariant value = children.at(i)->data(column, Qt::CheckStateRole);
executed (the execution status of this line is deduced): QVariant value = children.at(i)->data(column, Qt::CheckStateRole);
-
2141 if (!value.isValid())
partially evaluated: !value.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
2142 return QVariant();
never executed: return QVariant();
0
2143 -
2144 switch (static_cast<Qt::CheckState>(value.toInt())) -
2145 { -
2146 case Qt::Unchecked: -
2147 uncheckedChildren = true;
executed (the execution status of this line is deduced): uncheckedChildren = true;
-
2148 break;
executed: break;
Execution Count:4
4
2149 case Qt::Checked: -
2150 checkedChildren = true;
executed (the execution status of this line is deduced): checkedChildren = true;
-
2151 break;
executed: break;
Execution Count:7
7
2152 case Qt::PartiallyChecked: -
2153 default: -
2154 return Qt::PartiallyChecked;
executed: return Qt::PartiallyChecked;
Execution Count:1
1
2155 } -
2156 }
executed: }
Execution Count:11
11
2157 -
2158 if (uncheckedChildren && checkedChildren)
evaluated: uncheckedChildren
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
evaluated: checkedChildren
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-3
2159 return Qt::PartiallyChecked;
executed: return Qt::PartiallyChecked;
Execution Count:2
2
2160 if (uncheckedChildren)
evaluated: uncheckedChildren
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
2161 return Qt::Unchecked;
executed: return Qt::Unchecked;
Execution Count:1
1
2162 else if (checkedChildren)
partially evaluated: checkedChildren
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2163 return Qt::Checked;
executed: return Qt::Checked;
Execution Count:2
2
2164 else -
2165 return QVariant(); // value was not defined
never executed: return QVariant();
0
2166} -
2167 -
2168/*! -
2169 \since 4.5 -
2170 -
2171 Causes the model associated with this item to emit a -
2172 \l{QAbstractItemModel::dataChanged()}{dataChanged}() signal for this -
2173 item. -
2174 -
2175 You normally only need to call this function if you have subclassed -
2176 QTreeWidgetItem and reimplemented data() and/or setData(). -
2177 -
2178 \sa setData() -
2179*/ -
2180void QTreeWidgetItem::emitDataChanged() -
2181{ -
2182 itemChanged();
executed (the execution status of this line is deduced): itemChanged();
-
2183}
executed: }
Execution Count:6
6
2184 -
2185/*! -
2186 \internal -
2187*/ -
2188void QTreeWidgetItem::itemChanged() -
2189{ -
2190 if (QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0))
evaluated: view
TRUEFALSE
yes
Evaluation Count:231
yes
Evaluation Count:53
53-231
2191 model->itemChanged(this);
executed: model->itemChanged(this);
Execution Count:231
231
2192}
executed: }
Execution Count:284
284
2193 -
2194/*! -
2195 \internal -
2196*/ -
2197void QTreeWidgetItem::executePendingSort() const -
2198{ -
2199 if (QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0))
evaluated: view
TRUEFALSE
yes
Evaluation Count:35109
yes
Evaluation Count:331
331-35109
2200 model->executePendingSort();
executed: model->executePendingSort();
Execution Count:35109
35109
2201}
executed: }
Execution Count:35440
35440
2202 -
2203 -
2204#ifndef QT_NO_DATASTREAM -
2205/*! -
2206 \relates QTreeWidgetItem -
2207 -
2208 Writes the tree widget item \a item to stream \a out. -
2209 -
2210 This operator uses QTreeWidgetItem::write(). -
2211 -
2212 \sa {Serializing Qt Data Types} -
2213*/ -
2214QDataStream &operator<<(QDataStream &out, const QTreeWidgetItem &item) -
2215{ -
2216 item.write(out);
executed (the execution status of this line is deduced): item.write(out);
-
2217 return out;
executed: return out;
Execution Count:1
1
2218} -
2219 -
2220/*! -
2221 \relates QTreeWidgetItem -
2222 -
2223 Reads a tree widget item from stream \a in into \a item. -
2224 -
2225 This operator uses QTreeWidgetItem::read(). -
2226 -
2227 \sa {Serializing Qt Data Types} -
2228*/ -
2229QDataStream &operator>>(QDataStream &in, QTreeWidgetItem &item) -
2230{ -
2231 item.read(in);
executed (the execution status of this line is deduced): item.read(in);
-
2232 return in;
executed: return in;
Execution Count:1
1
2233} -
2234#endif // QT_NO_DATASTREAM -
2235 -
2236 -
2237void QTreeWidgetPrivate::_q_emitItemPressed(const QModelIndex &index) -
2238{ -
2239 Q_Q(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidget * const q = q_func();
-
2240 emit q->itemPressed(item(index), index.column());
executed (the execution status of this line is deduced): q->itemPressed(item(index), index.column());
-
2241}
executed: }
Execution Count:4
4
2242 -
2243void QTreeWidgetPrivate::_q_emitItemClicked(const QModelIndex &index) -
2244{ -
2245 Q_Q(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidget * const q = q_func();
-
2246 emit q->itemClicked(item(index), index.column());
executed (the execution status of this line is deduced): q->itemClicked(item(index), index.column());
-
2247}
executed: }
Execution Count:3
3
2248 -
2249void QTreeWidgetPrivate::_q_emitItemDoubleClicked(const QModelIndex &index) -
2250{ -
2251 Q_Q(QTreeWidget);
never executed (the execution status of this line is deduced): QTreeWidget * const q = q_func();
-
2252 emit q->itemDoubleClicked(item(index), index.column());
never executed (the execution status of this line is deduced): q->itemDoubleClicked(item(index), index.column());
-
2253}
never executed: }
0
2254 -
2255void QTreeWidgetPrivate::_q_emitItemActivated(const QModelIndex &index) -
2256{ -
2257 Q_Q(QTreeWidget);
never executed (the execution status of this line is deduced): QTreeWidget * const q = q_func();
-
2258 emit q->itemActivated(item(index), index.column());
never executed (the execution status of this line is deduced): q->itemActivated(item(index), index.column());
-
2259}
never executed: }
0
2260 -
2261void QTreeWidgetPrivate::_q_emitItemEntered(const QModelIndex &index) -
2262{ -
2263 Q_Q(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidget * const q = q_func();
-
2264 emit q->itemEntered(item(index), index.column());
executed (the execution status of this line is deduced): q->itemEntered(item(index), index.column());
-
2265}
executed: }
Execution Count:3
3
2266 -
2267void QTreeWidgetPrivate::_q_emitItemChanged(const QModelIndex &index) -
2268{ -
2269 Q_Q(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidget * const q = q_func();
-
2270 QTreeWidgetItem *indexItem = item(index);
executed (the execution status of this line is deduced): QTreeWidgetItem *indexItem = item(index);
-
2271 if (indexItem)
evaluated: indexItem
TRUEFALSE
yes
Evaluation Count:6380
yes
Evaluation Count:1
1-6380
2272 emit q->itemChanged(indexItem, index.column());
executed: q->itemChanged(indexItem, index.column());
Execution Count:6380
6380
2273}
executed: }
Execution Count:6381
6381
2274 -
2275void QTreeWidgetPrivate::_q_emitItemExpanded(const QModelIndex &index) -
2276{ -
2277 Q_Q(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidget * const q = q_func();
-
2278 emit q->itemExpanded(item(index));
executed (the execution status of this line is deduced): q->itemExpanded(item(index));
-
2279}
executed: }
Execution Count:132
132
2280 -
2281void QTreeWidgetPrivate::_q_emitItemCollapsed(const QModelIndex &index) -
2282{ -
2283 Q_Q(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidget * const q = q_func();
-
2284 emit q->itemCollapsed(item(index));
executed (the execution status of this line is deduced): q->itemCollapsed(item(index));
-
2285}
executed: }
Execution Count:11
11
2286 -
2287void QTreeWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex &current, -
2288 const QModelIndex &previous) -
2289{ -
2290 Q_Q(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidget * const q = q_func();
-
2291 QTreeWidgetItem *currentItem = item(current);
executed (the execution status of this line is deduced): QTreeWidgetItem *currentItem = item(current);
-
2292 QTreeWidgetItem *previousItem = item(previous);
executed (the execution status of this line is deduced): QTreeWidgetItem *previousItem = item(previous);
-
2293 emit q->currentItemChanged(currentItem, previousItem);
executed (the execution status of this line is deduced): q->currentItemChanged(currentItem, previousItem);
-
2294}
executed: }
Execution Count:87
87
2295 -
2296void QTreeWidgetPrivate::_q_sort() -
2297{ -
2298 if (sortingEnabled) {
partially evaluated: sortingEnabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
0-11
2299 int column = header->sortIndicatorSection();
never executed (the execution status of this line is deduced): int column = header->sortIndicatorSection();
-
2300 Qt::SortOrder order = header->sortIndicatorOrder();
never executed (the execution status of this line is deduced): Qt::SortOrder order = header->sortIndicatorOrder();
-
2301 treeModel()->sort(column, order);
never executed (the execution status of this line is deduced): treeModel()->sort(column, order);
-
2302 }
never executed: }
0
2303}
executed: }
Execution Count:11
11
2304 -
2305void QTreeWidgetPrivate::_q_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) -
2306{ -
2307 Q_Q(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidget * const q = q_func();
-
2308 QModelIndexList indices = selected.indexes();
executed (the execution status of this line is deduced): QModelIndexList indices = selected.indexes();
-
2309 int i;
executed (the execution status of this line is deduced): int i;
-
2310 QTreeModel *m = treeModel();
executed (the execution status of this line is deduced): QTreeModel *m = treeModel();
-
2311 for (i = 0; i < indices.count(); ++i) {
evaluated: i < indices.count()
TRUEFALSE
yes
Evaluation Count:222
yes
Evaluation Count:153
153-222
2312 QTreeWidgetItem *item = m->item(indices.at(i));
executed (the execution status of this line is deduced): QTreeWidgetItem *item = m->item(indices.at(i));
-
2313 item->d->selected = true;
executed (the execution status of this line is deduced): item->d->selected = true;
-
2314 }
executed: }
Execution Count:222
222
2315 -
2316 indices = deselected.indexes();
executed (the execution status of this line is deduced): indices = deselected.indexes();
-
2317 for (i = 0; i < indices.count(); ++i) {
evaluated: i < indices.count()
TRUEFALSE
yes
Evaluation Count:152
yes
Evaluation Count:153
152-153
2318 QTreeWidgetItem *item = m->item(indices.at(i));
executed (the execution status of this line is deduced): QTreeWidgetItem *item = m->item(indices.at(i));
-
2319 item->d->selected = false;
executed (the execution status of this line is deduced): item->d->selected = false;
-
2320 }
executed: }
Execution Count:152
152
2321 -
2322 emit q->itemSelectionChanged();
executed (the execution status of this line is deduced): q->itemSelectionChanged();
-
2323}
executed: }
Execution Count:153
153
2324 -
2325void QTreeWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, -
2326 const QModelIndex &bottomRight) -
2327{ -
2328 if (sortingEnabled && topLeft.isValid() && bottomRight.isValid()
evaluated: sortingEnabled
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:6259
partially evaluated: topLeft.isValid()
TRUEFALSE
yes
Evaluation Count:122
no
Evaluation Count:0
partially evaluated: bottomRight.isValid()
TRUEFALSE
yes
Evaluation Count:122
no
Evaluation Count:0
0-6259
2329 && !treeModel()->sortPendingTimer.isActive()) {
evaluated: !treeModel()->sortPendingTimer.isActive()
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:101
21-101
2330 int column = header->sortIndicatorSection();
executed (the execution status of this line is deduced): int column = header->sortIndicatorSection();
-
2331 if (column >= topLeft.column() && column <= bottomRight.column()) {
partially evaluated: column >= topLeft.column()
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
partially evaluated: column <= bottomRight.column()
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
2332 Qt::SortOrder order = header->sortIndicatorOrder();
executed (the execution status of this line is deduced): Qt::SortOrder order = header->sortIndicatorOrder();
-
2333 treeModel()->ensureSorted(column, order, topLeft.row(),
executed (the execution status of this line is deduced): treeModel()->ensureSorted(column, order, topLeft.row(),
-
2334 bottomRight.row(), topLeft.parent());
executed (the execution status of this line is deduced): bottomRight.row(), topLeft.parent());
-
2335 }
executed: }
Execution Count:21
21
2336 }
executed: }
Execution Count:21
21
2337}
executed: }
Execution Count:6381
6381
2338 -
2339/*! -
2340 \class QTreeWidget -
2341 -
2342 \brief The QTreeWidget class provides a tree view that uses a predefined -
2343 tree model. -
2344 -
2345 \ingroup model-view -
2346 \inmodule QtWidgets -
2347 -
2348 The QTreeWidget class is a convenience class that provides a standard -
2349 tree widget with a classic item-based interface similar to that used by -
2350 the QListView class in Qt 3. -
2351 This class is based on Qt's Model/View architecture and uses a default -
2352 model to hold items, each of which is a QTreeWidgetItem. -
2353 -
2354 Developers who do not need the flexibility of the Model/View framework -
2355 can use this class to create simple hierarchical lists very easily. A more -
2356 flexible approach involves combining a QTreeView with a standard item model. -
2357 This allows the storage of data to be separated from its representation. -
2358 -
2359 In its simplest form, a tree widget can be constructed in the following way: -
2360 -
2361 \snippet code/src_gui_itemviews_qtreewidget.cpp 0 -
2362 -
2363 Before items can be added to the tree widget, the number of columns must -
2364 be set with setColumnCount(). This allows each item to have one or more -
2365 labels or other decorations. The number of columns in use can be found -
2366 with the columnCount() function. -
2367 -
2368 The tree can have a header that contains a section for each column in -
2369 the widget. It is easiest to set up the labels for each section by -
2370 supplying a list of strings with setHeaderLabels(), but a custom header -
2371 can be constructed with a QTreeWidgetItem and inserted into the tree -
2372 with the setHeaderItem() function. -
2373 -
2374 The items in the tree can be sorted by column according to a predefined -
2375 sort order. If sorting is enabled, the user can sort the items by clicking -
2376 on a column header. Sorting can be enabled or disabled by calling -
2377 \l{QTreeView::setSortingEnabled()}{setSortingEnabled()}. The -
2378 \l{QTreeView::isSortingEnabled()}{isSortingEnabled()} function indicates -
2379 whether sorting is enabled. -
2380 -
2381 \table 100% -
2382 \row \li \inlineimage windowsvista-treeview.png Screenshot of a Windows Vista style tree widget -
2383 \li \inlineimage macintosh-treeview.png Screenshot of a Macintosh style tree widget -
2384 \li \inlineimage fusion-treeview.png Screenshot of a Fusion style tree widget -
2385 \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} tree widget. -
2386 \li A \l{Macintosh Style Widget Gallery}{Macintosh style} tree widget. -
2387 \li A \l{Fusion Style Widget Gallery}{Fusion style} tree widget. -
2388 \endtable -
2389 -
2390 \sa QTreeWidgetItem, QTreeWidgetItemIterator, QTreeView, -
2391 {Model/View Programming}, {Settings Editor Example} -
2392*/ -
2393 -
2394/*! -
2395 \property QTreeWidget::columnCount -
2396 \brief the number of columns displayed in the tree widget -
2397 -
2398 By default, this property has a value of 1. -
2399*/ -
2400 -
2401/*! -
2402 \fn void QTreeWidget::itemActivated(QTreeWidgetItem *item, int column) -
2403 -
2404 This signal is emitted when the user activates an item by single- -
2405 or double-clicking (depending on the platform, i.e. on the -
2406 QStyle::SH_ItemView_ActivateItemOnSingleClick style hint) or -
2407 pressing a special key (e.g., \uicontrol Enter). -
2408 -
2409 The specified \a item is the item that was clicked, or 0 if no -
2410 item was clicked. The \a column is the item's column that was -
2411 clicked, or -1 if no item was clicked. -
2412*/ -
2413 -
2414/*! -
2415 \fn void QTreeWidget::itemPressed(QTreeWidgetItem *item, int column) -
2416 -
2417 This signal is emitted when the user presses a mouse button inside -
2418 the widget. -
2419 -
2420 The specified \a item is the item that was clicked, or 0 if no -
2421 item was clicked. The \a column is the item's column that was -
2422 clicked, or -1 if no item was clicked. -
2423*/ -
2424 -
2425/*! -
2426 \fn void QTreeWidget::itemClicked(QTreeWidgetItem *item, int column) -
2427 -
2428 This signal is emitted when the user clicks inside the widget. -
2429 -
2430 The specified \a item is the item that was clicked. The \a column is the -
2431 item's column that was clicked. If no item was clicked, no signal will be -
2432 emitted. -
2433*/ -
2434 -
2435/*! -
2436 \fn void QTreeWidget::itemDoubleClicked(QTreeWidgetItem *item, int column) -
2437 -
2438 This signal is emitted when the user double clicks inside the -
2439 widget. -
2440 -
2441 The specified \a item is the item that was clicked, or 0 if no -
2442 item was clicked. The \a column is the item's column that was -
2443 clicked. If no item was double clicked, no signal will be emitted. -
2444*/ -
2445 -
2446/*! -
2447 \fn void QTreeWidget::itemExpanded(QTreeWidgetItem *item) -
2448 -
2449 This signal is emitted when the specified \a item is expanded so that -
2450 all of its children are displayed. -
2451 -
2452 \note This signal will not be emitted if an item changes its state when -
2453 expandAll() is invoked. -
2454 -
2455 \sa QTreeWidgetItem::isExpanded(), itemCollapsed(), expandItem() -
2456*/ -
2457 -
2458/*! -
2459 \fn void QTreeWidget::itemCollapsed(QTreeWidgetItem *item) -
2460 -
2461 This signal is emitted when the specified \a item is collapsed so that -
2462 none of its children are displayed. -
2463 -
2464 \note This signal will not be emitted if an item changes its state when -
2465 collapseAll() is invoked. -
2466 -
2467 \sa QTreeWidgetItem::isExpanded(), itemExpanded(), collapseItem() -
2468*/ -
2469 -
2470/*! -
2471 \fn void QTreeWidget::currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous) -
2472 -
2473 This signal is emitted when the current item changes. The current -
2474 item is specified by \a current, and this replaces the \a previous -
2475 current item. -
2476 -
2477 \sa setCurrentItem() -
2478*/ -
2479 -
2480/*! -
2481 \fn void QTreeWidget::itemSelectionChanged() -
2482 -
2483 This signal is emitted when the selection changes in the tree widget. -
2484 The current selection can be found with selectedItems(). -
2485*/ -
2486 -
2487/*! -
2488 \fn void QTreeWidget::itemEntered(QTreeWidgetItem *item, int column) -
2489 -
2490 This signal is emitted when the mouse cursor enters an \a item over the -
2491 specified \a column. -
2492 QTreeWidget mouse tracking needs to be enabled for this feature to work. -
2493*/ -
2494 -
2495/*! -
2496 \fn void QTreeWidget::itemChanged(QTreeWidgetItem *item, int column) -
2497 -
2498 This signal is emitted when the contents of the \a column in the specified -
2499 \a item changes. -
2500*/ -
2501 -
2502/*! -
2503 \since 4.3 -
2504 -
2505 \fn void QTreeWidget::removeItemWidget(QTreeWidgetItem *item, int column) -
2506 -
2507 Removes the widget set in the given \a item in the given \a column. -
2508*/ -
2509 -
2510/*! -
2511 Constructs a tree widget with the given \a parent. -
2512*/ -
2513QTreeWidget::QTreeWidget(QWidget *parent) -
2514 : QTreeView(*new QTreeWidgetPrivate(), parent) -
2515{ -
2516 QTreeView::setModel(new QTreeModel(1, this));
executed (the execution status of this line is deduced): QTreeView::setModel(new QTreeModel(1, this));
-
2517 connect(this, SIGNAL(pressed(QModelIndex)),
executed (the execution status of this line is deduced): connect(this, "2""pressed(QModelIndex)",
-
2518 SLOT(_q_emitItemPressed(QModelIndex)));
executed (the execution status of this line is deduced): "1""_q_emitItemPressed(QModelIndex)");
-
2519 connect(this, SIGNAL(clicked(QModelIndex)),
executed (the execution status of this line is deduced): connect(this, "2""clicked(QModelIndex)",
-
2520 SLOT(_q_emitItemClicked(QModelIndex)));
executed (the execution status of this line is deduced): "1""_q_emitItemClicked(QModelIndex)");
-
2521 connect(this, SIGNAL(doubleClicked(QModelIndex)),
executed (the execution status of this line is deduced): connect(this, "2""doubleClicked(QModelIndex)",
-
2522 SLOT(_q_emitItemDoubleClicked(QModelIndex)));
executed (the execution status of this line is deduced): "1""_q_emitItemDoubleClicked(QModelIndex)");
-
2523 connect(this, SIGNAL(activated(QModelIndex)),
executed (the execution status of this line is deduced): connect(this, "2""activated(QModelIndex)",
-
2524 SLOT(_q_emitItemActivated(QModelIndex)));
executed (the execution status of this line is deduced): "1""_q_emitItemActivated(QModelIndex)");
-
2525 connect(this, SIGNAL(entered(QModelIndex)),
executed (the execution status of this line is deduced): connect(this, "2""entered(QModelIndex)",
-
2526 SLOT(_q_emitItemEntered(QModelIndex)));
executed (the execution status of this line is deduced): "1""_q_emitItemEntered(QModelIndex)");
-
2527 connect(this, SIGNAL(expanded(QModelIndex)),
executed (the execution status of this line is deduced): connect(this, "2""expanded(QModelIndex)",
-
2528 SLOT(_q_emitItemExpanded(QModelIndex)));
executed (the execution status of this line is deduced): "1""_q_emitItemExpanded(QModelIndex)");
-
2529 connect(this, SIGNAL(collapsed(QModelIndex)),
executed (the execution status of this line is deduced): connect(this, "2""collapsed(QModelIndex)",
-
2530 SLOT(_q_emitItemCollapsed(QModelIndex)));
executed (the execution status of this line is deduced): "1""_q_emitItemCollapsed(QModelIndex)");
-
2531 connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
executed (the execution status of this line is deduced): connect(selectionModel(), "2""currentChanged(QModelIndex,QModelIndex)",
-
2532 this, SLOT(_q_emitCurrentItemChanged(QModelIndex,QModelIndex)));
executed (the execution status of this line is deduced): this, "1""_q_emitCurrentItemChanged(QModelIndex,QModelIndex)");
-
2533 connect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
executed (the execution status of this line is deduced): connect(model(), "2""dataChanged(QModelIndex,QModelIndex)",
-
2534 this, SLOT(_q_emitItemChanged(QModelIndex)));
executed (the execution status of this line is deduced): this, "1""_q_emitItemChanged(QModelIndex)");
-
2535 connect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
executed (the execution status of this line is deduced): connect(model(), "2""dataChanged(QModelIndex,QModelIndex)",
-
2536 this, SLOT(_q_dataChanged(QModelIndex,QModelIndex)));
executed (the execution status of this line is deduced): this, "1""_q_dataChanged(QModelIndex,QModelIndex)");
-
2537 connect(model(), SIGNAL(columnsRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): connect(model(), "2""columnsRemoved(QModelIndex,int,int)",
-
2538 this, SLOT(_q_sort()));
executed (the execution status of this line is deduced): this, "1""_q_sort()");
-
2539 connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
executed (the execution status of this line is deduced): connect(selectionModel(), "2""selectionChanged(QItemSelection,QItemSelection)",
-
2540 this, SLOT(_q_selectionChanged(QItemSelection,QItemSelection)));
executed (the execution status of this line is deduced): this, "1""_q_selectionChanged(QItemSelection,QItemSelection)");
-
2541 header()->setSectionsClickable(false);
executed (the execution status of this line is deduced): header()->setSectionsClickable(false);
-
2542}
executed: }
Execution Count:264
264
2543 -
2544/*! -
2545 Destroys the tree widget and all its items. -
2546*/ -
2547 -
2548QTreeWidget::~QTreeWidget() -
2549{ -
2550} -
2551 -
2552/* -
2553 Retuns the number of header columns in the view. -
2554 -
2555 \sa sortColumn(), currentColumn(), topLevelItemCount() -
2556*/ -
2557 -
2558int QTreeWidget::columnCount() const -
2559{ -
2560 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2561 return d->model->columnCount();
executed: return d->model->columnCount();
Execution Count:372
372
2562} -
2563 -
2564/* -
2565 Sets the number of header \a columns in the tree widget. -
2566*/ -
2567 -
2568void QTreeWidget::setColumnCount(int columns) -
2569{ -
2570 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2571 if (columns < 0)
evaluated: columns < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:310
2-310
2572 return;
executed: return;
Execution Count:2
2
2573 d->treeModel()->setColumnCount(columns);
executed (the execution status of this line is deduced): d->treeModel()->setColumnCount(columns);
-
2574}
executed: }
Execution Count:310
310
2575 -
2576/*! -
2577 \since 4.2 -
2578 -
2579 Returns the tree widget's invisible root item. -
2580 -
2581 The invisible root item provides access to the tree widget's top-level items -
2582 through the QTreeWidgetItem API, making it possible to write functions that -
2583 can treat top-level items and their children in a uniform way; for example, -
2584 recursive functions. -
2585*/ -
2586 -
2587QTreeWidgetItem *QTreeWidget::invisibleRootItem() const -
2588{ -
2589 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2590 return d->treeModel()->rootItem;
executed: return d->treeModel()->rootItem;
Execution Count:4
4
2591} -
2592 -
2593/*! -
2594 Returns the top level item at the given \a index, or 0 if the item does -
2595 not exist. -
2596 -
2597 \sa topLevelItemCount(), insertTopLevelItem() -
2598*/ -
2599 -
2600QTreeWidgetItem *QTreeWidget::topLevelItem(int index) const -
2601{ -
2602 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2603 return d->treeModel()->rootItem->child(index);
executed: return d->treeModel()->rootItem->child(index);
Execution Count:1345
1345
2604} -
2605 -
2606/*! -
2607 \property QTreeWidget::topLevelItemCount -
2608 \brief the number of top-level items -
2609 -
2610 By default, this property has a value of 0. -
2611 -
2612 \sa columnCount(), currentItem() -
2613*/ -
2614 -
2615int QTreeWidget::topLevelItemCount() const -
2616{ -
2617 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2618 return d->treeModel()->rootItem->childCount();
executed: return d->treeModel()->rootItem->childCount();
Execution Count:1691
1691
2619} -
2620 -
2621/*! -
2622 Inserts the \a item at \a index in the top level in the view. -
2623 -
2624 If the item has already been inserted somewhere else it won't be inserted. -
2625 -
2626 \sa addTopLevelItem(), columnCount() -
2627*/ -
2628 -
2629void QTreeWidget::insertTopLevelItem(int index, QTreeWidgetItem *item) -
2630{ -
2631 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2632 d->treeModel()->rootItem->insertChild(index, item);
executed (the execution status of this line is deduced): d->treeModel()->rootItem->insertChild(index, item);
-
2633}
executed: }
Execution Count:829
829
2634 -
2635/*! -
2636 \since 4.1 -
2637 -
2638 Appends the \a item as a top-level item in the widget. -
2639 -
2640 \sa insertTopLevelItem() -
2641*/ -
2642void QTreeWidget::addTopLevelItem(QTreeWidgetItem *item) -
2643{ -
2644 insertTopLevelItem(topLevelItemCount(), item);
executed (the execution status of this line is deduced): insertTopLevelItem(topLevelItemCount(), item);
-
2645}
executed: }
Execution Count:652
652
2646 -
2647/*! -
2648 Removes the top-level item at the given \a index in the tree and -
2649 returns it, otherwise returns 0; -
2650 -
2651 \sa insertTopLevelItem(), topLevelItem(), topLevelItemCount() -
2652*/ -
2653 -
2654QTreeWidgetItem *QTreeWidget::takeTopLevelItem(int index) -
2655{ -
2656 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2657 return d->treeModel()->rootItem->takeChild(index);
executed: return d->treeModel()->rootItem->takeChild(index);
Execution Count:8
8
2658} -
2659 -
2660/*! -
2661 Returns the index of the given top-level \a item, or -1 if the item -
2662 cannot be found. -
2663 -
2664 \sa sortItems(), topLevelItemCount() -
2665 */ -
2666int QTreeWidget::indexOfTopLevelItem(QTreeWidgetItem *item) const -
2667{ -
2668 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2669 d->treeModel()->executePendingSort();
executed (the execution status of this line is deduced): d->treeModel()->executePendingSort();
-
2670 return d->treeModel()->rootItem->children.indexOf(item);
executed: return d->treeModel()->rootItem->children.indexOf(item);
Execution Count:129
129
2671} -
2672 -
2673/*! -
2674 \since 4.1 -
2675 -
2676 Inserts the list of \a items at \a index in the top level in the view. -
2677 -
2678 Items that have already been inserted somewhere else won't be inserted. -
2679 -
2680 \sa addTopLevelItems() -
2681*/ -
2682void QTreeWidget::insertTopLevelItems(int index, const QList<QTreeWidgetItem*> &items) -
2683{ -
2684 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2685 d->treeModel()->rootItem->insertChildren(index, items);
executed (the execution status of this line is deduced): d->treeModel()->rootItem->insertChildren(index, items);
-
2686}
executed: }
Execution Count:48
48
2687 -
2688/*! -
2689 Appends the list of \a items as a top-level items in the widget. -
2690 -
2691 \sa insertTopLevelItems() -
2692*/ -
2693void QTreeWidget::addTopLevelItems(const QList<QTreeWidgetItem*> &items) -
2694{ -
2695 insertTopLevelItems(topLevelItemCount(), items);
executed (the execution status of this line is deduced): insertTopLevelItems(topLevelItemCount(), items);
-
2696}
executed: }
Execution Count:33
33
2697 -
2698/*! -
2699 Returns the item used for the tree widget's header. -
2700 -
2701 \sa setHeaderItem() -
2702*/ -
2703 -
2704QTreeWidgetItem *QTreeWidget::headerItem() const -
2705{ -
2706 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2707 return d->treeModel()->headerItem;
executed: return d->treeModel()->headerItem;
Execution Count:6
6
2708} -
2709 -
2710/*! -
2711 Sets the header \a item for the tree widget. The label for each column in -
2712 the header is supplied by the corresponding label in the item. -
2713 -
2714 The tree widget takes ownership of the item. -
2715 -
2716 \sa headerItem(), setHeaderLabels() -
2717*/ -
2718 -
2719void QTreeWidget::setHeaderItem(QTreeWidgetItem *item) -
2720{ -
2721 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2722 if (!item)
evaluated: !item
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:9
2-9
2723 return;
executed: return;
Execution Count:2
2
2724 item->view = this;
executed (the execution status of this line is deduced): item->view = this;
-
2725 -
2726 int oldCount = columnCount();
executed (the execution status of this line is deduced): int oldCount = columnCount();
-
2727 if (oldCount < item->columnCount())
evaluated: oldCount < item->columnCount()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
4-5
2728 d->treeModel()->beginInsertColumns(QModelIndex(), oldCount, item->columnCount());
executed: d->treeModel()->beginInsertColumns(QModelIndex(), oldCount, item->columnCount());
Execution Count:5
5
2729 else -
2730 d->treeModel()->beginRemoveColumns(QModelIndex(), item->columnCount(), oldCount);
executed: d->treeModel()->beginRemoveColumns(QModelIndex(), item->columnCount(), oldCount);
Execution Count:4
4
2731 delete d->treeModel()->headerItem;
executed (the execution status of this line is deduced): delete d->treeModel()->headerItem;
-
2732 d->treeModel()->headerItem = item;
executed (the execution status of this line is deduced): d->treeModel()->headerItem = item;
-
2733 if (oldCount < item->columnCount())
evaluated: oldCount < item->columnCount()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
4-5
2734 d->treeModel()->endInsertColumns();
executed: d->treeModel()->endInsertColumns();
Execution Count:5
5
2735 else -
2736 d->treeModel()->endRemoveColumns();
executed: d->treeModel()->endRemoveColumns();
Execution Count:4
4
2737 d->treeModel()->headerDataChanged(Qt::Horizontal, 0, oldCount);
executed (the execution status of this line is deduced): d->treeModel()->headerDataChanged(Qt::Horizontal, 0, oldCount);
-
2738}
executed: }
Execution Count:9
9
2739 -
2740 -
2741/*! -
2742 Adds a column in the header for each item in the \a labels list, and sets -
2743 the label for each column. -
2744 -
2745 Note that setHeaderLabels() won't remove existing columns. -
2746 -
2747 \sa setHeaderItem(), setHeaderLabel() -
2748*/ -
2749void QTreeWidget::setHeaderLabels(const QStringList &labels) -
2750{ -
2751 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2752 if (columnCount() < labels.count())
evaluated: columnCount() < labels.count()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
2753 setColumnCount(labels.count());
executed: setColumnCount(labels.count());
Execution Count:1
1
2754 QTreeWidgetItem *item = d->treeModel()->headerItem;
executed (the execution status of this line is deduced): QTreeWidgetItem *item = d->treeModel()->headerItem;
-
2755 for (int i = 0; i < labels.count(); ++i)
evaluated: i < labels.count()
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:4
4-30
2756 item->setText(i, labels.at(i));
executed: item->setText(i, labels.at(i));
Execution Count:30
30
2757}
executed: }
Execution Count:4
4
2758 -
2759/*! -
2760 \fn void QTreeWidget::setHeaderLabel(const QString &label) -
2761 \since 4.2 -
2762 -
2763 Same as setHeaderLabels(QStringList(\a label)). -
2764*/ -
2765 -
2766/*! -
2767 Returns the current item in the tree widget. -
2768 -
2769 \sa setCurrentItem(), currentItemChanged() -
2770*/ -
2771QTreeWidgetItem *QTreeWidget::currentItem() const -
2772{ -
2773 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2774 return d->item(currentIndex());
executed: return d->item(currentIndex());
Execution Count:134
134
2775} -
2776 -
2777/*! -
2778 \since 4.1 -
2779 Returns the current column in the tree widget. -
2780 -
2781 \sa setCurrentItem(), columnCount() -
2782*/ -
2783int QTreeWidget::currentColumn() const -
2784{ -
2785 return currentIndex().column();
executed: return currentIndex().column();
Execution Count:32
32
2786} -
2787 -
2788/*! -
2789 Sets the current \a item in the tree widget. -
2790 -
2791 Unless the selection mode is \l{QAbstractItemView::}{NoSelection}, -
2792 the item is also selected. -
2793 -
2794 \sa currentItem(), currentItemChanged() -
2795*/ -
2796void QTreeWidget::setCurrentItem(QTreeWidgetItem *item) -
2797{ -
2798 setCurrentItem(item, 0);
executed (the execution status of this line is deduced): setCurrentItem(item, 0);
-
2799}
executed: }
Execution Count:26
26
2800 -
2801/*! -
2802 \since 4.1 -
2803 Sets the current \a item in the tree widget and the current column to \a column. -
2804 -
2805 \sa currentItem() -
2806*/ -
2807void QTreeWidget::setCurrentItem(QTreeWidgetItem *item, int column) -
2808{ -
2809 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2810 setCurrentIndex(d->index(item, column));
executed (the execution status of this line is deduced): setCurrentIndex(d->index(item, column));
-
2811}
executed: }
Execution Count:58
58
2812 -
2813/*! -
2814 \since 4.4 -
2815 Sets the current \a item in the tree widget and the current column to \a column, -
2816 using the given \a command. -
2817 -
2818 \sa currentItem() -
2819*/ -
2820void QTreeWidget::setCurrentItem(QTreeWidgetItem *item, int column, -
2821 QItemSelectionModel::SelectionFlags command) -
2822{ -
2823 Q_D(QTreeWidget);
never executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2824 d->selectionModel->setCurrentIndex(d->index(item, column), command);
never executed (the execution status of this line is deduced): d->selectionModel->setCurrentIndex(d->index(item, column), command);
-
2825}
never executed: }
0
2826 -
2827 -
2828/*! -
2829 Returns a pointer to the item at the coordinates \a p. The coordinates -
2830 are relative to the tree widget's \l{QAbstractScrollArea::}{viewport()}. -
2831 -
2832 \sa visualItemRect() -
2833*/ -
2834QTreeWidgetItem *QTreeWidget::itemAt(const QPoint &p) const -
2835{ -
2836 Q_D(const QTreeWidget);
never executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2837 return d->item(indexAt(p));
never executed: return d->item(indexAt(p));
0
2838} -
2839 -
2840/*! -
2841 \fn QTreeWidgetItem *QTreeWidget::itemAt(int x, int y) const -
2842 \overload -
2843 -
2844 Returns a pointer to the item at the coordinates (\a x, \a y). The coordinates -
2845 are relative to the tree widget's \l{QAbstractScrollArea::}{viewport()}. -
2846*/ -
2847 -
2848/*! -
2849 Returns the rectangle on the viewport occupied by the item at \a item. -
2850 -
2851 \sa itemAt() -
2852*/ -
2853QRect QTreeWidget::visualItemRect(const QTreeWidgetItem *item) const -
2854{ -
2855 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2856 //the visual rect for an item is across all columns. So we need to determine -
2857 //what is the first and last column and get their visual index rects -
2858 QModelIndex base = d->index(item);
executed (the execution status of this line is deduced): QModelIndex base = d->index(item);
-
2859 const int firstVisiblesection = header()->logicalIndexAt(- header()->offset());
executed (the execution status of this line is deduced): const int firstVisiblesection = header()->logicalIndexAt(- header()->offset());
-
2860 const int lastVisibleSection = header()->logicalIndexAt(header()->length() - header()->offset() - 1);
executed (the execution status of this line is deduced): const int lastVisibleSection = header()->logicalIndexAt(header()->length() - header()->offset() - 1);
-
2861 QModelIndex first = base.sibling(base.row(), header()->logicalIndex(firstVisiblesection));
executed (the execution status of this line is deduced): QModelIndex first = base.sibling(base.row(), header()->logicalIndex(firstVisiblesection));
-
2862 QModelIndex last = base.sibling(base.row(), header()->logicalIndex(lastVisibleSection));
executed (the execution status of this line is deduced): QModelIndex last = base.sibling(base.row(), header()->logicalIndex(lastVisibleSection));
-
2863 return visualRect(first) | visualRect(last);
executed: return visualRect(first) | visualRect(last);
Execution Count:12
12
2864} -
2865 -
2866/*! -
2867 \since 4.1 -
2868 -
2869 Returns the column used to sort the contents of the widget. -
2870 -
2871 \sa sortItems() -
2872*/ -
2873int QTreeWidget::sortColumn() const -
2874{ -
2875 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2876 return (d->explicitSortColumn != -1
executed: return (d->explicitSortColumn != -1 ? d->explicitSortColumn : header()->sortIndicatorSection());
Execution Count:7599
7599
2877 ? d->explicitSortColumn
executed: return (d->explicitSortColumn != -1 ? d->explicitSortColumn : header()->sortIndicatorSection());
Execution Count:7599
7599
2878 : header()->sortIndicatorSection());
executed: return (d->explicitSortColumn != -1 ? d->explicitSortColumn : header()->sortIndicatorSection());
Execution Count:7599
7599
2879} -
2880 -
2881/*! -
2882 Sorts the items in the widget in the specified \a order by the values in -
2883 the given \a column. -
2884 -
2885 \sa sortColumn() -
2886*/ -
2887 -
2888void QTreeWidget::sortItems(int column, Qt::SortOrder order) -
2889{ -
2890 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2891 header()->setSortIndicator(column, order);
executed (the execution status of this line is deduced): header()->setSortIndicator(column, order);
-
2892 d->model->sort(column, order);
executed (the execution status of this line is deduced): d->model->sort(column, order);
-
2893}
executed: }
Execution Count:87
87
2894 -
2895/*! -
2896 Starts editing the \a item in the given \a column if it is editable. -
2897*/ -
2898 -
2899void QTreeWidget::editItem(QTreeWidgetItem *item, int column) -
2900{ -
2901 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2902 edit(d->index(item, column));
executed (the execution status of this line is deduced): edit(d->index(item, column));
-
2903}
executed: }
Execution Count:22
22
2904 -
2905/*! -
2906 Opens a persistent editor for the \a item in the given \a column. -
2907 -
2908 \sa closePersistentEditor() -
2909*/ -
2910 -
2911void QTreeWidget::openPersistentEditor(QTreeWidgetItem *item, int column) -
2912{ -
2913 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2914 QAbstractItemView::openPersistentEditor(d->index(item, column));
executed (the execution status of this line is deduced): QAbstractItemView::openPersistentEditor(d->index(item, column));
-
2915}
executed: }
Execution Count:20
20
2916 -
2917/*! -
2918 Closes the persistent editor for the \a item in the given \a column. -
2919 -
2920 This function has no effect if no persistent editor is open for this -
2921 combination of item and column. -
2922 -
2923 \sa openPersistentEditor() -
2924*/ -
2925 -
2926void QTreeWidget::closePersistentEditor(QTreeWidgetItem *item, int column) -
2927{ -
2928 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2929 QAbstractItemView::closePersistentEditor(d->index(item, column));
executed (the execution status of this line is deduced): QAbstractItemView::closePersistentEditor(d->index(item, column));
-
2930}
executed: }
Execution Count:20
20
2931 -
2932/*! -
2933 \since 4.1 -
2934 -
2935 Returns the widget displayed in the cell specified by \a item and the given \a column. -
2936 -
2937 \note The tree takes ownership of the widget. -
2938 -
2939*/ -
2940QWidget *QTreeWidget::itemWidget(QTreeWidgetItem *item, int column) const -
2941{ -
2942 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
2943 return QAbstractItemView::indexWidget(d->index(item, column));
executed: return QAbstractItemView::indexWidget(d->index(item, column));
Execution Count:66
66
2944} -
2945 -
2946/*! -
2947 \since 4.1 -
2948 -
2949 Sets the given \a widget to be displayed in the cell specified by the given -
2950 \a item and \a column. -
2951 -
2952 The given \a widget's \l {QWidget::}{autoFillBackground} property must be -
2953 set to true, otherwise the widget's background will be transparent, showing -
2954 both the model data and the tree widget item. -
2955 -
2956 This function should only be used to display static content in the place of -
2957 a tree widget item. If you want to display custom dynamic content or -
2958 implement a custom editor widget, use QTreeView and subclass QItemDelegate -
2959 instead. -
2960 -
2961 This function cannot be called before the item hierarchy has been set up, -
2962 i.e., the QTreeWidgetItem that will hold \a widget must have been added to -
2963 the view before \a widget is set. -
2964 -
2965 \note The tree takes ownership of the widget. -
2966 -
2967 \sa {Delegate Classes} -
2968*/ -
2969void QTreeWidget::setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget) -
2970{ -
2971 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
2972 QAbstractItemView::setIndexWidget(d->index(item, column), widget);
executed (the execution status of this line is deduced): QAbstractItemView::setIndexWidget(d->index(item, column), widget);
-
2973}
executed: }
Execution Count:42
42
2974 -
2975/*! -
2976 Returns true if the \a item is selected; otherwise returns false. -
2977 -
2978 \sa itemSelectionChanged() -
2979 -
2980 \obsolete -
2981 -
2982 This function is deprecated. Use \l{QTreeWidgetItem::isSelected()} instead. -
2983*/ -
2984bool QTreeWidget::isItemSelected(const QTreeWidgetItem *item) const -
2985{ -
2986 if (!item)
evaluated: !item
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:686
8-686
2987 return false;
executed: return false;
Execution Count:8
8
2988 return item->d->selected;
executed: return item->d->selected;
Execution Count:686
686
2989} -
2990 -
2991/*! -
2992 If \a select is true, the given \a item is selected; otherwise it is -
2993 deselected. -
2994 -
2995 \sa itemSelectionChanged() -
2996 -
2997 \obsolete -
2998 -
2999 This function is deprecated. Use \l{QTreeWidgetItem::setSelected()} instead. -
3000*/ -
3001void QTreeWidget::setItemSelected(const QTreeWidgetItem *item, bool select) -
3002{ -
3003 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3004 -
3005 if (!item)
evaluated: !item
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:93
8-93
3006 return;
executed: return;
Execution Count:8
8
3007 -
3008 selectionModel()->select(d->index(item), (select ? QItemSelectionModel::Select
executed (the execution status of this line is deduced): selectionModel()->select(d->index(item), (select ? QItemSelectionModel::Select
-
3009 : QItemSelectionModel::Deselect)
executed (the execution status of this line is deduced): : QItemSelectionModel::Deselect)
-
3010 |QItemSelectionModel::Rows);
executed (the execution status of this line is deduced): |QItemSelectionModel::Rows);
-
3011 item->d->selected = select;
executed (the execution status of this line is deduced): item->d->selected = select;
-
3012}
executed: }
Execution Count:93
93
3013 -
3014/*! -
3015 Returns a list of all selected non-hidden items. -
3016 -
3017 \sa itemSelectionChanged() -
3018*/ -
3019QList<QTreeWidgetItem*> QTreeWidget::selectedItems() const -
3020{ -
3021 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
3022 QModelIndexList indexes = selectionModel()->selectedIndexes();
executed (the execution status of this line is deduced): QModelIndexList indexes = selectionModel()->selectedIndexes();
-
3023 QList<QTreeWidgetItem*> items;
executed (the execution status of this line is deduced): QList<QTreeWidgetItem*> items;
-
3024 items.reserve(indexes.count());
executed (the execution status of this line is deduced): items.reserve(indexes.count());
-
3025 QSet<QTreeWidgetItem *> seen;
executed (the execution status of this line is deduced): QSet<QTreeWidgetItem *> seen;
-
3026 seen.reserve(indexes.count());
executed (the execution status of this line is deduced): seen.reserve(indexes.count());
-
3027 for (int i = 0; i < indexes.count(); ++i) {
evaluated: i < indexes.count()
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:16
16-46
3028 QTreeWidgetItem *item = d->item(indexes.at(i));
executed (the execution status of this line is deduced): QTreeWidgetItem *item = d->item(indexes.at(i));
-
3029 if (isItemHidden(item) || seen.contains(item))
evaluated: isItemHidden(item)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:38
evaluated: seen.contains(item)
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:19
8-38
3030 continue;
executed: continue;
Execution Count:27
27
3031 seen.insert(item);
executed (the execution status of this line is deduced): seen.insert(item);
-
3032 items.append(item);
executed (the execution status of this line is deduced): items.append(item);
-
3033 }
executed: }
Execution Count:19
19
3034 return items;
executed: return items;
Execution Count:16
16
3035} -
3036 -
3037/*! -
3038 Returns a list of items that match the given \a text, using the given \a flags, in the given \a column. -
3039*/ -
3040QList<QTreeWidgetItem*> QTreeWidget::findItems(const QString &text, Qt::MatchFlags flags, int column) const -
3041{ -
3042 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
3043 QModelIndexList indexes = d->model->match(model()->index(0, column, QModelIndex()),
executed (the execution status of this line is deduced): QModelIndexList indexes = d->model->match(model()->index(0, column, QModelIndex()),
-
3044 Qt::DisplayRole, text, -1, flags);
executed (the execution status of this line is deduced): Qt::DisplayRole, text, -1, flags);
-
3045 QList<QTreeWidgetItem*> items;
executed (the execution status of this line is deduced): QList<QTreeWidgetItem*> items;
-
3046 for (int i = 0; i < indexes.size(); ++i)
evaluated: i < indexes.size()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:3
3-5
3047 items.append(d->item(indexes.at(i)));
executed: items.append(d->item(indexes.at(i)));
Execution Count:5
5
3048 return items;
executed: return items;
Execution Count:3
3
3049} -
3050 -
3051/*! -
3052 Returns true if the \a item is explicitly hidden, otherwise returns false. -
3053 -
3054 \obsolete -
3055 -
3056 This function is deprecated. Use \l{QTreeWidgetItem::isHidden()} instead. -
3057*/ -
3058bool QTreeWidget::isItemHidden(const QTreeWidgetItem *item) const -
3059{ -
3060 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
3061 if (item == d->treeModel()->headerItem)
partially evaluated: item == d->treeModel()->headerItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1016
0-1016
3062 return header()->isHidden();
never executed: return header()->isHidden();
0
3063 if (d->hiddenIndexes.isEmpty())
evaluated: d->hiddenIndexes.isEmpty()
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:984
32-984
3064 return false;
executed: return false;
Execution Count:32
32
3065 QTreeModel::SkipSorting skipSorting(d->treeModel());
executed (the execution status of this line is deduced): QTreeModel::SkipSorting skipSorting(d->treeModel());
-
3066 return d->isRowHidden(d->index(item));
executed: return d->isRowHidden(d->index(item));
Execution Count:984
984
3067} -
3068 -
3069/*! -
3070 Hides the given \a item if \a hide is true; otherwise shows the item. -
3071 -
3072 \sa itemChanged() -
3073 -
3074 \obsolete -
3075 -
3076 This function is deprecated. Use \l{QTreeWidgetItem::setHidden()} instead. -
3077*/ -
3078void QTreeWidget::setItemHidden(const QTreeWidgetItem *item, bool hide) -
3079{ -
3080 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3081 if (item == d->treeModel()->headerItem) {
partially evaluated: item == d->treeModel()->headerItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50
0-50
3082 header()->setHidden(hide);
never executed (the execution status of this line is deduced): header()->setHidden(hide);
-
3083 } else {
never executed: }
0
3084 const QModelIndex index = d->index(item);
executed (the execution status of this line is deduced): const QModelIndex index = d->index(item);
-
3085 setRowHidden(index.row(), index.parent(), hide);
executed (the execution status of this line is deduced): setRowHidden(index.row(), index.parent(), hide);
-
3086 }
executed: }
Execution Count:50
50
3087} -
3088 -
3089/*! -
3090 Returns true if the given \a item is open; otherwise returns false. -
3091 -
3092 \sa itemExpanded() -
3093 -
3094 \obsolete -
3095 -
3096 This function is deprecated. Use \l{QTreeWidgetItem::isExpanded()} instead. -
3097*/ -
3098bool QTreeWidget::isItemExpanded(const QTreeWidgetItem *item) const -
3099{ -
3100 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
3101 QTreeModel::SkipSorting skipSorting(d->treeModel());
executed (the execution status of this line is deduced): QTreeModel::SkipSorting skipSorting(d->treeModel());
-
3102 return isExpanded(d->index(item));
executed: return isExpanded(d->index(item));
Execution Count:347
347
3103} -
3104 -
3105/*! -
3106 Sets the item referred to by \a item to either closed or opened, -
3107 depending on the value of \a expand. -
3108 -
3109 \sa expandItem(), collapseItem(), itemExpanded() -
3110 -
3111 \obsolete -
3112 -
3113 This function is deprecated. Use \l{QTreeWidgetItem::setExpanded()} instead. -
3114*/ -
3115void QTreeWidget::setItemExpanded(const QTreeWidgetItem *item, bool expand) -
3116{ -
3117 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3118 QTreeModel::SkipSorting skipSorting(d->treeModel());
executed (the execution status of this line is deduced): QTreeModel::SkipSorting skipSorting(d->treeModel());
-
3119 setExpanded(d->index(item), expand);
executed (the execution status of this line is deduced): setExpanded(d->index(item), expand);
-
3120}
executed: }
Execution Count:115
115
3121 -
3122/*! -
3123 \since 4.3 -
3124 -
3125 Returns true if the given \a item is set to show only one section over all columns; -
3126 otherwise returns false. -
3127 -
3128 \sa setFirstItemColumnSpanned() -
3129*/ -
3130bool QTreeWidget::isFirstItemColumnSpanned(const QTreeWidgetItem *item) const -
3131{ -
3132 Q_D(const QTreeWidget);
never executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
3133 if (item == d->treeModel()->headerItem)
never evaluated: item == d->treeModel()->headerItem
0
3134 return false; // We can't set the header items to spanning
never executed: return false;
0
3135 const QModelIndex index = d->index(item);
never executed (the execution status of this line is deduced): const QModelIndex index = d->index(item);
-
3136 return isFirstColumnSpanned(index.row(), index.parent());
never executed: return isFirstColumnSpanned(index.row(), index.parent());
0
3137} -
3138 -
3139/*! -
3140 \since 4.3 -
3141 -
3142 Sets the given \a item to only show one section for all columns if \a span is true; -
3143 otherwise the item will show one section per column. -
3144 -
3145 \sa isFirstItemColumnSpanned() -
3146*/ -
3147void QTreeWidget::setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span) -
3148{ -
3149 Q_D(QTreeWidget);
never executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3150 if (item == d->treeModel()->headerItem)
never evaluated: item == d->treeModel()->headerItem
0
3151 return; // We can't set header items to spanning
never executed: return;
0
3152 const QModelIndex index = d->index(item);
never executed (the execution status of this line is deduced): const QModelIndex index = d->index(item);
-
3153 setFirstColumnSpanned(index.row(), index.parent(), span);
never executed (the execution status of this line is deduced): setFirstColumnSpanned(index.row(), index.parent(), span);
-
3154}
never executed: }
0
3155 -
3156/*! -
3157 \since 4.3 -
3158 -
3159 Returns the item above the given \a item. -
3160*/ -
3161QTreeWidgetItem *QTreeWidget::itemAbove(const QTreeWidgetItem *item) const -
3162{ -
3163 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
3164 if (item == d->treeModel()->headerItem)
partially evaluated: item == d->treeModel()->headerItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
3165 return 0;
never executed: return 0;
0
3166 const QModelIndex index = d->index(item);
executed (the execution status of this line is deduced): const QModelIndex index = d->index(item);
-
3167 const QModelIndex above = indexAbove(index);
executed (the execution status of this line is deduced): const QModelIndex above = indexAbove(index);
-
3168 return d->item(above);
executed: return d->item(above);
Execution Count:1
1
3169} -
3170 -
3171/*! -
3172 \since 4.3 -
3173 -
3174 Returns the item visually below the given \a item. -
3175*/ -
3176QTreeWidgetItem *QTreeWidget::itemBelow(const QTreeWidgetItem *item) const -
3177{ -
3178 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
3179 if (item == d->treeModel()->headerItem)
partially evaluated: item == d->treeModel()->headerItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
3180 return 0;
never executed: return 0;
0
3181 const QModelIndex index = d->index(item);
executed (the execution status of this line is deduced): const QModelIndex index = d->index(item);
-
3182 const QModelIndex below = indexBelow(index);
executed (the execution status of this line is deduced): const QModelIndex below = indexBelow(index);
-
3183 return d->item(below);
executed: return d->item(below);
Execution Count:1
1
3184} -
3185 -
3186/*! -
3187 \reimp -
3188 */ -
3189void QTreeWidget::setSelectionModel(QItemSelectionModel *selectionModel) -
3190{ -
3191 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3192 QTreeView::setSelectionModel(selectionModel);
executed (the execution status of this line is deduced): QTreeView::setSelectionModel(selectionModel);
-
3193 QItemSelection newSelection = selectionModel->selection();
executed (the execution status of this line is deduced): QItemSelection newSelection = selectionModel->selection();
-
3194 if (!newSelection.isEmpty())
evaluated: !newSelection.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:264
1-264
3195 d->_q_selectionChanged(newSelection, QItemSelection());
executed: d->_q_selectionChanged(newSelection, QItemSelection());
Execution Count:1
1
3196}
executed: }
Execution Count:265
265
3197 -
3198/*! -
3199 Ensures that the \a item is visible, scrolling the view if necessary using -
3200 the specified \a hint. -
3201 -
3202 \sa currentItem(), itemAt(), topLevelItem() -
3203*/ -
3204void QTreeWidget::scrollToItem(const QTreeWidgetItem *item, QAbstractItemView::ScrollHint hint) -
3205{ -
3206 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3207 QTreeView::scrollTo(d->index(item), hint);
executed (the execution status of this line is deduced): QTreeView::scrollTo(d->index(item), hint);
-
3208}
executed: }
Execution Count:2
2
3209 -
3210/*! -
3211 Expands the \a item. This causes the tree containing the item's children -
3212 to be expanded. -
3213 -
3214 \sa collapseItem(), currentItem(), itemAt(), topLevelItem(), itemExpanded() -
3215*/ -
3216void QTreeWidget::expandItem(const QTreeWidgetItem *item) -
3217{ -
3218 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3219 QTreeModel::SkipSorting skipSorting(d->treeModel());
executed (the execution status of this line is deduced): QTreeModel::SkipSorting skipSorting(d->treeModel());
-
3220 expand(d->index(item));
executed (the execution status of this line is deduced): expand(d->index(item));
-
3221}
executed: }
Execution Count:6
6
3222 -
3223/*! -
3224 Closes the \a item. This causes the tree containing the item's children -
3225 to be collapsed. -
3226 -
3227 \sa expandItem(), currentItem(), itemAt(), topLevelItem() -
3228*/ -
3229void QTreeWidget::collapseItem(const QTreeWidgetItem *item) -
3230{ -
3231 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3232 QTreeModel::SkipSorting skipSorting(d->treeModel());
executed (the execution status of this line is deduced): QTreeModel::SkipSorting skipSorting(d->treeModel());
-
3233 collapse(d->index(item));
executed (the execution status of this line is deduced): collapse(d->index(item));
-
3234}
executed: }
Execution Count:17
17
3235 -
3236/*! -
3237 Clears the tree widget by removing all of its items and selections. -
3238 -
3239 \b{Note:} Since each item is removed from the tree widget before being -
3240 deleted, the return value of QTreeWidgetItem::treeWidget() will be invalid -
3241 when called from an item's destructor. -
3242 -
3243 \sa takeTopLevelItem(), topLevelItemCount(), columnCount() -
3244*/ -
3245void QTreeWidget::clear() -
3246{ -
3247 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3248 selectionModel()->clear();
executed (the execution status of this line is deduced): selectionModel()->clear();
-
3249 d->treeModel()->clear();
executed (the execution status of this line is deduced): d->treeModel()->clear();
-
3250}
executed: }
Execution Count:166
166
3251 -
3252/*! -
3253 Returns a list of MIME types that can be used to describe a list of -
3254 treewidget items. -
3255 -
3256 \sa mimeData() -
3257*/ -
3258QStringList QTreeWidget::mimeTypes() const -
3259{ -
3260 return model()->QAbstractItemModel::mimeTypes();
executed: return model()->QAbstractItemModel::mimeTypes();
Execution Count:53
53
3261} -
3262 -
3263/*! -
3264 Returns an object that contains a serialized description of the specified -
3265 \a items. The format used to describe the items is obtained from the -
3266 mimeTypes() function. -
3267 -
3268 If the list of items is empty, 0 is returned rather than a serialized -
3269 empty list. -
3270*/ -
3271QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem*> items) const -
3272{ -
3273 Q_D(const QTreeWidget);
never executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
3274 if (d->treeModel()->cachedIndexes.isEmpty()) {
never evaluated: d->treeModel()->cachedIndexes.isEmpty()
0
3275 QList<QModelIndex> indexes;
never executed (the execution status of this line is deduced): QList<QModelIndex> indexes;
-
3276 for (int i = 0; i < items.count(); ++i) {
never evaluated: i < items.count()
0
3277 QTreeWidgetItem *item = items.at(i);
never executed (the execution status of this line is deduced): QTreeWidgetItem *item = items.at(i);
-
3278 for (int c = 0; c < item->values.count(); ++c) {
never evaluated: c < item->values.count()
0
3279 indexes << indexFromItem(item, c);
never executed (the execution status of this line is deduced): indexes << indexFromItem(item, c);
-
3280 }
never executed: }
0
3281 }
never executed: }
0
3282 return d->model->QAbstractItemModel::mimeData(indexes);
never executed: return d->model->QAbstractItemModel::mimeData(indexes);
0
3283 } -
3284 return d->treeModel()->internalMimeData();
never executed: return d->treeModel()->internalMimeData();
0
3285} -
3286 -
3287/*! -
3288 Handles the \a data supplied by a drag and drop operation that ended with -
3289 the given \a action in the \a index in the given \a parent item. -
3290 -
3291 The default implementation returns true if the drop was -
3292 successfully handled by decoding the mime data and inserting it -
3293 into the model; otherwise it returns false. -
3294 -
3295 \sa supportedDropActions() -
3296*/ -
3297bool QTreeWidget::dropMimeData(QTreeWidgetItem *parent, int index, -
3298 const QMimeData *data, Qt::DropAction action) -
3299{ -
3300 QModelIndex idx;
never executed (the execution status of this line is deduced): QModelIndex idx;
-
3301 if (parent) idx = indexFromItem(parent);
never executed: idx = indexFromItem(parent);
never evaluated: parent
0
3302 return model()->QAbstractItemModel::dropMimeData(data, action , index, 0, idx);
never executed: return model()->QAbstractItemModel::dropMimeData(data, action , index, 0, idx);
0
3303} -
3304 -
3305/*! -
3306 Returns the drop actions supported by this view. -
3307 -
3308 \sa Qt::DropActions -
3309*/ -
3310Qt::DropActions QTreeWidget::supportedDropActions() const -
3311{ -
3312 return model()->QAbstractItemModel::supportedDropActions() | Qt::MoveAction;
executed: return model()->QAbstractItemModel::supportedDropActions() | Qt::MoveAction;
Execution Count:53
53
3313} -
3314 -
3315/*! -
3316 \obsolete -
3317 Returns an empty list -
3318 -
3319 \sa mimeData() -
3320*/ -
3321QList<QTreeWidgetItem*> QTreeWidget::items(const QMimeData *data) const -
3322{ -
3323 Q_UNUSED(data);
never executed (the execution status of this line is deduced): (void)data;;
-
3324 return QList<QTreeWidgetItem*>();
never executed: return QList<QTreeWidgetItem*>();
0
3325} -
3326 -
3327/*! -
3328 Returns the QModelIndex assocated with the given \a item in the given \a column. -
3329 -
3330 \sa itemFromIndex(), topLevelItem() -
3331*/ -
3332QModelIndex QTreeWidget::indexFromItem(QTreeWidgetItem *item, int column) const -
3333{ -
3334 Q_D(const QTreeWidget);
executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
3335 return d->index(item, column);
executed: return d->index(item, column);
Execution Count:24
24
3336} -
3337 -
3338/*! -
3339 Returns a pointer to the QTreeWidgetItem assocated with the given \a index. -
3340 -
3341 \sa indexFromItem() -
3342*/ -
3343QTreeWidgetItem *QTreeWidget::itemFromIndex(const QModelIndex &index) const -
3344{ -
3345 Q_D(const QTreeWidget);
never executed (the execution status of this line is deduced): const QTreeWidgetPrivate * const d = d_func();
-
3346 return d->item(index);
never executed: return d->item(index);
0
3347} -
3348 -
3349#ifndef QT_NO_DRAGANDDROP -
3350/*! \reimp */ -
3351void QTreeWidget::dropEvent(QDropEvent *event) { -
3352 Q_D(QTreeWidget);
never executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3353 if (event->source() == this && (event->dropAction() == Qt::MoveAction ||
never evaluated: event->source() == this
never evaluated: event->dropAction() == Qt::MoveAction
0
3354 dragDropMode() == QAbstractItemView::InternalMove)) {
never evaluated: dragDropMode() == QAbstractItemView::InternalMove
0
3355 QModelIndex topIndex;
never executed (the execution status of this line is deduced): QModelIndex topIndex;
-
3356 int col = -1;
never executed (the execution status of this line is deduced): int col = -1;
-
3357 int row = -1;
never executed (the execution status of this line is deduced): int row = -1;
-
3358 if (d->dropOn(event, &row, &col, &topIndex)) {
never evaluated: d->dropOn(event, &row, &col, &topIndex)
0
3359 QList<QModelIndex> idxs = selectedIndexes();
never executed (the execution status of this line is deduced): QList<QModelIndex> idxs = selectedIndexes();
-
3360 QList<QPersistentModelIndex> indexes;
never executed (the execution status of this line is deduced): QList<QPersistentModelIndex> indexes;
-
3361 for (int i = 0; i < idxs.count(); i++)
never evaluated: i < idxs.count()
0
3362 indexes.append(idxs.at(i));
never executed: indexes.append(idxs.at(i));
0
3363 -
3364 if (indexes.contains(topIndex))
never evaluated: indexes.contains(topIndex)
0
3365 return;
never executed: return;
0
3366 -
3367 // When removing items the drop location could shift -
3368 QPersistentModelIndex dropRow = model()->index(row, col, topIndex);
never executed (the execution status of this line is deduced): QPersistentModelIndex dropRow = model()->index(row, col, topIndex);
-
3369 -
3370 // Remove the items -
3371 QList<QTreeWidgetItem *> taken;
never executed (the execution status of this line is deduced): QList<QTreeWidgetItem *> taken;
-
3372 for (int i = indexes.count() - 1; i >= 0; --i) {
never evaluated: i >= 0
0
3373 QTreeWidgetItem *parent = itemFromIndex(indexes.at(i));
never executed (the execution status of this line is deduced): QTreeWidgetItem *parent = itemFromIndex(indexes.at(i));
-
3374 if (!parent || !parent->parent()) {
never evaluated: !parent
never evaluated: !parent->parent()
0
3375 taken.append(takeTopLevelItem(indexes.at(i).row()));
never executed (the execution status of this line is deduced): taken.append(takeTopLevelItem(indexes.at(i).row()));
-
3376 } else {
never executed: }
0
3377 taken.append(parent->parent()->takeChild(indexes.at(i).row()));
never executed (the execution status of this line is deduced): taken.append(parent->parent()->takeChild(indexes.at(i).row()));
-
3378 }
never executed: }
0
3379 } -
3380 -
3381 // insert them back in at their new positions -
3382 for (int i = 0; i < indexes.count(); ++i) {
never evaluated: i < indexes.count()
0
3383 // Either at a specific point or appended -
3384 if (row == -1) {
never evaluated: row == -1
0
3385 if (topIndex.isValid()) {
never evaluated: topIndex.isValid()
0
3386 QTreeWidgetItem *parent = itemFromIndex(topIndex);
never executed (the execution status of this line is deduced): QTreeWidgetItem *parent = itemFromIndex(topIndex);
-
3387 parent->insertChild(parent->childCount(), taken.takeFirst());
never executed (the execution status of this line is deduced): parent->insertChild(parent->childCount(), taken.takeFirst());
-
3388 } else {
never executed: }
0
3389 insertTopLevelItem(topLevelItemCount(), taken.takeFirst());
never executed (the execution status of this line is deduced): insertTopLevelItem(topLevelItemCount(), taken.takeFirst());
-
3390 }
never executed: }
0
3391 } else { -
3392 int r = dropRow.row() >= 0 ? dropRow.row() : row;
never evaluated: dropRow.row() >= 0
0
3393 if (topIndex.isValid()) {
never evaluated: topIndex.isValid()
0
3394 QTreeWidgetItem *parent = itemFromIndex(topIndex);
never executed (the execution status of this line is deduced): QTreeWidgetItem *parent = itemFromIndex(topIndex);
-
3395 parent->insertChild(qMin(r, parent->childCount()), taken.takeFirst());
never executed (the execution status of this line is deduced): parent->insertChild(qMin(r, parent->childCount()), taken.takeFirst());
-
3396 } else {
never executed: }
0
3397 insertTopLevelItem(qMin(r, topLevelItemCount()), taken.takeFirst());
never executed (the execution status of this line is deduced): insertTopLevelItem(qMin(r, topLevelItemCount()), taken.takeFirst());
-
3398 }
never executed: }
0
3399 } -
3400 } -
3401 -
3402 event->accept();
never executed (the execution status of this line is deduced): event->accept();
-
3403 // Don't want QAbstractItemView to delete it because it was "moved" we already did it -
3404 event->setDropAction(Qt::CopyAction);
never executed (the execution status of this line is deduced): event->setDropAction(Qt::CopyAction);
-
3405 }
never executed: }
0
3406 }
never executed: }
0
3407 -
3408 QTreeView::dropEvent(event);
never executed (the execution status of this line is deduced): QTreeView::dropEvent(event);
-
3409}
never executed: }
0
3410#endif -
3411 -
3412/*! -
3413 \reimp -
3414*/ -
3415 -
3416void QTreeWidget::setModel(QAbstractItemModel * /*model*/) -
3417{ -
3418 Q_ASSERT(!"QTreeWidget::setModel() - Changing the model of the QTreeWidget is not allowed.");
never executed (the execution status of this line is deduced): qt_noop();
-
3419}
never executed: }
0
3420 -
3421/*! -
3422 \reimp -
3423*/ -
3424bool QTreeWidget::event(QEvent *e) -
3425{ -
3426 Q_D(QTreeWidget);
executed (the execution status of this line is deduced): QTreeWidgetPrivate * const d = d_func();
-
3427 if (e->type() == QEvent::Polish)
evaluated: e->type() == QEvent::Polish
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:2115
29-2115
3428 d->treeModel()->executePendingSort();
executed: d->treeModel()->executePendingSort();
Execution Count:29
29
3429 return QTreeView::event(e);
executed: return QTreeView::event(e);
Execution Count:2144
2144
3430} -
3431 -
3432QT_END_NAMESPACE -
3433 -
3434#include "moc_qtreewidget.cpp" -
3435 -
3436#endif // QT_NO_TREEWIDGET -
3437 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial