itemviews/qtreeview.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#include "qtreeview.h" -
42 -
43#ifndef QT_NO_TREEVIEW -
44#include <qheaderview.h> -
45#include <qitemdelegate.h> -
46#include <qapplication.h> -
47#include <qscrollbar.h> -
48#include <qpainter.h> -
49#include <qstack.h> -
50#include <qstyle.h> -
51#include <qstyleoption.h> -
52#include <qevent.h> -
53#include <qpen.h> -
54#include <qdebug.h> -
55#ifndef QT_NO_ACCESSIBILITY -
56#include <qaccessible.h> -
57#include <qaccessible2.h> -
58#endif -
59 -
60#include <private/qtreeview_p.h> -
61#include <private/qheaderview_p.h> -
62 -
63QT_BEGIN_NAMESPACE -
64 -
65/*! -
66 \class QTreeView -
67 \brief The QTreeView class provides a default model/view implementation of a tree view. -
68 -
69 \ingroup model-view -
70 \ingroup advanced -
71 \inmodule QtWidgets -
72 -
73 A QTreeView implements a tree representation of items from a -
74 model. This class is used to provide standard hierarchical lists that -
75 were previously provided by the \c QListView class, but using the more -
76 flexible approach provided by Qt's model/view architecture. -
77 -
78 The QTreeView class is one of the \l{Model/View Classes} and is part of -
79 Qt's \l{Model/View Programming}{model/view framework}. -
80 -
81 QTreeView implements the interfaces defined by the -
82 QAbstractItemView class to allow it to display data provided by -
83 models derived from the QAbstractItemModel class. -
84 -
85 It is simple to construct a tree view displaying data from a -
86 model. In the following example, the contents of a directory are -
87 supplied by a QFileSystemModel and displayed as a tree: -
88 -
89 \snippet shareddirmodel/main.cpp 3 -
90 \snippet shareddirmodel/main.cpp 6 -
91 -
92 The model/view architecture ensures that the contents of the tree view -
93 are updated as the model changes. -
94 -
95 Items that have children can be in an expanded (children are -
96 visible) or collapsed (children are hidden) state. When this state -
97 changes a collapsed() or expanded() signal is emitted with the -
98 model index of the relevant item. -
99 -
100 The amount of indentation used to indicate levels of hierarchy is -
101 controlled by the \l indentation property. -
102 -
103 Headers in tree views are constructed using the QHeaderView class and can -
104 be hidden using \c{header()->hide()}. Note that each header is configured -
105 with its \l{QHeaderView::}{stretchLastSection} property set to true, -
106 ensuring that the view does not waste any of the space assigned to it for -
107 its header. If this value is set to true, this property will override the -
108 resize mode set on the last section in the header. -
109 -
110 -
111 \section1 Key Bindings -
112 -
113 QTreeView supports a set of key bindings that enable the user to -
114 navigate in the view and interact with the contents of items: -
115 -
116 \table -
117 \header \li Key \li Action -
118 \row \li Up \li Moves the cursor to the item in the same column on -
119 the previous row. If the parent of the current item has no more rows to -
120 navigate to, the cursor moves to the relevant item in the last row -
121 of the sibling that precedes the parent. -
122 \row \li Down \li Moves the cursor to the item in the same column on -
123 the next row. If the parent of the current item has no more rows to -
124 navigate to, the cursor moves to the relevant item in the first row -
125 of the sibling that follows the parent. -
126 \row \li Left \li Hides the children of the current item (if present) -
127 by collapsing a branch. -
128 \row \li Minus \li Same as LeftArrow. -
129 \row \li Right \li Reveals the children of the current item (if present) -
130 by expanding a branch. -
131 \row \li Plus \li Same as RightArrow. -
132 \row \li Asterisk \li Expands all children of the current item (if present). -
133 \row \li PageUp \li Moves the cursor up one page. -
134 \row \li PageDown \li Moves the cursor down one page. -
135 \row \li Home \li Moves the cursor to an item in the same column of the first -
136 row of the first top-level item in the model. -
137 \row \li End \li Moves the cursor to an item in the same column of the last -
138 row of the last top-level item in the model. -
139 \row \li F2 \li In editable models, this opens the current item for editing. -
140 The Escape key can be used to cancel the editing process and revert -
141 any changes to the data displayed. -
142 \endtable -
143 -
144 \omit -
145 Describe the expanding/collapsing concept if not covered elsewhere. -
146 \endomit -
147 -
148 \table 100% -
149 \row \li \inlineimage windowsvista-treeview.png Screenshot of a Windows Vista style tree view -
150 \li \inlineimage macintosh-treeview.png Screenshot of a Macintosh style tree view -
151 \li \inlineimage fusion-treeview.png Screenshot of a Fusion style tree view -
152 \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} tree view. -
153 \li A \l{Macintosh Style Widget Gallery}{Macintosh style} tree view. -
154 \li A \l{Fusion Style Widget Gallery}{Fusion style} tree view. -
155 \endtable -
156 -
157 \section1 Improving Performance -
158 -
159 It is possible to give the view hints about the data it is handling in order -
160 to improve its performance when displaying large numbers of items. One approach -
161 that can be taken for views that are intended to display items with equal heights -
162 is to set the \l uniformRowHeights property to true. -
163 -
164 \sa QListView, QTreeWidget, {View Classes}, QAbstractItemModel, QAbstractItemView, -
165 {Dir View Example} -
166*/ -
167 -
168 -
169/*! -
170 \fn void QTreeView::expanded(const QModelIndex &index) -
171 -
172 This signal is emitted when the item specified by \a index is expanded. -
173*/ -
174 -
175 -
176/*! -
177 \fn void QTreeView::collapsed(const QModelIndex &index) -
178 -
179 This signal is emitted when the item specified by \a index is collapsed. -
180*/ -
181 -
182/*! -
183 Constructs a tree view with a \a parent to represent a model's -
184 data. Use setModel() to set the model. -
185 -
186 \sa QAbstractItemModel -
187*/ -
188QTreeView::QTreeView(QWidget *parent) -
189 : QAbstractItemView(*new QTreeViewPrivate, parent) -
190{ -
191 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
192 d->initialize();
executed (the execution status of this line is deduced): d->initialize();
-
193}
executed: }
Execution Count:406
406
194 -
195/*! -
196 \internal -
197*/ -
198QTreeView::QTreeView(QTreeViewPrivate &dd, QWidget *parent) -
199 : QAbstractItemView(dd, parent) -
200{ -
201 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
202 d->initialize();
executed (the execution status of this line is deduced): d->initialize();
-
203}
executed: }
Execution Count:264
264
204 -
205/*! -
206 Destroys the tree view. -
207*/ -
208QTreeView::~QTreeView() -
209{ -
210} -
211 -
212/*! -
213 \reimp -
214*/ -
215void QTreeView::setModel(QAbstractItemModel *model) -
216{ -
217 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
218 if (model == d->model)
evaluated: model == d->model
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:633
2-633
219 return;
executed: return;
Execution Count:2
2
220 if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) {
partially evaluated: d->model
TRUEFALSE
yes
Evaluation Count:633
no
Evaluation Count:0
evaluated: d->model != QAbstractItemModelPrivate::staticEmptyModel()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:627
0-633
221 disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsRemoved(QModelIndex,int,int)",
-
222 this, SLOT(rowsRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""rowsRemoved(QModelIndex,int,int)");
-
223 -
224 disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_modelAboutToBeReset()));
executed (the execution status of this line is deduced): disconnect(d->model, "2""modelAboutToBeReset()", this, "1""_q_modelAboutToBeReset()");
-
225 }
executed: }
Execution Count:6
6
226 -
227 if (d->selectionModel) { // support row editing
evaluated: d->selectionModel
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:623
10-623
228 disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
executed (the execution status of this line is deduced): disconnect(d->selectionModel, "2""currentRowChanged(QModelIndex,QModelIndex)",
-
229 d->model, SLOT(submit()));
executed (the execution status of this line is deduced): d->model, "1""submit()");
-
230 disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsRemoved(QModelIndex,int,int)",
-
231 this, SLOT(rowsRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""rowsRemoved(QModelIndex,int,int)");
-
232 disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_modelAboutToBeReset()));
executed (the execution status of this line is deduced): disconnect(d->model, "2""modelAboutToBeReset()", this, "1""_q_modelAboutToBeReset()");
-
233 }
executed: }
Execution Count:10
10
234 d->viewItems.clear();
executed (the execution status of this line is deduced): d->viewItems.clear();
-
235 d->expandedIndexes.clear();
executed (the execution status of this line is deduced): d->expandedIndexes.clear();
-
236 d->hiddenIndexes.clear();
executed (the execution status of this line is deduced): d->hiddenIndexes.clear();
-
237 d->header->setModel(model);
executed (the execution status of this line is deduced): d->header->setModel(model);
-
238 QAbstractItemView::setModel(model);
executed (the execution status of this line is deduced): QAbstractItemView::setModel(model);
-
239 -
240 // QAbstractItemView connects to a private slot -
241 disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsRemoved(QModelIndex,int,int)",
-
242 this, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""_q_rowsRemoved(QModelIndex,int,int)");
-
243 // do header layout after the tree -
244 disconnect(d->model, SIGNAL(layoutChanged()),
executed (the execution status of this line is deduced): disconnect(d->model, "2""layoutChanged()",
-
245 d->header, SLOT(_q_layoutChanged()));
executed (the execution status of this line is deduced): d->header, "1""_q_layoutChanged()");
-
246 // QTreeView has a public slot for this -
247 connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
executed (the execution status of this line is deduced): connect(d->model, "2""rowsRemoved(QModelIndex,int,int)",
-
248 this, SLOT(rowsRemoved(QModelIndex,int,int)));
executed (the execution status of this line is deduced): this, "1""rowsRemoved(QModelIndex,int,int)");
-
249 -
250 connect(d->model, SIGNAL(modelAboutToBeReset()), SLOT(_q_modelAboutToBeReset()));
executed (the execution status of this line is deduced): connect(d->model, "2""modelAboutToBeReset()", "1""_q_modelAboutToBeReset()");
-
251 -
252 if (d->sortingEnabled)
evaluated: d->sortingEnabled
TRUEFALSE
yes
Evaluation Count:195
yes
Evaluation Count:438
195-438
253 d->_q_sortIndicatorChanged(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
executed: d->_q_sortIndicatorChanged(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
Execution Count:195
195
254}
executed: }
Execution Count:633
633
255 -
256/*! -
257 \reimp -
258*/ -
259void QTreeView::setRootIndex(const QModelIndex &index) -
260{ -
261 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
262 d->header->setRootIndex(index);
executed (the execution status of this line is deduced): d->header->setRootIndex(index);
-
263 QAbstractItemView::setRootIndex(index);
executed (the execution status of this line is deduced): QAbstractItemView::setRootIndex(index);
-
264}
executed: }
Execution Count:1160
1160
265 -
266/*! -
267 \reimp -
268*/ -
269void QTreeView::setSelectionModel(QItemSelectionModel *selectionModel) -
270{ -
271 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
272 Q_ASSERT(selectionModel);
executed (the execution status of this line is deduced): qt_noop();
-
273 if (d->selectionModel) {
evaluated: d->selectionModel
TRUEFALSE
yes
Evaluation Count:203
yes
Evaluation Count:623
203-623
274 // support row editing -
275 disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
executed (the execution status of this line is deduced): disconnect(d->selectionModel, "2""currentRowChanged(QModelIndex,QModelIndex)",
-
276 d->model, SLOT(submit()));
executed (the execution status of this line is deduced): d->model, "1""submit()");
-
277 }
executed: }
Execution Count:203
203
278 -
279 d->header->setSelectionModel(selectionModel);
executed (the execution status of this line is deduced): d->header->setSelectionModel(selectionModel);
-
280 QAbstractItemView::setSelectionModel(selectionModel);
executed (the execution status of this line is deduced): QAbstractItemView::setSelectionModel(selectionModel);
-
281 -
282 if (d->selectionModel) {
partially evaluated: d->selectionModel
TRUEFALSE
yes
Evaluation Count:826
no
Evaluation Count:0
0-826
283 // support row editing -
284 connect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
executed (the execution status of this line is deduced): connect(d->selectionModel, "2""currentRowChanged(QModelIndex,QModelIndex)",
-
285 d->model, SLOT(submit()));
executed (the execution status of this line is deduced): d->model, "1""submit()");
-
286 }
executed: }
Execution Count:826
826
287}
executed: }
Execution Count:826
826
288 -
289/*! -
290 Returns the header for the tree view. -
291 -
292 \sa QAbstractItemModel::headerData() -
293*/ -
294QHeaderView *QTreeView::header() const -
295{ -
296 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
297 return d->header;
executed: return d->header;
Execution Count:6185
6185
298} -
299 -
300/*! -
301 Sets the header for the tree view, to the given \a header. -
302 -
303 The view takes ownership over the given \a header and deletes it -
304 when a new header is set. -
305 -
306 \sa QAbstractItemModel::headerData() -
307*/ -
308void QTreeView::setHeader(QHeaderView *header) -
309{ -
310 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
311 if (header == d->header || !header)
evaluated: header == d->header
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:674
evaluated: !header
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:672
2-674
312 return;
executed: return;
Execution Count:4
4
313 if (d->header && d->header->parent() == this)
evaluated: d->header
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:670
partially evaluated: d->header->parent() == this
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-670
314 delete d->header;
executed: delete d->header;
Execution Count:2
2
315 d->header = header;
executed (the execution status of this line is deduced): d->header = header;
-
316 d->header->setParent(this);
executed (the execution status of this line is deduced): d->header->setParent(this);
-
317 d->header->d_func()->setAllowUserMoveOfSection0(false);
executed (the execution status of this line is deduced): d->header->d_func()->setAllowUserMoveOfSection0(false);
-
318 -
319 if (!d->header->model()) {
partially evaluated: !d->header->model()
TRUEFALSE
yes
Evaluation Count:672
no
Evaluation Count:0
0-672
320 d->header->setModel(d->model);
executed (the execution status of this line is deduced): d->header->setModel(d->model);
-
321 if (d->selectionModel)
partially evaluated: d->selectionModel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:672
0-672
322 d->header->setSelectionModel(d->selectionModel);
never executed: d->header->setSelectionModel(d->selectionModel);
0
323 }
executed: }
Execution Count:672
672
324 -
325 connect(d->header, SIGNAL(sectionResized(int,int,int)),
executed (the execution status of this line is deduced): connect(d->header, "2""sectionResized(int,int,int)",
-
326 this, SLOT(columnResized(int,int,int)));
executed (the execution status of this line is deduced): this, "1""columnResized(int,int,int)");
-
327 connect(d->header, SIGNAL(sectionMoved(int,int,int)),
executed (the execution status of this line is deduced): connect(d->header, "2""sectionMoved(int,int,int)",
-
328 this, SLOT(columnMoved()));
executed (the execution status of this line is deduced): this, "1""columnMoved()");
-
329 connect(d->header, SIGNAL(sectionCountChanged(int,int)),
executed (the execution status of this line is deduced): connect(d->header, "2""sectionCountChanged(int,int)",
-
330 this, SLOT(columnCountChanged(int,int)));
executed (the execution status of this line is deduced): this, "1""columnCountChanged(int,int)");
-
331 connect(d->header, SIGNAL(sectionHandleDoubleClicked(int)),
executed (the execution status of this line is deduced): connect(d->header, "2""sectionHandleDoubleClicked(int)",
-
332 this, SLOT(resizeColumnToContents(int)));
executed (the execution status of this line is deduced): this, "1""resizeColumnToContents(int)");
-
333 connect(d->header, SIGNAL(geometriesChanged()),
executed (the execution status of this line is deduced): connect(d->header, "2""geometriesChanged()",
-
334 this, SLOT(updateGeometries()));
executed (the execution status of this line is deduced): this, "1""updateGeometries()");
-
335 -
336 setSortingEnabled(d->sortingEnabled);
executed (the execution status of this line is deduced): setSortingEnabled(d->sortingEnabled);
-
337}
executed: }
Execution Count:672
672
338 -
339/*! -
340 \property QTreeView::autoExpandDelay -
341 \brief The delay time before items in a tree are opened during a drag and drop operation. -
342 \since 4.3 -
343 -
344 This property holds the amount of time in milliseconds that the user must wait over -
345 a node before that node will automatically open or close. If the time is -
346 set to less then 0 then it will not be activated. -
347 -
348 By default, this property has a value of -1, meaning that auto-expansion is disabled. -
349*/ -
350int QTreeView::autoExpandDelay() const -
351{ -
352 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
353 return d->autoExpandDelay;
executed: return d->autoExpandDelay;
Execution Count:1
1
354} -
355 -
356void QTreeView::setAutoExpandDelay(int delay) -
357{ -
358 Q_D(QTreeView);
never executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
359 d->autoExpandDelay = delay;
never executed (the execution status of this line is deduced): d->autoExpandDelay = delay;
-
360}
never executed: }
0
361 -
362/*! -
363 \property QTreeView::indentation -
364 \brief indentation of the items in the tree view. -
365 -
366 This property holds the indentation measured in pixels of the items for each -
367 level in the tree view. For top-level items, the indentation specifies the -
368 horizontal distance from the viewport edge to the items in the first column; -
369 for child items, it specifies their indentation from their parent items. -
370 -
371 By default, this property has a value of 20. -
372*/ -
373int QTreeView::indentation() const -
374{ -
375 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
376 return d->indent;
executed: return d->indent;
Execution Count:12
12
377} -
378 -
379void QTreeView::setIndentation(int i) -
380{ -
381 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
382 if (i != d->indent) {
partially evaluated: i != d->indent
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
383 d->indent = i;
executed (the execution status of this line is deduced): d->indent = i;
-
384 d->viewport->update();
executed (the execution status of this line is deduced): d->viewport->update();
-
385 }
executed: }
Execution Count:3
3
386}
executed: }
Execution Count:3
3
387 -
388/*! -
389 \property QTreeView::rootIsDecorated -
390 \brief whether to show controls for expanding and collapsing top-level items -
391 -
392 Items with children are typically shown with controls to expand and collapse -
393 them, allowing their children to be shown or hidden. If this property is -
394 false, these controls are not shown for top-level items. This can be used to -
395 make a single level tree structure appear like a simple list of items. -
396 -
397 By default, this property is true. -
398*/ -
399bool QTreeView::rootIsDecorated() const -
400{ -
401 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
402 return d->rootDecoration;
executed: return d->rootDecoration;
Execution Count:4
4
403} -
404 -
405void QTreeView::setRootIsDecorated(bool show) -
406{ -
407 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
408 if (show != d->rootDecoration) {
partially evaluated: show != d->rootDecoration
TRUEFALSE
yes
Evaluation Count:197
no
Evaluation Count:0
0-197
409 d->rootDecoration = show;
executed (the execution status of this line is deduced): d->rootDecoration = show;
-
410 d->viewport->update();
executed (the execution status of this line is deduced): d->viewport->update();
-
411 }
executed: }
Execution Count:197
197
412}
executed: }
Execution Count:197
197
413 -
414/*! -
415 \property QTreeView::uniformRowHeights -
416 \brief whether all items in the treeview have the same height -
417 -
418 This property should only be set to true if it is guaranteed that all items -
419 in the view has the same height. This enables the view to do some -
420 optimizations. -
421 -
422 The height is obtained from the first item in the view. It is updated -
423 when the data changes on that item. -
424 -
425 By default, this property is false. -
426*/ -
427bool QTreeView::uniformRowHeights() const -
428{ -
429 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
430 return d->uniformRowHeights;
executed: return d->uniformRowHeights;
Execution Count:4
4
431} -
432 -
433void QTreeView::setUniformRowHeights(bool uniform) -
434{ -
435 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
436 d->uniformRowHeights = uniform;
executed (the execution status of this line is deduced): d->uniformRowHeights = uniform;
-
437}
executed: }
Execution Count:16
16
438 -
439/*! -
440 \property QTreeView::itemsExpandable -
441 \brief whether the items are expandable by the user. -
442 -
443 This property holds whether the user can expand and collapse items -
444 interactively. -
445 -
446 By default, this property is true. -
447 -
448*/ -
449bool QTreeView::itemsExpandable() const -
450{ -
451 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
452 return d->itemsExpandable;
executed: return d->itemsExpandable;
Execution Count:4
4
453} -
454 -
455void QTreeView::setItemsExpandable(bool enable) -
456{ -
457 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
458 d->itemsExpandable = enable;
executed (the execution status of this line is deduced): d->itemsExpandable = enable;
-
459}
executed: }
Execution Count:201
201
460 -
461/*! -
462 \property QTreeView::expandsOnDoubleClick -
463 \since 4.4 -
464 \brief whether the items can be expanded by double-clicking. -
465 -
466 This property holds whether the user can expand and collapse items -
467 by double-clicking. The default value is true. -
468 -
469 \sa itemsExpandable -
470*/ -
471bool QTreeView::expandsOnDoubleClick() const -
472{ -
473 Q_D(const QTreeView);
never executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
474 return d->expandsOnDoubleClick;
never executed: return d->expandsOnDoubleClick;
0
475} -
476 -
477void QTreeView::setExpandsOnDoubleClick(bool enable) -
478{ -
479 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
480 d->expandsOnDoubleClick = enable;
executed (the execution status of this line is deduced): d->expandsOnDoubleClick = enable;
-
481}
executed: }
Execution Count:1
1
482 -
483/*! -
484 Returns the horizontal position of the \a column in the viewport. -
485*/ -
486int QTreeView::columnViewportPosition(int column) const -
487{ -
488 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
489 return d->header->sectionViewportPosition(column);
executed: return d->header->sectionViewportPosition(column);
Execution Count:24951
24951
490} -
491 -
492/*! -
493 Returns the width of the \a column. -
494 -
495 \sa resizeColumnToContents(), setColumnWidth() -
496*/ -
497int QTreeView::columnWidth(int column) const -
498{ -
499 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
500 return d->header->sectionSize(column);
executed: return d->header->sectionSize(column);
Execution Count:18976
18976
501} -
502 -
503/*! -
504 \since 4.2 -
505 -
506 Sets the width of the given \a column to the \a width specified. -
507 -
508 \sa columnWidth(), resizeColumnToContents() -
509*/ -
510void QTreeView::setColumnWidth(int column, int width) -
511{ -
512 Q_D(QTreeView);
never executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
513 d->header->resizeSection(column, width);
never executed (the execution status of this line is deduced): d->header->resizeSection(column, width);
-
514}
never executed: }
0
515 -
516/*! -
517 Returns the column in the tree view whose header covers the \a x -
518 coordinate given. -
519*/ -
520int QTreeView::columnAt(int x) const -
521{ -
522 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
523 return d->header->logicalIndexAt(x);
executed: return d->header->logicalIndexAt(x);
Execution Count:4
4
524} -
525 -
526/*! -
527 Returns true if the \a column is hidden; otherwise returns false. -
528 -
529 \sa hideColumn(), isRowHidden() -
530*/ -
531bool QTreeView::isColumnHidden(int column) const -
532{ -
533 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
534 return d->header->isSectionHidden(column);
executed: return d->header->isSectionHidden(column);
Execution Count:18632
18632
535} -
536 -
537/*! -
538 If \a hide is true the \a column is hidden, otherwise the \a column is shown. -
539 -
540 \sa hideColumn(), setRowHidden() -
541*/ -
542void QTreeView::setColumnHidden(int column, bool hide) -
543{ -
544 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
545 if (column < 0 || column >= d->header->count())
partially evaluated: column < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
partially evaluated: column >= d->header->count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
546 return;
never executed: return;
0
547 d->header->setSectionHidden(column, hide);
executed (the execution status of this line is deduced): d->header->setSectionHidden(column, hide);
-
548}
executed: }
Execution Count:46
46
549 -
550/*! -
551 \property QTreeView::headerHidden -
552 \brief whether the header is shown or not. -
553 \since 4.4 -
554 -
555 If this property is true, the header is not shown otherwise it is. -
556 The default value is false. -
557 -
558 \sa header() -
559*/ -
560bool QTreeView::isHeaderHidden() const -
561{ -
562 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
563 return d->header->isHidden();
executed: return d->header->isHidden();
Execution Count:2
2
564} -
565 -
566void QTreeView::setHeaderHidden(bool hide) -
567{ -
568 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
569 d->header->setHidden(hide);
executed (the execution status of this line is deduced): d->header->setHidden(hide);
-
570}
executed: }
Execution Count:1
1
571 -
572/*! -
573 Returns true if the item in the given \a row of the \a parent is hidden; -
574 otherwise returns false. -
575 -
576 \sa setRowHidden(), isColumnHidden() -
577*/ -
578bool QTreeView::isRowHidden(int row, const QModelIndex &parent) const -
579{ -
580 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
581 if (!d->model)
partially evaluated: !d->model
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24494
0-24494
582 return false;
never executed: return false;
0
583 return d->isRowHidden(d->model->index(row, 0, parent));
executed: return d->isRowHidden(d->model->index(row, 0, parent));
Execution Count:24494
24494
584} -
585 -
586/*! -
587 If \a hide is true the \a row with the given \a parent is hidden, otherwise the \a row is shown. -
588 -
589 \sa isRowHidden(), setColumnHidden() -
590*/ -
591void QTreeView::setRowHidden(int row, const QModelIndex &parent, bool hide) -
592{ -
593 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
594 if (!d->model)
partially evaluated: !d->model
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4194
0-4194
595 return;
never executed: return;
0
596 QModelIndex index = d->model->index(row, 0, parent);
executed (the execution status of this line is deduced): QModelIndex index = d->model->index(row, 0, parent);
-
597 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4191
3-4191
598 return;
executed: return;
Execution Count:3
3
599 -
600 if (hide) {
evaluated: hide
TRUEFALSE
yes
Evaluation Count:2117
yes
Evaluation Count:2074
2074-2117
601 d->hiddenIndexes.insert(index);
executed (the execution status of this line is deduced): d->hiddenIndexes.insert(index);
-
602 } else if(d->isPersistent(index)) { //if the index is not persistent, it cannot be in the set
executed: }
Execution Count:2117
evaluated: d->isPersistent(index)
TRUEFALSE
yes
Evaluation Count:1374
yes
Evaluation Count:700
700-2117
603 d->hiddenIndexes.remove(index);
executed (the execution status of this line is deduced): d->hiddenIndexes.remove(index);
-
604 }
executed: }
Execution Count:1374
1374
605 -
606 d->doDelayedItemsLayout();
executed (the execution status of this line is deduced): d->doDelayedItemsLayout();
-
607}
executed: }
Execution Count:4191
4191
608 -
609/*! -
610 \since 4.3 -
611 -
612 Returns true if the item in first column in the given \a row -
613 of the \a parent is spanning all the columns; otherwise returns false. -
614 -
615 \sa setFirstColumnSpanned() -
616*/ -
617bool QTreeView::isFirstColumnSpanned(int row, const QModelIndex &parent) const -
618{ -
619 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
620 if (d->spanningIndexes.isEmpty() || !d->model)
evaluated: d->spanningIndexes.isEmpty()
TRUEFALSE
yes
Evaluation Count:9235
yes
Evaluation Count:34
partially evaluated: !d->model
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-9235
621 return false;
executed: return false;
Execution Count:9235
9235
622 QModelIndex index = d->model->index(row, 0, parent);
executed (the execution status of this line is deduced): QModelIndex index = d->model->index(row, 0, parent);
-
623 for (int i = 0; i < d->spanningIndexes.count(); ++i)
evaluated: i < d->spanningIndexes.count()
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:23
23-64
624 if (d->spanningIndexes.at(i) == index)
evaluated: d->spanningIndexes.at(i) == index
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:53
11-53
625 return true;
executed: return true;
Execution Count:11
11
626 return false;
executed: return false;
Execution Count:23
23
627} -
628 -
629/*! -
630 \since 4.3 -
631 -
632 If \a span is true the item in the first column in the \a row -
633 with the given \a parent is set to span all columns, otherwise all items -
634 on the \a row are shown. -
635 -
636 \sa isFirstColumnSpanned() -
637*/ -
638void QTreeView::setFirstColumnSpanned(int row, const QModelIndex &parent, bool span) -
639{ -
640 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
641 if (!d->model)
partially evaluated: !d->model
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
642 return;
never executed: return;
0
643 QModelIndex index = d->model->index(row, 0, parent);
executed (the execution status of this line is deduced): QModelIndex index = d->model->index(row, 0, parent);
-
644 if (!index.isValid())
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
645 return;
never executed: return;
0
646 -
647 if (span) {
partially evaluated: span
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
648 QPersistentModelIndex persistent(index);
executed (the execution status of this line is deduced): QPersistentModelIndex persistent(index);
-
649 if (!d->spanningIndexes.contains(persistent))
partially evaluated: !d->spanningIndexes.contains(persistent)
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
650 d->spanningIndexes.append(persistent);
executed: d->spanningIndexes.append(persistent);
Execution Count:9
9
651 } else {
executed: }
Execution Count:9
9
652 QPersistentModelIndex persistent(index);
never executed (the execution status of this line is deduced): QPersistentModelIndex persistent(index);
-
653 int i = d->spanningIndexes.indexOf(persistent);
never executed (the execution status of this line is deduced): int i = d->spanningIndexes.indexOf(persistent);
-
654 if (i >= 0)
never evaluated: i >= 0
0
655 d->spanningIndexes.remove(i);
never executed: d->spanningIndexes.remove(i);
0
656 }
never executed: }
0
657 -
658 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
659 int i = d->viewIndex(index);
executed (the execution status of this line is deduced): int i = d->viewIndex(index);
-
660 if (i >= 0)
partially evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
661 d->viewItems[i].spanning = span;
executed: d->viewItems[i].spanning = span;
Execution Count:9
9
662 -
663 d->viewport->update();
executed (the execution status of this line is deduced): d->viewport->update();
-
664}
executed: }
Execution Count:9
9
665 -
666/*! -
667 \reimp -
668*/ -
669void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) -
670{ -
671 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
672 -
673 // if we are going to do a complete relayout anyway, there is no need to update -
674 if (d->delayedPendingLayout)
evaluated: d->delayedPendingLayout
TRUEFALSE
yes
Evaluation Count:5957
yes
Evaluation Count:523
523-5957
675 return;
executed: return;
Execution Count:5957
5957
676 -
677 // refresh the height cache here; we don't really lose anything by getting the size hint, -
678 // since QAbstractItemView::dataChanged() will get the visualRect for the items anyway -
679 -
680 bool sizeChanged = false;
executed (the execution status of this line is deduced): bool sizeChanged = false;
-
681 int topViewIndex = d->viewIndex(topLeft);
executed (the execution status of this line is deduced): int topViewIndex = d->viewIndex(topLeft);
-
682 if (topViewIndex == 0) {
evaluated: topViewIndex == 0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:511
12-511
683 int newDefaultItemHeight = indexRowSizeHint(topLeft);
executed (the execution status of this line is deduced): int newDefaultItemHeight = indexRowSizeHint(topLeft);
-
684 sizeChanged = d->defaultItemHeight != newDefaultItemHeight;
executed (the execution status of this line is deduced): sizeChanged = d->defaultItemHeight != newDefaultItemHeight;
-
685 d->defaultItemHeight = newDefaultItemHeight;
executed (the execution status of this line is deduced): d->defaultItemHeight = newDefaultItemHeight;
-
686 }
executed: }
Execution Count:12
12
687 -
688 if (topViewIndex != -1) {
evaluated: topViewIndex != -1
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:478
45-478
689 if (topLeft.row() == bottomRight.row()) {
partially evaluated: topLeft.row() == bottomRight.row()
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
0-45
690 int oldHeight = d->itemHeight(topViewIndex);
executed (the execution status of this line is deduced): int oldHeight = d->itemHeight(topViewIndex);
-
691 d->invalidateHeightCache(topViewIndex);
executed (the execution status of this line is deduced): d->invalidateHeightCache(topViewIndex);
-
692 sizeChanged |= (oldHeight != d->itemHeight(topViewIndex));
executed (the execution status of this line is deduced): sizeChanged |= (oldHeight != d->itemHeight(topViewIndex));
-
693 if (topLeft.column() == 0)
evaluated: topLeft.column() == 0
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:16
16-29
694 d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft);
executed: d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft);
Execution Count:29
29
695 } else {
executed: }
Execution Count:45
45
696 int bottomViewIndex = d->viewIndex(bottomRight);
never executed (the execution status of this line is deduced): int bottomViewIndex = d->viewIndex(bottomRight);
-
697 for (int i = topViewIndex; i <= bottomViewIndex; ++i) {
never evaluated: i <= bottomViewIndex
0
698 int oldHeight = d->itemHeight(i);
never executed (the execution status of this line is deduced): int oldHeight = d->itemHeight(i);
-
699 d->invalidateHeightCache(i);
never executed (the execution status of this line is deduced): d->invalidateHeightCache(i);
-
700 sizeChanged |= (oldHeight != d->itemHeight(i));
never executed (the execution status of this line is deduced): sizeChanged |= (oldHeight != d->itemHeight(i));
-
701 if (topLeft.column() == 0)
never evaluated: topLeft.column() == 0
0
702 d->viewItems[i].hasChildren = d->hasVisibleChildren(d->viewItems.at(i).index);
never executed: d->viewItems[i].hasChildren = d->hasVisibleChildren(d->viewItems.at(i).index);
0
703 }
never executed: }
0
704 }
never executed: }
0
705 } -
706 -
707 if (sizeChanged) {
evaluated: sizeChanged
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:505
18-505
708 d->updateScrollBars();
executed (the execution status of this line is deduced): d->updateScrollBars();
-
709 d->viewport->update();
executed (the execution status of this line is deduced): d->viewport->update();
-
710 }
executed: }
Execution Count:18
18
711 QAbstractItemView::dataChanged(topLeft, bottomRight, roles);
executed (the execution status of this line is deduced): QAbstractItemView::dataChanged(topLeft, bottomRight, roles);
-
712}
executed: }
Execution Count:523
523
713 -
714/*! -
715 Hides the \a column given. -
716 -
717 \note This function should only be called after the model has been -
718 initialized, as the view needs to know the number of columns in order to -
719 hide \a column. -
720 -
721 \sa showColumn(), setColumnHidden() -
722*/ -
723void QTreeView::hideColumn(int column) -
724{ -
725 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
726 d->header->hideSection(column);
executed (the execution status of this line is deduced): d->header->hideSection(column);
-
727}
executed: }
Execution Count:2
2
728 -
729/*! -
730 Shows the given \a column in the tree view. -
731 -
732 \sa hideColumn(), setColumnHidden() -
733*/ -
734void QTreeView::showColumn(int column) -
735{ -
736 Q_D(QTreeView);
never executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
737 d->header->showSection(column);
never executed (the execution status of this line is deduced): d->header->showSection(column);
-
738}
never executed: }
0
739 -
740/*! -
741 \fn void QTreeView::expand(const QModelIndex &index) -
742 -
743 Expands the model item specified by the \a index. -
744 -
745 \sa expanded() -
746*/ -
747void QTreeView::expand(const QModelIndex &index) -
748{ -
749 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
750 if (!d->isIndexValid(index))
evaluated: !d->isIndexValid(index)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:213
8-213
751 return;
executed: return;
Execution Count:8
8
752 if (d->delayedPendingLayout) {
evaluated: d->delayedPendingLayout
TRUEFALSE
yes
Evaluation Count:161
yes
Evaluation Count:52
52-161
753 //A complete relayout is going to be performed, just store the expanded index, no need to layout. -
754 if (d->storeExpanded(index))
evaluated: d->storeExpanded(index)
TRUEFALSE
yes
Evaluation Count:153
yes
Evaluation Count:8
8-153
755 emit expanded(index);
executed: expanded(index);
Execution Count:153
153
756 return;
executed: return;
Execution Count:161
161
757 } -
758 -
759 int i = d->viewIndex(index);
executed (the execution status of this line is deduced): int i = d->viewIndex(index);
-
760 if (i != -1) { // is visible
evaluated: i != -1
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:3
3-49
761 d->expand(i, true);
executed (the execution status of this line is deduced): d->expand(i, true);
-
762 if (!d->isAnimating()) {
evaluated: !d->isAnimating()
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:15
15-34
763 updateGeometries();
executed (the execution status of this line is deduced): updateGeometries();
-
764 d->viewport->update();
executed (the execution status of this line is deduced): d->viewport->update();
-
765 }
executed: }
Execution Count:34
34
766 } else if (d->storeExpanded(index)) {
executed: }
Execution Count:49
partially evaluated: d->storeExpanded(index)
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-49
767 emit expanded(index);
executed (the execution status of this line is deduced): expanded(index);
-
768 }
executed: }
Execution Count:3
3
769} -
770 -
771/*! -
772 \fn void QTreeView::collapse(const QModelIndex &index) -
773 -
774 Collapses the model item specified by the \a index. -
775 -
776 \sa collapsed() -
777*/ -
778void QTreeView::collapse(const QModelIndex &index) -
779{ -
780 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
781 if (!d->isIndexValid(index))
evaluated: !d->isIndexValid(index)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:94
8-94
782 return;
executed: return;
Execution Count:8
8
783 //if the current item is now invisible, the autoscroll will expand the tree to see it, so disable the autoscroll -
784 d->delayedAutoScroll.stop();
executed (the execution status of this line is deduced): d->delayedAutoScroll.stop();
-
785 -
786 if (d->delayedPendingLayout) {
evaluated: d->delayedPendingLayout
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:48
46-48
787 //A complete relayout is going to be performed, just un-store the expanded index, no need to layout. -
788 if (d->isPersistent(index) && d->expandedIndexes.remove(index))
evaluated: d->isPersistent(index)
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:7
evaluated: d->expandedIndexes.remove(index)
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:6
6-39
789 emit collapsed(index);
executed: collapsed(index);
Execution Count:33
33
790 return;
executed: return;
Execution Count:46
46
791 } -
792 int i = d->viewIndex(index);
executed (the execution status of this line is deduced): int i = d->viewIndex(index);
-
793 if (i != -1) { // is visible
partially evaluated: i != -1
TRUEFALSE
yes
Evaluation Count:48
no
Evaluation Count:0
0-48
794 d->collapse(i, true);
executed (the execution status of this line is deduced): d->collapse(i, true);
-
795 if (!d->isAnimating()) {
evaluated: !d->isAnimating()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:9
9-39
796 updateGeometries();
executed (the execution status of this line is deduced): updateGeometries();
-
797 viewport()->update();
executed (the execution status of this line is deduced): viewport()->update();
-
798 }
executed: }
Execution Count:39
39
799 } else {
executed: }
Execution Count:48
48
800 if (d->isPersistent(index) && d->expandedIndexes.remove(index))
never evaluated: d->isPersistent(index)
never evaluated: d->expandedIndexes.remove(index)
0
801 emit collapsed(index);
never executed: collapsed(index);
0
802 }
never executed: }
0
803} -
804 -
805/*! -
806 \fn bool QTreeView::isExpanded(const QModelIndex &index) const -
807 -
808 Returns true if the model item \a index is expanded; otherwise returns -
809 false. -
810 -
811 \sa expand(), expanded(), setExpanded() -
812*/ -
813bool QTreeView::isExpanded(const QModelIndex &index) const -
814{ -
815 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
816 return d->isIndexExpanded(index);
executed: return d->isIndexExpanded(index);
Execution Count:871
871
817} -
818 -
819/*! -
820 Sets the item referred to by \a index to either collapse or expanded, -
821 depending on the value of \a expanded. -
822 -
823 \sa expanded(), expand(), isExpanded() -
824*/ -
825void QTreeView::setExpanded(const QModelIndex &index, bool expanded) -
826{ -
827 if (expanded)
evaluated: expanded
TRUEFALSE
yes
Evaluation Count:123
yes
Evaluation Count:24
24-123
828 this->expand(index);
executed: this->expand(index);
Execution Count:123
123
829 else -
830 this->collapse(index);
executed: this->collapse(index);
Execution Count:24
24
831} -
832 -
833/*! -
834 \since 4.2 -
835 \property QTreeView::sortingEnabled -
836 \brief whether sorting is enabled -
837 -
838 If this property is true, sorting is enabled for the tree; if the property -
839 is false, sorting is not enabled. The default value is false. -
840 -
841 \note In order to avoid performance issues, it is recommended that -
842 sorting is enabled \e after inserting the items into the tree. -
843 Alternatively, you could also insert the items into a list before inserting -
844 the items into the tree. -
845 -
846 \sa sortByColumn() -
847*/ -
848 -
849void QTreeView::setSortingEnabled(bool enable) -
850{ -
851 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
852 header()->setSortIndicatorShown(enable);
executed (the execution status of this line is deduced): header()->setSortIndicatorShown(enable);
-
853 header()->setSectionsClickable(enable);
executed (the execution status of this line is deduced): header()->setSectionsClickable(enable);
-
854 if (enable) {
evaluated: enable
TRUEFALSE
yes
Evaluation Count:289
yes
Evaluation Count:683
289-683
855 //sortByColumn has to be called before we connect or set the sortingEnabled flag -
856 // because otherwise it will not call sort on the model. -
857 sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
executed (the execution status of this line is deduced): sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
-
858 connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
executed (the execution status of this line is deduced): connect(header(), "2""sortIndicatorChanged(int,Qt::SortOrder)",
-
859 this, SLOT(_q_sortIndicatorChanged(int,Qt::SortOrder)), Qt::UniqueConnection);
executed (the execution status of this line is deduced): this, "1""_q_sortIndicatorChanged(int,Qt::SortOrder)", Qt::UniqueConnection);
-
860 } else {
executed: }
Execution Count:289
289
861 disconnect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
executed (the execution status of this line is deduced): disconnect(header(), "2""sortIndicatorChanged(int,Qt::SortOrder)",
-
862 this, SLOT(_q_sortIndicatorChanged(int,Qt::SortOrder)));
executed (the execution status of this line is deduced): this, "1""_q_sortIndicatorChanged(int,Qt::SortOrder)");
-
863 }
executed: }
Execution Count:683
683
864 d->sortingEnabled = enable;
executed (the execution status of this line is deduced): d->sortingEnabled = enable;
-
865}
executed: }
Execution Count:972
972
866 -
867bool QTreeView::isSortingEnabled() const -
868{ -
869 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
870 return d->sortingEnabled;
executed: return d->sortingEnabled;
Execution Count:68181
68181
871} -
872 -
873/*! -
874 \since 4.2 -
875 \property QTreeView::animated -
876 \brief whether animations are enabled -
877 -
878 If this property is true the treeview will animate expandsion -
879 and collapsing of branches. If this property is false, the treeview -
880 will expand or collapse branches immediately without showing -
881 the animation. -
882 -
883 By default, this property is false. -
884*/ -
885 -
886void QTreeView::setAnimated(bool animate) -
887{ -
888 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
889 d->animationsEnabled = animate;
executed (the execution status of this line is deduced): d->animationsEnabled = animate;
-
890}
executed: }
Execution Count:6
6
891 -
892bool QTreeView::isAnimated() const -
893{ -
894 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
895 return d->animationsEnabled;
executed: return d->animationsEnabled;
Execution Count:4
4
896} -
897 -
898/*! -
899 \since 4.2 -
900 \property QTreeView::allColumnsShowFocus -
901 \brief whether items should show keyboard focus using all columns -
902 -
903 If this property is true all columns will show focus, otherwise only -
904 one column will show focus. -
905 -
906 The default is false. -
907*/ -
908 -
909void QTreeView::setAllColumnsShowFocus(bool enable) -
910{ -
911 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
912 if (d->allColumnsShowFocus == enable)
evaluated: d->allColumnsShowFocus == enable
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
913 return;
executed: return;
Execution Count:1
1
914 d->allColumnsShowFocus = enable;
executed (the execution status of this line is deduced): d->allColumnsShowFocus = enable;
-
915 d->viewport->update();
executed (the execution status of this line is deduced): d->viewport->update();
-
916}
executed: }
Execution Count:1
1
917 -
918bool QTreeView::allColumnsShowFocus() const -
919{ -
920 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
921 return d->allColumnsShowFocus;
executed: return d->allColumnsShowFocus;
Execution Count:472
472
922} -
923 -
924/*! -
925 \property QTreeView::wordWrap -
926 \brief the item text word-wrapping policy -
927 \since 4.3 -
928 -
929 If this property is true then the item text is wrapped where -
930 necessary at word-breaks; otherwise it is not wrapped at all. -
931 This property is false by default. -
932 -
933 Note that even if wrapping is enabled, the cell will not be -
934 expanded to fit all text. Ellipsis will be inserted according to -
935 the current \l{QAbstractItemView::}{textElideMode}. -
936*/ -
937void QTreeView::setWordWrap(bool on) -
938{ -
939 Q_D(QTreeView);
never executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
940 if (d->wrapItemText == on)
never evaluated: d->wrapItemText == on
0
941 return;
never executed: return;
0
942 d->wrapItemText = on;
never executed (the execution status of this line is deduced): d->wrapItemText = on;
-
943 d->doDelayedItemsLayout();
never executed (the execution status of this line is deduced): d->doDelayedItemsLayout();
-
944}
never executed: }
0
945 -
946bool QTreeView::wordWrap() const -
947{ -
948 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
949 return d->wrapItemText;
executed: return d->wrapItemText;
Execution Count:1
1
950} -
951 -
952 -
953/*! -
954 \reimp -
955 */ -
956void QTreeView::keyboardSearch(const QString &search) -
957{ -
958 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
959 if (!d->model->rowCount(d->root) || !d->model->columnCount(d->root))
evaluated: !d->model->rowCount(d->root)
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:12
partially evaluated: !d->model->columnCount(d->root)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-16
960 return;
executed: return;
Execution Count:16
16
961 -
962 QModelIndex start;
executed (the execution status of this line is deduced): QModelIndex start;
-
963 if (currentIndex().isValid())
evaluated: currentIndex().isValid()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:4
4-8
964 start = currentIndex();
executed: start = currentIndex();
Execution Count:8
8
965 else -
966 start = d->model->index(0, 0, d->root);
executed: start = d->model->index(0, 0, d->root);
Execution Count:4
4
967 -
968 bool skipRow = false;
executed (the execution status of this line is deduced): bool skipRow = false;
-
969 bool keyboardTimeWasValid = d->keyboardInputTime.isValid();
executed (the execution status of this line is deduced): bool keyboardTimeWasValid = d->keyboardInputTime.isValid();
-
970 qint64 keyboardInputTimeElapsed = d->keyboardInputTime.restart();
executed (the execution status of this line is deduced): qint64 keyboardInputTimeElapsed = d->keyboardInputTime.restart();
-
971 if (search.isEmpty() || !keyboardTimeWasValid
evaluated: search.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:11
evaluated: !keyboardTimeWasValid
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:8
1-11
972 || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) {
evaluated: keyboardInputTimeElapsed > QApplication::keyboardInputInterval()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6
2-6
973 d->keyboardInput = search;
executed (the execution status of this line is deduced): d->keyboardInput = search;
-
974 skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0)
executed (the execution status of this line is deduced): skipRow = currentIndex().isValid();
-
975 } else {
executed: }
Execution Count:6
6
976 d->keyboardInput += search;
executed (the execution status of this line is deduced): d->keyboardInput += search;
-
977 }
executed: }
Execution Count:6
6
978 -
979 // special case for searches with same key like 'aaaaa' -
980 bool sameKey = false;
executed (the execution status of this line is deduced): bool sameKey = false;
-
981 if (d->keyboardInput.length() > 1) {
evaluated: d->keyboardInput.length() > 1
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:5
5-7
982 int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1));
executed (the execution status of this line is deduced): int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1));
-
983 sameKey = (c == d->keyboardInput.length());
executed (the execution status of this line is deduced): sameKey = (c == d->keyboardInput.length());
-
984 if (sameKey)
evaluated: sameKey
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
985 skipRow = true;
executed: skipRow = true;
Execution Count:1
1
986 }
executed: }
Execution Count:7
7
987 -
988 // skip if we are searching for the same key or a new search started -
989 if (skipRow) {
evaluated: skipRow
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:7
5-7
990 if (indexBelow(start).isValid())
evaluated: indexBelow(start).isValid()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
991 start = indexBelow(start);
executed: start = indexBelow(start);
Execution Count:4
4
992 else -
993 start = d->model->index(0, start.column(), d->root);
executed: start = d->model->index(0, start.column(), d->root);
Execution Count:1
1
994 } -
995 -
996 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
997 int startIndex = d->viewIndex(start);
executed (the execution status of this line is deduced): int startIndex = d->viewIndex(start);
-
998 if (startIndex <= -1)
partially evaluated: startIndex <= -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
999 return;
never executed: return;
0
1000 -
1001 int previousLevel = -1;
executed (the execution status of this line is deduced): int previousLevel = -1;
-
1002 int bestAbove = -1;
executed (the execution status of this line is deduced): int bestAbove = -1;
-
1003 int bestBelow = -1;
executed (the execution status of this line is deduced): int bestBelow = -1;
-
1004 QString searchString = sameKey ? QString(d->keyboardInput.at(0)) : d->keyboardInput;
evaluated: sameKey
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:11
1-11
1005 for (int i = 0; i < d->viewItems.count(); ++i) {
evaluated: i < d->viewItems.count()
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:12
12-84
1006 if ((int)d->viewItems.at(i).level > previousLevel) {
evaluated: (int)d->viewItems.at(i).level > previousLevel
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:71
13-71
1007 QModelIndex searchFrom = d->viewItems.at(i).index;
executed (the execution status of this line is deduced): QModelIndex searchFrom = d->viewItems.at(i).index;
-
1008 if (start.column() > 0)
evaluated: start.column() > 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:11
2-11
1009 searchFrom = searchFrom.sibling(searchFrom.row(), start.column());
executed: searchFrom = searchFrom.sibling(searchFrom.row(), start.column());
Execution Count:2
2
1010 if (searchFrom.parent() == start.parent())
evaluated: searchFrom.parent() == start.parent()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
1011 searchFrom = start;
executed: searchFrom = start;
Execution Count:12
12
1012 QModelIndexList match = d->model->match(searchFrom, Qt::DisplayRole, searchString);
executed (the execution status of this line is deduced): QModelIndexList match = d->model->match(searchFrom, Qt::DisplayRole, searchString);
-
1013 if (match.count()) {
evaluated: match.count()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:8
5-8
1014 int hitIndex = d->viewIndex(match.at(0));
executed (the execution status of this line is deduced): int hitIndex = d->viewIndex(match.at(0));
-
1015 if (hitIndex >= 0 && hitIndex < startIndex)
partially evaluated: hitIndex >= 0
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
partially evaluated: hitIndex < startIndex
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1016 bestAbove = bestAbove == -1 ? hitIndex : qMin(hitIndex, bestAbove);
never executed: bestAbove = bestAbove == -1 ? hitIndex : qMin(hitIndex, bestAbove);
never evaluated: bestAbove == -1
0
1017 else if (hitIndex >= startIndex)
partially evaluated: hitIndex >= startIndex
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1018 bestBelow = bestBelow == -1 ? hitIndex : qMin(hitIndex, bestBelow);
executed: bestBelow = bestBelow == -1 ? hitIndex : qMin(hitIndex, bestBelow);
Execution Count:5
partially evaluated: bestBelow == -1
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1019 } -
1020 }
executed: }
Execution Count:13
13
1021 previousLevel = d->viewItems.at(i).level;
executed (the execution status of this line is deduced): previousLevel = d->viewItems.at(i).level;
-
1022 }
executed: }
Execution Count:84
84
1023 -
1024 QModelIndex index;
executed (the execution status of this line is deduced): QModelIndex index;
-
1025 if (bestBelow > -1)
evaluated: bestBelow > -1
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:7
5-7
1026 index = d->viewItems.at(bestBelow).index;
executed: index = d->viewItems.at(bestBelow).index;
Execution Count:5
5
1027 else if (bestAbove > -1)
partially evaluated: bestAbove > -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1028 index = d->viewItems.at(bestAbove).index;
never executed: index = d->viewItems.at(bestAbove).index;
0
1029 -
1030 if (start.column() > 0)
evaluated: start.column() > 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:10
2-10
1031 index = index.sibling(index.row(), start.column());
executed: index = index.sibling(index.row(), start.column());
Execution Count:2
2
1032 -
1033 if (index.isValid()) {
evaluated: index.isValid()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:7
5-7
1034 QItemSelectionModel::SelectionFlags flags = (d->selectionMode == SingleSelection
partially evaluated: d->selectionMode == SingleSelection
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1035 ? QItemSelectionModel::SelectionFlags(
executed (the execution status of this line is deduced): ? QItemSelectionModel::SelectionFlags(
-
1036 QItemSelectionModel::ClearAndSelect
executed (the execution status of this line is deduced): QItemSelectionModel::ClearAndSelect
-
1037 |d->selectionBehaviorFlags())
executed (the execution status of this line is deduced): |d->selectionBehaviorFlags())
-
1038 : QItemSelectionModel::SelectionFlags(
executed (the execution status of this line is deduced): : QItemSelectionModel::SelectionFlags(
-
1039 QItemSelectionModel::NoUpdate));
executed (the execution status of this line is deduced): QItemSelectionModel::NoUpdate));
-
1040 selectionModel()->setCurrentIndex(index, flags);
executed (the execution status of this line is deduced): selectionModel()->setCurrentIndex(index, flags);
-
1041 }
executed: }
Execution Count:5
5
1042}
executed: }
Execution Count:12
12
1043 -
1044/*! -
1045 Returns the rectangle on the viewport occupied by the item at \a index. -
1046 If the index is not visible or explicitly hidden, the returned rectangle is invalid. -
1047*/ -
1048QRect QTreeView::visualRect(const QModelIndex &index) const -
1049{ -
1050 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
1051 -
1052 if (!d->isIndexValid(index) || isIndexHidden(index))
evaluated: !d->isIndexValid(index)
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:16830
evaluated: isIndexHidden(index)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:16824
6-16830
1053 return QRect();
executed: return QRect();
Execution Count:53
53
1054 -
1055 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
1056 -
1057 int vi = d->viewIndex(index);
executed (the execution status of this line is deduced): int vi = d->viewIndex(index);
-
1058 if (vi < 0)
evaluated: vi < 0
TRUEFALSE
yes
Evaluation Count:568
yes
Evaluation Count:16256
568-16256
1059 return QRect();
executed: return QRect();
Execution Count:568
568
1060 -
1061 bool spanning = d->viewItems.at(vi).spanning;
executed (the execution status of this line is deduced): bool spanning = d->viewItems.at(vi).spanning;
-
1062 -
1063 // if we have a spanning item, make the selection stretch from left to right -
1064 int x = (spanning ? 0 : columnViewportPosition(index.column()));
evaluated: spanning
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:16234
22-16234
1065 int w = (spanning ? d->header->length() : columnWidth(index.column()));
evaluated: spanning
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:16234
22-16234
1066 // handle indentation -
1067 if (index.column() == 0) {
evaluated: index.column() == 0
TRUEFALSE
yes
Evaluation Count:6931
yes
Evaluation Count:9325
6931-9325
1068 int i = d->indentationForItem(vi);
executed (the execution status of this line is deduced): int i = d->indentationForItem(vi);
-
1069 w -= i;
executed (the execution status of this line is deduced): w -= i;
-
1070 if (!isRightToLeft())
evaluated: !isRightToLeft()
TRUEFALSE
yes
Evaluation Count:6923
yes
Evaluation Count:8
8-6923
1071 x += i;
executed: x += i;
Execution Count:6923
6923
1072 }
executed: }
Execution Count:6931
6931
1073 -
1074 int y = d->coordinateForItem(vi);
executed (the execution status of this line is deduced): int y = d->coordinateForItem(vi);
-
1075 int h = d->itemHeight(vi);
executed (the execution status of this line is deduced): int h = d->itemHeight(vi);
-
1076 -
1077 return QRect(x, y, w, h);
executed: return QRect(x, y, w, h);
Execution Count:16256
16256
1078} -
1079 -
1080/*! -
1081 Scroll the contents of the tree view until the given model item -
1082 \a index is visible. The \a hint parameter specifies more -
1083 precisely where the item should be located after the -
1084 operation. -
1085 If any of the parents of the model item are collapsed, they will -
1086 be expanded to ensure that the model item is visible. -
1087*/ -
1088void QTreeView::scrollTo(const QModelIndex &index, ScrollHint hint) -
1089{ -
1090 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
1091 -
1092 if (!d->isIndexValid(index))
evaluated: !d->isIndexValid(index)
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:5635
30-5635
1093 return;
executed: return;
Execution Count:30
30
1094 -
1095 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
1096 d->updateScrollBars();
executed (the execution status of this line is deduced): d->updateScrollBars();
-
1097 -
1098 // Expand all parents if the parent(s) of the node are not expanded. -
1099 QModelIndex parent = index.parent();
executed (the execution status of this line is deduced): QModelIndex parent = index.parent();
-
1100 while (parent != d->root && parent.isValid() && state() == NoState && d->itemsExpandable) {
evaluated: parent != d->root
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:5635
partially evaluated: parent.isValid()
TRUEFALSE
yes
Evaluation Count:56
no
Evaluation Count:0
partially evaluated: state() == NoState
TRUEFALSE
yes
Evaluation Count:56
no
Evaluation Count:0
partially evaluated: d->itemsExpandable
TRUEFALSE
yes
Evaluation Count:56
no
Evaluation Count:0
0-5635
1101 if (!isExpanded(parent))
evaluated: !isExpanded(parent)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:49
7-49
1102 expand(parent);
executed: expand(parent);
Execution Count:7
7
1103 parent = d->model->parent(parent);
executed (the execution status of this line is deduced): parent = d->model->parent(parent);
-
1104 }
executed: }
Execution Count:56
56
1105 -
1106 int item = d->viewIndex(index);
executed (the execution status of this line is deduced): int item = d->viewIndex(index);
-
1107 if (item < 0)
partially evaluated: item < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5635
0-5635
1108 return;
never executed: return;
0
1109 -
1110 QRect area = d->viewport->rect();
executed (the execution status of this line is deduced): QRect area = d->viewport->rect();
-
1111 -
1112 // vertical -
1113 if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
evaluated: verticalScrollMode() == QAbstractItemView::ScrollPerItem
TRUEFALSE
yes
Evaluation Count:2897
yes
Evaluation Count:2738
2738-2897
1114 int top = verticalScrollBar()->value();
executed (the execution status of this line is deduced): int top = verticalScrollBar()->value();
-
1115 int bottom = top + verticalScrollBar()->pageStep();
executed (the execution status of this line is deduced): int bottom = top + verticalScrollBar()->pageStep();
-
1116 if (hint == EnsureVisible && item >= top && item < bottom) {
evaluated: hint == EnsureVisible
TRUEFALSE
yes
Evaluation Count:2889
yes
Evaluation Count:8
evaluated: item >= top
TRUEFALSE
yes
Evaluation Count:2882
yes
Evaluation Count:7
evaluated: item < bottom
TRUEFALSE
yes
Evaluation Count:2842
yes
Evaluation Count:40
7-2889
1117 // nothing to do -
1118 } else if (hint == PositionAtTop || (hint == EnsureVisible && item < top)) {
executed: }
Execution Count:2842
evaluated: hint == PositionAtTop
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:48
evaluated: hint == EnsureVisible
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:1
evaluated: item < top
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:40
1-2842
1119 verticalScrollBar()->setValue(item);
executed (the execution status of this line is deduced): verticalScrollBar()->setValue(item);
-
1120 } else { // PositionAtBottom or PositionAtCenter
executed: }
Execution Count:14
14
1121 const int currentItemHeight = d->itemHeight(item);
executed (the execution status of this line is deduced): const int currentItemHeight = d->itemHeight(item);
-
1122 int y = (hint == PositionAtCenter
partially evaluated: hint == PositionAtCenter
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41
0-41
1123 //we center on the current item with a preference to the top item (ie. -1)
executed (the execution status of this line is deduced):
-
1124 ? area.height() / 2 + currentItemHeight - 1
executed (the execution status of this line is deduced): ? area.height() / 2 + currentItemHeight - 1
-
1125 //otherwise we simply take the whole space
executed (the execution status of this line is deduced):
-
1126 : area.height());
executed (the execution status of this line is deduced): : area.height());
-
1127 if (y > currentItemHeight) {
partially evaluated: y > currentItemHeight
TRUEFALSE
yes
Evaluation Count:41
no
Evaluation Count:0
0-41
1128 while (item >= 0) {
evaluated: item >= 0
TRUEFALSE
yes
Evaluation Count:357
yes
Evaluation Count:1
1-357
1129 y -= d->itemHeight(item);
executed (the execution status of this line is deduced): y -= d->itemHeight(item);
-
1130 if (y < 0) { //there is no more space left
evaluated: y < 0
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:317
40-317
1131 item++;
executed (the execution status of this line is deduced): item++;
-
1132 break;
executed: break;
Execution Count:40
40
1133 } -
1134 item--;
executed (the execution status of this line is deduced): item--;
-
1135 }
executed: }
Execution Count:317
317
1136 }
executed: }
Execution Count:41
41
1137 verticalScrollBar()->setValue(item);
executed (the execution status of this line is deduced): verticalScrollBar()->setValue(item);
-
1138 }
executed: }
Execution Count:41
41
1139 } else { // ScrollPerPixel -
1140 QRect rect(columnViewportPosition(index.column()),
executed (the execution status of this line is deduced): QRect rect(columnViewportPosition(index.column()),
-
1141 d->coordinateForItem(item), // ### slow for items outside the view
executed (the execution status of this line is deduced): d->coordinateForItem(item),
-
1142 columnWidth(index.column()),
executed (the execution status of this line is deduced): columnWidth(index.column()),
-
1143 d->itemHeight(item));
executed (the execution status of this line is deduced): d->itemHeight(item));
-
1144 -
1145 if (rect.isEmpty()) {
partially evaluated: rect.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2738
0-2738
1146 // nothing to do -
1147 } else if (hint == EnsureVisible && area.contains(rect)) {
never executed: }
evaluated: hint == EnsureVisible
TRUEFALSE
yes
Evaluation Count:2736
yes
Evaluation Count:2
evaluated: area.contains(rect)
TRUEFALSE
yes
Evaluation Count:461
yes
Evaluation Count:2275
0-2736
1148 d->viewport->update(rect);
executed (the execution status of this line is deduced): d->viewport->update(rect);
-
1149 // nothing to do -
1150 } else {
executed: }
Execution Count:461
461
1151 bool above = (hint == EnsureVisible
evaluated: hint == EnsureVisible
TRUEFALSE
yes
Evaluation Count:2275
yes
Evaluation Count:2
2-2275
1152 && (rect.top() < area.top()
evaluated: rect.top() < area.top()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2271
4-2271
1153 || area.height() < rect.height()));
partially evaluated: area.height() < rect.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2271
0-2271
1154 bool below = (hint == EnsureVisible
evaluated: hint == EnsureVisible
TRUEFALSE
yes
Evaluation Count:2275
yes
Evaluation Count:2
2-2275
1155 && rect.bottom() > area.bottom()
evaluated: rect.bottom() > area.bottom()
TRUEFALSE
yes
Evaluation Count:1873
yes
Evaluation Count:402
402-1873
1156 && rect.height() < area.height());
partially evaluated: rect.height() < area.height()
TRUEFALSE
yes
Evaluation Count:1873
no
Evaluation Count:0
0-1873
1157 -
1158 int verticalValue = verticalScrollBar()->value();
executed (the execution status of this line is deduced): int verticalValue = verticalScrollBar()->value();
-
1159 if (hint == PositionAtTop || above)
evaluated: hint == PositionAtTop
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2275
evaluated: above
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2271
2-2275
1160 verticalValue += rect.top();
executed: verticalValue += rect.top();
Execution Count:6
6
1161 else if (hint == PositionAtBottom || below)
partially evaluated: hint == PositionAtBottom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2271
evaluated: below
TRUEFALSE
yes
Evaluation Count:1873
yes
Evaluation Count:398
0-2271
1162 verticalValue += rect.bottom() - area.height();
executed: verticalValue += rect.bottom() - area.height();
Execution Count:1873
1873
1163 else if (hint == PositionAtCenter)
partially evaluated: hint == PositionAtCenter
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:398
0-398
1164 verticalValue += rect.top() - ((area.height() - rect.height()) / 2);
never executed: verticalValue += rect.top() - ((area.height() - rect.height()) / 2);
0
1165 verticalScrollBar()->setValue(verticalValue);
executed (the execution status of this line is deduced): verticalScrollBar()->setValue(verticalValue);
-
1166 }
executed: }
Execution Count:2277
2277
1167 } -
1168 // horizontal -
1169 int viewportWidth = d->viewport->width();
executed (the execution status of this line is deduced): int viewportWidth = d->viewport->width();
-
1170 int horizontalOffset = d->header->offset();
executed (the execution status of this line is deduced): int horizontalOffset = d->header->offset();
-
1171 int horizontalPosition = d->header->sectionPosition(index.column());
executed (the execution status of this line is deduced): int horizontalPosition = d->header->sectionPosition(index.column());
-
1172 int cellWidth = d->header->sectionSize(index.column());
executed (the execution status of this line is deduced): int cellWidth = d->header->sectionSize(index.column());
-
1173 -
1174 if (hint == PositionAtCenter) {
partially evaluated: hint == PositionAtCenter
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5635
0-5635
1175 horizontalScrollBar()->setValue(horizontalPosition - ((viewportWidth - cellWidth) / 2));
never executed (the execution status of this line is deduced): horizontalScrollBar()->setValue(horizontalPosition - ((viewportWidth - cellWidth) / 2));
-
1176 } else {
never executed: }
0
1177 if (horizontalPosition - horizontalOffset < 0 || cellWidth > viewportWidth)
evaluated: horizontalPosition - horizontalOffset < 0
TRUEFALSE
yes
Evaluation Count:2355
yes
Evaluation Count:3280
evaluated: cellWidth > viewportWidth
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:3255
25-3280
1178 horizontalScrollBar()->setValue(horizontalPosition);
executed: horizontalScrollBar()->setValue(horizontalPosition);
Execution Count:2380
2380
1179 else if (horizontalPosition - horizontalOffset + cellWidth > viewportWidth)
evaluated: horizontalPosition - horizontalOffset + cellWidth > viewportWidth
TRUEFALSE
yes
Evaluation Count:1317
yes
Evaluation Count:1938
1317-1938
1180 horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth);
executed: horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth);
Execution Count:1317
1317
1181 } -
1182} -
1183 -
1184/*! -
1185 \reimp -
1186*/ -
1187void QTreeView::timerEvent(QTimerEvent *event) -
1188{ -
1189 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
1190 if (event->timerId() == d->columnResizeTimerID) {
evaluated: event->timerId() == d->columnResizeTimerID
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:483
92-483
1191 updateGeometries();
executed (the execution status of this line is deduced): updateGeometries();
-
1192 killTimer(d->columnResizeTimerID);
executed (the execution status of this line is deduced): killTimer(d->columnResizeTimerID);
-
1193 d->columnResizeTimerID = 0;
executed (the execution status of this line is deduced): d->columnResizeTimerID = 0;
-
1194 QRect rect;
executed (the execution status of this line is deduced): QRect rect;
-
1195 int viewportHeight = d->viewport->height();
executed (the execution status of this line is deduced): int viewportHeight = d->viewport->height();
-
1196 int viewportWidth = d->viewport->width();
executed (the execution status of this line is deduced): int viewportWidth = d->viewport->width();
-
1197 for (int i = d->columnsToUpdate.size() - 1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:224
yes
Evaluation Count:92
92-224
1198 int column = d->columnsToUpdate.at(i);
executed (the execution status of this line is deduced): int column = d->columnsToUpdate.at(i);
-
1199 int x = columnViewportPosition(column);
executed (the execution status of this line is deduced): int x = columnViewportPosition(column);
-
1200 if (isRightToLeft())
evaluated: isRightToLeft()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:223
1-223
1201 rect |= QRect(0, 0, x + columnWidth(column), viewportHeight);
executed: rect |= QRect(0, 0, x + columnWidth(column), viewportHeight);
Execution Count:1
1
1202 else -
1203 rect |= QRect(x, 0, viewportWidth - x, viewportHeight);
executed: rect |= QRect(x, 0, viewportWidth - x, viewportHeight);
Execution Count:223
223
1204 } -
1205 d->viewport->update(rect.normalized());
executed (the execution status of this line is deduced): d->viewport->update(rect.normalized());
-
1206 d->columnsToUpdate.clear();
executed (the execution status of this line is deduced): d->columnsToUpdate.clear();
-
1207 } else if (event->timerId() == d->openTimer.timerId()) {
executed: }
Execution Count:92
partially evaluated: event->timerId() == d->openTimer.timerId()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:483
0-483
1208 QPoint pos = d->viewport->mapFromGlobal(QCursor::pos());
never executed (the execution status of this line is deduced): QPoint pos = d->viewport->mapFromGlobal(QCursor::pos());
-
1209 if (state() == QAbstractItemView::DraggingState
never evaluated: state() == QAbstractItemView::DraggingState
0
1210 && d->viewport->rect().contains(pos)) {
never evaluated: d->viewport->rect().contains(pos)
0
1211 QModelIndex index = indexAt(pos);
never executed (the execution status of this line is deduced): QModelIndex index = indexAt(pos);
-
1212 setExpanded(index, !isExpanded(index));
never executed (the execution status of this line is deduced): setExpanded(index, !isExpanded(index));
-
1213 }
never executed: }
0
1214 d->openTimer.stop();
never executed (the execution status of this line is deduced): d->openTimer.stop();
-
1215 }
never executed: }
0
1216 -
1217 QAbstractItemView::timerEvent(event);
executed (the execution status of this line is deduced): QAbstractItemView::timerEvent(event);
-
1218}
executed: }
Execution Count:575
575
1219 -
1220/*! -
1221 \reimp -
1222*/ -
1223#ifndef QT_NO_DRAGANDDROP -
1224void QTreeView::dragMoveEvent(QDragMoveEvent *event) -
1225{ -
1226 Q_D(QTreeView);
never executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
1227 if (d->autoExpandDelay >= 0)
never evaluated: d->autoExpandDelay >= 0
0
1228 d->openTimer.start(d->autoExpandDelay, this);
never executed: d->openTimer.start(d->autoExpandDelay, this);
0
1229 QAbstractItemView::dragMoveEvent(event);
never executed (the execution status of this line is deduced): QAbstractItemView::dragMoveEvent(event);
-
1230}
never executed: }
0
1231#endif -
1232 -
1233/*! -
1234 \reimp -
1235*/ -
1236bool QTreeView::viewportEvent(QEvent *event) -
1237{ -
1238 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
1239 switch (event->type()) { -
1240 case QEvent::HoverEnter: -
1241 case QEvent::HoverLeave: -
1242 case QEvent::HoverMove: { -
1243 QHoverEvent *he = static_cast<QHoverEvent*>(event);
never executed (the execution status of this line is deduced): QHoverEvent *he = static_cast<QHoverEvent*>(event);
-
1244 int oldBranch = d->hoverBranch;
never executed (the execution status of this line is deduced): int oldBranch = d->hoverBranch;
-
1245 d->hoverBranch = d->itemDecorationAt(he->pos());
never executed (the execution status of this line is deduced): d->hoverBranch = d->itemDecorationAt(he->pos());
-
1246 QModelIndex newIndex = indexAt(he->pos());
never executed (the execution status of this line is deduced): QModelIndex newIndex = indexAt(he->pos());
-
1247 if (d->hover != newIndex || d->hoverBranch != oldBranch) {
never evaluated: d->hover != newIndex
never evaluated: d->hoverBranch != oldBranch
0
1248 // Update the whole hovered over row. No need to update the old hovered -
1249 // row, that is taken care in superclass hover handling. -
1250 QRect rect = visualRect(newIndex);
never executed (the execution status of this line is deduced): QRect rect = visualRect(newIndex);
-
1251 rect.setX(0);
never executed (the execution status of this line is deduced): rect.setX(0);
-
1252 rect.setWidth(viewport()->width());
never executed (the execution status of this line is deduced): rect.setWidth(viewport()->width());
-
1253 viewport()->update(rect);
never executed (the execution status of this line is deduced): viewport()->update(rect);
-
1254 }
never executed: }
0
1255 break; }
never executed: break;
0
1256 default: -
1257 break;
executed: break;
Execution Count:11783
11783
1258 } -
1259 return QAbstractItemView::viewportEvent(event);
executed: return QAbstractItemView::viewportEvent(event);
Execution Count:11783
11783
1260} -
1261 -
1262/*! -
1263 \reimp -
1264*/ -
1265void QTreeView::paintEvent(QPaintEvent *event) -
1266{ -
1267 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
1268 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
1269 QPainter painter(viewport());
executed (the execution status of this line is deduced): QPainter painter(viewport());
-
1270#ifndef QT_NO_ANIMATION -
1271 if (d->isAnimating()) {
evaluated: d->isAnimating()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:365
1-365
1272 drawTree(&painter, event->region() - d->animatedOperation.rect());
executed (the execution status of this line is deduced): drawTree(&painter, event->region() - d->animatedOperation.rect());
-
1273 d->drawAnimatedOperation(&painter);
executed (the execution status of this line is deduced): d->drawAnimatedOperation(&painter);
-
1274 } else
executed: }
Execution Count:1
1
1275#endif //QT_NO_ANIMATION -
1276 { -
1277 drawTree(&painter, event->region());
executed (the execution status of this line is deduced): drawTree(&painter, event->region());
-
1278#ifndef QT_NO_DRAGANDDROP -
1279 d->paintDropIndicator(&painter);
executed (the execution status of this line is deduced): d->paintDropIndicator(&painter);
-
1280#endif -
1281 }
executed: }
Execution Count:365
365
1282} -
1283 -
1284void QTreeViewPrivate::paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItem *option, int y, int bottom) const -
1285{ -
1286 Q_Q(const QTreeView);
executed (the execution status of this line is deduced): const QTreeView * const q = q_func();
-
1287 if (!alternatingColors || !q->style()->styleHint(QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea, option, q))
evaluated: !alternatingColors
TRUEFALSE
yes
Evaluation Count:149
yes
Evaluation Count:19
partially evaluated: !q->style()->styleHint(QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea, option, q)
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-149
1288 return;
executed: return;
Execution Count:168
168
1289 int rowHeight = defaultItemHeight;
never executed (the execution status of this line is deduced): int rowHeight = defaultItemHeight;
-
1290 if (rowHeight <= 0) {
never evaluated: rowHeight <= 0
0
1291 rowHeight = itemDelegate->sizeHint(*option, QModelIndex()).height();
never executed (the execution status of this line is deduced): rowHeight = itemDelegate->sizeHint(*option, QModelIndex()).height();
-
1292 if (rowHeight <= 0)
never evaluated: rowHeight <= 0
0
1293 return;
never executed: return;
0
1294 }
never executed: }
0
1295 while (y <= bottom) {
never evaluated: y <= bottom
0
1296 option->rect.setRect(0, y, viewport->width(), rowHeight);
never executed (the execution status of this line is deduced): option->rect.setRect(0, y, viewport->width(), rowHeight);
-
1297 if (current & 1) {
never evaluated: current & 1
0
1298 option->features |= QStyleOptionViewItem::Alternate;
never executed (the execution status of this line is deduced): option->features |= QStyleOptionViewItem::Alternate;
-
1299 } else {
never executed: }
0
1300 option->features &= ~QStyleOptionViewItem::Alternate;
never executed (the execution status of this line is deduced): option->features &= ~QStyleOptionViewItem::Alternate;
-
1301 }
never executed: }
0
1302 ++current;
never executed (the execution status of this line is deduced): ++current;
-
1303 q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, option, painter, q);
never executed (the execution status of this line is deduced): q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, option, painter, q);
-
1304 y += rowHeight;
never executed (the execution status of this line is deduced): y += rowHeight;
-
1305 }
never executed: }
0
1306}
never executed: }
0
1307 -
1308bool QTreeViewPrivate::expandOrCollapseItemAtPos(const QPoint &pos) -
1309{ -
1310 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
1311 // we want to handle mousePress in EditingState (persistent editors) -
1312 if ((state != QAbstractItemView::NoState
evaluated: state != QAbstractItemView::NoState
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4577
1-4577
1313 && state != QAbstractItemView::EditingState)
partially evaluated: state != QAbstractItemView::EditingState
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1314 || !viewport->rect().contains(pos))
evaluated: !viewport->rect().contains(pos)
TRUEFALSE
yes
Evaluation Count:4298
yes
Evaluation Count:280
280-4298
1315 return true;
executed: return true;
Execution Count:4298
4298
1316 -
1317 int i = itemDecorationAt(pos);
executed (the execution status of this line is deduced): int i = itemDecorationAt(pos);
-
1318 if ((i != -1) && itemsExpandable && hasVisibleChildren(viewItems.at(i).index)) {
evaluated: (i != -1)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:278
partially evaluated: itemsExpandable
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: hasVisibleChildren(viewItems.at(i).index)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-278
1319 if (viewItems.at(i).expanded)
partially evaluated: viewItems.at(i).expanded
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1320 collapse(i, true);
never executed: collapse(i, true);
0
1321 else -
1322 expand(i, true);
executed: expand(i, true);
Execution Count:2
2
1323 if (!isAnimating()) {
partially evaluated: !isAnimating()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1324 q->updateGeometries();
executed (the execution status of this line is deduced): q->updateGeometries();
-
1325 viewport->update();
executed (the execution status of this line is deduced): viewport->update();
-
1326 }
executed: }
Execution Count:2
2
1327 return true;
executed: return true;
Execution Count:2
2
1328 } -
1329 return false;
executed: return false;
Execution Count:278
278
1330} -
1331 -
1332void QTreeViewPrivate::_q_modelDestroyed() -
1333{ -
1334 //we need to clear the viewItems because it contains QModelIndexes to -
1335 //the model currently being destroyed -
1336 viewItems.clear();
executed (the execution status of this line is deduced): viewItems.clear();
-
1337 QAbstractItemViewPrivate::_q_modelDestroyed();
executed (the execution status of this line is deduced): QAbstractItemViewPrivate::_q_modelDestroyed();
-
1338}
executed: }
Execution Count:367
367
1339 -
1340/*! -
1341 \reimp -
1342 -
1343 We have a QTreeView way of knowing what elements are on the viewport -
1344*/ -
1345QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const -
1346{ -
1347 Q_ASSERT(r);
never executed (the execution status of this line is deduced): qt_noop();
-
1348 Q_Q(const QTreeView);
never executed (the execution status of this line is deduced): const QTreeView * const q = q_func();
-
1349 if (spanningIndexes.isEmpty())
never evaluated: spanningIndexes.isEmpty()
0
1350 return QAbstractItemViewPrivate::draggablePaintPairs(indexes, r);
never executed: return QAbstractItemViewPrivate::draggablePaintPairs(indexes, r);
0
1351 QModelIndexList list;
never executed (the execution status of this line is deduced): QModelIndexList list;
-
1352 foreach (const QModelIndex &idx, indexes) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(indexes)> _container_(indexes); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QModelIndex &idx = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
1353 if (idx.column() > 0 && q->isFirstColumnSpanned(idx.row(), idx.parent()))
never evaluated: idx.column() > 0
never evaluated: q->isFirstColumnSpanned(idx.row(), idx.parent())
0
1354 continue;
never executed: continue;
0
1355 list << idx;
never executed (the execution status of this line is deduced): list << idx;
-
1356 }
never executed: }
0
1357 return QAbstractItemViewPrivate::draggablePaintPairs(list, r);
never executed: return QAbstractItemViewPrivate::draggablePaintPairs(list, r);
0
1358} -
1359 -
1360void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItem *option, const QModelIndex &current) const -
1361{ -
1362 const int row = viewIndex(current); // get the index in viewItems[]
never executed (the execution status of this line is deduced): const int row = viewIndex(current);
-
1363 option->state = option->state | (viewItems.at(row).expanded ? QStyle::State_Open : QStyle::State_None)
never executed (the execution status of this line is deduced): option->state = option->state | (viewItems.at(row).expanded ? QStyle::State_Open : QStyle::State_None)
-
1364 | (viewItems.at(row).hasChildren ? QStyle::State_Children : QStyle::State_None)
never executed (the execution status of this line is deduced): | (viewItems.at(row).hasChildren ? QStyle::State_Children : QStyle::State_None)
-
1365 | (viewItems.at(row).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None);
never executed (the execution status of this line is deduced): | (viewItems.at(row).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None);
-
1366 -
1367 option->showDecorationSelected = (selectionBehavior & QTreeView::SelectRows)
never evaluated: (selectionBehavior & QTreeView::SelectRows)
0
1368 || option->showDecorationSelected;
never evaluated: option->showDecorationSelected
0
1369 -
1370 QVector<int> logicalIndices; // index = visual index of visible columns only. data = logical index.
never executed (the execution status of this line is deduced): QVector<int> logicalIndices;
-
1371 QVector<QStyleOptionViewItem::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex, visible columns only.
never executed (the execution status of this line is deduced): QVector<QStyleOptionViewItem::ViewItemPosition> viewItemPosList;
-
1372 const bool spanning = viewItems.at(row).spanning;
never executed (the execution status of this line is deduced): const bool spanning = viewItems.at(row).spanning;
-
1373 const int left = (spanning ? header->visualIndex(0) : 0);
never evaluated: spanning
0
1374 const int right = (spanning ? header->visualIndex(0) : header->count() - 1 );
never evaluated: spanning
0
1375 calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right);
never executed (the execution status of this line is deduced): calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right);
-
1376 -
1377 int columnIndex = 0;
never executed (the execution status of this line is deduced): int columnIndex = 0;
-
1378 for (int visualIndex = 0; visualIndex < current.column(); ++visualIndex) {
never evaluated: visualIndex < current.column()
0
1379 int logicalIndex = header->logicalIndex(visualIndex);
never executed (the execution status of this line is deduced): int logicalIndex = header->logicalIndex(visualIndex);
-
1380 if (!header->isSectionHidden(logicalIndex)) {
never evaluated: !header->isSectionHidden(logicalIndex)
0
1381 ++columnIndex;
never executed (the execution status of this line is deduced): ++columnIndex;
-
1382 }
never executed: }
0
1383 }
never executed: }
0
1384 -
1385 option->viewItemPosition = viewItemPosList.at(columnIndex);
never executed (the execution status of this line is deduced): option->viewItemPosition = viewItemPosList.at(columnIndex);
-
1386}
never executed: }
0
1387 -
1388 -
1389/*! -
1390 \since 4.2 -
1391 Draws the part of the tree intersecting the given \a region using the specified -
1392 \a painter. -
1393 -
1394 \sa paintEvent() -
1395*/ -
1396void QTreeView::drawTree(QPainter *painter, const QRegion &region) const -
1397{ -
1398 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
1399 const QVector<QTreeViewItem> viewItems = d->viewItems;
executed (the execution status of this line is deduced): const QVector<QTreeViewItem> viewItems = d->viewItems;
-
1400 -
1401 QStyleOptionViewItem option = d->viewOptions();
executed (the execution status of this line is deduced): QStyleOptionViewItem option = d->viewOptions();
-
1402 const QStyle::State state = option.state;
executed (the execution status of this line is deduced): const QStyle::State state = option.state;
-
1403 d->current = 0;
executed (the execution status of this line is deduced): d->current = 0;
-
1404 -
1405 if (viewItems.count() == 0 || d->header->count() == 0 || !d->itemDelegate) {
evaluated: viewItems.count() == 0
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:360
partially evaluated: d->header->count() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:360
partially evaluated: !d->itemDelegate
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:360
0-360
1406 d->paintAlternatingRowColors(painter, &option, 0, region.boundingRect().bottom()+1);
executed (the execution status of this line is deduced): d->paintAlternatingRowColors(painter, &option, 0, region.boundingRect().bottom()+1);
-
1407 return;
executed: return;
Execution Count:43
43
1408 } -
1409 -
1410 int firstVisibleItemOffset = 0;
executed (the execution status of this line is deduced): int firstVisibleItemOffset = 0;
-
1411 const int firstVisibleItem = d->firstVisibleItem(&firstVisibleItemOffset);
executed (the execution status of this line is deduced): const int firstVisibleItem = d->firstVisibleItem(&firstVisibleItemOffset);
-
1412 if (firstVisibleItem < 0) {
partially evaluated: firstVisibleItem < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:360
0-360
1413 d->paintAlternatingRowColors(painter, &option, 0, region.boundingRect().bottom()+1);
never executed (the execution status of this line is deduced): d->paintAlternatingRowColors(painter, &option, 0, region.boundingRect().bottom()+1);
-
1414 return;
never executed: return;
0
1415 } -
1416 -
1417 const int viewportWidth = d->viewport->width();
executed (the execution status of this line is deduced): const int viewportWidth = d->viewport->width();
-
1418 -
1419 QPoint hoverPos = d->viewport->mapFromGlobal(QCursor::pos());
executed (the execution status of this line is deduced): QPoint hoverPos = d->viewport->mapFromGlobal(QCursor::pos());
-
1420 d->hoverBranch = d->itemDecorationAt(hoverPos);
executed (the execution status of this line is deduced): d->hoverBranch = d->itemDecorationAt(hoverPos);
-
1421 -
1422 QVector<QRect> rects = region.rects();
executed (the execution status of this line is deduced): QVector<QRect> rects = region.rects();
-
1423 QVector<int> drawn;
executed (the execution status of this line is deduced): QVector<int> drawn;
-
1424 bool multipleRects = (rects.size() > 1);
executed (the execution status of this line is deduced): bool multipleRects = (rects.size() > 1);
-
1425 for (int a = 0; a < rects.size(); ++a) {
evaluated: a < rects.size()
TRUEFALSE
yes
Evaluation Count:471
yes
Evaluation Count:360
360-471
1426 const QRect area = (multipleRects
evaluated: multipleRects
TRUEFALSE
yes
Evaluation Count:174
yes
Evaluation Count:297
174-297
1427 ? QRect(0, rects.at(a).y(), viewportWidth, rects.at(a).height())
executed (the execution status of this line is deduced): ? QRect(0, rects.at(a).y(), viewportWidth, rects.at(a).height())
-
1428 : rects.at(a));
executed (the execution status of this line is deduced): : rects.at(a));
-
1429 d->leftAndRight = d->startAndEndColumns(area);
executed (the execution status of this line is deduced): d->leftAndRight = d->startAndEndColumns(area);
-
1430 -
1431 int i = firstVisibleItem; // the first item at the top of the viewport
executed (the execution status of this line is deduced): int i = firstVisibleItem;
-
1432 int y = firstVisibleItemOffset; // we may only see part of the first item
executed (the execution status of this line is deduced): int y = firstVisibleItemOffset;
-
1433 -
1434 // start at the top of the viewport and iterate down to the update area -
1435 for (; i < viewItems.count(); ++i) {
evaluated: i < viewItems.count()
TRUEFALSE
yes
Evaluation Count:1269
yes
Evaluation Count:8
8-1269
1436 const int itemHeight = d->itemHeight(i);
executed (the execution status of this line is deduced): const int itemHeight = d->itemHeight(i);
-
1437 if (y + itemHeight > area.top())
evaluated: y + itemHeight > area.top()
TRUEFALSE
yes
Evaluation Count:463
yes
Evaluation Count:806
463-806
1438 break;
executed: break;
Execution Count:463
463
1439 y += itemHeight;
executed (the execution status of this line is deduced): y += itemHeight;
-
1440 }
executed: }
Execution Count:806
806
1441 -
1442 // paint the visible rows -
1443 for (; i < viewItems.count() && y <= area.bottom(); ++i) {
evaluated: i < viewItems.count()
TRUEFALSE
yes
Evaluation Count:2307
yes
Evaluation Count:163
evaluated: y <= area.bottom()
TRUEFALSE
yes
Evaluation Count:1999
yes
Evaluation Count:308
163-2307
1444 const int itemHeight = d->itemHeight(i);
executed (the execution status of this line is deduced): const int itemHeight = d->itemHeight(i);
-
1445 option.rect.setRect(0, y, viewportWidth, itemHeight);
executed (the execution status of this line is deduced): option.rect.setRect(0, y, viewportWidth, itemHeight);
-
1446 option.state = state | (viewItems.at(i).expanded ? QStyle::State_Open : QStyle::State_None)
executed (the execution status of this line is deduced): option.state = state | (viewItems.at(i).expanded ? QStyle::State_Open : QStyle::State_None)
-
1447 | (viewItems.at(i).hasChildren ? QStyle::State_Children : QStyle::State_None)
executed (the execution status of this line is deduced): | (viewItems.at(i).hasChildren ? QStyle::State_Children : QStyle::State_None)
-
1448 | (viewItems.at(i).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None);
executed (the execution status of this line is deduced): | (viewItems.at(i).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None);
-
1449 d->current = i;
executed (the execution status of this line is deduced): d->current = i;
-
1450 d->spanning = viewItems.at(i).spanning;
executed (the execution status of this line is deduced): d->spanning = viewItems.at(i).spanning;
-
1451 if (!multipleRects || !drawn.contains(i)) {
evaluated: !multipleRects
TRUEFALSE
yes
Evaluation Count:1799
yes
Evaluation Count:200
evaluated: !drawn.contains(i)
TRUEFALSE
yes
Evaluation Count:193
yes
Evaluation Count:7
7-1799
1452 drawRow(painter, option, viewItems.at(i).index);
executed (the execution status of this line is deduced): drawRow(painter, option, viewItems.at(i).index);
-
1453 if (multipleRects) // even if the rect only intersects the item,
evaluated: multipleRects
TRUEFALSE
yes
Evaluation Count:193
yes
Evaluation Count:1799
193-1799
1454 drawn.append(i); // the entire item will be painted
executed: drawn.append(i);
Execution Count:193
193
1455 }
executed: }
Execution Count:1992
1992
1456 y += itemHeight;
executed (the execution status of this line is deduced): y += itemHeight;
-
1457 }
executed: }
Execution Count:1999
1999
1458 -
1459 if (y <= area.bottom()) {
evaluated: y <= area.bottom()
TRUEFALSE
yes
Evaluation Count:125
yes
Evaluation Count:346
125-346
1460 d->current = i;
executed (the execution status of this line is deduced): d->current = i;
-
1461 d->paintAlternatingRowColors(painter, &option, y, area.bottom());
executed (the execution status of this line is deduced): d->paintAlternatingRowColors(painter, &option, y, area.bottom());
-
1462 }
executed: }
Execution Count:125
125
1463 }
executed: }
Execution Count:471
471
1464}
executed: }
Execution Count:360
360
1465 -
1466/// ### move to QObject :) -
1467static inline bool ancestorOf(QObject *widget, QObject *other) -
1468{ -
1469 for (QObject *parent = other; parent != 0; parent = parent->parent()) {
evaluated: parent != 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
1470 if (parent == widget)
partially evaluated: parent == widget
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1471 return true;
executed: return true;
Execution Count:5
5
1472 }
never executed: }
0
1473 return false;
executed: return false;
Execution Count:1
1
1474} -
1475 -
1476void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItem::ViewItemPosition> *itemPositions, int left, int right) const -
1477{ -
1478 const int columnCount = header->count();
executed (the execution status of this line is deduced): const int columnCount = header->count();
-
1479 /* 'left' and 'right' are the left-most and right-most visible visual indices. -
1480 Compute the first visible logical indices before and after the left and right. -
1481 We will use these values to determine the QStyleOptionViewItem::viewItemPosition. */ -
1482 int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1;
executed (the execution status of this line is deduced): int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1;
-
1483 for (int visualIndex = left - 1; visualIndex >= 0; --visualIndex) {
evaluated: visualIndex >= 0
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:1982
17-1982
1484 int logicalIndex = header->logicalIndex(visualIndex);
executed (the execution status of this line is deduced): int logicalIndex = header->logicalIndex(visualIndex);
-
1485 if (!header->isSectionHidden(logicalIndex)) {
evaluated: !header->isSectionHidden(logicalIndex)
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:7
7-10
1486 logicalIndexBeforeLeft = logicalIndex;
executed (the execution status of this line is deduced): logicalIndexBeforeLeft = logicalIndex;
-
1487 break;
executed: break;
Execution Count:10
10
1488 } -
1489 }
executed: }
Execution Count:7
7
1490 -
1491 for (int visualIndex = left; visualIndex < columnCount; ++visualIndex) {
evaluated: visualIndex < columnCount
TRUEFALSE
yes
Evaluation Count:5910
yes
Evaluation Count:1093
1093-5910
1492 int logicalIndex = header->logicalIndex(visualIndex);
executed (the execution status of this line is deduced): int logicalIndex = header->logicalIndex(visualIndex);
-
1493 if (!header->isSectionHidden(logicalIndex)) {
evaluated: !header->isSectionHidden(logicalIndex)
TRUEFALSE
yes
Evaluation Count:5884
yes
Evaluation Count:26
26-5884
1494 if (visualIndex > right) {
evaluated: visualIndex > right
TRUEFALSE
yes
Evaluation Count:899
yes
Evaluation Count:4985
899-4985
1495 logicalIndexAfterRight = logicalIndex;
executed (the execution status of this line is deduced): logicalIndexAfterRight = logicalIndex;
-
1496 break;
executed: break;
Execution Count:899
899
1497 } -
1498 logicalIndices->append(logicalIndex);
executed (the execution status of this line is deduced): logicalIndices->append(logicalIndex);
-
1499 }
executed: }
Execution Count:4985
4985
1500 }
executed: }
Execution Count:5011
5011
1501 -
1502 itemPositions->resize(logicalIndices->count());
executed (the execution status of this line is deduced): itemPositions->resize(logicalIndices->count());
-
1503 for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices->count(); ++currentLogicalSection) {
evaluated: currentLogicalSection < logicalIndices->count()
TRUEFALSE
yes
Evaluation Count:4985
yes
Evaluation Count:1992
1992-4985
1504 const int headerSection = logicalIndices->at(currentLogicalSection);
executed (the execution status of this line is deduced): const int headerSection = logicalIndices->at(currentLogicalSection);
-
1505 // determine the viewItemPosition depending on the position of column 0 -
1506 int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices->count()
evaluated: currentLogicalSection + 1 >= logicalIndices->count()
TRUEFALSE
yes
Evaluation Count:1992
yes
Evaluation Count:2993
1992-2993
1507 ? logicalIndexAfterRight
executed (the execution status of this line is deduced): ? logicalIndexAfterRight
-
1508 : logicalIndices->at(currentLogicalSection + 1);
executed (the execution status of this line is deduced): : logicalIndices->at(currentLogicalSection + 1);
-
1509 int prevLogicalSection = currentLogicalSection - 1 < 0
evaluated: currentLogicalSection - 1 < 0
TRUEFALSE
yes
Evaluation Count:1992
yes
Evaluation Count:2993
1992-2993
1510 ? logicalIndexBeforeLeft
executed (the execution status of this line is deduced): ? logicalIndexBeforeLeft
-
1511 : logicalIndices->at(currentLogicalSection - 1);
executed (the execution status of this line is deduced): : logicalIndices->at(currentLogicalSection - 1);
-
1512 QStyleOptionViewItem::ViewItemPosition pos;
executed (the execution status of this line is deduced): QStyleOptionViewItem::ViewItemPosition pos;
-
1513 if (columnCount == 1 || (nextLogicalSection == 0 && prevLogicalSection == -1)
evaluated: columnCount == 1
TRUEFALSE
yes
Evaluation Count:328
yes
Evaluation Count:4657
partially evaluated: nextLogicalSection == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4657
never evaluated: prevLogicalSection == -1
0-4657
1514 || (headerSection == 0 && nextLogicalSection == -1) || spanning)
evaluated: headerSection == 0
TRUEFALSE
yes
Evaluation Count:1647
yes
Evaluation Count:3010
partially evaluated: nextLogicalSection == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1647
evaluated: spanning
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4651
0-4651
1515 pos = QStyleOptionViewItem::OnlyOne;
executed: pos = QStyleOptionViewItem::OnlyOne;
Execution Count:334
334
1516 else if (headerSection == 0 || (nextLogicalSection != 0 && prevLogicalSection == -1))
evaluated: headerSection == 0
TRUEFALSE
yes
Evaluation Count:1641
yes
Evaluation Count:3010
partially evaluated: nextLogicalSection != 0
TRUEFALSE
yes
Evaluation Count:3010
no
Evaluation Count:0
evaluated: prevLogicalSection == -1
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:3003
0-3010
1517 pos = QStyleOptionViewItem::Beginning;
executed: pos = QStyleOptionViewItem::Beginning;
Execution Count:1648
1648
1518 else if (nextLogicalSection == 0 || nextLogicalSection == -1)
partially evaluated: nextLogicalSection == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3003
evaluated: nextLogicalSection == -1
TRUEFALSE
yes
Evaluation Count:758
yes
Evaluation Count:2245
0-3003
1519 pos = QStyleOptionViewItem::End;
executed: pos = QStyleOptionViewItem::End;
Execution Count:758
758
1520 else -
1521 pos = QStyleOptionViewItem::Middle;
executed: pos = QStyleOptionViewItem::Middle;
Execution Count:2245
2245
1522 (*itemPositions)[currentLogicalSection] = pos;
executed (the execution status of this line is deduced): (*itemPositions)[currentLogicalSection] = pos;
-
1523 }
executed: }
Execution Count:4985
4985
1524}
executed: }
Execution Count:1992
1992
1525 -
1526 -
1527/*! -
1528 Draws the row in the tree view that contains the model item \a index, -
1529 using the \a painter given. The \a option control how the item is -
1530 displayed. -
1531 -
1532 \sa setAlternatingRowColors() -
1533*/ -
1534void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, -
1535 const QModelIndex &index) const -
1536{ -
1537 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
1538 QStyleOptionViewItem opt = option;
executed (the execution status of this line is deduced): QStyleOptionViewItem opt = option;
-
1539 const QPoint offset = d->scrollDelayOffset;
executed (the execution status of this line is deduced): const QPoint offset = d->scrollDelayOffset;
-
1540 const int y = option.rect.y() + offset.y();
executed (the execution status of this line is deduced): const int y = option.rect.y() + offset.y();
-
1541 const QModelIndex parent = index.parent();
executed (the execution status of this line is deduced): const QModelIndex parent = index.parent();
-
1542 const QHeaderView *header = d->header;
executed (the execution status of this line is deduced): const QHeaderView *header = d->header;
-
1543 const QModelIndex current = currentIndex();
executed (the execution status of this line is deduced): const QModelIndex current = currentIndex();
-
1544 const QModelIndex hover = d->hover;
executed (the execution status of this line is deduced): const QModelIndex hover = d->hover;
-
1545 const bool reverse = isRightToLeft();
executed (the execution status of this line is deduced): const bool reverse = isRightToLeft();
-
1546 const QStyle::State state = opt.state;
executed (the execution status of this line is deduced): const QStyle::State state = opt.state;
-
1547 const bool spanning = d->spanning;
executed (the execution status of this line is deduced): const bool spanning = d->spanning;
-
1548 const int left = (spanning ? header->visualIndex(0) : d->leftAndRight.first);
evaluated: spanning
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1986
6-1986
1549 const int right = (spanning ? header->visualIndex(0) : d->leftAndRight.second);
evaluated: spanning
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1986
6-1986
1550 const bool alternate = d->alternatingColors;
executed (the execution status of this line is deduced): const bool alternate = d->alternatingColors;
-
1551 const bool enabled = (state & QStyle::State_Enabled) != 0;
executed (the execution status of this line is deduced): const bool enabled = (state & QStyle::State_Enabled) != 0;
-
1552 const bool allColumnsShowFocus = d->allColumnsShowFocus;
executed (the execution status of this line is deduced): const bool allColumnsShowFocus = d->allColumnsShowFocus;
-
1553 -
1554 -
1555 // when the row contains an index widget which has focus, -
1556 // we want to paint the entire row as active -
1557 bool indexWidgetHasFocus = false;
executed (the execution status of this line is deduced): bool indexWidgetHasFocus = false;
-
1558 if ((current.row() == index.row()) && !d->editorIndexHash.isEmpty()) {
evaluated: (current.row() == index.row())
TRUEFALSE
yes
Evaluation Count:268
yes
Evaluation Count:1724
evaluated: !d->editorIndexHash.isEmpty()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:251
17-1724
1559 const int r = index.row();
executed (the execution status of this line is deduced): const int r = index.row();
-
1560 QWidget *fw = QApplication::focusWidget();
executed (the execution status of this line is deduced): QWidget *fw = QApplication::focusWidget();
-
1561 for (int c = 0; c < header->count(); ++c) {
evaluated: c < header->count()
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:12
12-54
1562 QModelIndex idx = d->model->index(r, c, parent);
executed (the execution status of this line is deduced): QModelIndex idx = d->model->index(r, c, parent);
-
1563 if (QWidget *editor = indexWidget(idx)) {
evaluated: QWidget *editor = indexWidget(idx)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:48
6-48
1564 if (ancestorOf(editor, fw)) {
evaluated: ancestorOf(editor, fw)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
1565 indexWidgetHasFocus = true;
executed (the execution status of this line is deduced): indexWidgetHasFocus = true;
-
1566 break;
executed: break;
Execution Count:5
5
1567 } -
1568 }
executed: }
Execution Count:1
1
1569 }
executed: }
Execution Count:49
49
1570 }
executed: }
Execution Count:17
17
1571 -
1572 const bool widgetHasFocus = hasFocus();
executed (the execution status of this line is deduced): const bool widgetHasFocus = hasFocus();
-
1573 bool currentRowHasFocus = false;
executed (the execution status of this line is deduced): bool currentRowHasFocus = false;
-
1574 if (allColumnsShowFocus && widgetHasFocus && current.isValid()) {
partially evaluated: allColumnsShowFocus
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1992
never evaluated: widgetHasFocus
never evaluated: current.isValid()
0-1992
1575 // check if the focus index is before or after the visible columns -
1576 const int r = index.row();
never executed (the execution status of this line is deduced): const int r = index.row();
-
1577 for (int c = 0; c < left && !currentRowHasFocus; ++c) {
never evaluated: c < left
never evaluated: !currentRowHasFocus
0
1578 QModelIndex idx = d->model->index(r, c, parent);
never executed (the execution status of this line is deduced): QModelIndex idx = d->model->index(r, c, parent);
-
1579 currentRowHasFocus = (idx == current);
never executed (the execution status of this line is deduced): currentRowHasFocus = (idx == current);
-
1580 }
never executed: }
0
1581 QModelIndex parent = d->model->parent(index);
never executed (the execution status of this line is deduced): QModelIndex parent = d->model->parent(index);
-
1582 for (int c = right; c < header->count() && !currentRowHasFocus; ++c) {
never evaluated: c < header->count()
never evaluated: !currentRowHasFocus
0
1583 currentRowHasFocus = (d->model->index(r, c, parent) == current);
never executed (the execution status of this line is deduced): currentRowHasFocus = (d->model->index(r, c, parent) == current);
-
1584 }
never executed: }
0
1585 }
never executed: }
0
1586 -
1587 // ### special case: treeviews with multiple columns draw -
1588 // the selections differently than with only one column -
1589 opt.showDecorationSelected = (d->selectionBehavior & SelectRows)
evaluated: (d->selectionBehavior & SelectRows)
TRUEFALSE
yes
Evaluation Count:1637
yes
Evaluation Count:355
355-1637
1590 || option.showDecorationSelected;
partially evaluated: option.showDecorationSelected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:355
0-355
1591 -
1592 int width, height = option.rect.height();
executed (the execution status of this line is deduced): int width, height = option.rect.height();
-
1593 int position;
executed (the execution status of this line is deduced): int position;
-
1594 QModelIndex modelIndex;
executed (the execution status of this line is deduced): QModelIndex modelIndex;
-
1595 const bool hoverRow = selectionBehavior() == QAbstractItemView::SelectRows
evaluated: selectionBehavior() == QAbstractItemView::SelectRows
TRUEFALSE
yes
Evaluation Count:1637
yes
Evaluation Count:355
355-1637
1596 && index.parent() == hover.parent()
evaluated: index.parent() == hover.parent()
TRUEFALSE
yes
Evaluation Count:864
yes
Evaluation Count:773
773-864
1597 && index.row() == hover.row();
evaluated: index.row() == hover.row()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:860
4-860
1598 -
1599 QVector<int> logicalIndices;
executed (the execution status of this line is deduced): QVector<int> logicalIndices;
-
1600 QVector<QStyleOptionViewItem::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex
executed (the execution status of this line is deduced): QVector<QStyleOptionViewItem::ViewItemPosition> viewItemPosList;
-
1601 d->calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right);
executed (the execution status of this line is deduced): d->calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right);
-
1602 -
1603 for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices.count(); ++currentLogicalSection) {
evaluated: currentLogicalSection < logicalIndices.count()
TRUEFALSE
yes
Evaluation Count:4985
yes
Evaluation Count:1992
1992-4985
1604 int headerSection = logicalIndices.at(currentLogicalSection);
executed (the execution status of this line is deduced): int headerSection = logicalIndices.at(currentLogicalSection);
-
1605 position = columnViewportPosition(headerSection) + offset.x();
executed (the execution status of this line is deduced): position = columnViewportPosition(headerSection) + offset.x();
-
1606 width = header->sectionSize(headerSection);
executed (the execution status of this line is deduced): width = header->sectionSize(headerSection);
-
1607 -
1608 if (spanning) {
evaluated: spanning
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4979
6-4979
1609 int lastSection = header->logicalIndex(header->count() - 1);
executed (the execution status of this line is deduced): int lastSection = header->logicalIndex(header->count() - 1);
-
1610 if (!reverse) {
partially evaluated: !reverse
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1611 width = columnViewportPosition(lastSection) + header->sectionSize(lastSection) - position;
executed (the execution status of this line is deduced): width = columnViewportPosition(lastSection) + header->sectionSize(lastSection) - position;
-
1612 } else {
executed: }
Execution Count:6
6
1613 width += position - columnViewportPosition(lastSection);
never executed (the execution status of this line is deduced): width += position - columnViewportPosition(lastSection);
-
1614 position = columnViewportPosition(lastSection);
never executed (the execution status of this line is deduced): position = columnViewportPosition(lastSection);
-
1615 }
never executed: }
0
1616 } -
1617 -
1618 modelIndex = d->model->index(index.row(), headerSection, parent);
executed (the execution status of this line is deduced): modelIndex = d->model->index(index.row(), headerSection, parent);
-
1619 if (!modelIndex.isValid())
partially evaluated: !modelIndex.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4985
0-4985
1620 continue;
never executed: continue;
0
1621 opt.state = state;
executed (the execution status of this line is deduced): opt.state = state;
-
1622 -
1623 opt.viewItemPosition = viewItemPosList.at(currentLogicalSection);
executed (the execution status of this line is deduced): opt.viewItemPosition = viewItemPosList.at(currentLogicalSection);
-
1624 -
1625 // fake activeness when row editor has focus -
1626 if (indexWidgetHasFocus)
evaluated: indexWidgetHasFocus
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:4977
8-4977
1627 opt.state |= QStyle::State_Active;
executed: opt.state |= QStyle::State_Active;
Execution Count:8
8
1628 -
1629 if (d->selectionModel->isSelected(modelIndex))
evaluated: d->selectionModel->isSelected(modelIndex)
TRUEFALSE
yes
Evaluation Count:169
yes
Evaluation Count:4816
169-4816
1630 opt.state |= QStyle::State_Selected;
executed: opt.state |= QStyle::State_Selected;
Execution Count:169
169
1631 if (widgetHasFocus && (current == modelIndex)) {
evaluated: widgetHasFocus
TRUEFALSE
yes
Evaluation Count:3182
yes
Evaluation Count:1803
evaluated: (current == modelIndex)
TRUEFALSE
yes
Evaluation Count:192
yes
Evaluation Count:2990
192-3182
1632 if (allColumnsShowFocus)
partially evaluated: allColumnsShowFocus
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:192
0-192
1633 currentRowHasFocus = true;
never executed: currentRowHasFocus = true;
0
1634 else -
1635 opt.state |= QStyle::State_HasFocus;
executed: opt.state |= QStyle::State_HasFocus;
Execution Count:192
192
1636 } -
1637 if ((hoverRow || modelIndex == hover)
evaluated: hoverRow
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4981
evaluated: modelIndex == hover
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4975
4-4981
1638 && (option.showDecorationSelected || (d->hoverBranch == -1)))
partially evaluated: option.showDecorationSelected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
partially evaluated: (d->hoverBranch == -1)
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
1639 opt.state |= QStyle::State_MouseOver;
executed: opt.state |= QStyle::State_MouseOver;
Execution Count:10
10
1640 else -
1641 opt.state &= ~QStyle::State_MouseOver;
executed: opt.state &= ~QStyle::State_MouseOver;
Execution Count:4975
4975
1642 -
1643 if (enabled) {
partially evaluated: enabled
TRUEFALSE
yes
Evaluation Count:4985
no
Evaluation Count:0
0-4985
1644 QPalette::ColorGroup cg;
executed (the execution status of this line is deduced): QPalette::ColorGroup cg;
-
1645 if ((d->model->flags(modelIndex) & Qt::ItemIsEnabled) == 0) {
evaluated: (d->model->flags(modelIndex) & Qt::ItemIsEnabled) == 0
TRUEFALSE
yes
Evaluation Count:394
yes
Evaluation Count:4591
394-4591
1646 opt.state &= ~QStyle::State_Enabled;
executed (the execution status of this line is deduced): opt.state &= ~QStyle::State_Enabled;
-
1647 cg = QPalette::Disabled;
executed (the execution status of this line is deduced): cg = QPalette::Disabled;
-
1648 } else if (opt.state & QStyle::State_Active) {
executed: }
Execution Count:394
evaluated: opt.state & QStyle::State_Active
TRUEFALSE
yes
Evaluation Count:2840
yes
Evaluation Count:1751
394-2840
1649 cg = QPalette::Active;
executed (the execution status of this line is deduced): cg = QPalette::Active;
-
1650 } else {
executed: }
Execution Count:2840
2840
1651 cg = QPalette::Inactive;
executed (the execution status of this line is deduced): cg = QPalette::Inactive;
-
1652 }
executed: }
Execution Count:1751
1751
1653 opt.palette.setCurrentColorGroup(cg);
executed (the execution status of this line is deduced): opt.palette.setCurrentColorGroup(cg);
-
1654 }
executed: }
Execution Count:4985
4985
1655 -
1656 if (alternate) {
evaluated: alternate
TRUEFALSE
yes
Evaluation Count:127
yes
Evaluation Count:4858
127-4858
1657 if (d->current & 1) {
evaluated: d->current & 1
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:69
58-69
1658 opt.features |= QStyleOptionViewItem::Alternate;
executed (the execution status of this line is deduced): opt.features |= QStyleOptionViewItem::Alternate;
-
1659 } else {
executed: }
Execution Count:58
58
1660 opt.features &= ~QStyleOptionViewItem::Alternate;
executed (the execution status of this line is deduced): opt.features &= ~QStyleOptionViewItem::Alternate;
-
1661 }
executed: }
Execution Count:69
69
1662 } -
1663 -
1664 /* Prior to Qt 4.3, the background of the branch (in selected state and -
1665 alternate row color was provided by the view. For backward compatibility, -
1666 this is now delegated to the style using PE_PanelViewItemRow which -
1667 does the appropriate fill */ -
1668 if (headerSection == 0) {
evaluated: headerSection == 0
TRUEFALSE
yes
Evaluation Count:1975
yes
Evaluation Count:3010
1975-3010
1669 const int i = d->indentationForItem(d->current);
executed (the execution status of this line is deduced): const int i = d->indentationForItem(d->current);
-
1670 QRect branches(reverse ? position + width - i : position, y, i, height);
executed (the execution status of this line is deduced): QRect branches(reverse ? position + width - i : position, y, i, height);
-
1671 const bool setClipRect = branches.width() > width;
executed (the execution status of this line is deduced): const bool setClipRect = branches.width() > width;
-
1672 if (setClipRect) {
partially evaluated: setClipRect
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1975
0-1975
1673 painter->save();
never executed (the execution status of this line is deduced): painter->save();
-
1674 painter->setClipRect(QRect(position, y, width, height));
never executed (the execution status of this line is deduced): painter->setClipRect(QRect(position, y, width, height));
-
1675 }
never executed: }
0
1676 // draw background for the branch (selection + alternate row) -
1677 opt.rect = branches;
executed (the execution status of this line is deduced): opt.rect = branches;
-
1678 style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this);
executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this);
-
1679 -
1680 // draw background of the item (only alternate row). rest of the background -
1681 // is provided by the delegate -
1682 QStyle::State oldState = opt.state;
executed (the execution status of this line is deduced): QStyle::State oldState = opt.state;
-
1683 opt.state &= ~QStyle::State_Selected;
executed (the execution status of this line is deduced): opt.state &= ~QStyle::State_Selected;
-
1684 opt.rect.setRect(reverse ? position : i + position, y, width - i, height);
executed (the execution status of this line is deduced): opt.rect.setRect(reverse ? position : i + position, y, width - i, height);
-
1685 style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this);
executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this);
-
1686 opt.state = oldState;
executed (the execution status of this line is deduced): opt.state = oldState;
-
1687 -
1688 if (d->indent != 0)
partially evaluated: d->indent != 0
TRUEFALSE
yes
Evaluation Count:1975
no
Evaluation Count:0
0-1975
1689 drawBranches(painter, branches, index);
executed: drawBranches(painter, branches, index);
Execution Count:1975
1975
1690 if (setClipRect)
partially evaluated: setClipRect
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1975
0-1975
1691 painter->restore();
never executed: painter->restore();
0
1692 } else {
executed: }
Execution Count:1975
1975
1693 QStyle::State oldState = opt.state;
executed (the execution status of this line is deduced): QStyle::State oldState = opt.state;
-
1694 opt.state &= ~QStyle::State_Selected;
executed (the execution status of this line is deduced): opt.state &= ~QStyle::State_Selected;
-
1695 opt.rect.setRect(position, y, width, height);
executed (the execution status of this line is deduced): opt.rect.setRect(position, y, width, height);
-
1696 style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this);
executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this);
-
1697 opt.state = oldState;
executed (the execution status of this line is deduced): opt.state = oldState;
-
1698 }
executed: }
Execution Count:3010
3010
1699 -
1700 d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex);
executed (the execution status of this line is deduced): d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex);
-
1701 }
executed: }
Execution Count:4985
4985
1702 -
1703 if (currentRowHasFocus) {
partially evaluated: currentRowHasFocus
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1992
0-1992
1704 QStyleOptionFocusRect o;
never executed (the execution status of this line is deduced): QStyleOptionFocusRect o;
-
1705 o.QStyleOption::operator=(option);
never executed (the execution status of this line is deduced): o.QStyleOption::operator=(option);
-
1706 o.state |= QStyle::State_KeyboardFocusChange;
never executed (the execution status of this line is deduced): o.state |= QStyle::State_KeyboardFocusChange;
-
1707 QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled)
never evaluated: (option.state & QStyle::State_Enabled)
0
1708 ? QPalette::Normal : QPalette::Disabled;
never executed (the execution status of this line is deduced): ? QPalette::Normal : QPalette::Disabled;
-
1709 o.backgroundColor = option.palette.color(cg, d->selectionModel->isSelected(index)
never executed (the execution status of this line is deduced): o.backgroundColor = option.palette.color(cg, d->selectionModel->isSelected(index)
-
1710 ? QPalette::Highlight : QPalette::Background);
never executed (the execution status of this line is deduced): ? QPalette::Highlight : QPalette::Background);
-
1711 int x = 0;
never executed (the execution status of this line is deduced): int x = 0;
-
1712 if (!option.showDecorationSelected)
never evaluated: !option.showDecorationSelected
0
1713 x = header->sectionPosition(0) + d->indentationForItem(d->current);
never executed: x = header->sectionPosition(0) + d->indentationForItem(d->current);
0
1714 QRect focusRect(x - header->offset(), y, header->length() - x, height);
never executed (the execution status of this line is deduced): QRect focusRect(x - header->offset(), y, header->length() - x, height);
-
1715 o.rect = style()->visualRect(layoutDirection(), d->viewport->rect(), focusRect);
never executed (the execution status of this line is deduced): o.rect = style()->visualRect(layoutDirection(), d->viewport->rect(), focusRect);
-
1716 style()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter);
never executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter);
-
1717 // if we show focus on all columns and the first section is moved, -
1718 // we have to split the focus rect into two rects -
1719 if (allColumnsShowFocus && !option.showDecorationSelected
never evaluated: allColumnsShowFocus
never evaluated: !option.showDecorationSelected
0
1720 && header->sectionsMoved() && (header->visualIndex(0) != 0)) {
never evaluated: header->sectionsMoved()
never evaluated: (header->visualIndex(0) != 0)
0
1721 QRect sectionRect(0, y, header->sectionPosition(0), height);
never executed (the execution status of this line is deduced): QRect sectionRect(0, y, header->sectionPosition(0), height);
-
1722 o.rect = style()->visualRect(layoutDirection(), d->viewport->rect(), sectionRect);
never executed (the execution status of this line is deduced): o.rect = style()->visualRect(layoutDirection(), d->viewport->rect(), sectionRect);
-
1723 style()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter);
never executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter);
-
1724 }
never executed: }
0
1725 }
never executed: }
0
1726}
executed: }
Execution Count:1992
1992
1727 -
1728/*! -
1729 Draws the branches in the tree view on the same row as the model item -
1730 \a index, using the \a painter given. The branches are drawn in the -
1731 rectangle specified by \a rect. -
1732*/ -
1733void QTreeView::drawBranches(QPainter *painter, const QRect &rect, -
1734 const QModelIndex &index) const -
1735{ -
1736 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
1737 const bool reverse = isRightToLeft();
executed (the execution status of this line is deduced): const bool reverse = isRightToLeft();
-
1738 const int indent = d->indent;
executed (the execution status of this line is deduced): const int indent = d->indent;
-
1739 const int outer = d->rootDecoration ? 0 : 1;
evaluated: d->rootDecoration
TRUEFALSE
yes
Evaluation Count:1878
yes
Evaluation Count:97
97-1878
1740 const int item = d->current;
executed (the execution status of this line is deduced): const int item = d->current;
-
1741 const QTreeViewItem &viewItem = d->viewItems.at(item);
executed (the execution status of this line is deduced): const QTreeViewItem &viewItem = d->viewItems.at(item);
-
1742 int level = viewItem.level;
executed (the execution status of this line is deduced): int level = viewItem.level;
-
1743 QRect primitive(reverse ? rect.left() : rect.right() + 1, rect.top(), indent, rect.height());
executed (the execution status of this line is deduced): QRect primitive(reverse ? rect.left() : rect.right() + 1, rect.top(), indent, rect.height());
-
1744 -
1745 QModelIndex parent = index.parent();
executed (the execution status of this line is deduced): QModelIndex parent = index.parent();
-
1746 QModelIndex current = parent;
executed (the execution status of this line is deduced): QModelIndex current = parent;
-
1747 QModelIndex ancestor = current.parent();
executed (the execution status of this line is deduced): QModelIndex ancestor = current.parent();
-
1748 -
1749 QStyleOptionViewItem opt = viewOptions();
executed (the execution status of this line is deduced): QStyleOptionViewItem opt = viewOptions();
-
1750 QStyle::State extraFlags = QStyle::State_None;
executed (the execution status of this line is deduced): QStyle::State extraFlags = QStyle::State_None;
-
1751 if (isEnabled())
partially evaluated: isEnabled()
TRUEFALSE
yes
Evaluation Count:1975
no
Evaluation Count:0
0-1975
1752 extraFlags |= QStyle::State_Enabled;
executed: extraFlags |= QStyle::State_Enabled;
Execution Count:1975
1975
1753 if (window()->isActiveWindow())
evaluated: window()->isActiveWindow()
TRUEFALSE
yes
Evaluation Count:1441
yes
Evaluation Count:534
534-1441
1754 extraFlags |= QStyle::State_Active;
executed: extraFlags |= QStyle::State_Active;
Execution Count:1441
1441
1755 QPoint oldBO = painter->brushOrigin();
executed (the execution status of this line is deduced): QPoint oldBO = painter->brushOrigin();
-
1756 if (verticalScrollMode() == QAbstractItemView::ScrollPerPixel)
evaluated: verticalScrollMode() == QAbstractItemView::ScrollPerPixel
TRUEFALSE
yes
Evaluation Count:180
yes
Evaluation Count:1795
180-1795
1757 painter->setBrushOrigin(QPoint(0, verticalOffset()));
executed: painter->setBrushOrigin(QPoint(0, verticalOffset()));
Execution Count:180
180
1758 -
1759 if (d->alternatingColors) {
evaluated: d->alternatingColors
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:1905
70-1905
1760 if (d->current & 1) {
evaluated: d->current & 1
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:39
31-39
1761 opt.features |= QStyleOptionViewItem::Alternate;
executed (the execution status of this line is deduced): opt.features |= QStyleOptionViewItem::Alternate;
-
1762 } else {
executed: }
Execution Count:31
31
1763 opt.features &= ~QStyleOptionViewItem::Alternate;
executed (the execution status of this line is deduced): opt.features &= ~QStyleOptionViewItem::Alternate;
-
1764 }
executed: }
Execution Count:39
39
1765 } -
1766 -
1767 // When hovering over a row, pass State_Hover for painting the branch -
1768 // indicators if it has the decoration (aka branch) selected. -
1769 bool hoverRow = selectionBehavior() == QAbstractItemView::SelectRows
evaluated: selectionBehavior() == QAbstractItemView::SelectRows
TRUEFALSE
yes
Evaluation Count:1621
yes
Evaluation Count:354
354-1621
1770 && opt.showDecorationSelected
partially evaluated: opt.showDecorationSelected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1621
0-1621
1771 && index.parent() == d->hover.parent()
never evaluated: index.parent() == d->hover.parent()
0
1772 && index.row() == d->hover.row();
never evaluated: index.row() == d->hover.row()
0
1773 -
1774 if (d->selectionModel->isSelected(index))
evaluated: d->selectionModel->isSelected(index)
TRUEFALSE
yes
Evaluation Count:107
yes
Evaluation Count:1868
107-1868
1775 extraFlags |= QStyle::State_Selected;
executed: extraFlags |= QStyle::State_Selected;
Execution Count:107
107
1776 -
1777 if (level >= outer) {
evaluated: level >= outer
TRUEFALSE
yes
Evaluation Count:1878
yes
Evaluation Count:97
97-1878
1778 // start with the innermost branch -
1779 primitive.moveLeft(reverse ? primitive.left() : primitive.left() - indent);
executed (the execution status of this line is deduced): primitive.moveLeft(reverse ? primitive.left() : primitive.left() - indent);
-
1780 opt.rect = primitive;
executed (the execution status of this line is deduced): opt.rect = primitive;
-
1781 -
1782 const bool expanded = viewItem.expanded;
executed (the execution status of this line is deduced): const bool expanded = viewItem.expanded;
-
1783 const bool children = viewItem.hasChildren;
executed (the execution status of this line is deduced): const bool children = viewItem.hasChildren;
-
1784 bool moreSiblings = viewItem.hasMoreSiblings;
executed (the execution status of this line is deduced): bool moreSiblings = viewItem.hasMoreSiblings;
-
1785 -
1786 opt.state = QStyle::State_Item | extraFlags
executed (the execution status of this line is deduced): opt.state = QStyle::State_Item | extraFlags
-
1787 | (moreSiblings ? QStyle::State_Sibling : QStyle::State_None)
executed (the execution status of this line is deduced): | (moreSiblings ? QStyle::State_Sibling : QStyle::State_None)
-
1788 | (children ? QStyle::State_Children : QStyle::State_None)
executed (the execution status of this line is deduced): | (children ? QStyle::State_Children : QStyle::State_None)
-
1789 | (expanded ? QStyle::State_Open : QStyle::State_None);
executed (the execution status of this line is deduced): | (expanded ? QStyle::State_Open : QStyle::State_None);
-
1790 if (hoverRow || item == d->hoverBranch)
partially evaluated: hoverRow
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1878
partially evaluated: item == d->hoverBranch
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1878
0-1878
1791 opt.state |= QStyle::State_MouseOver;
never executed: opt.state |= QStyle::State_MouseOver;
0
1792 else -
1793 opt.state &= ~QStyle::State_MouseOver;
executed: opt.state &= ~QStyle::State_MouseOver;
Execution Count:1878
1878
1794 style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this);
executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this);
-
1795 }
executed: }
Execution Count:1878
1878
1796 // then go out level by level -
1797 for (--level; level >= outer; --level) { // we have already drawn the innermost branch
evaluated: level >= outer
TRUEFALSE
yes
Evaluation Count:986
yes
Evaluation Count:1975
986-1975
1798 primitive.moveLeft(reverse ? primitive.left() + indent : primitive.left() - indent);
executed (the execution status of this line is deduced): primitive.moveLeft(reverse ? primitive.left() + indent : primitive.left() - indent);
-
1799 opt.rect = primitive;
executed (the execution status of this line is deduced): opt.rect = primitive;
-
1800 opt.state = extraFlags;
executed (the execution status of this line is deduced): opt.state = extraFlags;
-
1801 bool moreSiblings = false;
executed (the execution status of this line is deduced): bool moreSiblings = false;
-
1802 if (d->hiddenIndexes.isEmpty()) {
evaluated: d->hiddenIndexes.isEmpty()
TRUEFALSE
yes
Evaluation Count:972
yes
Evaluation Count:14
14-972
1803 moreSiblings = (d->model->rowCount(ancestor) - 1 > current.row());
executed (the execution status of this line is deduced): moreSiblings = (d->model->rowCount(ancestor) - 1 > current.row());
-
1804 } else {
executed: }
Execution Count:972
972
1805 int successor = item + viewItem.total + 1;
executed (the execution status of this line is deduced): int successor = item + viewItem.total + 1;
-
1806 while (successor < d->viewItems.size()
partially evaluated: successor < d->viewItems.size()
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-23
1807 && d->viewItems.at(successor).level >= uint(level)) {
partially evaluated: d->viewItems.at(successor).level >= uint(level)
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-23
1808 const QTreeViewItem &successorItem = d->viewItems.at(successor);
executed (the execution status of this line is deduced): const QTreeViewItem &successorItem = d->viewItems.at(successor);
-
1809 if (successorItem.level == uint(level)) {
evaluated: successorItem.level == uint(level)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:9
9-14
1810 moreSiblings = true;
executed (the execution status of this line is deduced): moreSiblings = true;
-
1811 break;
executed: break;
Execution Count:14
14
1812 } -
1813 successor += successorItem.total + 1;
executed (the execution status of this line is deduced): successor += successorItem.total + 1;
-
1814 }
executed: }
Execution Count:9
9
1815 }
executed: }
Execution Count:14
14
1816 if (moreSiblings)
evaluated: moreSiblings
TRUEFALSE
yes
Evaluation Count:639
yes
Evaluation Count:347
347-639
1817 opt.state |= QStyle::State_Sibling;
executed: opt.state |= QStyle::State_Sibling;
Execution Count:639
639
1818 if (hoverRow || item == d->hoverBranch)
partially evaluated: hoverRow
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:986
partially evaluated: item == d->hoverBranch
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:986
0-986
1819 opt.state |= QStyle::State_MouseOver;
never executed: opt.state |= QStyle::State_MouseOver;
0
1820 else -
1821 opt.state &= ~QStyle::State_MouseOver;
executed: opt.state &= ~QStyle::State_MouseOver;
Execution Count:986
986
1822 style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this);
executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this);
-
1823 current = ancestor;
executed (the execution status of this line is deduced): current = ancestor;
-
1824 ancestor = current.parent();
executed (the execution status of this line is deduced): ancestor = current.parent();
-
1825 }
executed: }
Execution Count:986
986
1826 painter->setBrushOrigin(oldBO);
executed (the execution status of this line is deduced): painter->setBrushOrigin(oldBO);
-
1827}
executed: }
Execution Count:1975
1975
1828 -
1829/*! -
1830 \reimp -
1831*/ -
1832void QTreeView::mousePressEvent(QMouseEvent *event) -
1833{ -
1834 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
1835 bool handled = false;
executed (the execution status of this line is deduced): bool handled = false;
-
1836 if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonPress)
partially evaluated: style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonPress
TRUEFALSE
yes
Evaluation Count:4578
no
Evaluation Count:0
0-4578
1837 handled = d->expandOrCollapseItemAtPos(event->pos());
executed: handled = d->expandOrCollapseItemAtPos(event->pos());
Execution Count:4578
4578
1838 if (!handled && d->itemDecorationAt(event->pos()) == -1)
evaluated: !handled
TRUEFALSE
yes
Evaluation Count:278
yes
Evaluation Count:4300
partially evaluated: d->itemDecorationAt(event->pos()) == -1
TRUEFALSE
yes
Evaluation Count:278
no
Evaluation Count:0
0-4300
1839 QAbstractItemView::mousePressEvent(event);
executed: QAbstractItemView::mousePressEvent(event);
Execution Count:278
278
1840}
executed: }
Execution Count:4578
4578
1841 -
1842/*! -
1843 \reimp -
1844*/ -
1845void QTreeView::mouseReleaseEvent(QMouseEvent *event) -
1846{ -
1847 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
1848 if (d->itemDecorationAt(event->pos()) == -1) {
evaluated: d->itemDecorationAt(event->pos()) == -1
TRUEFALSE
yes
Evaluation Count:4497
yes
Evaluation Count:1
1-4497
1849 QAbstractItemView::mouseReleaseEvent(event);
executed (the execution status of this line is deduced): QAbstractItemView::mouseReleaseEvent(event);
-
1850 } else {
executed: }
Execution Count:4497
4497
1851 if (state() == QAbstractItemView::DragSelectingState)
partially evaluated: state() == QAbstractItemView::DragSelectingState
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1852 setState(QAbstractItemView::NoState);
never executed: setState(QAbstractItemView::NoState);
0
1853 if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonRelease)
partially evaluated: style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonRelease
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1854 d->expandOrCollapseItemAtPos(event->pos());
never executed: d->expandOrCollapseItemAtPos(event->pos());
0
1855 }
executed: }
Execution Count:1
1
1856} -
1857 -
1858/*! -
1859 \reimp -
1860*/ -
1861void QTreeView::mouseDoubleClickEvent(QMouseEvent *event) -
1862{ -
1863 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
1864 if (state() != NoState || !d->viewport->rect().contains(event->pos()))
partially evaluated: state() != NoState
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:90
partially evaluated: !d->viewport->rect().contains(event->pos())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:90
0-90
1865 return;
never executed: return;
0
1866 -
1867 int i = d->itemDecorationAt(event->pos());
executed (the execution status of this line is deduced): int i = d->itemDecorationAt(event->pos());
-
1868 if (i == -1) {
partially evaluated: i == -1
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
1869 i = d->itemAtCoordinate(event->y());
executed (the execution status of this line is deduced): i = d->itemAtCoordinate(event->y());
-
1870 if (i == -1)
partially evaluated: i == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:90
0-90
1871 return; // user clicked outside the items
never executed: return;
0
1872 -
1873 const QPersistentModelIndex firstColumnIndex = d->viewItems.at(i).index;
executed (the execution status of this line is deduced): const QPersistentModelIndex firstColumnIndex = d->viewItems.at(i).index;
-
1874 const QPersistentModelIndex persistent = indexAt(event->pos());
executed (the execution status of this line is deduced): const QPersistentModelIndex persistent = indexAt(event->pos());
-
1875 -
1876 if (d->pressedIndex != persistent) {
evaluated: d->pressedIndex != persistent
TRUEFALSE
yes
Evaluation Count:75
yes
Evaluation Count:15
15-75
1877 mousePressEvent(event);
executed (the execution status of this line is deduced): mousePressEvent(event);
-
1878 return;
executed: return;
Execution Count:75
75
1879 } -
1880 -
1881 // signal handlers may change the model -
1882 emit doubleClicked(persistent);
executed (the execution status of this line is deduced): doubleClicked(persistent);
-
1883 -
1884 if (!persistent.isValid())
partially evaluated: !persistent.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1885 return;
never executed: return;
0
1886 -
1887 if (edit(persistent, DoubleClicked, event) || state() != NoState)
evaluated: edit(persistent, DoubleClicked, event)
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:5
partially evaluated: state() != NoState
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-10
1888 return; // the double click triggered editing
executed: return;
Execution Count:10
10
1889 -
1890 if (!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this))
partially evaluated: !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this)
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1891 emit activated(persistent);
executed: activated(persistent);
Execution Count:5
5
1892 -
1893 d->executePostedLayout(); // we need to make sure viewItems is updated
executed (the execution status of this line is deduced): d->executePostedLayout();
-
1894 if (d->itemsExpandable
partially evaluated: d->itemsExpandable
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1895 && d->expandsOnDoubleClick
partially evaluated: d->expandsOnDoubleClick
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1896 && d->hasVisibleChildren(persistent)) {
partially evaluated: d->hasVisibleChildren(persistent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1897 if (!((i < d->viewItems.count()) && (d->viewItems.at(i).index == firstColumnIndex))) {
never evaluated: (i < d->viewItems.count())
never evaluated: (d->viewItems.at(i).index == firstColumnIndex)
0
1898 // find the new index of the item -
1899 for (i = 0; i < d->viewItems.count(); ++i) {
never evaluated: i < d->viewItems.count()
0
1900 if (d->viewItems.at(i).index == firstColumnIndex)
never evaluated: d->viewItems.at(i).index == firstColumnIndex
0
1901 break;
never executed: break;
0
1902 }
never executed: }
0
1903 if (i == d->viewItems.count())
never evaluated: i == d->viewItems.count()
0
1904 return;
never executed: return;
0
1905 }
never executed: }
0
1906 if (d->viewItems.at(i).expanded)
never evaluated: d->viewItems.at(i).expanded
0
1907 d->collapse(i, true);
never executed: d->collapse(i, true);
0
1908 else -
1909 d->expand(i, true);
never executed: d->expand(i, true);
0
1910 updateGeometries();
never executed (the execution status of this line is deduced): updateGeometries();
-
1911 viewport()->update();
never executed (the execution status of this line is deduced): viewport()->update();
-
1912 }
never executed: }
0
1913 }
executed: }
Execution Count:5
5
1914}
executed: }
Execution Count:5
5
1915 -
1916/*! -
1917 \reimp -
1918*/ -
1919void QTreeView::mouseMoveEvent(QMouseEvent *event) -
1920{ -
1921 Q_D(QTreeView);
never executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
1922 if (d->itemDecorationAt(event->pos()) == -1) // ### what about expanding/collapsing state ?
never evaluated: d->itemDecorationAt(event->pos()) == -1
0
1923 QAbstractItemView::mouseMoveEvent(event);
never executed: QAbstractItemView::mouseMoveEvent(event);
0
1924}
never executed: }
0
1925 -
1926/*! -
1927 \reimp -
1928*/ -
1929void QTreeView::keyPressEvent(QKeyEvent *event) -
1930{ -
1931 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
1932 QModelIndex current = currentIndex();
executed (the execution status of this line is deduced): QModelIndex current = currentIndex();
-
1933 //this is the management of the expansion -
1934 if (d->isIndexValid(current) && d->model && d->itemsExpandable) {
evaluated: d->isIndexValid(current)
TRUEFALSE
yes
Evaluation Count:204
yes
Evaluation Count:3
partially evaluated: d->model
TRUEFALSE
yes
Evaluation Count:204
no
Evaluation Count:0
evaluated: d->itemsExpandable
TRUEFALSE
yes
Evaluation Count:202
yes
Evaluation Count:2
0-204
1935 switch (event->key()) { -
1936 case Qt::Key_Asterisk: { -
1937 QStack<QModelIndex> parents;
never executed (the execution status of this line is deduced): QStack<QModelIndex> parents;
-
1938 parents.push(current);
never executed (the execution status of this line is deduced): parents.push(current);
-
1939 while (!parents.isEmpty()) {
never evaluated: !parents.isEmpty()
0
1940 QModelIndex parent = parents.pop();
never executed (the execution status of this line is deduced): QModelIndex parent = parents.pop();
-
1941 for (int row = 0; row < d->model->rowCount(parent); ++row) {
never evaluated: row < d->model->rowCount(parent)
0
1942 QModelIndex child = d->model->index(row, 0, parent);
never executed (the execution status of this line is deduced): QModelIndex child = d->model->index(row, 0, parent);
-
1943 if (!d->isIndexValid(child))
never evaluated: !d->isIndexValid(child)
0
1944 break;
never executed: break;
0
1945 parents.push(child);
never executed (the execution status of this line is deduced): parents.push(child);
-
1946 expand(child);
never executed (the execution status of this line is deduced): expand(child);
-
1947 }
never executed: }
0
1948 }
never executed: }
0
1949 expand(current);
never executed (the execution status of this line is deduced): expand(current);
-
1950 break; }
never executed: break;
0
1951 case Qt::Key_Plus: -
1952 expand(current);
executed (the execution status of this line is deduced): expand(current);
-
1953 break;
executed: break;
Execution Count:1
1
1954 case Qt::Key_Minus: -
1955 collapse(current);
executed (the execution status of this line is deduced): collapse(current);
-
1956 break;
executed: break;
Execution Count:1
1
1957 } -
1958 }
executed: }
Execution Count:202
202
1959 -
1960 QAbstractItemView::keyPressEvent(event);
executed (the execution status of this line is deduced): QAbstractItemView::keyPressEvent(event);
-
1961}
executed: }
Execution Count:207
207
1962 -
1963/*! -
1964 \reimp -
1965*/ -
1966QModelIndex QTreeView::indexAt(const QPoint &point) const -
1967{ -
1968 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
1969 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
1970 -
1971 int visualIndex = d->itemAtCoordinate(point.y());
executed (the execution status of this line is deduced): int visualIndex = d->itemAtCoordinate(point.y());
-
1972 QModelIndex idx = d->modelIndex(visualIndex);
executed (the execution status of this line is deduced): QModelIndex idx = d->modelIndex(visualIndex);
-
1973 if (!idx.isValid())
evaluated: !idx.isValid()
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:7081
42-7081
1974 return QModelIndex();
executed: return QModelIndex();
Execution Count:42
42
1975 -
1976 if (d->viewItems.at(visualIndex).spanning)
evaluated: d->viewItems.at(visualIndex).spanning
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:7061
20-7061
1977 return idx;
executed: return idx;
Execution Count:20
20
1978 -
1979 int column = d->columnAt(point.x());
executed (the execution status of this line is deduced): int column = d->columnAt(point.x());
-
1980 if (column == idx.column())
evaluated: column == idx.column()
TRUEFALSE
yes
Evaluation Count:5182
yes
Evaluation Count:1879
1879-5182
1981 return idx;
executed: return idx;
Execution Count:5182
5182
1982 if (column < 0)
evaluated: column < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1877
2-1877
1983 return QModelIndex();
executed: return QModelIndex();
Execution Count:2
2
1984 return idx.sibling(idx.row(), column);
executed: return idx.sibling(idx.row(), column);
Execution Count:1877
1877
1985} -
1986 -
1987/*! -
1988 Returns the model index of the item above \a index. -
1989*/ -
1990QModelIndex QTreeView::indexAbove(const QModelIndex &index) const -
1991{ -
1992 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
1993 if (!d->isIndexValid(index))
evaluated: !d->isIndexValid(index)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:25
3-25
1994 return QModelIndex();
executed: return QModelIndex();
Execution Count:3
3
1995 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
1996 int i = d->viewIndex(index);
executed (the execution status of this line is deduced): int i = d->viewIndex(index);
-
1997 if (--i < 0)
evaluated: --i < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:22
3-22
1998 return QModelIndex();
executed: return QModelIndex();
Execution Count:3
3
1999 const QModelIndex firstColumnIndex = d->viewItems.at(i).index;
executed (the execution status of this line is deduced): const QModelIndex firstColumnIndex = d->viewItems.at(i).index;
-
2000 return firstColumnIndex.sibling(firstColumnIndex.row(), index.column());
executed: return firstColumnIndex.sibling(firstColumnIndex.row(), index.column());
Execution Count:22
22
2001} -
2002 -
2003/*! -
2004 Returns the model index of the item below \a index. -
2005*/ -
2006QModelIndex QTreeView::indexBelow(const QModelIndex &index) const -
2007{ -
2008 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
2009 if (!d->isIndexValid(index))
evaluated: !d->isIndexValid(index)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14
1-14
2010 return QModelIndex();
executed: return QModelIndex();
Execution Count:1
1
2011 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
2012 int i = d->viewIndex(index);
executed (the execution status of this line is deduced): int i = d->viewIndex(index);
-
2013 if (++i >= d->viewItems.count())
evaluated: ++i >= d->viewItems.count()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:11
3-11
2014 return QModelIndex();
executed: return QModelIndex();
Execution Count:3
3
2015 const QModelIndex firstColumnIndex = d->viewItems.at(i).index;
executed (the execution status of this line is deduced): const QModelIndex firstColumnIndex = d->viewItems.at(i).index;
-
2016 return firstColumnIndex.sibling(firstColumnIndex.row(), index.column());
executed: return firstColumnIndex.sibling(firstColumnIndex.row(), index.column());
Execution Count:11
11
2017} -
2018 -
2019/*! -
2020 \internal -
2021 -
2022 Lays out the items in the tree view. -
2023*/ -
2024void QTreeView::doItemsLayout() -
2025{ -
2026 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2027 if (d->hasRemovedItems) {
evaluated: d->hasRemovedItems
TRUEFALSE
yes
Evaluation Count:107
yes
Evaluation Count:616
107-616
2028 //clean the QSet that may contains old (and this invalid) indexes -
2029 d->hasRemovedItems = false;
executed (the execution status of this line is deduced): d->hasRemovedItems = false;
-
2030 QSet<QPersistentModelIndex>::iterator it = d->expandedIndexes.begin();
executed (the execution status of this line is deduced): QSet<QPersistentModelIndex>::iterator it = d->expandedIndexes.begin();
-
2031 while (it != d->expandedIndexes.end()) {
evaluated: it != d->expandedIndexes.end()
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:107
35-107
2032 if (!it->isValid())
evaluated: !it->isValid()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:18
17-18
2033 it = d->expandedIndexes.erase(it);
executed: it = d->expandedIndexes.erase(it);
Execution Count:17
17
2034 else -
2035 ++it;
executed: ++it;
Execution Count:18
18
2036 } -
2037 it = d->hiddenIndexes.begin();
executed (the execution status of this line is deduced): it = d->hiddenIndexes.begin();
-
2038 while (it != d->hiddenIndexes.end()) {
evaluated: it != d->hiddenIndexes.end()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:107
3-107
2039 if (!it->isValid())
partially evaluated: !it->isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
2040 it = d->hiddenIndexes.erase(it);
never executed: it = d->hiddenIndexes.erase(it);
0
2041 else -
2042 ++it;
executed: ++it;
Execution Count:3
3
2043 } -
2044 }
executed: }
Execution Count:107
107
2045 d->viewItems.clear(); // prepare for new layout
executed (the execution status of this line is deduced): d->viewItems.clear();
-
2046 QModelIndex parent = d->root;
executed (the execution status of this line is deduced): QModelIndex parent = d->root;
-
2047 if (d->model->hasChildren(parent)) {
evaluated: d->model->hasChildren(parent)
TRUEFALSE
yes
Evaluation Count:421
yes
Evaluation Count:302
302-421
2048 d->layout(-1);
executed (the execution status of this line is deduced): d->layout(-1);
-
2049 }
executed: }
Execution Count:421
421
2050 QAbstractItemView::doItemsLayout();
executed (the execution status of this line is deduced): QAbstractItemView::doItemsLayout();
-
2051 d->header->doItemsLayout();
executed (the execution status of this line is deduced): d->header->doItemsLayout();
-
2052}
executed: }
Execution Count:723
723
2053 -
2054/*! -
2055 \reimp -
2056*/ -
2057void QTreeView::reset() -
2058{ -
2059 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2060 d->expandedIndexes.clear();
executed (the execution status of this line is deduced): d->expandedIndexes.clear();
-
2061 d->hiddenIndexes.clear();
executed (the execution status of this line is deduced): d->hiddenIndexes.clear();
-
2062 d->spanningIndexes.clear();
executed (the execution status of this line is deduced): d->spanningIndexes.clear();
-
2063 d->viewItems.clear();
executed (the execution status of this line is deduced): d->viewItems.clear();
-
2064 QAbstractItemView::reset();
executed (the execution status of this line is deduced): QAbstractItemView::reset();
-
2065}
executed: }
Execution Count:909
909
2066 -
2067/*! -
2068 Returns the horizontal offset of the items in the treeview. -
2069 -
2070 Note that the tree view uses the horizontal header section -
2071 positions to determine the positions of columns in the view. -
2072 -
2073 \sa verticalOffset() -
2074*/ -
2075int QTreeView::horizontalOffset() const -
2076{ -
2077 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
2078 return d->header->offset();
executed: return d->header->offset();
Execution Count:979
979
2079} -
2080 -
2081/*! -
2082 Returns the vertical offset of the items in the tree view. -
2083 -
2084 \sa horizontalOffset() -
2085*/ -
2086int QTreeView::verticalOffset() const -
2087{ -
2088 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
2089 if (d->verticalScrollMode == QAbstractItemView::ScrollPerItem) {
evaluated: d->verticalScrollMode == QAbstractItemView::ScrollPerItem
TRUEFALSE
yes
Evaluation Count:768
yes
Evaluation Count:391
391-768
2090 if (d->uniformRowHeights)
evaluated: d->uniformRowHeights
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:755
13-755
2091 return verticalScrollBar()->value() * d->defaultItemHeight;
executed: return verticalScrollBar()->value() * d->defaultItemHeight;
Execution Count:13
13
2092 // If we are scrolling per item and have non-uniform row heights, -
2093 // finding the vertical offset in pixels is going to be relatively slow. -
2094 // ### find a faster way to do this -
2095 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
2096 int offset = 0;
executed (the execution status of this line is deduced): int offset = 0;
-
2097 for (int i = 0; i < d->viewItems.count(); ++i) {
evaluated: i < d->viewItems.count()
TRUEFALSE
yes
Evaluation Count:1447
yes
Evaluation Count:45
45-1447
2098 if (i == verticalScrollBar()->value())
evaluated: i == verticalScrollBar()->value()
TRUEFALSE
yes
Evaluation Count:710
yes
Evaluation Count:737
710-737
2099 return offset;
executed: return offset;
Execution Count:710
710
2100 offset += d->itemHeight(i);
executed (the execution status of this line is deduced): offset += d->itemHeight(i);
-
2101 }
executed: }
Execution Count:737
737
2102 return 0;
executed: return 0;
Execution Count:45
45
2103 } -
2104 // scroll per pixel -
2105 return verticalScrollBar()->value();
executed: return verticalScrollBar()->value();
Execution Count:391
391
2106} -
2107 -
2108/*! -
2109 Move the cursor in the way described by \a cursorAction, using the -
2110 information provided by the button \a modifiers. -
2111*/ -
2112QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) -
2113{ -
2114 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2115 Q_UNUSED(modifiers);
executed (the execution status of this line is deduced): (void)modifiers;;
-
2116 -
2117 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
2118 -
2119 QModelIndex current = currentIndex();
executed (the execution status of this line is deduced): QModelIndex current = currentIndex();
-
2120 if (!current.isValid()) {
evaluated: !current.isValid()
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:155
42-155
2121 int i = d->below(-1);
executed (the execution status of this line is deduced): int i = d->below(-1);
-
2122 int c = 0;
executed (the execution status of this line is deduced): int c = 0;
-
2123 while (c < d->header->count() && d->header->isSectionHidden(c))
evaluated: c < d->header->count()
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:3
evaluated: d->header->isSectionHidden(c)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:39
3-44
2124 ++c;
executed: ++c;
Execution Count:5
5
2125 if (i < d->viewItems.count() && c < d->header->count()) {
partially evaluated: i < d->viewItems.count()
TRUEFALSE
yes
Evaluation Count:42
no
Evaluation Count:0
evaluated: c < d->header->count()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:3
0-42
2126 return d->modelIndex(i, c);
executed: return d->modelIndex(i, c);
Execution Count:39
39
2127 } -
2128 return QModelIndex();
executed: return QModelIndex();
Execution Count:3
3
2129 } -
2130 int vi = -1;
executed (the execution status of this line is deduced): int vi = -1;
-
2131#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) -
2132 // Selection behavior is slightly different on the Mac. -
2133 if (d->selectionMode == QAbstractItemView::ExtendedSelection -
2134 && d->selectionModel -
2135 && d->selectionModel->hasSelection()) { -
2136 -
2137 const bool moveUpDown = (cursorAction == MoveUp || cursorAction == MoveDown); -
2138 const bool moveNextPrev = (cursorAction == MoveNext || cursorAction == MovePrevious); -
2139 const bool contiguousSelection = moveUpDown && (modifiers & Qt::ShiftModifier); -
2140 -
2141 // Use the outermost index in the selection as the current index -
2142 if (!contiguousSelection && (moveUpDown || moveNextPrev)) { -
2143 -
2144 // Find outermost index. -
2145 const bool useTopIndex = (cursorAction == MoveUp || cursorAction == MovePrevious); -
2146 int index = useTopIndex ? INT_MAX : INT_MIN; -
2147 const QItemSelection selection = d->selectionModel->selection(); -
2148 for (int i = 0; i < selection.count(); ++i) { -
2149 const QItemSelectionRange &range = selection.at(i); -
2150 int candidate = d->viewIndex(useTopIndex ? range.topLeft() : range.bottomRight()); -
2151 if (candidate >= 0) -
2152 index = useTopIndex ? qMin(index, candidate) : qMax(index, candidate); -
2153 } -
2154 -
2155 if (index >= 0 && index < INT_MAX) -
2156 vi = index; -
2157 } -
2158 } -
2159#endif -
2160 if (vi < 0)
partially evaluated: vi < 0
TRUEFALSE
yes
Evaluation Count:155
no
Evaluation Count:0
0-155
2161 vi = qMax(0, d->viewIndex(current));
executed: vi = qMax(0, d->viewIndex(current));
Execution Count:155
155
2162 -
2163 if (isRightToLeft()) {
partially evaluated: isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:155
0-155
2164 if (cursorAction == MoveRight)
never evaluated: cursorAction == MoveRight
0
2165 cursorAction = MoveLeft;
never executed: cursorAction = MoveLeft;
0
2166 else if (cursorAction == MoveLeft)
never evaluated: cursorAction == MoveLeft
0
2167 cursorAction = MoveRight;
never executed: cursorAction = MoveRight;
0
2168 } -
2169 switch (cursorAction) { -
2170 case MoveNext: -
2171 case MoveDown: -
2172#ifdef QT_KEYPAD_NAVIGATION -
2173 if (vi == d->viewItems.count()-1 && QApplication::keypadNavigationEnabled()) -
2174 return d->model->index(0, current.column(), d->root); -
2175#endif -
2176 return d->modelIndex(d->below(vi), current.column());
executed: return d->modelIndex(d->below(vi), current.column());
Execution Count:33
33
2177 case MovePrevious: -
2178 case MoveUp: -
2179#ifdef QT_KEYPAD_NAVIGATION -
2180 if (vi == 0 && QApplication::keypadNavigationEnabled()) -
2181 return d->modelIndex(d->viewItems.count() - 1, current.column()); -
2182#endif -
2183 return d->modelIndex(d->above(vi), current.column());
executed: return d->modelIndex(d->above(vi), current.column());
Execution Count:51
51
2184 case MoveLeft: { -
2185 QScrollBar *sb = horizontalScrollBar();
executed (the execution status of this line is deduced): QScrollBar *sb = horizontalScrollBar();
-
2186 if (vi < d->viewItems.count() && d->viewItems.at(vi).expanded && d->itemsExpandable && sb->value() == sb->minimum()) {
partially evaluated: vi < d->viewItems.count()
TRUEFALSE
yes
Evaluation Count:46
no
Evaluation Count:0
evaluated: d->viewItems.at(vi).expanded
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:38
partially evaluated: d->itemsExpandable
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
partially evaluated: sb->value() == sb->minimum()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-46
2187 d->collapse(vi, true);
executed (the execution status of this line is deduced): d->collapse(vi, true);
-
2188 d->moveCursorUpdatedView = true;
executed (the execution status of this line is deduced): d->moveCursorUpdatedView = true;
-
2189 } else {
executed: }
Execution Count:8
8
2190 bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this);
executed (the execution status of this line is deduced): bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this);
-
2191 if (descend) {
partially evaluated: descend
TRUEFALSE
yes
Evaluation Count:38
no
Evaluation Count:0
0-38
2192 QModelIndex par = current.parent();
executed (the execution status of this line is deduced): QModelIndex par = current.parent();
-
2193 if (par.isValid() && par != rootIndex())
evaluated: par.isValid()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:32
evaluated: par != rootIndex()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-32
2194 return par;
executed: return par;
Execution Count:5
5
2195 else -
2196 descend = false;
executed: descend = false;
Execution Count:33
33
2197 } -
2198 if (!descend) {
partially evaluated: !descend
TRUEFALSE
yes
Evaluation Count:33
no
Evaluation Count:0
0-33
2199 if (d->selectionBehavior == SelectItems || d->selectionBehavior == SelectColumns) {
evaluated: d->selectionBehavior == SelectItems
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:5
partially evaluated: d->selectionBehavior == SelectColumns
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-28
2200 int visualColumn = d->header->visualIndex(current.column()) - 1;
executed (the execution status of this line is deduced): int visualColumn = d->header->visualIndex(current.column()) - 1;
-
2201 while (visualColumn >= 0 && isColumnHidden(d->header->logicalIndex(visualColumn)))
evaluated: visualColumn >= 0
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:11
evaluated: isColumnHidden(d->header->logicalIndex(visualColumn))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:17
4-21
2202 visualColumn--;
executed: visualColumn--;
Execution Count:4
4
2203 int newColumn = d->header->logicalIndex(visualColumn);
executed (the execution status of this line is deduced): int newColumn = d->header->logicalIndex(visualColumn);
-
2204 QModelIndex next = current.sibling(current.row(), newColumn);
executed (the execution status of this line is deduced): QModelIndex next = current.sibling(current.row(), newColumn);
-
2205 if (next.isValid())
evaluated: next.isValid()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:11
11-17
2206 return next;
executed: return next;
Execution Count:17
17
2207 }
executed: }
Execution Count:11
11
2208 -
2209 int oldValue = sb->value();
executed (the execution status of this line is deduced): int oldValue = sb->value();
-
2210 sb->setValue(sb->value() - sb->singleStep());
executed (the execution status of this line is deduced): sb->setValue(sb->value() - sb->singleStep());
-
2211 if (oldValue != sb->value())
partially evaluated: oldValue != sb->value()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
2212 d->moveCursorUpdatedView = true;
never executed: d->moveCursorUpdatedView = true;
0
2213 }
executed: }
Execution Count:16
16
2214 -
2215 }
executed: }
Execution Count:16
16
2216 updateGeometries();
executed (the execution status of this line is deduced): updateGeometries();
-
2217 viewport()->update();
executed (the execution status of this line is deduced): viewport()->update();
-
2218 break;
executed: break;
Execution Count:24
24
2219 } -
2220 case MoveRight: -
2221 if (vi < d->viewItems.count() && !d->viewItems.at(vi).expanded && d->itemsExpandable
partially evaluated: vi < d->viewItems.count()
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
evaluated: !d->viewItems.at(vi).expanded
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:5
evaluated: d->itemsExpandable
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:1
0-19
2222 && d->hasVisibleChildren(d->viewItems.at(vi).index)) {
evaluated: d->hasVisibleChildren(d->viewItems.at(vi).index)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
2223 d->expand(vi, true);
executed (the execution status of this line is deduced): d->expand(vi, true);
-
2224 d->moveCursorUpdatedView = true;
executed (the execution status of this line is deduced): d->moveCursorUpdatedView = true;
-
2225 } else {
executed: }
Execution Count:12
12
2226 bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this);
executed (the execution status of this line is deduced): bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this);
-
2227 if (descend) {
partially evaluated: descend
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
2228 QModelIndex idx = d->modelIndex(d->below(vi));
executed (the execution status of this line is deduced): QModelIndex idx = d->modelIndex(d->below(vi));
-
2229 if (idx.parent() == current)
evaluated: idx.parent() == current
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
2-5
2230 return idx;
executed: return idx;
Execution Count:5
5
2231 else -
2232 descend = false;
executed: descend = false;
Execution Count:2
2
2233 } -
2234 if (!descend) {
partially evaluated: !descend
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2235 if (d->selectionBehavior == SelectItems || d->selectionBehavior == SelectColumns) {
partially evaluated: d->selectionBehavior == SelectItems
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: d->selectionBehavior == SelectColumns
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2236 int visualColumn = d->header->visualIndex(current.column()) + 1;
never executed (the execution status of this line is deduced): int visualColumn = d->header->visualIndex(current.column()) + 1;
-
2237 while (visualColumn < d->model->columnCount(current.parent()) && isColumnHidden(d->header->logicalIndex(visualColumn)))
never evaluated: visualColumn < d->model->columnCount(current.parent())
never evaluated: isColumnHidden(d->header->logicalIndex(visualColumn))
0
2238 visualColumn++;
never executed: visualColumn++;
0
2239 -
2240 QModelIndex next = current.sibling(current.row(), visualColumn);
never executed (the execution status of this line is deduced): QModelIndex next = current.sibling(current.row(), visualColumn);
-
2241 if (next.isValid())
never evaluated: next.isValid()
0
2242 return next;
never executed: return next;
0
2243 }
never executed: }
0
2244 -
2245 //last restort: we change the scrollbar value -
2246 QScrollBar *sb = horizontalScrollBar();
executed (the execution status of this line is deduced): QScrollBar *sb = horizontalScrollBar();
-
2247 int oldValue = sb->value();
executed (the execution status of this line is deduced): int oldValue = sb->value();
-
2248 sb->setValue(sb->value() + sb->singleStep());
executed (the execution status of this line is deduced): sb->setValue(sb->value() + sb->singleStep());
-
2249 if (oldValue != sb->value())
partially evaluated: oldValue != sb->value()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2250 d->moveCursorUpdatedView = true;
never executed: d->moveCursorUpdatedView = true;
0
2251 }
executed: }
Execution Count:2
2
2252 }
executed: }
Execution Count:2
2
2253 updateGeometries();
executed (the execution status of this line is deduced): updateGeometries();
-
2254 viewport()->update();
executed (the execution status of this line is deduced): viewport()->update();
-
2255 break;
executed: break;
Execution Count:14
14
2256 case MovePageUp: -
2257 return d->modelIndex(d->pageUp(vi), current.column());
executed: return d->modelIndex(d->pageUp(vi), current.column());
Execution Count:5
5
2258 case MovePageDown: -
2259 return d->modelIndex(d->pageDown(vi), current.column());
executed: return d->modelIndex(d->pageDown(vi), current.column());
Execution Count:1
1
2260 case MoveHome: -
2261 return d->model->index(0, current.column(), d->root);
never executed: return d->model->index(0, current.column(), d->root);
0
2262 case MoveEnd: -
2263 return d->modelIndex(d->viewItems.count() - 1, current.column());
never executed: return d->modelIndex(d->viewItems.count() - 1, current.column());
0
2264 } -
2265 return current;
executed: return current;
Execution Count:38
38
2266} -
2267 -
2268/*! -
2269 Applies the selection \a command to the items in or touched by the -
2270 rectangle, \a rect. -
2271 -
2272 \sa selectionCommand() -
2273*/ -
2274void QTreeView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) -
2275{ -
2276 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2277 if (!selectionModel() || rect.isNull())
evaluated: !selectionModel()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:318
partially evaluated: rect.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:318
0-318
2278 return;
executed: return;
Execution Count:2
2
2279 -
2280 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
2281 QPoint tl(isRightToLeft() ? qMax(rect.left(), rect.right())
executed (the execution status of this line is deduced): QPoint tl(isRightToLeft() ? qMax(rect.left(), rect.right())
-
2282 : qMin(rect.left(), rect.right()), qMin(rect.top(), rect.bottom()));
executed (the execution status of this line is deduced): : qMin(rect.left(), rect.right()), qMin(rect.top(), rect.bottom()));
-
2283 QPoint br(isRightToLeft() ? qMin(rect.left(), rect.right()) :
executed (the execution status of this line is deduced): QPoint br(isRightToLeft() ? qMin(rect.left(), rect.right()) :
-
2284 qMax(rect.left(), rect.right()), qMax(rect.top(), rect.bottom()));
executed (the execution status of this line is deduced): qMax(rect.left(), rect.right()), qMax(rect.top(), rect.bottom()));
-
2285 QModelIndex topLeft = indexAt(tl);
executed (the execution status of this line is deduced): QModelIndex topLeft = indexAt(tl);
-
2286 QModelIndex bottomRight = indexAt(br);
executed (the execution status of this line is deduced): QModelIndex bottomRight = indexAt(br);
-
2287 if (!topLeft.isValid() && !bottomRight.isValid()) {
evaluated: !topLeft.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:317
partially evaluated: !bottomRight.isValid()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-317
2288 if (command & QItemSelectionModel::Clear)
partially evaluated: command & QItemSelectionModel::Clear
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2289 selectionModel()->clear();
executed: selectionModel()->clear();
Execution Count:1
1
2290 return;
executed: return;
Execution Count:1
1
2291 } -
2292 if (!topLeft.isValid() && !d->viewItems.isEmpty())
partially evaluated: !topLeft.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:317
never evaluated: !d->viewItems.isEmpty()
0-317
2293 topLeft = d->viewItems.first().index;
never executed: topLeft = d->viewItems.first().index;
0
2294 if (!bottomRight.isValid() && !d->viewItems.isEmpty()) {
partially evaluated: !bottomRight.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:317
never evaluated: !d->viewItems.isEmpty()
0-317
2295 const int column = d->header->logicalIndex(d->header->count() - 1);
never executed (the execution status of this line is deduced): const int column = d->header->logicalIndex(d->header->count() - 1);
-
2296 const QModelIndex index = d->viewItems.last().index;
never executed (the execution status of this line is deduced): const QModelIndex index = d->viewItems.last().index;
-
2297 bottomRight = index.sibling(index.row(), column);
never executed (the execution status of this line is deduced): bottomRight = index.sibling(index.row(), column);
-
2298 }
never executed: }
0
2299 -
2300 if (!d->isIndexEnabled(topLeft) || !d->isIndexEnabled(bottomRight))
partially evaluated: !d->isIndexEnabled(topLeft)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:317
partially evaluated: !d->isIndexEnabled(bottomRight)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:317
0-317
2301 return;
never executed: return;
0
2302 -
2303 d->select(topLeft, bottomRight, command);
executed (the execution status of this line is deduced): d->select(topLeft, bottomRight, command);
-
2304}
executed: }
Execution Count:317
317
2305 -
2306/*! -
2307 Returns the rectangle from the viewport of the items in the given -
2308 \a selection. -
2309 -
2310 Since 4.7, the returned region only contains rectangles intersecting -
2311 (or included in) the viewport. -
2312*/ -
2313QRegion QTreeView::visualRegionForSelection(const QItemSelection &selection) const -
2314{ -
2315 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
2316 if (selection.isEmpty())
evaluated: selection.isEmpty()
TRUEFALSE
yes
Evaluation Count:161
yes
Evaluation Count:757
161-757
2317 return QRegion();
executed: return QRegion();
Execution Count:161
161
2318 -
2319 QRegion selectionRegion;
executed (the execution status of this line is deduced): QRegion selectionRegion;
-
2320 const QRect &viewportRect = d->viewport->rect();
executed (the execution status of this line is deduced): const QRect &viewportRect = d->viewport->rect();
-
2321 for (int i = 0; i < selection.count(); ++i) {
evaluated: i < selection.count()
TRUEFALSE
yes
Evaluation Count:765
yes
Evaluation Count:757
757-765
2322 QItemSelectionRange range = selection.at(i);
executed (the execution status of this line is deduced): QItemSelectionRange range = selection.at(i);
-
2323 if (!range.isValid())
partially evaluated: !range.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:765
0-765
2324 continue;
never executed: continue;
0
2325 QModelIndex parent = range.parent();
executed (the execution status of this line is deduced): QModelIndex parent = range.parent();
-
2326 QModelIndex leftIndex = range.topLeft();
executed (the execution status of this line is deduced): QModelIndex leftIndex = range.topLeft();
-
2327 int columnCount = d->model->columnCount(parent);
executed (the execution status of this line is deduced): int columnCount = d->model->columnCount(parent);
-
2328 while (leftIndex.isValid() && isIndexHidden(leftIndex)) {
evaluated: leftIndex.isValid()
TRUEFALSE
yes
Evaluation Count:769
yes
Evaluation Count:4
evaluated: isIndexHidden(leftIndex)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:761
4-769
2329 if (leftIndex.column() + 1 < columnCount)
evaluated: leftIndex.column() + 1 < columnCount
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
2330 leftIndex = d->model->index(leftIndex.row(), leftIndex.column() + 1, parent);
executed: leftIndex = d->model->index(leftIndex.row(), leftIndex.column() + 1, parent);
Execution Count:4
4
2331 else -
2332 leftIndex = QModelIndex();
executed: leftIndex = QModelIndex();
Execution Count:4
4
2333 } -
2334 if (!leftIndex.isValid())
evaluated: !leftIndex.isValid()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:761
4-761
2335 continue;
executed: continue;
Execution Count:4
4
2336 const QRect leftRect = visualRect(leftIndex);
executed (the execution status of this line is deduced): const QRect leftRect = visualRect(leftIndex);
-
2337 int top = leftRect.top();
executed (the execution status of this line is deduced): int top = leftRect.top();
-
2338 QModelIndex rightIndex = range.bottomRight();
executed (the execution status of this line is deduced): QModelIndex rightIndex = range.bottomRight();
-
2339 while (rightIndex.isValid() && isIndexHidden(rightIndex)) {
partially evaluated: rightIndex.isValid()
TRUEFALSE
yes
Evaluation Count:761
no
Evaluation Count:0
partially evaluated: isIndexHidden(rightIndex)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:761
0-761
2340 if (rightIndex.column() - 1 >= 0)
never evaluated: rightIndex.column() - 1 >= 0
0
2341 rightIndex = d->model->index(rightIndex.row(), rightIndex.column() - 1, parent);
never executed: rightIndex = d->model->index(rightIndex.row(), rightIndex.column() - 1, parent);
0
2342 else -
2343 rightIndex = QModelIndex();
never executed: rightIndex = QModelIndex();
0
2344 } -
2345 if (!rightIndex.isValid())
partially evaluated: !rightIndex.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:761
0-761
2346 continue;
never executed: continue;
0
2347 const QRect rightRect = visualRect(rightIndex);
executed (the execution status of this line is deduced): const QRect rightRect = visualRect(rightIndex);
-
2348 int bottom = rightRect.bottom();
executed (the execution status of this line is deduced): int bottom = rightRect.bottom();
-
2349 if (top > bottom)
evaluated: top > bottom
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:713
48-713
2350 qSwap<int>(top, bottom);
executed: qSwap<int>(top, bottom);
Execution Count:48
48
2351 int height = bottom - top + 1;
executed (the execution status of this line is deduced): int height = bottom - top + 1;
-
2352 if (d->header->sectionsMoved()) {
partially evaluated: d->header->sectionsMoved()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:761
0-761
2353 for (int c = range.left(); c <= range.right(); ++c) {
never evaluated: c <= range.right()
0
2354 const QRect rangeRect(columnViewportPosition(c), top, columnWidth(c), height);
never executed (the execution status of this line is deduced): const QRect rangeRect(columnViewportPosition(c), top, columnWidth(c), height);
-
2355 if (viewportRect.intersects(rangeRect))
never evaluated: viewportRect.intersects(rangeRect)
0
2356 selectionRegion += rangeRect;
never executed: selectionRegion += rangeRect;
0
2357 }
never executed: }
0
2358 } else {
never executed: }
0
2359 QRect combined = leftRect|rightRect;
executed (the execution status of this line is deduced): QRect combined = leftRect|rightRect;
-
2360 combined.setX(columnViewportPosition(isRightToLeft() ? range.right() : range.left()));
executed (the execution status of this line is deduced): combined.setX(columnViewportPosition(isRightToLeft() ? range.right() : range.left()));
-
2361 if (viewportRect.intersects(combined))
evaluated: viewportRect.intersects(combined)
TRUEFALSE
yes
Evaluation Count:700
yes
Evaluation Count:61
61-700
2362 selectionRegion += combined;
executed: selectionRegion += combined;
Execution Count:700
700
2363 }
executed: }
Execution Count:761
761
2364 } -
2365 return selectionRegion;
executed: return selectionRegion;
Execution Count:757
757
2366} -
2367 -
2368/*! -
2369 \reimp -
2370*/ -
2371QModelIndexList QTreeView::selectedIndexes() const -
2372{ -
2373 QModelIndexList viewSelected;
executed (the execution status of this line is deduced): QModelIndexList viewSelected;
-
2374 QModelIndexList modelSelected;
executed (the execution status of this line is deduced): QModelIndexList modelSelected;
-
2375 if (selectionModel())
evaluated: selectionModel()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:2
2-8
2376 modelSelected = selectionModel()->selectedIndexes();
executed: modelSelected = selectionModel()->selectedIndexes();
Execution Count:8
8
2377 for (int i = 0; i < modelSelected.count(); ++i) {
evaluated: i < modelSelected.count()
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:10
10-25
2378 // check that neither the parents nor the index is hidden before we add -
2379 QModelIndex index = modelSelected.at(i);
executed (the execution status of this line is deduced): QModelIndex index = modelSelected.at(i);
-
2380 while (index.isValid() && !isIndexHidden(index))
evaluated: index.isValid()
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:25
partially evaluated: !isIndexHidden(index)
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
2381 index = index.parent();
executed: index = index.parent();
Execution Count:25
25
2382 if (index.isValid())
partially evaluated: index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
2383 continue;
never executed: continue;
0
2384 viewSelected.append(modelSelected.at(i));
executed (the execution status of this line is deduced): viewSelected.append(modelSelected.at(i));
-
2385 }
executed: }
Execution Count:25
25
2386 return viewSelected;
executed: return viewSelected;
Execution Count:10
10
2387} -
2388 -
2389/*! -
2390 Scrolls the contents of the tree view by (\a dx, \a dy). -
2391*/ -
2392void QTreeView::scrollContentsBy(int dx, int dy) -
2393{ -
2394 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2395 -
2396 d->delayedAutoScroll.stop(); // auto scroll was canceled by the user scrolling
executed (the execution status of this line is deduced): d->delayedAutoScroll.stop();
-
2397 -
2398 dx = isRightToLeft() ? -dx : dx;
partially evaluated: isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1540
0-1540
2399 if (dx) {
evaluated: dx
TRUEFALSE
yes
Evaluation Count:1438
yes
Evaluation Count:102
102-1438
2400 if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) {
evaluated: horizontalScrollMode() == QAbstractItemView::ScrollPerItem
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:1334
104-1334
2401 int oldOffset = d->header->offset();
executed (the execution status of this line is deduced): int oldOffset = d->header->offset();
-
2402 if (horizontalScrollBar()->value() == horizontalScrollBar()->maximum())
evaluated: horizontalScrollBar()->value() == horizontalScrollBar()->maximum()
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:52
52
2403 d->header->setOffsetToLastSection();
executed: d->header->setOffsetToLastSection();
Execution Count:52
52
2404 else -
2405 d->header->setOffsetToSectionPosition(horizontalScrollBar()->value());
executed: d->header->setOffsetToSectionPosition(horizontalScrollBar()->value());
Execution Count:52
52
2406 int newOffset = d->header->offset();
executed (the execution status of this line is deduced): int newOffset = d->header->offset();
-
2407 dx = isRightToLeft() ? newOffset - oldOffset : oldOffset - newOffset;
partially evaluated: isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104
0-104
2408 } else {
executed: }
Execution Count:104
104
2409 d->header->setOffset(horizontalScrollBar()->value());
executed (the execution status of this line is deduced): d->header->setOffset(horizontalScrollBar()->value());
-
2410 }
executed: }
Execution Count:1334
1334
2411 } -
2412 -
2413 const int itemHeight = d->defaultItemHeight <= 0 ? sizeHintForRow(0) : d->defaultItemHeight;
evaluated: d->defaultItemHeight <= 0
TRUEFALSE
yes
Evaluation Count:1533
yes
Evaluation Count:7
7-1533
2414 if (d->viewItems.isEmpty() || itemHeight == 0)
evaluated: d->viewItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1539
partially evaluated: itemHeight == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1539
0-1539
2415 return;
executed: return;
Execution Count:1
1
2416 -
2417 // guestimate the number of items in the viewport -
2418 int viewCount = d->viewport->height() / itemHeight;
executed (the execution status of this line is deduced): int viewCount = d->viewport->height() / itemHeight;
-
2419 int maxDeltaY = qMin(d->viewItems.count(), viewCount);
executed (the execution status of this line is deduced): int maxDeltaY = qMin(d->viewItems.count(), viewCount);
-
2420 // no need to do a lot of work if we are going to redraw the whole thing anyway -
2421 if (qAbs(dy) > qAbs(maxDeltaY) && d->editorIndexHash.isEmpty()) {
evaluated: qAbs(dy) > qAbs(maxDeltaY)
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:1484
partially evaluated: d->editorIndexHash.isEmpty()
TRUEFALSE
yes
Evaluation Count:55
no
Evaluation Count:0
0-1484
2422 verticalScrollBar()->update();
executed (the execution status of this line is deduced): verticalScrollBar()->update();
-
2423 d->viewport->update();
executed (the execution status of this line is deduced): d->viewport->update();
-
2424 return;
executed: return;
Execution Count:55
55
2425 } -
2426 -
2427 if (dy && verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
evaluated: dy
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:1438
evaluated: verticalScrollMode() == QAbstractItemView::ScrollPerItem
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:3
3-1438
2428 int currentScrollbarValue = verticalScrollBar()->value();
executed (the execution status of this line is deduced): int currentScrollbarValue = verticalScrollBar()->value();
-
2429 int previousScrollbarValue = currentScrollbarValue + dy; // -(-dy)
executed (the execution status of this line is deduced): int previousScrollbarValue = currentScrollbarValue + dy;
-
2430 int currentViewIndex = currentScrollbarValue; // the first visible item
executed (the execution status of this line is deduced): int currentViewIndex = currentScrollbarValue;
-
2431 int previousViewIndex = previousScrollbarValue;
executed (the execution status of this line is deduced): int previousViewIndex = previousScrollbarValue;
-
2432 const QVector<QTreeViewItem> viewItems = d->viewItems;
executed (the execution status of this line is deduced): const QVector<QTreeViewItem> viewItems = d->viewItems;
-
2433 dy = 0;
executed (the execution status of this line is deduced): dy = 0;
-
2434 if (previousViewIndex < currentViewIndex) { // scrolling down
evaluated: previousViewIndex < currentViewIndex
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:3
3-40
2435 for (int i = previousViewIndex; i < currentViewIndex; ++i) {
evaluated: i < currentViewIndex
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:40
40-49
2436 if (i < d->viewItems.count())
partially evaluated: i < d->viewItems.count()
TRUEFALSE
yes
Evaluation Count:49
no
Evaluation Count:0
0-49
2437 dy -= d->itemHeight(i);
executed: dy -= d->itemHeight(i);
Execution Count:49
49
2438 }
executed: }
Execution Count:49
49
2439 } else if (previousViewIndex > currentViewIndex) { // scrolling up
executed: }
Execution Count:40
partially evaluated: previousViewIndex > currentViewIndex
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-40
2440 for (int i = previousViewIndex - 1; i >= currentViewIndex; --i) {
evaluated: i >= currentViewIndex
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:3
3-12
2441 if (i < d->viewItems.count())
partially evaluated: i < d->viewItems.count()
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
2442 dy += d->itemHeight(i);
executed: dy += d->itemHeight(i);
Execution Count:12
12
2443 }
executed: }
Execution Count:12
12
2444 }
executed: }
Execution Count:3
3
2445 } -
2446 -
2447 d->scrollContentsBy(dx, dy);
executed (the execution status of this line is deduced): d->scrollContentsBy(dx, dy);
-
2448}
executed: }
Execution Count:1484
1484
2449 -
2450/*! -
2451 This slot is called whenever a column has been moved. -
2452*/ -
2453void QTreeView::columnMoved() -
2454{ -
2455 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2456 updateEditorGeometries();
executed (the execution status of this line is deduced): updateEditorGeometries();
-
2457 d->viewport->update();
executed (the execution status of this line is deduced): d->viewport->update();
-
2458}
executed: }
Execution Count:3
3
2459 -
2460/*! -
2461 \internal -
2462*/ -
2463void QTreeView::reexpand() -
2464{ -
2465 // do nothing -
2466} -
2467 -
2468/*! -
2469 Informs the view that the rows from the \a start row to the \a end row -
2470 inclusive have been inserted into the \a parent model item. -
2471*/ -
2472void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) -
2473{ -
2474 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2475 // if we are going to do a complete relayout anyway, there is no need to update -
2476 if (d->delayedPendingLayout) {
evaluated: d->delayedPendingLayout
TRUEFALSE
yes
Evaluation Count:69498
yes
Evaluation Count:399
399-69498
2477 QAbstractItemView::rowsInserted(parent, start, end);
executed (the execution status of this line is deduced): QAbstractItemView::rowsInserted(parent, start, end);
-
2478 return;
executed: return;
Execution Count:69498
69498
2479 } -
2480 -
2481 //don't add a hierarchy on a column != 0 -
2482 if (parent.column() != 0 && parent.isValid()) {
evaluated: parent.column() != 0
TRUEFALSE
yes
Evaluation Count:137
yes
Evaluation Count:262
partially evaluated: parent.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:137
0-262
2483 QAbstractItemView::rowsInserted(parent, start, end);
never executed (the execution status of this line is deduced): QAbstractItemView::rowsInserted(parent, start, end);
-
2484 return;
never executed: return;
0
2485 } -
2486 -
2487 const int parentRowCount = d->model->rowCount(parent);
executed (the execution status of this line is deduced): const int parentRowCount = d->model->rowCount(parent);
-
2488 const int delta = end - start + 1;
executed (the execution status of this line is deduced): const int delta = end - start + 1;
-
2489 if (parent != d->root && !d->isIndexExpanded(parent) && parentRowCount > delta) {
evaluated: parent != d->root
TRUEFALSE
yes
Evaluation Count:257
yes
Evaluation Count:142
evaluated: !d->isIndexExpanded(parent)
TRUEFALSE
yes
Evaluation Count:244
yes
Evaluation Count:13
evaluated: parentRowCount > delta
TRUEFALSE
yes
Evaluation Count:240
yes
Evaluation Count:4
4-257
2490 QAbstractItemView::rowsInserted(parent, start, end);
executed (the execution status of this line is deduced): QAbstractItemView::rowsInserted(parent, start, end);
-
2491 return;
executed: return;
Execution Count:240
240
2492 } -
2493 -
2494 const int parentItem = d->viewIndex(parent);
executed (the execution status of this line is deduced): const int parentItem = d->viewIndex(parent);
-
2495 if (((parentItem != -1) && d->viewItems.at(parentItem).expanded)
evaluated: (parentItem != -1)
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:142
evaluated: d->viewItems.at(parentItem).expanded
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:4
4-142
2496 || (parent == d->root)) {
evaluated: (parent == d->root)
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:4
4-142
2497 d->doDelayedItemsLayout();
executed (the execution status of this line is deduced): d->doDelayedItemsLayout();
-
2498 } else if (parentItem != -1 && (d->model->rowCount(parent) == end - start + 1)) {
executed: }
Execution Count:155
partially evaluated: parentItem != -1
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
partially evaluated: (d->model->rowCount(parent) == end - start + 1)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-155
2499 // the parent just went from 0 children to more. update to re-paint the decoration -
2500 d->viewItems[parentItem].hasChildren = true;
executed (the execution status of this line is deduced): d->viewItems[parentItem].hasChildren = true;
-
2501 viewport()->update();
executed (the execution status of this line is deduced): viewport()->update();
-
2502 }
executed: }
Execution Count:4
4
2503 QAbstractItemView::rowsInserted(parent, start, end);
executed (the execution status of this line is deduced): QAbstractItemView::rowsInserted(parent, start, end);
-
2504}
executed: }
Execution Count:159
159
2505 -
2506/*! -
2507 Informs the view that the rows from the \a start row to the \a end row -
2508 inclusive are about to removed from the given \a parent model item. -
2509*/ -
2510void QTreeView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) -
2511{ -
2512 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2513 QAbstractItemView::rowsAboutToBeRemoved(parent, start, end);
executed (the execution status of this line is deduced): QAbstractItemView::rowsAboutToBeRemoved(parent, start, end);
-
2514 d->viewItems.clear();
executed (the execution status of this line is deduced): d->viewItems.clear();
-
2515}
executed: }
Execution Count:1290
1290
2516 -
2517/*! -
2518 \since 4.1 -
2519 -
2520 Informs the view that the rows from the \a start row to the \a end row -
2521 inclusive have been removed from the given \a parent model item. -
2522*/ -
2523void QTreeView::rowsRemoved(const QModelIndex &parent, int start, int end) -
2524{ -
2525 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2526 d->viewItems.clear();
executed (the execution status of this line is deduced): d->viewItems.clear();
-
2527 d->doDelayedItemsLayout();
executed (the execution status of this line is deduced): d->doDelayedItemsLayout();
-
2528 d->hasRemovedItems = true;
executed (the execution status of this line is deduced): d->hasRemovedItems = true;
-
2529 d->_q_rowsRemoved(parent, start, end);
executed (the execution status of this line is deduced): d->_q_rowsRemoved(parent, start, end);
-
2530}
executed: }
Execution Count:1288
1288
2531 -
2532/*! -
2533 Informs the tree view that the number of columns in the tree view has -
2534 changed from \a oldCount to \a newCount. -
2535*/ -
2536void QTreeView::columnCountChanged(int oldCount, int newCount) -
2537{ -
2538 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2539 if (oldCount == 0 && newCount > 0) {
evaluated: oldCount == 0
TRUEFALSE
yes
Evaluation Count:812
yes
Evaluation Count:87
evaluated: newCount > 0
TRUEFALSE
yes
Evaluation Count:626
yes
Evaluation Count:186
87-812
2540 //if the first column has just been added we need to relayout. -
2541 d->doDelayedItemsLayout();
executed (the execution status of this line is deduced): d->doDelayedItemsLayout();
-
2542 }
executed: }
Execution Count:626
626
2543 -
2544 if (isVisible())
evaluated: isVisible()
TRUEFALSE
yes
Evaluation Count:136
yes
Evaluation Count:763
136-763
2545 updateGeometries();
executed: updateGeometries();
Execution Count:136
136
2546 viewport()->update();
executed (the execution status of this line is deduced): viewport()->update();
-
2547}
executed: }
Execution Count:899
899
2548 -
2549/*! -
2550 Resizes the \a column given to the size of its contents. -
2551 -
2552 \sa columnWidth(), setColumnWidth() -
2553*/ -
2554void QTreeView::resizeColumnToContents(int column) -
2555{ -
2556 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2557 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
2558 if (column < 0 || column >= d->header->count())
partially evaluated: column < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: column >= d->header->count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2559 return;
never executed: return;
0
2560 int contents = sizeHintForColumn(column);
executed (the execution status of this line is deduced): int contents = sizeHintForColumn(column);
-
2561 int header = d->header->isHidden() ? 0 : d->header->sectionSizeHint(column);
partially evaluated: d->header->isHidden()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2562 d->header->resizeSection(column, qMax(contents, header));
executed (the execution status of this line is deduced): d->header->resizeSection(column, qMax(contents, header));
-
2563}
executed: }
Execution Count:2
2
2564 -
2565/*! -
2566 \obsolete -
2567 \overload -
2568 -
2569 Sorts the model by the values in the given \a column. -
2570*/ -
2571void QTreeView::sortByColumn(int column) -
2572{ -
2573 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2574 sortByColumn(column, d->header->sortIndicatorOrder());
executed (the execution status of this line is deduced): sortByColumn(column, d->header->sortIndicatorOrder());
-
2575}
executed: }
Execution Count:4
4
2576 -
2577/*! -
2578 \since 4.2 -
2579 -
2580 Sets the model up for sorting by the values in the given \a column and \a order. -
2581 -
2582 \a column may be -1, in which case no sort indicator will be shown -
2583 and the model will return to its natural, unsorted order. Note that not -
2584 all models support this and may even crash in this case. -
2585 -
2586 \sa sortingEnabled -
2587*/ -
2588void QTreeView::sortByColumn(int column, Qt::SortOrder order) -
2589{ -
2590 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2591 -
2592 //If sorting is enabled will emit a signal connected to _q_sortIndicatorChanged, which then actually sorts -
2593 d->header->setSortIndicator(column, order);
executed (the execution status of this line is deduced): d->header->setSortIndicator(column, order);
-
2594 //If sorting is not enabled, force to sort now. -
2595 if (!d->sortingEnabled)
evaluated: !d->sortingEnabled
TRUEFALSE
yes
Evaluation Count:291
yes
Evaluation Count:4
4-291
2596 d->model->sort(column, order);
executed: d->model->sort(column, order);
Execution Count:291
291
2597}
executed: }
Execution Count:295
295
2598 -
2599/*! -
2600 \reimp -
2601*/ -
2602void QTreeView::selectAll() -
2603{ -
2604 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2605 if (!selectionModel())
evaluated: !selectionModel()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:9
5-9
2606 return;
executed: return;
Execution Count:5
5
2607 SelectionMode mode = d->selectionMode;
executed (the execution status of this line is deduced): SelectionMode mode = d->selectionMode;
-
2608 d->executePostedLayout(); //make sure we lay out the items
executed (the execution status of this line is deduced): d->executePostedLayout();
-
2609 if (mode != SingleSelection && mode != NoSelection && !d->viewItems.isEmpty()) {
evaluated: mode != SingleSelection
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1
evaluated: mode != NoSelection
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
partially evaluated: !d->viewItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-8
2610 const QModelIndex &idx = d->viewItems.last().index;
executed (the execution status of this line is deduced): const QModelIndex &idx = d->viewItems.last().index;
-
2611 QModelIndex lastItemIndex = idx.sibling(idx.row(), d->model->columnCount(idx.parent()) - 1);
executed (the execution status of this line is deduced): QModelIndex lastItemIndex = idx.sibling(idx.row(), d->model->columnCount(idx.parent()) - 1);
-
2612 d->select(d->viewItems.first().index, lastItemIndex,
executed (the execution status of this line is deduced): d->select(d->viewItems.first().index, lastItemIndex,
-
2613 QItemSelectionModel::ClearAndSelect
executed (the execution status of this line is deduced): QItemSelectionModel::ClearAndSelect
-
2614 |QItemSelectionModel::Rows);
executed (the execution status of this line is deduced): |QItemSelectionModel::Rows);
-
2615 }
executed: }
Execution Count:6
6
2616}
executed: }
Execution Count:9
9
2617 -
2618/*! -
2619 \since 4.2 -
2620 Expands all expandable items. -
2621 -
2622 Warning: if the model contains a large number of items, -
2623 this function will take some time to execute. -
2624 -
2625 \sa collapseAll(), expand(), collapse(), setExpanded() -
2626*/ -
2627void QTreeView::expandAll() -
2628{ -
2629 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2630 d->viewItems.clear();
executed (the execution status of this line is deduced): d->viewItems.clear();
-
2631 d->interruptDelayedItemsLayout();
executed (the execution status of this line is deduced): d->interruptDelayedItemsLayout();
-
2632 d->layout(-1, true);
executed (the execution status of this line is deduced): d->layout(-1, true);
-
2633 updateGeometries();
executed (the execution status of this line is deduced): updateGeometries();
-
2634 d->viewport->update();
executed (the execution status of this line is deduced): d->viewport->update();
-
2635}
executed: }
Execution Count:17
17
2636 -
2637/*! -
2638 \since 4.2 -
2639 -
2640 Collapses all expanded items. -
2641 -
2642 \sa expandAll(), expand(), collapse(), setExpanded() -
2643*/ -
2644void QTreeView::collapseAll() -
2645{ -
2646 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2647 d->expandedIndexes.clear();
executed (the execution status of this line is deduced): d->expandedIndexes.clear();
-
2648 doItemsLayout();
executed (the execution status of this line is deduced): doItemsLayout();
-
2649}
executed: }
Execution Count:1
1
2650 -
2651/*! -
2652 \since 4.3 -
2653 Expands all expandable items to the given \a depth. -
2654 -
2655 \sa expandAll(), collapseAll(), expand(), collapse(), setExpanded() -
2656*/ -
2657void QTreeView::expandToDepth(int depth) -
2658{ -
2659 Q_D(QTreeView);
never executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2660 d->viewItems.clear();
never executed (the execution status of this line is deduced): d->viewItems.clear();
-
2661 d->expandedIndexes.clear();
never executed (the execution status of this line is deduced): d->expandedIndexes.clear();
-
2662 d->interruptDelayedItemsLayout();
never executed (the execution status of this line is deduced): d->interruptDelayedItemsLayout();
-
2663 d->layout(-1);
never executed (the execution status of this line is deduced): d->layout(-1);
-
2664 for (int i = 0; i < d->viewItems.count(); ++i) {
never evaluated: i < d->viewItems.count()
0
2665 if (d->viewItems.at(i).level <= (uint)depth) {
never evaluated: d->viewItems.at(i).level <= (uint)depth
0
2666 d->viewItems[i].expanded = true;
never executed (the execution status of this line is deduced): d->viewItems[i].expanded = true;
-
2667 d->layout(i);
never executed (the execution status of this line is deduced): d->layout(i);
-
2668 d->storeExpanded(d->viewItems.at(i).index);
never executed (the execution status of this line is deduced): d->storeExpanded(d->viewItems.at(i).index);
-
2669 }
never executed: }
0
2670 }
never executed: }
0
2671 updateGeometries();
never executed (the execution status of this line is deduced): updateGeometries();
-
2672 d->viewport->update();
never executed (the execution status of this line is deduced): d->viewport->update();
-
2673}
never executed: }
0
2674 -
2675/*! -
2676 This function is called whenever \a{column}'s size is changed in -
2677 the header. \a oldSize and \a newSize give the previous size and -
2678 the new size in pixels. -
2679 -
2680 \sa setColumnWidth() -
2681*/ -
2682void QTreeView::columnResized(int column, int /* oldSize */, int /* newSize */) -
2683{ -
2684 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2685 d->columnsToUpdate.append(column);
executed (the execution status of this line is deduced): d->columnsToUpdate.append(column);
-
2686 if (d->columnResizeTimerID == 0)
evaluated: d->columnResizeTimerID == 0
TRUEFALSE
yes
Evaluation Count:345
yes
Evaluation Count:631
345-631
2687 d->columnResizeTimerID = startTimer(0);
executed: d->columnResizeTimerID = startTimer(0);
Execution Count:345
345
2688}
executed: }
Execution Count:976
976
2689 -
2690/*! -
2691 \reimp -
2692*/ -
2693void QTreeView::updateGeometries() -
2694{ -
2695 Q_D(QTreeView);
executed (the execution status of this line is deduced): QTreeViewPrivate * const d = d_func();
-
2696 if (d->header) {
evaluated: d->header
TRUEFALSE
yes
Evaluation Count:1674
yes
Evaluation Count:670
670-1674
2697 if (d->geometryRecursionBlock)
evaluated: d->geometryRecursionBlock
TRUEFALSE
yes
Evaluation Count:632
yes
Evaluation Count:1042
632-1042
2698 return;
executed: return;
Execution Count:632
632
2699 d->geometryRecursionBlock = true;
executed (the execution status of this line is deduced): d->geometryRecursionBlock = true;
-
2700 QSize hint = d->header->isHidden() ? QSize(0, 0) : d->header->sizeHint();
partially evaluated: d->header->isHidden()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1042
0-1042
2701 setViewportMargins(0, hint.height(), 0, 0);
executed (the execution status of this line is deduced): setViewportMargins(0, hint.height(), 0, 0);
-
2702 QRect vg = d->viewport->geometry();
executed (the execution status of this line is deduced): QRect vg = d->viewport->geometry();
-
2703 QRect geometryRect(vg.left(), vg.top() - hint.height(), vg.width(), hint.height());
executed (the execution status of this line is deduced): QRect geometryRect(vg.left(), vg.top() - hint.height(), vg.width(), hint.height());
-
2704 d->header->setGeometry(geometryRect);
executed (the execution status of this line is deduced): d->header->setGeometry(geometryRect);
-
2705 //d->header->setOffset(horizontalScrollBar()->value()); // ### bug ??? -
2706 QMetaObject::invokeMethod(d->header, "updateGeometries");
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(d->header, "updateGeometries");
-
2707 d->updateScrollBars();
executed (the execution status of this line is deduced): d->updateScrollBars();
-
2708 d->geometryRecursionBlock = false;
executed (the execution status of this line is deduced): d->geometryRecursionBlock = false;
-
2709 }
executed: }
Execution Count:1042
1042
2710 QAbstractItemView::updateGeometries();
executed (the execution status of this line is deduced): QAbstractItemView::updateGeometries();
-
2711}
executed: }
Execution Count:1712
1712
2712 -
2713/*! -
2714 Returns the size hint for the \a column's width or -1 if there is no -
2715 model. -
2716 -
2717 If you need to set the width of a given column to a fixed value, call -
2718 QHeaderView::resizeSection() on the view's header. -
2719 -
2720 If you reimplement this function in a subclass, note that the value you -
2721 return is only used when resizeColumnToContents() is called. In that case, -
2722 if a larger column width is required by either the view's header or -
2723 the item delegate, that width will be used instead. -
2724 -
2725 \sa QWidget::sizeHint, header() -
2726*/ -
2727int QTreeView::sizeHintForColumn(int column) const -
2728{ -
2729 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
2730 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
2731 if (d->viewItems.isEmpty())
evaluated: d->viewItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:38
5-38
2732 return -1;
executed: return -1;
Execution Count:5
5
2733 ensurePolished();
executed (the execution status of this line is deduced): ensurePolished();
-
2734 int w = 0;
executed (the execution status of this line is deduced): int w = 0;
-
2735 QStyleOptionViewItem option = d->viewOptions();
executed (the execution status of this line is deduced): QStyleOptionViewItem option = d->viewOptions();
-
2736 const QVector<QTreeViewItem> viewItems = d->viewItems;
executed (the execution status of this line is deduced): const QVector<QTreeViewItem> viewItems = d->viewItems;
-
2737 -
2738 int start = 0;
executed (the execution status of this line is deduced): int start = 0;
-
2739 int end = viewItems.count();
executed (the execution status of this line is deduced): int end = viewItems.count();
-
2740 if(end > 1000) { //if we have too many item this function would be too slow.
evaluated: end > 1000
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:32
6-32
2741 //we get a good approximation by only iterate over 1000 items. -
2742 start = qMax(0, d->firstVisibleItem() - 100);
executed (the execution status of this line is deduced): start = qMax(0, d->firstVisibleItem() - 100);
-
2743 end = qMin(end, start + 900);
executed (the execution status of this line is deduced): end = qMin(end, start + 900);
-
2744 }
executed: }
Execution Count:6
6
2745 -
2746 for (int i = start; i < end; ++i) {
evaluated: i < end
TRUEFALSE
yes
Evaluation Count:6576
yes
Evaluation Count:38
38-6576
2747 if (viewItems.at(i).spanning)
evaluated: viewItems.at(i).spanning
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:6571
5-6571
2748 continue; // we have no good size hint
executed: continue;
Execution Count:5
5
2749 QModelIndex index = viewItems.at(i).index;
executed (the execution status of this line is deduced): QModelIndex index = viewItems.at(i).index;
-
2750 index = index.sibling(index.row(), column);
executed (the execution status of this line is deduced): index = index.sibling(index.row(), column);
-
2751 QWidget *editor = d->editorForIndex(index).widget.data();
executed (the execution status of this line is deduced): QWidget *editor = d->editorForIndex(index).widget.data();
-
2752 if (editor && d->persistent.contains(editor)) {
partially evaluated: editor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6571
never evaluated: d->persistent.contains(editor)
0-6571
2753 w = qMax(w, editor->sizeHint().width());
never executed (the execution status of this line is deduced): w = qMax(w, editor->sizeHint().width());
-
2754 int min = editor->minimumSize().width();
never executed (the execution status of this line is deduced): int min = editor->minimumSize().width();
-
2755 int max = editor->maximumSize().width();
never executed (the execution status of this line is deduced): int max = editor->maximumSize().width();
-
2756 w = qBound(min, w, max);
never executed (the execution status of this line is deduced): w = qBound(min, w, max);
-
2757 }
never executed: }
0
2758 int hint = d->delegateForIndex(index)->sizeHint(option, index).width();
executed (the execution status of this line is deduced): int hint = d->delegateForIndex(index)->sizeHint(option, index).width();
-
2759 w = qMax(w, hint + (column == 0 ? d->indentationForItem(i) : 0));
executed (the execution status of this line is deduced): w = qMax(w, hint + (column == 0 ? d->indentationForItem(i) : 0));
-
2760 }
executed: }
Execution Count:6571
6571
2761 return w;
executed: return w;
Execution Count:38
38
2762} -
2763 -
2764/*! -
2765 Returns the size hint for the row indicated by \a index. -
2766 -
2767 \sa sizeHintForColumn(), uniformRowHeights() -
2768*/ -
2769int QTreeView::indexRowSizeHint(const QModelIndex &index) const -
2770{ -
2771 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
2772 if (!d->isIndexValid(index) || !d->itemDelegate)
partially evaluated: !d->isIndexValid(index)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2777
partially evaluated: !d->itemDelegate
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2777
0-2777
2773 return 0;
never executed: return 0;
0
2774 -
2775 int start = -1;
executed (the execution status of this line is deduced): int start = -1;
-
2776 int end = -1;
executed (the execution status of this line is deduced): int end = -1;
-
2777 int indexRow = index.row();
executed (the execution status of this line is deduced): int indexRow = index.row();
-
2778 int count = d->header->count();
executed (the execution status of this line is deduced): int count = d->header->count();
-
2779 bool emptyHeader = (count == 0);
executed (the execution status of this line is deduced): bool emptyHeader = (count == 0);
-
2780 QModelIndex parent = index.parent();
executed (the execution status of this line is deduced): QModelIndex parent = index.parent();
-
2781 -
2782 if (count && isVisible()) {
evaluated: count
TRUEFALSE
yes
Evaluation Count:2773
yes
Evaluation Count:4
evaluated: isVisible()
TRUEFALSE
yes
Evaluation Count:2436
yes
Evaluation Count:337
4-2773
2783 // If the sections have moved, we end up checking too many or too few -
2784 start = d->header->visualIndexAt(0);
executed (the execution status of this line is deduced): start = d->header->visualIndexAt(0);
-
2785 } else {
executed: }
Execution Count:2436
2436
2786 // If the header has not been laid out yet, we use the model directly -
2787 count = d->model->columnCount(parent);
executed (the execution status of this line is deduced): count = d->model->columnCount(parent);
-
2788 }
executed: }
Execution Count:341
341
2789 -
2790 if (isRightToLeft()) {
evaluated: isRightToLeft()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2774
3-2774
2791 start = (start == -1 ? count - 1 : start);
partially evaluated: start == -1
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2792 end = 0;
executed (the execution status of this line is deduced): end = 0;
-
2793 } else {
executed: }
Execution Count:3
3
2794 start = (start == -1 ? 0 : start);
evaluated: start == -1
TRUEFALSE
yes
Evaluation Count:341
yes
Evaluation Count:2433
341-2433
2795 end = count - 1;
executed (the execution status of this line is deduced): end = count - 1;
-
2796 }
executed: }
Execution Count:2774
2774
2797 -
2798 if (end < start)
partially evaluated: end < start
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2777
0-2777
2799 qSwap(end, start);
never executed: qSwap(end, start);
0
2800 -
2801 int height = -1;
executed (the execution status of this line is deduced): int height = -1;
-
2802 QStyleOptionViewItem option = d->viewOptions();
executed (the execution status of this line is deduced): QStyleOptionViewItem option = d->viewOptions();
-
2803 // ### If we want word wrapping in the items, -
2804 // ### we need to go through all the columns -
2805 // ### and set the width of the column -
2806 -
2807 // Hack to speed up the function -
2808 option.rect.setWidth(-1);
executed (the execution status of this line is deduced): option.rect.setWidth(-1);
-
2809 -
2810 for (int column = start; column <= end; ++column) {
evaluated: column <= end
TRUEFALSE
yes
Evaluation Count:14891
yes
Evaluation Count:2777
2777-14891
2811 int logicalColumn = emptyHeader ? column : d->header->logicalIndex(column);
evaluated: emptyHeader
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:14835
56-14835
2812 if (d->header->isSectionHidden(logicalColumn))
evaluated: d->header->isSectionHidden(logicalColumn)
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:14860
31-14860
2813 continue;
executed: continue;
Execution Count:31
31
2814 QModelIndex idx = d->model->index(indexRow, logicalColumn, parent);
executed (the execution status of this line is deduced): QModelIndex idx = d->model->index(indexRow, logicalColumn, parent);
-
2815 if (idx.isValid()) {
partially evaluated: idx.isValid()
TRUEFALSE
yes
Evaluation Count:14860
no
Evaluation Count:0
0-14860
2816 QWidget *editor = d->editorForIndex(idx).widget.data();
executed (the execution status of this line is deduced): QWidget *editor = d->editorForIndex(idx).widget.data();
-
2817 if (editor && d->persistent.contains(editor)) {
evaluated: editor
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:14818
evaluated: d->persistent.contains(editor)
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:14
14-14818
2818 height = qMax(height, editor->sizeHint().height());
executed (the execution status of this line is deduced): height = qMax(height, editor->sizeHint().height());
-
2819 int min = editor->minimumSize().height();
executed (the execution status of this line is deduced): int min = editor->minimumSize().height();
-
2820 int max = editor->maximumSize().height();
executed (the execution status of this line is deduced): int max = editor->maximumSize().height();
-
2821 height = qBound(min, height, max);
executed (the execution status of this line is deduced): height = qBound(min, height, max);
-
2822 }
executed: }
Execution Count:28
28
2823 int hint = d->delegateForIndex(idx)->sizeHint(option, idx).height();
executed (the execution status of this line is deduced): int hint = d->delegateForIndex(idx)->sizeHint(option, idx).height();
-
2824 height = qMax(height, hint);
executed (the execution status of this line is deduced): height = qMax(height, hint);
-
2825 }
executed: }
Execution Count:14860
14860
2826 }
executed: }
Execution Count:14860
14860
2827 -
2828 return height;
executed: return height;
Execution Count:2777
2777
2829} -
2830 -
2831/*! -
2832 \since 4.3 -
2833 Returns the height of the row indicated by the given \a index. -
2834 \sa indexRowSizeHint() -
2835*/ -
2836int QTreeView::rowHeight(const QModelIndex &index) const -
2837{ -
2838 Q_D(const QTreeView);
never executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
2839 d->executePostedLayout();
never executed (the execution status of this line is deduced): d->executePostedLayout();
-
2840 int i = d->viewIndex(index);
never executed (the execution status of this line is deduced): int i = d->viewIndex(index);
-
2841 if (i == -1)
never evaluated: i == -1
0
2842 return 0;
never executed: return 0;
0
2843 return d->itemHeight(i);
never executed: return d->itemHeight(i);
0
2844} -
2845 -
2846/*! -
2847 \internal -
2848*/ -
2849void QTreeView::horizontalScrollbarAction(int action) -
2850{ -
2851 QAbstractItemView::horizontalScrollbarAction(action);
executed (the execution status of this line is deduced): QAbstractItemView::horizontalScrollbarAction(action);
-
2852}
executed: }
Execution Count:2
2
2853 -
2854/*! -
2855 \reimp -
2856*/ -
2857bool QTreeView::isIndexHidden(const QModelIndex &index) const -
2858{ -
2859 return (isColumnHidden(index.column()) || isRowHidden(index.row(), index.parent()));
executed: return (isColumnHidden(index.column()) || isRowHidden(index.row(), index.parent()));
Execution Count:18580
18580
2860} -
2861 -
2862/* -
2863 private implementation -
2864*/ -
2865void QTreeViewPrivate::initialize() -
2866{ -
2867 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
2868 updateStyledFrameWidths();
executed (the execution status of this line is deduced): updateStyledFrameWidths();
-
2869 q->setSelectionBehavior(QAbstractItemView::SelectRows);
executed (the execution status of this line is deduced): q->setSelectionBehavior(QAbstractItemView::SelectRows);
-
2870 q->setSelectionMode(QAbstractItemView::SingleSelection);
executed (the execution status of this line is deduced): q->setSelectionMode(QAbstractItemView::SingleSelection);
-
2871 q->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
executed (the execution status of this line is deduced): q->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
-
2872 q->setAttribute(Qt::WA_MacShowFocusRect);
executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_MacShowFocusRect);
-
2873 -
2874 QHeaderView *header = new QHeaderView(Qt::Horizontal, q);
executed (the execution status of this line is deduced): QHeaderView *header = new QHeaderView(Qt::Horizontal, q);
-
2875 header->setSectionsMovable(true);
executed (the execution status of this line is deduced): header->setSectionsMovable(true);
-
2876 header->setStretchLastSection(true);
executed (the execution status of this line is deduced): header->setStretchLastSection(true);
-
2877 header->setDefaultAlignment(Qt::AlignLeft|Qt::AlignVCenter);
executed (the execution status of this line is deduced): header->setDefaultAlignment(Qt::AlignLeft|Qt::AlignVCenter);
-
2878 q->setHeader(header);
executed (the execution status of this line is deduced): q->setHeader(header);
-
2879#ifndef QT_NO_ANIMATION -
2880 QObject::connect(&animatedOperation, SIGNAL(finished()), q, SLOT(_q_endAnimatedOperation()));
executed (the execution status of this line is deduced): QObject::connect(&animatedOperation, "2""finished()", q, "1""_q_endAnimatedOperation()");
-
2881#endif //QT_NO_ANIMATION -
2882}
executed: }
Execution Count:670
670
2883 -
2884void QTreeViewPrivate::expand(int item, bool emitSignal) -
2885{ -
2886 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
2887 -
2888 if (item == -1 || viewItems.at(item).expanded)
partially evaluated: item == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:63
evaluated: viewItems.at(item).expanded
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:53
0-63
2889 return;
executed: return;
Execution Count:10
10
2890 -
2891#ifndef QT_NO_ANIMATION -
2892 if (emitSignal && animationsEnabled)
partially evaluated: emitSignal
TRUEFALSE
yes
Evaluation Count:53
no
Evaluation Count:0
evaluated: animationsEnabled
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:41
0-53
2893 prepareAnimatedOperation(item, QVariantAnimation::Forward);
executed: prepareAnimatedOperation(item, QVariantAnimation::Forward);
Execution Count:12
12
2894#endif //QT_NO_ANIMATION -
2895 //if already animating, stateBeforeAnimation is set to the correct value -
2896 if (state != QAbstractItemView::AnimatingState)
evaluated: state != QAbstractItemView::AnimatingState
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:8
8-45
2897 stateBeforeAnimation = state;
executed: stateBeforeAnimation = state;
Execution Count:45
45
2898 q->setState(QAbstractItemView::ExpandingState);
executed (the execution status of this line is deduced): q->setState(QAbstractItemView::ExpandingState);
-
2899 const QModelIndex index = viewItems.at(item).index;
executed (the execution status of this line is deduced): const QModelIndex index = viewItems.at(item).index;
-
2900 storeExpanded(index);
executed (the execution status of this line is deduced): storeExpanded(index);
-
2901 viewItems[item].expanded = true;
executed (the execution status of this line is deduced): viewItems[item].expanded = true;
-
2902 layout(item);
executed (the execution status of this line is deduced): layout(item);
-
2903 q->setState(stateBeforeAnimation);
executed (the execution status of this line is deduced): q->setState(stateBeforeAnimation);
-
2904 -
2905 if (model->canFetchMore(index))
partially evaluated: model->canFetchMore(index)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:53
0-53
2906 model->fetchMore(index);
never executed: model->fetchMore(index);
0
2907 if (emitSignal) {
partially evaluated: emitSignal
TRUEFALSE
yes
Evaluation Count:53
no
Evaluation Count:0
0-53
2908 emit q->expanded(index);
executed (the execution status of this line is deduced): q->expanded(index);
-
2909#ifndef QT_NO_ANIMATION -
2910 if (animationsEnabled)
evaluated: animationsEnabled
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:41
12-41
2911 beginAnimatedOperation();
executed: beginAnimatedOperation();
Execution Count:12
12
2912#endif //QT_NO_ANIMATION -
2913 }
executed: }
Execution Count:53
53
2914}
executed: }
Execution Count:53
53
2915 -
2916void QTreeViewPrivate::insertViewItems(int pos, int count, const QTreeViewItem &viewItem) -
2917{ -
2918 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
2919 Q_UNUSED(q)
executed (the execution status of this line is deduced): (void)q;
-
2920 viewItems.insert(pos, count, viewItem);
executed (the execution status of this line is deduced): viewItems.insert(pos, count, viewItem);
-
2921 QTreeViewItem *items = viewItems.data();
executed (the execution status of this line is deduced): QTreeViewItem *items = viewItems.data();
-
2922 for (int i = pos + count; i < viewItems.count(); i++)
evaluated: i < viewItems.count()
TRUEFALSE
yes
Evaluation Count:469
yes
Evaluation Count:55
55-469
2923 if (items[i].parentItem >= pos)
evaluated: items[i].parentItem >= pos
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:461
8-461
2924 items[i].parentItem += count;
executed: items[i].parentItem += count;
Execution Count:8
8
2925}
executed: }
Execution Count:55
55
2926 -
2927void QTreeViewPrivate::removeViewItems(int pos, int count) -
2928{ -
2929 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
2930 Q_UNUSED(q)
executed (the execution status of this line is deduced): (void)q;
-
2931 viewItems.remove(pos, count);
executed (the execution status of this line is deduced): viewItems.remove(pos, count);
-
2932 QTreeViewItem *items = viewItems.data();
executed (the execution status of this line is deduced): QTreeViewItem *items = viewItems.data();
-
2933 for (int i = pos; i < viewItems.count(); i++)
evaluated: i < viewItems.count()
TRUEFALSE
yes
Evaluation Count:244
yes
Evaluation Count:26
26-244
2934 if (items[i].parentItem >= pos)
evaluated: items[i].parentItem >= pos
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:238
6-238
2935 items[i].parentItem -= count;
executed: items[i].parentItem -= count;
Execution Count:6
6
2936}
executed: }
Execution Count:26
26
2937 -
2938#if 0 -
2939bool QTreeViewPrivate::checkViewItems() const -
2940{ -
2941 for (int i = 0; i < viewItems.count(); ++i) { -
2942 const QTreeViewItem &vi = viewItems.at(i); -
2943 if (vi.parentItem == -1) { -
2944 Q_ASSERT(!vi.index.parent().isValid() || vi.index.parent() == root); -
2945 } else { -
2946 Q_ASSERT(vi.index.parent() == viewItems.at(vi.parentItem).index); -
2947 } -
2948 } -
2949 return true; -
2950} -
2951#endif -
2952 -
2953void QTreeViewPrivate::collapse(int item, bool emitSignal) -
2954{ -
2955 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
2956 -
2957 if (item == -1 || expandedIndexes.isEmpty())
partially evaluated: item == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:56
evaluated: expandedIndexes.isEmpty()
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:30
0-56
2958 return;
executed: return;
Execution Count:26
26
2959 -
2960 //if the current item is now invisible, the autoscroll will expand the tree to see it, so disable the autoscroll -
2961 delayedAutoScroll.stop();
executed (the execution status of this line is deduced): delayedAutoScroll.stop();
-
2962 -
2963 int total = viewItems.at(item).total;
executed (the execution status of this line is deduced): int total = viewItems.at(item).total;
-
2964 const QModelIndex &modelIndex = viewItems.at(item).index;
executed (the execution status of this line is deduced): const QModelIndex &modelIndex = viewItems.at(item).index;
-
2965 if (!isPersistent(modelIndex))
evaluated: !isPersistent(modelIndex)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:26
4-26
2966 return; // if the index is not persistent, no chances it is expanded
executed: return;
Execution Count:4
4
2967 QSet<QPersistentModelIndex>::iterator it = expandedIndexes.find(modelIndex);
executed (the execution status of this line is deduced): QSet<QPersistentModelIndex>::iterator it = expandedIndexes.find(modelIndex);
-
2968 if (it == expandedIndexes.end() || viewItems.at(item).expanded == false)
partially evaluated: it == expandedIndexes.end()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
partially evaluated: viewItems.at(item).expanded == false
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
2969 return; // nothing to do
never executed: return;
0
2970 -
2971#ifndef QT_NO_ANIMATION -
2972 if (emitSignal && animationsEnabled)
partially evaluated: emitSignal
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
evaluated: animationsEnabled
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:19
0-26
2973 prepareAnimatedOperation(item, QVariantAnimation::Backward);
executed: prepareAnimatedOperation(item, QVariantAnimation::Backward);
Execution Count:7
7
2974#endif //QT_NO_ANIMATION -
2975 -
2976 //if already animating, stateBeforeAnimation is set to the correct value -
2977 if (state != QAbstractItemView::AnimatingState)
evaluated: state != QAbstractItemView::AnimatingState
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:7
7-19
2978 stateBeforeAnimation = state;
executed: stateBeforeAnimation = state;
Execution Count:19
19
2979 q->setState(QAbstractItemView::CollapsingState);
executed (the execution status of this line is deduced): q->setState(QAbstractItemView::CollapsingState);
-
2980 expandedIndexes.erase(it);
executed (the execution status of this line is deduced): expandedIndexes.erase(it);
-
2981 viewItems[item].expanded = false;
executed (the execution status of this line is deduced): viewItems[item].expanded = false;
-
2982 int index = item;
executed (the execution status of this line is deduced): int index = item;
-
2983 while (index > -1) {
evaluated: index > -1
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:26
26-38
2984 viewItems[index].total -= total;
executed (the execution status of this line is deduced): viewItems[index].total -= total;
-
2985 index = viewItems[index].parentItem;
executed (the execution status of this line is deduced): index = viewItems[index].parentItem;
-
2986 }
executed: }
Execution Count:38
38
2987 removeViewItems(item + 1, total); // collapse
executed (the execution status of this line is deduced): removeViewItems(item + 1, total);
-
2988 q->setState(stateBeforeAnimation);
executed (the execution status of this line is deduced): q->setState(stateBeforeAnimation);
-
2989 -
2990 if (emitSignal) {
partially evaluated: emitSignal
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-26
2991 emit q->collapsed(modelIndex);
executed (the execution status of this line is deduced): q->collapsed(modelIndex);
-
2992#ifndef QT_NO_ANIMATION -
2993 if (animationsEnabled)
evaluated: animationsEnabled
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:19
7-19
2994 beginAnimatedOperation();
executed: beginAnimatedOperation();
Execution Count:7
7
2995#endif //QT_NO_ANIMATION -
2996 }
executed: }
Execution Count:26
26
2997}
executed: }
Execution Count:26
26
2998 -
2999#ifndef QT_NO_ANIMATION -
3000void QTreeViewPrivate::prepareAnimatedOperation(int item, QVariantAnimation::Direction direction) -
3001{ -
3002 animatedOperation.item = item;
executed (the execution status of this line is deduced): animatedOperation.item = item;
-
3003 animatedOperation.viewport = viewport;
executed (the execution status of this line is deduced): animatedOperation.viewport = viewport;
-
3004 animatedOperation.setDirection(direction);
executed (the execution status of this line is deduced): animatedOperation.setDirection(direction);
-
3005 -
3006 int top = coordinateForItem(item) + itemHeight(item);
executed (the execution status of this line is deduced): int top = coordinateForItem(item) + itemHeight(item);
-
3007 QRect rect = viewport->rect();
executed (the execution status of this line is deduced): QRect rect = viewport->rect();
-
3008 rect.setTop(top);
executed (the execution status of this line is deduced): rect.setTop(top);
-
3009 if (direction == QVariantAnimation::Backward) {
evaluated: direction == QVariantAnimation::Backward
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:12
7-12
3010 const int limit = rect.height() * 2;
executed (the execution status of this line is deduced): const int limit = rect.height() * 2;
-
3011 int h = 0;
executed (the execution status of this line is deduced): int h = 0;
-
3012 int c = item + viewItems.at(item).total + 1;
executed (the execution status of this line is deduced): int c = item + viewItems.at(item).total + 1;
-
3013 for (int i = item + 1; i < c && h < limit; ++i)
evaluated: i < c
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:6
evaluated: h < limit
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:1
1-70
3014 h += itemHeight(i);
executed: h += itemHeight(i);
Execution Count:69
69
3015 rect.setHeight(h);
executed (the execution status of this line is deduced): rect.setHeight(h);
-
3016 animatedOperation.setEndValue(top + h);
executed (the execution status of this line is deduced): animatedOperation.setEndValue(top + h);
-
3017 }
executed: }
Execution Count:7
7
3018 animatedOperation.setStartValue(top);
executed (the execution status of this line is deduced): animatedOperation.setStartValue(top);
-
3019 animatedOperation.before = renderTreeToPixmapForAnimation(rect);
executed (the execution status of this line is deduced): animatedOperation.before = renderTreeToPixmapForAnimation(rect);
-
3020}
executed: }
Execution Count:19
19
3021 -
3022void QTreeViewPrivate::beginAnimatedOperation() -
3023{ -
3024 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
3025 -
3026 QRect rect = viewport->rect();
executed (the execution status of this line is deduced): QRect rect = viewport->rect();
-
3027 rect.setTop(animatedOperation.top());
executed (the execution status of this line is deduced): rect.setTop(animatedOperation.top());
-
3028 if (animatedOperation.direction() == QVariantAnimation::Forward) {
evaluated: animatedOperation.direction() == QVariantAnimation::Forward
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:7
7-12
3029 const int limit = rect.height() * 2;
executed (the execution status of this line is deduced): const int limit = rect.height() * 2;
-
3030 int h = 0;
executed (the execution status of this line is deduced): int h = 0;
-
3031 int c = animatedOperation.item + viewItems.at(animatedOperation.item).total + 1;
executed (the execution status of this line is deduced): int c = animatedOperation.item + viewItems.at(animatedOperation.item).total + 1;
-
3032 for (int i = animatedOperation.item + 1; i < c && h < limit; ++i)
evaluated: i < c
TRUEFALSE
yes
Evaluation Count:106
yes
Evaluation Count:11
evaluated: h < limit
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:1
1-106
3033 h += itemHeight(i);
executed: h += itemHeight(i);
Execution Count:105
105
3034 rect.setHeight(h);
executed (the execution status of this line is deduced): rect.setHeight(h);
-
3035 animatedOperation.setEndValue(animatedOperation.top() + h);
executed (the execution status of this line is deduced): animatedOperation.setEndValue(animatedOperation.top() + h);
-
3036 }
executed: }
Execution Count:12
12
3037 -
3038 if (!rect.isEmpty()) {
evaluated: !rect.isEmpty()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:1
1-18
3039 animatedOperation.after = renderTreeToPixmapForAnimation(rect);
executed (the execution status of this line is deduced): animatedOperation.after = renderTreeToPixmapForAnimation(rect);
-
3040 -
3041 q->setState(QAbstractItemView::AnimatingState);
executed (the execution status of this line is deduced): q->setState(QAbstractItemView::AnimatingState);
-
3042 animatedOperation.start(); //let's start the animation
executed (the execution status of this line is deduced): animatedOperation.start();
-
3043 }
executed: }
Execution Count:18
18
3044}
executed: }
Execution Count:19
19
3045 -
3046void QTreeViewPrivate::drawAnimatedOperation(QPainter *painter) const -
3047{ -
3048 const int start = animatedOperation.startValue().toInt(),
executed (the execution status of this line is deduced): const int start = animatedOperation.startValue().toInt(),
-
3049 end = animatedOperation.endValue().toInt(),
executed (the execution status of this line is deduced): end = animatedOperation.endValue().toInt(),
-
3050 current = animatedOperation.currentValue().toInt();
executed (the execution status of this line is deduced): current = animatedOperation.currentValue().toInt();
-
3051 bool collapsing = animatedOperation.direction() == QVariantAnimation::Backward;
executed (the execution status of this line is deduced): bool collapsing = animatedOperation.direction() == QVariantAnimation::Backward;
-
3052 const QPixmap top = collapsing ? animatedOperation.before : animatedOperation.after;
partially evaluated: collapsing
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
3053 painter->drawPixmap(0, start, top, 0, end - current - 1, top.width(), top.height());
executed (the execution status of this line is deduced): painter->drawPixmap(0, start, top, 0, end - current - 1, top.width(), top.height());
-
3054 const QPixmap bottom = collapsing ? animatedOperation.after : animatedOperation.before;
partially evaluated: collapsing
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
3055 painter->drawPixmap(0, current, bottom);
executed (the execution status of this line is deduced): painter->drawPixmap(0, current, bottom);
-
3056}
executed: }
Execution Count:1
1
3057 -
3058QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) const -
3059{ -
3060 Q_Q(const QTreeView);
executed (the execution status of this line is deduced): const QTreeView * const q = q_func();
-
3061 QPixmap pixmap(rect.size());
executed (the execution status of this line is deduced): QPixmap pixmap(rect.size());
-
3062 if (rect.size().isEmpty())
partially evaluated: rect.size().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
0-37
3063 return pixmap;
never executed: return pixmap;
0
3064 pixmap.fill(Qt::transparent); //the base might not be opaque, and we don't want uninitialized pixels.
executed (the execution status of this line is deduced): pixmap.fill(Qt::transparent);
-
3065 QPainter painter(&pixmap);
executed (the execution status of this line is deduced): QPainter painter(&pixmap);
-
3066 painter.fillRect(QRect(QPoint(0,0), rect.size()), q->palette().base());
executed (the execution status of this line is deduced): painter.fillRect(QRect(QPoint(0,0), rect.size()), q->palette().base());
-
3067 painter.translate(0, -rect.top());
executed (the execution status of this line is deduced): painter.translate(0, -rect.top());
-
3068 q->drawTree(&painter, QRegion(rect));
executed (the execution status of this line is deduced): q->drawTree(&painter, QRegion(rect));
-
3069 painter.end();
executed (the execution status of this line is deduced): painter.end();
-
3070 -
3071 //and now let's render the editors the editors -
3072 QStyleOptionViewItem option = viewOptions();
executed (the execution status of this line is deduced): QStyleOptionViewItem option = viewOptions();
-
3073 for (QEditorIndexHash::const_iterator it = editorIndexHash.constBegin(); it != editorIndexHash.constEnd(); ++it) {
partially evaluated: it != editorIndexHash.constEnd()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
0-37
3074 QWidget *editor = it.key();
never executed (the execution status of this line is deduced): QWidget *editor = it.key();
-
3075 const QModelIndex &index = it.value();
never executed (the execution status of this line is deduced): const QModelIndex &index = it.value();
-
3076 option.rect = q->visualRect(index);
never executed (the execution status of this line is deduced): option.rect = q->visualRect(index);
-
3077 if (option.rect.isValid()) {
never evaluated: option.rect.isValid()
0
3078 -
3079 if (QAbstractItemDelegate *delegate = delegateForIndex(index))
never evaluated: QAbstractItemDelegate *delegate = delegateForIndex(index)
0
3080 delegate->updateEditorGeometry(editor, option, index);
never executed: delegate->updateEditorGeometry(editor, option, index);
0
3081 -
3082 const QPoint pos = editor->pos();
never executed (the execution status of this line is deduced): const QPoint pos = editor->pos();
-
3083 if (rect.contains(pos)) {
never evaluated: rect.contains(pos)
0
3084 editor->render(&pixmap, pos - rect.topLeft());
never executed (the execution status of this line is deduced): editor->render(&pixmap, pos - rect.topLeft());
-
3085 //the animation uses pixmap to display the treeview's content -
3086 //the editor is rendered on this pixmap and thus can (should) be hidden -
3087 editor->hide();
never executed (the execution status of this line is deduced): editor->hide();
-
3088 }
never executed: }
0
3089 }
never executed: }
0
3090 }
never executed: }
0
3091 -
3092 -
3093 return pixmap;
executed: return pixmap;
Execution Count:37
37
3094} -
3095 -
3096void QTreeViewPrivate::_q_endAnimatedOperation() -
3097{ -
3098 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
3099 q->setState(stateBeforeAnimation);
executed (the execution status of this line is deduced): q->setState(stateBeforeAnimation);
-
3100 q->updateGeometries();
executed (the execution status of this line is deduced): q->updateGeometries();
-
3101 viewport->update();
executed (the execution status of this line is deduced): viewport->update();
-
3102}
executed: }
Execution Count:1
1
3103#endif //QT_NO_ANIMATION -
3104 -
3105void QTreeViewPrivate::_q_modelAboutToBeReset() -
3106{ -
3107 viewItems.clear();
executed (the execution status of this line is deduced): viewItems.clear();
-
3108}
executed: }
Execution Count:270
270
3109 -
3110void QTreeViewPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end) -
3111{ -
3112 if (start <= 0 && 0 <= end)
evaluated: start <= 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
partially evaluated: 0 <= end
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
3113 viewItems.clear();
executed: viewItems.clear();
Execution Count:7
7
3114 QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(parent, start, end);
executed (the execution status of this line is deduced): QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(parent, start, end);
-
3115}
executed: }
Execution Count:14
14
3116 -
3117void QTreeViewPrivate::_q_columnsRemoved(const QModelIndex &parent, int start, int end) -
3118{ -
3119 if (start <= 0 && 0 <= end)
evaluated: start <= 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
partially evaluated: 0 <= end
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
3120 doDelayedItemsLayout();
executed: doDelayedItemsLayout();
Execution Count:7
7
3121 QAbstractItemViewPrivate::_q_columnsRemoved(parent, start, end);
executed (the execution status of this line is deduced): QAbstractItemViewPrivate::_q_columnsRemoved(parent, start, end);
-
3122}
executed: }
Execution Count:14
14
3123 -
3124/** \internal -
3125 creates and initialize the viewItem structure of the children of the element \li -
3126 -
3127 set \a recursiveExpanding if the function has to expand all the children (called from expandAll) -
3128 \a afterIsUninitialized is when we recurse from layout(-1), it means all the items after 'i' are -
3129 not yet initialized and need not to be moved -
3130 */ -
3131void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninitialized) -
3132{ -
3133 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
3134 QModelIndex current;
executed (the execution status of this line is deduced): QModelIndex current;
-
3135 QModelIndex parent = (i < 0) ? (QModelIndex)root : modelIndex(i);
evaluated: (i < 0)
TRUEFALSE
yes
Evaluation Count:438
yes
Evaluation Count:332
332-438
3136 -
3137 if (i>=0 && !parent.isValid()) {
evaluated: i>=0
TRUEFALSE
yes
Evaluation Count:332
yes
Evaluation Count:438
partially evaluated: !parent.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:332
0-438
3138 //modelIndex() should never return something invalid for the real items. -
3139 //This can happen if columncount has been set to 0. -
3140 //To avoid infinite loop we stop here. -
3141 return;
never executed: return;
0
3142 } -
3143 -
3144 int count = 0;
executed (the execution status of this line is deduced): int count = 0;
-
3145 if (model->hasChildren(parent)) {
evaluated: model->hasChildren(parent)
TRUEFALSE
yes
Evaluation Count:609
yes
Evaluation Count:161
161-609
3146 if (model->canFetchMore(parent))
evaluated: model->canFetchMore(parent)
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:574
35-574
3147 model->fetchMore(parent);
executed: model->fetchMore(parent);
Execution Count:35
35
3148 count = model->rowCount(parent);
executed (the execution status of this line is deduced): count = model->rowCount(parent);
-
3149 }
executed: }
Execution Count:609
609
3150 -
3151 bool expanding = true;
executed (the execution status of this line is deduced): bool expanding = true;
-
3152 if (i == -1) {
evaluated: i == -1
TRUEFALSE
yes
Evaluation Count:438
yes
Evaluation Count:332
332-438
3153 if (uniformRowHeights) {
evaluated: uniformRowHeights
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:421
17-421
3154 QModelIndex index = model->index(0, 0, parent);
executed (the execution status of this line is deduced): QModelIndex index = model->index(0, 0, parent);
-
3155 defaultItemHeight = q->indexRowSizeHint(index);
executed (the execution status of this line is deduced): defaultItemHeight = q->indexRowSizeHint(index);
-
3156 }
executed: }
Execution Count:17
17
3157 viewItems.resize(count);
executed (the execution status of this line is deduced): viewItems.resize(count);
-
3158 afterIsUninitialized = true;
executed (the execution status of this line is deduced): afterIsUninitialized = true;
-
3159 } else if (viewItems[i].total != (uint)count) {
executed: }
Execution Count:438
evaluated: viewItems[i].total != (uint)count
TRUEFALSE
yes
Evaluation Count:165
yes
Evaluation Count:167
165-438
3160 if (!afterIsUninitialized)
evaluated: !afterIsUninitialized
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:110
55-110
3161 insertViewItems(i + 1, count, QTreeViewItem()); // expand
executed: insertViewItems(i + 1, count, QTreeViewItem());
Execution Count:55
55
3162 else if (count > 0)
partially evaluated: count > 0
TRUEFALSE
yes
Evaluation Count:110
no
Evaluation Count:0
0-110
3163 viewItems.resize(viewItems.count() + count);
executed: viewItems.resize(viewItems.count() + count);
Execution Count:110
110
3164 } else { -
3165 expanding = false;
executed (the execution status of this line is deduced): expanding = false;
-
3166 }
executed: }
Execution Count:167
167
3167 -
3168 int first = i + 1;
executed (the execution status of this line is deduced): int first = i + 1;
-
3169 int level = (i >= 0 ? viewItems.at(i).level + 1 : 0);
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:332
yes
Evaluation Count:438
332-438
3170 int hidden = 0;
executed (the execution status of this line is deduced): int hidden = 0;
-
3171 int last = 0;
executed (the execution status of this line is deduced): int last = 0;
-
3172 int children = 0;
executed (the execution status of this line is deduced): int children = 0;
-
3173 QTreeViewItem *item = 0;
executed (the execution status of this line is deduced): QTreeViewItem *item = 0;
-
3174 for (int j = first; j < first + count; ++j) {
evaluated: j < first + count
TRUEFALSE
yes
Evaluation Count:9296
yes
Evaluation Count:770
770-9296
3175 current = model->index(j - first, 0, parent);
executed (the execution status of this line is deduced): current = model->index(j - first, 0, parent);
-
3176 if (isRowHidden(current)) {
evaluated: isRowHidden(current)
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:9256
40-9256
3177 ++hidden;
executed (the execution status of this line is deduced): ++hidden;
-
3178 last = j - hidden + children;
executed (the execution status of this line is deduced): last = j - hidden + children;
-
3179 } else {
executed: }
Execution Count:40
40
3180 last = j - hidden + children;
executed (the execution status of this line is deduced): last = j - hidden + children;
-
3181 if (item)
evaluated: item
TRUEFALSE
yes
Evaluation Count:8680
yes
Evaluation Count:576
576-8680
3182 item->hasMoreSiblings = true;
executed: item->hasMoreSiblings = true;
Execution Count:8680
8680
3183 item = &viewItems[last];
executed (the execution status of this line is deduced): item = &viewItems[last];
-
3184 item->index = current;
executed (the execution status of this line is deduced): item->index = current;
-
3185 item->parentItem = i;
executed (the execution status of this line is deduced): item->parentItem = i;
-
3186 item->level = level;
executed (the execution status of this line is deduced): item->level = level;
-
3187 item->height = 0;
executed (the execution status of this line is deduced): item->height = 0;
-
3188 item->spanning = q->isFirstColumnSpanned(current.row(), parent);
executed (the execution status of this line is deduced): item->spanning = q->isFirstColumnSpanned(current.row(), parent);
-
3189 item->expanded = false;
executed (the execution status of this line is deduced): item->expanded = false;
-
3190 item->total = 0;
executed (the execution status of this line is deduced): item->total = 0;
-
3191 item->hasMoreSiblings = false;
executed (the execution status of this line is deduced): item->hasMoreSiblings = false;
-
3192 if (recursiveExpanding || isIndexExpanded(current)) {
evaluated: recursiveExpanding
TRUEFALSE
yes
Evaluation Count:190
yes
Evaluation Count:9066
evaluated: isIndexExpanded(current)
TRUEFALSE
yes
Evaluation Count:89
yes
Evaluation Count:8977
89-9066
3193 if (recursiveExpanding)
evaluated: recursiveExpanding
TRUEFALSE
yes
Evaluation Count:190
yes
Evaluation Count:89
89-190
3194 expandedIndexes.insert(current);
executed: expandedIndexes.insert(current);
Execution Count:190
190
3195 item->expanded = true;
executed (the execution status of this line is deduced): item->expanded = true;
-
3196 layout(last, recursiveExpanding, afterIsUninitialized);
executed (the execution status of this line is deduced): layout(last, recursiveExpanding, afterIsUninitialized);
-
3197 item = &viewItems[last];
executed (the execution status of this line is deduced): item = &viewItems[last];
-
3198 children += item->total;
executed (the execution status of this line is deduced): children += item->total;
-
3199 item->hasChildren = item->total > 0;
executed (the execution status of this line is deduced): item->hasChildren = item->total > 0;
-
3200 last = j - hidden + children;
executed (the execution status of this line is deduced): last = j - hidden + children;
-
3201 } else {
executed: }
Execution Count:279
279
3202 item->hasChildren = hasVisibleChildren(current);
executed (the execution status of this line is deduced): item->hasChildren = hasVisibleChildren(current);
-
3203 }
executed: }
Execution Count:8977
8977
3204 } -
3205 } -
3206 -
3207 // remove hidden items -
3208 if (hidden > 0) {
evaluated: hidden > 0
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:732
38-732
3209 if (!afterIsUninitialized)
partially evaluated: !afterIsUninitialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:38
0-38
3210 removeViewItems(last + 1, hidden);
never executed: removeViewItems(last + 1, hidden);
0
3211 else -
3212 viewItems.resize(viewItems.size() - hidden);
executed: viewItems.resize(viewItems.size() - hidden);
Execution Count:38
38
3213 } -
3214 -
3215 if (!expanding)
evaluated: !expanding
TRUEFALSE
yes
Evaluation Count:167
yes
Evaluation Count:603
167-603
3216 return; // nothing changed
executed: return;
Execution Count:167
167
3217 -
3218 while (i > -1) {
evaluated: i > -1
TRUEFALSE
yes
Evaluation Count:295
yes
Evaluation Count:603
295-603
3219 viewItems[i].total += count - hidden;
executed (the execution status of this line is deduced): viewItems[i].total += count - hidden;
-
3220 i = viewItems[i].parentItem;
executed (the execution status of this line is deduced): i = viewItems[i].parentItem;
-
3221 }
executed: }
Execution Count:295
295
3222}
executed: }
Execution Count:603
603
3223 -
3224int QTreeViewPrivate::pageUp(int i) const -
3225{ -
3226 int index = itemAtCoordinate(coordinateForItem(i) - viewport->height());
executed (the execution status of this line is deduced): int index = itemAtCoordinate(coordinateForItem(i) - viewport->height());
-
3227 while (isItemHiddenOrDisabled(index))
evaluated: isItemHiddenOrDisabled(index)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:5
3-5
3228 index--;
executed: index--;
Execution Count:3
3
3229 return index == -1 ? 0 : index;
executed: return index == -1 ? 0 : index;
Execution Count:5
5
3230} -
3231 -
3232int QTreeViewPrivate::pageDown(int i) const -
3233{ -
3234 int index = itemAtCoordinate(coordinateForItem(i) + viewport->height());
executed (the execution status of this line is deduced): int index = itemAtCoordinate(coordinateForItem(i) + viewport->height());
-
3235 while (isItemHiddenOrDisabled(index))
evaluated: isItemHiddenOrDisabled(index)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
3236 index++;
executed: index++;
Execution Count:4
4
3237 return index == -1 ? viewItems.count() - 1 : index;
executed: return index == -1 ? viewItems.count() - 1 : index;
Execution Count:1
1
3238} -
3239 -
3240int QTreeViewPrivate::indentationForItem(int item) const -
3241{ -
3242 if (item < 0 || item >= viewItems.count())
partially evaluated: item < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15656
partially evaluated: item >= viewItems.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15656
0-15656
3243 return 0;
never executed: return 0;
0
3244 int level = viewItems.at(item).level;
executed (the execution status of this line is deduced): int level = viewItems.at(item).level;
-
3245 if (rootDecoration)
evaluated: rootDecoration
TRUEFALSE
yes
Evaluation Count:15543
yes
Evaluation Count:113
113-15543
3246 ++level;
executed: ++level;
Execution Count:15543
15543
3247 return level * indent;
executed: return level * indent;
Execution Count:15656
15656
3248} -
3249 -
3250int QTreeViewPrivate::itemHeight(int item) const -
3251{ -
3252 if (uniformRowHeights)
evaluated: uniformRowHeights
TRUEFALSE
yes
Evaluation Count:745
yes
Evaluation Count:302521
745-302521
3253 return defaultItemHeight;
executed: return defaultItemHeight;
Execution Count:745
745
3254 if (viewItems.isEmpty())
partially evaluated: viewItems.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:302521
0-302521
3255 return 0;
never executed: return 0;
0
3256 const QModelIndex &index = viewItems.at(item).index;
executed (the execution status of this line is deduced): const QModelIndex &index = viewItems.at(item).index;
-
3257 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:302520
1-302520
3258 return 0;
executed: return 0;
Execution Count:1
1
3259 int height = viewItems.at(item).height;
executed (the execution status of this line is deduced): int height = viewItems.at(item).height;
-
3260 if (height <= 0) {
evaluated: height <= 0
TRUEFALSE
yes
Evaluation Count:2747
yes
Evaluation Count:299773
2747-299773
3261 height = q_func()->indexRowSizeHint(index);
executed (the execution status of this line is deduced): height = q_func()->indexRowSizeHint(index);
-
3262 viewItems[item].height = height;
executed (the execution status of this line is deduced): viewItems[item].height = height;
-
3263 }
executed: }
Execution Count:2747
2747
3264 return qMax(height, 0);
executed: return qMax(height, 0);
Execution Count:302520
302520
3265} -
3266 -
3267 -
3268/*! -
3269 \internal -
3270 Returns the viewport y coordinate for \a item. -
3271*/ -
3272int QTreeViewPrivate::coordinateForItem(int item) const -
3273{ -
3274 if (verticalScrollMode == QAbstractItemView::ScrollPerPixel) {
evaluated: verticalScrollMode == QAbstractItemView::ScrollPerPixel
TRUEFALSE
yes
Evaluation Count:9140
yes
Evaluation Count:10058
9140-10058
3275 if (uniformRowHeights)
evaluated: uniformRowHeights
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:9088
52-9088
3276 return (item * defaultItemHeight) - vbar->value();
executed: return (item * defaultItemHeight) - vbar->value();
Execution Count:52
52
3277 // ### optimize (spans or caching) -
3278 int y = 0;
executed (the execution status of this line is deduced): int y = 0;
-
3279 for (int i = 0; i < viewItems.count(); ++i) {
partially evaluated: i < viewItems.count()
TRUEFALSE
yes
Evaluation Count:107221
no
Evaluation Count:0
0-107221
3280 if (i == item)
evaluated: i == item
TRUEFALSE
yes
Evaluation Count:9088
yes
Evaluation Count:98133
9088-98133
3281 return y - vbar->value();
executed: return y - vbar->value();
Execution Count:9088
9088
3282 y += itemHeight(i);
executed (the execution status of this line is deduced): y += itemHeight(i);
-
3283 }
executed: }
Execution Count:98133
98133
3284 } else { // ScrollPerItem
never executed: }
0
3285 int topViewItemIndex = vbar->value();
executed (the execution status of this line is deduced): int topViewItemIndex = vbar->value();
-
3286 if (uniformRowHeights)
evaluated: uniformRowHeights
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:9946
112-9946
3287 return defaultItemHeight * (item - topViewItemIndex);
executed: return defaultItemHeight * (item - topViewItemIndex);
Execution Count:112
112
3288 if (item >= topViewItemIndex) {
evaluated: item >= topViewItemIndex
TRUEFALSE
yes
Evaluation Count:9936
yes
Evaluation Count:10
10-9936
3289 // search in the visible area first and continue down -
3290 // ### slow if the item is not visible -
3291 int viewItemCoordinate = 0;
executed (the execution status of this line is deduced): int viewItemCoordinate = 0;
-
3292 int viewItemIndex = topViewItemIndex;
executed (the execution status of this line is deduced): int viewItemIndex = topViewItemIndex;
-
3293 while (viewItemIndex < viewItems.count()) {
partially evaluated: viewItemIndex < viewItems.count()
TRUEFALSE
yes
Evaluation Count:33505
no
Evaluation Count:0
0-33505
3294 if (viewItemIndex == item)
evaluated: viewItemIndex == item
TRUEFALSE
yes
Evaluation Count:9936
yes
Evaluation Count:23569
9936-23569
3295 return viewItemCoordinate;
executed: return viewItemCoordinate;
Execution Count:9936
9936
3296 viewItemCoordinate += itemHeight(viewItemIndex);
executed (the execution status of this line is deduced): viewItemCoordinate += itemHeight(viewItemIndex);
-
3297 ++viewItemIndex;
executed (the execution status of this line is deduced): ++viewItemIndex;
-
3298 }
executed: }
Execution Count:23569
23569
3299 // below the last item in the view -
3300 Q_ASSERT(false);
never executed (the execution status of this line is deduced): qt_noop();
-
3301 return viewItemCoordinate;
never executed: return viewItemCoordinate;
0
3302 } else { -
3303 // search the area above the viewport (used for editor widgets) -
3304 int viewItemCoordinate = 0;
executed (the execution status of this line is deduced): int viewItemCoordinate = 0;
-
3305 for (int viewItemIndex = topViewItemIndex; viewItemIndex > 0; --viewItemIndex) {
evaluated: viewItemIndex > 0
TRUEFALSE
yes
Evaluation Count:270
yes
Evaluation Count:3
3-270
3306 if (viewItemIndex == item)
evaluated: viewItemIndex == item
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:263
7-263
3307 return viewItemCoordinate;
executed: return viewItemCoordinate;
Execution Count:7
7
3308 viewItemCoordinate -= itemHeight(viewItemIndex - 1);
executed (the execution status of this line is deduced): viewItemCoordinate -= itemHeight(viewItemIndex - 1);
-
3309 }
executed: }
Execution Count:263
263
3310 return viewItemCoordinate;
executed: return viewItemCoordinate;
Execution Count:3
3
3311 } -
3312 } -
3313 return 0;
never executed: return 0;
0
3314} -
3315 -
3316/*! -
3317 \internal -
3318 Returns the index of the view item at the -
3319 given viewport \a coordinate. -
3320 -
3321 \sa modelIndex() -
3322*/ -
3323int QTreeViewPrivate::itemAtCoordinate(int coordinate) const -
3324{ -
3325 const int itemCount = viewItems.count();
executed (the execution status of this line is deduced): const int itemCount = viewItems.count();
-
3326 if (itemCount == 0)
evaluated: itemCount == 0
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:12173
38-12173
3327 return -1;
executed: return -1;
Execution Count:38
38
3328 if (uniformRowHeights && defaultItemHeight <= 0)
evaluated: uniformRowHeights
TRUEFALSE
yes
Evaluation Count:66
yes
Evaluation Count:12107
partially evaluated: defaultItemHeight <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66
0-12107
3329 return -1;
never executed: return -1;
0
3330 if (verticalScrollMode == QAbstractItemView::ScrollPerPixel) {
evaluated: verticalScrollMode == QAbstractItemView::ScrollPerPixel
TRUEFALSE
yes
Evaluation Count:2004
yes
Evaluation Count:10169
2004-10169
3331 if (uniformRowHeights) {
evaluated: uniformRowHeights
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1995
9-1995
3332 const int viewItemIndex = (coordinate + vbar->value()) / defaultItemHeight;
executed (the execution status of this line is deduced): const int viewItemIndex = (coordinate + vbar->value()) / defaultItemHeight;
-
3333 return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex);
executed: return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex);
Execution Count:9
9
3334 } -
3335 // ### optimize -
3336 int viewItemCoordinate = 0;
executed (the execution status of this line is deduced): int viewItemCoordinate = 0;
-
3337 const int contentsCoordinate = coordinate + vbar->value();
executed (the execution status of this line is deduced): const int contentsCoordinate = coordinate + vbar->value();
-
3338 for (int viewItemIndex = 0; viewItemIndex < viewItems.count(); ++viewItemIndex) {
partially evaluated: viewItemIndex < viewItems.count()
TRUEFALSE
yes
Evaluation Count:17867
no
Evaluation Count:0
0-17867
3339 viewItemCoordinate += itemHeight(viewItemIndex);
executed (the execution status of this line is deduced): viewItemCoordinate += itemHeight(viewItemIndex);
-
3340 if (viewItemCoordinate >= contentsCoordinate)
evaluated: viewItemCoordinate >= contentsCoordinate
TRUEFALSE
yes
Evaluation Count:1995
yes
Evaluation Count:15872
1995-15872
3341 return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
executed: return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
Execution Count:1995
1995
3342 }
executed: }
Execution Count:15872
15872
3343 } else { // ScrollPerItem
never executed: }
0
3344 int topViewItemIndex = vbar->value();
executed (the execution status of this line is deduced): int topViewItemIndex = vbar->value();
-
3345 if (uniformRowHeights) {
evaluated: uniformRowHeights
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:10112
57-10112
3346 if (coordinate < 0)
evaluated: coordinate < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:54
3-54
3347 coordinate -= defaultItemHeight - 1;
executed: coordinate -= defaultItemHeight - 1;
Execution Count:3
3
3348 const int viewItemIndex = topViewItemIndex + (coordinate / defaultItemHeight);
executed (the execution status of this line is deduced): const int viewItemIndex = topViewItemIndex + (coordinate / defaultItemHeight);
-
3349 return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex);
executed: return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex);
Execution Count:57
57
3350 } -
3351 if (coordinate >= 0) {
evaluated: coordinate >= 0
TRUEFALSE
yes
Evaluation Count:10102
yes
Evaluation Count:10
10-10102
3352 // the coordinate is in or below the viewport -
3353 int viewItemCoordinate = 0;
executed (the execution status of this line is deduced): int viewItemCoordinate = 0;
-
3354 for (int viewItemIndex = topViewItemIndex; viewItemIndex < viewItems.count(); ++viewItemIndex) {
evaluated: viewItemIndex < viewItems.count()
TRUEFALSE
yes
Evaluation Count:14198
yes
Evaluation Count:55
55-14198
3355 viewItemCoordinate += itemHeight(viewItemIndex);
executed (the execution status of this line is deduced): viewItemCoordinate += itemHeight(viewItemIndex);
-
3356 if (viewItemCoordinate > coordinate)
evaluated: viewItemCoordinate > coordinate
TRUEFALSE
yes
Evaluation Count:10047
yes
Evaluation Count:4151
4151-10047
3357 return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
executed: return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
Execution Count:10047
10047
3358 }
executed: }
Execution Count:4151
4151
3359 } else {
executed: }
Execution Count:55
55
3360 // the coordinate is above the viewport -
3361 int viewItemCoordinate = 0;
executed (the execution status of this line is deduced): int viewItemCoordinate = 0;
-
3362 for (int viewItemIndex = topViewItemIndex; viewItemIndex >= 0; --viewItemIndex) {
evaluated: viewItemIndex >= 0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:9
9-12
3363 if (viewItemCoordinate <= coordinate)
evaluated: viewItemCoordinate <= coordinate
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:11
1-11
3364 return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
executed: return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
Execution Count:1
1
3365 viewItemCoordinate -= itemHeight(viewItemIndex);
executed (the execution status of this line is deduced): viewItemCoordinate -= itemHeight(viewItemIndex);
-
3366 }
executed: }
Execution Count:11
11
3367 }
executed: }
Execution Count:9
9
3368 } -
3369 return -1;
executed: return -1;
Execution Count:64
64
3370} -
3371 -
3372int QTreeViewPrivate::viewIndex(const QModelIndex &_index) const -
3373{ -
3374 if (!_index.isValid() || viewItems.isEmpty())
evaluated: !_index.isValid()
TRUEFALSE
yes
Evaluation Count:195
yes
Evaluation Count:28908
evaluated: viewItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:28843
65-28908
3375 return -1;
executed: return -1;
Execution Count:260
260
3376 -
3377 const int totalCount = viewItems.count();
executed (the execution status of this line is deduced): const int totalCount = viewItems.count();
-
3378 const QModelIndex index = _index.sibling(_index.row(), 0);
executed (the execution status of this line is deduced): const QModelIndex index = _index.sibling(_index.row(), 0);
-
3379 const int row = index.row();
executed (the execution status of this line is deduced): const int row = index.row();
-
3380 const quintptr internalId = index.internalId();
executed (the execution status of this line is deduced): const quintptr internalId = index.internalId();
-
3381 -
3382 // We start nearest to the lastViewedItem -
3383 int localCount = qMin(lastViewedItem - 1, totalCount - lastViewedItem);
executed (the execution status of this line is deduced): int localCount = qMin(lastViewedItem - 1, totalCount - lastViewedItem);
-
3384 for (int i = 0; i < localCount; ++i) {
evaluated: i < localCount
TRUEFALSE
yes
Evaluation Count:24582
yes
Evaluation Count:13700
13700-24582
3385 const QModelIndex &idx1 = viewItems.at(lastViewedItem + i).index;
executed (the execution status of this line is deduced): const QModelIndex &idx1 = viewItems.at(lastViewedItem + i).index;
-
3386 if (idx1.row() == row && idx1.internalId() == internalId) {
evaluated: idx1.row() == row
TRUEFALSE
yes
Evaluation Count:13557
yes
Evaluation Count:11025
evaluated: idx1.internalId() == internalId
TRUEFALSE
yes
Evaluation Count:13526
yes
Evaluation Count:31
31-13557
3387 lastViewedItem = lastViewedItem + i;
executed (the execution status of this line is deduced): lastViewedItem = lastViewedItem + i;
-
3388 return lastViewedItem;
executed: return lastViewedItem;
Execution Count:13526
13526
3389 } -
3390 const QModelIndex &idx2 = viewItems.at(lastViewedItem - i - 1).index;
executed (the execution status of this line is deduced): const QModelIndex &idx2 = viewItems.at(lastViewedItem - i - 1).index;
-
3391 if (idx2.row() == row && idx2.internalId() == internalId) {
evaluated: idx2.row() == row
TRUEFALSE
yes
Evaluation Count:1655
yes
Evaluation Count:9401
evaluated: idx2.internalId() == internalId
TRUEFALSE
yes
Evaluation Count:1617
yes
Evaluation Count:38
38-9401
3392 lastViewedItem = lastViewedItem - i - 1;
executed (the execution status of this line is deduced): lastViewedItem = lastViewedItem - i - 1;
-
3393 return lastViewedItem;
executed: return lastViewedItem;
Execution Count:1617
1617
3394 } -
3395 }
executed: }
Execution Count:9439
9439
3396 -
3397 for (int j = qMax(0, lastViewedItem + localCount); j < totalCount; ++j) {
evaluated: j < totalCount
TRUEFALSE
yes
Evaluation Count:27187
yes
Evaluation Count:1501
1501-27187
3398 const QModelIndex &idx = viewItems.at(j).index;
executed (the execution status of this line is deduced): const QModelIndex &idx = viewItems.at(j).index;
-
3399 if (idx.row() == row && idx.internalId() == internalId) {
evaluated: idx.row() == row
TRUEFALSE
yes
Evaluation Count:12784
yes
Evaluation Count:14403
evaluated: idx.internalId() == internalId
TRUEFALSE
yes
Evaluation Count:12199
yes
Evaluation Count:585
585-14403
3400 lastViewedItem = j;
executed (the execution status of this line is deduced): lastViewedItem = j;
-
3401 return j;
executed: return j;
Execution Count:12199
12199
3402 } -
3403 }
executed: }
Execution Count:14988
14988
3404 for (int j = qMin(totalCount, lastViewedItem - localCount) - 1; j >= 0; --j) {
evaluated: j >= 0
TRUEFALSE
yes
Evaluation Count:2221
yes
Evaluation Count:987
987-2221
3405 const QModelIndex &idx = viewItems.at(j).index;
executed (the execution status of this line is deduced): const QModelIndex &idx = viewItems.at(j).index;
-
3406 if (idx.row() == row && idx.internalId() == internalId) {
evaluated: idx.row() == row
TRUEFALSE
yes
Evaluation Count:562
yes
Evaluation Count:1659
evaluated: idx.internalId() == internalId
TRUEFALSE
yes
Evaluation Count:514
yes
Evaluation Count:48
48-1659
3407 lastViewedItem = j;
executed (the execution status of this line is deduced): lastViewedItem = j;
-
3408 return j;
executed: return j;
Execution Count:514
514
3409 } -
3410 }
executed: }
Execution Count:1707
1707
3411 -
3412 // nothing found -
3413 return -1;
executed: return -1;
Execution Count:987
987
3414} -
3415 -
3416QModelIndex QTreeViewPrivate::modelIndex(int i, int column) const -
3417{ -
3418 if (i < 0 || i >= viewItems.count())
evaluated: i < 0
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:12831
partially evaluated: i >= viewItems.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12831
0-12831
3419 return QModelIndex();
executed: return QModelIndex();
Execution Count:105
105
3420 -
3421 QModelIndex ret = viewItems.at(i).index;
executed (the execution status of this line is deduced): QModelIndex ret = viewItems.at(i).index;
-
3422 if (column)
evaluated: column
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:12800
31-12800
3423 ret = ret.sibling(ret.row(), column);
executed: ret = ret.sibling(ret.row(), column);
Execution Count:31
31
3424 return ret;
executed: return ret;
Execution Count:12831
12831
3425} -
3426 -
3427int QTreeViewPrivate::firstVisibleItem(int *offset) const -
3428{ -
3429 const int value = vbar->value();
executed (the execution status of this line is deduced): const int value = vbar->value();
-
3430 if (verticalScrollMode == QAbstractItemView::ScrollPerItem) {
evaluated: verticalScrollMode == QAbstractItemView::ScrollPerItem
TRUEFALSE
yes
Evaluation Count:324
yes
Evaluation Count:42
42-324
3431 if (offset)
evaluated: offset
TRUEFALSE
yes
Evaluation Count:318
yes
Evaluation Count:6
6-318
3432 *offset = 0;
executed: *offset = 0;
Execution Count:318
318
3433 return (value < 0 || value >= viewItems.count()) ? -1 : value;
executed: return (value < 0 || value >= viewItems.count()) ? -1 : value;
Execution Count:324
324
3434 } -
3435 // ScrollMode == ScrollPerPixel -
3436 if (uniformRowHeights) {
partially evaluated: uniformRowHeights
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
3437 if (!defaultItemHeight)
never evaluated: !defaultItemHeight
0
3438 return -1;
never executed: return -1;
0
3439 -
3440 if (offset)
never evaluated: offset
0
3441 *offset = -(value % defaultItemHeight);
never executed: *offset = -(value % defaultItemHeight);
0
3442 return value / defaultItemHeight;
never executed: return value / defaultItemHeight;
0
3443 } -
3444 int y = 0; // ### optimize (use spans ?)
executed (the execution status of this line is deduced): int y = 0;
-
3445 for (int i = 0; i < viewItems.count(); ++i) {
partially evaluated: i < viewItems.count()
TRUEFALSE
yes
Evaluation Count:42
no
Evaluation Count:0
0-42
3446 y += itemHeight(i); // the height value is cached
executed (the execution status of this line is deduced): y += itemHeight(i);
-
3447 if (y > value) {
partially evaluated: y > value
TRUEFALSE
yes
Evaluation Count:42
no
Evaluation Count:0
0-42
3448 if (offset)
partially evaluated: offset
TRUEFALSE
yes
Evaluation Count:42
no
Evaluation Count:0
0-42
3449 *offset = y - value - itemHeight(i);
executed: *offset = y - value - itemHeight(i);
Execution Count:42
42
3450 return i;
executed: return i;
Execution Count:42
42
3451 } -
3452 }
never executed: }
0
3453 return -1;
never executed: return -1;
0
3454} -
3455 -
3456int QTreeViewPrivate::columnAt(int x) const -
3457{ -
3458 return header->logicalIndexAt(x);
executed: return header->logicalIndexAt(x);
Execution Count:7061
7061
3459} -
3460 -
3461void QTreeViewPrivate::updateScrollBars() -
3462{ -
3463 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
3464 QSize viewportSize = viewport->size();
executed (the execution status of this line is deduced): QSize viewportSize = viewport->size();
-
3465 if (!viewportSize.isValid())
partially evaluated: !viewportSize.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6695
0-6695
3466 viewportSize = QSize(0, 0);
never executed: viewportSize = QSize(0, 0);
0
3467 -
3468 if (viewItems.isEmpty()) {
evaluated: viewItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:441
yes
Evaluation Count:6254
441-6254
3469 q->doItemsLayout();
executed (the execution status of this line is deduced): q->doItemsLayout();
-
3470 }
executed: }
Execution Count:441
441
3471 -
3472 int itemsInViewport = 0;
executed (the execution status of this line is deduced): int itemsInViewport = 0;
-
3473 if (uniformRowHeights) {
evaluated: uniformRowHeights
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:6615
80-6615
3474 if (defaultItemHeight <= 0)
partially evaluated: defaultItemHeight <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:80
0-80
3475 itemsInViewport = viewItems.count();
never executed: itemsInViewport = viewItems.count();
0
3476 else -
3477 itemsInViewport = viewportSize.height() / defaultItemHeight;
executed: itemsInViewport = viewportSize.height() / defaultItemHeight;
Execution Count:80
80
3478 } else { -
3479 const int itemsCount = viewItems.count();
executed (the execution status of this line is deduced): const int itemsCount = viewItems.count();
-
3480 const int viewportHeight = viewportSize.height();
executed (the execution status of this line is deduced): const int viewportHeight = viewportSize.height();
-
3481 for (int height = 0, item = itemsCount - 1; item >= 0; --item) {
evaluated: item >= 0
TRUEFALSE
yes
Evaluation Count:53675
yes
Evaluation Count:795
795-53675
3482 height += itemHeight(item);
executed (the execution status of this line is deduced): height += itemHeight(item);
-
3483 if (height > viewportHeight)
evaluated: height > viewportHeight
TRUEFALSE
yes
Evaluation Count:5820
yes
Evaluation Count:47855
5820-47855
3484 break;
executed: break;
Execution Count:5820
5820
3485 ++itemsInViewport;
executed (the execution status of this line is deduced): ++itemsInViewport;
-
3486 }
executed: }
Execution Count:47855
47855
3487 }
executed: }
Execution Count:6615
6615
3488 if (verticalScrollMode == QAbstractItemView::ScrollPerItem) {
evaluated: verticalScrollMode == QAbstractItemView::ScrollPerItem
TRUEFALSE
yes
Evaluation Count:3892
yes
Evaluation Count:2803
2803-3892
3489 if (!viewItems.isEmpty())
evaluated: !viewItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:3625
yes
Evaluation Count:267
267-3625
3490 itemsInViewport = qMax(1, itemsInViewport);
executed: itemsInViewport = qMax(1, itemsInViewport);
Execution Count:3625
3625
3491 vbar->setRange(0, viewItems.count() - itemsInViewport);
executed (the execution status of this line is deduced): vbar->setRange(0, viewItems.count() - itemsInViewport);
-
3492 vbar->setPageStep(itemsInViewport);
executed (the execution status of this line is deduced): vbar->setPageStep(itemsInViewport);
-
3493 vbar->setSingleStep(1);
executed (the execution status of this line is deduced): vbar->setSingleStep(1);
-
3494 } else { // scroll per pixel
executed: }
Execution Count:3892
3892
3495 int contentsHeight = 0;
executed (the execution status of this line is deduced): int contentsHeight = 0;
-
3496 if (uniformRowHeights) {
evaluated: uniformRowHeights
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:2791
12-2791
3497 contentsHeight = defaultItemHeight * viewItems.count();
executed (the execution status of this line is deduced): contentsHeight = defaultItemHeight * viewItems.count();
-
3498 } else { // ### optimize (spans or caching)
executed: }
Execution Count:12
12
3499 for (int i = 0; i < viewItems.count(); ++i)
evaluated: i < viewItems.count()
TRUEFALSE
yes
Evaluation Count:71546
yes
Evaluation Count:2791
2791-71546
3500 contentsHeight += itemHeight(i);
executed: contentsHeight += itemHeight(i);
Execution Count:71546
71546
3501 }
executed: }
Execution Count:2791
2791
3502 vbar->setRange(0, contentsHeight - viewportSize.height());
executed (the execution status of this line is deduced): vbar->setRange(0, contentsHeight - viewportSize.height());
-
3503 vbar->setPageStep(viewportSize.height());
executed (the execution status of this line is deduced): vbar->setPageStep(viewportSize.height());
-
3504 vbar->setSingleStep(qMax(viewportSize.height() / (itemsInViewport + 1), 2));
executed (the execution status of this line is deduced): vbar->setSingleStep(qMax(viewportSize.height() / (itemsInViewport + 1), 2));
-
3505 }
executed: }
Execution Count:2803
2803
3506 -
3507 const int columnCount = header->count();
executed (the execution status of this line is deduced): const int columnCount = header->count();
-
3508 const int viewportWidth = viewportSize.width();
executed (the execution status of this line is deduced): const int viewportWidth = viewportSize.width();
-
3509 int columnsInViewport = 0;
executed (the execution status of this line is deduced): int columnsInViewport = 0;
-
3510 for (int width = 0, column = columnCount - 1; column >= 0; --column) {
evaluated: column >= 0
TRUEFALSE
yes
Evaluation Count:18444
yes
Evaluation Count:720
720-18444
3511 int logical = header->logicalIndex(column);
executed (the execution status of this line is deduced): int logical = header->logicalIndex(column);
-
3512 width += header->sectionSize(logical);
executed (the execution status of this line is deduced): width += header->sectionSize(logical);
-
3513 if (width > viewportWidth)
evaluated: width > viewportWidth
TRUEFALSE
yes
Evaluation Count:5975
yes
Evaluation Count:12469
5975-12469
3514 break;
executed: break;
Execution Count:5975
5975
3515 ++columnsInViewport;
executed (the execution status of this line is deduced): ++columnsInViewport;
-
3516 }
executed: }
Execution Count:12469
12469
3517 if (columnCount > 0)
evaluated: columnCount > 0
TRUEFALSE
yes
Evaluation Count:6543
yes
Evaluation Count:152
152-6543
3518 columnsInViewport = qMax(1, columnsInViewport);
executed: columnsInViewport = qMax(1, columnsInViewport);
Execution Count:6543
6543
3519 if (horizontalScrollMode == QAbstractItemView::ScrollPerItem) {
evaluated: horizontalScrollMode == QAbstractItemView::ScrollPerItem
TRUEFALSE
yes
Evaluation Count:2778
yes
Evaluation Count:3917
2778-3917
3520 hbar->setRange(0, columnCount - columnsInViewport);
executed (the execution status of this line is deduced): hbar->setRange(0, columnCount - columnsInViewport);
-
3521 hbar->setPageStep(columnsInViewport);
executed (the execution status of this line is deduced): hbar->setPageStep(columnsInViewport);
-
3522 hbar->setSingleStep(1);
executed (the execution status of this line is deduced): hbar->setSingleStep(1);
-
3523 } else { // scroll per pixel
executed: }
Execution Count:2778
2778
3524 const int horizontalLength = header->length();
executed (the execution status of this line is deduced): const int horizontalLength = header->length();
-
3525 const QSize maxSize = q->maximumViewportSize();
executed (the execution status of this line is deduced): const QSize maxSize = q->maximumViewportSize();
-
3526 if (maxSize.width() >= horizontalLength && vbar->maximum() <= 0)
evaluated: maxSize.width() >= horizontalLength
TRUEFALSE
yes
Evaluation Count:681
yes
Evaluation Count:3236
evaluated: vbar->maximum() <= 0
TRUEFALSE
yes
Evaluation Count:586
yes
Evaluation Count:95
95-3236
3527 viewportSize = maxSize;
executed: viewportSize = maxSize;
Execution Count:586
586
3528 hbar->setPageStep(viewportSize.width());
executed (the execution status of this line is deduced): hbar->setPageStep(viewportSize.width());
-
3529 hbar->setRange(0, qMax(horizontalLength - viewportSize.width(), 0));
executed (the execution status of this line is deduced): hbar->setRange(0, qMax(horizontalLength - viewportSize.width(), 0));
-
3530 hbar->setSingleStep(qMax(viewportSize.width() / (columnsInViewport + 1), 2));
executed (the execution status of this line is deduced): hbar->setSingleStep(qMax(viewportSize.width() / (columnsInViewport + 1), 2));
-
3531 }
executed: }
Execution Count:3917
3917
3532} -
3533 -
3534int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const -
3535{ -
3536 executePostedLayout();
executed (the execution status of this line is deduced): executePostedLayout();
-
3537 int x = pos.x();
executed (the execution status of this line is deduced): int x = pos.x();
-
3538 int column = header->logicalIndexAt(x);
executed (the execution status of this line is deduced): int column = header->logicalIndexAt(x);
-
3539 if (column != 0)
evaluated: column != 0
TRUEFALSE
yes
Evaluation Count:514
yes
Evaluation Count:4992
514-4992
3540 return -1; // no logical index at x
executed: return -1;
Execution Count:514
514
3541 -
3542 int viewItemIndex = itemAtCoordinate(pos.y());
executed (the execution status of this line is deduced): int viewItemIndex = itemAtCoordinate(pos.y());
-
3543 QRect returning = itemDecorationRect(modelIndex(viewItemIndex));
executed (the execution status of this line is deduced): QRect returning = itemDecorationRect(modelIndex(viewItemIndex));
-
3544 if (!returning.contains(pos))
evaluated: !returning.contains(pos)
TRUEFALSE
yes
Evaluation Count:4989
yes
Evaluation Count:3
3-4989
3545 return -1;
executed: return -1;
Execution Count:4989
4989
3546 -
3547 return viewItemIndex;
executed: return viewItemIndex;
Execution Count:3
3
3548} -
3549 -
3550QRect QTreeViewPrivate::itemDecorationRect(const QModelIndex &index) const -
3551{ -
3552 Q_Q(const QTreeView);
executed (the execution status of this line is deduced): const QTreeView * const q = q_func();
-
3553 if (!rootDecoration && index.parent() == root)
evaluated: !rootDecoration
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:4977
evaluated: index.parent() == root
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:6
6-4977
3554 return QRect(); // no decoration at root
executed: return QRect();
Execution Count:9
9
3555 -
3556 int viewItemIndex = viewIndex(index);
executed (the execution status of this line is deduced): int viewItemIndex = viewIndex(index);
-
3557 if (viewItemIndex < 0 || !hasVisibleChildren(viewItems.at(viewItemIndex).index))
evaluated: viewItemIndex < 0
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:4927
evaluated: !hasVisibleChildren(viewItems.at(viewItemIndex).index)
TRUEFALSE
yes
Evaluation Count:4748
yes
Evaluation Count:179
56-4927
3558 return QRect();
executed: return QRect();
Execution Count:4804
4804
3559 -
3560 int itemIndentation = indentationForItem(viewItemIndex);
executed (the execution status of this line is deduced): int itemIndentation = indentationForItem(viewItemIndex);
-
3561 int position = header->sectionViewportPosition(0);
executed (the execution status of this line is deduced): int position = header->sectionViewportPosition(0);
-
3562 int size = header->sectionSize(0);
executed (the execution status of this line is deduced): int size = header->sectionSize(0);
-
3563 -
3564 QRect rect;
executed (the execution status of this line is deduced): QRect rect;
-
3565 if (q->isRightToLeft())
partially evaluated: q->isRightToLeft()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:179
0-179
3566 rect = QRect(position + size - itemIndentation, coordinateForItem(viewItemIndex),
never executed: rect = QRect(position + size - itemIndentation, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex));
0
3567 indent, itemHeight(viewItemIndex));
never executed: rect = QRect(position + size - itemIndentation, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex));
0
3568 else -
3569 rect = QRect(position + itemIndentation - indent, coordinateForItem(viewItemIndex),
executed: rect = QRect(position + itemIndentation - indent, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex));
Execution Count:179
179
3570 indent, itemHeight(viewItemIndex));
executed: rect = QRect(position + itemIndentation - indent, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex));
Execution Count:179
179
3571 QStyleOption opt;
executed (the execution status of this line is deduced): QStyleOption opt;
-
3572 opt.initFrom(q);
executed (the execution status of this line is deduced): opt.initFrom(q);
-
3573 opt.rect = rect;
executed (the execution status of this line is deduced): opt.rect = rect;
-
3574 return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q);
executed: return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q);
Execution Count:179
179
3575} -
3576 -
3577QList<QPair<int, int> > QTreeViewPrivate::columnRanges(const QModelIndex &topIndex, -
3578 const QModelIndex &bottomIndex) const -
3579{ -
3580 const int topVisual = header->visualIndex(topIndex.column()),
executed (the execution status of this line is deduced): const int topVisual = header->visualIndex(topIndex.column()),
-
3581 bottomVisual = header->visualIndex(bottomIndex.column());
executed (the execution status of this line is deduced): bottomVisual = header->visualIndex(bottomIndex.column());
-
3582 -
3583 const int start = qMin(topVisual, bottomVisual);
executed (the execution status of this line is deduced): const int start = qMin(topVisual, bottomVisual);
-
3584 const int end = qMax(topVisual, bottomVisual);
executed (the execution status of this line is deduced): const int end = qMax(topVisual, bottomVisual);
-
3585 -
3586 QList<int> logicalIndexes;
executed (the execution status of this line is deduced): QList<int> logicalIndexes;
-
3587 -
3588 //we iterate over the visual indexes to get the logical indexes -
3589 for (int c = start; c <= end; c++) {
evaluated: c <= end
TRUEFALSE
yes
Evaluation Count:327
yes
Evaluation Count:323
323-327
3590 const int logical = header->logicalIndex(c);
executed (the execution status of this line is deduced): const int logical = header->logicalIndex(c);
-
3591 if (!header->isSectionHidden(logical)) {
evaluated: !header->isSectionHidden(logical)
TRUEFALSE
yes
Evaluation Count:326
yes
Evaluation Count:1
1-326
3592 logicalIndexes << logical;
executed (the execution status of this line is deduced): logicalIndexes << logical;
-
3593 }
executed: }
Execution Count:326
326
3594 }
executed: }
Execution Count:327
327
3595 //let's sort the list -
3596 qSort(logicalIndexes.begin(), logicalIndexes.end());
executed (the execution status of this line is deduced): qSort(logicalIndexes.begin(), logicalIndexes.end());
-
3597 -
3598 QList<QPair<int, int> > ret;
executed (the execution status of this line is deduced): QList<QPair<int, int> > ret;
-
3599 QPair<int, int> current;
executed (the execution status of this line is deduced): QPair<int, int> current;
-
3600 current.first = -2; // -1 is not enough because -1+1 = 0
executed (the execution status of this line is deduced): current.first = -2;
-
3601 current.second = -2;
executed (the execution status of this line is deduced): current.second = -2;
-
3602 for(int i = 0; i < logicalIndexes.count(); ++i) {
evaluated: i < logicalIndexes.count()
TRUEFALSE
yes
Evaluation Count:326
yes
Evaluation Count:323
323-326
3603 const int logicalColumn = logicalIndexes.at(i);
executed (the execution status of this line is deduced): const int logicalColumn = logicalIndexes.at(i);
-
3604 if (current.second + 1 != logicalColumn) {
evaluated: current.second + 1 != logicalColumn
TRUEFALSE
yes
Evaluation Count:323
yes
Evaluation Count:3
3-323
3605 if (current.first != -2) {
partially evaluated: current.first != -2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:323
0-323
3606 //let's save the current one -
3607 ret += current;
never executed (the execution status of this line is deduced): ret += current;
-
3608 }
never executed: }
0
3609 //let's start a new one -
3610 current.first = current.second = logicalColumn;
executed (the execution status of this line is deduced): current.first = current.second = logicalColumn;
-
3611 } else {
executed: }
Execution Count:323
323
3612 current.second++;
executed (the execution status of this line is deduced): current.second++;
-
3613 }
executed: }
Execution Count:3
3
3614 } -
3615 -
3616 //let's get the last range -
3617 if (current.first != -2) {
partially evaluated: current.first != -2
TRUEFALSE
yes
Evaluation Count:323
no
Evaluation Count:0
0-323
3618 ret += current;
executed (the execution status of this line is deduced): ret += current;
-
3619 }
executed: }
Execution Count:323
323
3620 -
3621 return ret;
executed: return ret;
Execution Count:323
323
3622} -
3623 -
3624void QTreeViewPrivate::select(const QModelIndex &topIndex, const QModelIndex &bottomIndex, -
3625 QItemSelectionModel::SelectionFlags command) -
3626{ -
3627 Q_Q(QTreeView);
executed (the execution status of this line is deduced): QTreeView * const q = q_func();
-
3628 QItemSelection selection;
executed (the execution status of this line is deduced): QItemSelection selection;
-
3629 const int top = viewIndex(topIndex),
executed (the execution status of this line is deduced): const int top = viewIndex(topIndex),
-
3630 bottom = viewIndex(bottomIndex);
executed (the execution status of this line is deduced): bottom = viewIndex(bottomIndex);
-
3631 -
3632 const QList< QPair<int, int> > colRanges = columnRanges(topIndex, bottomIndex);
executed (the execution status of this line is deduced): const QList< QPair<int, int> > colRanges = columnRanges(topIndex, bottomIndex);
-
3633 QList< QPair<int, int> >::const_iterator it;
executed (the execution status of this line is deduced): QList< QPair<int, int> >::const_iterator it;
-
3634 for (it = colRanges.begin(); it != colRanges.end(); ++it) {
evaluated: it != colRanges.end()
TRUEFALSE
yes
Evaluation Count:323
yes
Evaluation Count:323
323
3635 const int left = (*it).first,
executed (the execution status of this line is deduced): const int left = (*it).first,
-
3636 right = (*it).second;
executed (the execution status of this line is deduced): right = (*it).second;
-
3637 -
3638 QModelIndex previous;
executed (the execution status of this line is deduced): QModelIndex previous;
-
3639 QItemSelectionRange currentRange;
executed (the execution status of this line is deduced): QItemSelectionRange currentRange;
-
3640 QStack<QItemSelectionRange> rangeStack;
executed (the execution status of this line is deduced): QStack<QItemSelectionRange> rangeStack;
-
3641 for (int i = top; i <= bottom; ++i) {
evaluated: i <= bottom
TRUEFALSE
yes
Evaluation Count:353
yes
Evaluation Count:323
323-353
3642 QModelIndex index = modelIndex(i);
executed (the execution status of this line is deduced): QModelIndex index = modelIndex(i);
-
3643 QModelIndex parent = index.parent();
executed (the execution status of this line is deduced): QModelIndex parent = index.parent();
-
3644 QModelIndex previousParent = previous.parent();
executed (the execution status of this line is deduced): QModelIndex previousParent = previous.parent();
-
3645 if (previous.isValid() && parent == previousParent) {
evaluated: previous.isValid()
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:323
evaluated: parent == previousParent
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:4
4-323
3646 // same parent -
3647 if (qAbs(previous.row() - index.row()) > 1) {
evaluated: qAbs(previous.row() - index.row()) > 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:24
2-24
3648 //a hole (hidden index inside a range) has been detected -
3649 if (currentRange.isValid()) {
partially evaluated: currentRange.isValid()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
3650 selection.append(currentRange);
executed (the execution status of this line is deduced): selection.append(currentRange);
-
3651 }
executed: }
Execution Count:2
2
3652 //let's start a new range -
3653 currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right));
executed (the execution status of this line is deduced): currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right));
-
3654 } else {
executed: }
Execution Count:2
2
3655 QModelIndex tl = model->index(currentRange.top(), currentRange.left(),
executed (the execution status of this line is deduced): QModelIndex tl = model->index(currentRange.top(), currentRange.left(),
-
3656 currentRange.parent());
executed (the execution status of this line is deduced): currentRange.parent());
-
3657 currentRange = QItemSelectionRange(tl, index.sibling(index.row(), right));
executed (the execution status of this line is deduced): currentRange = QItemSelectionRange(tl, index.sibling(index.row(), right));
-
3658 }
executed: }
Execution Count:24
24
3659 } else if (previous.isValid() && parent == model->index(previous.row(), 0, previousParent)) {
evaluated: previous.isValid()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:323
evaluated: parent == model->index(previous.row(), 0, previousParent)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2-323
3660 // item is child of previous -
3661 rangeStack.push(currentRange);
executed (the execution status of this line is deduced): rangeStack.push(currentRange);
-
3662 currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right));
executed (the execution status of this line is deduced): currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right));
-
3663 } else {
executed: }
Execution Count:2
2
3664 if (currentRange.isValid())
evaluated: currentRange.isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:323
2-323
3665 selection.append(currentRange);
executed: selection.append(currentRange);
Execution Count:2
2
3666 if (rangeStack.isEmpty()) {
evaluated: rangeStack.isEmpty()
TRUEFALSE
yes
Evaluation Count:323
yes
Evaluation Count:2
2-323
3667 currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right));
executed (the execution status of this line is deduced): currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right));
-
3668 } else {
executed: }
Execution Count:323
323
3669 currentRange = rangeStack.pop();
executed (the execution status of this line is deduced): currentRange = rangeStack.pop();
-
3670 index = currentRange.bottomRight(); //let's resume the range
executed (the execution status of this line is deduced): index = currentRange.bottomRight();
-
3671 --i; //we process again the current item
executed (the execution status of this line is deduced): --i;
-
3672 }
executed: }
Execution Count:2
2
3673 } -
3674 previous = index;
executed (the execution status of this line is deduced): previous = index;
-
3675 }
executed: }
Execution Count:353
353
3676 if (currentRange.isValid())
partially evaluated: currentRange.isValid()
TRUEFALSE
yes
Evaluation Count:323
no
Evaluation Count:0
0-323
3677 selection.append(currentRange);
executed: selection.append(currentRange);
Execution Count:323
323
3678 for (int i = 0; i < rangeStack.count(); ++i)
partially evaluated: i < rangeStack.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:323
0-323
3679 selection.append(rangeStack.at(i));
never executed: selection.append(rangeStack.at(i));
0
3680 }
executed: }
Execution Count:323
323
3681 q->selectionModel()->select(selection, command);
executed (the execution status of this line is deduced): q->selectionModel()->select(selection, command);
-
3682}
executed: }
Execution Count:323
323
3683 -
3684QPair<int,int> QTreeViewPrivate::startAndEndColumns(const QRect &rect) const -
3685{ -
3686 Q_Q(const QTreeView);
executed (the execution status of this line is deduced): const QTreeView * const q = q_func();
-
3687 int start = header->visualIndexAt(rect.left());
executed (the execution status of this line is deduced): int start = header->visualIndexAt(rect.left());
-
3688 int end = header->visualIndexAt(rect.right());
executed (the execution status of this line is deduced): int end = header->visualIndexAt(rect.right());
-
3689 if (q->isRightToLeft()) {
evaluated: q->isRightToLeft()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:466
5-466
3690 start = (start == -1 ? header->count() - 1 : start);
evaluated: start == -1
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
3691 end = (end == -1 ? 0 : end);
partially evaluated: end == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
3692 } else {
executed: }
Execution Count:5
5
3693 start = (start == -1 ? 0 : start);
partially evaluated: start == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:466
0-466
3694 end = (end == -1 ? header->count() - 1 : end);
evaluated: end == -1
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:454
12-454
3695 }
executed: }
Execution Count:466
466
3696 return qMakePair<int,int>(qMin(start, end), qMax(start, end));
executed: return qMakePair<int,int>(qMin(start, end), qMax(start, end));
Execution Count:471
471
3697} -
3698 -
3699bool QTreeViewPrivate::hasVisibleChildren(const QModelIndex& parent) const -
3700{ -
3701 Q_Q(const QTreeView);
executed (the execution status of this line is deduced): const QTreeView * const q = q_func();
-
3702 if (model->hasChildren(parent)) {
evaluated: model->hasChildren(parent)
TRUEFALSE
yes
Evaluation Count:2199
yes
Evaluation Count:11754
2199-11754
3703 if (hiddenIndexes.isEmpty())
evaluated: hiddenIndexes.isEmpty()
TRUEFALSE
yes
Evaluation Count:2008
yes
Evaluation Count:191
191-2008
3704 return true;
executed: return true;
Execution Count:2008
2008
3705 if (q->isIndexHidden(parent))
evaluated: q->isIndexHidden(parent)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:177
14-177
3706 return false;
executed: return false;
Execution Count:14
14
3707 int rowCount = model->rowCount(parent);
executed (the execution status of this line is deduced): int rowCount = model->rowCount(parent);
-
3708 for (int i = 0; i < rowCount; ++i) {
evaluated: i < rowCount
TRUEFALSE
yes
Evaluation Count:459
yes
Evaluation Count:17
17-459
3709 if (!q->isRowHidden(i, parent))
evaluated: !q->isRowHidden(i, parent)
TRUEFALSE
yes
Evaluation Count:160
yes
Evaluation Count:299
160-299
3710 return true;
executed: return true;
Execution Count:160
160
3711 }
executed: }
Execution Count:299
299
3712 if (rowCount == 0)
partially evaluated: rowCount == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
3713 return true;
never executed: return true;
0
3714 }
executed: }
Execution Count:17
17
3715 return false;
executed: return false;
Execution Count:11771
11771
3716} -
3717 -
3718void QTreeViewPrivate::_q_sortIndicatorChanged(int column, Qt::SortOrder order) -
3719{ -
3720 model->sort(column, order);
executed (the execution status of this line is deduced): model->sort(column, order);
-
3721}
executed: }
Execution Count:548
548
3722 -
3723/*! -
3724 \reimp -
3725 */ -
3726void QTreeView::currentChanged(const QModelIndex &current, const QModelIndex &previous) -
3727{ -
3728 QAbstractItemView::currentChanged(current, previous);
executed (the execution status of this line is deduced): QAbstractItemView::currentChanged(current, previous);
-
3729 -
3730 if (allColumnsShowFocus()) {
partially evaluated: allColumnsShowFocus()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:468
0-468
3731 if (previous.isValid()) {
never evaluated: previous.isValid()
0
3732 QRect previousRect = visualRect(previous);
never executed (the execution status of this line is deduced): QRect previousRect = visualRect(previous);
-
3733 previousRect.setX(0);
never executed (the execution status of this line is deduced): previousRect.setX(0);
-
3734 previousRect.setWidth(viewport()->width());
never executed (the execution status of this line is deduced): previousRect.setWidth(viewport()->width());
-
3735 viewport()->update(previousRect);
never executed (the execution status of this line is deduced): viewport()->update(previousRect);
-
3736 }
never executed: }
0
3737 if (current.isValid()) {
never evaluated: current.isValid()
0
3738 QRect currentRect = visualRect(current);
never executed (the execution status of this line is deduced): QRect currentRect = visualRect(current);
-
3739 currentRect.setX(0);
never executed (the execution status of this line is deduced): currentRect.setX(0);
-
3740 currentRect.setWidth(viewport()->width());
never executed (the execution status of this line is deduced): currentRect.setWidth(viewport()->width());
-
3741 viewport()->update(currentRect);
never executed (the execution status of this line is deduced): viewport()->update(currentRect);
-
3742 }
never executed: }
0
3743 }
never executed: }
0
3744#ifndef QT_NO_ACCESSIBILITY -
3745 if (QAccessible::isActive() && current.isValid()) {
evaluated: QAccessible::isActive()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:467
partially evaluated: current.isValid()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-467
3746 int entry = (visualIndex(current) + (header()?1:0))*current.model()->columnCount()+current.column();
partially evaluated: header()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
3747 QAccessibleEvent event(this, QAccessible::Focus);
executed (the execution status of this line is deduced): QAccessibleEvent event(this, QAccessible::Focus);
-
3748 event.setChild(entry);
executed (the execution status of this line is deduced): event.setChild(entry);
-
3749 QAccessible::updateAccessibility(&event);
executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event);
-
3750 }
executed: }
Execution Count:1
1
3751#endif -
3752}
executed: }
Execution Count:468
468
3753 -
3754/*! -
3755 \reimp -
3756 */ -
3757void QTreeView::selectionChanged(const QItemSelection &selected, -
3758 const QItemSelection &deselected) -
3759{ -
3760 QAbstractItemView::selectionChanged(selected, deselected);
executed (the execution status of this line is deduced): QAbstractItemView::selectionChanged(selected, deselected);
-
3761#ifndef QT_NO_ACCESSIBILITY -
3762 if (QAccessible::isActive()) {
partially evaluated: QAccessible::isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:556
0-556
3763 // ### does not work properly for selection ranges. -
3764 QModelIndex sel = selected.indexes().value(0);
never executed (the execution status of this line is deduced): QModelIndex sel = selected.indexes().value(0);
-
3765 if (sel.isValid()) {
never evaluated: sel.isValid()
0
3766 int entry = (visualIndex(sel) + (header()?1:0))*sel.model()->columnCount()+sel.column();
never evaluated: header()
0
3767 Q_ASSERT(entry >= 0);
never executed (the execution status of this line is deduced): qt_noop();
-
3768 QAccessibleEvent event(this, QAccessible::Selection);
never executed (the execution status of this line is deduced): QAccessibleEvent event(this, QAccessible::Selection);
-
3769 event.setChild(entry);
never executed (the execution status of this line is deduced): event.setChild(entry);
-
3770 QAccessible::updateAccessibility(&event);
never executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event);
-
3771 }
never executed: }
0
3772 QModelIndex desel = deselected.indexes().value(0);
never executed (the execution status of this line is deduced): QModelIndex desel = deselected.indexes().value(0);
-
3773 if (desel.isValid()) {
never evaluated: desel.isValid()
0
3774 int entry = (visualIndex(desel) + (header()?1:0))*desel.model()->columnCount()+desel.column();
never evaluated: header()
0
3775 Q_ASSERT(entry >= 0);
never executed (the execution status of this line is deduced): qt_noop();
-
3776 QAccessibleEvent event(this, QAccessible::SelectionRemove);
never executed (the execution status of this line is deduced): QAccessibleEvent event(this, QAccessible::SelectionRemove);
-
3777 event.setChild(entry);
never executed (the execution status of this line is deduced): event.setChild(entry);
-
3778 QAccessible::updateAccessibility(&event);
never executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event);
-
3779 }
never executed: }
0
3780 }
never executed: }
0
3781#endif -
3782}
executed: }
Execution Count:556
556
3783 -
3784int QTreeView::visualIndex(const QModelIndex &index) const -
3785{ -
3786 Q_D(const QTreeView);
executed (the execution status of this line is deduced): const QTreeViewPrivate * const d = d_func();
-
3787 d->executePostedLayout();
executed (the execution status of this line is deduced): d->executePostedLayout();
-
3788 return d->viewIndex(index);
executed: return d->viewIndex(index);
Execution Count:1
1
3789} -
3790 -
3791QT_END_NAMESPACE -
3792 -
3793#include "moc_qtreeview.cpp" -
3794 -
3795#endif // QT_NO_TREEVIEW -
3796 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial