qabstractitemview.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/itemviews/qabstractitemview.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qabstractitemview.h"-
35-
36#ifndef QT_NO_ITEMVIEWS-
37#include <qpointer.h>-
38#include <qapplication.h>-
39#include <qclipboard.h>-
40#include <qpainter.h>-
41#include <qstyle.h>-
42#include <qdrag.h>-
43#include <qevent.h>-
44#include <qscrollbar.h>-
45#include <qwhatsthis.h>-
46#include <qtooltip.h>-
47#include <qdatetime.h>-
48#include <qlineedit.h>-
49#include <qspinbox.h>-
50#include <qtreeview.h>-
51#include <qtableview.h>-
52#include <qheaderview.h>-
53#include <qstyleditemdelegate.h>-
54#include <private/qabstractitemview_p.h>-
55#include <private/qabstractitemmodel_p.h>-
56#include <private/qguiapplication_p.h>-
57#ifndef QT_NO_ACCESSIBILITY-
58#include <qaccessible.h>-
59#endif-
60#ifndef QT_NO_GESTURES-
61# include <qscroller.h>-
62#endif-
63-
64QT_BEGIN_NAMESPACE-
65-
66QAbstractItemViewPrivate::QAbstractItemViewPrivate()-
67 : model(QAbstractItemModelPrivate::staticEmptyModel()),-
68 itemDelegate(0),-
69 selectionModel(0),-
70 ctrlDragSelectionFlag(QItemSelectionModel::NoUpdate),-
71 noSelectionOnMousePress(false),-
72 selectionMode(QAbstractItemView::ExtendedSelection),-
73 selectionBehavior(QAbstractItemView::SelectItems),-
74 currentlyCommittingEditor(0),-
75 pressedModifiers(Qt::NoModifier),-
76 pressedPosition(QPoint(-1, -1)),-
77 pressedAlreadySelected(false),-
78 viewportEnteredNeeded(false),-
79 state(QAbstractItemView::NoState),-
80 stateBeforeAnimation(QAbstractItemView::NoState),-
81 editTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed),-
82 lastTrigger(QAbstractItemView::NoEditTriggers),-
83 tabKeyNavigation(false),-
84#ifndef QT_NO_DRAGANDDROP-
85 showDropIndicator(true),-
86 dragEnabled(false),-
87 dragDropMode(QAbstractItemView::NoDragDrop),-
88 overwrite(false),-
89 dropIndicatorPosition(QAbstractItemView::OnItem),-
90 defaultDropAction(Qt::IgnoreAction),-
91#endif-
92 autoScroll(true),-
93 autoScrollMargin(16),-
94 autoScrollCount(0),-
95 shouldScrollToCurrentOnShow(false),-
96 shouldClearStatusTip(false),-
97 alternatingColors(false),-
98 textElideMode(Qt::ElideRight),-
99 verticalScrollMode(QAbstractItemView::ScrollPerItem),-
100 horizontalScrollMode(QAbstractItemView::ScrollPerItem),-
101 currentIndexSet(false),-
102 wrapItemText(false),-
103 delayedPendingLayout(true),-
104 moveCursorUpdatedView(false)-
105{-
106 keyboardInputTime.invalidate();-
107}
never executed: end of block
0
108-
109QAbstractItemViewPrivate::~QAbstractItemViewPrivate()-
110{-
111}-
112-
113void QAbstractItemViewPrivate::init()-
114{-
115 Q_Q(QAbstractItemView);-
116 q->setItemDelegate(new QStyledItemDelegate(q));-
117-
118 vbar->setRange(0, 0);-
119 hbar->setRange(0, 0);-
120-
121 QObject::connect(vbar, SIGNAL(actionTriggered(int)),-
122 q, SLOT(verticalScrollbarAction(int)));-
123 QObject::connect(hbar, SIGNAL(actionTriggered(int)),-
124 q, SLOT(horizontalScrollbarAction(int)));-
125 QObject::connect(vbar, SIGNAL(valueChanged(int)),-
126 q, SLOT(verticalScrollbarValueChanged(int)));-
127 QObject::connect(hbar, SIGNAL(valueChanged(int)),-
128 q, SLOT(horizontalScrollbarValueChanged(int)));-
129-
130 viewport->setBackgroundRole(QPalette::Base);-
131-
132 q->setAttribute(Qt::WA_InputMethodEnabled);-
133}
never executed: end of block
0
134-
135void QAbstractItemViewPrivate::setHoverIndex(const QPersistentModelIndex &index)-
136{-
137 Q_Q(QAbstractItemView);-
138 if (hover == index)
hover == indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
139 return;
never executed: return;
0
140-
141 if (selectionBehavior != QAbstractItemView::SelectRows) {
selectionBehav...ew::SelectRowsDescription
TRUEnever evaluated
FALSEnever evaluated
0
142 q->update(hover); //update the old one-
143 q->update(index); //update the new one-
144 } else {
never executed: end of block
0
145 QRect oldHoverRect = q->visualRect(hover);-
146 QRect newHoverRect = q->visualRect(index);-
147 viewport->update(QRect(0, newHoverRect.y(), viewport->width(), newHoverRect.height()));-
148 viewport->update(QRect(0, oldHoverRect.y(), viewport->width(), oldHoverRect.height()));-
149 }
never executed: end of block
0
150 hover = index;-
151}
never executed: end of block
0
152-
153void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index)-
154{-
155 //we take a persistent model index because the model might change by emitting signals-
156 Q_Q(QAbstractItemView);-
157 setHoverIndex(index);-
158 if (viewportEnteredNeeded || enteredIndex != index) {
viewportEnteredNeededDescription
TRUEnever evaluated
FALSEnever evaluated
enteredIndex != indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
159 viewportEnteredNeeded = false;-
160-
161 if (index.isValid()) {
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
162 emit q->entered(index);-
163#ifndef QT_NO_STATUSTIP-
164 QString statustip = model->data(index, Qt::StatusTipRole).toString();-
165 if (parent && (shouldClearStatusTip || !statustip.isEmpty())) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
shouldClearStatusTipDescription
TRUEnever evaluated
FALSEnever evaluated
!statustip.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
166 QStatusTipEvent tip(statustip);-
167 QApplication::sendEvent(parent, &tip);-
168 shouldClearStatusTip = !statustip.isEmpty();-
169 }
never executed: end of block
0
170#endif-
171 } else {
never executed: end of block
0
172#ifndef QT_NO_STATUSTIP-
173 if (parent && shouldClearStatusTip) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
shouldClearStatusTipDescription
TRUEnever evaluated
FALSEnever evaluated
0
174 QString emptyString;-
175 QStatusTipEvent tip( emptyString );-
176 QApplication::sendEvent(parent, &tip);-
177 }
never executed: end of block
0
178#endif-
179 emit q->viewportEntered();-
180 }
never executed: end of block
0
181 enteredIndex = index;-
182 }
never executed: end of block
0
183}
never executed: end of block
0
184-
185#ifndef QT_NO_GESTURES-
186-
187// stores and restores the selection and current item when flicking-
188void QAbstractItemViewPrivate::_q_scrollerStateChanged()-
189{-
190 Q_Q(QAbstractItemView);-
191-
192 if (QScroller *scroller = QScroller::scroller(viewport)) {
QScroller *scr...ller(viewport)Description
TRUEnever evaluated
FALSEnever evaluated
0
193 switch (scroller->state()) {-
194 case QScroller::Pressed:
never executed: case QScroller::Pressed:
0
195 // store the current selection in case we start scrolling-
196 if (q->selectionModel()) {
q->selectionModel()Description
TRUEnever evaluated
FALSEnever evaluated
0
197 oldSelection = q->selectionModel()->selection();-
198 oldCurrent = q->selectionModel()->currentIndex();-
199 }
never executed: end of block
0
200 break;
never executed: break;
0
201-
202 case QScroller::Dragging:
never executed: case QScroller::Dragging:
0
203 // restore the old selection if we really start scrolling-
204 if (q->selectionModel()) {
q->selectionModel()Description
TRUEnever evaluated
FALSEnever evaluated
0
205 q->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);-
206 q->selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate);-
207 }
never executed: end of block
0
208 // fall through-
209-
210 default:
code before this statement never executed: default:
never executed: default:
0
211 oldSelection = QItemSelection();-
212 oldCurrent = QModelIndex();-
213 break;
never executed: break;
0
214 }-
215 }-
216}
never executed: end of block
0
217-
218#endif // QT_NO_GESTURES-
219-
220/*!-
221 \class QAbstractItemView-
222-
223 \brief The QAbstractItemView class provides the basic functionality for-
224 item view classes.-
225-
226 \ingroup model-view-
227 \inmodule QtWidgets-
228-
229 QAbstractItemView class is the base class for every standard view-
230 that uses a QAbstractItemModel. QAbstractItemView is an abstract-
231 class and cannot itself be instantiated. It provides a standard-
232 interface for interoperating with models through the signals and-
233 slots mechanism, enabling subclasses to be kept up-to-date with-
234 changes to their models. This class provides standard support for-
235 keyboard and mouse navigation, viewport scrolling, item editing,-
236 and selections. The keyboard navigation implements this-
237 functionality:-
238-
239 \table-
240 \header-
241 \li Keys-
242 \li Functionality-
243 \row-
244 \li Arrow keys-
245 \li Changes the current item and selects it.-
246 \row-
247 \li Ctrl+Arrow keys-
248 \li Changes the current item but does not select it.-
249 \row-
250 \li Shift+Arrow keys-
251 \li Changes the current item and selects it. The previously-
252 selected item(s) is not deselected.-
253 \row-
254 \li Ctr+Space-
255 \li Toggles selection of the current item.-
256 \row-
257 \li Tab/Backtab-
258 \li Changes the current item to the next/previous item.-
259 \row-
260 \li Home/End-
261 \li Selects the first/last item in the model.-
262 \row-
263 \li Page up/Page down-
264 \li Scrolls the rows shown up/down by the number of-
265 visible rows in the view.-
266 \row-
267 \li Ctrl+A-
268 \li Selects all items in the model.-
269 \endtable-
270-
271 Note that the above table assumes that the-
272 \l{selectionMode}{selection mode} allows the operations. For-
273 instance, you cannot select items if the selection mode is-
274 QAbstractItemView::NoSelection.-
275-
276 The QAbstractItemView class is one of the \l{Model/View Classes}-
277 and is part of Qt's \l{Model/View Programming}{model/view framework}.-
278-
279 The view classes that inherit QAbstractItemView only need-
280 to implement their own view-specific functionality, such as-
281 drawing items, returning the geometry of items, finding items,-
282 etc.-
283-
284 QAbstractItemView provides common slots such as edit() and-
285 setCurrentIndex(). Many protected slots are also provided, including-
286 dataChanged(), rowsInserted(), rowsAboutToBeRemoved(), selectionChanged(),-
287 and currentChanged().-
288-
289 The root item is returned by rootIndex(), and the current item by-
290 currentIndex(). To make sure that an item is visible use-
291 scrollTo().-
292-
293 Some of QAbstractItemView's functions are concerned with-
294 scrolling, for example setHorizontalScrollMode() and-
295 setVerticalScrollMode(). To set the range of the scroll bars, you-
296 can, for example, reimplement the view's resizeEvent() function:-
297-
298 \snippet code/src_gui_itemviews_qabstractitemview.cpp 0-
299-
300 Note that the range is not updated until the widget is shown.-
301-
302 Several other functions are concerned with selection control; for-
303 example setSelectionMode(), and setSelectionBehavior(). This class-
304 provides a default selection model to work with-
305 (selectionModel()), but this can be replaced by using-
306 setSelectionModel() with an instance of QItemSelectionModel.-
307-
308 For complete control over the display and editing of items you can-
309 specify a delegate with setItemDelegate().-
310-
311 QAbstractItemView provides a lot of protected functions. Some are-
312 concerned with editing, for example, edit(), and commitData(),-
313 whilst others are keyboard and mouse event handlers.-
314-
315 \note If you inherit QAbstractItemView and intend to update the contents-
316 of the viewport, you should use viewport->update() instead of-
317 \l{QWidget::update()}{update()} as all painting operations take place on the-
318 viewport.-
319-
320 \sa {View Classes}, {Model/View Programming}, QAbstractItemModel, {Chart Example}-
321*/-
322-
323/*!-
324 \enum QAbstractItemView::SelectionMode-
325-
326 This enum indicates how the view responds to user selections:-
327-
328 \value SingleSelection When the user selects an item, any already-selected-
329 item becomes unselected, and the user cannot unselect the selected item by-
330 clicking on it.-
331-
332 \value ContiguousSelection When the user selects an item in the usual way,-
333 the selection is cleared and the new item selected. However, if the user-
334 presses the Shift key while clicking on an item, all items between the-
335 current item and the clicked item are selected or unselected, depending on-
336 the state of the clicked item.-
337-
338 \value ExtendedSelection When the user selects an item in the usual way,-
339 the selection is cleared and the new item selected. However, if the user-
340 presses the Ctrl key when clicking on an item, the clicked item gets-
341 toggled and all other items are left untouched. If the user presses the-
342 Shift key while clicking on an item, all items between the current item-
343 and the clicked item are selected or unselected, depending on the state of-
344 the clicked item. Multiple items can be selected by dragging the mouse over-
345 them.-
346-
347 \value MultiSelection When the user selects an item in the usual way, the-
348 selection status of that item is toggled and the other items are left-
349 alone. Multiple items can be toggled by dragging the mouse over them.-
350-
351 \value NoSelection Items cannot be selected.-
352-
353 The most commonly used modes are SingleSelection and ExtendedSelection.-
354*/-
355-
356/*!-
357 \enum QAbstractItemView::SelectionBehavior-
358-
359 \value SelectItems Selecting single items.-
360 \value SelectRows Selecting only rows.-
361 \value SelectColumns Selecting only columns.-
362*/-
363-
364/*!-
365 \enum QAbstractItemView::ScrollHint-
366-
367 \value EnsureVisible Scroll to ensure that the item is visible.-
368 \value PositionAtTop Scroll to position the item at the top of the-
369 viewport.-
370 \value PositionAtBottom Scroll to position the item at the bottom of the-
371 viewport.-
372 \value PositionAtCenter Scroll to position the item at the center of the-
373 viewport.-
374*/-
375-
376-
377/*!-
378 \enum QAbstractItemView::EditTrigger-
379-
380 This enum describes actions which will initiate item editing.-
381-
382 \value NoEditTriggers No editing possible.-
383 \value CurrentChanged Editing start whenever current item changes.-
384 \value DoubleClicked Editing starts when an item is double clicked.-
385 \value SelectedClicked Editing starts when clicking on an already selected-
386 item.-
387 \value EditKeyPressed Editing starts when the platform edit key has been-
388 pressed over an item.-
389 \value AnyKeyPressed Editing starts when any key is pressed over an item.-
390 \value AllEditTriggers Editing starts for all above actions.-
391*/-
392-
393/*!-
394 \enum QAbstractItemView::CursorAction-
395-
396 This enum describes the different ways to navigate between items,-
397 \sa moveCursor()-
398-
399 \value MoveUp Move to the item above the current item.-
400 \value MoveDown Move to the item below the current item.-
401 \value MoveLeft Move to the item left of the current item.-
402 \value MoveRight Move to the item right of the current item.-
403 \value MoveHome Move to the top-left corner item.-
404 \value MoveEnd Move to the bottom-right corner item.-
405 \value MovePageUp Move one page up above the current item.-
406 \value MovePageDown Move one page down below the current item.-
407 \value MoveNext Move to the item after the current item.-
408 \value MovePrevious Move to the item before the current item.-
409*/-
410-
411/*!-
412 \enum QAbstractItemView::State-
413-
414 Describes the different states the view can be in. This is usually-
415 only interesting when reimplementing your own view.-
416-
417 \value NoState The is the default state.-
418 \value DraggingState The user is dragging items.-
419 \value DragSelectingState The user is selecting items.-
420 \value EditingState The user is editing an item in a widget editor.-
421 \value ExpandingState The user is opening a branch of items.-
422 \value CollapsingState The user is closing a branch of items.-
423 \value AnimatingState The item view is performing an animation.-
424*/-
425-
426/*!-
427 \since 4.2-
428 \enum QAbstractItemView::ScrollMode-
429-
430 \value ScrollPerItem The view will scroll the contents one item at a time.-
431 \value ScrollPerPixel The view will scroll the contents one pixel at a time.-
432*/-
433-
434/*!-
435 \fn QRect QAbstractItemView::visualRect(const QModelIndex &index) const = 0-
436 Returns the rectangle on the viewport occupied by the item at \a index.-
437-
438 If your item is displayed in several areas then visualRect should return-
439 the primary area that contains index and not the complete area that index-
440 might encompasses, touch or cause drawing.-
441-
442 In the base class this is a pure virtual function.-
443-
444 \sa indexAt(), visualRegionForSelection()-
445*/-
446-
447/*!-
448 \fn void QAbstractItemView::scrollTo(const QModelIndex &index, ScrollHint hint) = 0-
449-
450 Scrolls the view if necessary to ensure that the item at \a index-
451 is visible. The view will try to position the item according to the given \a hint.-
452-
453 In the base class this is a pure virtual function.-
454*/-
455-
456/*!-
457 \fn QModelIndex QAbstractItemView::indexAt(const QPoint &point) const = 0-
458-
459 Returns the model index of the item at the viewport coordinates \a point.-
460-
461 In the base class this is a pure virtual function.-
462-
463 \sa visualRect()-
464*/-
465-
466/*!-
467 \fn void QAbstractItemView::activated(const QModelIndex &index)-
468-
469 This signal is emitted when the item specified by \a index is-
470 activated by the user. How to activate items depends on the-
471 platform; e.g., by single- or double-clicking the item, or by-
472 pressing the Return or Enter key when the item is current.-
473-
474 \sa clicked(), doubleClicked(), entered(), pressed()-
475*/-
476-
477/*!-
478 \fn void QAbstractItemView::entered(const QModelIndex &index)-
479-
480 This signal is emitted when the mouse cursor enters the item-
481 specified by \a index.-
482 Mouse tracking needs to be enabled for this feature to work.-
483-
484 \sa viewportEntered(), activated(), clicked(), doubleClicked(), pressed()-
485*/-
486-
487/*!-
488 \fn void QAbstractItemView::viewportEntered()-
489-
490 This signal is emitted when the mouse cursor enters the viewport.-
491 Mouse tracking needs to be enabled for this feature to work.-
492-
493 \sa entered()-
494*/-
495-
496/*!-
497 \fn void QAbstractItemView::pressed(const QModelIndex &index)-
498-
499 This signal is emitted when a mouse button is pressed. The item-
500 the mouse was pressed on is specified by \a index. The signal is-
501 only emitted when the index is valid.-
502-
503 Use the QApplication::mouseButtons() function to get the state-
504 of the mouse buttons.-
505-
506 \sa activated(), clicked(), doubleClicked(), entered()-
507*/-
508-
509/*!-
510 \fn void QAbstractItemView::clicked(const QModelIndex &index)-
511-
512 This signal is emitted when a mouse button is left-clicked. The item-
513 the mouse was clicked on is specified by \a index. The signal is-
514 only emitted when the index is valid.-
515-
516 \sa activated(), doubleClicked(), entered(), pressed()-
517*/-
518-
519/*!-
520 \fn void QAbstractItemView::doubleClicked(const QModelIndex &index)-
521-
522 This signal is emitted when a mouse button is double-clicked. The-
523 item the mouse was double-clicked on is specified by \a index.-
524 The signal is only emitted when the index is valid.-
525-
526 \sa clicked(), activated()-
527*/-
528-
529/*!-
530 \fn QModelIndex QAbstractItemView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) = 0-
531-
532 Returns a QModelIndex object pointing to the next object in the view,-
533 based on the given \a cursorAction and keyboard modifiers specified-
534 by \a modifiers.-
535-
536 In the base class this is a pure virtual function.-
537*/-
538-
539/*!-
540 \fn int QAbstractItemView::horizontalOffset() const = 0-
541-
542 Returns the horizontal offset of the view.-
543-
544 In the base class this is a pure virtual function.-
545-
546 \sa verticalOffset()-
547*/-
548-
549/*!-
550 \fn int QAbstractItemView::verticalOffset() const = 0-
551-
552 Returns the vertical offset of the view.-
553-
554 In the base class this is a pure virtual function.-
555-
556 \sa horizontalOffset()-
557*/-
558-
559/*!-
560 \fn bool QAbstractItemView::isIndexHidden(const QModelIndex &index) const-
561-
562 Returns \c true if the item referred to by the given \a index is hidden in the view,-
563 otherwise returns \c false.-
564-
565 Hiding is a view specific feature. For example in TableView a column can be marked-
566 as hidden or a row in the TreeView.-
567-
568 In the base class this is a pure virtual function.-
569*/-
570-
571/*!-
572 \fn void QAbstractItemView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags)-
573-
574 Applies the selection \a flags to the items in or touched by the-
575 rectangle, \a rect.-
576-
577 When implementing your own itemview setSelection should call-
578 selectionModel()->select(selection, flags) where selection-
579 is either an empty QModelIndex or a QItemSelection that contains-
580 all items that are contained in \a rect.-
581-
582 \sa selectionCommand(), selectedIndexes()-
583*/-
584-
585/*!-
586 \fn QRegion QAbstractItemView::visualRegionForSelection(const QItemSelection &selection) const = 0-
587-
588 Returns the region from the viewport of the items in the given-
589 \a selection.-
590-
591 In the base class this is a pure virtual function.-
592-
593 \sa visualRect(), selectedIndexes()-
594*/-
595-
596/*!-
597 Constructs an abstract item view with the given \a parent.-
598*/-
599QAbstractItemView::QAbstractItemView(QWidget *parent)-
600 : QAbstractScrollArea(*(new QAbstractItemViewPrivate), parent)-
601{-
602 d_func()->init();-
603}
never executed: end of block
0
604-
605/*!-
606 \internal-
607*/-
608QAbstractItemView::QAbstractItemView(QAbstractItemViewPrivate &dd, QWidget *parent)-
609 : QAbstractScrollArea(dd, parent)-
610{-
611 d_func()->init();-
612}
never executed: end of block
0
613-
614/*!-
615 Destroys the view.-
616*/-
617QAbstractItemView::~QAbstractItemView()-
618{-
619 Q_D(QAbstractItemView);-
620 // stop these timers here before ~QObject-
621 d->delayedReset.stop();-
622 d->updateTimer.stop();-
623 d->delayedEditing.stop();-
624 d->delayedAutoScroll.stop();-
625 d->autoScrollTimer.stop();-
626 d->delayedLayout.stop();-
627 d->fetchMoreTimer.stop();-
628}
never executed: end of block
0
629-
630/*!-
631 Sets the \a model for the view to present.-
632-
633 This function will create and set a new selection model, replacing any-
634 model that was previously set with setSelectionModel(). However, the old-
635 selection model will not be deleted as it may be shared between several-
636 views. We recommend that you delete the old selection model if it is no-
637 longer required. This is done with the following code:-
638-
639 \snippet code/src_gui_itemviews_qabstractitemview.cpp 2-
640-
641 If both the old model and the old selection model do not have parents, or-
642 if their parents are long-lived objects, it may be preferable to call their-
643 deleteLater() functions to explicitly delete them.-
644-
645 The view \e{does not} take ownership of the model unless it is the model's-
646 parent object because the model may be shared between many different views.-
647-
648 \sa selectionModel(), setSelectionModel()-
649*/-
650void QAbstractItemView::setModel(QAbstractItemModel *model)-
651{-
652 Q_D(QAbstractItemView);-
653 if (model == d->model)
model == d->modelDescription
TRUEnever evaluated
FALSEnever evaluated
0
654 return;
never executed: return;
0
655 if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) {
d->modelDescription
TRUEnever evaluated
FALSEnever evaluated
d->model != QA...icEmptyModel()Description
TRUEnever evaluated
FALSEnever evaluated
0
656 disconnect(d->model, SIGNAL(destroyed()),-
657 this, SLOT(_q_modelDestroyed()));-
658 disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),-
659 this, SLOT(dataChanged(QModelIndex,QModelIndex,QVector<int>)));-
660 disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),-
661 this, SLOT(_q_headerDataChanged()));-
662 disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),-
663 this, SLOT(rowsInserted(QModelIndex,int,int)));-
664 disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),-
665 this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));-
666 disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),-
667 this, SLOT(_q_rowsRemoved(QModelIndex,int,int)));-
668 disconnect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),-
669 this, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int)));-
670 disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),-
671 this, SLOT(_q_rowsInserted(QModelIndex,int,int)));-
672 disconnect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),-
673 this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));-
674 disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),-
675 this, SLOT(_q_columnsRemoved(QModelIndex,int,int)));-
676 disconnect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)),-
677 this, SLOT(_q_columnsInserted(QModelIndex,int,int)));-
678 disconnect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),-
679 this, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));-
680-
681 disconnect(d->model, SIGNAL(modelReset()), this, SLOT(reset()));-
682 disconnect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));-
683 }
never executed: end of block
0
684 d->model = (model ? model : QAbstractItemModelPrivate::staticEmptyModel());
modelDescription
TRUEnever evaluated
FALSEnever evaluated
0
685-
686 // These asserts do basic sanity checking of the model-
687 Q_ASSERT_X(d->model->index(0,0) == d->model->index(0,0),-
688 "QAbstractItemView::setModel",-
689 "A model should return the exact same index "-
690 "(including its internal id/pointer) when asked for it twice in a row.");-
691 Q_ASSERT_X(!d->model->index(0,0).parent().isValid(),-
692 "QAbstractItemView::setModel",-
693 "The parent of a top level index should be invalid");-
694-
695 if (d->model != QAbstractItemModelPrivate::staticEmptyModel()) {
d->model != QA...icEmptyModel()Description
TRUEnever evaluated
FALSEnever evaluated
0
696 connect(d->model, SIGNAL(destroyed()),-
697 this, SLOT(_q_modelDestroyed()));-
698 connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),-
699 this, SLOT(dataChanged(QModelIndex,QModelIndex,QVector<int>)));-
700 connect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),-
701 this, SLOT(_q_headerDataChanged()));-
702 connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),-
703 this, SLOT(rowsInserted(QModelIndex,int,int)));-
704 connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),-
705 this, SLOT(_q_rowsInserted(QModelIndex,int,int)));-
706 connect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),-
707 this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));-
708 connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),-
709 this, SLOT(_q_rowsRemoved(QModelIndex,int,int)));-
710 connect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),-
711 this, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int)));-
712 connect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),-
713 this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));-
714 connect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),-
715 this, SLOT(_q_columnsRemoved(QModelIndex,int,int)));-
716 connect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)),-
717 this, SLOT(_q_columnsInserted(QModelIndex,int,int)));-
718 connect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),-
719 this, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));-
720-
721 connect(d->model, SIGNAL(modelReset()), this, SLOT(reset()));-
722 connect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));-
723 }
never executed: end of block
0
724-
725 QItemSelectionModel *selection_model = new QItemSelectionModel(d->model, this);-
726 connect(d->model, SIGNAL(destroyed()), selection_model, SLOT(deleteLater()));-
727 setSelectionModel(selection_model);-
728-
729 reset(); // kill editors, set new root and do layout-
730}
never executed: end of block
0
731-
732/*!-
733 Returns the model that this view is presenting.-
734*/-
735QAbstractItemModel *QAbstractItemView::model() const-
736{-
737 Q_D(const QAbstractItemView);-
738 return (d->model == QAbstractItemModelPrivate::staticEmptyModel() ? 0 : d->model);
never executed: return (d->model == QAbstractItemModelPrivate::staticEmptyModel() ? 0 : d->model);
d->model == QA...icEmptyModel()Description
TRUEnever evaluated
FALSEnever evaluated
0
739}-
740-
741/*!-
742 Sets the current selection model to the given \a selectionModel.-
743-
744 Note that, if you call setModel() after this function, the given \a selectionModel-
745 will be replaced by one created by the view.-
746-
747 \note It is up to the application to delete the old selection model if it is no-
748 longer needed; i.e., if it is not being used by other views. This will happen-
749 automatically when its parent object is deleted. However, if it does not have a-
750 parent, or if the parent is a long-lived object, it may be preferable to call its-
751 deleteLater() function to explicitly delete it.-
752-
753 \sa selectionModel(), setModel(), clearSelection()-
754*/-
755void QAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel)-
756{-
757 // ### if the given model is null, we should use the original selection model-
758 Q_ASSERT(selectionModel);-
759 Q_D(QAbstractItemView);-
760-
761 if (selectionModel->model() != d->model) {
selectionModel...() != d->modelDescription
TRUEnever evaluated
FALSEnever evaluated
0
762 qWarning("QAbstractItemView::setSelectionModel() failed: "-
763 "Trying to set a selection model, which works on "-
764 "a different model than the view.");-
765 return;
never executed: return;
0
766 }-
767-
768 QItemSelection oldSelection;-
769 QModelIndex oldCurrentIndex;-
770-
771 if (d->selectionModel) {
d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
772 if (d->selectionModel->model() == selectionModel->model()) {
d->selectionMo...Model->model()Description
TRUEnever evaluated
FALSEnever evaluated
0
773 oldSelection = d->selectionModel->selection();-
774 oldCurrentIndex = d->selectionModel->currentIndex();-
775 }
never executed: end of block
0
776-
777 disconnect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),-
778 this, SLOT(selectionChanged(QItemSelection,QItemSelection)));-
779 disconnect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)),-
780 this, SLOT(currentChanged(QModelIndex,QModelIndex)));-
781 }
never executed: end of block
0
782-
783 d->selectionModel = selectionModel;-
784-
785 if (d->selectionModel) {
d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
786 connect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),-
787 this, SLOT(selectionChanged(QItemSelection,QItemSelection)));-
788 connect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)),-
789 this, SLOT(currentChanged(QModelIndex,QModelIndex)));-
790-
791 selectionChanged(d->selectionModel->selection(), oldSelection);-
792 currentChanged(d->selectionModel->currentIndex(), oldCurrentIndex);-
793 }
never executed: end of block
0
794}
never executed: end of block
0
795-
796/*!-
797 Returns the current selection model.-
798-
799 \sa setSelectionModel(), selectedIndexes()-
800*/-
801QItemSelectionModel* QAbstractItemView::selectionModel() const-
802{-
803 Q_D(const QAbstractItemView);-
804 return d->selectionModel;
never executed: return d->selectionModel;
0
805}-
806-
807/*!-
808 Sets the item delegate for this view and its model to \a delegate.-
809 This is useful if you want complete control over the editing and-
810 display of items.-
811-
812 Any existing delegate will be removed, but not deleted. QAbstractItemView-
813 does not take ownership of \a delegate.-
814-
815 \warning You should not share the same instance of a delegate between views.-
816 Doing so can cause incorrect or unintuitive editing behavior since each-
817 view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()}-
818 signal, and attempt to access, modify or close an editor that has already been closed.-
819-
820 \sa itemDelegate()-
821*/-
822void QAbstractItemView::setItemDelegate(QAbstractItemDelegate *delegate)-
823{-
824 Q_D(QAbstractItemView);-
825 if (delegate == d->itemDelegate)
delegate == d->itemDelegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
826 return;
never executed: return;
0
827-
828 if (d->itemDelegate) {
d->itemDelegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
829 if (d->delegateRefCount(d->itemDelegate) == 1) {
d->delegateRef...Delegate) == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
830 disconnect(d->itemDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),-
831 this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));-
832 disconnect(d->itemDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));-
833 disconnect(d->itemDelegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()));-
834 }
never executed: end of block
0
835 }
never executed: end of block
0
836-
837 if (delegate) {
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
838 if (d->delegateRefCount(delegate) == 0) {
d->delegateRef...delegate) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
839 connect(delegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),-
840 this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));-
841 connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));-
842 connect(delegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()), Qt::QueuedConnection);-
843 }
never executed: end of block
0
844 }
never executed: end of block
0
845 d->itemDelegate = delegate;-
846 viewport()->update();-
847 d->doDelayedItemsLayout();-
848}
never executed: end of block
0
849-
850/*!-
851 Returns the item delegate used by this view and model. This is-
852 either one set with setItemDelegate(), or the default one.-
853-
854 \sa setItemDelegate()-
855*/-
856QAbstractItemDelegate *QAbstractItemView::itemDelegate() const-
857{-
858 return d_func()->itemDelegate;
never executed: return d_func()->itemDelegate;
0
859}-
860-
861/*!-
862 \reimp-
863*/-
864QVariant QAbstractItemView::inputMethodQuery(Qt::InputMethodQuery query) const-
865{-
866 const QModelIndex current = currentIndex();-
867 if (!current.isValid() || query != Qt::ImCursorRectangle)
!current.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
query != Qt::ImCursorRectangleDescription
TRUEnever evaluated
FALSEnever evaluated
0
868 return QAbstractScrollArea::inputMethodQuery(query);
never executed: return QAbstractScrollArea::inputMethodQuery(query);
0
869 return visualRect(current);
never executed: return visualRect(current);
0
870}-
871-
872/*!-
873 \since 4.2-
874-
875 Sets the given item \a delegate used by this view and model for the given-
876 \a row. All items on \a row will be drawn and managed by \a delegate-
877 instead of using the default delegate (i.e., itemDelegate()).-
878-
879 Any existing row delegate for \a row will be removed, but not-
880 deleted. QAbstractItemView does not take ownership of \a delegate.-
881-
882 \note If a delegate has been assigned to both a row and a column, the row-
883 delegate (i.e., this delegate) will take precedence and manage the-
884 intersecting cell index.-
885-
886 \warning You should not share the same instance of a delegate between views.-
887 Doing so can cause incorrect or unintuitive editing behavior since each-
888 view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()}-
889 signal, and attempt to access, modify or close an editor that has already been closed.-
890-
891 \sa itemDelegateForRow(), setItemDelegateForColumn(), itemDelegate()-
892*/-
893void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *delegate)-
894{-
895 Q_D(QAbstractItemView);-
896 if (QAbstractItemDelegate *rowDelegate = d->rowDelegates.value(row, 0)) {
QAbstractItemD....value(row, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
897 if (d->delegateRefCount(rowDelegate) == 1) {
d->delegateRef...Delegate) == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
898 disconnect(rowDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),-
899 this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));-
900 disconnect(rowDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));-
901 disconnect(rowDelegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()));-
902 }
never executed: end of block
0
903 d->rowDelegates.remove(row);-
904 }
never executed: end of block
0
905 if (delegate) {
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
906 if (d->delegateRefCount(delegate) == 0) {
d->delegateRef...delegate) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
907 connect(delegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),-
908 this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));-
909 connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));-
910 connect(delegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()), Qt::QueuedConnection);-
911 }
never executed: end of block
0
912 d->rowDelegates.insert(row, delegate);-
913 }
never executed: end of block
0
914 viewport()->update();-
915 d->doDelayedItemsLayout();-
916}
never executed: end of block
0
917-
918/*!-
919 \since 4.2-
920-
921 Returns the item delegate used by this view and model for the given \a row,-
922 or 0 if no delegate has been assigned. You can call itemDelegate() to get a-
923 pointer to the current delegate for a given index.-
924-
925 \sa setItemDelegateForRow(), itemDelegateForColumn(), setItemDelegate()-
926*/-
927QAbstractItemDelegate *QAbstractItemView::itemDelegateForRow(int row) const-
928{-
929 Q_D(const QAbstractItemView);-
930 return d->rowDelegates.value(row, 0);
never executed: return d->rowDelegates.value(row, 0);
0
931}-
932-
933/*!-
934 \since 4.2-
935-
936 Sets the given item \a delegate used by this view and model for the given-
937 \a column. All items on \a column will be drawn and managed by \a delegate-
938 instead of using the default delegate (i.e., itemDelegate()).-
939-
940 Any existing column delegate for \a column will be removed, but not-
941 deleted. QAbstractItemView does not take ownership of \a delegate.-
942-
943 \note If a delegate has been assigned to both a row and a column, the row-
944 delegate will take precedence and manage the intersecting cell index.-
945-
946 \warning You should not share the same instance of a delegate between views.-
947 Doing so can cause incorrect or unintuitive editing behavior since each-
948 view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()}-
949 signal, and attempt to access, modify or close an editor that has already been closed.-
950-
951 \sa itemDelegateForColumn(), setItemDelegateForRow(), itemDelegate()-
952*/-
953void QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate)-
954{-
955 Q_D(QAbstractItemView);-
956 if (QAbstractItemDelegate *columnDelegate = d->columnDelegates.value(column, 0)) {
QAbstractItemD...lue(column, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
957 if (d->delegateRefCount(columnDelegate) == 1) {
d->delegateRef...Delegate) == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
958 disconnect(columnDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),-
959 this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));-
960 disconnect(columnDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));-
961 disconnect(columnDelegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()));-
962 }
never executed: end of block
0
963 d->columnDelegates.remove(column);-
964 }
never executed: end of block
0
965 if (delegate) {
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
966 if (d->delegateRefCount(delegate) == 0) {
d->delegateRef...delegate) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
967 connect(delegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),-
968 this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));-
969 connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));-
970 connect(delegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()), Qt::QueuedConnection);-
971 }
never executed: end of block
0
972 d->columnDelegates.insert(column, delegate);-
973 }
never executed: end of block
0
974 viewport()->update();-
975 d->doDelayedItemsLayout();-
976}
never executed: end of block
0
977-
978/*!-
979 \since 4.2-
980-
981 Returns the item delegate used by this view and model for the given \a-
982 column. You can call itemDelegate() to get a pointer to the current delegate-
983 for a given index.-
984-
985 \sa setItemDelegateForColumn(), itemDelegateForRow(), itemDelegate()-
986*/-
987QAbstractItemDelegate *QAbstractItemView::itemDelegateForColumn(int column) const-
988{-
989 Q_D(const QAbstractItemView);-
990 return d->columnDelegates.value(column, 0);
never executed: return d->columnDelegates.value(column, 0);
0
991}-
992-
993/*!-
994 Returns the item delegate used by this view and model for-
995 the given \a index.-
996*/-
997QAbstractItemDelegate *QAbstractItemView::itemDelegate(const QModelIndex &index) const-
998{-
999 Q_D(const QAbstractItemView);-
1000 return d->delegateForIndex(index);
never executed: return d->delegateForIndex(index);
0
1001}-
1002-
1003/*!-
1004 \property QAbstractItemView::selectionMode-
1005 \brief which selection mode the view operates in-
1006-
1007 This property controls whether the user can select one or many items-
1008 and, in many-item selections, whether the selection must be a-
1009 continuous range of items.-
1010-
1011 \sa SelectionMode, SelectionBehavior-
1012*/-
1013void QAbstractItemView::setSelectionMode(SelectionMode mode)-
1014{-
1015 Q_D(QAbstractItemView);-
1016 d->selectionMode = mode;-
1017}
never executed: end of block
0
1018-
1019QAbstractItemView::SelectionMode QAbstractItemView::selectionMode() const-
1020{-
1021 Q_D(const QAbstractItemView);-
1022 return d->selectionMode;
never executed: return d->selectionMode;
0
1023}-
1024-
1025/*!-
1026 \property QAbstractItemView::selectionBehavior-
1027 \brief which selection behavior the view uses-
1028-
1029 This property holds whether selections are done-
1030 in terms of single items, rows or columns.-
1031-
1032 \sa SelectionMode, SelectionBehavior-
1033*/-
1034-
1035void QAbstractItemView::setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)-
1036{-
1037 Q_D(QAbstractItemView);-
1038 d->selectionBehavior = behavior;-
1039}
never executed: end of block
0
1040-
1041QAbstractItemView::SelectionBehavior QAbstractItemView::selectionBehavior() const-
1042{-
1043 Q_D(const QAbstractItemView);-
1044 return d->selectionBehavior;
never executed: return d->selectionBehavior;
0
1045}-
1046-
1047/*!-
1048 Sets the current item to be the item at \a index.-
1049-
1050 Unless the current selection mode is-
1051 \l{QAbstractItemView::}{NoSelection}, the item is also selected.-
1052 Note that this function also updates the starting position for any-
1053 new selections the user performs.-
1054-
1055 To set an item as the current item without selecting it, call-
1056-
1057 \c{selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);}-
1058-
1059 \sa currentIndex(), currentChanged(), selectionMode-
1060*/-
1061void QAbstractItemView::setCurrentIndex(const QModelIndex &index)-
1062{-
1063 Q_D(QAbstractItemView);-
1064 if (d->selectionModel && (!index.isValid() || d->isIndexEnabled(index))) {
d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
d->isIndexEnabled(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1065 QItemSelectionModel::SelectionFlags command = selectionCommand(index, 0);-
1066 d->selectionModel->setCurrentIndex(index, command);-
1067 d->currentIndexSet = true;-
1068 if ((command & QItemSelectionModel::Current) == 0)
(command & QIt...:Current) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1069 d->currentSelectionStartIndex = index;
never executed: d->currentSelectionStartIndex = index;
0
1070 }
never executed: end of block
0
1071}
never executed: end of block
0
1072-
1073/*!-
1074 Returns the model index of the current item.-
1075-
1076 \sa setCurrentIndex()-
1077*/-
1078QModelIndex QAbstractItemView::currentIndex() const-
1079{-
1080 Q_D(const QAbstractItemView);-
1081 return d->selectionModel ? d->selectionModel->currentIndex() : QModelIndex();
never executed: return d->selectionModel ? d->selectionModel->currentIndex() : QModelIndex();
d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1082}-
1083-
1084-
1085/*!-
1086 Reset the internal state of the view.-
1087-
1088 \warning This function will reset open editors, scroll bar positions,-
1089 selections, etc. Existing changes will not be committed. If you would like-
1090 to save your changes when resetting the view, you can reimplement this-
1091 function, commit your changes, and then call the superclass'-
1092 implementation.-
1093*/-
1094void QAbstractItemView::reset()-
1095{-
1096 Q_D(QAbstractItemView);-
1097 d->delayedReset.stop(); //make sure we stop the timer-
1098 foreach (const QEditorInfo &info, d->indexEditorHash) {-
1099 if (info.widget)
info.widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1100 d->releaseEditor(info.widget.data(), d->indexForEditor(info.widget.data()));
never executed: d->releaseEditor(info.widget.data(), d->indexForEditor(info.widget.data()));
0
1101 }
never executed: end of block
0
1102 d->editorIndexHash.clear();-
1103 d->indexEditorHash.clear();-
1104 d->persistent.clear();-
1105 d->currentIndexSet = false;-
1106 setState(NoState);-
1107 setRootIndex(QModelIndex());-
1108 if (d->selectionModel)
d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1109 d->selectionModel->reset();
never executed: d->selectionModel->reset();
0
1110#ifndef QT_NO_ACCESSIBILITY-
1111 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1112 QAccessibleTableModelChangeEvent accessibleEvent(this, QAccessibleTableModelChangeEvent::ModelReset);-
1113 QAccessible::updateAccessibility(&accessibleEvent);-
1114 }
never executed: end of block
0
1115#endif-
1116 d->updateGeometry();-
1117}
never executed: end of block
0
1118-
1119/*!-
1120 Sets the root item to the item at the given \a index.-
1121-
1122 \sa rootIndex()-
1123*/-
1124void QAbstractItemView::setRootIndex(const QModelIndex &index)-
1125{-
1126 Q_D(QAbstractItemView);-
1127 if (index.isValid() && index.model() != d->model) {
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
index.model() != d->modelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1128 qWarning("QAbstractItemView::setRootIndex failed : index must be from the currently set model");-
1129 return;
never executed: return;
0
1130 }-
1131 d->root = index;-
1132 d->doDelayedItemsLayout();-
1133 d->updateGeometry();-
1134}
never executed: end of block
0
1135-
1136/*!-
1137 Returns the model index of the model's root item. The root item is-
1138 the parent item to the view's toplevel items. The root can be invalid.-
1139-
1140 \sa setRootIndex()-
1141*/-
1142QModelIndex QAbstractItemView::rootIndex() const-
1143{-
1144 return QModelIndex(d_func()->root);
never executed: return QModelIndex(d_func()->root);
0
1145}-
1146-
1147/*!-
1148 Selects all items in the view.-
1149 This function will use the selection behavior-
1150 set on the view when selecting.-
1151-
1152 \sa setSelection(), selectedIndexes(), clearSelection()-
1153*/-
1154void QAbstractItemView::selectAll()-
1155{-
1156 Q_D(QAbstractItemView);-
1157 SelectionMode mode = d->selectionMode;-
1158 if (mode == MultiSelection || mode == ExtendedSelection)
mode == MultiSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
mode == ExtendedSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1159 d->selectAll(QItemSelectionModel::ClearAndSelect
never executed: d->selectAll(QItemSelectionModel::ClearAndSelect |d->selectionBehaviorFlags());
0
1160 |d->selectionBehaviorFlags());
never executed: d->selectAll(QItemSelectionModel::ClearAndSelect |d->selectionBehaviorFlags());
0
1161 else if (mode != SingleSelection)
mode != SingleSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1162 d->selectAll(selectionCommand(d->model->index(0, 0, d->root)));
never executed: d->selectAll(selectionCommand(d->model->index(0, 0, d->root)));
0
1163}
never executed: end of block
0
1164-
1165/*!-
1166 Starts editing the item corresponding to the given \a index if it is-
1167 editable.-
1168-
1169 Note that this function does not change the current index. Since the current-
1170 index defines the next and previous items to edit, users may find that-
1171 keyboard navigation does not work as expected. To provide consistent navigation-
1172 behavior, call setCurrentIndex() before this function with the same model-
1173 index.-
1174-
1175 \sa QModelIndex::flags()-
1176*/-
1177void QAbstractItemView::edit(const QModelIndex &index)-
1178{-
1179 Q_D(QAbstractItemView);-
1180 if (!d->isIndexValid(index))
!d->isIndexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1181 qWarning("edit: index was invalid");
never executed: QMessageLogger(__FILE__, 1181, __PRETTY_FUNCTION__).warning("edit: index was invalid");
0
1182 if (!edit(index, AllEditTriggers, 0))
!edit(index, A...itTriggers, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1183 qWarning("edit: editing failed");
never executed: QMessageLogger(__FILE__, 1183, __PRETTY_FUNCTION__).warning("edit: editing failed");
0
1184}
never executed: end of block
0
1185-
1186/*!-
1187 Deselects all selected items. The current index will not be changed.-
1188-
1189 \sa setSelection(), selectAll()-
1190*/-
1191void QAbstractItemView::clearSelection()-
1192{-
1193 Q_D(QAbstractItemView);-
1194 if (d->selectionModel)
d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1195 d->selectionModel->clearSelection();
never executed: d->selectionModel->clearSelection();
0
1196}
never executed: end of block
0
1197-
1198/*!-
1199 \internal-
1200-
1201 This function is intended to lay out the items in the view.-
1202 The default implementation just calls updateGeometries() and updates the viewport.-
1203*/-
1204void QAbstractItemView::doItemsLayout()-
1205{-
1206 Q_D(QAbstractItemView);-
1207 d->interruptDelayedItemsLayout();-
1208 updateGeometries();-
1209 d->viewport->update();-
1210}
never executed: end of block
0
1211-
1212/*!-
1213 \property QAbstractItemView::editTriggers-
1214 \brief which actions will initiate item editing-
1215-
1216 This property is a selection of flags defined by-
1217 \l{EditTrigger}, combined using the OR-
1218 operator. The view will only initiate the editing of an item if the-
1219 action performed is set in this property.-
1220*/-
1221void QAbstractItemView::setEditTriggers(EditTriggers actions)-
1222{-
1223 Q_D(QAbstractItemView);-
1224 d->editTriggers = actions;-
1225}
never executed: end of block
0
1226-
1227QAbstractItemView::EditTriggers QAbstractItemView::editTriggers() const-
1228{-
1229 Q_D(const QAbstractItemView);-
1230 return d->editTriggers;
never executed: return d->editTriggers;
0
1231}-
1232-
1233/*!-
1234 \since 4.2-
1235 \property QAbstractItemView::verticalScrollMode-
1236 \brief how the view scrolls its contents in the vertical direction-
1237-
1238 This property controls how the view scroll its contents vertically.-
1239 Scrolling can be done either per pixel or per item.-
1240*/-
1241-
1242void QAbstractItemView::setVerticalScrollMode(ScrollMode mode)-
1243{-
1244 Q_D(QAbstractItemView);-
1245 if (mode == d->verticalScrollMode)
mode == d->verticalScrollModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1246 return;
never executed: return;
0
1247 QModelIndex topLeft = indexAt(QPoint(0, 0));-
1248 d->verticalScrollMode = mode;-
1249 updateGeometries(); // update the scroll bars-
1250 scrollTo(topLeft, QAbstractItemView::PositionAtTop);-
1251}
never executed: end of block
0
1252-
1253QAbstractItemView::ScrollMode QAbstractItemView::verticalScrollMode() const-
1254{-
1255 Q_D(const QAbstractItemView);-
1256 return d->verticalScrollMode;
never executed: return d->verticalScrollMode;
0
1257}-
1258-
1259/*!-
1260 \since 4.2-
1261 \property QAbstractItemView::horizontalScrollMode-
1262 \brief how the view scrolls its contents in the horizontal direction-
1263-
1264 This property controls how the view scroll its contents horizontally.-
1265 Scrolling can be done either per pixel or per item.-
1266*/-
1267-
1268void QAbstractItemView::setHorizontalScrollMode(ScrollMode mode)-
1269{-
1270 Q_D(QAbstractItemView);-
1271 d->horizontalScrollMode = mode;-
1272 updateGeometries(); // update the scroll bars-
1273}
never executed: end of block
0
1274-
1275QAbstractItemView::ScrollMode QAbstractItemView::horizontalScrollMode() const-
1276{-
1277 Q_D(const QAbstractItemView);-
1278 return d->horizontalScrollMode;
never executed: return d->horizontalScrollMode;
0
1279}-
1280-
1281#ifndef QT_NO_DRAGANDDROP-
1282/*!-
1283 \since 4.2-
1284 \property QAbstractItemView::dragDropOverwriteMode-
1285 \brief the view's drag and drop behavior-
1286-
1287 If its value is \c true, the selected data will overwrite the-
1288 existing item data when dropped, while moving the data will clear-
1289 the item. If its value is \c false, the selected data will be-
1290 inserted as a new item when the data is dropped. When the data is-
1291 moved, the item is removed as well.-
1292-
1293 The default value is \c false, as in the QListView and QTreeView-
1294 subclasses. In the QTableView subclass, on the other hand, the-
1295 property has been set to \c true.-
1296-
1297 Note: This is not intended to prevent overwriting of items.-
1298 The model's implementation of flags() should do that by not-
1299 returning Qt::ItemIsDropEnabled.-
1300-
1301 \sa dragDropMode-
1302*/-
1303void QAbstractItemView::setDragDropOverwriteMode(bool overwrite)-
1304{-
1305 Q_D(QAbstractItemView);-
1306 d->overwrite = overwrite;-
1307}
never executed: end of block
0
1308-
1309bool QAbstractItemView::dragDropOverwriteMode() const-
1310{-
1311 Q_D(const QAbstractItemView);-
1312 return d->overwrite;
never executed: return d->overwrite;
0
1313}-
1314#endif-
1315-
1316/*!-
1317 \property QAbstractItemView::autoScroll-
1318 \brief whether autoscrolling in drag move events is enabled-
1319-
1320 If this property is set to true (the default), the-
1321 QAbstractItemView automatically scrolls the contents of the view-
1322 if the user drags within 16 pixels of the viewport edge. If the current-
1323 item changes, then the view will scroll automatically to ensure that the-
1324 current item is fully visible.-
1325-
1326 This property only works if the viewport accepts drops. Autoscroll is-
1327 switched off by setting this property to false.-
1328*/-
1329-
1330void QAbstractItemView::setAutoScroll(bool enable)-
1331{-
1332 Q_D(QAbstractItemView);-
1333 d->autoScroll = enable;-
1334}
never executed: end of block
0
1335-
1336bool QAbstractItemView::hasAutoScroll() const-
1337{-
1338 Q_D(const QAbstractItemView);-
1339 return d->autoScroll;
never executed: return d->autoScroll;
0
1340}-
1341-
1342/*!-
1343 \since 4.4-
1344 \property QAbstractItemView::autoScrollMargin-
1345 \brief the size of the area when auto scrolling is triggered-
1346-
1347 This property controls the size of the area at the edge of the viewport that-
1348 triggers autoscrolling. The default value is 16 pixels.-
1349*/-
1350void QAbstractItemView::setAutoScrollMargin(int margin)-
1351{-
1352 Q_D(QAbstractItemView);-
1353 d->autoScrollMargin = margin;-
1354}
never executed: end of block
0
1355-
1356int QAbstractItemView::autoScrollMargin() const-
1357{-
1358 Q_D(const QAbstractItemView);-
1359 return d->autoScrollMargin;
never executed: return d->autoScrollMargin;
0
1360}-
1361-
1362/*!-
1363 \property QAbstractItemView::tabKeyNavigation-
1364 \brief whether item navigation with tab and backtab is enabled.-
1365*/-
1366-
1367void QAbstractItemView::setTabKeyNavigation(bool enable)-
1368{-
1369 Q_D(QAbstractItemView);-
1370 d->tabKeyNavigation = enable;-
1371}
never executed: end of block
0
1372-
1373bool QAbstractItemView::tabKeyNavigation() const-
1374{-
1375 Q_D(const QAbstractItemView);-
1376 return d->tabKeyNavigation;
never executed: return d->tabKeyNavigation;
0
1377}-
1378-
1379/*!-
1380 \since 5.2-
1381 \reimp-
1382*/-
1383QSize QAbstractItemView::viewportSizeHint() const-
1384{-
1385 return QAbstractScrollArea::viewportSizeHint();
never executed: return QAbstractScrollArea::viewportSizeHint();
0
1386}-
1387-
1388#ifndef QT_NO_DRAGANDDROP-
1389/*!-
1390 \property QAbstractItemView::showDropIndicator-
1391 \brief whether the drop indicator is shown when dragging items and dropping.-
1392-
1393 \sa dragEnabled, DragDropMode, dragDropOverwriteMode, acceptDrops-
1394*/-
1395-
1396void QAbstractItemView::setDropIndicatorShown(bool enable)-
1397{-
1398 Q_D(QAbstractItemView);-
1399 d->showDropIndicator = enable;-
1400}
never executed: end of block
0
1401-
1402bool QAbstractItemView::showDropIndicator() const-
1403{-
1404 Q_D(const QAbstractItemView);-
1405 return d->showDropIndicator;
never executed: return d->showDropIndicator;
0
1406}-
1407-
1408/*!-
1409 \property QAbstractItemView::dragEnabled-
1410 \brief whether the view supports dragging of its own items-
1411-
1412 \sa showDropIndicator, DragDropMode, dragDropOverwriteMode, acceptDrops-
1413*/-
1414-
1415void QAbstractItemView::setDragEnabled(bool enable)-
1416{-
1417 Q_D(QAbstractItemView);-
1418 d->dragEnabled = enable;-
1419}
never executed: end of block
0
1420-
1421bool QAbstractItemView::dragEnabled() const-
1422{-
1423 Q_D(const QAbstractItemView);-
1424 return d->dragEnabled;
never executed: return d->dragEnabled;
0
1425}-
1426-
1427/*!-
1428 \since 4.2-
1429 \enum QAbstractItemView::DragDropMode-
1430-
1431 Describes the various drag and drop events the view can act upon.-
1432 By default the view does not support dragging or dropping (\c-
1433 NoDragDrop).-
1434-
1435 \value NoDragDrop Does not support dragging or dropping.-
1436 \value DragOnly The view supports dragging of its own items-
1437 \value DropOnly The view accepts drops-
1438 \value DragDrop The view supports both dragging and dropping-
1439 \value InternalMove The view accepts move (\b{not copy}) operations only-
1440 from itself.-
1441-
1442 Note that the model used needs to provide support for drag and drop operations.-
1443-
1444 \sa setDragDropMode(), {Using drag and drop with item views}-
1445*/-
1446-
1447/*!-
1448 \property QAbstractItemView::dragDropMode-
1449 \brief the drag and drop event the view will act upon-
1450-
1451 \since 4.2-
1452 \sa showDropIndicator, dragDropOverwriteMode-
1453*/-
1454void QAbstractItemView::setDragDropMode(DragDropMode behavior)-
1455{-
1456 Q_D(QAbstractItemView);-
1457 d->dragDropMode = behavior;-
1458 setDragEnabled(behavior == DragOnly || behavior == DragDrop || behavior == InternalMove);-
1459 setAcceptDrops(behavior == DropOnly || behavior == DragDrop || behavior == InternalMove);-
1460}
never executed: end of block
0
1461-
1462QAbstractItemView::DragDropMode QAbstractItemView::dragDropMode() const-
1463{-
1464 Q_D(const QAbstractItemView);-
1465 DragDropMode setBehavior = d->dragDropMode;-
1466 if (!dragEnabled() && !acceptDrops())
!dragEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
!acceptDrops()Description
TRUEnever evaluated
FALSEnever evaluated
0
1467 return NoDragDrop;
never executed: return NoDragDrop;
0
1468-
1469 if (dragEnabled() && !acceptDrops())
dragEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
!acceptDrops()Description
TRUEnever evaluated
FALSEnever evaluated
0
1470 return DragOnly;
never executed: return DragOnly;
0
1471-
1472 if (!dragEnabled() && acceptDrops())
!dragEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
acceptDrops()Description
TRUEnever evaluated
FALSEnever evaluated
0
1473 return DropOnly;
never executed: return DropOnly;
0
1474-
1475 if (dragEnabled() && acceptDrops()) {
dragEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
acceptDrops()Description
TRUEnever evaluated
FALSEnever evaluated
0
1476 if (setBehavior == InternalMove)
setBehavior == InternalMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1477 return setBehavior;
never executed: return setBehavior;
0
1478 else-
1479 return DragDrop;
never executed: return DragDrop;
0
1480 }-
1481-
1482 return NoDragDrop;
never executed: return NoDragDrop;
0
1483}-
1484-
1485/*!-
1486 \property QAbstractItemView::defaultDropAction-
1487 \brief the drop action that will be used by default in QAbstractItemView::drag()-
1488-
1489 If the property is not set, the drop action is CopyAction when the supported-
1490 actions support CopyAction.-
1491-
1492 \since 4.6-
1493 \sa showDropIndicator, dragDropOverwriteMode-
1494*/-
1495void QAbstractItemView::setDefaultDropAction(Qt::DropAction dropAction)-
1496{-
1497 Q_D(QAbstractItemView);-
1498 d->defaultDropAction = dropAction;-
1499}
never executed: end of block
0
1500-
1501Qt::DropAction QAbstractItemView::defaultDropAction() const-
1502{-
1503 Q_D(const QAbstractItemView);-
1504 return d->defaultDropAction;
never executed: return d->defaultDropAction;
0
1505}-
1506-
1507#endif // QT_NO_DRAGANDDROP-
1508-
1509/*!-
1510 \property QAbstractItemView::alternatingRowColors-
1511 \brief whether to draw the background using alternating colors-
1512-
1513 If this property is \c true, the item background will be drawn using-
1514 QPalette::Base and QPalette::AlternateBase; otherwise the background-
1515 will be drawn using the QPalette::Base color.-
1516-
1517 By default, this property is \c false.-
1518*/-
1519void QAbstractItemView::setAlternatingRowColors(bool enable)-
1520{-
1521 Q_D(QAbstractItemView);-
1522 d->alternatingColors = enable;-
1523 if (isVisible())
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
1524 d->viewport->update();
never executed: d->viewport->update();
0
1525}
never executed: end of block
0
1526-
1527bool QAbstractItemView::alternatingRowColors() const-
1528{-
1529 Q_D(const QAbstractItemView);-
1530 return d->alternatingColors;
never executed: return d->alternatingColors;
0
1531}-
1532-
1533/*!-
1534 \property QAbstractItemView::iconSize-
1535 \brief the size of items' icons-
1536-
1537 Setting this property when the view is visible will cause the-
1538 items to be laid out again.-
1539*/-
1540void QAbstractItemView::setIconSize(const QSize &size)-
1541{-
1542 Q_D(QAbstractItemView);-
1543 if (size == d->iconSize)
size == d->iconSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1544 return;
never executed: return;
0
1545 d->iconSize = size;-
1546 d->doDelayedItemsLayout();-
1547 emit iconSizeChanged(size);-
1548}
never executed: end of block
0
1549-
1550QSize QAbstractItemView::iconSize() const-
1551{-
1552 Q_D(const QAbstractItemView);-
1553 return d->iconSize;
never executed: return d->iconSize;
0
1554}-
1555-
1556/*!-
1557 \property QAbstractItemView::textElideMode-
1558-
1559 \brief the position of the "..." in elided text.-
1560-
1561 The default value for all item views is Qt::ElideRight.-
1562*/-
1563void QAbstractItemView::setTextElideMode(Qt::TextElideMode mode)-
1564{-
1565 Q_D(QAbstractItemView);-
1566 d->textElideMode = mode;-
1567}
never executed: end of block
0
1568-
1569Qt::TextElideMode QAbstractItemView::textElideMode() const-
1570{-
1571 return d_func()->textElideMode;
never executed: return d_func()->textElideMode;
0
1572}-
1573-
1574/*!-
1575 \reimp-
1576*/-
1577bool QAbstractItemView::focusNextPrevChild(bool next)-
1578{-
1579 Q_D(QAbstractItemView);-
1580 if (d->tabKeyNavigation && isEnabled() && d->viewport->isEnabled()) {
d->tabKeyNavigationDescription
TRUEnever evaluated
FALSEnever evaluated
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
d->viewport->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
1581 QKeyEvent event(QEvent::KeyPress, next ? Qt::Key_Tab : Qt::Key_Backtab, Qt::NoModifier);-
1582 keyPressEvent(&event);-
1583 if (event.isAccepted())
event.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
1584 return true;
never executed: return true;
0
1585 }
never executed: end of block
0
1586 return QAbstractScrollArea::focusNextPrevChild(next);
never executed: return QAbstractScrollArea::focusNextPrevChild(next);
0
1587}-
1588-
1589/*!-
1590 \reimp-
1591*/-
1592bool QAbstractItemView::event(QEvent *event)-
1593{-
1594 Q_D(QAbstractItemView);-
1595 switch (event->type()) {-
1596 case QEvent::Paint:
never executed: case QEvent::Paint:
0
1597 //we call this here because the scrollbars' visibility might be altered-
1598 //so this can't be done in the paintEvent method-
1599 d->executePostedLayout(); //make sure we set the layout properly-
1600 break;
never executed: break;
0
1601 case QEvent::Show:
never executed: case QEvent::Show:
0
1602 d->executePostedLayout(); //make sure we set the layout properly-
1603 if (d->shouldScrollToCurrentOnShow) {
d->shouldScrollToCurrentOnShowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1604 d->shouldScrollToCurrentOnShow = false;-
1605 const QModelIndex current = currentIndex();-
1606 if (current.isValid() && (d->state == QAbstractItemView::EditingState || d->autoScroll))
current.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
d->state == QA...::EditingStateDescription
TRUEnever evaluated
FALSEnever evaluated
d->autoScrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
1607 scrollTo(current);
never executed: scrollTo(current);
0
1608 }
never executed: end of block
0
1609 break;
never executed: break;
0
1610 case QEvent::LocaleChange:
never executed: case QEvent::LocaleChange:
0
1611 viewport()->update();-
1612 break;
never executed: break;
0
1613 case QEvent::LayoutDirectionChange:
never executed: case QEvent::LayoutDirectionChange:
0
1614 case QEvent::ApplicationLayoutDirectionChange:
never executed: case QEvent::ApplicationLayoutDirectionChange:
0
1615 updateGeometries();-
1616 break;
never executed: break;
0
1617 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
1618 doItemsLayout();-
1619 break;
never executed: break;
0
1620 case QEvent::FocusOut:
never executed: case QEvent::FocusOut:
0
1621 d->checkPersistentEditorFocus();-
1622 break;
never executed: break;
0
1623 case QEvent::FontChange:
never executed: case QEvent::FontChange:
0
1624 d->doDelayedItemsLayout(); // the size of the items will change-
1625 break;
never executed: break;
0
1626 default:
never executed: default:
0
1627 break;
never executed: break;
0
1628 }-
1629 return QAbstractScrollArea::event(event);
never executed: return QAbstractScrollArea::event(event);
0
1630}-
1631-
1632/*!-
1633 \fn bool QAbstractItemView::viewportEvent(QEvent *event)-
1634-
1635 This function is used to handle tool tips, and What's-
1636 This? mode, if the given \a event is a QEvent::ToolTip,or a-
1637 QEvent::WhatsThis. It passes all other-
1638 events on to its base class viewportEvent() handler.-
1639*/-
1640bool QAbstractItemView::viewportEvent(QEvent *event)-
1641{-
1642 Q_D(QAbstractItemView);-
1643 switch (event->type()) {-
1644 case QEvent::HoverMove:
never executed: case QEvent::HoverMove:
0
1645 case QEvent::HoverEnter:
never executed: case QEvent::HoverEnter:
0
1646 d->setHoverIndex(indexAt(static_cast<QHoverEvent*>(event)->pos()));-
1647 break;
never executed: break;
0
1648 case QEvent::HoverLeave:
never executed: case QEvent::HoverLeave:
0
1649 d->setHoverIndex(QModelIndex());-
1650 break;
never executed: break;
0
1651 case QEvent::Enter:
never executed: case QEvent::Enter:
0
1652 d->viewportEnteredNeeded = true;-
1653 break;
never executed: break;
0
1654 case QEvent::Leave:
never executed: case QEvent::Leave:
0
1655 #ifndef QT_NO_STATUSTIP-
1656 if (d->shouldClearStatusTip && d->parent) {
d->shouldClearStatusTipDescription
TRUEnever evaluated
FALSEnever evaluated
d->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1657 QString empty;-
1658 QStatusTipEvent tip(empty);-
1659 QApplication::sendEvent(d->parent, &tip);-
1660 d->shouldClearStatusTip = false;-
1661 }
never executed: end of block
0
1662 #endif-
1663 d->enteredIndex = QModelIndex();-
1664 break;
never executed: break;
0
1665 case QEvent::ToolTip:
never executed: case QEvent::ToolTip:
0
1666 case QEvent::QueryWhatsThis:
never executed: case QEvent::QueryWhatsThis:
0
1667 case QEvent::WhatsThis: {
never executed: case QEvent::WhatsThis:
0
1668 QHelpEvent *he = static_cast<QHelpEvent*>(event);-
1669 const QModelIndex index = indexAt(he->pos());-
1670 QStyleOptionViewItem option = d->viewOptionsV1();-
1671 option.rect = visualRect(index);-
1672 option.state |= (index == currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
index == currentIndex()Description
TRUEnever evaluated
FALSEnever evaluated
0
1673-
1674 QAbstractItemDelegate *delegate = d->delegateForIndex(index);-
1675 if (!delegate)
!delegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1676 return false;
never executed: return false;
0
1677 return delegate->helpEvent(he, this, option, index);
never executed: return delegate->helpEvent(he, this, option, index);
0
1678 }-
1679 case QEvent::FontChange:
never executed: case QEvent::FontChange:
0
1680 d->doDelayedItemsLayout(); // the size of the items will change-
1681 break;
never executed: break;
0
1682 case QEvent::WindowActivate:
never executed: case QEvent::WindowActivate:
0
1683 case QEvent::WindowDeactivate:
never executed: case QEvent::WindowDeactivate:
0
1684 d->viewport->update();-
1685 break;
never executed: break;
0
1686 case QEvent::ScrollPrepare:
never executed: case QEvent::ScrollPrepare:
0
1687 executeDelayedItemsLayout();-
1688#ifndef QT_NO_GESTURES-
1689 connect(QScroller::scroller(d->viewport), SIGNAL(stateChanged(QScroller::State)), this, SLOT(_q_scrollerStateChanged()), Qt::UniqueConnection);-
1690#endif-
1691 break;
never executed: break;
0
1692-
1693 default:
never executed: default:
0
1694 break;
never executed: break;
0
1695 }-
1696 return QAbstractScrollArea::viewportEvent(event);
never executed: return QAbstractScrollArea::viewportEvent(event);
0
1697}-
1698-
1699/*!-
1700 This function is called with the given \a event when a mouse button is pressed-
1701 while the cursor is inside the widget. If a valid item is pressed on it is made-
1702 into the current item. This function emits the pressed() signal.-
1703*/-
1704void QAbstractItemView::mousePressEvent(QMouseEvent *event)-
1705{-
1706 Q_D(QAbstractItemView);-
1707 d->delayedAutoScroll.stop(); //any interaction with the view cancel the auto scrolling-
1708 QPoint pos = event->pos();-
1709 QPersistentModelIndex index = indexAt(pos);-
1710-
1711 if (!d->selectionModel
!d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1712 || (d->state == EditingState && d->hasEditor(index)))
d->state == EditingStateDescription
TRUEnever evaluated
FALSEnever evaluated
d->hasEditor(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1713 return;
never executed: return;
0
1714-
1715 d->pressedAlreadySelected = d->selectionModel->isSelected(index);-
1716 d->pressedIndex = index;-
1717 d->pressedModifiers = event->modifiers();-
1718 QItemSelectionModel::SelectionFlags command = selectionCommand(index, event);-
1719 d->noSelectionOnMousePress = command == QItemSelectionModel::NoUpdate || !index.isValid();
command == QIt...odel::NoUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1720 QPoint offset = d->offset();-
1721 if ((command & QItemSelectionModel::Current) == 0) {
(command & QIt...:Current) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1722 d->pressedPosition = pos + offset;-
1723 d->currentSelectionStartIndex = index;-
1724 }
never executed: end of block
0
1725 else if (!d->currentSelectionStartIndex.isValid())
!d->currentSel...ndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1726 d->currentSelectionStartIndex = currentIndex();
never executed: d->currentSelectionStartIndex = currentIndex();
0
1727-
1728 if (edit(index, NoEditTriggers, event))
edit(index, No...iggers, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1729 return;
never executed: return;
0
1730-
1731 if (index.isValid() && d->isIndexEnabled(index)) {
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
d->isIndexEnabled(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1732 // we disable scrollTo for mouse press so the item doesn't change position-
1733 // when the user is interacting with it (ie. clicking on it)-
1734 bool autoScroll = d->autoScroll;-
1735 d->autoScroll = false;-
1736 d->selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);-
1737 d->autoScroll = autoScroll;-
1738 if (command.testFlag(QItemSelectionModel::Toggle)) {
command.testFl...Model::Toggle)Description
TRUEnever evaluated
FALSEnever evaluated
0
1739 command &= ~QItemSelectionModel::Toggle;-
1740 d->ctrlDragSelectionFlag = d->selectionModel->isSelected(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
d->selectionMo...elected(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1741 command |= d->ctrlDragSelectionFlag;-
1742 }
never executed: end of block
0
1743-
1744 if ((command & QItemSelectionModel::Current) == 0) {
(command & QIt...:Current) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1745 setSelection(QRect(pos, QSize(1, 1)), command);-
1746 } else {
never executed: end of block
0
1747 QRect rect(visualRect(d->currentSelectionStartIndex).center(), pos);-
1748 setSelection(rect, command);-
1749 }
never executed: end of block
0
1750-
1751 // signal handlers may change the model-
1752 emit pressed(index);-
1753 if (d->autoScroll) {
d->autoScrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
1754 //we delay the autoscrolling to filter out double click event-
1755 //100 is to be sure that there won't be a double-click misinterpreted as a 2 single clicks-
1756 d->delayedAutoScroll.start(QApplication::doubleClickInterval()+100, this);-
1757 }
never executed: end of block
0
1758-
1759 } else {
never executed: end of block
0
1760 // Forces a finalize() even if mouse is pressed, but not on a item-
1761 d->selectionModel->select(QModelIndex(), QItemSelectionModel::Select);-
1762 }
never executed: end of block
0
1763}-
1764-
1765/*!-
1766 This function is called with the given \a event when a mouse move event is-
1767 sent to the widget. If a selection is in progress and new items are moved-
1768 over the selection is extended; if a drag is in progress it is continued.-
1769*/-
1770void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)-
1771{-
1772 Q_D(QAbstractItemView);-
1773 QPoint topLeft;-
1774 QPoint bottomRight = event->pos();-
1775-
1776 if (state() == ExpandingState || state() == CollapsingState)
state() == ExpandingStateDescription
TRUEnever evaluated
FALSEnever evaluated
state() == CollapsingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1777 return;
never executed: return;
0
1778-
1779#ifndef QT_NO_DRAGANDDROP-
1780 if (state() == DraggingState) {
state() == DraggingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1781 topLeft = d->pressedPosition - d->offset();-
1782 if ((topLeft - bottomRight).manhattanLength() > QApplication::startDragDistance()) {
(topLeft - bot...DragDistance()Description
TRUEnever evaluated
FALSEnever evaluated
0
1783 d->pressedIndex = QModelIndex();-
1784 startDrag(d->model->supportedDragActions());-
1785 setState(NoState); // the startDrag will return when the dnd operation is done-
1786 stopAutoScroll();-
1787 }
never executed: end of block
0
1788 return;
never executed: return;
0
1789 }-
1790#endif // QT_NO_DRAGANDDROP-
1791-
1792 QPersistentModelIndex index = indexAt(bottomRight);-
1793 QModelIndex buddy = d->model->buddy(d->pressedIndex);-
1794 if ((state() == EditingState && d->hasEditor(buddy))
state() == EditingStateDescription
TRUEnever evaluated
FALSEnever evaluated
d->hasEditor(buddy)Description
TRUEnever evaluated
FALSEnever evaluated
0
1795 || edit(index, NoEditTriggers, event))
edit(index, No...iggers, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1796 return;
never executed: return;
0
1797-
1798 if (d->selectionMode != SingleSelection)
d->selectionMo...ingleSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1799 topLeft = d->pressedPosition - d->offset();
never executed: topLeft = d->pressedPosition - d->offset();
0
1800 else-
1801 topLeft = bottomRight;
never executed: topLeft = bottomRight;
0
1802-
1803 d->checkMouseMove(index);-
1804-
1805#ifndef QT_NO_DRAGANDDROP-
1806 if (d->pressedIndex.isValid()
d->pressedIndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1807 && d->dragEnabled
d->dragEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1808 && (state() != DragSelectingState)
(state() != Dr...electingState)Description
TRUEnever evaluated
FALSEnever evaluated
0
1809 && (event->buttons() != Qt::NoButton)
(event->button... Qt::NoButton)Description
TRUEnever evaluated
FALSEnever evaluated
0
1810 && !d->selectedDraggableIndexes().isEmpty()) {
!d->selectedDr...es().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1811 setState(DraggingState);-
1812 return;
never executed: return;
0
1813 }-
1814#endif-
1815-
1816 if ((event->buttons() & Qt::LeftButton) && d->selectionAllowed(index) && d->selectionModel) {
(event->button...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
d->selectionAllowed(index)Description
TRUEnever evaluated
FALSEnever evaluated
d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1817 setState(DragSelectingState);-
1818 QItemSelectionModel::SelectionFlags command = selectionCommand(index, event);-
1819 if (d->ctrlDragSelectionFlag != QItemSelectionModel::NoUpdate && command.testFlag(QItemSelectionModel::Toggle)) {
d->ctrlDragSel...odel::NoUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
command.testFl...Model::Toggle)Description
TRUEnever evaluated
FALSEnever evaluated
0
1820 command &= ~QItemSelectionModel::Toggle;-
1821 command |= d->ctrlDragSelectionFlag;-
1822 }
never executed: end of block
0
1823-
1824 // Do the normalize ourselves, since QRect::normalized() is flawed-
1825 QRect selectionRect = QRect(topLeft, bottomRight);-
1826 setSelection(selectionRect, command);-
1827-
1828 // set at the end because it might scroll the view-
1829 if (index.isValid()
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1830 && (index != d->selectionModel->currentIndex())
(index != d->s...urrentIndex())Description
TRUEnever evaluated
FALSEnever evaluated
0
1831 && d->isIndexEnabled(index))
d->isIndexEnabled(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1832 d->selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
never executed: d->selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
0
1833 }
never executed: end of block
0
1834}
never executed: end of block
0
1835-
1836/*!-
1837 This function is called with the given \a event when a mouse button is released,-
1838 after a mouse press event on the widget. If a user presses the mouse inside your-
1839 widget and then drags the mouse to another location before releasing the mouse button,-
1840 your widget receives the release event. The function will emit the clicked() signal if an-
1841 item was being pressed.-
1842*/-
1843void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event)-
1844{-
1845 Q_D(QAbstractItemView);-
1846-
1847 QPoint pos = event->pos();-
1848 QPersistentModelIndex index = indexAt(pos);-
1849-
1850 if (state() == EditingState) {
state() == EditingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1851 if (d->isIndexValid(index)
d->isIndexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1852 && d->isIndexEnabled(index)
d->isIndexEnabled(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1853 && d->sendDelegateEvent(index, event))
d->sendDelegat...(index, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1854 update(index);
never executed: update(index);
0
1855 return;
never executed: return;
0
1856 }-
1857-
1858 bool click = (index == d->pressedIndex && index.isValid());
index == d->pressedIndexDescription
TRUEnever evaluated
FALSEnever evaluated
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1859 bool selectedClicked = click && (event->button() == Qt::LeftButton) && d->pressedAlreadySelected;
clickDescription
TRUEnever evaluated
FALSEnever evaluated
(event->button...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
d->pressedAlreadySelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1860 EditTrigger trigger = (selectedClicked ? SelectedClicked : NoEditTriggers);
selectedClickedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1861 bool edited = edit(index, trigger, event);-
1862-
1863 d->ctrlDragSelectionFlag = QItemSelectionModel::NoUpdate;-
1864-
1865 if (d->selectionModel && d->noSelectionOnMousePress) {
d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
d->noSelectionOnMousePressDescription
TRUEnever evaluated
FALSEnever evaluated
0
1866 d->noSelectionOnMousePress = false;-
1867 d->selectionModel->select(index, selectionCommand(index, event));-
1868 }
never executed: end of block
0
1869-
1870 setState(NoState);-
1871-
1872 if (click) {
clickDescription
TRUEnever evaluated
FALSEnever evaluated
0
1873 if (event->button() == Qt::LeftButton)
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1874 emit clicked(index);
never executed: clicked(index);
0
1875 if (edited)
editedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1876 return;
never executed: return;
0
1877 QStyleOptionViewItem option = d->viewOptionsV1();-
1878 if (d->pressedAlreadySelected)
d->pressedAlreadySelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1879 option.state |= QStyle::State_Selected;
never executed: option.state |= QStyle::State_Selected;
0
1880 if ((model()->flags(index) & Qt::ItemIsEnabled)
(model()->flag...ItemIsEnabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
1881 && style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, &option, this))
style()->style...&option, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
1882 emit activated(index);
never executed: activated(index);
0
1883 }
never executed: end of block
0
1884}
never executed: end of block
0
1885-
1886/*!-
1887 This function is called with the given \a event when a mouse button is-
1888 double clicked inside the widget. If the double-click is on a valid item it-
1889 emits the doubleClicked() signal and calls edit() on the item.-
1890*/-
1891void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)-
1892{-
1893 Q_D(QAbstractItemView);-
1894-
1895 QModelIndex index = indexAt(event->pos());-
1896 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1897 || !d->isIndexEnabled(index)
!d->isIndexEnabled(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1898 || (d->pressedIndex != index)) {
(d->pressedIndex != index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1899 QMouseEvent me(QEvent::MouseButtonPress,-
1900 event->localPos(), event->windowPos(), event->screenPos(),-
1901 event->button(), event->buttons(), event->modifiers(), event->source());-
1902 mousePressEvent(&me);-
1903 return;
never executed: return;
0
1904 }-
1905 // signal handlers may change the model-
1906 QPersistentModelIndex persistent = index;-
1907 emit doubleClicked(persistent);-
1908 if ((event->button() == Qt::LeftButton) && !edit(persistent, DoubleClicked, event)
(event->button...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
!edit(persiste...licked, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1909 && !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this))
!style()->styl...lick, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
1910 emit activated(persistent);
never executed: activated(persistent);
0
1911}
never executed: end of block
0
1912-
1913#ifndef QT_NO_DRAGANDDROP-
1914-
1915/*!-
1916 This function is called with the given \a event when a drag and drop operation enters-
1917 the widget. If the drag is over a valid dropping place (e.g. over an item that-
1918 accepts drops), the event is accepted; otherwise it is ignored.-
1919-
1920 \sa dropEvent(), startDrag()-
1921*/-
1922void QAbstractItemView::dragEnterEvent(QDragEnterEvent *event)-
1923{-
1924 if (dragDropMode() == InternalMove
dragDropMode() == InternalMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1925 && (event->source() != this|| !(event->possibleActions() & Qt::MoveAction)))
event->source() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
!(event->possi...t::MoveAction)Description
TRUEnever evaluated
FALSEnever evaluated
0
1926 return;
never executed: return;
0
1927-
1928 if (d_func()->canDrop(event)) {
d_func()->canDrop(event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1929 event->accept();-
1930 setState(DraggingState);-
1931 } else {
never executed: end of block
0
1932 event->ignore();-
1933 }
never executed: end of block
0
1934}-
1935-
1936/*!-
1937 This function is called continuously with the given \a event during a drag and-
1938 drop operation over the widget. It can cause the view to scroll if, for example,-
1939 the user drags a selection to view's right or bottom edge. In this case, the-
1940 event will be accepted; otherwise it will be ignored.-
1941-
1942 \sa dropEvent(), startDrag()-
1943*/-
1944void QAbstractItemView::dragMoveEvent(QDragMoveEvent *event)-
1945{-
1946 Q_D(QAbstractItemView);-
1947 if (dragDropMode() == InternalMove
dragDropMode() == InternalMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1948 && (event->source() != this || !(event->possibleActions() & Qt::MoveAction)))
event->source() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
!(event->possi...t::MoveAction)Description
TRUEnever evaluated
FALSEnever evaluated
0
1949 return;
never executed: return;
0
1950-
1951 // ignore by default-
1952 event->ignore();-
1953-
1954 QModelIndex index = indexAt(event->pos());-
1955 d->hover = index;-
1956 if (!d->droppingOnItself(event, index)
!d->droppingOn...(event, index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1957 && d->canDrop(event)) {
d->canDrop(event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1958-
1959 if (index.isValid() && d->showDropIndicator) {
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
d->showDropIndicatorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1960 QRect rect = visualRect(index);-
1961 d->dropIndicatorPosition = d->position(event->pos(), rect, index);-
1962 switch (d->dropIndicatorPosition) {-
1963 case AboveItem:
never executed: case AboveItem:
0
1964 if (d->isIndexDropEnabled(index.parent())) {
d->isIndexDrop...ndex.parent())Description
TRUEnever evaluated
FALSEnever evaluated
0
1965 d->dropIndicatorRect = QRect(rect.left(), rect.top(), rect.width(), 0);-
1966 event->acceptProposedAction();-
1967 } else {
never executed: end of block
0
1968 d->dropIndicatorRect = QRect();-
1969 }
never executed: end of block
0
1970 break;
never executed: break;
0
1971 case BelowItem:
never executed: case BelowItem:
0
1972 if (d->isIndexDropEnabled(index.parent())) {
d->isIndexDrop...ndex.parent())Description
TRUEnever evaluated
FALSEnever evaluated
0
1973 d->dropIndicatorRect = QRect(rect.left(), rect.bottom(), rect.width(), 0);-
1974 event->acceptProposedAction();-
1975 } else {
never executed: end of block
0
1976 d->dropIndicatorRect = QRect();-
1977 }
never executed: end of block
0
1978 break;
never executed: break;
0
1979 case OnItem:
never executed: case OnItem:
0
1980 if (d->isIndexDropEnabled(index)) {
d->isIndexDropEnabled(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
1981 d->dropIndicatorRect = rect;-
1982 event->acceptProposedAction();-
1983 } else {
never executed: end of block
0
1984 d->dropIndicatorRect = QRect();-
1985 }
never executed: end of block
0
1986 break;
never executed: break;
0
1987 case OnViewport:
never executed: case OnViewport:
0
1988 d->dropIndicatorRect = QRect();-
1989 if (d->isIndexDropEnabled(rootIndex())) {
d->isIndexDrop...d(rootIndex())Description
TRUEnever evaluated
FALSEnever evaluated
0
1990 event->acceptProposedAction(); // allow dropping in empty areas-
1991 }
never executed: end of block
0
1992 break;
never executed: break;
0
1993 }-
1994 } else {
never executed: end of block
0
1995 d->dropIndicatorRect = QRect();-
1996 d->dropIndicatorPosition = OnViewport;-
1997 if (d->isIndexDropEnabled(rootIndex())) {
d->isIndexDrop...d(rootIndex())Description
TRUEnever evaluated
FALSEnever evaluated
0
1998 event->acceptProposedAction(); // allow dropping in empty areas-
1999 }
never executed: end of block
0
2000 }
never executed: end of block
0
2001 d->viewport->update();-
2002 } // can drop
never executed: end of block
0
2003-
2004 if (d->shouldAutoScroll(event->pos()))
d->shouldAutoS...(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2005 startAutoScroll();
never executed: startAutoScroll();
0
2006}
never executed: end of block
0
2007-
2008/*!-
2009 \internal-
2010 Return true if this is a move from ourself and \a index is a child of the selection that-
2011 is being moved.-
2012 */-
2013bool QAbstractItemViewPrivate::droppingOnItself(QDropEvent *event, const QModelIndex &index)-
2014{-
2015 Q_Q(QAbstractItemView);-
2016 Qt::DropAction dropAction = event->dropAction();-
2017 if (q->dragDropMode() == QAbstractItemView::InternalMove)
q->dragDropMod...::InternalMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
2018 dropAction = Qt::MoveAction;
never executed: dropAction = Qt::MoveAction;
0
2019 if (event->source() == q
event->source() == qDescription
TRUEnever evaluated
FALSEnever evaluated
0
2020 && event->possibleActions() & Qt::MoveAction
event->possibl...Qt::MoveActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2021 && dropAction == Qt::MoveAction) {
dropAction == Qt::MoveActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2022 QModelIndexList selectedIndexes = q->selectedIndexes();-
2023 QModelIndex child = index;-
2024 while (child.isValid() && child != root) {
child.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
child != rootDescription
TRUEnever evaluated
FALSEnever evaluated
0
2025 if (selectedIndexes.contains(child))
selectedIndexe...ontains(child)Description
TRUEnever evaluated
FALSEnever evaluated
0
2026 return true;
never executed: return true;
0
2027 child = child.parent();-
2028 }
never executed: end of block
0
2029 }
never executed: end of block
0
2030 return false;
never executed: return false;
0
2031}-
2032-
2033/*!-
2034 \fn void QAbstractItemView::dragLeaveEvent(QDragLeaveEvent *event)-
2035-
2036 This function is called when the item being dragged leaves the view.-
2037 The \a event describes the state of the drag and drop operation.-
2038*/-
2039void QAbstractItemView::dragLeaveEvent(QDragLeaveEvent *)-
2040{-
2041 Q_D(QAbstractItemView);-
2042 stopAutoScroll();-
2043 setState(NoState);-
2044 d->hover = QModelIndex();-
2045 d->viewport->update();-
2046}
never executed: end of block
0
2047-
2048/*!-
2049 This function is called with the given \a event when a drop event occurs over-
2050 the widget. If the model accepts the even position the drop event is accepted;-
2051 otherwise it is ignored.-
2052-
2053 \sa startDrag()-
2054*/-
2055void QAbstractItemView::dropEvent(QDropEvent *event)-
2056{-
2057 Q_D(QAbstractItemView);-
2058 if (dragDropMode() == InternalMove) {
dragDropMode() == InternalMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
2059 if (event->source() != this || !(event->possibleActions() & Qt::MoveAction))
event->source() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
!(event->possi...t::MoveAction)Description
TRUEnever evaluated
FALSEnever evaluated
0
2060 return;
never executed: return;
0
2061 }
never executed: end of block
0
2062-
2063 QModelIndex index;-
2064 int col = -1;-
2065 int row = -1;-
2066 if (d->dropOn(event, &row, &col, &index)) {
d->dropOn(even... &col, &index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2067 const Qt::DropAction action = dragDropMode() == InternalMove ? Qt::MoveAction : event->dropAction();
dragDropMode() == InternalMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
2068 if (d->model->dropMimeData(event->mimeData(), action, row, col, index)) {
d->model->drop...w, col, index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2069 if (action != event->dropAction()) {
action != event->dropAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
2070 event->setDropAction(action);-
2071 event->accept();-
2072 } else {
never executed: end of block
0
2073 event->acceptProposedAction();-
2074 }
never executed: end of block
0
2075 }-
2076 }
never executed: end of block
0
2077 stopAutoScroll();-
2078 setState(NoState);-
2079 d->viewport->update();-
2080}
never executed: end of block
0
2081-
2082/*!-
2083 If the event hasn't already been accepted, determines the index to drop on.-
2084-
2085 if (row == -1 && col == -1)-
2086 // append to this drop index-
2087 else-
2088 // place at row, col in drop index-
2089-
2090 If it returns \c true a drop can be done, and dropRow, dropCol and dropIndex reflects the position of the drop.-
2091 \internal-
2092 */-
2093bool QAbstractItemViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex)-
2094{-
2095 Q_Q(QAbstractItemView);-
2096 if (event->isAccepted())
event->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
2097 return false;
never executed: return false;
0
2098-
2099 QModelIndex index;-
2100 // rootIndex() (i.e. the viewport) might be a valid index-
2101 if (viewport->rect().contains(event->pos())) {
viewport->rect...(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2102 index = q->indexAt(event->pos());-
2103 if (!index.isValid() || !q->visualRect(index).contains(event->pos()))
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
!q->visualRect...(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
2104 index = root;
never executed: index = root;
0
2105 }
never executed: end of block
0
2106-
2107 // If we are allowed to do the drop-
2108 if (model->supportedDropActions() & event->dropAction()) {
model->support...->dropAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
2109 int row = -1;-
2110 int col = -1;-
2111 if (index != root) {
index != rootDescription
TRUEnever evaluated
FALSEnever evaluated
0
2112 dropIndicatorPosition = position(event->pos(), q->visualRect(index), index);-
2113 switch (dropIndicatorPosition) {-
2114 case QAbstractItemView::AboveItem:
never executed: case QAbstractItemView::AboveItem:
0
2115 row = index.row();-
2116 col = index.column();-
2117 index = index.parent();-
2118 break;
never executed: break;
0
2119 case QAbstractItemView::BelowItem:
never executed: case QAbstractItemView::BelowItem:
0
2120 row = index.row() + 1;-
2121 col = index.column();-
2122 index = index.parent();-
2123 break;
never executed: break;
0
2124 case QAbstractItemView::OnItem:
never executed: case QAbstractItemView::OnItem:
0
2125 case QAbstractItemView::OnViewport:
never executed: case QAbstractItemView::OnViewport:
0
2126 break;
never executed: break;
0
2127 }-
2128 } else {
never executed: end of block
0
2129 dropIndicatorPosition = QAbstractItemView::OnViewport;-
2130 }
never executed: end of block
0
2131 *dropIndex = index;-
2132 *dropRow = row;-
2133 *dropCol = col;-
2134 if (!droppingOnItself(event, index))
!droppingOnIts...(event, index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2135 return true;
never executed: return true;
0
2136 }
never executed: end of block
0
2137 return false;
never executed: return false;
0
2138}-
2139-
2140QAbstractItemView::DropIndicatorPosition-
2141QAbstractItemViewPrivate::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const-
2142{-
2143 QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport;-
2144 if (!overwrite) {
!overwriteDescription
TRUEnever evaluated
FALSEnever evaluated
0
2145 const int margin = 2;-
2146 if (pos.y() - rect.top() < margin) {
pos.y() - rect.top() < marginDescription
TRUEnever evaluated
FALSEnever evaluated
0
2147 r = QAbstractItemView::AboveItem;-
2148 } else if (rect.bottom() - pos.y() < margin) {
never executed: end of block
rect.bottom() ...s.y() < marginDescription
TRUEnever evaluated
FALSEnever evaluated
0
2149 r = QAbstractItemView::BelowItem;-
2150 } else if (rect.contains(pos, true)) {
never executed: end of block
rect.contains(pos, true)Description
TRUEnever evaluated
FALSEnever evaluated
0
2151 r = QAbstractItemView::OnItem;-
2152 }
never executed: end of block
0
2153 } else {
never executed: end of block
0
2154 QRect touchingRect = rect;-
2155 touchingRect.adjust(-1, -1, 1, 1);-
2156 if (touchingRect.contains(pos, false)) {
touchingRect.c...ns(pos, false)Description
TRUEnever evaluated
FALSEnever evaluated
0
2157 r = QAbstractItemView::OnItem;-
2158 }
never executed: end of block
0
2159 }
never executed: end of block
0
2160-
2161 if (r == QAbstractItemView::OnItem && (!(model->flags(index) & Qt::ItemIsDropEnabled)))
r == QAbstractItemView::OnItemDescription
TRUEnever evaluated
FALSEnever evaluated
(!(model->flag...sDropEnabled))Description
TRUEnever evaluated
FALSEnever evaluated
0
2162 r = pos.y() < rect.center().y() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem;
never executed: r = pos.y() < rect.center().y() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem;
pos.y() < rect.center().y()Description
TRUEnever evaluated
FALSEnever evaluated
0
2163-
2164 return r;
never executed: return r;
0
2165}-
2166-
2167#endif // QT_NO_DRAGANDDROP-
2168-
2169/*!-
2170 This function is called with the given \a event when the widget obtains the focus.-
2171 By default, the event is ignored.-
2172-
2173 \sa setFocus(), focusOutEvent()-
2174*/-
2175void QAbstractItemView::focusInEvent(QFocusEvent *event)-
2176{-
2177 Q_D(QAbstractItemView);-
2178 QAbstractScrollArea::focusInEvent(event);-
2179-
2180 const QItemSelectionModel* model = selectionModel();-
2181 const bool currentIndexValid = currentIndex().isValid();-
2182-
2183 if (model
modelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2184 && !d->currentIndexSet
!d->currentIndexSetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2185 && !currentIndexValid) {
!currentIndexValidDescription
TRUEnever evaluated
FALSEnever evaluated
0
2186 bool autoScroll = d->autoScroll;-
2187 d->autoScroll = false;-
2188 QModelIndex index = moveCursor(MoveNext, Qt::NoModifier); // first visible index-
2189 if (index.isValid() && d->isIndexEnabled(index) && event->reason() != Qt::MouseFocusReason)
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
d->isIndexEnabled(index)Description
TRUEnever evaluated
FALSEnever evaluated
event->reason(...useFocusReasonDescription
TRUEnever evaluated
FALSEnever evaluated
0
2190 selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
never executed: selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
0
2191 d->autoScroll = autoScroll;-
2192 }
never executed: end of block
0
2193-
2194 if (model && currentIndexValid) {
modelDescription
TRUEnever evaluated
FALSEnever evaluated
currentIndexValidDescription
TRUEnever evaluated
FALSEnever evaluated
0
2195 if (currentIndex().flags() != Qt::ItemIsEditable)
currentIndex()...ItemIsEditableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2196 setAttribute(Qt::WA_InputMethodEnabled, false);
never executed: setAttribute(Qt::WA_InputMethodEnabled, false);
0
2197 else-
2198 setAttribute(Qt::WA_InputMethodEnabled);
never executed: setAttribute(Qt::WA_InputMethodEnabled);
0
2199 }-
2200-
2201 if (!currentIndexValid)
!currentIndexValidDescription
TRUEnever evaluated
FALSEnever evaluated
0
2202 setAttribute(Qt::WA_InputMethodEnabled, false);
never executed: setAttribute(Qt::WA_InputMethodEnabled, false);
0
2203-
2204 d->viewport->update();-
2205}
never executed: end of block
0
2206-
2207/*!-
2208 This function is called with the given \a event when the widget-
2209 looses the focus. By default, the event is ignored.-
2210-
2211 \sa clearFocus(), focusInEvent()-
2212*/-
2213void QAbstractItemView::focusOutEvent(QFocusEvent *event)-
2214{-
2215 Q_D(QAbstractItemView);-
2216 QAbstractScrollArea::focusOutEvent(event);-
2217 d->viewport->update();-
2218}
never executed: end of block
0
2219-
2220/*!-
2221 This function is called with the given \a event when a key event is sent to-
2222 the widget. The default implementation handles basic cursor movement, e.g. Up,-
2223 Down, Left, Right, Home, PageUp, and PageDown; the activated() signal is-
2224 emitted if the current index is valid and the activation key is pressed-
2225 (e.g. Enter or Return, depending on the platform).-
2226 This function is where editing is initiated by key press, e.g. if F2 is-
2227 pressed.-
2228-
2229 \sa edit(), moveCursor(), keyboardSearch(), tabKeyNavigation-
2230*/-
2231void QAbstractItemView::keyPressEvent(QKeyEvent *event)-
2232{-
2233 Q_D(QAbstractItemView);-
2234 d->delayedAutoScroll.stop(); //any interaction with the view cancel the auto scrolling-
2235-
2236#ifdef QT_KEYPAD_NAVIGATION-
2237 switch (event->key()) {-
2238 case Qt::Key_Select:-
2239 if (QApplication::keypadNavigationEnabled()) {-
2240 if (!hasEditFocus()) {-
2241 setEditFocus(true);-
2242 return;-
2243 }-
2244 }-
2245 break;-
2246 case Qt::Key_Back:-
2247 if (QApplication::keypadNavigationEnabled() && hasEditFocus()) {-
2248 setEditFocus(false);-
2249 } else {-
2250 event->ignore();-
2251 }-
2252 return;-
2253 case Qt::Key_Down:-
2254 case Qt::Key_Up:-
2255 // Let's ignore vertical navigation events, only if there is no other widget-
2256 // what can take the focus in vertical direction. This means widget can handle navigation events-
2257 // even the widget don't have edit focus, and there is no other widget in requested direction.-
2258 if(QApplication::keypadNavigationEnabled() && !hasEditFocus()-
2259 && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) {-
2260 event->ignore();-
2261 return;-
2262 }-
2263 break;-
2264 case Qt::Key_Left:-
2265 case Qt::Key_Right:-
2266 // Similar logic as in up and down events-
2267 if(QApplication::keypadNavigationEnabled() && !hasEditFocus()-
2268 && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this))) {-
2269 event->ignore();-
2270 return;-
2271 }-
2272 break;-
2273 default:-
2274 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {-
2275 event->ignore();-
2276 return;-
2277 }-
2278 }-
2279#endif-
2280-
2281#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)-
2282 if (event == QKeySequence::Copy) {
event == QKeySequence::CopyDescription
TRUEnever evaluated
FALSEnever evaluated
0
2283 QVariant variant;-
2284 if (d->model)
d->modelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2285 variant = d->model->data(currentIndex(), Qt::DisplayRole);
never executed: variant = d->model->data(currentIndex(), Qt::DisplayRole);
0
2286 if (variant.type() == QVariant::String)
variant.type()...ariant::StringDescription
TRUEnever evaluated
FALSEnever evaluated
0
2287 QApplication::clipboard()->setText(variant.toString());
never executed: QApplication::clipboard()->setText(variant.toString());
0
2288 event->accept();-
2289 }
never executed: end of block
0
2290#endif-
2291-
2292 QPersistentModelIndex newCurrent;-
2293 d->moveCursorUpdatedView = false;-
2294 switch (event->key()) {-
2295 case Qt::Key_Down:
never executed: case Qt::Key_Down:
0
2296 newCurrent = moveCursor(MoveDown, event->modifiers());-
2297 break;
never executed: break;
0
2298 case Qt::Key_Up:
never executed: case Qt::Key_Up:
0
2299 newCurrent = moveCursor(MoveUp, event->modifiers());-
2300 break;
never executed: break;
0
2301 case Qt::Key_Left:
never executed: case Qt::Key_Left:
0
2302 newCurrent = moveCursor(MoveLeft, event->modifiers());-
2303 break;
never executed: break;
0
2304 case Qt::Key_Right:
never executed: case Qt::Key_Right:
0
2305 newCurrent = moveCursor(MoveRight, event->modifiers());-
2306 break;
never executed: break;
0
2307 case Qt::Key_Home:
never executed: case Qt::Key_Home:
0
2308 newCurrent = moveCursor(MoveHome, event->modifiers());-
2309 break;
never executed: break;
0
2310 case Qt::Key_End:
never executed: case Qt::Key_End:
0
2311 newCurrent = moveCursor(MoveEnd, event->modifiers());-
2312 break;
never executed: break;
0
2313 case Qt::Key_PageUp:
never executed: case Qt::Key_PageUp:
0
2314 newCurrent = moveCursor(MovePageUp, event->modifiers());-
2315 break;
never executed: break;
0
2316 case Qt::Key_PageDown:
never executed: case Qt::Key_PageDown:
0
2317 newCurrent = moveCursor(MovePageDown, event->modifiers());-
2318 break;
never executed: break;
0
2319 case Qt::Key_Tab:
never executed: case Qt::Key_Tab:
0
2320 if (d->tabKeyNavigation)
d->tabKeyNavigationDescription
TRUEnever evaluated
FALSEnever evaluated
0
2321 newCurrent = moveCursor(MoveNext, event->modifiers());
never executed: newCurrent = moveCursor(MoveNext, event->modifiers());
0
2322 break;
never executed: break;
0
2323 case Qt::Key_Backtab:
never executed: case Qt::Key_Backtab:
0
2324 if (d->tabKeyNavigation)
d->tabKeyNavigationDescription
TRUEnever evaluated
FALSEnever evaluated
0
2325 newCurrent = moveCursor(MovePrevious, event->modifiers());
never executed: newCurrent = moveCursor(MovePrevious, event->modifiers());
0
2326 break;
never executed: break;
0
2327 }-
2328-
2329 QPersistentModelIndex oldCurrent = currentIndex();-
2330 if (newCurrent != oldCurrent && newCurrent.isValid() && d->isIndexEnabled(newCurrent)) {
newCurrent != oldCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
newCurrent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
d->isIndexEnabled(newCurrent)Description
TRUEnever evaluated
FALSEnever evaluated
0
2331 if (!hasFocus() && QApplication::focusWidget() == indexWidget(oldCurrent))
!hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
QApplication::...et(oldCurrent)Description
TRUEnever evaluated
FALSEnever evaluated
0
2332 setFocus();
never executed: setFocus();
0
2333 QItemSelectionModel::SelectionFlags command = selectionCommand(newCurrent, event);-
2334 if (command != QItemSelectionModel::NoUpdate
command != QIt...odel::NoUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2335 || style()->styleHint(QStyle::SH_ItemView_MovementWithoutUpdatingSelection, 0, this)) {
style()->style...tion, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2336 // note that we don't check if the new current index is enabled because moveCursor() makes sure it is-
2337 if (command & QItemSelectionModel::Current) {
command & QIte...Model::CurrentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2338 d->selectionModel->setCurrentIndex(newCurrent, QItemSelectionModel::NoUpdate);-
2339 if (!d->currentSelectionStartIndex.isValid())
!d->currentSel...ndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2340 d->currentSelectionStartIndex = oldCurrent;
never executed: d->currentSelectionStartIndex = oldCurrent;
0
2341 QRect rect(visualRect(d->currentSelectionStartIndex).center(), visualRect(newCurrent).center());-
2342 setSelection(rect, command);-
2343 } else {
never executed: end of block
0
2344 d->selectionModel->setCurrentIndex(newCurrent, command);-
2345 d->currentSelectionStartIndex = newCurrent;-
2346 if (newCurrent.isValid()) {
newCurrent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2347 // We copy the same behaviour as for mousePressEvent().-
2348 QRect rect(visualRect(newCurrent).center(), QSize(1, 1));-
2349 setSelection(rect, command);-
2350 }
never executed: end of block
0
2351 }
never executed: end of block
0
2352 event->accept();-
2353 return;
never executed: return;
0
2354 }-
2355 }
never executed: end of block
0
2356-
2357 switch (event->key()) {-
2358 // ignored keys-
2359 case Qt::Key_Down:
never executed: case Qt::Key_Down:
0
2360 case Qt::Key_Up:
never executed: case Qt::Key_Up:
0
2361#ifdef QT_KEYPAD_NAVIGATION-
2362 if (QApplication::keypadNavigationEnabled() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) {-
2363 event->accept(); // don't change focus-
2364 break;-
2365 }-
2366#endif-
2367 case Qt::Key_Left:
never executed: case Qt::Key_Left:
0
2368 case Qt::Key_Right:
never executed: case Qt::Key_Right:
0
2369#ifdef QT_KEYPAD_NAVIGATION-
2370 if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional-
2371 && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal)-
2372 || (QWidgetPrivate::inTabWidget(this) && d->model->columnCount(d->root) > 1))) {-
2373 event->accept(); // don't change focus-
2374 break;-
2375 }-
2376#endif // QT_KEYPAD_NAVIGATION-
2377 case Qt::Key_Home:
never executed: case Qt::Key_Home:
0
2378 case Qt::Key_End:
never executed: case Qt::Key_End:
0
2379 case Qt::Key_PageUp:
never executed: case Qt::Key_PageUp:
0
2380 case Qt::Key_PageDown:
never executed: case Qt::Key_PageDown:
0
2381 case Qt::Key_Escape:
never executed: case Qt::Key_Escape:
0
2382 case Qt::Key_Shift:
never executed: case Qt::Key_Shift:
0
2383 case Qt::Key_Control:
never executed: case Qt::Key_Control:
0
2384 case Qt::Key_Delete:
never executed: case Qt::Key_Delete:
0
2385 case Qt::Key_Backspace:
never executed: case Qt::Key_Backspace:
0
2386 event->ignore();-
2387 break;
never executed: break;
0
2388 case Qt::Key_Space:
never executed: case Qt::Key_Space:
0
2389 case Qt::Key_Select:
never executed: case Qt::Key_Select:
0
2390 if (!edit(currentIndex(), AnyKeyPressed, event) && d->selectionModel)
!edit(currentI...ressed, event)Description
TRUEnever evaluated
FALSEnever evaluated
d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2391 d->selectionModel->select(currentIndex(), selectionCommand(currentIndex(), event));
never executed: d->selectionModel->select(currentIndex(), selectionCommand(currentIndex(), event));
0
2392#ifdef QT_KEYPAD_NAVIGATION-
2393 if ( event->key()==Qt::Key_Select ) {-
2394 // Also do Key_Enter action.-
2395 if (currentIndex().isValid()) {-
2396 if (state() != EditingState)-
2397 emit activated(currentIndex());-
2398 } else {-
2399 event->ignore();-
2400 }-
2401 }-
2402#endif-
2403 break;
never executed: break;
0
2404#ifdef Q_OS_OSX-
2405 case Qt::Key_Enter:-
2406 case Qt::Key_Return:-
2407 // Propagate the enter if you couldn't edit the item and there are no-
2408 // current editors (if there are editors, the event was most likely propagated from it).-
2409 if (!edit(currentIndex(), EditKeyPressed, event) && d->editorIndexHash.isEmpty())-
2410 event->ignore();-
2411 break;-
2412#else-
2413 case Qt::Key_F2:
never executed: case Qt::Key_F2:
0
2414 if (!edit(currentIndex(), EditKeyPressed, event))
!edit(currentI...ressed, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
2415 event->ignore();
never executed: event->ignore();
0
2416 break;
never executed: break;
0
2417 case Qt::Key_Enter:
never executed: case Qt::Key_Enter:
0
2418 case Qt::Key_Return:
never executed: case Qt::Key_Return:
0
2419 // ### we can't open the editor on enter, becuse-
2420 // some widgets will forward the enter event back-
2421 // to the viewport, starting an endless loop-
2422 if (state() != EditingState || hasFocus()) {
state() != EditingStateDescription
TRUEnever evaluated
FALSEnever evaluated
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
2423 if (currentIndex().isValid())
currentIndex().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2424 emit activated(currentIndex());
never executed: activated(currentIndex());
0
2425 event->ignore();-
2426 }
never executed: end of block
0
2427 break;
never executed: break;
0
2428#endif-
2429 default: {
never executed: default:
0
2430 if (event == QKeySequence::SelectAll && selectionMode() != NoSelection) {
event == QKeyS...nce::SelectAllDescription
TRUEnever evaluated
FALSEnever evaluated
selectionMode() != NoSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2431 selectAll();-
2432 break;
never executed: break;
0
2433 }-
2434#ifdef Q_OS_OSX-
2435 if (event->key() == Qt::Key_O && event->modifiers() & Qt::ControlModifier && currentIndex().isValid()) {-
2436 emit activated(currentIndex());-
2437 break;-
2438 }-
2439#endif-
2440 bool modified = (event->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier));-
2441 if (!event->text().isEmpty() && !modified && !edit(currentIndex(), AnyKeyPressed, event)) {
!event->text().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!modifiedDescription
TRUEnever evaluated
FALSEnever evaluated
!edit(currentI...ressed, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
2442 keyboardSearch(event->text());-
2443 event->accept();-
2444 } else {
never executed: end of block
0
2445 event->ignore();-
2446 }
never executed: end of block
0
2447 break; }
never executed: break;
0
2448 }-
2449 if (d->moveCursorUpdatedView)
d->moveCursorUpdatedViewDescription
TRUEnever evaluated
FALSEnever evaluated
0
2450 event->accept();
never executed: event->accept();
0
2451}
never executed: end of block
0
2452-
2453/*!-
2454 This function is called with the given \a event when a resize event is sent to-
2455 the widget.-
2456-
2457 \sa QWidget::resizeEvent()-
2458*/-
2459void QAbstractItemView::resizeEvent(QResizeEvent *event)-
2460{-
2461 QAbstractScrollArea::resizeEvent(event);-
2462 updateGeometries();-
2463}
never executed: end of block
0
2464-
2465/*!-
2466 This function is called with the given \a event when a timer event is sent-
2467 to the widget.-
2468-
2469 \sa QObject::timerEvent()-
2470*/-
2471void QAbstractItemView::timerEvent(QTimerEvent *event)-
2472{-
2473 Q_D(QAbstractItemView);-
2474 if (event->timerId() == d->fetchMoreTimer.timerId())
event->timerId...imer.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
2475 d->fetchMore();
never executed: d->fetchMore();
0
2476 else if (event->timerId() == d->delayedReset.timerId())
event->timerId...eset.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
2477 reset();
never executed: reset();
0
2478 else if (event->timerId() == d->autoScrollTimer.timerId())
event->timerId...imer.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
2479 doAutoScroll();
never executed: doAutoScroll();
0
2480 else if (event->timerId() == d->updateTimer.timerId())
event->timerId...imer.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
2481 d->updateDirtyRegion();
never executed: d->updateDirtyRegion();
0
2482 else if (event->timerId() == d->delayedEditing.timerId()) {
event->timerId...ting.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
2483 d->delayedEditing.stop();-
2484 edit(currentIndex());-
2485 } else if (event->timerId() == d->delayedLayout.timerId()) {
never executed: end of block
event->timerId...yout.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
2486 d->delayedLayout.stop();-
2487 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
2488 d->interruptDelayedItemsLayout();-
2489 doItemsLayout();-
2490 const QModelIndex current = currentIndex();-
2491 if (current.isValid() && d->state == QAbstractItemView::EditingState)
current.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
d->state == QA...::EditingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2492 scrollTo(current);
never executed: scrollTo(current);
0
2493 }
never executed: end of block
0
2494 } else if (event->timerId() == d->delayedAutoScroll.timerId()) {
never executed: end of block
event->timerId...roll.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
0
2495 d->delayedAutoScroll.stop();-
2496 //end of the timer: if the current item is still the same as the one when the mouse press occurred-
2497 //we only get here if there was no double click-
2498 if (d->pressedIndex.isValid() && d->pressedIndex == currentIndex())
d->pressedIndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
d->pressedInde...currentIndex()Description
TRUEnever evaluated
FALSEnever evaluated
0
2499 scrollTo(d->pressedIndex);
never executed: scrollTo(d->pressedIndex);
0
2500 }
never executed: end of block
0
2501}
never executed: end of block
0
2502-
2503/*!-
2504 \reimp-
2505*/-
2506void QAbstractItemView::inputMethodEvent(QInputMethodEvent *event)-
2507{-
2508 if (event->commitString().isEmpty() && event->preeditString().isEmpty()) {
event->commitS...ng().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
event->preedit...ng().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2509 event->ignore();-
2510 return;
never executed: return;
0
2511 }-
2512 if (!edit(currentIndex(), AnyKeyPressed, event)) {
!edit(currentI...ressed, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
2513 if (!event->commitString().isEmpty())
!event->commit...ng().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2514 keyboardSearch(event->commitString());
never executed: keyboardSearch(event->commitString());
0
2515 event->ignore();-
2516 }
never executed: end of block
0
2517}
never executed: end of block
0
2518-
2519#ifndef QT_NO_DRAGANDDROP-
2520/*!-
2521 \enum QAbstractItemView::DropIndicatorPosition-
2522-
2523 This enum indicates the position of the drop indicator in-
2524 relation to the index at the current mouse position:-
2525-
2526 \value OnItem The item will be dropped on the index.-
2527-
2528 \value AboveItem The item will be dropped above the index.-
2529-
2530 \value BelowItem The item will be dropped below the index.-
2531-
2532 \value OnViewport The item will be dropped onto a region of the viewport with-
2533 no items. The way each view handles items dropped onto the viewport depends on-
2534 the behavior of the underlying model in use.-
2535*/-
2536-
2537-
2538/*!-
2539 \since 4.1-
2540-
2541 Returns the position of the drop indicator in relation to the closest item.-
2542*/-
2543QAbstractItemView::DropIndicatorPosition QAbstractItemView::dropIndicatorPosition() const-
2544{-
2545 Q_D(const QAbstractItemView);-
2546 return d->dropIndicatorPosition;
never executed: return d->dropIndicatorPosition;
0
2547}-
2548#endif-
2549-
2550/*!-
2551 This convenience function returns a list of all selected and-
2552 non-hidden item indexes in the view. The list contains no-
2553 duplicates, and is not sorted.-
2554-
2555 \sa QItemSelectionModel::selectedIndexes()-
2556*/-
2557QModelIndexList QAbstractItemView::selectedIndexes() const-
2558{-
2559 Q_D(const QAbstractItemView);-
2560 QModelIndexList indexes;-
2561 if (d->selectionModel) {
d->selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2562 indexes = d->selectionModel->selectedIndexes();-
2563 QList<QModelIndex>::iterator it = indexes.begin();-
2564 while (it != indexes.end())
it != indexes.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
2565 if (isIndexHidden(*it))
isIndexHidden(*it)Description
TRUEnever evaluated
FALSEnever evaluated
0
2566 it = indexes.erase(it);
never executed: it = indexes.erase(it);
0
2567 else-
2568 ++it;
never executed: ++it;
0
2569 }
never executed: end of block
0
2570 return indexes;
never executed: return indexes;
0
2571}-
2572-
2573/*!-
2574 Starts editing the item at \a index, creating an editor if-
2575 necessary, and returns \c true if the view's \l{State} is now-
2576 EditingState; otherwise returns \c false.-
2577-
2578 The action that caused the editing process is described by-
2579 \a trigger, and the associated event is specified by \a event.-
2580-
2581 Editing can be forced by specifying the \a trigger to be-
2582 QAbstractItemView::AllEditTriggers.-
2583-
2584 \sa closeEditor()-
2585*/-
2586bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEvent *event)-
2587{-
2588 Q_D(QAbstractItemView);-
2589-
2590 if (!d->isIndexValid(index))
!d->isIndexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
2591 return false;
never executed: return false;
0
2592-
2593 if (QWidget *w = (d->persistent.isEmpty() ? static_cast<QWidget*>(0) : d->editorForIndex(index).widget.data())) {
QWidget *w = (...widget.data())Description
TRUEnever evaluated
FALSEnever evaluated
d->persistent.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2594 if (w->focusPolicy() == Qt::NoFocus)
w->focusPolicy...== Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
2595 return false;
never executed: return false;
0
2596 w->setFocus();-
2597 return true;
never executed: return true;
0
2598 }-
2599-
2600 if (trigger == DoubleClicked) {
trigger == DoubleClickedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2601 d->delayedEditing.stop();-
2602 d->delayedAutoScroll.stop();-
2603 } else if (trigger == CurrentChanged) {
never executed: end of block
trigger == CurrentChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2604 d->delayedEditing.stop();-
2605 }
never executed: end of block
0
2606-
2607 if (d->sendDelegateEvent(index, event)) {
d->sendDelegat...(index, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
2608 update(index);-
2609 return true;
never executed: return true;
0
2610 }-
2611-
2612 // save the previous trigger before updating-
2613 EditTriggers lastTrigger = d->lastTrigger;-
2614 d->lastTrigger = trigger;-
2615-
2616 if (!d->shouldEdit(trigger, d->model->buddy(index)))
!d->shouldEdit...>buddy(index))Description
TRUEnever evaluated
FALSEnever evaluated
0
2617 return false;
never executed: return false;
0
2618-
2619 if (d->delayedEditing.isActive())
d->delayedEditing.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
2620 return false;
never executed: return false;
0
2621-
2622 // we will receive a mouseButtonReleaseEvent after a-
2623 // mouseDoubleClickEvent, so we need to check the previous trigger-
2624 if (lastTrigger == DoubleClicked && trigger == SelectedClicked)
lastTrigger == DoubleClickedDescription
TRUEnever evaluated
FALSEnever evaluated
trigger == SelectedClickedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2625 return false;
never executed: return false;
0
2626-
2627 // we may get a double click event later-
2628 if (trigger == SelectedClicked)
trigger == SelectedClickedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2629 d->delayedEditing.start(QApplication::doubleClickInterval(), this);
never executed: d->delayedEditing.start(QApplication::doubleClickInterval(), this);
0
2630 else-
2631 d->openEditor(index, d->shouldForwardEvent(trigger, event) ? event : 0);
never executed: d->openEditor(index, d->shouldForwardEvent(trigger, event) ? event : 0);
0
2632-
2633 return true;
never executed: return true;
0
2634}-
2635-
2636/*!-
2637 \internal-
2638 Updates the data shown in the open editor widgets in the view.-
2639*/-
2640void QAbstractItemView::updateEditorData()-
2641{-
2642 Q_D(QAbstractItemView);-
2643 d->updateEditorData(QModelIndex(), QModelIndex());-
2644}
never executed: end of block
0
2645-
2646/*!-
2647 \internal-
2648 Updates the geometry of the open editor widgets in the view.-
2649*/-
2650void QAbstractItemView::updateEditorGeometries()-
2651{-
2652 Q_D(QAbstractItemView);-
2653 if(d->editorIndexHash.isEmpty())
d->editorIndexHash.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2654 return;
never executed: return;
0
2655 if (d->delayedPendingLayout) {
d->delayedPendingLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
2656 // doItemsLayout() will end up calling this function again-
2657 d->executePostedLayout();-
2658 return;
never executed: return;
0
2659 }-
2660 QStyleOptionViewItem option = d->viewOptionsV1();-
2661 QEditorIndexHash::iterator it = d->editorIndexHash.begin();-
2662 QWidgetList editorsToRelease;-
2663 QWidgetList editorsToHide;-
2664 while (it != d->editorIndexHash.end()) {
it != d->editorIndexHash.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
2665 QModelIndex index = it.value();-
2666 QWidget *editor = it.key();-
2667 if (index.isValid() && editor) {
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
editorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2668 option.rect = visualRect(index);-
2669 if (option.rect.isValid()) {
option.rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2670 editor->show();-
2671 QAbstractItemDelegate *delegate = d->delegateForIndex(index);-
2672 if (delegate)
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2673 delegate->updateEditorGeometry(editor, option, index);
never executed: delegate->updateEditorGeometry(editor, option, index);
0
2674 } else {
never executed: end of block
0
2675 editorsToHide << editor;-
2676 }
never executed: end of block
0
2677 ++it;-
2678 } else {
never executed: end of block
0
2679 d->indexEditorHash.remove(it.value());-
2680 it = d->editorIndexHash.erase(it);-
2681 editorsToRelease << editor;-
2682 }
never executed: end of block
0
2683 }-
2684-
2685 //we hide and release the editor outside of the loop because it might change the focus and try-
2686 //to change the editors hashes.-
2687 for (int i = 0; i < editorsToHide.count(); ++i) {
i < editorsToHide.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2688 editorsToHide.at(i)->hide();-
2689 }
never executed: end of block
0
2690 for (int i = 0; i < editorsToRelease.count(); ++i) {
i < editorsToRelease.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2691 d->releaseEditor(editorsToRelease.at(i));-
2692 }
never executed: end of block
0
2693}
never executed: end of block
0
2694-
2695/*!-
2696 \since 4.4-
2697-
2698 Updates the geometry of the child widgets of the view.-
2699*/-
2700void QAbstractItemView::updateGeometries()-
2701{-
2702 Q_D(QAbstractItemView);-
2703 updateEditorGeometries();-
2704 d->fetchMoreTimer.start(0, this); //fetch more later-
2705 d->updateGeometry();-
2706}
never executed: end of block
0
2707-
2708/*!-
2709 \internal-
2710*/-
2711void QAbstractItemView::verticalScrollbarValueChanged(int value)-
2712{-
2713 Q_D(QAbstractItemView);-
2714 if (verticalScrollBar()->maximum() == value && d->model->canFetchMore(d->root))
verticalScroll...mum() == valueDescription
TRUEnever evaluated
FALSEnever evaluated
d->model->canF...hMore(d->root)Description
TRUEnever evaluated
FALSEnever evaluated
0
2715 d->model->fetchMore(d->root);
never executed: d->model->fetchMore(d->root);
0
2716 QPoint posInVp = viewport()->mapFromGlobal(QCursor::pos());-
2717 if (viewport()->rect().contains(posInVp))
viewport()->re...tains(posInVp)Description
TRUEnever evaluated
FALSEnever evaluated
0
2718 d->checkMouseMove(posInVp);
never executed: d->checkMouseMove(posInVp);
0
2719}
never executed: end of block
0
2720-
2721/*!-
2722 \internal-
2723*/-
2724void QAbstractItemView::horizontalScrollbarValueChanged(int value)-
2725{-
2726 Q_D(QAbstractItemView);-
2727 if (horizontalScrollBar()->maximum() == value && d->model->canFetchMore(d->root))
horizontalScro...mum() == valueDescription
TRUEnever evaluated
FALSEnever evaluated
d->model->canF...hMore(d->root)Description
TRUEnever evaluated
FALSEnever evaluated
0
2728 d->model->fetchMore(d->root);
never executed: d->model->fetchMore(d->root);
0
2729 QPoint posInVp = viewport()->mapFromGlobal(QCursor::pos());-
2730 if (viewport()->rect().contains(posInVp))
viewport()->re...tains(posInVp)Description
TRUEnever evaluated
FALSEnever evaluated
0
2731 d->checkMouseMove(posInVp);
never executed: d->checkMouseMove(posInVp);
0
2732}
never executed: end of block
0
2733-
2734/*!-
2735 \internal-
2736*/-
2737void QAbstractItemView::verticalScrollbarAction(int)-
2738{-
2739 //do nothing-
2740}-
2741-
2742/*!-
2743 \internal-
2744*/-
2745void QAbstractItemView::horizontalScrollbarAction(int)-
2746{-
2747 //do nothing-
2748}-
2749-
2750/*!-
2751 Closes the given \a editor, and releases it. The \a hint is-
2752 used to specify how the view should respond to the end of the editing-
2753 operation. For example, the hint may indicate that the next item in-
2754 the view should be opened for editing.-
2755-
2756 \sa edit(), commitData()-
2757*/-
2758-
2759void QAbstractItemView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint)-
2760{-
2761 Q_D(QAbstractItemView);-
2762-
2763 // Close the editor-
2764 if (editor) {
editorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2765 bool isPersistent = d->persistent.contains(editor);-
2766 bool hadFocus = editor->hasFocus();-
2767 QModelIndex index = d->indexForEditor(editor);-
2768 if (!index.isValid())
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2769 return; // the editor was not registered
never executed: return;
0
2770-
2771 if (!isPersistent) {
!isPersistentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2772 setState(NoState);-
2773 QModelIndex index = d->indexForEditor(editor);-
2774 editor->removeEventFilter(d->delegateForIndex(index));-
2775 d->removeEditor(editor);-
2776 }
never executed: end of block
0
2777 if (hadFocus) {
hadFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
2778 if (focusPolicy() != Qt::NoFocus)
focusPolicy() != Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
2779 setFocus(); // this will send a focusLost event to the editor
never executed: setFocus();
0
2780 else-
2781 editor->clearFocus();
never executed: editor->clearFocus();
0
2782 } else {-
2783 d->checkPersistentEditorFocus();-
2784 }
never executed: end of block
0
2785-
2786 QPointer<QWidget> ed = editor;-
2787 QApplication::sendPostedEvents(editor, 0);-
2788 editor = ed;-
2789-
2790 if (!isPersistent && editor)
!isPersistentDescription
TRUEnever evaluated
FALSEnever evaluated
editorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2791 d->releaseEditor(editor, index);
never executed: d->releaseEditor(editor, index);
0
2792 }
never executed: end of block
0
2793-
2794 // The EndEditHint part-
2795 QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::NoUpdate;-
2796 if (d->selectionMode != NoSelection)
d->selectionMo...!= NoSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2797 flags = QItemSelectionModel::ClearAndSelect | d->selectionBehaviorFlags();
never executed: flags = QItemSelectionModel::ClearAndSelect | d->selectionBehaviorFlags();
0
2798 switch (hint) {-
2799 case QAbstractItemDelegate::EditNextItem: {
never executed: case QAbstractItemDelegate::EditNextItem:
0
2800 QModelIndex index = moveCursor(MoveNext, Qt::NoModifier);-
2801 if (index.isValid()) {
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2802 QPersistentModelIndex persistent(index);-
2803 d->selectionModel->setCurrentIndex(persistent, flags);-
2804 // currentChanged signal would have already started editing-
2805 if (index.flags() & Qt::ItemIsEditable
index.flags() ...ItemIsEditableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2806 && (!(editTriggers() & QAbstractItemView::CurrentChanged)))
(!(editTrigger...rrentChanged))Description
TRUEnever evaluated
FALSEnever evaluated
0
2807 edit(persistent);
never executed: edit(persistent);
0
2808 } break; }
never executed: end of block
never executed: break;
0
2809 case QAbstractItemDelegate::EditPreviousItem: {
never executed: case QAbstractItemDelegate::EditPreviousItem:
0
2810 QModelIndex index = moveCursor(MovePrevious, Qt::NoModifier);-
2811 if (index.isValid()) {
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2812 QPersistentModelIndex persistent(index);-
2813 d->selectionModel->setCurrentIndex(persistent, flags);-
2814 // currentChanged signal would have already started editing-
2815 if (index.flags() & Qt::ItemIsEditable
index.flags() ...ItemIsEditableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2816 && (!(editTriggers() & QAbstractItemView::CurrentChanged)))
(!(editTrigger...rrentChanged))Description
TRUEnever evaluated
FALSEnever evaluated
0
2817 edit(persistent);
never executed: edit(persistent);
0
2818 } break; }
never executed: end of block
never executed: break;
0
2819 case QAbstractItemDelegate::SubmitModelCache:
never executed: case QAbstractItemDelegate::SubmitModelCache:
0
2820 d->model->submit();-
2821 break;
never executed: break;
0
2822 case QAbstractItemDelegate::RevertModelCache:
never executed: case QAbstractItemDelegate::RevertModelCache:
0
2823 d->model->revert();-
2824 break;
never executed: break;
0
2825 default:
never executed: default:
0
2826 break;
never executed: break;
0
2827 }-
2828}-
2829-
2830/*!-
2831 Commit the data in the \a editor to the model.-
2832-
2833 \sa closeEditor()-
2834*/-
2835void QAbstractItemView::commitData(QWidget *editor)-
2836{-
2837 Q_D(QAbstractItemView);-
2838 if (!editor || !d->itemDelegate || d->currentlyCommittingEditor)
!editorDescription
TRUEnever evaluated
FALSEnever evaluated
!d->itemDelegateDescription
TRUEnever evaluated
FALSEnever evaluated
d->currentlyCommittingEditorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2839 return;
never executed: return;
0
2840 QModelIndex index = d->indexForEditor(editor);-
2841 if (!index.isValid())
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2842 return;
never executed: return;
0
2843 d->currentlyCommittingEditor = editor;-
2844 QAbstractItemDelegate *delegate = d->delegateForIndex(index);-
2845 editor->removeEventFilter(delegate);-
2846 delegate->setModelData(editor, d->model, index);-
2847 editor->installEventFilter(delegate);-
2848 d->currentlyCommittingEditor = 0;-
2849}
never executed: end of block
0
2850-
2851/*!-
2852 This function is called when the given \a editor has been destroyed.-
2853-
2854 \sa closeEditor()-
2855*/-
2856void QAbstractItemView::editorDestroyed(QObject *editor)-
2857{-
2858 Q_D(QAbstractItemView);-
2859 QWidget *w = qobject_cast<QWidget*>(editor);-
2860 d->removeEditor(w);-
2861 d->persistent.remove(w);-
2862 if (state() == EditingState)
state() == EditingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2863 setState(NoState);
never executed: setState(NoState);
0
2864}
never executed: end of block
0
2865-
2866/*!-
2867 \obsolete-
2868 Sets the horizontal scroll bar's steps per item to \a steps.-
2869-
2870 This is the number of steps used by the horizontal scroll bar to-
2871 represent the width of an item.-
2872-
2873 Note that if the view has a horizontal header, the item steps-
2874 will be ignored and the header section size will be used instead.-
2875-
2876 \sa horizontalStepsPerItem(), setVerticalStepsPerItem()-
2877*/-
2878void QAbstractItemView::setHorizontalStepsPerItem(int steps)-
2879{-
2880 Q_UNUSED(steps)-
2881 // do nothing-
2882}
never executed: end of block
0
2883-
2884/*!-
2885 \obsolete-
2886 Returns the horizontal scroll bar's steps per item.-
2887-
2888 \sa setHorizontalStepsPerItem(), verticalStepsPerItem()-
2889*/-
2890int QAbstractItemView::horizontalStepsPerItem() const-
2891{-
2892 return 1;
never executed: return 1;
0
2893}-
2894-
2895/*!-
2896 \obsolete-
2897 Sets the vertical scroll bar's steps per item to \a steps.-
2898-
2899 This is the number of steps used by the vertical scroll bar to-
2900 represent the height of an item.-
2901-
2902 Note that if the view has a vertical header, the item steps-
2903 will be ignored and the header section size will be used instead.-
2904-
2905 \sa verticalStepsPerItem(), setHorizontalStepsPerItem()-
2906*/-
2907void QAbstractItemView::setVerticalStepsPerItem(int steps)-
2908{-
2909 Q_UNUSED(steps)-
2910 // do nothing-
2911}
never executed: end of block
0
2912-
2913/*!-
2914 \obsolete-
2915 Returns the vertical scroll bar's steps per item.-
2916-
2917 \sa setVerticalStepsPerItem(), horizontalStepsPerItem()-
2918*/-
2919int QAbstractItemView::verticalStepsPerItem() const-
2920{-
2921 return 1;
never executed: return 1;
0
2922}-
2923-
2924/*!-
2925 Moves to and selects the item best matching the string \a search.-
2926 If no item is found nothing happens.-
2927-
2928 In the default implementation, the search is reset if \a search is empty, or-
2929 the time interval since the last search has exceeded-
2930 QApplication::keyboardInputInterval().-
2931*/-
2932void QAbstractItemView::keyboardSearch(const QString &search)-
2933{-
2934 Q_D(QAbstractItemView);-
2935 if (!d->model->rowCount(d->root) || !d->model->columnCount(d->root))
!d->model->rowCount(d->root)Description
TRUEnever evaluated
FALSEnever evaluated
!d->model->col...Count(d->root)Description
TRUEnever evaluated
FALSEnever evaluated
0
2936 return;
never executed: return;
0
2937-
2938 QModelIndex start = currentIndex().isValid() ? currentIndex()
currentIndex().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2939 : d->model->index(0, 0, d->root);-
2940 bool skipRow = false;-
2941 bool keyboardTimeWasValid = d->keyboardInputTime.isValid();-
2942 qint64 keyboardInputTimeElapsed;-
2943 if (keyboardTimeWasValid)
keyboardTimeWasValidDescription
TRUEnever evaluated
FALSEnever evaluated
0
2944 keyboardInputTimeElapsed = d->keyboardInputTime.restart();
never executed: keyboardInputTimeElapsed = d->keyboardInputTime.restart();
0
2945 else-
2946 d->keyboardInputTime.start();
never executed: d->keyboardInputTime.start();
0
2947 if (search.isEmpty() || !keyboardTimeWasValid
search.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!keyboardTimeWasValidDescription
TRUEnever evaluated
FALSEnever evaluated
0
2948 || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) {
keyboardInputT...nputInterval()Description
TRUEnever evaluated
FALSEnever evaluated
0
2949 d->keyboardInput = search;-
2950 skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0)-
2951 } else {
never executed: end of block
0
2952 d->keyboardInput += search;-
2953 }
never executed: end of block
0
2954-
2955 // special case for searches with same key like 'aaaaa'-
2956 bool sameKey = false;-
2957 if (d->keyboardInput.length() > 1) {
d->keyboardInput.length() > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2958 int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1));-
2959 sameKey = (c == d->keyboardInput.length());-
2960 if (sameKey)
sameKeyDescription
TRUEnever evaluated
FALSEnever evaluated
0
2961 skipRow = true;
never executed: skipRow = true;
0
2962 }
never executed: end of block
0
2963-
2964 // skip if we are searching for the same key or a new search started-
2965 if (skipRow) {
skipRowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2966 QModelIndex parent = start.parent();-
2967 int newRow = (start.row() < d->model->rowCount(parent) - 1) ? start.row() + 1 : 0;
(start.row() <...t(parent) - 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
2968 start = d->model->index(newRow, start.column(), parent);-
2969 }
never executed: end of block
0
2970-
2971 // search from start with wraparound-
2972 QModelIndex current = start;-
2973 QModelIndexList match;-
2974 QModelIndex firstMatch;-
2975 QModelIndex startMatch;-
2976 QModelIndexList previous;-
2977 do {-
2978 match = d->model->match(current, Qt::DisplayRole, d->keyboardInput);-
2979 if (match == previous)
match == previousDescription
TRUEnever evaluated
FALSEnever evaluated
0
2980 break;
never executed: break;
0
2981 firstMatch = match.value(0);-
2982 previous = match;-
2983 if (firstMatch.isValid()) {
firstMatch.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2984 if (d->isIndexEnabled(firstMatch)) {
d->isIndexEnabled(firstMatch)Description
TRUEnever evaluated
FALSEnever evaluated
0
2985 setCurrentIndex(firstMatch);-
2986 break;
never executed: break;
0
2987 }-
2988 int row = firstMatch.row() + 1;-
2989 if (row >= d->model->rowCount(firstMatch.parent()))
row >= d->mode...atch.parent())Description
TRUEnever evaluated
FALSEnever evaluated
0
2990 row = 0;
never executed: row = 0;
0
2991 current = firstMatch.sibling(row, firstMatch.column());-
2992-
2993 //avoid infinite loop if all the matching items are disabled.-
2994 if (!startMatch.isValid())
!startMatch.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2995 startMatch = firstMatch;
never executed: startMatch = firstMatch;
0
2996 else if (startMatch == firstMatch)
startMatch == firstMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
2997 break;
never executed: break;
0
2998 }
never executed: end of block
0
2999 } while (current != start && firstMatch.isValid());
never executed: end of block
current != startDescription
TRUEnever evaluated
FALSEnever evaluated
firstMatch.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3000}
never executed: end of block
0
3001-
3002/*!-
3003 Returns the size hint for the item with the specified \a index or-
3004 an invalid size for invalid indexes.-
3005-
3006 \sa sizeHintForRow(), sizeHintForColumn()-
3007*/-
3008QSize QAbstractItemView::sizeHintForIndex(const QModelIndex &index) const-
3009{-
3010 Q_D(const QAbstractItemView);-
3011 if (!d->isIndexValid(index) || !d->itemDelegate)
!d->isIndexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
!d->itemDelegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
3012 return QSize();
never executed: return QSize();
0
3013 return d->delegateForIndex(index)->sizeHint(d->viewOptionsV1(), index);
never executed: return d->delegateForIndex(index)->sizeHint(d->viewOptionsV1(), index);
0
3014}-
3015-
3016/*!-
3017 Returns the height size hint for the specified \a row or -1 if-
3018 there is no model.-
3019-
3020 The returned height is calculated using the size hints of the-
3021 given \a row's items, i.e. the returned value is the maximum-
3022 height among the items. Note that to control the height of a row,-
3023 you must reimplement the QAbstractItemDelegate::sizeHint()-
3024 function.-
3025-
3026 This function is used in views with a vertical header to find the-
3027 size hint for a header section based on the contents of the given-
3028 \a row.-
3029-
3030 \sa sizeHintForColumn()-
3031*/-
3032int QAbstractItemView::sizeHintForRow(int row) const-
3033{-
3034 Q_D(const QAbstractItemView);-
3035-
3036 if (row < 0 || row >= d->model->rowCount(d->root))
row < 0Description
TRUEnever evaluated
FALSEnever evaluated
row >= d->mode...Count(d->root)Description
TRUEnever evaluated
FALSEnever evaluated
0
3037 return -1;
never executed: return -1;
0
3038-
3039 ensurePolished();-
3040-
3041 QStyleOptionViewItem option = d->viewOptionsV1();-
3042 int height = 0;-
3043 int colCount = d->model->columnCount(d->root);-
3044 for (int c = 0; c < colCount; ++c) {
c < colCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3045 const QModelIndex index = d->model->index(row, c, d->root);-
3046 if (QWidget *editor = d->editorForIndex(index).widget.data())
QWidget *edito....widget.data()Description
TRUEnever evaluated
FALSEnever evaluated
0
3047 height = qMax(height, editor->height());
never executed: height = qMax(height, editor->height());
0
3048 if (const QAbstractItemDelegate *delegate = d->delegateForIndex(index))
const QAbstrac...orIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
3049 height = qMax(height, delegate->sizeHint(option, index).height());
never executed: height = qMax(height, delegate->sizeHint(option, index).height());
0
3050 }
never executed: end of block
0
3051 return height;
never executed: return height;
0
3052}-
3053-
3054/*!-
3055 Returns the width size hint for the specified \a column or -1 if there is no model.-
3056-
3057 This function is used in views with a horizontal header to find the size hint for-
3058 a header section based on the contents of the given \a column.-
3059-
3060 \sa sizeHintForRow()-
3061*/-
3062int QAbstractItemView::sizeHintForColumn(int column) const-
3063{-
3064 Q_D(const QAbstractItemView);-
3065-
3066 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
3067 return -1;
never executed: return -1;
0
3068-
3069 ensurePolished();-
3070-
3071 QStyleOptionViewItem option = d->viewOptionsV1();-
3072 int width = 0;-
3073 int rows = d->model->rowCount(d->root);-
3074 for (int r = 0; r < rows; ++r) {
r < rowsDescription
TRUEnever evaluated
FALSEnever evaluated
0
3075 const QModelIndex index = d->model->index(r, column, d->root);-
3076 if (QWidget *editor = d->editorForIndex(index).widget.data())
QWidget *edito....widget.data()Description
TRUEnever evaluated
FALSEnever evaluated
0
3077 width = qMax(width, editor->sizeHint().width());
never executed: width = qMax(width, editor->sizeHint().width());
0
3078 if (const QAbstractItemDelegate *delegate = d->delegateForIndex(index))
const QAbstrac...orIndex(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
3079 width = qMax(width, delegate->sizeHint(option, index).width());
never executed: width = qMax(width, delegate->sizeHint(option, index).width());
0
3080 }
never executed: end of block
0
3081 return width;
never executed: return width;
0
3082}-
3083-
3084/*!-
3085 Opens a persistent editor on the item at the given \a index.-
3086 If no editor exists, the delegate will create a new editor.-
3087-
3088 \sa closePersistentEditor()-
3089*/-
3090void QAbstractItemView::openPersistentEditor(const QModelIndex &index)-
3091{-
3092 Q_D(QAbstractItemView);-
3093 QStyleOptionViewItem options = d->viewOptionsV1();-
3094 options.rect = visualRect(index);-
3095 options.state |= (index == currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
index == currentIndex()Description
TRUEnever evaluated
FALSEnever evaluated
0
3096-
3097 QWidget *editor = d->editor(index, options);-
3098 if (editor) {
editorDescription
TRUEnever evaluated
FALSEnever evaluated
0
3099 editor->show();-
3100 d->persistent.insert(editor);-
3101 }
never executed: end of block
0
3102}
never executed: end of block
0
3103-
3104/*!-
3105 Closes the persistent editor for the item at the given \a index.-
3106-
3107 \sa openPersistentEditor()-
3108*/-
3109void QAbstractItemView::closePersistentEditor(const QModelIndex &index)-
3110{-
3111 Q_D(QAbstractItemView);-
3112 if (QWidget *editor = d->editorForIndex(index).widget.data()) {
QWidget *edito....widget.data()Description
TRUEnever evaluated
FALSEnever evaluated
0
3113 if (index == selectionModel()->currentIndex())
index == selec...currentIndex()Description
TRUEnever evaluated
FALSEnever evaluated
0
3114 closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
never executed: closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
0
3115 d->persistent.remove(editor);-
3116 d->removeEditor(editor);-
3117 d->releaseEditor(editor, index);-
3118 }
never executed: end of block
0
3119}
never executed: end of block
0
3120-
3121/*!-
3122 \since 4.1-
3123-
3124 Sets the given \a widget on the item at the given \a index, passing the-
3125 ownership of the widget to the viewport.-
3126-
3127 If \a index is invalid (e.g., if you pass the root index), this function-
3128 will do nothing.-
3129-
3130 The given \a widget's \l{QWidget}{autoFillBackground} property must be set-
3131 to true, otherwise the widget's background will be transparent, showing-
3132 both the model data and the item at the given \a index.-
3133-
3134 If index widget A is replaced with index widget B, index widget A will be-
3135 deleted. For example, in the code snippet below, the QLineEdit object will-
3136 be deleted.-
3137-
3138 \snippet code/src_gui_itemviews_qabstractitemview.cpp 1-
3139-
3140 This function should only be used to display static content within the-
3141 visible area corresponding to an item of data. If you want to display-
3142 custom dynamic content or implement a custom editor widget, subclass-
3143 QItemDelegate instead.-
3144-
3145 \sa {Delegate Classes}-
3146*/-
3147void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget)-
3148{-
3149 Q_D(QAbstractItemView);-
3150 if (!d->isIndexValid(index))
!d->isIndexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
3151 return;
never executed: return;
0
3152 if (indexWidget(index) == widget)
indexWidget(index) == widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
3153 return;
never executed: return;
0
3154 if (QWidget *oldWidget = indexWidget(index)) {
QWidget *oldWi...xWidget(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
3155 d->persistent.remove(oldWidget);-
3156 d->removeEditor(oldWidget);-
3157 oldWidget->deleteLater();-
3158 }
never executed: end of block
0
3159 if (widget) {
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
3160 widget->setParent(viewport());-
3161 d->persistent.insert(widget);-
3162 d->addEditor(index, widget, true);-
3163 widget->show();-
3164 dataChanged(index, index); // update the geometry-
3165 if (!d->delayedPendingLayout)
!d->delayedPendingLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
3166 widget->setGeometry(visualRect(index));
never executed: widget->setGeometry(visualRect(index));
0
3167 }
never executed: end of block
0
3168}
never executed: end of block
0
3169-
3170/*!-
3171 \since 4.1-
3172-
3173 Returns the widget for the item at the given \a index.-
3174*/-
3175QWidget* QAbstractItemView::indexWidget(const QModelIndex &index) const-
3176{-
3177 Q_D(const QAbstractItemView);-
3178 if (d->isIndexValid(index))
d->isIndexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
3179 if (QWidget *editor = d->editorForIndex(index).widget.data())
QWidget *edito....widget.data()Description
TRUEnever evaluated
FALSEnever evaluated
0
3180 return editor;
never executed: return editor;
0
3181-
3182 return 0;
never executed: return 0;
0
3183}-
3184-
3185/*!-
3186 \since 4.1-
3187-
3188 Scrolls the view to the top.-
3189-
3190 \sa scrollTo(), scrollToBottom()-
3191*/-
3192void QAbstractItemView::scrollToTop()-
3193{-
3194 verticalScrollBar()->setValue(verticalScrollBar()->minimum());-
3195}
never executed: end of block
0
3196-
3197/*!-
3198 \since 4.1-
3199-
3200 Scrolls the view to the bottom.-
3201-
3202 \sa scrollTo(), scrollToTop()-
3203*/-
3204void QAbstractItemView::scrollToBottom()-
3205{-
3206 Q_D(QAbstractItemView);-
3207 if (d->delayedPendingLayout) {
d->delayedPendingLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
3208 d->executePostedLayout();-
3209 updateGeometries();-
3210 }
never executed: end of block
0
3211 verticalScrollBar()->setValue(verticalScrollBar()->maximum());-
3212}
never executed: end of block
0
3213-
3214/*!-
3215 \since 4.3-
3216-
3217 Updates the area occupied by the given \a index.-
3218-
3219*/-
3220void QAbstractItemView::update(const QModelIndex &index)-
3221{-
3222 Q_D(QAbstractItemView);-
3223 if (index.isValid()) {
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3224 const QRect rect = visualRect(index);-
3225 //this test is important for peformance reason-
3226 //For example in dataChanged we simply update all the cells without checking-
3227 //it can be a major bottleneck to update rects that aren't even part of the viewport-
3228 if (d->viewport->rect().intersects(rect))
d->viewport->r...tersects(rect)Description
TRUEnever evaluated
FALSEnever evaluated
0
3229 d->viewport->update(rect);
never executed: d->viewport->update(rect);
0
3230 }
never executed: end of block
0
3231}
never executed: end of block
0
3232-
3233/*!-
3234 This slot is called when items with the given \a roles are changed in the-
3235 model. The changed items are those from \a topLeft to \a bottomRight-
3236 inclusive. If just one item is changed \a topLeft == \a bottomRight.-
3237-
3238 The \a roles which have been changed can either be an empty container (meaning everything-
3239 has changed), or a non-empty container with the subset of roles which have changed.-
3240*/-
3241void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)-
3242{-
3243 Q_UNUSED(roles);-
3244 // Single item changed-
3245 Q_D(QAbstractItemView);-
3246 if (topLeft == bottomRight && topLeft.isValid()) {
topLeft == bottomRightDescription
TRUEnever evaluated
FALSEnever evaluated
topLeft.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3247 const QEditorInfo &editorInfo = d->editorForIndex(topLeft);-
3248 //we don't update the edit data if it is static-
3249 if (!editorInfo.isStatic && editorInfo.widget) {
!editorInfo.isStaticDescription
TRUEnever evaluated
FALSEnever evaluated
editorInfo.widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
3250 QAbstractItemDelegate *delegate = d->delegateForIndex(topLeft);-
3251 if (delegate) {
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
3252 delegate->setEditorData(editorInfo.widget.data(), topLeft);-
3253 }
never executed: end of block
0
3254 }
never executed: end of block
0
3255 if (isVisible() && !d->delayedPendingLayout) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!d->delayedPendingLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
3256 // otherwise the items will be update later anyway-
3257 update(topLeft);-
3258 }
never executed: end of block
0
3259 } else {
never executed: end of block
0
3260 d->updateEditorData(topLeft, bottomRight);-
3261 if (isVisible() && !d->delayedPendingLayout)
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!d->delayedPendingLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
3262 d->viewport->update();
never executed: d->viewport->update();
0
3263 }
never executed: end of block
0
3264-
3265#ifndef QT_NO_ACCESSIBILITY-
3266 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3267 QAccessibleTableModelChangeEvent accessibleEvent(this, QAccessibleTableModelChangeEvent::DataChanged);-
3268 accessibleEvent.setFirstRow(topLeft.row());-
3269 accessibleEvent.setFirstColumn(topLeft.column());-
3270 accessibleEvent.setLastRow(bottomRight.row());-
3271 accessibleEvent.setLastColumn(bottomRight.column());-
3272 QAccessible::updateAccessibility(&accessibleEvent);-
3273 }
never executed: end of block
0
3274#endif-
3275 d->updateGeometry();-
3276}
never executed: end of block
0
3277-
3278/*!-
3279 This slot is called when rows are inserted. The new rows are those-
3280 under the given \a parent from \a start to \a end inclusive. The-
3281 base class implementation calls fetchMore() on the model to check-
3282 for more data.-
3283-
3284 \sa rowsAboutToBeRemoved()-
3285*/-
3286void QAbstractItemView::rowsInserted(const QModelIndex &, int, int)-
3287{-
3288 if (!isVisible())
!isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3289 d_func()->fetchMoreTimer.start(0, this); //fetch more later
never executed: d_func()->fetchMoreTimer.start(0, this);
0
3290 else-
3291 updateEditorGeometries();
never executed: updateEditorGeometries();
0
3292}-
3293-
3294/*!-
3295 This slot is called when rows are about to be removed. The deleted rows are-
3296 those under the given \a parent from \a start to \a end inclusive.-
3297-
3298 \sa rowsInserted()-
3299*/-
3300void QAbstractItemView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)-
3301{-
3302 Q_D(QAbstractItemView);-
3303-
3304 setState(CollapsingState);-
3305-
3306 // Ensure one selected item in single selection mode.-
3307 QModelIndex current = currentIndex();-
3308 if (d->selectionMode == SingleSelection
d->selectionMo...ingleSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3309 && current.isValid()
current.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3310 && current.row() >= start
current.row() >= startDescription
TRUEnever evaluated
FALSEnever evaluated
0
3311 && current.row() <= end
current.row() <= endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3312 && current.parent() == parent) {
current.parent() == parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
3313 int totalToRemove = end - start + 1;-
3314 if (d->model->rowCount(parent) <= totalToRemove) { // no more children
d->model->rowC... totalToRemoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
3315 QModelIndex index = parent;-
3316 while (index != d->root && !d->isIndexEnabled(index))
index != d->rootDescription
TRUEnever evaluated
FALSEnever evaluated
!d->isIndexEnabled(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
3317 index = index.parent();
never executed: index = index.parent();
0
3318 if (index != d->root)
index != d->rootDescription
TRUEnever evaluated
FALSEnever evaluated
0
3319 setCurrentIndex(index);
never executed: setCurrentIndex(index);
0
3320 } else {
never executed: end of block
0
3321 int row = end + 1;-
3322 QModelIndex next;-
3323 do { // find the next visible and enabled item-
3324 next = d->model->index(row++, current.column(), current.parent());-
3325 } while (next.isValid() && (isIndexHidden(next) || !d->isIndexEnabled(next)));
never executed: end of block
next.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
isIndexHidden(next)Description
TRUEnever evaluated
FALSEnever evaluated
!d->isIndexEnabled(next)Description
TRUEnever evaluated
FALSEnever evaluated
0
3326 if (row > d->model->rowCount(parent)) {
row > d->model...wCount(parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
3327 row = start - 1;-
3328 do { // find the previous visible and enabled item-
3329 next = d->model->index(row--, current.column(), current.parent());-
3330 } while (next.isValid() && (isIndexHidden(next) || !d->isIndexEnabled(next)));
never executed: end of block
next.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
isIndexHidden(next)Description
TRUEnever evaluated
FALSEnever evaluated
!d->isIndexEnabled(next)Description
TRUEnever evaluated
FALSEnever evaluated
0
3331 }
never executed: end of block
0
3332 setCurrentIndex(next);-
3333 }
never executed: end of block
0
3334 }-
3335-
3336 // Remove all affected editors; this is more efficient than waiting for updateGeometries() to clean out editors for invalid indexes-
3337 QEditorIndexHash::iterator i = d->editorIndexHash.begin();-
3338 while (i != d->editorIndexHash.end()) {
i != d->editorIndexHash.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
3339 const QModelIndex index = i.value();-
3340 if (index.row() >= start && index.row() <= end && d->model->parent(index) == parent) {
index.row() >= startDescription
TRUEnever evaluated
FALSEnever evaluated
index.row() <= endDescription
TRUEnever evaluated
FALSEnever evaluated
d->model->pare...dex) == parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
3341 QWidget *editor = i.key();-
3342 QEditorInfo info = d->indexEditorHash.take(index);-
3343 i = d->editorIndexHash.erase(i);-
3344 if (info.widget)
info.widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
3345 d->releaseEditor(editor, index);
never executed: d->releaseEditor(editor, index);
0
3346 } else {
never executed: end of block
0
3347 ++i;-
3348 }
never executed: end of block
0
3349 }-
3350}
never executed: end of block
0
3351-
3352/*!-
3353 \internal-
3354-
3355 This slot is called when rows have been removed. The deleted-
3356 rows are those under the given \a parent from \a start to \a end-
3357 inclusive.-
3358*/-
3359void QAbstractItemViewPrivate::_q_rowsRemoved(const QModelIndex &index, int start, int end)-
3360{-
3361 Q_UNUSED(index)-
3362 Q_UNUSED(start)-
3363 Q_UNUSED(end)-
3364-
3365 Q_Q(QAbstractItemView);-
3366 if (q->isVisible())
q->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3367 q->updateEditorGeometries();
never executed: q->updateEditorGeometries();
0
3368 q->setState(QAbstractItemView::NoState);-
3369#ifndef QT_NO_ACCESSIBILITY-
3370 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3371 QAccessibleTableModelChangeEvent accessibleEvent(q, QAccessibleTableModelChangeEvent::RowsRemoved);-
3372 accessibleEvent.setFirstRow(start);-
3373 accessibleEvent.setLastRow(end);-
3374 QAccessible::updateAccessibility(&accessibleEvent);-
3375 }
never executed: end of block
0
3376#endif-
3377 updateGeometry();-
3378}
never executed: end of block
0
3379-
3380/*!-
3381 \internal-
3382-
3383 This slot is called when columns are about to be removed. The deleted-
3384 columns are those under the given \a parent from \a start to \a end-
3385 inclusive.-
3386*/-
3387void QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)-
3388{-
3389 Q_Q(QAbstractItemView);-
3390-
3391 q->setState(QAbstractItemView::CollapsingState);-
3392-
3393 // Ensure one selected item in single selection mode.-
3394 QModelIndex current = q->currentIndex();-
3395 if (current.isValid()
current.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3396 && selectionMode == QAbstractItemView::SingleSelection
selectionMode ...ingleSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3397 && current.column() >= start
current.column() >= startDescription
TRUEnever evaluated
FALSEnever evaluated
0
3398 && current.column() <= end) {
current.column() <= endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3399 int totalToRemove = end - start + 1;-
3400 if (model->columnCount(parent) < totalToRemove) { // no more columns
model->columnC... totalToRemoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
3401 QModelIndex index = parent;-
3402 while (index.isValid() && !isIndexEnabled(index))
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
!isIndexEnabled(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
3403 index = index.parent();
never executed: index = index.parent();
0
3404 if (index.isValid())
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3405 q->setCurrentIndex(index);
never executed: q->setCurrentIndex(index);
0
3406 } else {
never executed: end of block
0
3407 int column = end;-
3408 QModelIndex next;-
3409 do { // find the next visible and enabled item-
3410 next = model->index(current.row(), column++, current.parent());-
3411 } while (next.isValid() && (q->isIndexHidden(next) || !isIndexEnabled(next)));
never executed: end of block
next.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
q->isIndexHidden(next)Description
TRUEnever evaluated
FALSEnever evaluated
!isIndexEnabled(next)Description
TRUEnever evaluated
FALSEnever evaluated
0
3412 q->setCurrentIndex(next);-
3413 }
never executed: end of block
0
3414 }-
3415-
3416 // Remove all affected editors; this is more efficient than waiting for updateGeometries() to clean out editors for invalid indexes-
3417 QEditorIndexHash::iterator it = editorIndexHash.begin();-
3418 while (it != editorIndexHash.end()) {
it != editorIndexHash.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
3419 QModelIndex index = it.value();-
3420 if (index.column() <= start && index.column() >= end && model->parent(index) == parent) {
index.column() <= startDescription
TRUEnever evaluated
FALSEnever evaluated
index.column() >= endDescription
TRUEnever evaluated
FALSEnever evaluated
model->parent(index) == parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
3421 QWidget *editor = it.key();-
3422 QEditorInfo info = indexEditorHash.take(it.value());-
3423 it = editorIndexHash.erase(it);-
3424 if (info.widget)
info.widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
3425 releaseEditor(editor, index);
never executed: releaseEditor(editor, index);
0
3426 } else {
never executed: end of block
0
3427 ++it;-
3428 }
never executed: end of block
0
3429 }-
3430-
3431}
never executed: end of block
0
3432-
3433/*!-
3434 \internal-
3435-
3436 This slot is called when columns have been removed. The deleted-
3437 rows are those under the given \a parent from \a start to \a end-
3438 inclusive.-
3439*/-
3440void QAbstractItemViewPrivate::_q_columnsRemoved(const QModelIndex &index, int start, int end)-
3441{-
3442 Q_UNUSED(index)-
3443 Q_UNUSED(start)-
3444 Q_UNUSED(end)-
3445-
3446 Q_Q(QAbstractItemView);-
3447 if (q->isVisible())
q->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3448 q->updateEditorGeometries();
never executed: q->updateEditorGeometries();
0
3449 q->setState(QAbstractItemView::NoState);-
3450#ifndef QT_NO_ACCESSIBILITY-
3451 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3452 QAccessibleTableModelChangeEvent accessibleEvent(q, QAccessibleTableModelChangeEvent::ColumnsRemoved);-
3453 accessibleEvent.setFirstColumn(start);-
3454 accessibleEvent.setLastColumn(end);-
3455 QAccessible::updateAccessibility(&accessibleEvent);-
3456 }
never executed: end of block
0
3457#endif-
3458 updateGeometry();-
3459}
never executed: end of block
0
3460-
3461-
3462/*!-
3463 \internal-
3464-
3465 This slot is called when rows have been inserted.-
3466*/-
3467void QAbstractItemViewPrivate::_q_rowsInserted(const QModelIndex &index, int start, int end)-
3468{-
3469 Q_UNUSED(index)-
3470 Q_UNUSED(start)-
3471 Q_UNUSED(end)-
3472-
3473#ifndef QT_NO_ACCESSIBILITY-
3474 Q_Q(QAbstractItemView);-
3475 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3476 QAccessibleTableModelChangeEvent accessibleEvent(q, QAccessibleTableModelChangeEvent::RowsInserted);-
3477 accessibleEvent.setFirstRow(start);-
3478 accessibleEvent.setLastRow(end);-
3479 QAccessible::updateAccessibility(&accessibleEvent);-
3480 }
never executed: end of block
0
3481#endif-
3482 updateGeometry();-
3483}
never executed: end of block
0
3484-
3485/*!-
3486 \internal-
3487-
3488 This slot is called when columns have been inserted.-
3489*/-
3490void QAbstractItemViewPrivate::_q_columnsInserted(const QModelIndex &index, int start, int end)-
3491{-
3492 Q_UNUSED(index)-
3493 Q_UNUSED(start)-
3494 Q_UNUSED(end)-
3495-
3496 Q_Q(QAbstractItemView);-
3497 if (q->isVisible())
q->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3498 q->updateEditorGeometries();
never executed: q->updateEditorGeometries();
0
3499#ifndef QT_NO_ACCESSIBILITY-
3500 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3501 QAccessibleTableModelChangeEvent accessibleEvent(q, QAccessibleTableModelChangeEvent::ColumnsInserted);-
3502 accessibleEvent.setFirstColumn(start);-
3503 accessibleEvent.setLastColumn(end);-
3504 QAccessible::updateAccessibility(&accessibleEvent);-
3505 }
never executed: end of block
0
3506#endif-
3507 updateGeometry();-
3508}
never executed: end of block
0
3509-
3510/*!-
3511 \internal-
3512*/-
3513void QAbstractItemViewPrivate::_q_modelDestroyed()-
3514{-
3515 model = QAbstractItemModelPrivate::staticEmptyModel();-
3516 doDelayedReset();-
3517}
never executed: end of block
0
3518-
3519/*!-
3520 \internal-
3521-
3522 This slot is called when the layout is changed.-
3523*/-
3524void QAbstractItemViewPrivate::_q_layoutChanged()-
3525{-
3526 doDelayedItemsLayout();-
3527#ifndef QT_NO_ACCESSIBILITY-
3528 Q_Q(QAbstractItemView);-
3529 if (QAccessible::isActive()) {
QAccessible::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3530 QAccessibleTableModelChangeEvent accessibleEvent(q, QAccessibleTableModelChangeEvent::ModelReset);-
3531 QAccessible::updateAccessibility(&accessibleEvent);-
3532 }
never executed: end of block
0
3533#endif-
3534}
never executed: end of block
0
3535-
3536void QAbstractItemViewPrivate::_q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)-
3537{-
3538 _q_layoutChanged();-
3539}
never executed: end of block
0
3540-
3541void QAbstractItemViewPrivate::_q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)-
3542{-
3543 _q_layoutChanged();-
3544}
never executed: end of block
0
3545-
3546/*!-
3547 This slot is called when the selection is changed. The previous-
3548 selection (which may be empty), is specified by \a deselected, and the-
3549 new selection by \a selected.-
3550-
3551 \sa setSelection()-
3552*/-
3553void QAbstractItemView::selectionChanged(const QItemSelection &selected,-
3554 const QItemSelection &deselected)-
3555{-
3556 Q_D(QAbstractItemView);-
3557 if (isVisible() && updatesEnabled()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
updatesEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
3558 d->viewport->update(visualRegionForSelection(deselected) | visualRegionForSelection(selected));-
3559 }
never executed: end of block
0
3560}
never executed: end of block
0
3561-
3562/*!-
3563 This slot is called when a new item becomes the current item.-
3564 The previous current item is specified by the \a previous index, and the new-
3565 item by the \a current index.-
3566-
3567 If you want to know about changes to items see the-
3568 dataChanged() signal.-
3569*/-
3570void QAbstractItemView::currentChanged(const QModelIndex &current, const QModelIndex &previous)-
3571{-
3572 Q_D(QAbstractItemView);-
3573 Q_ASSERT(d->model);-
3574-
3575 if (previous.isValid()) {
previous.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3576 QModelIndex buddy = d->model->buddy(previous);-
3577 QWidget *editor = d->editorForIndex(buddy).widget.data();-
3578 if (editor && !d->persistent.contains(editor)) {
editorDescription
TRUEnever evaluated
FALSEnever evaluated
!d->persistent...ntains(editor)Description
TRUEnever evaluated
FALSEnever evaluated
0
3579 commitData(editor);-
3580 if (current.row() != previous.row())
current.row() ...previous.row()Description
TRUEnever evaluated
FALSEnever evaluated
0
3581 closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
never executed: closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
0
3582 else-
3583 closeEditor(editor, QAbstractItemDelegate::NoHint);
never executed: closeEditor(editor, QAbstractItemDelegate::NoHint);
0
3584 }-
3585 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3586 update(previous);-
3587 }
never executed: end of block
0
3588 }
never executed: end of block
0
3589-
3590 if (current.isValid() && !d->autoScrollTimer.isActive()) {
current.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
!d->autoScrollTimer.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3591 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3592 if (d->autoScroll)
d->autoScrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
3593 scrollTo(current);
never executed: scrollTo(current);
0
3594 update(current);-
3595 edit(current, CurrentChanged, 0);-
3596 if (current.row() == (d->model->rowCount(d->root) - 1))
current.row() ...(d->root) - 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
3597 d->fetchMore();
never executed: d->fetchMore();
0
3598 } else {
never executed: end of block
0
3599 d->shouldScrollToCurrentOnShow = d->autoScroll;-
3600 }
never executed: end of block
0
3601 }-
3602}
never executed: end of block
0
3603-
3604#ifndef QT_NO_DRAGANDDROP-
3605/*!-
3606 Starts a drag by calling drag->exec() using the given \a supportedActions.-
3607*/-
3608void QAbstractItemView::startDrag(Qt::DropActions supportedActions)-
3609{-
3610 Q_D(QAbstractItemView);-
3611 QModelIndexList indexes = d->selectedDraggableIndexes();-
3612 if (indexes.count() > 0) {
indexes.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3613 QMimeData *data = d->model->mimeData(indexes);-
3614 if (!data)
!dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3615 return;
never executed: return;
0
3616 QRect rect;-
3617 QPixmap pixmap = d->renderToPixmap(indexes, &rect);-
3618 rect.adjust(horizontalOffset(), verticalOffset(), 0, 0);-
3619 QDrag *drag = new QDrag(this);-
3620 drag->setPixmap(pixmap);-
3621 drag->setMimeData(data);-
3622 drag->setHotSpot(d->pressedPosition - rect.topLeft());-
3623 Qt::DropAction defaultDropAction = Qt::IgnoreAction;-
3624 if (d->defaultDropAction != Qt::IgnoreAction && (supportedActions & d->defaultDropAction))
d->defaultDrop...::IgnoreActionDescription
TRUEnever evaluated
FALSEnever evaluated
(supportedActi...ultDropAction)Description
TRUEnever evaluated
FALSEnever evaluated
0
3625 defaultDropAction = d->defaultDropAction;
never executed: defaultDropAction = d->defaultDropAction;
0
3626 else if (supportedActions & Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove)
supportedActio...Qt::CopyActionDescription
TRUEnever evaluated
FALSEnever evaluated
dragDropMode()...::InternalMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
3627 defaultDropAction = Qt::CopyAction;
never executed: defaultDropAction = Qt::CopyAction;
0
3628 if (drag->exec(supportedActions, defaultDropAction) == Qt::MoveAction)
drag->exec(sup...Qt::MoveActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
3629 d->clearOrRemove();
never executed: d->clearOrRemove();
0
3630 // Reset the drop indicator-
3631 d->dropIndicatorRect = QRect();-
3632 d->dropIndicatorPosition = OnItem;-
3633 }
never executed: end of block
0
3634}
never executed: end of block
0
3635#endif // QT_NO_DRAGANDDROP-
3636-
3637/*!-
3638 Returns a QStyleOptionViewItem structure populated with the view's-
3639 palette, font, state, alignments etc.-
3640*/-
3641QStyleOptionViewItem QAbstractItemView::viewOptions() const-
3642{-
3643 Q_D(const QAbstractItemView);-
3644 QStyleOptionViewItem option;-
3645 option.init(this);-
3646 option.state &= ~QStyle::State_MouseOver;-
3647 option.font = font();-
3648-
3649#ifndef Q_DEAD_CODE_FROM_QT4_MAC-
3650 // On mac the focus appearance follows window activation-
3651 // not widget activation-
3652 if (!hasFocus())
!hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
3653 option.state &= ~QStyle::State_Active;
never executed: option.state &= ~QStyle::State_Active;
0
3654#endif-
3655-
3656 option.state &= ~QStyle::State_HasFocus;-
3657 if (d->iconSize.isValid()) {
d->iconSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3658 option.decorationSize = d->iconSize;-
3659 } else {
never executed: end of block
0
3660 int pm = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);-
3661 option.decorationSize = QSize(pm, pm);-
3662 }
never executed: end of block
0
3663 option.decorationPosition = QStyleOptionViewItem::Left;-
3664 option.decorationAlignment = Qt::AlignCenter;-
3665 option.displayAlignment = Qt::AlignLeft|Qt::AlignVCenter;-
3666 option.textElideMode = d->textElideMode;-
3667 option.rect = QRect();-
3668 option.showDecorationSelected = style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, this);-
3669 if (d->wrapItemText)
d->wrapItemTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
3670 option.features = QStyleOptionViewItem::WrapText;
never executed: option.features = QStyleOptionViewItem::WrapText;
0
3671 option.locale = locale();-
3672 option.locale.setNumberOptions(QLocale::OmitGroupSeparator);-
3673 option.widget = this;-
3674 return option;
never executed: return option;
0
3675}-
3676-
3677QStyleOptionViewItem QAbstractItemViewPrivate::viewOptionsV1() const-
3678{-
3679 Q_Q(const QAbstractItemView);-
3680 return q->viewOptions();
never executed: return q->viewOptions();
0
3681}-
3682-
3683/*!-
3684 Returns the item view's state.-
3685-
3686 \sa setState()-
3687*/-
3688QAbstractItemView::State QAbstractItemView::state() const-
3689{-
3690 Q_D(const QAbstractItemView);-
3691 return d->state;
never executed: return d->state;
0
3692}-
3693-
3694/*!-
3695 Sets the item view's state to the given \a state.-
3696-
3697 \sa state()-
3698*/-
3699void QAbstractItemView::setState(State state)-
3700{-
3701 Q_D(QAbstractItemView);-
3702 d->state = state;-
3703}
never executed: end of block
0
3704-
3705/*!-
3706 Schedules a layout of the items in the view to be executed when the-
3707 event processing starts.-
3708-
3709 Even if scheduleDelayedItemsLayout() is called multiple times before-
3710 events are processed, the view will only do the layout once.-
3711-
3712 \sa executeDelayedItemsLayout()-
3713*/-
3714void QAbstractItemView::scheduleDelayedItemsLayout()-
3715{-
3716 Q_D(QAbstractItemView);-
3717 d->doDelayedItemsLayout();-
3718}
never executed: end of block
0
3719-
3720/*!-
3721 Executes the scheduled layouts without waiting for the event processing-
3722 to begin.-
3723-
3724 \sa scheduleDelayedItemsLayout()-
3725*/-
3726void QAbstractItemView::executeDelayedItemsLayout()-
3727{-
3728 Q_D(QAbstractItemView);-
3729 d->executePostedLayout();-
3730}
never executed: end of block
0
3731-
3732/*!-
3733 \since 4.1-
3734-
3735 Marks the given \a region as dirty and schedules it to be updated.-
3736 You only need to call this function if you are implementing-
3737 your own view subclass.-
3738-
3739 \sa scrollDirtyRegion(), dirtyRegionOffset()-
3740*/-
3741-
3742void QAbstractItemView::setDirtyRegion(const QRegion &region)-
3743{-
3744 Q_D(QAbstractItemView);-
3745 d->setDirtyRegion(region);-
3746}
never executed: end of block
0
3747-
3748/*!-
3749 Prepares the view for scrolling by (\a{dx},\a{dy}) pixels by moving the dirty regions in the-
3750 opposite direction. You only need to call this function if you are implementing a scrolling-
3751 viewport in your view subclass.-
3752-
3753 If you implement scrollContentsBy() in a subclass of QAbstractItemView, call this function-
3754 before you call QWidget::scroll() on the viewport. Alternatively, just call update().-
3755-
3756 \sa scrollContentsBy(), dirtyRegionOffset(), setDirtyRegion()-
3757*/-
3758void QAbstractItemView::scrollDirtyRegion(int dx, int dy)-
3759{-
3760 Q_D(QAbstractItemView);-
3761 d->scrollDirtyRegion(dx, dy);-
3762}
never executed: end of block
0
3763-
3764/*!-
3765 Returns the offset of the dirty regions in the view.-
3766-
3767 If you use scrollDirtyRegion() and implement a paintEvent() in a subclass of-
3768 QAbstractItemView, you should translate the area given by the paint event with-
3769 the offset returned from this function.-
3770-
3771 \sa scrollDirtyRegion(), setDirtyRegion()-
3772*/-
3773QPoint QAbstractItemView::dirtyRegionOffset() const-
3774{-
3775 Q_D(const QAbstractItemView);-
3776 return d->scrollDelayOffset;
never executed: return d->scrollDelayOffset;
0
3777}-
3778-
3779/*!-
3780 \internal-
3781*/-
3782void QAbstractItemView::startAutoScroll()-
3783{-
3784 d_func()->startAutoScroll();-
3785}
never executed: end of block
0
3786-
3787/*!-
3788 \internal-
3789*/-
3790void QAbstractItemView::stopAutoScroll()-
3791{-
3792 d_func()->stopAutoScroll();-
3793}
never executed: end of block
0
3794-
3795/*!-
3796 \internal-
3797*/-
3798void QAbstractItemView::doAutoScroll()-
3799{-
3800 // find how much we should scroll with-
3801 Q_D(QAbstractItemView);-
3802 QScrollBar *verticalScroll = verticalScrollBar();-
3803 QScrollBar *horizontalScroll = horizontalScrollBar();-
3804-
3805 // QHeaderView does not (normally) have scrollbars-
3806 // It needs to use its parents scroll instead-
3807 QHeaderView *hv = qobject_cast<QHeaderView*>(this);-
3808 if (hv) {
hvDescription
TRUEnever evaluated
FALSEnever evaluated
0
3809 QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea*>(parentWidget());-
3810 if (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
3811 if (hv->orientation() == Qt::Horizontal) {
hv->orientatio...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
3812 if (!hv->horizontalScrollBar() || !hv->horizontalScrollBar()->isVisible())
!hv->horizontalScrollBar()Description
TRUEnever evaluated
FALSEnever evaluated
!hv->horizonta...)->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3813 horizontalScroll = parent->horizontalScrollBar();
never executed: horizontalScroll = parent->horizontalScrollBar();
0
3814 } else {
never executed: end of block
0
3815 if (!hv->verticalScrollBar() || !hv->verticalScrollBar()->isVisible())
!hv->verticalScrollBar()Description
TRUEnever evaluated
FALSEnever evaluated
!hv->verticalS...)->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3816 verticalScroll = parent->verticalScrollBar();
never executed: verticalScroll = parent->verticalScrollBar();
0
3817 }
never executed: end of block
0
3818 }-
3819 }
never executed: end of block
0
3820-
3821 int verticalStep = verticalScroll->pageStep();-
3822 int horizontalStep = horizontalScroll->pageStep();-
3823 if (d->autoScrollCount < qMax(verticalStep, horizontalStep))
d->autoScrollC...orizontalStep)Description
TRUEnever evaluated
FALSEnever evaluated
0
3824 ++d->autoScrollCount;
never executed: ++d->autoScrollCount;
0
3825-
3826 int margin = d->autoScrollMargin;-
3827 int verticalValue = verticalScroll->value();-
3828 int horizontalValue = horizontalScroll->value();-
3829-
3830 QPoint pos = d->viewport->mapFromGlobal(QCursor::pos());-
3831 QRect area = QWidgetPrivate::get(d->viewport)->clipRect();-
3832-
3833 // do the scrolling if we are in the scroll margins-
3834 if (pos.y() - area.top() < margin)
pos.y() - area.top() < marginDescription
TRUEnever evaluated
FALSEnever evaluated
0
3835 verticalScroll->setValue(verticalValue - d->autoScrollCount);
never executed: verticalScroll->setValue(verticalValue - d->autoScrollCount);
0
3836 else if (area.bottom() - pos.y() < margin)
area.bottom() ...s.y() < marginDescription
TRUEnever evaluated
FALSEnever evaluated
0
3837 verticalScroll->setValue(verticalValue + d->autoScrollCount);
never executed: verticalScroll->setValue(verticalValue + d->autoScrollCount);
0
3838 if (pos.x() - area.left() < margin)
pos.x() - area.left() < marginDescription
TRUEnever evaluated
FALSEnever evaluated
0
3839 horizontalScroll->setValue(horizontalValue - d->autoScrollCount);
never executed: horizontalScroll->setValue(horizontalValue - d->autoScrollCount);
0
3840 else if (area.right() - pos.x() < margin)
area.right() -...s.x() < marginDescription
TRUEnever evaluated
FALSEnever evaluated
0
3841 horizontalScroll->setValue(horizontalValue + d->autoScrollCount);
never executed: horizontalScroll->setValue(horizontalValue + d->autoScrollCount);
0
3842 // if nothing changed, stop scrolling-
3843 bool verticalUnchanged = (verticalValue == verticalScroll->value());-
3844 bool horizontalUnchanged = (horizontalValue == horizontalScroll->value());-
3845 if (verticalUnchanged && horizontalUnchanged) {
verticalUnchangedDescription
TRUEnever evaluated
FALSEnever evaluated
horizontalUnchangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3846 stopAutoScroll();-
3847 } else {
never executed: end of block
0
3848#ifndef QT_NO_DRAGANDDROP-
3849 d->dropIndicatorRect = QRect();-
3850 d->dropIndicatorPosition = QAbstractItemView::OnViewport;-
3851#endif-
3852 d->viewport->update();-
3853 }
never executed: end of block
0
3854}-
3855-
3856/*!-
3857 Returns the SelectionFlags to be used when updating a selection with-
3858 to include the \a index specified. The \a event is a user input event,-
3859 such as a mouse or keyboard event.-
3860-
3861 Reimplement this function to define your own selection behavior.-
3862-
3863 \sa setSelection()-
3864*/-
3865QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand(const QModelIndex &index,-
3866 const QEvent *event) const-
3867{-
3868 Q_D(const QAbstractItemView);-
3869 Qt::KeyboardModifiers keyModifiers = Qt::NoModifier;-
3870 if (event) {
eventDescription
TRUEnever evaluated
FALSEnever evaluated
0
3871 switch (event->type()) {-
3872 case QEvent::MouseButtonDblClick:
never executed: case QEvent::MouseButtonDblClick:
0
3873 case QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
3874 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
3875 case QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
3876 case QEvent::KeyPress:
never executed: case QEvent::KeyPress:
0
3877 case QEvent::KeyRelease:
never executed: case QEvent::KeyRelease:
0
3878 keyModifiers = (static_cast<const QInputEvent*>(event))->modifiers();-
3879 break;
never executed: break;
0
3880 default:
never executed: default:
0
3881 keyModifiers = QApplication::keyboardModifiers();-
3882 }
never executed: end of block
0
3883 }-
3884 switch (d->selectionMode) {-
3885 case NoSelection: // Never update selection model
never executed: case NoSelection:
0
3886 return QItemSelectionModel::NoUpdate;
never executed: return QItemSelectionModel::NoUpdate;
0
3887 case SingleSelection: // ClearAndSelect on valid index otherwise NoUpdate
never executed: case SingleSelection:
0
3888 if (event && event->type() == QEvent::MouseButtonRelease)
eventDescription
TRUEnever evaluated
FALSEnever evaluated
event->type() ...eButtonReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
3889 return QItemSelectionModel::NoUpdate;
never executed: return QItemSelectionModel::NoUpdate;
0
3890 if ((keyModifiers & Qt::ControlModifier) && d->selectionModel->isSelected(index))
(keyModifiers ...ntrolModifier)Description
TRUEnever evaluated
FALSEnever evaluated
d->selectionMo...elected(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
3891 return QItemSelectionModel::Deselect | d->selectionBehaviorFlags();
never executed: return QItemSelectionModel::Deselect | d->selectionBehaviorFlags();
0
3892 else-
3893 return QItemSelectionModel::ClearAndSelect | d->selectionBehaviorFlags();
never executed: return QItemSelectionModel::ClearAndSelect | d->selectionBehaviorFlags();
0
3894 case MultiSelection:
never executed: case MultiSelection:
0
3895 return d->multiSelectionCommand(index, event);
never executed: return d->multiSelectionCommand(index, event);
0
3896 case ExtendedSelection:
never executed: case ExtendedSelection:
0
3897 return d->extendedSelectionCommand(index, event);
never executed: return d->extendedSelectionCommand(index, event);
0
3898 case ContiguousSelection:
never executed: case ContiguousSelection:
0
3899 return d->contiguousSelectionCommand(index, event);
never executed: return d->contiguousSelectionCommand(index, event);
0
3900 }-
3901 return QItemSelectionModel::NoUpdate;
never executed: return QItemSelectionModel::NoUpdate;
0
3902}-
3903-
3904QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::multiSelectionCommand(-
3905 const QModelIndex &index, const QEvent *event) const-
3906{-
3907 Q_UNUSED(index)-
3908-
3909 if (event) {
eventDescription
TRUEnever evaluated
FALSEnever evaluated
0
3910 switch (event->type()) {-
3911 case QEvent::KeyPress:
never executed: case QEvent::KeyPress:
0
3912 if (static_cast<const QKeyEvent*>(event)->key() == Qt::Key_Space
static_cast<co... Qt::Key_SpaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
3913 || static_cast<const QKeyEvent*>(event)->key() == Qt::Key_Select)
static_cast<co...Qt::Key_SelectDescription
TRUEnever evaluated
FALSEnever evaluated
0
3914 return QItemSelectionModel::Toggle|selectionBehaviorFlags();
never executed: return QItemSelectionModel::Toggle|selectionBehaviorFlags();
0
3915 break;
never executed: break;
0
3916 case QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
3917 if (static_cast<const QMouseEvent*>(event)->button() == Qt::LeftButton)
static_cast<co...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
3918 return QItemSelectionModel::Toggle|selectionBehaviorFlags(); // toggle
never executed: return QItemSelectionModel::Toggle|selectionBehaviorFlags();
0
3919 break;
never executed: break;
0
3920 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
3921 if (static_cast<const QMouseEvent*>(event)->button() == Qt::LeftButton)
static_cast<co...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
3922 return QItemSelectionModel::NoUpdate|selectionBehaviorFlags(); // finalize
never executed: return QItemSelectionModel::NoUpdate|selectionBehaviorFlags();
0
3923 break;
never executed: break;
0
3924 case QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
3925 if (static_cast<const QMouseEvent*>(event)->buttons() & Qt::LeftButton)
static_cast<co...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
3926 return QItemSelectionModel::ToggleCurrent|selectionBehaviorFlags(); // toggle drag select
never executed: return QItemSelectionModel::ToggleCurrent|selectionBehaviorFlags();
0
3927 default:
code before this statement never executed: default:
never executed: default:
0
3928 break;
never executed: break;
0
3929 }-
3930 return QItemSelectionModel::NoUpdate;
never executed: return QItemSelectionModel::NoUpdate;
0
3931 }-
3932-
3933 return QItemSelectionModel::Toggle|selectionBehaviorFlags();
never executed: return QItemSelectionModel::Toggle|selectionBehaviorFlags();
0
3934}-
3935-
3936QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionCommand(-
3937 const QModelIndex &index, const QEvent *event) const-
3938{-
3939 Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();-
3940 if (event) {
eventDescription
TRUEnever evaluated
FALSEnever evaluated
0
3941 switch (event->type()) {-
3942 case QEvent::MouseMove: {
never executed: case QEvent::MouseMove:
0
3943 // Toggle on MouseMove-
3944 modifiers = static_cast<const QMouseEvent*>(event)->modifiers();-
3945 if (modifiers & Qt::ControlModifier)
modifiers & Qt...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
3946 return QItemSelectionModel::ToggleCurrent|selectionBehaviorFlags();
never executed: return QItemSelectionModel::ToggleCurrent|selectionBehaviorFlags();
0
3947 break;
never executed: break;
0
3948 }-
3949 case QEvent::MouseButtonPress: {
never executed: case QEvent::MouseButtonPress:
0
3950 modifiers = static_cast<const QMouseEvent*>(event)->modifiers();-
3951 const Qt::MouseButton button = static_cast<const QMouseEvent*>(event)->button();-
3952 const bool rightButtonPressed = button & Qt::RightButton;-
3953 const bool shiftKeyPressed = modifiers & Qt::ShiftModifier;-
3954 const bool controlKeyPressed = modifiers & Qt::ControlModifier;-
3955 const bool indexIsSelected = selectionModel->isSelected(index);-
3956 if ((shiftKeyPressed || controlKeyPressed) && rightButtonPressed)
shiftKeyPressedDescription
TRUEnever evaluated
FALSEnever evaluated
controlKeyPressedDescription
TRUEnever evaluated
FALSEnever evaluated
rightButtonPressedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3957 return QItemSelectionModel::NoUpdate;
never executed: return QItemSelectionModel::NoUpdate;
0
3958 if (!shiftKeyPressed && !controlKeyPressed && indexIsSelected)
!shiftKeyPressedDescription
TRUEnever evaluated
FALSEnever evaluated
!controlKeyPressedDescription
TRUEnever evaluated
FALSEnever evaluated
indexIsSelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3959 return QItemSelectionModel::NoUpdate;
never executed: return QItemSelectionModel::NoUpdate;
0
3960 if (!index.isValid() && !rightButtonPressed && !shiftKeyPressed && !controlKeyPressed)
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
!rightButtonPressedDescription
TRUEnever evaluated
FALSEnever evaluated
!shiftKeyPressedDescription
TRUEnever evaluated
FALSEnever evaluated
!controlKeyPressedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3961 return QItemSelectionModel::Clear;
never executed: return QItemSelectionModel::Clear;
0
3962 if (!index.isValid())
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3963 return QItemSelectionModel::NoUpdate;
never executed: return QItemSelectionModel::NoUpdate;
0
3964 break;
never executed: break;
0
3965 }-
3966 case QEvent::MouseButtonRelease: {
never executed: case QEvent::MouseButtonRelease:
0
3967 // ClearAndSelect on MouseButtonRelease if MouseButtonPress on selected item or empty area-
3968 modifiers = static_cast<const QMouseEvent*>(event)->modifiers();-
3969 const Qt::MouseButton button = static_cast<const QMouseEvent*>(event)->button();-
3970 const bool rightButtonPressed = button & Qt::RightButton;-
3971 const bool shiftKeyPressed = modifiers & Qt::ShiftModifier;-
3972 const bool controlKeyPressed = modifiers & Qt::ControlModifier;-
3973 if (((index == pressedIndex && selectionModel->isSelected(index))
index == pressedIndexDescription
TRUEnever evaluated
FALSEnever evaluated
selectionModel...elected(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
3974 || !index.isValid()) && state != QAbstractItemView::DragSelectingState
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
state != QAbst...SelectingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
3975 && !shiftKeyPressed && !controlKeyPressed && (!rightButtonPressed || !index.isValid()))
!shiftKeyPressedDescription
TRUEnever evaluated
FALSEnever evaluated
!controlKeyPressedDescription
TRUEnever evaluated
FALSEnever evaluated
!rightButtonPressedDescription
TRUEnever evaluated
FALSEnever evaluated
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3976 return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags();
never executed: return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags();
0
3977 return QItemSelectionModel::NoUpdate;
never executed: return QItemSelectionModel::NoUpdate;
0
3978 }-
3979 case QEvent::KeyPress: {
never executed: case QEvent::KeyPress:
0
3980 // NoUpdate on Key movement and Ctrl-
3981 modifiers = static_cast<const QKeyEvent*>(event)->modifiers();-
3982 switch (static_cast<const QKeyEvent*>(event)->key()) {-
3983 case Qt::Key_Backtab:
never executed: case Qt::Key_Backtab:
0
3984 modifiers = modifiers & ~Qt::ShiftModifier; // special case for backtab-
3985 case Qt::Key_Down:
code before this statement never executed: case Qt::Key_Down:
never executed: case Qt::Key_Down:
0
3986 case Qt::Key_Up:
never executed: case Qt::Key_Up:
0
3987 case Qt::Key_Left:
never executed: case Qt::Key_Left:
0
3988 case Qt::Key_Right:
never executed: case Qt::Key_Right:
0
3989 case Qt::Key_Home:
never executed: case Qt::Key_Home:
0
3990 case Qt::Key_End:
never executed: case Qt::Key_End:
0
3991 case Qt::Key_PageUp:
never executed: case Qt::Key_PageUp:
0
3992 case Qt::Key_PageDown:
never executed: case Qt::Key_PageDown:
0
3993 case Qt::Key_Tab:
never executed: case Qt::Key_Tab:
0
3994 if (modifiers & Qt::ControlModifier
modifiers & Qt...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
3995#ifdef QT_KEYPAD_NAVIGATION-
3996 // Preserve historical tab order navigation behavior-
3997 || QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder-
3998#endif-
3999 )-
4000 return QItemSelectionModel::NoUpdate;
never executed: return QItemSelectionModel::NoUpdate;
0
4001 break;
never executed: break;
0
4002 case Qt::Key_Select:
never executed: case Qt::Key_Select:
0
4003 return QItemSelectionModel::Toggle|selectionBehaviorFlags();
never executed: return QItemSelectionModel::Toggle|selectionBehaviorFlags();
0
4004 case Qt::Key_Space:// Toggle on Ctrl-Qt::Key_Space, Select on Space
never executed: case Qt::Key_Space:
0
4005 if (modifiers & Qt::ControlModifier)
modifiers & Qt...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
4006 return QItemSelectionModel::Toggle|selectionBehaviorFlags();
never executed: return QItemSelectionModel::Toggle|selectionBehaviorFlags();
0
4007 return QItemSelectionModel::Select|selectionBehaviorFlags();
never executed: return QItemSelectionModel::Select|selectionBehaviorFlags();
0
4008 default:
never executed: default:
0
4009 break;
never executed: break;
0
4010 }-
4011 }-
4012 default:
code before this statement never executed: default:
never executed: default:
0
4013 break;
never executed: break;
0
4014 }-
4015 }-
4016-
4017 if (modifiers & Qt::ShiftModifier)
modifiers & Qt::ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
4018 return QItemSelectionModel::SelectCurrent|selectionBehaviorFlags();
never executed: return QItemSelectionModel::SelectCurrent|selectionBehaviorFlags();
0
4019 if (modifiers & Qt::ControlModifier)
modifiers & Qt...ontrolModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
4020 return QItemSelectionModel::Toggle|selectionBehaviorFlags();
never executed: return QItemSelectionModel::Toggle|selectionBehaviorFlags();
0
4021 if (state == QAbstractItemView::DragSelectingState) {
state == QAbst...SelectingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4022 //when drag-selecting we need to clear any previous selection and select the current one-
4023 return QItemSelectionModel::Clear|QItemSelectionModel::SelectCurrent|selectionBehaviorFlags();
never executed: return QItemSelectionModel::Clear|QItemSelectionModel::SelectCurrent|selectionBehaviorFlags();
0
4024 }-
4025-
4026 return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags();
never executed: return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags();
0
4027}-
4028-
4029QItemSelectionModel::SelectionFlags-
4030QAbstractItemViewPrivate::contiguousSelectionCommand(const QModelIndex &index,-
4031 const QEvent *event) const-
4032{-
4033 QItemSelectionModel::SelectionFlags flags = extendedSelectionCommand(index, event);-
4034 const int Mask = QItemSelectionModel::Clear | QItemSelectionModel::Select-
4035 | QItemSelectionModel::Deselect | QItemSelectionModel::Toggle-
4036 | QItemSelectionModel::Current;-
4037-
4038 switch (flags & Mask) {-
4039 case QItemSelectionModel::Clear:
never executed: case QItemSelectionModel::Clear:
0
4040 case QItemSelectionModel::ClearAndSelect:
never executed: case QItemSelectionModel::ClearAndSelect:
0
4041 case QItemSelectionModel::SelectCurrent:
never executed: case QItemSelectionModel::SelectCurrent:
0
4042 return flags;
never executed: return flags;
0
4043 case QItemSelectionModel::NoUpdate:
never executed: case QItemSelectionModel::NoUpdate:
0
4044 if (event &&
eventDescription
TRUEnever evaluated
FALSEnever evaluated
0
4045 (event->type() == QEvent::MouseButtonPress
event->type() ...useButtonPressDescription
TRUEnever evaluated
FALSEnever evaluated
0
4046 || event->type() == QEvent::MouseButtonRelease))
event->type() ...eButtonReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
4047 return flags;
never executed: return flags;
0
4048 return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags();
never executed: return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags();
0
4049 default:
never executed: default:
0
4050 return QItemSelectionModel::SelectCurrent|selectionBehaviorFlags();
never executed: return QItemSelectionModel::SelectCurrent|selectionBehaviorFlags();
0
4051 }-
4052}-
4053-
4054void QAbstractItemViewPrivate::fetchMore()-
4055{-
4056 fetchMoreTimer.stop();-
4057 if (!model->canFetchMore(root))
!model->canFetchMore(root)Description
TRUEnever evaluated
FALSEnever evaluated
0
4058 return;
never executed: return;
0
4059 int last = model->rowCount(root) - 1;-
4060 if (last < 0) {
last < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4061 model->fetchMore(root);-
4062 return;
never executed: return;
0
4063 }-
4064-
4065 QModelIndex index = model->index(last, 0, root);-
4066 QRect rect = q_func()->visualRect(index);-
4067 if (viewport->rect().intersects(rect))
viewport->rect...tersects(rect)Description
TRUEnever evaluated
FALSEnever evaluated
0
4068 model->fetchMore(root);
never executed: model->fetchMore(root);
0
4069}
never executed: end of block
0
4070-
4071bool QAbstractItemViewPrivate::shouldEdit(QAbstractItemView::EditTrigger trigger,-
4072 const QModelIndex &index) const-
4073{-
4074 if (!index.isValid())
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
4075 return false;
never executed: return false;
0
4076 Qt::ItemFlags flags = model->flags(index);-
4077 if (((flags & Qt::ItemIsEditable) == 0) || ((flags & Qt::ItemIsEnabled) == 0))
((flags & Qt::...ditable) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
((flags & Qt::...Enabled) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
4078 return false;
never executed: return false;
0
4079 if (state == QAbstractItemView::EditingState)
state == QAbst...::EditingStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4080 return false;
never executed: return false;
0
4081 if (hasEditor(index))
hasEditor(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
4082 return false;
never executed: return false;
0
4083 if (trigger == QAbstractItemView::AllEditTriggers) // force editing
trigger == QAb...llEditTriggersDescription
TRUEnever evaluated
FALSEnever evaluated
0
4084 return true;
never executed: return true;
0
4085 if ((trigger & editTriggers) == QAbstractItemView::SelectedClicked
(trigger & edi...electedClickedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4086 && !selectionModel->isSelected(index))
!selectionMode...elected(index)Description
TRUEnever evaluated
FALSEnever evaluated
0
4087 return false;
never executed: return false;
0
4088 return (trigger & editTriggers);
never executed: return (trigger & editTriggers);
0
4089}-
4090-
4091bool QAbstractItemViewPrivate::shouldForwardEvent(QAbstractItemView::EditTrigger trigger,-
4092 const QEvent *event) const-
4093{-
4094 if (!event || (trigger & editTriggers) != QAbstractItemView::AnyKeyPressed)
!eventDescription
TRUEnever evaluated
FALSEnever evaluated
(trigger & edi...:AnyKeyPressedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4095 return false;
never executed: return false;
0
4096-
4097 switch (event->type()) {-
4098 case QEvent::KeyPress:
never executed: case QEvent::KeyPress:
0
4099 case QEvent::MouseButtonDblClick:
never executed: case QEvent::MouseButtonDblClick:
0
4100 case QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
4101 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
4102 case QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
4103 return true;
never executed: return true;
0
4104 default:
never executed: default:
0
4105 break;
never executed: break;
0
4106 };-
4107-
4108 return false;
never executed: return false;
0
4109}-
4110-
4111bool QAbstractItemViewPrivate::shouldAutoScroll(const QPoint &pos) const-
4112{-
4113 if (!autoScroll)
!autoScrollDescription
TRUEnever evaluated
FALSEnever evaluated
0
4114 return false;
never executed: return false;
0
4115 QRect area = static_cast<QAbstractItemView*>(viewport)->d_func()->clipRect(); // access QWidget private by bending C++ rules-
4116 return (pos.y() - area.top() < autoScrollMargin)
never executed: return (pos.y() - area.top() < autoScrollMargin) || (area.bottom() - pos.y() < autoScrollMargin) || (pos.x() - area.left() < autoScrollMargin) || (area.right() - pos.x() < autoScrollMargin);
(pos.y() - are...oScrollMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
4117 || (area.bottom() - pos.y() < autoScrollMargin)
never executed: return (pos.y() - area.top() < autoScrollMargin) || (area.bottom() - pos.y() < autoScrollMargin) || (pos.x() - area.left() < autoScrollMargin) || (area.right() - pos.x() < autoScrollMargin);
(area.bottom()...oScrollMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
4118 || (pos.x() - area.left() < autoScrollMargin)
never executed: return (pos.y() - area.top() < autoScrollMargin) || (area.bottom() - pos.y() < autoScrollMargin) || (pos.x() - area.left() < autoScrollMargin) || (area.right() - pos.x() < autoScrollMargin);
(pos.x() - are...oScrollMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
4119 || (area.right() - pos.x() < autoScrollMargin);
never executed: return (pos.y() - area.top() < autoScrollMargin) || (area.bottom() - pos.y() < autoScrollMargin) || (pos.x() - area.left() < autoScrollMargin) || (area.right() - pos.x() < autoScrollMargin);
(area.right() ...oScrollMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
4120}-
4121-
4122void QAbstractItemViewPrivate::doDelayedItemsLayout(int delay)-
4123{-
4124 if (!delayedPendingLayout) {
!delayedPendingLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
4125 delayedPendingLayout = true;-
4126 delayedLayout.start(delay, q_func());-
4127 }
never executed: end of block
0
4128}
never executed: end of block
0
4129-
4130void QAbstractItemViewPrivate::interruptDelayedItemsLayout() const-
4131{-
4132 delayedLayout.stop();-
4133 delayedPendingLayout = false;-
4134}
never executed: end of block
0
4135-
4136void QAbstractItemViewPrivate::updateGeometry()-
4137{-
4138 Q_Q(QAbstractItemView);-
4139 if (sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored)
sizeAdjustPoli...:AdjustIgnoredDescription
TRUEnever evaluated
FALSEnever evaluated
0
4140 return;
never executed: return;
0
4141 if (sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents || !shownOnce)
sizeAdjustPoli...justToContentsDescription
TRUEnever evaluated
FALSEnever evaluated
!shownOnceDescription
TRUEnever evaluated
FALSEnever evaluated
0
4142 q->updateGeometry();
never executed: q->updateGeometry();
0
4143}
never executed: end of block
0
4144-
4145QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index,-
4146 const QStyleOptionViewItem &options)-
4147{-
4148 Q_Q(QAbstractItemView);-
4149 QWidget *w = editorForIndex(index).widget.data();-
4150 if (!w) {
!wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4151 QAbstractItemDelegate *delegate = delegateForIndex(index);-
4152 if (!delegate)
!delegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4153 return 0;
never executed: return 0;
0
4154 w = delegate->createEditor(viewport, options, index);-
4155 if (w) {
wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4156 w->installEventFilter(delegate);-
4157 QObject::connect(w, SIGNAL(destroyed(QObject*)), q, SLOT(editorDestroyed(QObject*)));-
4158 delegate->updateEditorGeometry(w, options, index);-
4159 delegate->setEditorData(w, index);-
4160 addEditor(index, w, false);-
4161 if (w->parent() == viewport)
w->parent() == viewportDescription
TRUEnever evaluated
FALSEnever evaluated
0
4162 QWidget::setTabOrder(q, w);
never executed: QWidget::setTabOrder(q, w);
0
4163-
4164 // Special cases for some editors containing QLineEdit-
4165 QWidget *focusWidget = w;-
4166 while (QWidget *fp = focusWidget->focusProxy())
QWidget *fp = ...->focusProxy()Description
TRUEnever evaluated
FALSEnever evaluated
0
4167 focusWidget = fp;
never executed: focusWidget = fp;
0
4168#ifndef QT_NO_LINEEDIT-
4169 if (QLineEdit *le = qobject_cast<QLineEdit*>(focusWidget))
QLineEdit *le ...>(focusWidget)Description
TRUEnever evaluated
FALSEnever evaluated
0
4170 le->selectAll();
never executed: le->selectAll();
0
4171#endif-
4172#ifndef QT_NO_SPINBOX-
4173 if (QSpinBox *sb = qobject_cast<QSpinBox*>(focusWidget))
QSpinBox *sb =...>(focusWidget)Description
TRUEnever evaluated
FALSEnever evaluated
0
4174 sb->selectAll();
never executed: sb->selectAll();
0
4175 else if (QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(focusWidget))
QDoubleSpinBox...>(focusWidget)Description
TRUEnever evaluated
FALSEnever evaluated
0
4176 dsb->selectAll();
never executed: dsb->selectAll();
0
4177#endif-
4178 }
never executed: end of block
0
4179 }
never executed: end of block
0
4180-
4181 return w;
never executed: return w;
0
4182}-
4183-
4184void QAbstractItemViewPrivate::updateEditorData(const QModelIndex &tl, const QModelIndex &br)-
4185{-
4186 // we are counting on having relatively few editors-
4187 const bool checkIndexes = tl.isValid() && br.isValid();
tl.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
br.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
4188 const QModelIndex parent = tl.parent();-
4189 // QTBUG-25370: We need to copy the indexEditorHash, because while we're-
4190 // iterating over it, we are calling methods which can allow user code to-
4191 // call a method on *this which can modify the member indexEditorHash.-
4192 const QIndexEditorHash indexEditorHashCopy = indexEditorHash;-
4193 QIndexEditorHash::const_iterator it = indexEditorHashCopy.constBegin();-
4194 for (; it != indexEditorHashCopy.constEnd(); ++it) {
it != indexEdi...opy.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
4195 QWidget *editor = it.value().widget.data();-
4196 const QModelIndex index = it.key();-
4197 if (it.value().isStatic || !editor || !index.isValid() ||
it.value().isStaticDescription
TRUEnever evaluated
FALSEnever evaluated
!editorDescription
TRUEnever evaluated
FALSEnever evaluated
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
4198 (checkIndexes
checkIndexesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4199 && (index.row() < tl.row() || index.row() > br.row()
index.row() < tl.row()Description
TRUEnever evaluated
FALSEnever evaluated
index.row() > br.row()Description
TRUEnever evaluated
FALSEnever evaluated
0
4200 || index.column() < tl.column() || index.column() > br.column()
index.column() < tl.column()Description
TRUEnever evaluated
FALSEnever evaluated
index.column() > br.column()Description
TRUEnever evaluated
FALSEnever evaluated
0
4201 || index.parent() != parent)))
index.parent() != parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4202 continue;
never executed: continue;
0
4203-
4204 QAbstractItemDelegate *delegate = delegateForIndex(index);-
4205 if (delegate) {
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4206 delegate->setEditorData(editor, index);-
4207 }
never executed: end of block
0
4208 }
never executed: end of block
0
4209}
never executed: end of block
0
4210-
4211/*!-
4212 \internal-
4213-
4214 In DND if something has been moved then this is called.-
4215 Typically this means you should "remove" the selected item or row,-
4216 but the behavior is view dependant (table just clears the selected indexes for example).-
4217-
4218 Either remove the selected rows or clear them-
4219*/-
4220void QAbstractItemViewPrivate::clearOrRemove()-
4221{-
4222#ifndef QT_NO_DRAGANDDROP-
4223 const QItemSelection selection = selectionModel->selection();-
4224 QList<QItemSelectionRange>::const_iterator it = selection.constBegin();-
4225-
4226 if (!overwrite) {
!overwriteDescription
TRUEnever evaluated
FALSEnever evaluated
0
4227 for (; it != selection.constEnd(); ++it) {
it != selection.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
4228 QModelIndex parent = (*it).parent();-
4229 if ((*it).left() != 0)
(*it).left() != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4230 continue;
never executed: continue;
0
4231 if ((*it).right() != (model->columnCount(parent) - 1))
(*it).right() ...t(parent) - 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
4232 continue;
never executed: continue;
0
4233 int count = (*it).bottom() - (*it).top() + 1;-
4234 model->removeRows((*it).top(), count, parent);-
4235 }
never executed: end of block
0
4236 } else {
never executed: end of block
0
4237 // we can't remove the rows so reset the items (i.e. the view is like a table)-
4238 QModelIndexList list = selection.indexes();-
4239 for (int i=0; i < list.size(); ++i) {
i < list.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4240 QModelIndex index = list.at(i);-
4241 QMap<int, QVariant> roles = model->itemData(index);-
4242 for (QMap<int, QVariant>::Iterator it = roles.begin(); it != roles.end(); ++it)
it != roles.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
4243 it.value() = QVariant();
never executed: it.value() = QVariant();
0
4244 model->setItemData(index, roles);-
4245 }
never executed: end of block
0
4246 }
never executed: end of block
0
4247#endif-
4248}-
4249-
4250/*!-
4251 \internal-
4252-
4253 When persistent aeditor gets/loses focus, we need to check-
4254 and setcorrectly the current index.-
4255*/-
4256void QAbstractItemViewPrivate::checkPersistentEditorFocus()-
4257{-
4258 Q_Q(QAbstractItemView);-
4259 if (QWidget *widget = QApplication::focusWidget()) {
QWidget *widge...:focusWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
4260 if (persistent.contains(widget)) {
persistent.contains(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
4261 //a persistent editor has gained the focus-
4262 QModelIndex index = indexForEditor(widget);-
4263 if (selectionModel->currentIndex() != index)
selectionModel...dex() != indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
4264 q->setCurrentIndex(index);
never executed: q->setCurrentIndex(index);
0
4265 }
never executed: end of block
0
4266 }
never executed: end of block
0
4267}
never executed: end of block
0
4268-
4269-
4270const QEditorInfo & QAbstractItemViewPrivate::editorForIndex(const QModelIndex &index) const-
4271{-
4272 static QEditorInfo nullInfo;-
4273-
4274 // do not try to search to avoid slow implicit cast from QModelIndex to QPersistentModelIndex-
4275 if (indexEditorHash.isEmpty())
indexEditorHash.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4276 return nullInfo;
never executed: return nullInfo;
0
4277-
4278 QIndexEditorHash::const_iterator it = indexEditorHash.find(index);-
4279 if (it == indexEditorHash.end())
it == indexEditorHash.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
4280 return nullInfo;
never executed: return nullInfo;
0
4281-
4282 return it.value();
never executed: return it.value();
0
4283}-
4284-
4285bool QAbstractItemViewPrivate::hasEditor(const QModelIndex &index) const-
4286{-
4287 return indexEditorHash.find(index) != indexEditorHash.constEnd();
never executed: return indexEditorHash.find(index) != indexEditorHash.constEnd();
0
4288}-
4289-
4290QModelIndex QAbstractItemViewPrivate::indexForEditor(QWidget *editor) const-
4291{-
4292 // do not try to search to avoid slow implicit cast from QModelIndex to QPersistentModelIndex-
4293 if (indexEditorHash.isEmpty())
indexEditorHash.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4294 return QModelIndex();
never executed: return QModelIndex();
0
4295-
4296 QEditorIndexHash::const_iterator it = editorIndexHash.find(editor);-
4297 if (it == editorIndexHash.end())
it == editorIndexHash.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
4298 return QModelIndex();
never executed: return QModelIndex();
0
4299-
4300 return it.value();
never executed: return it.value();
0
4301}-
4302-
4303void QAbstractItemViewPrivate::removeEditor(QWidget *editor)-
4304{-
4305 QEditorIndexHash::iterator it = editorIndexHash.find(editor);-
4306 if (it != editorIndexHash.end())
it != editorIndexHash.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
4307 {-
4308 indexEditorHash.remove(it.value());-
4309 editorIndexHash.erase(it);-
4310 }
never executed: end of block
0
4311}
never executed: end of block
0
4312-
4313void QAbstractItemViewPrivate::addEditor(const QModelIndex &index, QWidget *editor, bool isStatic)-
4314{-
4315 editorIndexHash.insert(editor, index);-
4316 indexEditorHash.insert(index, QEditorInfo(editor, isStatic));-
4317}
never executed: end of block
0
4318-
4319bool QAbstractItemViewPrivate::sendDelegateEvent(const QModelIndex &index, QEvent *event) const-
4320{-
4321 Q_Q(const QAbstractItemView);-
4322 QModelIndex buddy = model->buddy(index);-
4323 QStyleOptionViewItem options = viewOptionsV1();-
4324 options.rect = q->visualRect(buddy);-
4325 options.state |= (buddy == q->currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
buddy == q->currentIndex()Description
TRUEnever evaluated
FALSEnever evaluated
0
4326 QAbstractItemDelegate *delegate = delegateForIndex(index);-
4327 return (event && delegate && delegate->editorEvent(event, model, options, buddy));
never executed: return (event && delegate && delegate->editorEvent(event, model, options, buddy));
eventDescription
TRUEnever evaluated
FALSEnever evaluated
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
delegate->edit...ptions, buddy)Description
TRUEnever evaluated
FALSEnever evaluated
0
4328}-
4329-
4330bool QAbstractItemViewPrivate::openEditor(const QModelIndex &index, QEvent *event)-
4331{-
4332 Q_Q(QAbstractItemView);-
4333-
4334 QModelIndex buddy = model->buddy(index);-
4335 QStyleOptionViewItem options = viewOptionsV1();-
4336 options.rect = q->visualRect(buddy);-
4337 options.state |= (buddy == q->currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
buddy == q->currentIndex()Description
TRUEnever evaluated
FALSEnever evaluated
0
4338-
4339 QWidget *w = editor(buddy, options);-
4340 if (!w)
!wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4341 return false;
never executed: return false;
0
4342-
4343 q->setState(QAbstractItemView::EditingState);-
4344 w->show();-
4345 w->setFocus();-
4346-
4347 if (event)
eventDescription
TRUEnever evaluated
FALSEnever evaluated
0
4348 QApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event);
never executed: QApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event);
0
4349-
4350 return true;
never executed: return true;
0
4351}-
4352-
4353/*-
4354 \internal-
4355-
4356 returns the pair QRect/QModelIndex that should be painted on the viewports's rect-
4357*/-
4358-
4359QItemViewPaintPairs QAbstractItemViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const-
4360{-
4361 Q_ASSERT(r);-
4362 Q_Q(const QAbstractItemView);-
4363 QRect &rect = *r;-
4364 const QRect viewportRect = viewport->rect();-
4365 QItemViewPaintPairs ret;-
4366 for (int i = 0; i < indexes.count(); ++i) {
i < indexes.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
4367 const QModelIndex &index = indexes.at(i);-
4368 const QRect current = q->visualRect(index);-
4369 if (current.intersects(viewportRect)) {
current.inters...(viewportRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
4370 ret += qMakePair(current, index);-
4371 rect |= current;-
4372 }
never executed: end of block
0
4373 }
never executed: end of block
0
4374 rect &= viewportRect;-
4375 return ret;
never executed: return ret;
0
4376}-
4377-
4378QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes, QRect *r) const-
4379{-
4380 Q_ASSERT(r);-
4381 QItemViewPaintPairs paintPairs = draggablePaintPairs(indexes, r);-
4382 if (paintPairs.isEmpty())
paintPairs.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4383 return QPixmap();
never executed: return QPixmap();
0
4384-
4385 qreal scale = 1.0f;-
4386-
4387 Q_Q(const QAbstractItemView);-
4388 QWidget *window = q->window();-
4389 if (window) {
windowDescription
TRUEnever evaluated
FALSEnever evaluated
0
4390 QWindow *windowHandle = window->windowHandle();-
4391 if (windowHandle)
windowHandleDescription
TRUEnever evaluated
FALSEnever evaluated
0
4392 scale = windowHandle->devicePixelRatio();
never executed: scale = windowHandle->devicePixelRatio();
0
4393 }
never executed: end of block
0
4394-
4395 QPixmap pixmap(r->size() * scale);-
4396 pixmap.setDevicePixelRatio(scale);-
4397-
4398 pixmap.fill(Qt::transparent);-
4399 QPainter painter(&pixmap);-
4400 QStyleOptionViewItem option = viewOptionsV1();-
4401 option.state |= QStyle::State_Selected;-
4402 for (int j = 0; j < paintPairs.count(); ++j) {
j < paintPairs.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
4403 option.rect = paintPairs.at(j).first.translated(-r->topLeft());-
4404 const QModelIndex &current = paintPairs.at(j).second;-
4405 adjustViewOptionsForIndex(&option, current);-
4406 delegateForIndex(current)->paint(&painter, option, current);-
4407 }
never executed: end of block
0
4408 return pixmap;
never executed: return pixmap;
0
4409}-
4410-
4411void QAbstractItemViewPrivate::selectAll(QItemSelectionModel::SelectionFlags command)-
4412{-
4413 if (!selectionModel)
!selectionModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
4414 return;
never executed: return;
0
4415-
4416 QItemSelection selection;-
4417 QModelIndex tl = model->index(0, 0, root);-
4418 QModelIndex br = model->index(model->rowCount(root) - 1,-
4419 model->columnCount(root) - 1,-
4420 root);-
4421 selection.append(QItemSelectionRange(tl, br));-
4422 selectionModel->select(selection, command);-
4423}
never executed: end of block
0
4424-
4425QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes() const-
4426{-
4427 Q_Q(const QAbstractItemView);-
4428 QModelIndexList indexes = q->selectedIndexes();-
4429 for(int i = indexes.count() - 1 ; i >= 0; --i) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4430 if (!isIndexDragEnabled(indexes.at(i)))
!isIndexDragEn...indexes.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
0
4431 indexes.removeAt(i);
never executed: indexes.removeAt(i);
0
4432 }
never executed: end of block
0
4433 return indexes;
never executed: return indexes;
0
4434}-
4435-
4436-
4437QT_END_NAMESPACE-
4438-
4439#include "moc_qabstractitemview.cpp"-
4440-
4441#endif // QT_NO_ITEMVIEWS-
Source codeSwitch to Preprocessed file

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