qlistview.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/itemviews/qlistview.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2013 Samuel Gaist <samuel.gaist@deltech.ch>-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtWidgets module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include "qlistview.h"-
42-
43#ifndef QT_NO_LISTVIEW-
44#include <qabstractitemdelegate.h>-
45#include <qapplication.h>-
46#include <qpainter.h>-
47#include <qbitmap.h>-
48#include <qdrag.h>-
49#include <qvector.h>-
50#include <qstyle.h>-
51#include <qevent.h>-
52#include <qscrollbar.h>-
53#include <qrubberband.h>-
54#include <private/qlistview_p.h>-
55#include <private/qscrollbar_p.h>-
56#include <qdebug.h>-
57#ifndef QT_NO_ACCESSIBILITY-
58#include <qaccessible.h>-
59#endif-
60-
61#include <algorithm>-
62-
63QT_BEGIN_NAMESPACE-
64-
65extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);-
66-
67/*!-
68 \class QListView-
69-
70 \brief The QListView class provides a list or icon view onto a model.-
71-
72 \ingroup model-view-
73 \ingroup advanced-
74 \inmodule QtWidgets-
75-
76 A QListView presents items stored in a model, either as a simple-
77 non-hierarchical list, or as a collection of icons. This class is used-
78 to provide lists and icon views that were previously provided by the-
79 \c QListBox and \c QIconView classes, but using the more flexible-
80 approach provided by Qt's model/view architecture.-
81-
82 The QListView class is one of the \l{Model/View Classes}-
83 and is part of Qt's \l{Model/View Programming}{model/view framework}.-
84-
85 This view does not display horizontal or vertical headers; to display-
86 a list of items with a horizontal header, use QTreeView instead.-
87-
88 QListView implements the interfaces defined by the-
89 QAbstractItemView class to allow it to display data provided by-
90 models derived from the QAbstractItemModel class.-
91-
92 Items in a list view can be displayed using one of two view modes:-
93 In \l ListMode, the items are displayed in the form of a simple list;-
94 in \l IconMode, the list view takes the form of an \e{icon view} in-
95 which the items are displayed with icons like files in a file manager.-
96 By default, the list view is in \l ListMode. To change the view mode,-
97 use the setViewMode() function, and to determine the current view mode,-
98 use viewMode().-
99-
100 Items in these views are laid out in the direction specified by the-
101 flow() of the list view. The items may be fixed in place, or allowed-
102 to move, depending on the view's movement() state.-
103-
104 If the items in the model cannot be completely laid out in the-
105 direction of flow, they can be wrapped at the boundary of the view-
106 widget; this depends on isWrapping(). This property is useful when the-
107 items are being represented by an icon view.-
108-
109 The resizeMode() and layoutMode() govern how and when the items are-
110 laid out. Items are spaced according to their spacing(), and can exist-
111 within a notional grid of size specified by gridSize(). The items can-
112 be rendered as large or small icons depending on their iconSize().-
113-
114 \table 100%-
115 \row \li \inlineimage windowsvista-listview.png Screenshot of a Windows Vista style list view-
116 \li \inlineimage macintosh-listview.png Screenshot of a Macintosh style table view-
117 \li \inlineimage fusion-listview.png Screenshot of a Fusion style table view-
118 \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} list view.-
119 \li A \l{Macintosh Style Widget Gallery}{Macintosh style} list view.-
120 \li A \l{Fusion Style Widget Gallery}{Fusion style} list view.-
121 \endtable-
122-
123 \section1 Improving Performance-
124-
125 It is possible to give the view hints about the data it is handling in order-
126 to improve its performance when displaying large numbers of items. One approach-
127 that can be taken for views that are intended to display items with equal sizes-
128 is to set the \l uniformItemSizes property to true.-
129-
130 \sa {View Classes}, {Item Views Puzzle Example}, QTreeView, QTableView, QListWidget-
131*/-
132-
133/*!-
134 \enum QListView::ViewMode-
135-
136 \value ListMode The items are laid out using TopToBottom flow, with Small size and Static movement-
137 \value IconMode The items are laid out using LeftToRight flow, with Large size and Free movement-
138*/-
139-
140/*!-
141 \enum QListView::Movement-
142-
143 \value Static The items cannot be moved by the user.-
144 \value Free The items can be moved freely by the user.-
145 \value Snap The items snap to the specified grid when moved; see-
146 setGridSize().-
147*/-
148-
149/*!-
150 \enum QListView::Flow-
151-
152 \value LeftToRight The items are laid out in the view from the left-
153 to the right.-
154 \value TopToBottom The items are laid out in the view from the top-
155 to the bottom.-
156*/-
157-
158/*!-
159 \enum QListView::ResizeMode-
160-
161 \value Fixed The items will only be laid out the first time the view is shown.-
162 \value Adjust The items will be laid out every time the view is resized.-
163*/-
164-
165/*!-
166 \enum QListView::LayoutMode-
167-
168 \value SinglePass The items are laid out all at once.-
169 \value Batched The items are laid out in batches of \l batchSize items.-
170 \sa batchSize-
171*/-
172-
173/*!-
174 \since 4.2-
175 \fn void QListView::indexesMoved(const QModelIndexList &indexes)-
176-
177 This signal is emitted when the specified \a indexes are moved in the view.-
178*/-
179-
180/*!-
181 Creates a new QListView with the given \a parent to view a model.-
182 Use setModel() to set the model.-
183*/-
184QListView::QListView(QWidget *parent)-
185 : QAbstractItemView(*new QListViewPrivate, parent)-
186{-
187 setViewMode(ListMode);-
188 setSelectionMode(SingleSelection);-
189 setAttribute(Qt::WA_MacShowFocusRect);-
190 Q_D(QListView); // We rely on a qobject_cast for PM_DefaultFrameWidth to change-
191 d->updateStyledFrameWidths(); // hence we have to force an update now that the object has been constructed-
192}
never executed: end of block
0
193-
194/*!-
195 \internal-
196*/-
197QListView::QListView(QListViewPrivate &dd, QWidget *parent)-
198 : QAbstractItemView(dd, parent)-
199{-
200 setViewMode(ListMode);-
201 setSelectionMode(SingleSelection);-
202 setAttribute(Qt::WA_MacShowFocusRect);-
203 Q_D(QListView); // We rely on a qobject_cast for PM_DefaultFrameWidth to change-
204 d->updateStyledFrameWidths(); // hence we have to force an update now that the object has been constructed-
205}
never executed: end of block
0
206-
207/*!-
208 Destroys the view.-
209*/-
210QListView::~QListView()-
211{-
212}-
213-
214/*!-
215 \property QListView::movement-
216 \brief whether the items can be moved freely, are snapped to a-
217 grid, or cannot be moved at all.-
218-
219 This property determines how the user can move the items in the-
220 view. \l Static means that the items can't be moved the user. \l-
221 Free means that the user can drag and drop the items to any-
222 position in the view. \l Snap means that the user can drag and-
223 drop the items, but only to the positions in a notional grid-
224 signified by the gridSize property.-
225-
226 Setting this property when the view is visible will cause the-
227 items to be laid out again.-
228-
229 By default, this property is set to \l Static.-
230-
231 \sa gridSize, resizeMode, viewMode-
232*/-
233void QListView::setMovement(Movement movement)-
234{-
235 Q_D(QListView);-
236 d->modeProperties |= uint(QListViewPrivate::Movement);-
237 d->movement = movement;-
238-
239#ifndef QT_NO_DRAGANDDROP-
240 bool movable = (movement != Static);-
241 setDragEnabled(movable);-
242 d->viewport->setAcceptDrops(movable);-
243#endif-
244 d->doDelayedItemsLayout();-
245}
never executed: end of block
0
246-
247QListView::Movement QListView::movement() const-
248{-
249 Q_D(const QListView);-
250 return d->movement;
never executed: return d->movement;
0
251}-
252-
253/*!-
254 \property QListView::flow-
255 \brief which direction the items layout should flow.-
256-
257 If this property is \l LeftToRight, the items will be laid out left-
258 to right. If the \l isWrapping property is \c true, the layout will wrap-
259 when it reaches the right side of the visible area. If this-
260 property is \l TopToBottom, the items will be laid out from the top-
261 of the visible area, wrapping when it reaches the bottom.-
262-
263 Setting this property when the view is visible will cause the-
264 items to be laid out again.-
265-
266 By default, this property is set to \l TopToBottom.-
267-
268 \sa viewMode-
269*/-
270void QListView::setFlow(Flow flow)-
271{-
272 Q_D(QListView);-
273 d->modeProperties |= uint(QListViewPrivate::Flow);-
274 d->flow = flow;-
275 d->doDelayedItemsLayout();-
276}
never executed: end of block
0
277-
278QListView::Flow QListView::flow() const-
279{-
280 Q_D(const QListView);-
281 return d->flow;
never executed: return d->flow;
0
282}-
283-
284/*!-
285 \property QListView::isWrapping-
286 \brief whether the items layout should wrap.-
287-
288 This property holds whether the layout should wrap when there is-
289 no more space in the visible area. The point at which the layout wraps-
290 depends on the \l flow property.-
291-
292 Setting this property when the view is visible will cause the-
293 items to be laid out again.-
294-
295 By default, this property is \c false.-
296-
297 \sa viewMode-
298*/-
299void QListView::setWrapping(bool enable)-
300{-
301 Q_D(QListView);-
302 d->modeProperties |= uint(QListViewPrivate::Wrap);-
303 d->setWrapping(enable);-
304 d->doDelayedItemsLayout();-
305}
never executed: end of block
0
306-
307bool QListView::isWrapping() const-
308{-
309 Q_D(const QListView);-
310 return d->isWrapping();
never executed: return d->isWrapping();
0
311}-
312-
313/*!-
314 \property QListView::resizeMode-
315 \brief whether the items are laid out again when the view is resized.-
316-
317 If this property is \l Adjust, the items will be laid out again-
318 when the view is resized. If the value is \l Fixed, the items will-
319 not be laid out when the view is resized.-
320-
321 By default, this property is set to \l Fixed.-
322-
323 \sa movement, gridSize, viewMode-
324*/-
325void QListView::setResizeMode(ResizeMode mode)-
326{-
327 Q_D(QListView);-
328 d->modeProperties |= uint(QListViewPrivate::ResizeMode);-
329 d->resizeMode = mode;-
330}
never executed: end of block
0
331-
332QListView::ResizeMode QListView::resizeMode() const-
333{-
334 Q_D(const QListView);-
335 return d->resizeMode;
never executed: return d->resizeMode;
0
336}-
337-
338/*!-
339 \property QListView::layoutMode-
340 \brief determines whether the layout of items should happen immediately or be delayed.-
341-
342 This property holds the layout mode for the items. When the mode-
343 is \l SinglePass (the default), the items are laid out all in one go.-
344 When the mode is \l Batched, the items are laid out in batches of \l batchSize-
345 items, while processing events. This makes it possible to-
346 instantly view and interact with the visible items while the rest-
347 are being laid out.-
348-
349 \sa viewMode-
350*/-
351void QListView::setLayoutMode(LayoutMode mode)-
352{-
353 Q_D(QListView);-
354 d->layoutMode = mode;-
355}
never executed: end of block
0
356-
357QListView::LayoutMode QListView::layoutMode() const-
358{-
359 Q_D(const QListView);-
360 return d->layoutMode;
never executed: return d->layoutMode;
0
361}-
362-
363/*!-
364 \property QListView::spacing-
365 \brief the space around the items in the layout-
366-
367 This property is the size of the empty space that is padded around-
368 an item in the layout.-
369-
370 Setting this property when the view is visible will cause the-
371 items to be laid out again.-
372-
373 By default, this property contains a value of 0.-
374-
375 \sa viewMode-
376*/-
377void QListView::setSpacing(int space)-
378{-
379 Q_D(QListView);-
380 d->modeProperties |= uint(QListViewPrivate::Spacing);-
381 d->setSpacing(space);-
382 d->doDelayedItemsLayout();-
383}
never executed: end of block
0
384-
385int QListView::spacing() const-
386{-
387 Q_D(const QListView);-
388 return d->spacing();
never executed: return d->spacing();
0
389}-
390-
391/*!-
392 \property QListView::batchSize-
393 \brief the number of items laid out in each batch if \l layoutMode is-
394 set to \l Batched-
395-
396 The default value is 100.-
397-
398 \since 4.2-
399*/-
400-
401void QListView::setBatchSize(int batchSize)-
402{-
403 Q_D(QListView);-
404 if (Q_UNLIKELY(batchSize <= 0)) {
__builtin_expe... <= 0), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
405 qWarning("Invalid batchSize (%d)", batchSize);-
406 return;
never executed: return;
0
407 }-
408 d->batchSize = batchSize;-
409}
never executed: end of block
0
410-
411int QListView::batchSize() const-
412{-
413 Q_D(const QListView);-
414 return d->batchSize;
never executed: return d->batchSize;
0
415}-
416-
417/*!-
418 \property QListView::gridSize-
419 \brief the size of the layout grid-
420-
421 This property is the size of the grid in which the items are laid-
422 out. The default is an empty size which means that there is no-
423 grid and the layout is not done in a grid. Setting this property-
424 to a non-empty size switches on the grid layout. (When a grid-
425 layout is in force the \l spacing property is ignored.)-
426-
427 Setting this property when the view is visible will cause the-
428 items to be laid out again.-
429-
430 \sa viewMode-
431*/-
432void QListView::setGridSize(const QSize &size)-
433{-
434 Q_D(QListView);-
435 d->modeProperties |= uint(QListViewPrivate::GridSize);-
436 d->setGridSize(size);-
437 d->doDelayedItemsLayout();-
438}
never executed: end of block
0
439-
440QSize QListView::gridSize() const-
441{-
442 Q_D(const QListView);-
443 return d->gridSize();
never executed: return d->gridSize();
0
444}-
445-
446/*!-
447 \property QListView::viewMode-
448 \brief the view mode of the QListView.-
449-
450 This property will change the other unset properties to conform-
451 with the set view mode. QListView-specific properties that have already been set-
452 will not be changed, unless clearPropertyFlags() has been called.-
453-
454 Setting the view mode will enable or disable drag and drop based on the-
455 selected movement. For ListMode, the default movement is \l Static-
456 (drag and drop disabled); for IconMode, the default movement is-
457 \l Free (drag and drop enabled).-
458-
459 \sa isWrapping, spacing, gridSize, flow, movement, resizeMode-
460*/-
461void QListView::setViewMode(ViewMode mode)-
462{-
463 Q_D(QListView);-
464 if (d->commonListView && d->viewMode == mode)
d->commonListViewDescription
TRUEnever evaluated
FALSEnever evaluated
d->viewMode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
465 return;
never executed: return;
0
466 d->viewMode = mode;-
467-
468 delete d->commonListView;-
469 if (mode == ListMode) {
mode == ListModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
470 d->commonListView = new QListModeViewBase(this, d);-
471 if (!(d->modeProperties & QListViewPrivate::Wrap))
!(d->modePrope...Private::Wrap)Description
TRUEnever evaluated
FALSEnever evaluated
0
472 d->setWrapping(false);
never executed: d->setWrapping(false);
0
473 if (!(d->modeProperties & QListViewPrivate::Spacing))
!(d->modePrope...vate::Spacing)Description
TRUEnever evaluated
FALSEnever evaluated
0
474 d->setSpacing(0);
never executed: d->setSpacing(0);
0
475 if (!(d->modeProperties & QListViewPrivate::GridSize))
!(d->modePrope...ate::GridSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
476 d->setGridSize(QSize());
never executed: d->setGridSize(QSize());
0
477 if (!(d->modeProperties & QListViewPrivate::Flow))
!(d->modePrope...Private::Flow)Description
TRUEnever evaluated
FALSEnever evaluated
0
478 d->flow = TopToBottom;
never executed: d->flow = TopToBottom;
0
479 if (!(d->modeProperties & QListViewPrivate::Movement))
!(d->modePrope...ate::Movement)Description
TRUEnever evaluated
FALSEnever evaluated
0
480 d->movement = Static;
never executed: d->movement = Static;
0
481 if (!(d->modeProperties & QListViewPrivate::ResizeMode))
!(d->modePrope...e::ResizeMode)Description
TRUEnever evaluated
FALSEnever evaluated
0
482 d->resizeMode = Fixed;
never executed: d->resizeMode = Fixed;
0
483 if (!(d->modeProperties & QListViewPrivate::SelectionRectVisible))
!(d->modePrope...onRectVisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
484 d->showElasticBand = false;
never executed: d->showElasticBand = false;
0
485 } else {
never executed: end of block
0
486 d->commonListView = new QIconModeViewBase(this, d);-
487 if (!(d->modeProperties & QListViewPrivate::Wrap))
!(d->modePrope...Private::Wrap)Description
TRUEnever evaluated
FALSEnever evaluated
0
488 d->setWrapping(true);
never executed: d->setWrapping(true);
0
489 if (!(d->modeProperties & QListViewPrivate::Spacing))
!(d->modePrope...vate::Spacing)Description
TRUEnever evaluated
FALSEnever evaluated
0
490 d->setSpacing(0);
never executed: d->setSpacing(0);
0
491 if (!(d->modeProperties & QListViewPrivate::GridSize))
!(d->modePrope...ate::GridSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
492 d->setGridSize(QSize());
never executed: d->setGridSize(QSize());
0
493 if (!(d->modeProperties & QListViewPrivate::Flow))
!(d->modePrope...Private::Flow)Description
TRUEnever evaluated
FALSEnever evaluated
0
494 d->flow = LeftToRight;
never executed: d->flow = LeftToRight;
0
495 if (!(d->modeProperties & QListViewPrivate::Movement))
!(d->modePrope...ate::Movement)Description
TRUEnever evaluated
FALSEnever evaluated
0
496 d->movement = Free;
never executed: d->movement = Free;
0
497 if (!(d->modeProperties & QListViewPrivate::ResizeMode))
!(d->modePrope...e::ResizeMode)Description
TRUEnever evaluated
FALSEnever evaluated
0
498 d->resizeMode = Fixed;
never executed: d->resizeMode = Fixed;
0
499 if (!(d->modeProperties & QListViewPrivate::SelectionRectVisible))
!(d->modePrope...onRectVisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
500 d->showElasticBand = true;
never executed: d->showElasticBand = true;
0
501 }
never executed: end of block
0
502-
503#ifndef QT_NO_DRAGANDDROP-
504 bool movable = (d->movement != Static);-
505 setDragEnabled(movable);-
506 setAcceptDrops(movable);-
507#endif-
508 d->clear();-
509 d->doDelayedItemsLayout();-
510}
never executed: end of block
0
511-
512QListView::ViewMode QListView::viewMode() const-
513{-
514 Q_D(const QListView);-
515 return d->viewMode;
never executed: return d->viewMode;
0
516}-
517-
518/*!-
519 Clears the QListView-specific property flags. See \l{viewMode}.-
520-
521 Properties inherited from QAbstractItemView are not covered by the-
522 property flags. Specifically, \l{QAbstractItemView::dragEnabled}-
523 {dragEnabled} and \l{QAbstractItemView::acceptDrops}-
524 {acceptsDrops} are computed by QListView when calling-
525 setMovement() or setViewMode().-
526*/-
527void QListView::clearPropertyFlags()-
528{-
529 Q_D(QListView);-
530 d->modeProperties = 0;-
531}
never executed: end of block
0
532-
533/*!-
534 Returns \c true if the \a row is hidden; otherwise returns \c false.-
535*/-
536bool QListView::isRowHidden(int row) const-
537{-
538 Q_D(const QListView);-
539 return d->isHidden(row);
never executed: return d->isHidden(row);
0
540}-
541-
542/*!-
543 If \a hide is true, the given \a row will be hidden; otherwise-
544 the \a row will be shown.-
545*/-
546void QListView::setRowHidden(int row, bool hide)-
547{-
548 Q_D(QListView);-
549 const bool hidden = d->isHidden(row);-
550 if (hide && !hidden)
hideDescription
TRUEnever evaluated
FALSEnever evaluated
!hiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
551 d->commonListView->appendHiddenRow(row);
never executed: d->commonListView->appendHiddenRow(row);
0
552 else if (!hide && hidden)
!hideDescription
TRUEnever evaluated
FALSEnever evaluated
hiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
553 d->commonListView->removeHiddenRow(row);
never executed: d->commonListView->removeHiddenRow(row);
0
554 d->doDelayedItemsLayout();-
555 d->viewport->update();-
556}
never executed: end of block
0
557-
558/*!-
559 \reimp-
560*/-
561QRect QListView::visualRect(const QModelIndex &index) const-
562{-
563 Q_D(const QListView);-
564 return d->mapToViewport(rectForIndex(index));
never executed: return d->mapToViewport(rectForIndex(index));
0
565}-
566-
567/*!-
568 \reimp-
569*/-
570void QListView::scrollTo(const QModelIndex &index, ScrollHint hint)-
571{-
572 Q_D(QListView);-
573-
574 if (index.parent() != d->root || index.column() != d->column)
index.parent() != d->rootDescription
TRUEnever evaluated
FALSEnever evaluated
index.column() != d->columnDescription
TRUEnever evaluated
FALSEnever evaluated
0
575 return;
never executed: return;
0
576-
577 const QRect rect = visualRect(index);-
578 if (hint == EnsureVisible && d->viewport->rect().contains(rect)) {
hint == EnsureVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
d->viewport->r...contains(rect)Description
TRUEnever evaluated
FALSEnever evaluated
0
579 d->viewport->update(rect);-
580 return;
never executed: return;
0
581 }-
582-
583 if (d->flow == QListView::TopToBottom || d->isWrapping()) // vertical
d->flow == QLi...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
d->isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
584 verticalScrollBar()->setValue(d->verticalScrollToValue(index, rect, hint));
never executed: verticalScrollBar()->setValue(d->verticalScrollToValue(index, rect, hint));
0
585-
586 if (d->flow == QListView::LeftToRight || d->isWrapping()) // horizontal
d->flow == QLi...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
d->isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
587 horizontalScrollBar()->setValue(d->horizontalScrollToValue(index, rect, hint));
never executed: horizontalScrollBar()->setValue(d->horizontalScrollToValue(index, rect, hint));
0
588}
never executed: end of block
0
589-
590int QListViewPrivate::horizontalScrollToValue(const QModelIndex &index, const QRect &rect,-
591 QListView::ScrollHint hint) const-
592{-
593 Q_Q(const QListView);-
594 const QRect area = viewport->rect();-
595 const bool leftOf = q->isRightToLeft()
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
596 ? (rect.left() < area.left()) && (rect.right() < area.right())
(rect.left() < area.left())Description
TRUEnever evaluated
FALSEnever evaluated
(rect.right() < area.right())Description
TRUEnever evaluated
FALSEnever evaluated
0
597 : rect.left() < area.left();-
598 const bool rightOf = q->isRightToLeft()
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
599 ? rect.right() > area.right()-
600 : (rect.right() > area.right()) && (rect.left() > area.left());
(rect.right() > area.right())Description
TRUEnever evaluated
FALSEnever evaluated
(rect.left() > area.left())Description
TRUEnever evaluated
FALSEnever evaluated
0
601 return commonListView->horizontalScrollToValue(q->visualIndex(index), hint, leftOf, rightOf, area, rect);
never executed: return commonListView->horizontalScrollToValue(q->visualIndex(index), hint, leftOf, rightOf, area, rect);
0
602}-
603-
604int QListViewPrivate::verticalScrollToValue(const QModelIndex &index, const QRect &rect,-
605 QListView::ScrollHint hint) const-
606{-
607 Q_Q(const QListView);-
608 const QRect area = viewport->rect();-
609 const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top());
hint == QListV...:EnsureVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
rect.top() < area.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
610 const bool below = (hint == QListView::EnsureVisible && rect.bottom() > area.bottom());
hint == QListV...:EnsureVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
rect.bottom() > area.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
611 return commonListView->verticalScrollToValue(q->visualIndex(index), hint, above, below, area, rect);
never executed: return commonListView->verticalScrollToValue(q->visualIndex(index), hint, above, below, area, rect);
0
612}-
613-
614void QListViewPrivate::selectAll(QItemSelectionModel::SelectionFlags command)-
615{-
616 if (!selectionModel)
!selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
617 return;
never executed: return;
0
618-
619 QItemSelection selection;-
620 QModelIndex topLeft;-
621 int row = 0;-
622 const int colCount = model->columnCount(root);-
623 for(; row < model->rowCount(root); ++row) {
row < model->rowCount(root)Description
TRUEnever evaluated
FALSEnever evaluated
0
624 if (isHidden(row)) {
isHidden(row)Description
TRUEnever evaluated
FALSEnever evaluated
0
625 //it might be the end of a selection range-
626 if (topLeft.isValid()) {
topLeft.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
627 QModelIndex bottomRight = model->index(row - 1, colCount - 1, root);-
628 selection.append(QItemSelectionRange(topLeft, bottomRight));-
629 topLeft = QModelIndex();-
630 }
never executed: end of block
0
631 continue;
never executed: continue;
0
632 }-
633-
634 if (!topLeft.isValid()) //start of a new selection range
!topLeft.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
635 topLeft = model->index(row, 0, root);
never executed: topLeft = model->index(row, 0, root);
0
636 }
never executed: end of block
0
637-
638 if (topLeft.isValid()) {
topLeft.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
639 //last selected range-
640 QModelIndex bottomRight = model->index(row - 1, colCount - 1, root);-
641 selection.append(QItemSelectionRange(topLeft, bottomRight));-
642 }
never executed: end of block
0
643-
644 if (!selection.isEmpty())
!selection.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
645 selectionModel->select(selection, command);
never executed: selectionModel->select(selection, command);
0
646}
never executed: end of block
0
647-
648/*!-
649 \reimp-
650-
651 We have a QListView way of knowing what elements are on the viewport-
652 through the intersectingSet function-
653*/-
654QItemViewPaintPairs QListViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const-
655{-
656 Q_ASSERT(r);-
657 Q_Q(const QListView);-
658 QRect &rect = *r;-
659 const QRect viewportRect = viewport->rect();-
660 QItemViewPaintPairs ret;-
661 QVector<QModelIndex> visibleIndexes = intersectingSet(viewportRect.translated(q->horizontalOffset(), q->verticalOffset()));-
662 std::sort(visibleIndexes.begin(), visibleIndexes.end());-
663 for (const auto &index : indexes) {-
664 if (std::binary_search(visibleIndexes.cbegin(), visibleIndexes.cend(), index)) {
std::binary_se...cend(), index)Description
TRUEnever evaluated
FALSEnever evaluated
0
665 const QRect current = q->visualRect(index);-
666 QItemViewPaintPair p = { current, index };-
667 ret += p;-
668 rect |= current;-
669 }
never executed: end of block
0
670 }
never executed: end of block
0
671 rect &= viewportRect;-
672 return ret;
never executed: return ret;
0
673}-
674-
675/*!-
676 \internal-
677*/-
678void QListView::reset()-
679{-
680 Q_D(QListView);-
681 d->clear();-
682 d->hiddenRows.clear();-
683 QAbstractItemView::reset();-
684}
never executed: end of block
0
685-
686/*!-
687 \internal-
688*/-
689void QListView::setRootIndex(const QModelIndex &index)-
690{-
691 Q_D(QListView);-
692 d->column = qBound(0, d->column, d->model->columnCount(index) - 1);-
693 QAbstractItemView::setRootIndex(index);-
694 // sometimes we get an update before reset() is called-
695 d->clear();-
696 d->hiddenRows.clear();-
697}
never executed: end of block
0
698-
699/*!-
700 \internal-
701-
702 Scroll the view contents by \a dx and \a dy.-
703*/-
704-
705void QListView::scrollContentsBy(int dx, int dy)-
706{-
707 Q_D(QListView);-
708 d->delayedAutoScroll.stop(); // auto scroll was canceled by the user scrolling-
709 d->commonListView->scrollContentsBy(dx, dy, d->state == QListView::DragSelectingState);-
710}
never executed: end of block
0
711-
712/*!-
713 \internal-
714-
715 Resize the internal contents to \a width and \a height and set the-
716 scroll bar ranges accordingly.-
717*/-
718void QListView::resizeContents(int width, int height)-
719{-
720 Q_D(QListView);-
721 d->setContentsSize(width, height);-
722}
never executed: end of block
0
723-
724/*!-
725 \internal-
726*/-
727QSize QListView::contentsSize() const-
728{-
729 Q_D(const QListView);-
730 return d->contentsSize();
never executed: return d->contentsSize();
0
731}-
732-
733/*!-
734 \reimp-
735*/-
736void QListView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)-
737{-
738 d_func()->commonListView->dataChanged(topLeft, bottomRight);-
739 QAbstractItemView::dataChanged(topLeft, bottomRight, roles);-
740}
never executed: end of block
0
741-
742/*!-
743 \reimp-
744*/-
745void QListView::rowsInserted(const QModelIndex &parent, int start, int end)-
746{-
747 Q_D(QListView);-
748 // ### be smarter about inserted items-
749 d->clear();-
750 d->doDelayedItemsLayout();-
751 QAbstractItemView::rowsInserted(parent, start, end);-
752}
never executed: end of block
0
753-
754/*!-
755 \reimp-
756*/-
757void QListView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)-
758{-
759 Q_D(QListView);-
760 // if the parent is above d->root in the tree, nothing will happen-
761 QAbstractItemView::rowsAboutToBeRemoved(parent, start, end);-
762 if (parent == d->root) {
parent == d->rootDescription
TRUEnever evaluated
FALSEnever evaluated
0
763 QSet<QPersistentModelIndex>::iterator it = d->hiddenRows.begin();-
764 while (it != d->hiddenRows.end()) {
it != d->hiddenRows.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
765 int hiddenRow = it->row();-
766 if (hiddenRow >= start && hiddenRow <= end) {
hiddenRow >= startDescription
TRUEnever evaluated
FALSEnever evaluated
hiddenRow <= endDescription
TRUEnever evaluated
FALSEnever evaluated
0
767 it = d->hiddenRows.erase(it);-
768 } else {
never executed: end of block
0
769 ++it;-
770 }
never executed: end of block
0
771 }-
772 }
never executed: end of block
0
773 d->clear();-
774 d->doDelayedItemsLayout();-
775}
never executed: end of block
0
776-
777/*!-
778 \reimp-
779*/-
780void QListView::mouseMoveEvent(QMouseEvent *e)-
781{-
782 if (!isVisible())
!isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
783 return;
never executed: return;
0
784 Q_D(QListView);-
785 QAbstractItemView::mouseMoveEvent(e);-
786 if (state() == DragSelectingState
state() == DragSelectingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
787 && d->showElasticBand
d->showElasticBandDescription
TRUEnever evaluated
FALSEnever evaluated
0
788 && d->selectionMode != SingleSelection
d->selectionMo...ingleSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
789 && d->selectionMode != NoSelection) {
d->selectionMo...!= NoSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
790 QRect rect(d->pressedPosition, e->pos() + QPoint(horizontalOffset(), verticalOffset()));-
791 rect = rect.normalized();-
792 d->viewport->update(d->mapToViewport(rect.united(d->elasticBand)));-
793 d->elasticBand = rect;-
794 }
never executed: end of block
0
795}
never executed: end of block
0
796-
797/*!-
798 \reimp-
799*/-
800void QListView::mouseReleaseEvent(QMouseEvent *e)-
801{-
802 Q_D(QListView);-
803 QAbstractItemView::mouseReleaseEvent(e);-
804 // #### move this implementation into a dynamic class-
805 if (d->showElasticBand && d->elasticBand.isValid()) {
d->showElasticBandDescription
TRUEnever evaluated
FALSEnever evaluated
d->elasticBand.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
806 d->viewport->update(d->mapToViewport(d->elasticBand));-
807 d->elasticBand = QRect();-
808 }
never executed: end of block
0
809}
never executed: end of block
0
810-
811#ifndef QT_NO_WHEELEVENT-
812/*!-
813 \reimp-
814*/-
815void QListView::wheelEvent(QWheelEvent *e)-
816{-
817 Q_D(QListView);-
818 if (e->orientation() == Qt::Vertical) {
e->orientation...= Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
819 if (e->angleDelta().x() == 0
e->angleDelta().x() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
820 && ((d->flow == TopToBottom && d->wrap) || (d->flow == LeftToRight && !d->wrap))
d->flow == TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
d->flow == LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
!d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
821 && d->vbar->minimum() == 0 && d->vbar->maximum() == 0) {
d->vbar->minimum() == 0Description
TRUEnever evaluated
FALSEnever evaluated
d->vbar->maximum() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
822 QPoint pixelDelta(e->pixelDelta().y(), e->pixelDelta().x());-
823 QPoint angleDelta(e->angleDelta().y(), e->angleDelta().x());-
824 QWheelEvent hwe(e->pos(), e->globalPos(), pixelDelta, angleDelta, e->delta(),-
825 Qt::Horizontal, e->buttons(), e->modifiers(), e->phase(), e->source(), e->inverted());-
826 if (e->spontaneous())
e->spontaneous()Description
TRUEnever evaluated
FALSEnever evaluated
0
827 qt_sendSpontaneousEvent(d->hbar, &hwe);
never executed: qt_sendSpontaneousEvent(d->hbar, &hwe);
0
828 else-
829 QApplication::sendEvent(d->hbar, &hwe);
never executed: QApplication::sendEvent(d->hbar, &hwe);
0
830 e->setAccepted(hwe.isAccepted());-
831 } else {
never executed: end of block
0
832 QApplication::sendEvent(d->vbar, e);-
833 }
never executed: end of block
0
834 } else {-
835 QApplication::sendEvent(d->hbar, e);-
836 }
never executed: end of block
0
837}-
838#endif // QT_NO_WHEELEVENT-
839-
840/*!-
841 \reimp-
842*/-
843void QListView::timerEvent(QTimerEvent *e)-
844{-
845 Q_D(QListView);-
846 if (e->timerId() == d->batchLayoutTimer.timerId()) {
e->timerId() =...imer.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
847 if (d->doItemsLayout(d->batchSize)) { // layout is done
d->doItemsLayout(d->batchSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
848 d->batchLayoutTimer.stop();-
849 updateGeometries();-
850 d->viewport->update();-
851 }
never executed: end of block
0
852 }
never executed: end of block
0
853 QAbstractItemView::timerEvent(e);-
854}
never executed: end of block
0
855-
856/*!-
857 \reimp-
858*/-
859void QListView::resizeEvent(QResizeEvent *e)-
860{-
861 Q_D(QListView);-
862 if (d->delayedPendingLayout)
d->delayedPendingLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
863 return;
never executed: return;
0
864-
865 QSize delta = e->size() - e->oldSize();-
866-
867 if (delta.isNull())
delta.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
868 return;
never executed: return;
0
869-
870 bool listWrap = (d->viewMode == ListMode) && d->wrapItemText;
(d->viewMode == ListMode)Description
TRUEnever evaluated
FALSEnever evaluated
d->wrapItemTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
871 bool flowDimensionChanged = (d->flow == LeftToRight && delta.width() != 0)
d->flow == LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
delta.width() != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
872 || (d->flow == TopToBottom && delta.height() != 0);
d->flow == TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
delta.height() != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
873-
874 // We post a delayed relayout in the following cases :-
875 // - we're wrapping-
876 // - the state is NoState, we're adjusting and the size has changed in the flowing direction-
877 if (listWrap
listWrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
878 || (state() == NoState && d->resizeMode == Adjust && flowDimensionChanged)) {
state() == NoStateDescription
TRUEnever evaluated
FALSEnever evaluated
d->resizeMode == AdjustDescription
TRUEnever evaluated
FALSEnever evaluated
flowDimensionChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
879 d->doDelayedItemsLayout(100); // wait 1/10 sec before starting the layout-
880 } else {
never executed: end of block
0
881 QAbstractItemView::resizeEvent(e);-
882 }
never executed: end of block
0
883}-
884-
885#ifndef QT_NO_DRAGANDDROP-
886-
887/*!-
888 \reimp-
889*/-
890void QListView::dragMoveEvent(QDragMoveEvent *e)-
891{-
892 Q_D(QListView);-
893 if (!d->commonListView->filterDragMoveEvent(e)) {
!d->commonList...agMoveEvent(e)Description
TRUEnever evaluated
FALSEnever evaluated
0
894 if (viewMode() == QListView::ListMode && flow() == QListView::LeftToRight)
viewMode() == ...View::ListModeDescription
TRUEnever evaluated
FALSEnever evaluated
flow() == QLis...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
895 static_cast<QListModeViewBase *>(d->commonListView)->dragMoveEvent(e);
never executed: static_cast<QListModeViewBase *>(d->commonListView)->dragMoveEvent(e);
0
896 else-
897 QAbstractItemView::dragMoveEvent(e);
never executed: QAbstractItemView::dragMoveEvent(e);
0
898 }-
899}
never executed: end of block
0
900-
901-
902/*!-
903 \reimp-
904*/-
905void QListView::dragLeaveEvent(QDragLeaveEvent *e)-
906{-
907 if (!d_func()->commonListView->filterDragLeaveEvent(e))
!d_func()->com...gLeaveEvent(e)Description
TRUEnever evaluated
FALSEnever evaluated
0
908 QAbstractItemView::dragLeaveEvent(e);
never executed: QAbstractItemView::dragLeaveEvent(e);
0
909}
never executed: end of block
0
910-
911/*!-
912 \reimp-
913*/-
914void QListView::dropEvent(QDropEvent *e)-
915{-
916 if (!d_func()->commonListView->filterDropEvent(e))
!d_func()->com...erDropEvent(e)Description
TRUEnever evaluated
FALSEnever evaluated
0
917 QAbstractItemView::dropEvent(e);
never executed: QAbstractItemView::dropEvent(e);
0
918}
never executed: end of block
0
919-
920/*!-
921 \reimp-
922*/-
923void QListView::startDrag(Qt::DropActions supportedActions)-
924{-
925 if (!d_func()->commonListView->filterStartDrag(supportedActions))
!d_func()->com...portedActions)Description
TRUEnever evaluated
FALSEnever evaluated
0
926 QAbstractItemView::startDrag(supportedActions);
never executed: QAbstractItemView::startDrag(supportedActions);
0
927}
never executed: end of block
0
928-
929#endif // QT_NO_DRAGANDDROP-
930-
931/*!-
932 \reimp-
933*/-
934QStyleOptionViewItem QListView::viewOptions() const-
935{-
936 Q_D(const QListView);-
937 QStyleOptionViewItem option = QAbstractItemView::viewOptions();-
938 if (!d->iconSize.isValid()) { // otherwise it was already set in abstractitemview
!d->iconSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
939 int pm = (d->viewMode == QListView::ListMode
d->viewMode ==...View::ListModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
940 ? style()->pixelMetric(QStyle::PM_ListViewIconSize, 0, this)-
941 : style()->pixelMetric(QStyle::PM_IconViewIconSize, 0, this));-
942 option.decorationSize = QSize(pm, pm);-
943 }
never executed: end of block
0
944 if (d->viewMode == QListView::IconMode) {
d->viewMode ==...View::IconModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
945 option.showDecorationSelected = false;-
946 option.decorationPosition = QStyleOptionViewItem::Top;-
947 option.displayAlignment = Qt::AlignCenter;-
948 } else {
never executed: end of block
0
949 option.decorationPosition = QStyleOptionViewItem::Left;-
950 }
never executed: end of block
0
951-
952 if (d->gridSize().isValid()) {
d->gridSize().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
953 option.rect.setSize(d->gridSize());-
954 }
never executed: end of block
0
955-
956 return option;
never executed: return option;
0
957}-
958-
959-
960/*!-
961 \reimp-
962*/-
963void QListView::paintEvent(QPaintEvent *e)-
964{-
965 Q_D(QListView);-
966 if (!d->itemDelegate)
!d->itemDelegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
967 return;
never executed: return;
0
968 QStyleOptionViewItem option = d->viewOptionsV1();-
969 QPainter painter(d->viewport);-
970-
971 const QVector<QModelIndex> toBeRendered = d->intersectingSet(e->rect().translated(horizontalOffset(), verticalOffset()), false);-
972-
973 const QModelIndex current = currentIndex();-
974 const QModelIndex hover = d->hover;-
975 const QAbstractItemModel *itemModel = d->model;-
976 const QItemSelectionModel *selections = d->selectionModel;-
977 const bool focus = (hasFocus() || d->viewport->hasFocus()) && current.isValid();
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
d->viewport->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
current.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
978 const bool alternate = d->alternatingColors;-
979 const QStyle::State state = option.state;-
980 const QAbstractItemView::State viewState = this->state();-
981 const bool enabled = (state & QStyle::State_Enabled) != 0;-
982-
983 bool alternateBase = false;-
984 int previousRow = -2; // trigger the alternateBase adjustment on first pass-
985-
986 int maxSize = (flow() == TopToBottom)
(flow() == TopToBottom)Description
TRUEnever evaluated
FALSEnever evaluated
0
987 ? qMax(viewport()->size().width(), d->contentsSize().width()) - 2 * d->spacing()-
988 : qMax(viewport()->size().height(), d->contentsSize().height()) - 2 * d->spacing();-
989-
990 QVector<QModelIndex>::const_iterator end = toBeRendered.constEnd();-
991 for (QVector<QModelIndex>::const_iterator it = toBeRendered.constBegin(); it != end; ++it) {
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
992 Q_ASSERT((*it).isValid());-
993 option.rect = visualRect(*it);-
994-
995 if (flow() == TopToBottom)
flow() == TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
996 option.rect.setWidth(qMin(maxSize, option.rect.width()));
never executed: option.rect.setWidth(qMin(maxSize, option.rect.width()));
0
997 else-
998 option.rect.setHeight(qMin(maxSize, option.rect.height()));
never executed: option.rect.setHeight(qMin(maxSize, option.rect.height()));
0
999-
1000 option.state = state;-
1001 if (selections && selections->isSelected(*it))
selectionsDescription
TRUEnever evaluated
FALSEnever evaluated
selections->isSelected(*it)Description
TRUEnever evaluated
FALSEnever evaluated
0
1002 option.state |= QStyle::State_Selected;
never executed: option.state |= QStyle::State_Selected;
0
1003 if (enabled) {
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1004 QPalette::ColorGroup cg;-
1005 if ((itemModel->flags(*it) & Qt::ItemIsEnabled) == 0) {
(itemModel->fl...sEnabled) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1006 option.state &= ~QStyle::State_Enabled;-
1007 cg = QPalette::Disabled;-
1008 } else {
never executed: end of block
0
1009 cg = QPalette::Normal;-
1010 }
never executed: end of block
0
1011 option.palette.setCurrentColorGroup(cg);-
1012 }
never executed: end of block
0
1013 if (focus && current == *it) {
focusDescription
TRUEnever evaluated
FALSEnever evaluated
current == *itDescription
TRUEnever evaluated
FALSEnever evaluated
0
1014 option.state |= QStyle::State_HasFocus;-
1015 if (viewState == EditingState)
viewState == EditingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1016 option.state |= QStyle::State_Editing;
never executed: option.state |= QStyle::State_Editing;
0
1017 }
never executed: end of block
0
1018 option.state.setFlag(QStyle::State_MouseOver, *it == hover);-
1019-
1020 if (alternate) {
alternateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1021 int row = (*it).row();-
1022 if (row != previousRow + 1) {
row != previousRow + 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1023 // adjust alternateBase according to rows in the "gap"-
1024 if (!d->hiddenRows.isEmpty()) {
!d->hiddenRows.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1025 for (int r = qMax(previousRow + 1, 0); r < row; ++r) {
r < rowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1026 if (!d->isHidden(r))
!d->isHidden(r)Description
TRUEnever evaluated
FALSEnever evaluated
0
1027 alternateBase = !alternateBase;
never executed: alternateBase = !alternateBase;
0
1028 }
never executed: end of block
0
1029 } else {
never executed: end of block
0
1030 alternateBase = (row & 1) != 0;-
1031 }
never executed: end of block
0
1032 }-
1033 option.features.setFlag(QStyleOptionViewItem::Alternate, alternateBase);-
1034-
1035 // draw background of the item (only alternate row). rest of the background-
1036 // is provided by the delegate-
1037 QStyle::State oldState = option.state;-
1038 option.state &= ~QStyle::State_Selected;-
1039 style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &option, &painter, this);-
1040 option.state = oldState;-
1041-
1042 alternateBase = !alternateBase;-
1043 previousRow = row;-
1044 }
never executed: end of block
0
1045-
1046 d->delegateForIndex(*it)->paint(&painter, option, *it);-
1047 }
never executed: end of block
0
1048-
1049#ifndef QT_NO_DRAGANDDROP-
1050 d->commonListView->paintDragDrop(&painter);-
1051#endif-
1052-
1053#ifndef QT_NO_RUBBERBAND-
1054 // #### move this implementation into a dynamic class-
1055 if (d->showElasticBand && d->elasticBand.isValid()) {
d->showElasticBandDescription
TRUEnever evaluated
FALSEnever evaluated
d->elasticBand.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1056 QStyleOptionRubberBand opt;-
1057 opt.initFrom(this);-
1058 opt.shape = QRubberBand::Rectangle;-
1059 opt.opaque = false;-
1060 opt.rect = d->mapToViewport(d->elasticBand, false).intersected(-
1061 d->viewport->rect().adjusted(-16, -16, 16, 16));-
1062 painter.save();-
1063 style()->drawControl(QStyle::CE_RubberBand, &opt, &painter);-
1064 painter.restore();-
1065 }
never executed: end of block
0
1066#endif-
1067}
never executed: end of block
0
1068-
1069/*!-
1070 \reimp-
1071*/-
1072QModelIndex QListView::indexAt(const QPoint &p) const-
1073{-
1074 Q_D(const QListView);-
1075 QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);-
1076 const QVector<QModelIndex> intersectVector = d->intersectingSet(rect);-
1077 QModelIndex index = intersectVector.count() > 0
intersectVector.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1078 ? intersectVector.last() : QModelIndex();-
1079 if (index.isValid() && visualRect(index).contains(p))
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
visualRect(index).contains(p)Description
TRUEnever evaluated
FALSEnever evaluated
0
1080 return index;
never executed: return index;
0
1081 return QModelIndex();
never executed: return QModelIndex();
0
1082}-
1083-
1084/*!-
1085 \reimp-
1086*/-
1087int QListView::horizontalOffset() const-
1088{-
1089 return d_func()->commonListView->horizontalOffset();
never executed: return d_func()->commonListView->horizontalOffset();
0
1090}-
1091-
1092/*!-
1093 \reimp-
1094*/-
1095int QListView::verticalOffset() const-
1096{-
1097 return d_func()->commonListView->verticalOffset();
never executed: return d_func()->commonListView->verticalOffset();
0
1098}-
1099-
1100/*!-
1101 \reimp-
1102*/-
1103QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)-
1104{-
1105 Q_D(QListView);-
1106 Q_UNUSED(modifiers);-
1107-
1108 QModelIndex current = currentIndex();-
1109 if (!current.isValid()) {
!current.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1110 int rowCount = d->model->rowCount(d->root);-
1111 if (!rowCount)
!rowCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1112 return QModelIndex();
never executed: return QModelIndex();
0
1113 int row = 0;-
1114 while (row < rowCount && d->isHiddenOrDisabled(row))
row < rowCountDescription
TRUEnever evaluated
FALSEnever evaluated
d->isHiddenOrDisabled(row)Description
TRUEnever evaluated
FALSEnever evaluated
0
1115 ++row;
never executed: ++row;
0
1116 if (row >= rowCount)
row >= rowCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1117 return QModelIndex();
never executed: return QModelIndex();
0
1118 return d->model->index(row, d->column, d->root);
never executed: return d->model->index(row, d->column, d->root);
0
1119 }-
1120-
1121 const QRect initialRect = rectForIndex(current);-
1122 QRect rect = initialRect;-
1123 if (rect.isEmpty()) {
rect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1124 return d->model->index(0, d->column, d->root);
never executed: return d->model->index(0, d->column, d->root);
0
1125 }-
1126 if (d->gridSize().isValid()) rect.setSize(d->gridSize());
never executed: rect.setSize(d->gridSize());
d->gridSize().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1127-
1128 QSize contents = d->contentsSize();-
1129 QVector<QModelIndex> intersectVector;-
1130-
1131 switch (cursorAction) {-
1132 case MoveLeft:
never executed: case MoveLeft:
0
1133 while (intersectVector.isEmpty()) {
intersectVector.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1134 rect.translate(-rect.width(), 0);-
1135 if (rect.right() <= 0)
rect.right() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1136 return current;
never executed: return current;
0
1137 if (rect.left() < 0)
rect.left() < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1138 rect.setLeft(0);
never executed: rect.setLeft(0);
0
1139 intersectVector = d->intersectingSet(rect);-
1140 d->removeCurrentAndDisabled(&intersectVector, current);-
1141 }
never executed: end of block
0
1142 return d->closestIndex(initialRect, intersectVector);
never executed: return d->closestIndex(initialRect, intersectVector);
0
1143 case MoveRight:
never executed: case MoveRight:
0
1144 while (intersectVector.isEmpty()) {
intersectVector.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1145 rect.translate(rect.width(), 0);-
1146 if (rect.left() >= contents.width())
rect.left() >=...ntents.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
1147 return current;
never executed: return current;
0
1148 if (rect.right() > contents.width())
rect.right() >...ntents.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
1149 rect.setRight(contents.width());
never executed: rect.setRight(contents.width());
0
1150 intersectVector = d->intersectingSet(rect);-
1151 d->removeCurrentAndDisabled(&intersectVector, current);-
1152 }
never executed: end of block
0
1153 return d->closestIndex(initialRect, intersectVector);
never executed: return d->closestIndex(initialRect, intersectVector);
0
1154 case MovePageUp:
never executed: case MovePageUp:
0
1155 // move current by (visibileRowCount - 1) items.-
1156 // rect.translate(0, -rect.height()); will happen in the switch fallthrough for MoveUp.-
1157 rect.moveTop(rect.top() - d->viewport->height() + 2 * rect.height());-
1158 if (rect.top() < rect.height())
rect.top() < rect.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
1159 rect.moveTop(rect.height());
never executed: rect.moveTop(rect.height());
0
1160 case MovePrevious:
code before this statement never executed: case MovePrevious:
never executed: case MovePrevious:
0
1161 case MoveUp:
never executed: case MoveUp:
0
1162 while (intersectVector.isEmpty()) {
intersectVector.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1163 rect.translate(0, -rect.height());-
1164 if (rect.bottom() <= 0) {
rect.bottom() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1165#ifdef QT_KEYPAD_NAVIGATION-
1166 if (QApplication::keypadNavigationEnabled()) {-
1167 int row = d->batchStartRow() - 1;-
1168 while (row >= 0 && d->isHiddenOrDisabled(row))-
1169 --row;-
1170 if (row >= 0)-
1171 return d->model->index(row, d->column, d->root);-
1172 }-
1173#endif-
1174 return current;
never executed: return current;
0
1175 }-
1176 if (rect.top() < 0)
rect.top() < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1177 rect.setTop(0);
never executed: rect.setTop(0);
0
1178 intersectVector = d->intersectingSet(rect);-
1179 d->removeCurrentAndDisabled(&intersectVector, current);-
1180 }
never executed: end of block
0
1181 return d->closestIndex(initialRect, intersectVector);
never executed: return d->closestIndex(initialRect, intersectVector);
0
1182 case MovePageDown:
never executed: case MovePageDown:
0
1183 // move current by (visibileRowCount - 1) items.-
1184 // rect.translate(0, rect.height()); will happen in the switch fallthrough for MoveDown.-
1185 rect.moveTop(rect.top() + d->viewport->height() - 2 * rect.height());-
1186 if (rect.bottom() > contents.height() - rect.height())
rect.bottom() ... rect.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
1187 rect.moveBottom(contents.height() - rect.height());
never executed: rect.moveBottom(contents.height() - rect.height());
0
1188 case MoveNext:
code before this statement never executed: case MoveNext:
never executed: case MoveNext:
0
1189 case MoveDown:
never executed: case MoveDown:
0
1190 while (intersectVector.isEmpty()) {
intersectVector.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1191 rect.translate(0, rect.height());-
1192 if (rect.top() >= contents.height()) {
rect.top() >= ...tents.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
1193#ifdef QT_KEYPAD_NAVIGATION-
1194 if (QApplication::keypadNavigationEnabled()) {-
1195 int rowCount = d->model->rowCount(d->root);-
1196 int row = 0;-
1197 while (row < rowCount && d->isHiddenOrDisabled(row))-
1198 ++row;-
1199 if (row < rowCount)-
1200 return d->model->index(row, d->column, d->root);-
1201 }-
1202#endif-
1203 return current;
never executed: return current;
0
1204 }-
1205 if (rect.bottom() > contents.height())
rect.bottom() ...tents.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
1206 rect.setBottom(contents.height());
never executed: rect.setBottom(contents.height());
0
1207 intersectVector = d->intersectingSet(rect);-
1208 d->removeCurrentAndDisabled(&intersectVector, current);-
1209 }
never executed: end of block
0
1210 return d->closestIndex(initialRect, intersectVector);
never executed: return d->closestIndex(initialRect, intersectVector);
0
1211 case MoveHome:
never executed: case MoveHome:
0
1212 return d->model->index(0, d->column, d->root);
never executed: return d->model->index(0, d->column, d->root);
0
1213 case MoveEnd:
never executed: case MoveEnd:
0
1214 return d->model->index(d->batchStartRow() - 1, d->column, d->root);}
never executed: return d->model->index(d->batchStartRow() - 1, d->column, d->root);
0
1215-
1216 return current;
never executed: return current;
0
1217}-
1218-
1219/*!-
1220 Returns the rectangle of the item at position \a index in the-
1221 model. The rectangle is in contents coordinates.-
1222-
1223 \sa visualRect()-
1224*/-
1225QRect QListView::rectForIndex(const QModelIndex &index) const-
1226{-
1227 return d_func()->rectForIndex(index);
never executed: return d_func()->rectForIndex(index);
0
1228}-
1229-
1230/*!-
1231 \since 4.1-
1232-
1233 Sets the contents position of the item at \a index in the model to the given-
1234 \a position.-
1235 If the list view's movement mode is Static or its view mode is ListView,-
1236 this function will have no effect.-
1237*/-
1238void QListView::setPositionForIndex(const QPoint &position, const QModelIndex &index)-
1239{-
1240 Q_D(QListView);-
1241 if (d->movement == Static
d->movement == StaticDescription
TRUEnever evaluated
FALSEnever evaluated
0
1242 || !d->isIndexValid(index)
!d->isIndexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1243 || index.parent() != d->root
index.parent() != d->rootDescription
TRUEnever evaluated
FALSEnever evaluated
0
1244 || index.column() != d->column)
index.column() != d->columnDescription
TRUEnever evaluated
FALSEnever evaluated
0
1245 return;
never executed: return;
0
1246-
1247 d->executePostedLayout();-
1248 d->commonListView->setPositionForIndex(position, index);-
1249}
never executed: end of block
0
1250-
1251/*!-
1252 \reimp-
1253*/-
1254void QListView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)-
1255{-
1256 Q_D(QListView);-
1257 if (!d->selectionModel)
!d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1258 return;
never executed: return;
0
1259-
1260 // if we are wrapping, we can only selecte inside the contents rectangle-
1261 int w = qMax(d->contentsSize().width(), d->viewport->width());-
1262 int h = qMax(d->contentsSize().height(), d->viewport->height());-
1263 if (d->wrap && !QRect(0, 0, w, h).intersects(rect))
d->wrapDescription
TRUEnever evaluated
FALSEnever evaluated
!QRect(0, 0, w...tersects(rect)Description
TRUEnever evaluated
FALSEnever evaluated
0
1264 return;
never executed: return;
0
1265-
1266 QItemSelection selection;-
1267-
1268 if (rect.width() == 1 && rect.height() == 1) {
rect.width() == 1Description
TRUEnever evaluated
FALSEnever evaluated
rect.height() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1269 const QVector<QModelIndex> intersectVector = d->intersectingSet(rect.translated(horizontalOffset(), verticalOffset()));-
1270 QModelIndex tl;-
1271 if (!intersectVector.isEmpty())
!intersectVector.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1272 tl = intersectVector.last(); // special case for mouse press; only select the top item
never executed: tl = intersectVector.last();
0
1273 if (tl.isValid() && d->isIndexEnabled(tl))
tl.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
d->isIndexEnabled(tl)Description
TRUEnever evaluated
FALSEnever evaluated
0
1274 selection.select(tl, tl);
never executed: selection.select(tl, tl);
0
1275 } else {
never executed: end of block
0
1276 if (state() == DragSelectingState) { // visual selection mode (rubberband selection)
state() == DragSelectingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1277 selection = d->selection(rect.translated(horizontalOffset(), verticalOffset()));-
1278 } else { // logical selection mode (key and mouse click selection)
never executed: end of block
0
1279 QModelIndex tl, br;-
1280 // get the first item-
1281 const QRect topLeft(rect.left() + horizontalOffset(), rect.top() + verticalOffset(), 1, 1);-
1282 QVector<QModelIndex> intersectVector = d->intersectingSet(topLeft);-
1283 if (!intersectVector.isEmpty())
!intersectVector.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1284 tl = intersectVector.last();
never executed: tl = intersectVector.last();
0
1285 // get the last item-
1286 const QRect bottomRight(rect.right() + horizontalOffset(), rect.bottom() + verticalOffset(), 1, 1);-
1287 intersectVector = d->intersectingSet(bottomRight);-
1288 if (!intersectVector.isEmpty())
!intersectVector.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1289 br = intersectVector.last();
never executed: br = intersectVector.last();
0
1290-
1291 // get the ranges-
1292 if (tl.isValid() && br.isValid()
tl.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
br.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1293 && d->isIndexEnabled(tl)
d->isIndexEnabled(tl)Description
TRUEnever evaluated
FALSEnever evaluated
0
1294 && d->isIndexEnabled(br)) {
d->isIndexEnabled(br)Description
TRUEnever evaluated
FALSEnever evaluated
0
1295 QRect first = rectForIndex(tl);-
1296 QRect last = rectForIndex(br);-
1297 QRect middle;-
1298 if (d->flow == LeftToRight) {
d->flow == LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
1299 QRect &top = first;-
1300 QRect &bottom = last;-
1301 // if bottom is above top, swap them-
1302 if (top.center().y() > bottom.center().y()) {
top.center().y...m.center().y()Description
TRUEnever evaluated
FALSEnever evaluated
0
1303 QRect tmp = top;-
1304 top = bottom;-
1305 bottom = tmp;-
1306 }
never executed: end of block
0
1307 // if the rect are on differnet lines, expand-
1308 if (top.top() != bottom.top()) {
top.top() != bottom.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
1309 // top rectangle-
1310 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1311 top.setLeft(0);
never executed: top.setLeft(0);
0
1312 else-
1313 top.setRight(contentsSize().width());
never executed: top.setRight(contentsSize().width());
0
1314 // bottom rectangle-
1315 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1316 bottom.setRight(contentsSize().width());
never executed: bottom.setRight(contentsSize().width());
0
1317 else-
1318 bottom.setLeft(0);
never executed: bottom.setLeft(0);
0
1319 } else if (top.left() > bottom.right()) {
top.left() > bottom.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
1320 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1321 bottom.setLeft(top.right());
never executed: bottom.setLeft(top.right());
0
1322 else-
1323 bottom.setRight(top.left());
never executed: bottom.setRight(top.left());
0
1324 } else {-
1325 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1326 top.setLeft(bottom.right());
never executed: top.setLeft(bottom.right());
0
1327 else-
1328 top.setRight(bottom.left());
never executed: top.setRight(bottom.left());
0
1329 }-
1330 // middle rectangle-
1331 if (top.bottom() < bottom.top()) {
top.bottom() < bottom.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
1332 if (gridSize().isValid() && !gridSize().isNull())
gridSize().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
!gridSize().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1333 middle.setTop(top.top() + gridSize().height());
never executed: middle.setTop(top.top() + gridSize().height());
0
1334 else-
1335 middle.setTop(top.bottom() + 1);
never executed: middle.setTop(top.bottom() + 1);
0
1336 middle.setLeft(qMin(top.left(), bottom.left()));-
1337 middle.setBottom(bottom.top() - 1);-
1338 middle.setRight(qMax(top.right(), bottom.right()));-
1339 }
never executed: end of block
0
1340 } else { // TopToBottom
never executed: end of block
0
1341 QRect &left = first;-
1342 QRect &right = last;-
1343 if (left.center().x() > right.center().x())
left.center()....t.center().x()Description
TRUEnever evaluated
FALSEnever evaluated
0
1344 qSwap(left, right);
never executed: qSwap(left, right);
0
1345-
1346 int ch = contentsSize().height();-
1347 if (left.left() != right.left()) {
left.left() != right.left()Description
TRUEnever evaluated
FALSEnever evaluated
0
1348 // left rectangle-
1349 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1350 left.setTop(0);
never executed: left.setTop(0);
0
1351 else-
1352 left.setBottom(ch);
never executed: left.setBottom(ch);
0
1353-
1354 // top rectangle-
1355 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1356 right.setBottom(ch);
never executed: right.setBottom(ch);
0
1357 else-
1358 right.setTop(0);
never executed: right.setTop(0);
0
1359 // only set middle if the-
1360 middle.setTop(0);-
1361 middle.setBottom(ch);-
1362 if (gridSize().isValid() && !gridSize().isNull())
gridSize().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
!gridSize().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1363 middle.setLeft(left.left() + gridSize().width());
never executed: middle.setLeft(left.left() + gridSize().width());
0
1364 else-
1365 middle.setLeft(left.right() + 1);
never executed: middle.setLeft(left.right() + 1);
0
1366 middle.setRight(right.left() - 1);-
1367 } else if (left.bottom() < right.top()) {
never executed: end of block
left.bottom() < right.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
1368 left.setBottom(right.top() - 1);-
1369 } else {
never executed: end of block
0
1370 right.setBottom(left.top() - 1);-
1371 }
never executed: end of block
0
1372 }-
1373-
1374 // do the selections-
1375 QItemSelection topSelection = d->selection(first);-
1376 QItemSelection middleSelection = d->selection(middle);-
1377 QItemSelection bottomSelection = d->selection(last);-
1378 // merge-
1379 selection.merge(topSelection, QItemSelectionModel::Select);-
1380 selection.merge(middleSelection, QItemSelectionModel::Select);-
1381 selection.merge(bottomSelection, QItemSelectionModel::Select);-
1382 }
never executed: end of block
0
1383 }
never executed: end of block
0
1384 }-
1385-
1386 d->selectionModel->select(selection, command);-
1387}
never executed: end of block
0
1388-
1389/*!-
1390 \reimp-
1391-
1392 Since 4.7, the returned region only contains rectangles intersecting-
1393 (or included in) the viewport.-
1394*/-
1395QRegion QListView::visualRegionForSelection(const QItemSelection &selection) const-
1396{-
1397 Q_D(const QListView);-
1398 // ### NOTE: this is a potential bottleneck in non-static mode-
1399 int c = d->column;-
1400 QRegion selectionRegion;-
1401 const QRect &viewportRect = d->viewport->rect();-
1402 for (const auto &elem : selection) {-
1403 if (!elem.isValid())
!elem.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1404 continue;
never executed: continue;
0
1405 QModelIndex parent = elem.topLeft().parent();-
1406 //we only display the children of the root in a listview-
1407 //we're not interested in the other model indexes-
1408 if (parent != d->root)
parent != d->rootDescription
TRUEnever evaluated
FALSEnever evaluated
0
1409 continue;
never executed: continue;
0
1410 int t = elem.topLeft().row();-
1411 int b = elem.bottomRight().row();-
1412 if (d->viewMode == IconMode || d->isWrapping()) { // in non-static mode, we have to go through all selected items
d->viewMode == IconModeDescription
TRUEnever evaluated
FALSEnever evaluated
d->isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
1413 for (int r = t; r <= b; ++r) {
r <= bDescription
TRUEnever evaluated
FALSEnever evaluated
0
1414 const QRect &rect = visualRect(d->model->index(r, c, parent));-
1415 if (viewportRect.intersects(rect))
viewportRect.intersects(rect)Description
TRUEnever evaluated
FALSEnever evaluated
0
1416 selectionRegion += rect;
never executed: selectionRegion += rect;
0
1417 }
never executed: end of block
0
1418 } else { // in static mode, we can optimize a bit
never executed: end of block
0
1419 while (t <= b && d->isHidden(t)) ++t;
never executed: ++t;
t <= bDescription
TRUEnever evaluated
FALSEnever evaluated
d->isHidden(t)Description
TRUEnever evaluated
FALSEnever evaluated
0
1420 while (b >= t && d->isHidden(b)) --b;
never executed: --b;
b >= tDescription
TRUEnever evaluated
FALSEnever evaluated
d->isHidden(b)Description
TRUEnever evaluated
FALSEnever evaluated
0
1421 const QModelIndex top = d->model->index(t, c, parent);-
1422 const QModelIndex bottom = d->model->index(b, c, parent);-
1423 QRect rect(visualRect(top).topLeft(),-
1424 visualRect(bottom).bottomRight());-
1425 if (viewportRect.intersects(rect))
viewportRect.intersects(rect)Description
TRUEnever evaluated
FALSEnever evaluated
0
1426 selectionRegion += rect;
never executed: selectionRegion += rect;
0
1427 }
never executed: end of block
0
1428 }-
1429-
1430 return selectionRegion;
never executed: return selectionRegion;
0
1431}-
1432-
1433/*!-
1434 \reimp-
1435*/-
1436QModelIndexList QListView::selectedIndexes() const-
1437{-
1438 Q_D(const QListView);-
1439 if (!d->selectionModel)
!d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1440 return QModelIndexList();
never executed: return QModelIndexList();
0
1441-
1442 QModelIndexList viewSelected = d->selectionModel->selectedIndexes();-
1443 auto ignorable = [this, d](const QModelIndex &index) {-
1444 return index.column() != d->column || index.parent() != d->root || isIndexHidden(index);
never executed: return index.column() != d->column || index.parent() != d->root || isIndexHidden(index);
0
1445 };-
1446 viewSelected.erase(std::remove_if(viewSelected.begin(), viewSelected.end(), ignorable),-
1447 viewSelected.end());-
1448 return viewSelected;
never executed: return viewSelected;
0
1449}-
1450-
1451/*!-
1452 \internal-
1453-
1454 Layout the items according to the flow and wrapping properties.-
1455*/-
1456void QListView::doItemsLayout()-
1457{-
1458 Q_D(QListView);-
1459 // showing the scroll bars will trigger a resize event,-
1460 // so we set the state to expanding to avoid-
1461 // triggering another layout-
1462 QAbstractItemView::State oldState = state();-
1463 setState(ExpandingState);-
1464 if (d->model->columnCount(d->root) > 0) { // no columns means no contents
d->model->colu...t(d->root) > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1465 d->resetBatchStartRow();-
1466 if (layoutMode() == SinglePass)
layoutMode() == SinglePassDescription
TRUEnever evaluated
FALSEnever evaluated
0
1467 d->doItemsLayout(d->model->rowCount(d->root)); // layout everything
never executed: d->doItemsLayout(d->model->rowCount(d->root));
0
1468 else if (!d->batchLayoutTimer.isActive()) {
!d->batchLayou...mer.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1469 if (!d->doItemsLayout(d->batchSize)) // layout is done
!d->doItemsLay...(d->batchSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
1470 d->batchLayoutTimer.start(0, this); // do a new batch as fast as possible
never executed: d->batchLayoutTimer.start(0, this);
0
1471 }
never executed: end of block
0
1472 }
never executed: end of block
0
1473 QAbstractItemView::doItemsLayout();-
1474 setState(oldState); // restoring the oldState-
1475}
never executed: end of block
0
1476-
1477/*!-
1478 \reimp-
1479*/-
1480void QListView::updateGeometries()-
1481{-
1482 Q_D(QListView);-
1483 if (geometry().isEmpty() || d->model->rowCount(d->root) <= 0 || d->model->columnCount(d->root) <= 0) {
geometry().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
d->model->rowC...(d->root) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
d->model->colu...(d->root) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1484 horizontalScrollBar()->setRange(0, 0);-
1485 verticalScrollBar()->setRange(0, 0);-
1486 } else {
never executed: end of block
0
1487 QModelIndex index = d->model->index(0, d->column, d->root);-
1488 QStyleOptionViewItem option = d->viewOptionsV1();-
1489 QSize step = d->itemSize(option, index);-
1490 d->commonListView->updateHorizontalScrollBar(step);-
1491 d->commonListView->updateVerticalScrollBar(step);-
1492 }
never executed: end of block
0
1493-
1494 QAbstractItemView::updateGeometries();-
1495-
1496 // if the scroll bars are turned off, we resize the contents to the viewport-
1497 if (d->movement == Static && !d->isWrapping()) {
d->movement == StaticDescription
TRUEnever evaluated
FALSEnever evaluated
!d->isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
1498 d->layoutChildren(); // we need the viewport size to be updated-
1499 if (d->flow == TopToBottom) {
d->flow == TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
1500 if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
horizontalScro...llBarAlwaysOffDescription
TRUEnever evaluated
FALSEnever evaluated
0
1501 d->setContentsSize(viewport()->width(), contentsSize().height());-
1502 horizontalScrollBar()->setRange(0, 0); // we see all the contents anyway-
1503 }
never executed: end of block
0
1504 } else { // LeftToRight
never executed: end of block
0
1505 if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
verticalScroll...llBarAlwaysOffDescription
TRUEnever evaluated
FALSEnever evaluated
0
1506 d->setContentsSize(contentsSize().width(), viewport()->height());-
1507 verticalScrollBar()->setRange(0, 0); // we see all the contents anyway-
1508 }
never executed: end of block
0
1509 }
never executed: end of block
0
1510 }-
1511-
1512}
never executed: end of block
0
1513-
1514/*!-
1515 \reimp-
1516*/-
1517bool QListView::isIndexHidden(const QModelIndex &index) const-
1518{-
1519 Q_D(const QListView);-
1520 return (d->isHidden(index.row())
never executed: return (d->isHidden(index.row()) && (index.parent() == d->root) && index.column() == d->column);
0
1521 && (index.parent() == d->root)
never executed: return (d->isHidden(index.row()) && (index.parent() == d->root) && index.column() == d->column);
0
1522 && index.column() == d->column);
never executed: return (d->isHidden(index.row()) && (index.parent() == d->root) && index.column() == d->column);
0
1523}-
1524-
1525/*!-
1526 \property QListView::modelColumn-
1527 \brief the column in the model that is visible-
1528-
1529 By default, this property contains 0, indicating that the first-
1530 column in the model will be shown.-
1531*/-
1532void QListView::setModelColumn(int column)-
1533{-
1534 Q_D(QListView);-
1535 if (column < 0 || column >= d->model->columnCount(d->root))
column < 0Description
TRUEnever evaluated
FALSEnever evaluated
column >= d->m...Count(d->root)Description
TRUEnever evaluated
FALSEnever evaluated
0
1536 return;
never executed: return;
0
1537 d->column = column;-
1538 d->doDelayedItemsLayout();-
1539}
never executed: end of block
0
1540-
1541int QListView::modelColumn() const-
1542{-
1543 Q_D(const QListView);-
1544 return d->column;
never executed: return d->column;
0
1545}-
1546-
1547/*!-
1548 \property QListView::uniformItemSizes-
1549 \brief whether all items in the listview have the same size-
1550 \since 4.1-
1551-
1552 This property should only be set to true if it is guaranteed that all items-
1553 in the view have the same size. This enables the view to do some-
1554 optimizations for performance purposes.-
1555-
1556 By default, this property is \c false.-
1557*/-
1558void QListView::setUniformItemSizes(bool enable)-
1559{-
1560 Q_D(QListView);-
1561 d->uniformItemSizes = enable;-
1562}
never executed: end of block
0
1563-
1564bool QListView::uniformItemSizes() const-
1565{-
1566 Q_D(const QListView);-
1567 return d->uniformItemSizes;
never executed: return d->uniformItemSizes;
0
1568}-
1569-
1570/*!-
1571 \property QListView::wordWrap-
1572 \brief the item text word-wrapping policy-
1573 \since 4.2-
1574-
1575 If this property is \c true then the item text is wrapped where-
1576 necessary at word-breaks; otherwise it is not wrapped at all.-
1577 This property is \c false by default.-
1578-
1579 Please note that even if wrapping is enabled, the cell will not be-
1580 expanded to make room for the text. It will print ellipsis for-
1581 text that cannot be shown, according to the view's-
1582 \l{QAbstractItemView::}{textElideMode}.-
1583*/-
1584void QListView::setWordWrap(bool on)-
1585{-
1586 Q_D(QListView);-
1587 if (d->wrapItemText == on)
d->wrapItemText == onDescription
TRUEnever evaluated
FALSEnever evaluated
0
1588 return;
never executed: return;
0
1589 d->wrapItemText = on;-
1590 d->doDelayedItemsLayout();-
1591}
never executed: end of block
0
1592-
1593bool QListView::wordWrap() const-
1594{-
1595 Q_D(const QListView);-
1596 return d->wrapItemText;
never executed: return d->wrapItemText;
0
1597}-
1598-
1599/*!-
1600 \property QListView::selectionRectVisible-
1601 \brief if the selection rectangle should be visible-
1602 \since 4.3-
1603-
1604 If this property is \c true then the selection rectangle is visible;-
1605 otherwise it will be hidden.-
1606-
1607 \note The selection rectangle will only be visible if the selection mode-
1608 is in a mode where more than one item can be selected; i.e., it will not-
1609 draw a selection rectangle if the selection mode is-
1610 QAbstractItemView::SingleSelection.-
1611-
1612 By default, this property is \c false.-
1613*/-
1614void QListView::setSelectionRectVisible(bool show)-
1615{-
1616 Q_D(QListView);-
1617 d->modeProperties |= uint(QListViewPrivate::SelectionRectVisible);-
1618 d->setSelectionRectVisible(show);-
1619}
never executed: end of block
0
1620-
1621bool QListView::isSelectionRectVisible() const-
1622{-
1623 Q_D(const QListView);-
1624 return d->isSelectionRectVisible();
never executed: return d->isSelectionRectVisible();
0
1625}-
1626-
1627/*!-
1628 \reimp-
1629*/-
1630bool QListView::event(QEvent *e)-
1631{-
1632 return QAbstractItemView::event(e);
never executed: return QAbstractItemView::event(e);
0
1633}-
1634-
1635/*-
1636 * private object implementation-
1637 */-
1638-
1639QListViewPrivate::QListViewPrivate()-
1640 : QAbstractItemViewPrivate(),-
1641 commonListView(0),-
1642 wrap(false),-
1643 space(0),-
1644 flow(QListView::TopToBottom),-
1645 movement(QListView::Static),-
1646 resizeMode(QListView::Fixed),-
1647 layoutMode(QListView::SinglePass),-
1648 viewMode(QListView::ListMode),-
1649 modeProperties(0),-
1650 column(0),-
1651 uniformItemSizes(false),-
1652 batchSize(100),-
1653 showElasticBand(false)-
1654{-
1655}
never executed: end of block
0
1656-
1657QListViewPrivate::~QListViewPrivate()-
1658{-
1659 delete commonListView;-
1660}
never executed: end of block
0
1661-
1662void QListViewPrivate::clear()-
1663{-
1664 // initialization of data structs-
1665 cachedItemSize = QSize();-
1666 commonListView->clear();-
1667}
never executed: end of block
0
1668-
1669void QListViewPrivate::prepareItemsLayout()-
1670{-
1671 Q_Q(QListView);-
1672 clear();-
1673-
1674 //take the size as if there were scrollbar in order to prevent scrollbar to blink-
1675 layoutBounds = QRect(QPoint(), q->maximumViewportSize());-
1676-
1677 int frameAroundContents = 0;-
1678 if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents))
q->style()->st...roundContents)Description
TRUEnever evaluated
FALSEnever evaluated
0
1679 frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 2;
never executed: frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 2;
0
1680-
1681 // maximumViewportSize() already takes scrollbar into account if policy is-
1682 // Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy-
1683 // is Qt::ScrollBarAsNeeded-
1684 int verticalMargin = vbarpolicy==Qt::ScrollBarAsNeeded
vbarpolicy==Qt...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
0
1685 ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, vbar) + frameAroundContents-
1686 : 0;-
1687 int horizontalMargin = hbarpolicy==Qt::ScrollBarAsNeeded
hbarpolicy==Qt...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
0
1688 ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, hbar) + frameAroundContents-
1689 : 0;-
1690-
1691 layoutBounds.adjust(0, 0, -verticalMargin, -horizontalMargin);-
1692-
1693 int rowCount = model->columnCount(root) <= 0 ? 0 : model->rowCount(root);
model->columnCount(root) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1694 commonListView->setRowCount(rowCount);-
1695}
never executed: end of block
0
1696-
1697/*!-
1698 \internal-
1699*/-
1700bool QListViewPrivate::doItemsLayout(int delta)-
1701{-
1702 int max = model->rowCount(root) - 1;-
1703 int first = batchStartRow();-
1704 int last = qMin(first + delta - 1, max);-
1705-
1706 if (first == 0) {
first == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1707 layoutChildren(); // make sure the viewport has the right size-
1708 prepareItemsLayout();-
1709 }
never executed: end of block
0
1710-
1711 if (max < 0 || last < first) {
max < 0Description
TRUEnever evaluated
FALSEnever evaluated
last < firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
1712 return true; // nothing to do
never executed: return true;
0
1713 }-
1714-
1715 QListViewLayoutInfo info;-
1716 info.bounds = layoutBounds;-
1717 info.grid = gridSize();-
1718 info.spacing = (info.grid.isValid() ? 0 : spacing());
info.grid.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1719 info.first = first;-
1720 info.last = last;-
1721 info.wrap = isWrapping();-
1722 info.flow = flow;-
1723 info.max = max;-
1724-
1725 return commonListView->doBatchedItemLayout(info, max);
never executed: return commonListView->doBatchedItemLayout(info, max);
0
1726}-
1727-
1728QListViewItem QListViewPrivate::indexToListViewItem(const QModelIndex &index) const-
1729{-
1730 if (!index.isValid() || isHidden(index.row()))
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
isHidden(index.row())Description
TRUEnever evaluated
FALSEnever evaluated
0
1731 return QListViewItem();
never executed: return QListViewItem();
0
1732-
1733 return commonListView->indexToListViewItem(index);
never executed: return commonListView->indexToListViewItem(index);
0
1734}-
1735-
1736QRect QListViewPrivate::mapToViewport(const QRect &rect, bool extend) const-
1737{-
1738 Q_Q(const QListView);-
1739 if (!rect.isValid())
!rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1740 return rect;
never executed: return rect;
0
1741-
1742 QRect result = extend ? commonListView->mapToViewport(rect) : rect;
extendDescription
TRUEnever evaluated
FALSEnever evaluated
0
1743 int dx = -q->horizontalOffset();-
1744 int dy = -q->verticalOffset();-
1745 return result.adjusted(dx, dy, dx, dy);
never executed: return result.adjusted(dx, dy, dx, dy);
0
1746}-
1747-
1748QModelIndex QListViewPrivate::closestIndex(const QRect &target,-
1749 const QVector<QModelIndex> &candidates) const-
1750{-
1751 int distance = 0;-
1752 int shortest = INT_MAX;-
1753 QModelIndex closest;-
1754 QVector<QModelIndex>::const_iterator it = candidates.begin();-
1755-
1756 for (; it != candidates.end(); ++it) {
it != candidates.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
1757 if (!(*it).isValid())
!(*it).isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1758 continue;
never executed: continue;
0
1759-
1760 const QRect indexRect = indexToListViewItem(*it).rect();-
1761-
1762 //if the center x (or y) position of an item is included in the rect of the other item,-
1763 //we define the distance between them as the difference in x (or y) of their respective center.-
1764 // Otherwise, we use the nahattan length between the 2 items-
1765 if ((target.center().x() >= indexRect.x() && target.center().x() < indexRect.right())
target.center(... indexRect.x()Description
TRUEnever evaluated
FALSEnever evaluated
target.center(...exRect.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
1766 || (indexRect.center().x() >= target.x() && indexRect.center().x() < target.right())) {
indexRect.cent... >= target.x()Description
TRUEnever evaluated
FALSEnever evaluated
indexRect.cent...target.right()Description
TRUEnever evaluated
FALSEnever evaluated
0
1767 //one item's center is at the vertical of the other-
1768 distance = qAbs(indexRect.center().y() - target.center().y());-
1769 } else if ((target.center().y() >= indexRect.y() && target.center().y() < indexRect.bottom())
never executed: end of block
target.center(... indexRect.y()Description
TRUEnever evaluated
FALSEnever evaluated
target.center(...xRect.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
1770 || (indexRect.center().y() >= target.y() && indexRect.center().y() < target.bottom())) {
indexRect.cent... >= target.y()Description
TRUEnever evaluated
FALSEnever evaluated
indexRect.cent...arget.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
1771 //one item's center is at the vertical of the other-
1772 distance = qAbs(indexRect.center().x() - target.center().x());-
1773 } else {
never executed: end of block
0
1774 distance = (indexRect.center() - target.center()).manhattanLength();-
1775 }
never executed: end of block
0
1776 if (distance < shortest) {
distance < shortestDescription
TRUEnever evaluated
FALSEnever evaluated
0
1777 shortest = distance;-
1778 closest = *it;-
1779 }
never executed: end of block
0
1780 }
never executed: end of block
0
1781 return closest;
never executed: return closest;
0
1782}-
1783-
1784QSize QListViewPrivate::itemSize(const QStyleOptionViewItem &option, const QModelIndex &index) const-
1785{-
1786 if (!uniformItemSizes) {
!uniformItemSizesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1787 const QAbstractItemDelegate *delegate = delegateForIndex(index);-
1788 return delegate ? delegate->sizeHint(option, index) : QSize();
never executed: return delegate ? delegate->sizeHint(option, index) : QSize();
0
1789 }-
1790 if (!cachedItemSize.isValid()) { // the last item is probaly the largest, so we use its size
!cachedItemSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1791 int row = model->rowCount(root) - 1;-
1792 QModelIndex sample = model->index(row, column, root);-
1793 const QAbstractItemDelegate *delegate = delegateForIndex(sample);-
1794 cachedItemSize = delegate ? delegate->sizeHint(option, sample) : QSize();
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1795 }
never executed: end of block
0
1796 return cachedItemSize;
never executed: return cachedItemSize;
0
1797}-
1798-
1799QItemSelection QListViewPrivate::selection(const QRect &rect) const-
1800{-
1801 QItemSelection selection;-
1802 QModelIndex tl, br;-
1803 const QVector<QModelIndex> intersectVector = intersectingSet(rect);-
1804 QVector<QModelIndex>::const_iterator it = intersectVector.begin();-
1805 for (; it != intersectVector.end(); ++it) {
it != intersectVector.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
1806 if (!tl.isValid() && !br.isValid()) {
!tl.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
!br.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1807 tl = br = *it;-
1808 } else if ((*it).row() == (tl.row() - 1)) {
never executed: end of block
(*it).row() == (tl.row() - 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1809 tl = *it; // expand current range-
1810 } else if ((*it).row() == (br.row() + 1)) {
never executed: end of block
(*it).row() == (br.row() + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1811 br = (*it); // expand current range-
1812 } else {
never executed: end of block
0
1813 selection.select(tl, br); // select current range-
1814 tl = br = *it; // start new range-
1815 }
never executed: end of block
0
1816 }-
1817-
1818 if (tl.isValid() && br.isValid())
tl.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
br.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1819 selection.select(tl, br);
never executed: selection.select(tl, br);
0
1820 else if (tl.isValid())
tl.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1821 selection.select(tl, tl);
never executed: selection.select(tl, tl);
0
1822 else if (br.isValid())
br.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1823 selection.select(br, br);
never executed: selection.select(br, br);
0
1824-
1825 return selection;
never executed: return selection;
0
1826}-
1827-
1828#ifndef QT_NO_DRAGANDDROP-
1829QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const-
1830{-
1831 if (viewMode == QListView::ListMode && flow == QListView::LeftToRight)
viewMode == QL...View::ListModeDescription
TRUEnever evaluated
FALSEnever evaluated
flow == QListView::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
1832 return static_cast<QListModeViewBase *>(commonListView)->position(pos, rect, idx);
never executed: return static_cast<QListModeViewBase *>(commonListView)->position(pos, rect, idx);
0
1833 else-
1834 return QAbstractItemViewPrivate::position(pos, rect, idx);
never executed: return QAbstractItemViewPrivate::position(pos, rect, idx);
0
1835}-
1836-
1837bool QListViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex)-
1838{-
1839 if (viewMode == QListView::ListMode && flow == QListView::LeftToRight)
viewMode == QL...View::ListModeDescription
TRUEnever evaluated
FALSEnever evaluated
flow == QListView::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
1840 return static_cast<QListModeViewBase *>(commonListView)->dropOn(event, dropRow, dropCol, dropIndex);
never executed: return static_cast<QListModeViewBase *>(commonListView)->dropOn(event, dropRow, dropCol, dropIndex);
0
1841 else-
1842 return QAbstractItemViewPrivate::dropOn(event, dropRow, dropCol, dropIndex);
never executed: return QAbstractItemViewPrivate::dropOn(event, dropRow, dropCol, dropIndex);
0
1843}-
1844#endif-
1845-
1846void QListViewPrivate::removeCurrentAndDisabled(QVector<QModelIndex> *indexes, const QModelIndex &current) const-
1847{-
1848 auto isCurrentOrDisabled = [=](const QModelIndex &index) {-
1849 return !isIndexEnabled(index) || index == current;
never executed: return !isIndexEnabled(index) || index == current;
0
1850 };-
1851 indexes->erase(std::remove_if(indexes->begin(), indexes->end(),-
1852 isCurrentOrDisabled),-
1853 indexes->end());-
1854}
never executed: end of block
0
1855-
1856/*-
1857 * Common ListView Implementation-
1858*/-
1859-
1860void QCommonListViewBase::appendHiddenRow(int row)-
1861{-
1862 dd->hiddenRows.insert(dd->model->index(row, 0, qq->rootIndex()));-
1863}
never executed: end of block
0
1864-
1865void QCommonListViewBase::removeHiddenRow(int row)-
1866{-
1867 dd->hiddenRows.remove(dd->model->index(row, 0, qq->rootIndex()));-
1868}
never executed: end of block
0
1869-
1870#ifndef QT_NO_DRAGANDDROP-
1871void QCommonListViewBase::paintDragDrop(QPainter *painter)-
1872{-
1873 // FIXME: Until the we can provide a proper drop indicator-
1874 // in IconMode, it makes no sense to show it-
1875 dd->paintDropIndicator(painter);-
1876}
never executed: end of block
0
1877#endif-
1878-
1879void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step)-
1880{-
1881 horizontalScrollBar()->d_func()->itemviewChangeSingleStep(step.width() + spacing());-
1882 horizontalScrollBar()->setPageStep(viewport()->width());-
1883-
1884 // If both scroll bars are set to auto, we might end up in a situation with enough space-
1885 // for the actual content. But still one of the scroll bars will become enabled due to-
1886 // the other one using the space. The other one will become invisible in the same cycle.-
1887 // -> Infinite loop, QTBUG-39902-
1888 const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded &&
qq->verticalSc...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
0
1889 qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded;
qq->horizontal...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
0
1890-
1891 const QSize viewportSize = qq->contentsRect().size();-
1892-
1893 bool verticalWantsToShow = contentsSize.height() > viewportSize.height();-
1894 bool horizontalWantsToShow;-
1895 if (verticalWantsToShow)
verticalWantsToShowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1896 horizontalWantsToShow = contentsSize.width() > viewportSize.width() - qq->verticalScrollBar()->width();
never executed: horizontalWantsToShow = contentsSize.width() > viewportSize.width() - qq->verticalScrollBar()->width();
0
1897 else-
1898 horizontalWantsToShow = contentsSize.width() > viewportSize.width();
never executed: horizontalWantsToShow = contentsSize.width() > viewportSize.width();
0
1899-
1900 if (bothScrollBarsAuto && !horizontalWantsToShow) {
bothScrollBarsAutoDescription
TRUEnever evaluated
FALSEnever evaluated
!horizontalWantsToShowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1901 // break the infinite loop described above by setting the range to 0, 0.-
1902 // QAbstractScrollArea will then hide the scroll bar for us-
1903 horizontalScrollBar()->setRange(0, 0);-
1904 } else {
never executed: end of block
0
1905 horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width());-
1906 }
never executed: end of block
0
1907}-
1908-
1909void QCommonListViewBase::updateVerticalScrollBar(const QSize &step)-
1910{-
1911 verticalScrollBar()->d_func()->itemviewChangeSingleStep(step.height() + spacing());-
1912 verticalScrollBar()->setPageStep(viewport()->height());-
1913-
1914 // If both scroll bars are set to auto, we might end up in a situation with enough space-
1915 // for the actual content. But still one of the scroll bars will become enabled due to-
1916 // the other one using the space. The other one will become invisible in the same cycle.-
1917 // -> Infinite loop, QTBUG-39902-
1918 const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded &&
qq->verticalSc...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
0
1919 qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded;
qq->horizontal...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
0
1920-
1921 const QSize viewportSize = qq->contentsRect().size();-
1922-
1923 bool horizontalWantsToShow = contentsSize.width() > viewportSize.width();-
1924 bool verticalWantsToShow;-
1925 if (horizontalWantsToShow)
horizontalWantsToShowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1926 verticalWantsToShow = contentsSize.height() > viewportSize.height() - qq->horizontalScrollBar()->height();
never executed: verticalWantsToShow = contentsSize.height() > viewportSize.height() - qq->horizontalScrollBar()->height();
0
1927 else-
1928 verticalWantsToShow = contentsSize.height() > viewportSize.height();
never executed: verticalWantsToShow = contentsSize.height() > viewportSize.height();
0
1929-
1930 if (bothScrollBarsAuto && !verticalWantsToShow) {
bothScrollBarsAutoDescription
TRUEnever evaluated
FALSEnever evaluated
!verticalWantsToShowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1931 // break the infinite loop described above by setting the range to 0, 0.-
1932 // QAbstractScrollArea will then hide the scroll bar for us-
1933 verticalScrollBar()->setRange(0, 0);-
1934 } else {
never executed: end of block
0
1935 verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height());-
1936 }
never executed: end of block
0
1937}-
1938-
1939void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool /*scrollElasticBand*/)-
1940{-
1941 dd->scrollContentsBy(isRightToLeft() ? -dx : dx, dy);-
1942}
never executed: end of block
0
1943-
1944int QCommonListViewBase::verticalScrollToValue(int /*index*/, QListView::ScrollHint hint,-
1945 bool above, bool below, const QRect &area, const QRect &rect) const-
1946{-
1947 int verticalValue = verticalScrollBar()->value();-
1948 QRect adjusted = rect.adjusted(-spacing(), -spacing(), spacing(), spacing());-
1949 if (hint == QListView::PositionAtTop || above)
hint == QListV...:PositionAtTopDescription
TRUEnever evaluated
FALSEnever evaluated
aboveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1950 verticalValue += adjusted.top();
never executed: verticalValue += adjusted.top();
0
1951 else if (hint == QListView::PositionAtBottom || below)
hint == QListV...sitionAtBottomDescription
TRUEnever evaluated
FALSEnever evaluated
belowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1952 verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1);
never executed: verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1);
0
1953 else if (hint == QListView::PositionAtCenter)
hint == QListV...sitionAtCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
1954 verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2);
never executed: verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2);
0
1955 return verticalValue;
never executed: return verticalValue;
0
1956}-
1957-
1958int QCommonListViewBase::horizontalOffset() const-
1959{-
1960 return (isRightToLeft() ? horizontalScrollBar()->maximum() - horizontalScrollBar()->value() : horizontalScrollBar()->value());
never executed: return (isRightToLeft() ? horizontalScrollBar()->maximum() - horizontalScrollBar()->value() : horizontalScrollBar()->value());
0
1961}-
1962-
1963int QCommonListViewBase::horizontalScrollToValue(const int /*index*/, QListView::ScrollHint hint,-
1964 bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const-
1965{-
1966 int horizontalValue = horizontalScrollBar()->value();-
1967 if (isRightToLeft()) {
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1968 if (hint == QListView::PositionAtCenter) {
hint == QListV...sitionAtCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
1969 horizontalValue += ((area.width() - rect.width()) / 2) - rect.left();-
1970 } else {
never executed: end of block
0
1971 if (leftOf)
leftOfDescription
TRUEnever evaluated
FALSEnever evaluated
0
1972 horizontalValue -= rect.left();
never executed: horizontalValue -= rect.left();
0
1973 else if (rightOf)
rightOfDescription
TRUEnever evaluated
FALSEnever evaluated
0
1974 horizontalValue += qMin(rect.left(), area.width() - rect.right());
never executed: horizontalValue += qMin(rect.left(), area.width() - rect.right());
0
1975 }
never executed: end of block
0
1976 } else {-
1977 if (hint == QListView::PositionAtCenter) {
hint == QListV...sitionAtCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
1978 horizontalValue += rect.left() - ((area.width()- rect.width()) / 2);-
1979 } else {
never executed: end of block
0
1980 if (leftOf)
leftOfDescription
TRUEnever evaluated
FALSEnever evaluated
0
1981 horizontalValue += rect.left();
never executed: horizontalValue += rect.left();
0
1982 else if (rightOf)
rightOfDescription
TRUEnever evaluated
FALSEnever evaluated
0
1983 horizontalValue += qMin(rect.left(), rect.right() - area.width());
never executed: horizontalValue += qMin(rect.left(), rect.right() - area.width());
0
1984 }
never executed: end of block
0
1985 }-
1986 return horizontalValue;
never executed: return horizontalValue;
0
1987}-
1988-
1989/*-
1990 * ListMode ListView Implementation-
1991*/-
1992QListModeViewBase::QListModeViewBase(QListView *q, QListViewPrivate *d)-
1993 : QCommonListViewBase(q, d)-
1994{-
1995 dd->defaultDropAction = Qt::CopyAction;-
1996}
never executed: end of block
0
1997-
1998#ifndef QT_NO_DRAGANDDROP-
1999QAbstractItemView::DropIndicatorPosition QListModeViewBase::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const-
2000{-
2001 QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport;-
2002 if (!dd->overwrite) {
!dd->overwriteDescription
TRUEnever evaluated
FALSEnever evaluated
0
2003 const int margin = 2;-
2004 if (pos.x() - rect.left() < margin) {
pos.x() - rect.left() < marginDescription
TRUEnever evaluated
FALSEnever evaluated
0
2005 r = QAbstractItemView::AboveItem; // Visually, on the left-
2006 } else if (rect.right() - pos.x() < margin) {
never executed: end of block
rect.right() -...s.x() < marginDescription
TRUEnever evaluated
FALSEnever evaluated
0
2007 r = QAbstractItemView::BelowItem; // Visually, on the right-
2008 } else if (rect.contains(pos, true)) {
never executed: end of block
rect.contains(pos, true)Description
TRUEnever evaluated
FALSEnever evaluated
0
2009 r = QAbstractItemView::OnItem;-
2010 }
never executed: end of block
0
2011 } else {
never executed: end of block
0
2012 QRect touchingRect = rect;-
2013 touchingRect.adjust(-1, -1, 1, 1);-
2014 if (touchingRect.contains(pos, false)) {
touchingRect.c...ns(pos, false)Description
TRUEnever evaluated
FALSEnever evaluated
0
2015 r = QAbstractItemView::OnItem;-
2016 }
never executed: end of block
0
2017 }
never executed: end of block
0
2018-
2019 if (r == QAbstractItemView::OnItem && (!(dd->model->flags(index) & Qt::ItemIsDropEnabled)))
r == QAbstractItemView::OnItemDescription
TRUEnever evaluated
FALSEnever evaluated
(!(dd->model->...sDropEnabled))Description
TRUEnever evaluated
FALSEnever evaluated
0
2020 r = pos.x() < rect.center().x() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem;
never executed: r = pos.x() < rect.center().x() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem;
pos.x() < rect.center().x()Description
TRUEnever evaluated
FALSEnever evaluated
0
2021-
2022 return r;
never executed: return r;
0
2023}-
2024-
2025void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)-
2026{-
2027 if (qq->dragDropMode() == QAbstractItemView::InternalMove
qq->dragDropMo...::InternalMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
2028 && (event->source() != qq || !(event->possibleActions() & Qt::MoveAction)))
event->source() != qqDescription
TRUEnever evaluated
FALSEnever evaluated
!(event->possi...t::MoveAction)Description
TRUEnever evaluated
FALSEnever evaluated
0
2029 return;
never executed: return;
0
2030-
2031 // ignore by default-
2032 event->ignore();-
2033-
2034 // can't use indexAt, doesn't account for spacing.-
2035 QPoint p = event->pos();-
2036 QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);-
2037 rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing());-
2038 const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect);-
2039 QModelIndex index = intersectVector.count() > 0
intersectVector.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2040 ? intersectVector.last() : QModelIndex();-
2041 dd->hover = index;-
2042 if (!dd->droppingOnItself(event, index)
!dd->droppingO...(event, index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2043 && dd->canDrop(event)) {
dd->canDrop(event)Description
TRUEnever evaluated
FALSEnever evaluated
0
2044-
2045 if (index.isValid() && dd->showDropIndicator) {
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
dd->showDropIndicatorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2046 QRect rect = qq->visualRect(index);-
2047 dd->dropIndicatorPosition = position(event->pos(), rect, index);-
2048 // if spacing, should try to draw between items, not just next to item.-
2049 switch (dd->dropIndicatorPosition) {-
2050 case QAbstractItemView::AboveItem:
never executed: case QAbstractItemView::AboveItem:
0
2051 if (dd->isIndexDropEnabled(index.parent())) {
dd->isIndexDro...ndex.parent())Description
TRUEnever evaluated
FALSEnever evaluated
0
2052 dd->dropIndicatorRect = QRect(rect.left()-dd->spacing(), rect.top(), 0, rect.height());-
2053 event->accept();-
2054 } else {
never executed: end of block
0
2055 dd->dropIndicatorRect = QRect();-
2056 }
never executed: end of block
0
2057 break;
never executed: break;
0
2058 case QAbstractItemView::BelowItem:
never executed: case QAbstractItemView::BelowItem:
0
2059 if (dd->isIndexDropEnabled(index.parent())) {
dd->isIndexDro...ndex.parent())Description
TRUEnever evaluated
FALSEnever evaluated
0
2060 dd->dropIndicatorRect = QRect(rect.right()+dd->spacing(), rect.top(), 0, rect.height());-
2061 event->accept();-
2062 } else {
never executed: end of block
0
2063 dd->dropIndicatorRect = QRect();-
2064 }
never executed: end of block
0
2065 break;
never executed: break;
0
2066 case QAbstractItemView::OnItem:
never executed: case QAbstractItemView::OnItem:
0
2067 if (dd->isIndexDropEnabled(index)) {
dd->isIndexDropEnabled(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2068 dd->dropIndicatorRect = rect;-
2069 event->accept();-
2070 } else {
never executed: end of block
0
2071 dd->dropIndicatorRect = QRect();-
2072 }
never executed: end of block
0
2073 break;
never executed: break;
0
2074 case QAbstractItemView::OnViewport:
never executed: case QAbstractItemView::OnViewport:
0
2075 dd->dropIndicatorRect = QRect();-
2076 if (dd->isIndexDropEnabled(qq->rootIndex())) {
dd->isIndexDro...->rootIndex())Description
TRUEnever evaluated
FALSEnever evaluated
0
2077 event->accept(); // allow dropping in empty areas-
2078 }
never executed: end of block
0
2079 break;
never executed: break;
0
2080 }-
2081 } else {
never executed: end of block
0
2082 dd->dropIndicatorRect = QRect();-
2083 dd->dropIndicatorPosition = QAbstractItemView::OnViewport;-
2084 if (dd->isIndexDropEnabled(qq->rootIndex())) {
dd->isIndexDro...->rootIndex())Description
TRUEnever evaluated
FALSEnever evaluated
0
2085 event->accept(); // allow dropping in empty areas-
2086 }
never executed: end of block
0
2087 }
never executed: end of block
0
2088 dd->viewport->update();-
2089 } // can drop
never executed: end of block
0
2090-
2091 if (dd->shouldAutoScroll(event->pos()))
dd->shouldAuto...(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2092 qq->startAutoScroll();
never executed: qq->startAutoScroll();
0
2093}
never executed: end of block
0
2094-
2095/*!-
2096 If the event hasn't already been accepted, determines the index to drop on.-
2097-
2098 if (row == -1 && col == -1)-
2099 // append to this drop index-
2100 else-
2101 // place at row, col in drop index-
2102-
2103 If it returns \c true a drop can be done, and dropRow, dropCol and dropIndex reflects the position of the drop.-
2104 \internal-
2105 */-
2106bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex)-
2107{-
2108 if (event->isAccepted())
event->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
2109 return false;
never executed: return false;
0
2110-
2111 QModelIndex index;-
2112 if (dd->viewport->rect().contains(event->pos())) {
dd->viewport->...(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2113 // can't use indexAt, doesn't account for spacing.-
2114 QPoint p = event->pos();-
2115 QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);-
2116 rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing());-
2117 const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect);-
2118 index = intersectVector.count() > 0
intersectVector.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2119 ? intersectVector.last() : QModelIndex();-
2120 if (!index.isValid())
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2121 index = dd->root;
never executed: index = dd->root;
0
2122 }
never executed: end of block
0
2123-
2124 // If we are allowed to do the drop-
2125 if (dd->model->supportedDropActions() & event->dropAction()) {
dd->model->sup...->dropAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
2126 int row = -1;-
2127 int col = -1;-
2128 if (index != dd->root) {
index != dd->rootDescription
TRUEnever evaluated
FALSEnever evaluated
0
2129 dd->dropIndicatorPosition = position(event->pos(), qq->visualRect(index), index);-
2130 switch (dd->dropIndicatorPosition) {-
2131 case QAbstractItemView::AboveItem:
never executed: case QAbstractItemView::AboveItem:
0
2132 row = index.row();-
2133 col = index.column();-
2134 index = index.parent();-
2135 break;
never executed: break;
0
2136 case QAbstractItemView::BelowItem:
never executed: case QAbstractItemView::BelowItem:
0
2137 row = index.row() + 1;-
2138 col = index.column();-
2139 index = index.parent();-
2140 break;
never executed: break;
0
2141 case QAbstractItemView::OnItem:
never executed: case QAbstractItemView::OnItem:
0
2142 case QAbstractItemView::OnViewport:
never executed: case QAbstractItemView::OnViewport:
0
2143 break;
never executed: break;
0
2144 }-
2145 } else {
never executed: end of block
0
2146 dd->dropIndicatorPosition = QAbstractItemView::OnViewport;-
2147 }
never executed: end of block
0
2148 *dropIndex = index;-
2149 *dropRow = row;-
2150 *dropCol = col;-
2151 if (!dd->droppingOnItself(event, index))
!dd->droppingO...(event, index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2152 return true;
never executed: return true;
0
2153 }
never executed: end of block
0
2154 return false;
never executed: return false;
0
2155}-
2156-
2157#endif //QT_NO_DRAGANDDROP-
2158-
2159void QListModeViewBase::updateVerticalScrollBar(const QSize &step)-
2160{-
2161 if (verticalScrollMode() == QAbstractItemView::ScrollPerItem
verticalScroll...:ScrollPerItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2162 && ((flow() == QListView::TopToBottom && !isWrapping())
flow() == QLis...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
!isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
2163 || (flow() == QListView::LeftToRight && isWrapping()))) {
flow() == QLis...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
2164 const int steps = (flow() == QListView::TopToBottom ? scrollValueMap : segmentPositions).count() - 1;
flow() == QLis...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
2165 if (steps > 0) {
steps > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2166 const int pageSteps = perItemScrollingPageSteps(viewport()->height(), contentsSize.height(), isWrapping());-
2167 verticalScrollBar()->setSingleStep(1);-
2168 verticalScrollBar()->setPageStep(pageSteps);-
2169 verticalScrollBar()->setRange(0, steps - pageSteps);-
2170 } else {
never executed: end of block
0
2171 verticalScrollBar()->setRange(0, 0);-
2172 }
never executed: end of block
0
2173 // } else if (vertical && d->isWrapping() && d->movement == Static) {-
2174 // ### wrapped scrolling in flow direction-
2175 } else {-
2176 QCommonListViewBase::updateVerticalScrollBar(step);-
2177 }
never executed: end of block
0
2178}-
2179-
2180void QListModeViewBase::updateHorizontalScrollBar(const QSize &step)-
2181{-
2182 if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem
horizontalScro...:ScrollPerItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2183 && ((flow() == QListView::TopToBottom && isWrapping())
flow() == QLis...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
2184 || (flow() == QListView::LeftToRight && !isWrapping()))) {
flow() == QLis...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
!isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
2185 int steps = (flow() == QListView::TopToBottom ? segmentPositions : scrollValueMap).count() - 1;
flow() == QLis...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
2186 if (steps > 0) {
steps > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2187 const int pageSteps = perItemScrollingPageSteps(viewport()->width(), contentsSize.width(), isWrapping());-
2188 horizontalScrollBar()->setSingleStep(1);-
2189 horizontalScrollBar()->setPageStep(pageSteps);-
2190 horizontalScrollBar()->setRange(0, steps - pageSteps);-
2191 } else {
never executed: end of block
0
2192 horizontalScrollBar()->setRange(0, 0);-
2193 }
never executed: end of block
0
2194 } else {-
2195 QCommonListViewBase::updateHorizontalScrollBar(step);-
2196 }
never executed: end of block
0
2197}-
2198-
2199int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hint,-
2200 bool above, bool below, const QRect &area, const QRect &rect) const-
2201{-
2202 if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
verticalScroll...:ScrollPerItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2203 int value;-
2204 if (scrollValueMap.isEmpty()) {
scrollValueMap.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2205 value = 0;-
2206 } else {
never executed: end of block
0
2207 int scrollBarValue = verticalScrollBar()->value();-
2208 int numHidden = 0;-
2209 for (int i = 0; i < flowPositions.count() - 1 && i <= scrollBarValue; ++i)
i < flowPositions.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
i <= scrollBarValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
2210 if (isHidden(i))
isHidden(i)Description
TRUEnever evaluated
FALSEnever evaluated
0
2211 ++numHidden;
never executed: ++numHidden;
0
2212 value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()) - numHidden, flowPositions.count() - 1);-
2213 }
never executed: end of block
0
2214 if (above)
aboveDescription
TRUEnever evaluated
FALSEnever evaluated
0
2215 hint = QListView::PositionAtTop;
never executed: hint = QListView::PositionAtTop;
0
2216 else if (below)
belowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2217 hint = QListView::PositionAtBottom;
never executed: hint = QListView::PositionAtBottom;
0
2218 if (hint == QListView::EnsureVisible)
hint == QListV...:EnsureVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2219 return value;
never executed: return value;
0
2220-
2221 return perItemScrollToValue(index, value, area.height(), hint, Qt::Vertical, isWrapping(), rect.height());
never executed: return perItemScrollToValue(index, value, area.height(), hint, Qt::Vertical, isWrapping(), rect.height());
0
2222 }-
2223-
2224 return QCommonListViewBase::verticalScrollToValue(index, hint, above, below, area, rect);
never executed: return QCommonListViewBase::verticalScrollToValue(index, hint, above, below, area, rect);
0
2225}-
2226-
2227int QListModeViewBase::horizontalOffset() const-
2228{-
2229 if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) {
horizontalScro...:ScrollPerItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2230 if (isWrapping()) {
isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
2231 if (flow() == QListView::TopToBottom && !segmentPositions.isEmpty()) {
flow() == QLis...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
!segmentPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2232 const int max = segmentPositions.count() - 1;-
2233 int currentValue = qBound(0, horizontalScrollBar()->value(), max);-
2234 int position = segmentPositions.at(currentValue);-
2235 int maximumValue = qBound(0, horizontalScrollBar()->maximum(), max);-
2236 int maximum = segmentPositions.at(maximumValue);-
2237 return (isRightToLeft() ? maximum - position : position);
never executed: return (isRightToLeft() ? maximum - position : position);
0
2238 }-
2239 } else if (flow() == QListView::LeftToRight && !flowPositions.isEmpty()) {
never executed: end of block
flow() == QLis...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
!flowPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2240 int position = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->value()));-
2241 int maximum = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->maximum()));-
2242 return (isRightToLeft() ? maximum - position : position);
never executed: return (isRightToLeft() ? maximum - position : position);
0
2243 }-
2244 }
never executed: end of block
0
2245 return QCommonListViewBase::horizontalOffset();
never executed: return QCommonListViewBase::horizontalOffset();
0
2246}-
2247-
2248int QListModeViewBase::verticalOffset() const-
2249{-
2250 if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
verticalScroll...:ScrollPerItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2251 if (isWrapping()) {
isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
2252 if (flow() == QListView::LeftToRight && !segmentPositions.isEmpty()) {
flow() == QLis...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
!segmentPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2253 int value = verticalScrollBar()->value();-
2254 if (value >= segmentPositions.count())
value >= segme...itions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2255 return 0;
never executed: return 0;
0
2256 return segmentPositions.at(value) - spacing();
never executed: return segmentPositions.at(value) - spacing();
0
2257 }-
2258 } else if (flow() == QListView::TopToBottom && !flowPositions.isEmpty()) {
never executed: end of block
flow() == QLis...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
!flowPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2259 int value = verticalScrollBar()->value();-
2260 if (value > scrollValueMap.count())
value > scrollValueMap.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2261 return 0;
never executed: return 0;
0
2262 return flowPositions.at(scrollValueMap.at(value)) - spacing();
never executed: return flowPositions.at(scrollValueMap.at(value)) - spacing();
0
2263 }-
2264 }
never executed: end of block
0
2265 return QCommonListViewBase::verticalOffset();
never executed: return QCommonListViewBase::verticalOffset();
0
2266}-
2267-
2268int QListModeViewBase::horizontalScrollToValue(int index, QListView::ScrollHint hint,-
2269 bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const-
2270{-
2271 if (horizontalScrollMode() != QAbstractItemView::ScrollPerItem)
horizontalScro...:ScrollPerItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2272 return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect);
never executed: return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect);
0
2273-
2274 int value;-
2275 if (scrollValueMap.isEmpty())
scrollValueMap.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2276 value = 0;
never executed: value = 0;
0
2277 else-
2278 value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1);
never executed: value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1);
0
2279 if (leftOf)
leftOfDescription
TRUEnever evaluated
FALSEnever evaluated
0
2280 hint = QListView::PositionAtTop;
never executed: hint = QListView::PositionAtTop;
0
2281 else if (rightOf)
rightOfDescription
TRUEnever evaluated
FALSEnever evaluated
0
2282 hint = QListView::PositionAtBottom;
never executed: hint = QListView::PositionAtBottom;
0
2283 if (hint == QListView::EnsureVisible)
hint == QListV...:EnsureVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2284 return value;
never executed: return value;
0
2285-
2286 return perItemScrollToValue(index, value, area.width(), hint, Qt::Horizontal, isWrapping(), rect.width());
never executed: return perItemScrollToValue(index, value, area.width(), hint, Qt::Horizontal, isWrapping(), rect.width());
0
2287}-
2288-
2289void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)-
2290{-
2291 // ### reorder this logic-
2292 const int verticalValue = verticalScrollBar()->value();-
2293 const int horizontalValue = horizontalScrollBar()->value();-
2294 const bool vertical = (verticalScrollMode() == QAbstractItemView::ScrollPerItem);-
2295 const bool horizontal = (horizontalScrollMode() == QAbstractItemView::ScrollPerItem);-
2296-
2297 if (isWrapping()) {
isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
2298 if (segmentPositions.isEmpty())
segmentPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2299 return;
never executed: return;
0
2300 const int max = segmentPositions.count() - 1;-
2301 if (horizontal && flow() == QListView::TopToBottom && dx != 0) {
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
flow() == QLis...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
dx != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2302 int currentValue = qBound(0, horizontalValue, max);-
2303 int previousValue = qBound(0, currentValue + dx, max);-
2304 int currentCoordinate = segmentPositions.at(currentValue) - spacing();-
2305 int previousCoordinate = segmentPositions.at(previousValue) - spacing();-
2306 dx = previousCoordinate - currentCoordinate;-
2307 } else if (vertical && flow() == QListView::LeftToRight && dy != 0) {
never executed: end of block
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
flow() == QLis...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
dy != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2308 int currentValue = qBound(0, verticalValue, max);-
2309 int previousValue = qBound(0, currentValue + dy, max);-
2310 int currentCoordinate = segmentPositions.at(currentValue) - spacing();-
2311 int previousCoordinate = segmentPositions.at(previousValue) - spacing();-
2312 dy = previousCoordinate - currentCoordinate;-
2313 }
never executed: end of block
0
2314 } else {
never executed: end of block
0
2315 if (flowPositions.isEmpty())
flowPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2316 return;
never executed: return;
0
2317 const int max = scrollValueMap.count() - 1;-
2318 if (vertical && flow() == QListView::TopToBottom && dy != 0) {
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
flow() == QLis...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
dy != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2319 int currentValue = qBound(0, verticalValue, max);-
2320 int previousValue = qBound(0, currentValue + dy, max);-
2321 int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue));-
2322 int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue));-
2323 dy = previousCoordinate - currentCoordinate;-
2324 } else if (horizontal && flow() == QListView::LeftToRight && dx != 0) {
never executed: end of block
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
flow() == QLis...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
dx != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2325 int currentValue = qBound(0, horizontalValue, max);-
2326 int previousValue = qBound(0, currentValue + dx, max);-
2327 int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue));-
2328 int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue));-
2329 dx = previousCoordinate - currentCoordinate;-
2330 }
never executed: end of block
0
2331 }
never executed: end of block
0
2332 QCommonListViewBase::scrollContentsBy(dx, dy, scrollElasticBand);-
2333}
never executed: end of block
0
2334-
2335bool QListModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)-
2336{-
2337 doStaticLayout(info);-
2338 if (batchStartRow > max) { // stop items layout
batchStartRow > maxDescription
TRUEnever evaluated
FALSEnever evaluated
0
2339 flowPositions.resize(flowPositions.count());-
2340 segmentPositions.resize(segmentPositions.count());-
2341 segmentStartRows.resize(segmentStartRows.count());-
2342 return true; // done
never executed: return true;
0
2343 }-
2344 return false; // not done
never executed: return false;
0
2345}-
2346-
2347QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) const-
2348{-
2349 if (flowPositions.isEmpty()
flowPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2350 || segmentPositions.isEmpty()
segmentPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2351 || index.row() >= flowPositions.count())
index.row() >=...itions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2352 return QListViewItem();
never executed: return QListViewItem();
0
2353-
2354 const int segment = qBinarySearch<int>(segmentStartRows, index.row(),-
2355 0, segmentStartRows.count() - 1);-
2356-
2357-
2358 QStyleOptionViewItem options = viewOptions();-
2359 options.rect.setSize(contentsSize);-
2360 QSize size = (uniformItemSizes() && cachedItemSize().isValid())
uniformItemSizes()Description
TRUEnever evaluated
FALSEnever evaluated
cachedItemSize().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2361 ? cachedItemSize() : itemSize(options, index);-
2362-
2363 QPoint pos;-
2364 if (flow() == QListView::LeftToRight) {
flow() == QLis...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2365 pos.setX(flowPositions.at(index.row()));-
2366 pos.setY(segmentPositions.at(segment));-
2367 } else { // TopToBottom
never executed: end of block
0
2368 pos.setY(flowPositions.at(index.row()));-
2369 pos.setX(segmentPositions.at(segment));-
2370 if (isWrapping()) { // make the items as wide as the segment
isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
2371 int right = (segment + 1 >= segmentPositions.count()
segment + 1 >=...itions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2372 ? contentsSize.width()-
2373 : segmentPositions.at(segment + 1));-
2374 size.setWidth(right - pos.x());-
2375 } else { // make the items as wide as the viewport
never executed: end of block
0
2376 size.setWidth(qMax(size.width(), viewport()->width() - 2 * spacing()));-
2377 }
never executed: end of block
0
2378 }-
2379-
2380 return QListViewItem(QRect(pos, size), index.row());
never executed: return QListViewItem(QRect(pos, size), index.row());
0
2381}-
2382-
2383QPoint QListModeViewBase::initStaticLayout(const QListViewLayoutInfo &info)-
2384{-
2385 int x, y;-
2386 if (info.first == 0) {
info.first == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2387 flowPositions.clear();-
2388 segmentPositions.clear();-
2389 segmentStartRows.clear();-
2390 segmentExtents.clear();-
2391 scrollValueMap.clear();-
2392 x = info.bounds.left() + info.spacing;-
2393 y = info.bounds.top() + info.spacing;-
2394 segmentPositions.append(info.flow == QListView::LeftToRight ? y : x);-
2395 segmentStartRows.append(0);-
2396 } else if (info.wrap) {
never executed: end of block
info.wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
2397 if (info.flow == QListView::LeftToRight) {
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2398 x = batchSavedPosition;-
2399 y = segmentPositions.constLast();-
2400 } else { // flow == QListView::TopToBottom
never executed: end of block
0
2401 x = segmentPositions.constLast();-
2402 y = batchSavedPosition;-
2403 }
never executed: end of block
0
2404 } else { // not first and not wrap-
2405 if (info.flow == QListView::LeftToRight) {
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2406 x = batchSavedPosition;-
2407 y = info.bounds.top() + info.spacing;-
2408 } else { // flow == QListView::TopToBottom
never executed: end of block
0
2409 x = info.bounds.left() + info.spacing;-
2410 y = batchSavedPosition;-
2411 }
never executed: end of block
0
2412 }-
2413 return QPoint(x, y);
never executed: return QPoint(x, y);
0
2414}-
2415-
2416/*!-
2417 \internal-
2418*/-
2419void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info)-
2420{-
2421 const bool useItemSize = !info.grid.isValid();-
2422 const QPoint topLeft = initStaticLayout(info);-
2423 QStyleOptionViewItem option = viewOptions();-
2424 option.rect = info.bounds;-
2425 option.rect.adjust(info.spacing, info.spacing, -info.spacing, -info.spacing);-
2426-
2427 // The static layout data structures are as follows:-
2428 // One vector contains the coordinate in the direction of layout flow.-
2429 // Another vector contains the coordinates of the segments.-
2430 // A third vector contains the index (model row) of the first item-
2431 // of each segment.-
2432-
2433 int segStartPosition;-
2434 int segEndPosition;-
2435 int deltaFlowPosition;-
2436 int deltaSegPosition;-
2437 int deltaSegHint;-
2438 int flowPosition;-
2439 int segPosition;-
2440-
2441 if (info.flow == QListView::LeftToRight) {
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2442 segStartPosition = info.bounds.left();-
2443 segEndPosition = info.bounds.width();-
2444 flowPosition = topLeft.x();-
2445 segPosition = topLeft.y();-
2446 deltaFlowPosition = info.grid.width(); // dx-
2447 deltaSegPosition = useItemSize ? batchSavedDeltaSeg : info.grid.height(); // dy
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2448 deltaSegHint = info.grid.height();-
2449 } else { // flow == QListView::TopToBottom
never executed: end of block
0
2450 segStartPosition = info.bounds.top();-
2451 segEndPosition = info.bounds.height();-
2452 flowPosition = topLeft.y();-
2453 segPosition = topLeft.x();-
2454 deltaFlowPosition = info.grid.height(); // dy-
2455 deltaSegPosition = useItemSize ? batchSavedDeltaSeg : info.grid.width(); // dx
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2456 deltaSegHint = info.grid.width();-
2457 }
never executed: end of block
0
2458-
2459 for (int row = info.first; row <= info.last; ++row) {
row <= info.lastDescription
TRUEnever evaluated
FALSEnever evaluated
0
2460 if (isHidden(row)) { // ###
isHidden(row)Description
TRUEnever evaluated
FALSEnever evaluated
0
2461 flowPositions.append(flowPosition);-
2462 } else {
never executed: end of block
0
2463 // if we are not using a grid, we need to find the deltas-
2464 if (useItemSize) {
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2465 QSize hint = itemSize(option, modelIndex(row));-
2466 if (info.flow == QListView::LeftToRight) {
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2467 deltaFlowPosition = hint.width() + info.spacing;-
2468 deltaSegHint = hint.height() + info.spacing;-
2469 } else { // TopToBottom
never executed: end of block
0
2470 deltaFlowPosition = hint.height() + info.spacing;-
2471 deltaSegHint = hint.width() + info.spacing;-
2472 }
never executed: end of block
0
2473 }-
2474 // create new segment-
2475 if (info.wrap && (flowPosition + deltaFlowPosition >= segEndPosition)) {
info.wrapDescription
TRUEnever evaluated
FALSEnever evaluated
(flowPosition ...egEndPosition)Description
TRUEnever evaluated
FALSEnever evaluated
0
2476 segmentExtents.append(flowPosition);-
2477 flowPosition = info.spacing + segStartPosition;-
2478 segPosition += deltaSegPosition;-
2479 if (info.wrap)
info.wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
2480 segPosition += info.spacing;
never executed: segPosition += info.spacing;
0
2481 segmentPositions.append(segPosition);-
2482 segmentStartRows.append(row);-
2483 deltaSegPosition = 0;-
2484 }
never executed: end of block
0
2485 // save the flow position of this item-
2486 scrollValueMap.append(flowPositions.count());-
2487 flowPositions.append(flowPosition);-
2488 // prepare for the next item-
2489 deltaSegPosition = qMax(deltaSegHint, deltaSegPosition);-
2490 flowPosition += info.spacing + deltaFlowPosition;-
2491 }
never executed: end of block
0
2492 }-
2493 // used when laying out next batch-
2494 batchSavedPosition = flowPosition;-
2495 batchSavedDeltaSeg = deltaSegPosition;-
2496 batchStartRow = info.last + 1;-
2497 if (info.last == info.max)
info.last == info.maxDescription
TRUEnever evaluated
FALSEnever evaluated
0
2498 flowPosition -= info.spacing; // remove extra spacing
never executed: flowPosition -= info.spacing;
0
2499 // set the contents size-
2500 QRect rect = info.bounds;-
2501 if (info.flow == QListView::LeftToRight) {
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2502 rect.setRight(segmentPositions.count() == 1 ? flowPosition : info.bounds.right());-
2503 rect.setBottom(segPosition + deltaSegPosition);-
2504 } else { // TopToBottom
never executed: end of block
0
2505 rect.setRight(segPosition + deltaSegPosition);-
2506 rect.setBottom(segmentPositions.count() == 1 ? flowPosition : info.bounds.bottom());-
2507 }
never executed: end of block
0
2508 contentsSize = QSize(rect.right(), rect.bottom());-
2509 // if it is the last batch, save the end of the segments-
2510 if (info.last == info.max) {
info.last == info.maxDescription
TRUEnever evaluated
FALSEnever evaluated
0
2511 segmentExtents.append(flowPosition);-
2512 scrollValueMap.append(flowPositions.count());-
2513 flowPositions.append(flowPosition);-
2514 segmentPositions.append(info.wrap ? segPosition + deltaSegPosition : INT_MAX);-
2515 }
never executed: end of block
0
2516 // if the new items are visble, update the viewport-
2517 QRect changedRect(topLeft, rect.bottomRight());-
2518 if (clipRect().intersects(changedRect))
clipRect().int...s(changedRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
2519 viewport()->update();
never executed: viewport()->update();
0
2520}
never executed: end of block
0
2521-
2522/*!-
2523 \internal-
2524 Finds the set of items intersecting with \a area.-
2525 In this function, itemsize is counted from topleft to the start of the next item.-
2526*/-
2527QVector<QModelIndex> QListModeViewBase::intersectingSet(const QRect &area) const-
2528{-
2529 QVector<QModelIndex> ret;-
2530 int segStartPosition;-
2531 int segEndPosition;-
2532 int flowStartPosition;-
2533 int flowEndPosition;-
2534 if (flow() == QListView::LeftToRight) {
flow() == QLis...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2535 segStartPosition = area.top();-
2536 segEndPosition = area.bottom();-
2537 flowStartPosition = area.left();-
2538 flowEndPosition = area.right();-
2539 } else {
never executed: end of block
0
2540 segStartPosition = area.left();-
2541 segEndPosition = area.right();-
2542 flowStartPosition = area.top();-
2543 flowEndPosition = area.bottom();-
2544 }
never executed: end of block
0
2545 if (segmentPositions.count() < 2 || flowPositions.isEmpty())
segmentPositions.count() < 2Description
TRUEnever evaluated
FALSEnever evaluated
flowPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2546 return ret;
never executed: return ret;
0
2547 // the last segment position is actually the edge of the last segment-
2548 const int segLast = segmentPositions.count() - 2;-
2549 int seg = qBinarySearch<int>(segmentPositions, segStartPosition, 0, segLast + 1);-
2550 for (; seg <= segLast && segmentPositions.at(seg) <= segEndPosition; ++seg) {
seg <= segLastDescription
TRUEnever evaluated
FALSEnever evaluated
segmentPositio...segEndPositionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2551 int first = segmentStartRows.at(seg);-
2552 int last = (seg < segLast ? segmentStartRows.at(seg + 1) : batchStartRow) - 1;
seg < segLastDescription
TRUEnever evaluated
FALSEnever evaluated
0
2553 if (segmentExtents.at(seg) < flowStartPosition)
segmentExtents...wStartPositionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2554 continue;
never executed: continue;
0
2555 int row = qBinarySearch<int>(flowPositions, flowStartPosition, first, last);-
2556 for (; row <= last && flowPositions.at(row) <= flowEndPosition; ++row) {
row <= lastDescription
TRUEnever evaluated
FALSEnever evaluated
flowPositions....lowEndPositionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2557 if (isHidden(row))
isHidden(row)Description
TRUEnever evaluated
FALSEnever evaluated
0
2558 continue;
never executed: continue;
0
2559 QModelIndex index = modelIndex(row);-
2560 if (index.isValid())
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2561 ret += index;
never executed: ret += index;
0
2562#if 0 // for debugging-
2563 else-
2564 qWarning("intersectingSet: row %d was invalid", row);-
2565#endif-
2566 }
never executed: end of block
0
2567 }
never executed: end of block
0
2568 return ret;
never executed: return ret;
0
2569}-
2570-
2571void QListModeViewBase::dataChanged(const QModelIndex &, const QModelIndex &)-
2572{-
2573 dd->doDelayedItemsLayout();-
2574}
never executed: end of block
0
2575-
2576-
2577QRect QListModeViewBase::mapToViewport(const QRect &rect) const-
2578{-
2579 if (isWrapping())
isWrapping()Description
TRUEnever evaluated
FALSEnever evaluated
0
2580 return rect;
never executed: return rect;
0
2581 // If the listview is in "listbox-mode", the items are as wide as the view.-
2582 // But we don't shrink the items.-
2583 QRect result = rect;-
2584 if (flow() == QListView::TopToBottom) {
flow() == QLis...w::TopToBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
2585 result.setLeft(spacing());-
2586 result.setWidth(qMax(rect.width(), qMax(contentsSize.width(), viewport()->width()) - 2 * spacing()));-
2587 } else { // LeftToRight
never executed: end of block
0
2588 result.setTop(spacing());-
2589 result.setHeight(qMax(rect.height(), qMax(contentsSize.height(), viewport()->height()) - 2 * spacing()));-
2590 }
never executed: end of block
0
2591 return result;
never executed: return result;
0
2592}-
2593-
2594int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wrap) const-
2595{-
2596 QVector<int> positions;-
2597 if (wrap)
wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
2598 positions = segmentPositions;
never executed: positions = segmentPositions;
0
2599 else if (!flowPositions.isEmpty()) {
!flowPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2600 positions.reserve(scrollValueMap.size());-
2601 foreach (int itemShown, scrollValueMap)-
2602 positions.append(flowPositions.at(itemShown));
never executed: positions.append(flowPositions.at(itemShown));
0
2603 }
never executed: end of block
0
2604 if (positions.isEmpty() || bounds <= length)
positions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
bounds <= lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2605 return positions.count();
never executed: return positions.count();
0
2606 if (uniformItemSizes()) {
uniformItemSizes()Description
TRUEnever evaluated
FALSEnever evaluated
0
2607 for (int i = 1; i < positions.count(); ++i)
i < positions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2608 if (positions.at(i) > 0)
positions.at(i) > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2609 return length / positions.at(i);
never executed: return length / positions.at(i);
0
2610 return 0; // all items had height 0
never executed: return 0;
0
2611 }-
2612 int pageSteps = 0;-
2613 int steps = positions.count() - 1;-
2614 int max = qMax(length, bounds);-
2615 int min = qMin(length, bounds);-
2616 int pos = min - (max - positions.constLast());-
2617-
2618 while (pos >= 0 && steps > 0) {
pos >= 0Description
TRUEnever evaluated
FALSEnever evaluated
steps > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2619 pos -= (positions.at(steps) - positions.at(steps - 1));-
2620 if (pos >= 0) //this item should be visible
pos >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2621 ++pageSteps;
never executed: ++pageSteps;
0
2622 --steps;-
2623 }
never executed: end of block
0
2624-
2625 // at this point we know that positions has at least one entry-
2626 return qMax(pageSteps, 1);
never executed: return qMax(pageSteps, 1);
0
2627}-
2628-
2629int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int viewportSize,-
2630 QAbstractItemView::ScrollHint hint,-
2631 Qt::Orientation orientation, bool wrap, int itemExtent) const-
2632{-
2633 if (index < 0)
index < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2634 return scrollValue;
never executed: return scrollValue;
0
2635-
2636 itemExtent += spacing();-
2637 QVector<int> visibleFlowPositions;-
2638 visibleFlowPositions.reserve(flowPositions.count() - 1);-
2639 for (int i = 0; i < flowPositions.count() - 1; i++) { // flowPositions count is +1 larger than actual row count
i < flowPositions.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2640 if (!isHidden(i))
!isHidden(i)Description
TRUEnever evaluated
FALSEnever evaluated
0
2641 visibleFlowPositions.append(flowPositions.at(i));
never executed: visibleFlowPositions.append(flowPositions.at(i));
0
2642 }
never executed: end of block
0
2643-
2644 if (!wrap) {
!wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
2645 int topIndex = index;-
2646 const int bottomIndex = topIndex;-
2647 const int bottomCoordinate = visibleFlowPositions.at(index);-
2648-
2649 while (topIndex > 0 &&
topIndex > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2650 (bottomCoordinate - visibleFlowPositions.at(topIndex - 1) + itemExtent) <= (viewportSize)) {
(bottomCoordin...(viewportSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
2651 topIndex--;-
2652 }
never executed: end of block
0
2653-
2654 const int itemCount = bottomIndex - topIndex + 1;-
2655 switch (hint) {-
2656 case QAbstractItemView::PositionAtTop:
never executed: case QAbstractItemView::PositionAtTop:
0
2657 return index;
never executed: return index;
0
2658 case QAbstractItemView::PositionAtBottom:
never executed: case QAbstractItemView::PositionAtBottom:
0
2659 return index - itemCount + 1;
never executed: return index - itemCount + 1;
0
2660 case QAbstractItemView::PositionAtCenter:
never executed: case QAbstractItemView::PositionAtCenter:
0
2661 return index - (itemCount / 2);
never executed: return index - (itemCount / 2);
0
2662 default:
never executed: default:
0
2663 break;
never executed: break;
0
2664 }-
2665 } else { // wrapping-
2666 Qt::Orientation flowOrientation = (flow() == QListView::LeftToRight
flow() == QLis...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2667 ? Qt::Horizontal : Qt::Vertical);-
2668 if (flowOrientation == orientation) { // scrolling in the "flow" direction
flowOrientation == orientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
2669 // ### wrapped scrolling in the flow direction-
2670 return visibleFlowPositions.at(index); // ### always pixel based for now
never executed: return visibleFlowPositions.at(index);
0
2671 } else if (!segmentStartRows.isEmpty()) { // we are scrolling in the "segment" direction
!segmentStartRows.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2672 int segment = qBinarySearch<int>(segmentStartRows, index, 0, segmentStartRows.count() - 1);-
2673 int leftSegment = segment;-
2674 const int rightSegment = leftSegment;-
2675 const int bottomCoordinate = segmentPositions.at(segment);-
2676-
2677 while (leftSegment > scrollValue &&
leftSegment > scrollValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
2678 (bottomCoordinate - segmentPositions.at(leftSegment-1) + itemExtent) <= (viewportSize)) {
(bottomCoordin...(viewportSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
2679 leftSegment--;-
2680 }
never executed: end of block
0
2681-
2682 const int segmentCount = rightSegment - leftSegment + 1;-
2683 switch (hint) {-
2684 case QAbstractItemView::PositionAtTop:
never executed: case QAbstractItemView::PositionAtTop:
0
2685 return segment;
never executed: return segment;
0
2686 case QAbstractItemView::PositionAtBottom:
never executed: case QAbstractItemView::PositionAtBottom:
0
2687 return segment - segmentCount + 1;
never executed: return segment - segmentCount + 1;
0
2688 case QAbstractItemView::PositionAtCenter:
never executed: case QAbstractItemView::PositionAtCenter:
0
2689 return segment - (segmentCount / 2);
never executed: return segment - (segmentCount / 2);
0
2690 default:
never executed: default:
0
2691 break;
never executed: break;
0
2692 }-
2693 }-
2694 }
never executed: end of block
0
2695 return scrollValue;
never executed: return scrollValue;
0
2696}-
2697-
2698void QListModeViewBase::clear()-
2699{-
2700 flowPositions.clear();-
2701 segmentPositions.clear();-
2702 segmentStartRows.clear();-
2703 segmentExtents.clear();-
2704 batchSavedPosition = 0;-
2705 batchStartRow = 0;-
2706 batchSavedDeltaSeg = 0;-
2707}
never executed: end of block
0
2708-
2709/*-
2710 * IconMode ListView Implementation-
2711*/-
2712-
2713void QIconModeViewBase::setPositionForIndex(const QPoint &position, const QModelIndex &index)-
2714{-
2715 if (index.row() >= items.count())
index.row() >= items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2716 return;
never executed: return;
0
2717 const QSize oldContents = contentsSize;-
2718 qq->update(index); // update old position-
2719 moveItem(index.row(), position);-
2720 qq->update(index); // update new position-
2721-
2722 if (contentsSize != oldContents)
contentsSize != oldContentsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2723 dd->viewUpdateGeometries(); // update the scroll bars
never executed: dd->viewUpdateGeometries();
0
2724}
never executed: end of block
0
2725-
2726void QIconModeViewBase::appendHiddenRow(int row)-
2727{-
2728 if (row >= 0 && row < items.count()) //remove item
row >= 0Description
TRUEnever evaluated
FALSEnever evaluated
row < items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2729 tree.removeLeaf(items.at(row).rect(), row);
never executed: tree.removeLeaf(items.at(row).rect(), row);
0
2730 QCommonListViewBase::appendHiddenRow(row);-
2731}
never executed: end of block
0
2732-
2733void QIconModeViewBase::removeHiddenRow(int row)-
2734{-
2735 QCommonListViewBase::removeHiddenRow(row);-
2736 if (row >= 0 && row < items.count()) //insert item
row >= 0Description
TRUEnever evaluated
FALSEnever evaluated
row < items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2737 tree.insertLeaf(items.at(row).rect(), row);
never executed: tree.insertLeaf(items.at(row).rect(), row);
0
2738}
never executed: end of block
0
2739-
2740#ifndef QT_NO_DRAGANDDROP-
2741bool QIconModeViewBase::filterStartDrag(Qt::DropActions supportedActions)-
2742{-
2743 // This function does the same thing as in QAbstractItemView::startDrag(),-
2744 // plus adding viewitems to the draggedItems list.-
2745 // We need these items to draw the drag items-
2746 QModelIndexList indexes = dd->selectionModel->selectedIndexes();-
2747 if (indexes.count() > 0 ) {
indexes.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2748 if (viewport()->acceptDrops()) {
viewport()->acceptDrops()Description
TRUEnever evaluated
FALSEnever evaluated
0
2749 QModelIndexList::ConstIterator it = indexes.constBegin();-
2750 for (; it != indexes.constEnd(); ++it)
it != indexes.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
2751 if (dd->model->flags(*it) & Qt::ItemIsDragEnabled
dd->model->fla...mIsDragEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
2752 && (*it).column() == dd->column)
(*it).column() == dd->columnDescription
TRUEnever evaluated
FALSEnever evaluated
0
2753 draggedItems.push_back(*it);
never executed: draggedItems.push_back(*it);
0
2754 }
never executed: end of block
0
2755-
2756 QRect rect;-
2757 QPixmap pixmap = dd->renderToPixmap(indexes, &rect);-
2758 rect.adjust(horizontalOffset(), verticalOffset(), 0, 0);-
2759 QDrag *drag = new QDrag(qq);-
2760 drag->setMimeData(dd->model->mimeData(indexes));-
2761 drag->setPixmap(pixmap);-
2762 drag->setHotSpot(dd->pressedPosition - rect.topLeft());-
2763 Qt::DropAction action = drag->exec(supportedActions, dd->defaultDropAction);-
2764 draggedItems.clear();-
2765 if (action == Qt::MoveAction)
action == Qt::MoveActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2766 dd->clearOrRemove();
never executed: dd->clearOrRemove();
0
2767 }
never executed: end of block
0
2768 return true;
never executed: return true;
0
2769}-
2770-
2771bool QIconModeViewBase::filterDropEvent(QDropEvent *e)-
2772{-
2773 if (e->source() != qq)
e->source() != qqDescription
TRUEnever evaluated
FALSEnever evaluated
0
2774 return false;
never executed: return false;
0
2775-
2776 const QSize contents = contentsSize;-
2777 QPoint offset(horizontalOffset(), verticalOffset());-
2778 QPoint end = e->pos() + offset;-
2779 if (qq->acceptDrops()) {
qq->acceptDrops()Description
TRUEnever evaluated
FALSEnever evaluated
0
2780 const Qt::ItemFlags dropableFlags = Qt::ItemIsDropEnabled|Qt::ItemIsEnabled;-
2781 const QVector<QModelIndex> &dropIndices = intersectingSet(QRect(end, QSize(1, 1)));-
2782 foreach (const QModelIndex &index, dropIndices)-
2783 if ((index.flags() & dropableFlags) == dropableFlags)
(index.flags()... dropableFlagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2784 return false;
never executed: return false;
0
2785 }
never executed: end of block
0
2786 QPoint start = dd->pressedPosition;-
2787 QPoint delta = (dd->movement == QListView::Snap ? snapToGrid(end) - snapToGrid(start) : end - start);
dd->movement =...ListView::SnapDescription
TRUEnever evaluated
FALSEnever evaluated
0
2788 const QList<QModelIndex> indexes = dd->selectionModel->selectedIndexes();-
2789 for (const auto &index : indexes) {-
2790 QRect rect = dd->rectForIndex(index);-
2791 viewport()->update(dd->mapToViewport(rect, false));-
2792 QPoint dest = rect.topLeft() + delta;-
2793 if (qq->isRightToLeft())
qq->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
2794 dest.setX(dd->flipX(dest.x()) - rect.width());
never executed: dest.setX(dd->flipX(dest.x()) - rect.width());
0
2795 moveItem(index.row(), dest);-
2796 qq->update(index);-
2797 }
never executed: end of block
0
2798 dd->stopAutoScroll();-
2799 draggedItems.clear();-
2800 dd->emitIndexesMoved(indexes);-
2801 e->accept(); // we have handled the event-
2802 // if the size has not grown, we need to check if it has shrinked-
2803 if (contentsSize != contents) {
contentsSize != contentsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2804 if ((contentsSize.width() <= contents.width()
contentsSize.w...ntents.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
2805 || contentsSize.height() <= contents.height())) {
contentsSize.h...tents.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
2806 updateContentsSize();-
2807 }
never executed: end of block
0
2808 dd->viewUpdateGeometries();-
2809 }
never executed: end of block
0
2810 return true;
never executed: return true;
0
2811}-
2812-
2813bool QIconModeViewBase::filterDragLeaveEvent(QDragLeaveEvent *e)-
2814{-
2815 viewport()->update(draggedItemsRect()); // erase the area-
2816 draggedItemsPos = QPoint(-1, -1); // don't draw the dragged items-
2817 return QCommonListViewBase::filterDragLeaveEvent(e);
never executed: return QCommonListViewBase::filterDragLeaveEvent(e);
0
2818}-
2819-
2820bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e)-
2821{-
2822 if (e->source() != qq || !dd->canDrop(e))
e->source() != qqDescription
TRUEnever evaluated
FALSEnever evaluated
!dd->canDrop(e)Description
TRUEnever evaluated
FALSEnever evaluated
0
2823 return false;
never executed: return false;
0
2824-
2825 // ignore by default-
2826 e->ignore();-
2827 // get old dragged items rect-
2828 QRect itemsRect = this->itemsRect(draggedItems);-
2829 viewport()->update(itemsRect.translated(draggedItemsDelta()));-
2830 // update position-
2831 draggedItemsPos = e->pos();-
2832 // get new items rect-
2833 viewport()->update(itemsRect.translated(draggedItemsDelta()));-
2834 // set the item under the cursor to current-
2835 QModelIndex index;-
2836 if (movement() == QListView::Snap) {
movement() == QListView::SnapDescription
TRUEnever evaluated
FALSEnever evaluated
0
2837 QRect rect(snapToGrid(e->pos() + offset()), gridSize());-
2838 const QVector<QModelIndex> intersectVector = intersectingSet(rect);-
2839 index = intersectVector.count() > 0 ? intersectVector.last() : QModelIndex();
intersectVector.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2840 } else {
never executed: end of block
0
2841 index = qq->indexAt(e->pos());-
2842 }
never executed: end of block
0
2843 // check if we allow drops here-
2844 if (draggedItems.contains(index))
draggedItems.contains(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2845 e->accept(); // allow changing item position
never executed: e->accept();
0
2846 else if (dd->model->flags(index) & Qt::ItemIsDropEnabled)
dd->model->fla...mIsDropEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
2847 e->accept(); // allow dropping on dropenabled items
never executed: e->accept();
0
2848 else if (!index.isValid())
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2849 e->accept(); // allow dropping in empty areas
never executed: e->accept();
0
2850-
2851 // the event was treated. do autoscrolling-
2852 if (dd->shouldAutoScroll(e->pos()))
dd->shouldAutoScroll(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2853 dd->startAutoScroll();
never executed: dd->startAutoScroll();
0
2854 return true;
never executed: return true;
0
2855}-
2856#endif // QT_NO_DRAGANDDROP-
2857-
2858void QIconModeViewBase::setRowCount(int rowCount)-
2859{-
2860 tree.create(qMax(rowCount - hiddenCount(), 0));-
2861}
never executed: end of block
0
2862-
2863void QIconModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)-
2864{-
2865 if (scrollElasticBand)
scrollElasticBandDescription
TRUEnever evaluated
FALSEnever evaluated
0
2866 dd->scrollElasticBandBy(isRightToLeft() ? -dx : dx, dy);
never executed: dd->scrollElasticBandBy(isRightToLeft() ? -dx : dx, dy);
0
2867-
2868 QCommonListViewBase::scrollContentsBy(dx, dy, scrollElasticBand);-
2869 if (!draggedItems.isEmpty())
!draggedItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2870 viewport()->update(draggedItemsRect().translated(dx, dy));
never executed: viewport()->update(draggedItemsRect().translated(dx, dy));
0
2871}
never executed: end of block
0
2872-
2873void QIconModeViewBase::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)-
2874{-
2875 if (column() >= topLeft.column() && column() <= bottomRight.column()) {
column() >= topLeft.column()Description
TRUEnever evaluated
FALSEnever evaluated
column() <= bo...Right.column()Description
TRUEnever evaluated
FALSEnever evaluated
0
2876 QStyleOptionViewItem option = viewOptions();-
2877 int bottom = qMin(items.count(), bottomRight.row() + 1);-
2878 for (int row = topLeft.row(); row < bottom; ++row)
row < bottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
2879 items[row].resize(itemSize(option, modelIndex(row)));
never executed: items[row].resize(itemSize(option, modelIndex(row)));
0
2880 }
never executed: end of block
0
2881}
never executed: end of block
0
2882-
2883bool QIconModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)-
2884{-
2885 if (info.last >= items.count()) {
info.last >= items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2886 //first we create the items-
2887 QStyleOptionViewItem option = viewOptions();-
2888 for (int row = items.count(); row <= info.last; ++row) {
row <= info.lastDescription
TRUEnever evaluated
FALSEnever evaluated
0
2889 QSize size = itemSize(option, modelIndex(row));-
2890 QListViewItem item(QRect(0, 0, size.width(), size.height()), row); // default pos-
2891 items.append(item);-
2892 }
never executed: end of block
0
2893 doDynamicLayout(info);-
2894 }
never executed: end of block
0
2895 return (batchStartRow > max); // done
never executed: return (batchStartRow > max);
0
2896}-
2897-
2898QListViewItem QIconModeViewBase::indexToListViewItem(const QModelIndex &index) const-
2899{-
2900 if (index.isValid() && index.row() < items.count())
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
index.row() < items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2901 return items.at(index.row());
never executed: return items.at(index.row());
0
2902 return QListViewItem();
never executed: return QListViewItem();
0
2903}-
2904-
2905void QIconModeViewBase::initBspTree(const QSize &contents)-
2906{-
2907 // remove all items from the tree-
2908 int leafCount = tree.leafCount();-
2909 for (int l = 0; l < leafCount; ++l)
l < leafCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
2910 tree.leaf(l).clear();
never executed: tree.leaf(l).clear();
0
2911 // we have to get the bounding rect of the items before we can initialize the tree-
2912 QBspTree::Node::Type type = QBspTree::Node::Both; // 2D-
2913 // simple heuristics to get better bsp-
2914 if (contents.height() / contents.width() >= 3)
contents.heigh...s.width() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
2915 type = QBspTree::Node::HorizontalPlane;
never executed: type = QBspTree::Node::HorizontalPlane;
0
2916 else if (contents.width() / contents.height() >= 3)
contents.width....height() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
2917 type = QBspTree::Node::VerticalPlane;
never executed: type = QBspTree::Node::VerticalPlane;
0
2918 // build tree for the bounding rect (not just the contents rect)-
2919 tree.init(QRect(0, 0, contents.width(), contents.height()), type);-
2920}
never executed: end of block
0
2921-
2922QPoint QIconModeViewBase::initDynamicLayout(const QListViewLayoutInfo &info)-
2923{-
2924 int x, y;-
2925 if (info.first == 0) {
info.first == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2926 x = info.bounds.x() + info.spacing;-
2927 y = info.bounds.y() + info.spacing;-
2928 items.reserve(rowCount() - hiddenCount());-
2929 } else {
never executed: end of block
0
2930 int idx = info.first - 1;-
2931 while (idx > 0 && !items.at(idx).isValid())
idx > 0Description
TRUEnever evaluated
FALSEnever evaluated
!items.at(idx).isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2932 --idx;
never executed: --idx;
0
2933 const QListViewItem &item = items.at(idx);-
2934 x = item.x;-
2935 y = item.y;-
2936 if (info.flow == QListView::LeftToRight)
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2937 x += (info.grid.isValid() ? info.grid.width() : item.w) + info.spacing;
never executed: x += (info.grid.isValid() ? info.grid.width() : item.w) + info.spacing;
info.grid.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2938 else-
2939 y += (info.grid.isValid() ? info.grid.height() : item.h) + info.spacing;
never executed: y += (info.grid.isValid() ? info.grid.height() : item.h) + info.spacing;
info.grid.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2940 }-
2941 return QPoint(x, y);
never executed: return QPoint(x, y);
0
2942}-
2943-
2944/*!-
2945 \internal-
2946*/-
2947void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info)-
2948{-
2949 const bool useItemSize = !info.grid.isValid();-
2950 const QPoint topLeft = initDynamicLayout(info);-
2951-
2952 int segStartPosition;-
2953 int segEndPosition;-
2954 int deltaFlowPosition;-
2955 int deltaSegPosition;-
2956 int deltaSegHint;-
2957 int flowPosition;-
2958 int segPosition;-
2959-
2960 if (info.flow == QListView::LeftToRight) {
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2961 segStartPosition = info.bounds.left() + info.spacing;-
2962 segEndPosition = info.bounds.right();-
2963 deltaFlowPosition = info.grid.width(); // dx-
2964 deltaSegPosition = (useItemSize ? batchSavedDeltaSeg : info.grid.height()); // dy
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2965 deltaSegHint = info.grid.height();-
2966 flowPosition = topLeft.x();-
2967 segPosition = topLeft.y();-
2968 } else { // flow == QListView::TopToBottom
never executed: end of block
0
2969 segStartPosition = info.bounds.top() + info.spacing;-
2970 segEndPosition = info.bounds.bottom();-
2971 deltaFlowPosition = info.grid.height(); // dy-
2972 deltaSegPosition = (useItemSize ? batchSavedDeltaSeg : info.grid.width()); // dx
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2973 deltaSegHint = info.grid.width();-
2974 flowPosition = topLeft.y();-
2975 segPosition = topLeft.x();-
2976 }
never executed: end of block
0
2977-
2978 if (moved.count() != items.count())
moved.count() != items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2979 moved.resize(items.count());
never executed: moved.resize(items.count());
0
2980-
2981 QRect rect(QPoint(), topLeft);-
2982 QListViewItem *item = 0;-
2983 for (int row = info.first; row <= info.last; ++row) {
row <= info.lastDescription
TRUEnever evaluated
FALSEnever evaluated
0
2984 item = &items[row];-
2985 if (isHidden(row)) {
isHidden(row)Description
TRUEnever evaluated
FALSEnever evaluated
0
2986 item->invalidate();-
2987 } else {
never executed: end of block
0
2988 // if we are not using a grid, we need to find the deltas-
2989 if (useItemSize) {
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2990 if (info.flow == QListView::LeftToRight)
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2991 deltaFlowPosition = item->w + info.spacing;
never executed: deltaFlowPosition = item->w + info.spacing;
0
2992 else-
2993 deltaFlowPosition = item->h + info.spacing;
never executed: deltaFlowPosition = item->h + info.spacing;
0
2994 } else {-
2995 item->w = qMin<int>(info.grid.width(), item->w);-
2996 item->h = qMin<int>(info.grid.height(), item->h);-
2997 }
never executed: end of block
0
2998-
2999 // create new segment-
3000 if (info.wrap
info.wrapDescription
TRUEnever evaluated
FALSEnever evaluated
0
3001 && flowPosition + deltaFlowPosition > segEndPosition
flowPosition +...segEndPositionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3002 && flowPosition > segStartPosition) {
flowPosition >...gStartPositionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3003 flowPosition = segStartPosition;-
3004 segPosition += deltaSegPosition;-
3005 if (useItemSize)
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3006 deltaSegPosition = 0;
never executed: deltaSegPosition = 0;
0
3007 }
never executed: end of block
0
3008 // We must delay calculation of the seg adjustment, as this item-
3009 // may have caused a wrap to occur-
3010 if (useItemSize) {
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3011 if (info.flow == QListView::LeftToRight)
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3012 deltaSegHint = item->h + info.spacing;
never executed: deltaSegHint = item->h + info.spacing;
0
3013 else-
3014 deltaSegHint = item->w + info.spacing;
never executed: deltaSegHint = item->w + info.spacing;
0
3015 deltaSegPosition = qMax(deltaSegPosition, deltaSegHint);-
3016 }
never executed: end of block
0
3017-
3018 // set the position of the item-
3019 // ### idealy we should have some sort of alignment hint for the item-
3020 // ### (normally that would be a point between the icon and the text)-
3021 if (!moved.testBit(row)) {
!moved.testBit(row)Description
TRUEnever evaluated
FALSEnever evaluated
0
3022 if (info.flow == QListView::LeftToRight) {
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3023 if (useItemSize) {
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3024 item->x = flowPosition;-
3025 item->y = segPosition;-
3026 } else { // use grid
never executed: end of block
0
3027 item->x = flowPosition + ((deltaFlowPosition - item->w) / 2);-
3028 item->y = segPosition;-
3029 }
never executed: end of block
0
3030 } else { // TopToBottom-
3031 if (useItemSize) {
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3032 item->y = flowPosition;-
3033 item->x = segPosition;-
3034 } else { // use grid
never executed: end of block
0
3035 item->y = flowPosition + ((deltaFlowPosition - item->h) / 2);-
3036 item->x = segPosition;-
3037 }
never executed: end of block
0
3038 }-
3039 }-
3040-
3041 // let the contents contain the new item-
3042 if (useItemSize)
useItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3043 rect |= item->rect();
never executed: rect |= item->rect();
0
3044 else if (info.flow == QListView::LeftToRight)
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3045 rect |= QRect(flowPosition, segPosition, deltaFlowPosition, deltaSegPosition);
never executed: rect |= QRect(flowPosition, segPosition, deltaFlowPosition, deltaSegPosition);
0
3046 else // flow == TopToBottom-
3047 rect |= QRect(segPosition, flowPosition, deltaSegPosition, deltaFlowPosition);
never executed: rect |= QRect(segPosition, flowPosition, deltaSegPosition, deltaFlowPosition);
0
3048-
3049 // prepare for next item-
3050 flowPosition += deltaFlowPosition; // current position + item width + gap-
3051 }
never executed: end of block
0
3052 }-
3053 batchSavedDeltaSeg = deltaSegPosition;-
3054 batchStartRow = info.last + 1;-
3055 bool done = (info.last >= rowCount() - 1);-
3056 // resize the content area-
3057 if (done || !info.bounds.contains(item->rect())) {
doneDescription
TRUEnever evaluated
FALSEnever evaluated
!info.bounds.c...(item->rect())Description
TRUEnever evaluated
FALSEnever evaluated
0
3058 contentsSize = rect.size();-
3059 if (info.flow == QListView::LeftToRight)
info.flow == Q...w::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3060 contentsSize.rheight() += info.spacing;
never executed: contentsSize.rheight() += info.spacing;
0
3061 else-
3062 contentsSize.rwidth() += info.spacing;
never executed: contentsSize.rwidth() += info.spacing;
0
3063 }-
3064 if (rect.size().isEmpty())
rect.size().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3065 return;
never executed: return;
0
3066 // resize tree-
3067 int insertFrom = info.first;-
3068 if (done || info.first == 0) {
doneDescription
TRUEnever evaluated
FALSEnever evaluated
info.first == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3069 initBspTree(rect.size());-
3070 insertFrom = 0;-
3071 }
never executed: end of block
0
3072 // insert items in tree-
3073 for (int row = insertFrom; row <= info.last; ++row)
row <= info.lastDescription
TRUEnever evaluated
FALSEnever evaluated
0
3074 tree.insertLeaf(items.at(row).rect(), row);
never executed: tree.insertLeaf(items.at(row).rect(), row);
0
3075 // if the new items are visble, update the viewport-
3076 QRect changedRect(topLeft, rect.bottomRight());-
3077 if (clipRect().intersects(changedRect))
clipRect().int...s(changedRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
3078 viewport()->update();
never executed: viewport()->update();
0
3079}
never executed: end of block
0
3080-
3081QVector<QModelIndex> QIconModeViewBase::intersectingSet(const QRect &area) const-
3082{-
3083 QIconModeViewBase *that = const_cast<QIconModeViewBase*>(this);-
3084 QBspTree::Data data(static_cast<void*>(that));-
3085 QVector<QModelIndex> res;-
3086 that->interSectingVector = &res;-
3087 that->tree.climbTree(area, &QIconModeViewBase::addLeaf, data);-
3088 that->interSectingVector = 0;-
3089 return res;
never executed: return res;
0
3090}-
3091-
3092QRect QIconModeViewBase::itemsRect(const QVector<QModelIndex> &indexes) const-
3093{-
3094 QVector<QModelIndex>::const_iterator it = indexes.begin();-
3095 QListViewItem item = indexToListViewItem(*it);-
3096 QRect rect(item.x, item.y, item.w, item.h);-
3097 for (; it != indexes.end(); ++it) {
it != indexes.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
3098 item = indexToListViewItem(*it);-
3099 rect |= viewItemRect(item);-
3100 }
never executed: end of block
0
3101 return rect;
never executed: return rect;
0
3102}-
3103-
3104int QIconModeViewBase::itemIndex(const QListViewItem &item) const-
3105{-
3106 if (!item.isValid())
!item.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3107 return -1;
never executed: return -1;
0
3108 int i = item.indexHint;-
3109 if (i < items.count()) {
i < items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
3110 if (items.at(i) == item)
items.at(i) == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3111 return i;
never executed: return i;
0
3112 } else {
never executed: end of block
0
3113 i = items.count() - 1;-
3114 }
never executed: end of block
0
3115-
3116 int j = i;-
3117 int c = items.count();-
3118 bool a = true;-
3119 bool b = true;-
3120-
3121 while (a || b) {
aDescription
TRUEnever evaluated
FALSEnever evaluated
bDescription
TRUEnever evaluated
FALSEnever evaluated
0
3122 if (a) {
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
3123 if (items.at(i) == item) {
items.at(i) == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3124 items.at(i).indexHint = i;-
3125 return i;
never executed: return i;
0
3126 }-
3127 a = ++i < c;-
3128 }
never executed: end of block
0
3129 if (b) {
bDescription
TRUEnever evaluated
FALSEnever evaluated
0
3130 if (items.at(j) == item) {
items.at(j) == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3131 items.at(j).indexHint = j;-
3132 return j;
never executed: return j;
0
3133 }-
3134 b = --j > -1;-
3135 }
never executed: end of block
0
3136 }
never executed: end of block
0
3137 return -1;
never executed: return -1;
0
3138}-
3139-
3140void QIconModeViewBase::addLeaf(QVector<int> &leaf, const QRect &area,-
3141 uint visited, QBspTree::Data data)-
3142{-
3143 QListViewItem *vi;-
3144 QIconModeViewBase *_this = static_cast<QIconModeViewBase *>(data.ptr);-
3145 for (int i = 0; i < leaf.count(); ++i) {
i < leaf.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
3146 int idx = leaf.at(i);-
3147 if (idx < 0 || idx >= _this->items.count())
idx < 0Description
TRUEnever evaluated
FALSEnever evaluated
idx >= _this->items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
3148 continue;
never executed: continue;
0
3149 vi = &_this->items[idx];-
3150 Q_ASSERT(vi);-
3151 if (vi->isValid() && vi->rect().intersects(area) && vi->visited != visited) {
vi->isValid()Description
TRUEnever evaluated
FALSEnever evaluated
vi->rect().intersects(area)Description
TRUEnever evaluated
FALSEnever evaluated
vi->visited != visitedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3152 QModelIndex index = _this->dd->listViewItemToIndex(*vi);-
3153 Q_ASSERT(index.isValid());-
3154 _this->interSectingVector->append(index);-
3155 vi->visited = visited;-
3156 }
never executed: end of block
0
3157 }
never executed: end of block
0
3158}
never executed: end of block
0
3159-
3160void QIconModeViewBase::moveItem(int index, const QPoint &dest)-
3161{-
3162 // does not impact on the bintree itself or the contents rect-
3163 QListViewItem *item = &items[index];-
3164 QRect rect = item->rect();-
3165-
3166 // move the item without removing it from the tree-
3167 tree.removeLeaf(rect, index);-
3168 item->move(dest);-
3169 tree.insertLeaf(QRect(dest, rect.size()), index);-
3170-
3171 // resize the contents area-
3172 contentsSize = (QRect(QPoint(0, 0), contentsSize)|QRect(dest, rect.size())).size();-
3173-
3174 // mark the item as moved-
3175 if (moved.count() != items.count())
moved.count() != items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
3176 moved.resize(items.count());
never executed: moved.resize(items.count());
0
3177 moved.setBit(index, true);-
3178}
never executed: end of block
0
3179-
3180QPoint QIconModeViewBase::snapToGrid(const QPoint &pos) const-
3181{-
3182 int x = pos.x() - (pos.x() % gridSize().width());-
3183 int y = pos.y() - (pos.y() % gridSize().height());-
3184 return QPoint(x, y);
never executed: return QPoint(x, y);
0
3185}-
3186-
3187QPoint QIconModeViewBase::draggedItemsDelta() const-
3188{-
3189 if (movement() == QListView::Snap) {
movement() == QListView::SnapDescription
TRUEnever evaluated
FALSEnever evaluated
0
3190 QPoint snapdelta = QPoint((offset().x() % gridSize().width()),-
3191 (offset().y() % gridSize().height()));-
3192 return snapToGrid(draggedItemsPos + snapdelta) - snapToGrid(pressedPosition()) - snapdelta;
never executed: return snapToGrid(draggedItemsPos + snapdelta) - snapToGrid(pressedPosition()) - snapdelta;
0
3193 }-
3194 return draggedItemsPos - pressedPosition();
never executed: return draggedItemsPos - pressedPosition();
0
3195}-
3196-
3197QRect QIconModeViewBase::draggedItemsRect() const-
3198{-
3199 QRect rect = itemsRect(draggedItems);-
3200 rect.translate(draggedItemsDelta());-
3201 return rect;
never executed: return rect;
0
3202}-
3203-
3204void QListViewPrivate::scrollElasticBandBy(int dx, int dy)-
3205{-
3206 if (dx > 0) // right
dx > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3207 elasticBand.moveRight(elasticBand.right() + dx);
never executed: elasticBand.moveRight(elasticBand.right() + dx);
0
3208 else if (dx < 0) // left
dx < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3209 elasticBand.moveLeft(elasticBand.left() - dx);
never executed: elasticBand.moveLeft(elasticBand.left() - dx);
0
3210 if (dy > 0) // down
dy > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3211 elasticBand.moveBottom(elasticBand.bottom() + dy);
never executed: elasticBand.moveBottom(elasticBand.bottom() + dy);
0
3212 else if (dy < 0) // up
dy < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3213 elasticBand.moveTop(elasticBand.top() - dy);
never executed: elasticBand.moveTop(elasticBand.top() - dy);
0
3214}
never executed: end of block
0
3215-
3216void QIconModeViewBase::clear()-
3217{-
3218 tree.destroy();-
3219 items.clear();-
3220 moved.clear();-
3221 batchStartRow = 0;-
3222 batchSavedDeltaSeg = 0;-
3223}
never executed: end of block
0
3224-
3225void QIconModeViewBase::updateContentsSize()-
3226{-
3227 QRect bounding;-
3228 for (int i = 0; i < items.count(); ++i)
i < items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
3229 bounding |= items.at(i).rect();
never executed: bounding |= items.at(i).rect();
0
3230 contentsSize = bounding.size();-
3231}
never executed: end of block
0
3232-
3233/*!-
3234 \reimp-
3235*/-
3236void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)-
3237{-
3238#ifndef QT_NO_ACCESSIBILITY-
3239 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3240 if (current.isValid()) {
current.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3241 int entry = visualIndex(current);-
3242 QAccessibleEvent event(this, QAccessible::Focus);-
3243 event.setChild(entry);-
3244 QAccessible::updateAccessibility(&event);-
3245 }
never executed: end of block
0
3246 }
never executed: end of block
0
3247#endif-
3248 QAbstractItemView::currentChanged(current, previous);-
3249}
never executed: end of block
0
3250-
3251/*!-
3252 \reimp-
3253*/-
3254void QListView::selectionChanged(const QItemSelection &selected,-
3255 const QItemSelection &deselected)-
3256{-
3257#ifndef QT_NO_ACCESSIBILITY-
3258 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3259 // ### does not work properly for selection ranges.-
3260 QModelIndex sel = selected.indexes().value(0);-
3261 if (sel.isValid()) {
sel.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3262 int entry = visualIndex(sel);-
3263 QAccessibleEvent event(this, QAccessible::SelectionAdd);-
3264 event.setChild(entry);-
3265 QAccessible::updateAccessibility(&event);-
3266 }
never executed: end of block
0
3267 QModelIndex desel = deselected.indexes().value(0);-
3268 if (desel.isValid()) {
desel.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3269 int entry = visualIndex(desel);-
3270 QAccessibleEvent event(this, QAccessible::SelectionRemove);-
3271 event.setChild(entry);-
3272 QAccessible::updateAccessibility(&event);-
3273 }
never executed: end of block
0
3274 }
never executed: end of block
0
3275#endif-
3276 QAbstractItemView::selectionChanged(selected, deselected);-
3277}
never executed: end of block
0
3278-
3279int QListView::visualIndex(const QModelIndex &index) const-
3280{-
3281 Q_D(const QListView);-
3282 d->executePostedLayout();-
3283 QListViewItem itm = d->indexToListViewItem(index);-
3284 int visualIndex = d->commonListView->itemIndex(itm);-
3285 for (int row = 0; row <= index.row() && visualIndex >= 0; row++) {
row <= index.row()Description
TRUEnever evaluated
FALSEnever evaluated
visualIndex >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3286 if (d->isHidden(row))
d->isHidden(row)Description
TRUEnever evaluated
FALSEnever evaluated
0
3287 visualIndex--;
never executed: visualIndex--;
0
3288 }
never executed: end of block
0
3289 return visualIndex;
never executed: return visualIndex;
0
3290}-
3291-
3292-
3293/*!-
3294 \since 5.2-
3295 \reimp-
3296*/-
3297QSize QListView::viewportSizeHint() const-
3298{-
3299 return QAbstractItemView::viewportSizeHint();
never executed: return QAbstractItemView::viewportSizeHint();
0
3300}-
3301-
3302QT_END_NAMESPACE-
3303-
3304#include "moc_qlistview.cpp"-
3305-
3306#endif // QT_NO_LISTVIEW-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9