OpenCoverage

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