11#if QT_CONFIG(draganddrop)
20#if QT_CONFIG(lineedit)
28#include <private/qabstractitemview_p.h>
29#include <private/qabstractitemmodel_p.h>
30#include <private/qapplication_p.h>
31#include <private/qguiapplication_p.h>
32#include <private/qscrollbar_p.h>
33#if QT_CONFIG(accessibility)
36#if QT_CONFIG(gestures) && QT_CONFIG(scroller)
49 noSelectionOnMousePress(
false),
52 currentlyCommittingEditor(
nullptr),
53 pressClosedEditor(
false),
54 waitForIMCommit(
false),
55 pressedModifiers(
Qt::NoModifier),
56 pressedPosition(
QPoint(-1, -1)),
57 pressedAlreadySelected(
false),
58 releaseFromDoubleClick(
false),
59 viewportEnteredNeeded(
false),
64 tabKeyNavigation(
false),
66 showDropIndicator(true),
70 dropEventMoved(
false),
72 defaultDropAction(
Qt::IgnoreAction),
77 shouldScrollToCurrentOnShow(
false),
78 shouldClearStatusTip(
false),
79 alternatingColors(
false),
80 textElideMode(
Qt::ElideRight),
83 currentIndexSet(
false),
85 delayedPendingLayout(true),
86 moveCursorUpdatedView(
false),
87 verticalScrollModeSet(
false),
88 horizontalScrollModeSet(
false)
102 vbar->setRange(0, 0);
103 hbar->setRange(0, 0);
149 if (
index.isValid()) {
151#if QT_CONFIG(statustip)
160#if QT_CONFIG(statustip)
167 emit q->viewportEntered();
173#if QT_CONFIG(gestures) && QT_CONFIG(scroller)
184 if (
q->selectionModel()) {
192 if (
q->selectionModel()) {
217 qWarning(
"Delegate size hint changed for a model index that does not belong to this view");
248void QAbstractItemViewPrivate::disconnectAll()
257 disconnectDelegate(delegate);
259 disconnectDelegate(delegate);
274#if QT_CONFIG(gestures) && QT_CONFIG(scroller)
673 : QAbstractScrollArea(dd, parent)
685 d->delayedReset.stop();
686 d->updateTimer.stop();
687 d->delayedEditing.stop();
688 d->delayedAutoScroll.stop();
689 d->autoScrollTimer.stop();
690 d->delayedLayout.stop();
691 d->fetchMoreTimer.stop();
727 d->modelConnections = {
797 qWarning(
"QAbstractItemView::setSelectionModel() failed: "
798 "Trying to set a selection model, which works on "
799 "a different model than the view.");
806 if (
d->selectionModel) {
808 oldSelection =
d->selectionModel->selection();
809 oldCurrentIndex =
d->selectionModel->currentIndex();
819 if (
d->selectionModel) {
838 return d->selectionModel;
859 if (delegate ==
d->itemDelegate)
862 if (
d->itemDelegate) {
863 if (
d->delegateRefCount(
d->itemDelegate) == 1)
864 d->disconnectDelegate(delegate);
868 if (
d->delegateRefCount(delegate) == 0)
869 d->connectDelegate(delegate);
871 d->itemDelegate = delegate;
873 d->doDelayedItemsLayout();
884 return d_func()->itemDelegate;
897 d->waitForIMCommit && (currentEditor =
d->editorForIndex(current).
widget)) {
901 if (
result.typeId() == QMetaType::QRect) {
903 result =
QRect(currentEditor->mapTo(
this, editorRect.topLeft()), editorRect.size());
910 result = QAbstractScrollArea::inputMethodQuery(
query);
939 if (
d->delegateRefCount(rowDelegate) == 1)
940 d->disconnectDelegate(rowDelegate);
941 d->rowDelegates.remove(
row);
944 if (
d->delegateRefCount(delegate) == 0)
945 d->connectDelegate(delegate);
946 d->rowDelegates.insert(
row, delegate);
949 d->doDelayedItemsLayout();
964 return d->rowDelegates.value(
row,
nullptr);
991 if (
d->delegateRefCount(columnDelegate) == 1)
992 d->disconnectDelegate(columnDelegate);
993 d->columnDelegates.remove(
column);
996 if (
d->delegateRefCount(delegate) == 0)
997 d->connectDelegate(delegate);
998 d->columnDelegates.insert(
column, delegate);
1001 d->doDelayedItemsLayout();
1016 return d->columnDelegates.value(
column,
nullptr);
1037 return d->delegateForIndex(
index);
1053 d->selectionMode =
mode;
1059 return d->selectionMode;
1075 d->selectionBehavior = behavior;
1081 return d->selectionBehavior;
1101 if (
d->selectionModel && (!
index.isValid() ||
d->isIndexEnabled(
index))) {
1103 d->selectionModel->setCurrentIndex(
index, command);
1104 d->currentIndexSet =
true;
1106 d->currentSelectionStartIndex =
index;
1118 return d->selectionModel ?
d->selectionModel->currentIndex() :
QModelIndex();
1134 d->delayedReset.stop();
1138 const auto copy =
d->indexEditorHash;
1141 d->releaseEditor(
info.widget.data(),
d->indexForEditor(
info.widget.data()));
1143 d->editorIndexHash.clear();
1144 d->indexEditorHash.clear();
1145 d->persistent.clear();
1146 d->currentIndexSet =
false;
1149 if (
d->selectionModel)
1150 d->selectionModel->reset();
1151#if QT_CONFIG(accessibility)
1152 if (QAccessible::isActive()) {
1153 QAccessibleTableModelChangeEvent accessibleEvent(
this, QAccessibleTableModelChangeEvent::ModelReset);
1154 QAccessible::updateAccessibility(&accessibleEvent);
1157 d->updateGeometry();
1169 qWarning(
"QAbstractItemView::setRootIndex failed : index must be from the currently set model");
1173#if QT_CONFIG(accessibility)
1174 if (QAccessible::isActive()) {
1175 QAccessibleTableModelChangeEvent accessibleEvent(
this, QAccessibleTableModelChangeEvent::ModelReset);
1176 QAccessible::updateAccessibility(&accessibleEvent);
1179 d->doDelayedItemsLayout();
1180 d->updateGeometry();
1209 |
d->selectionBehaviorFlags());
1213 if (
d->model->hasChildren(
d->root))
1237 qWarning(
"edit: index was invalid");
1250 if (
d->selectionModel)
1251 d->selectionModel->clearSelection();
1263 d->interruptDelayedItemsLayout();
1265 d->viewport->update();
1280 d->editTriggers = actions;
1286 return d->editTriggers;
1302 d->verticalScrollModeSet =
true;
1303 if (
mode ==
d->verticalScrollMode)
1306 d->verticalScrollMode =
mode;
1308 verticalScrollBar()->d_func()->itemviewChangeSingleStep(1);
1310 verticalScrollBar()->setSingleStep(-1);
1318 return d->verticalScrollMode;
1325 d_func()->verticalScrollModeSet =
false;
1341 d->horizontalScrollModeSet =
true;
1342 if (
mode ==
d->horizontalScrollMode)
1344 d->horizontalScrollMode =
mode;
1346 horizontalScrollBar()->d_func()->itemviewChangeSingleStep(1);
1348 horizontalScrollBar()->setSingleStep(-1);
1355 return d->horizontalScrollMode;
1362 d_func()->horizontalScrollModeSet =
false;
1365#if QT_CONFIG(draganddrop)
1387void QAbstractItemView::setDragDropOverwriteMode(
bool overwrite)
1390 d->overwrite = overwrite;
1393bool QAbstractItemView::dragDropOverwriteMode()
const
1396 return d->overwrite;
1423 return d->autoScroll;
1437 d->autoScrollMargin = margin;
1443 return d->autoScrollMargin;
1460 return d->tabKeyNavigation;
1469 return QAbstractScrollArea::viewportSizeHint();
1472#if QT_CONFIG(draganddrop)
1480void QAbstractItemView::setDropIndicatorShown(
bool enable)
1483 d->showDropIndicator =
enable;
1486bool QAbstractItemView::showDropIndicator()
const
1489 return d->showDropIndicator;
1499void QAbstractItemView::setDragEnabled(
bool enable)
1505bool QAbstractItemView::dragEnabled()
const
1508 return d->dragEnabled;
1538void QAbstractItemView::setDragDropMode(DragDropMode behavior)
1541 d->dragDropMode = behavior;
1542 setDragEnabled(behavior == DragOnly || behavior == DragDrop || behavior == InternalMove);
1543 setAcceptDrops(behavior == DropOnly || behavior == DragDrop || behavior == InternalMove);
1546QAbstractItemView::DragDropMode QAbstractItemView::dragDropMode()
const
1549 DragDropMode setBehavior =
d->dragDropMode;
1550 if (!dragEnabled() && !acceptDrops())
1553 if (dragEnabled() && !acceptDrops())
1556 if (!dragEnabled() && acceptDrops())
1559 if (dragEnabled() && acceptDrops()) {
1560 if (setBehavior == InternalMove)
1579void QAbstractItemView::setDefaultDropAction(
Qt::DropAction dropAction)
1582 d->defaultDropAction = dropAction;
1588 return d->defaultDropAction;
1606 d->alternatingColors =
enable;
1608 d->viewport->update();
1614 return d->alternatingColors;
1627 if (
size ==
d->iconSize)
1630 d->doDelayedItemsLayout();
1650 d->textElideMode =
mode;
1655 return d_func()->textElideMode;
1664 if (
d->tabKeyNavigation &&
isVisible() && isEnabled() &&
d->viewport->isEnabled()) {
1667 if (
event.isAccepted())
1670 return QAbstractScrollArea::focusNextPrevChild(
next);
1679 switch (
event->type()) {
1683 d->executePostedLayout();
1686 d->executePostedLayout();
1687 if (
d->shouldScrollToCurrentOnShow) {
1688 d->shouldScrollToCurrentOnShow =
false;
1703 if (!
d->verticalScrollModeSet)
1705 if (!
d->horizontalScrollModeSet)
1709 d->checkPersistentEditorFocus();
1712 d->doDelayedItemsLayout();
1717 return QAbstractScrollArea::event(
event);
1734 switch (
event->type()) {
1739 d->executePostedLayout();
1749 d->viewportEnteredNeeded =
true;
1753 #if QT_CONFIG(statustip)
1754 if (
d->shouldClearStatusTip &&
d->parent) {
1758 d->shouldClearStatusTip =
false;
1768 QStyleOptionViewItem
option;
1779 d->doDelayedItemsLayout();
1783 d->viewport->update();
1787#if QT_CONFIG(gestures) && QT_CONFIG(scroller)
1798 return QAbstractScrollArea::viewportEvent(
event);
1809 d->releaseFromDoubleClick =
false;
1810 d->delayedAutoScroll.stop();
1811 QPoint pos =
event->position().toPoint();
1815 d->pressClosedEditor =
d->pressClosedEditorWatcher.isActive() &&
d->lastEditedIndex ==
index;
1820 d->pressedAlreadySelected =
d->selectionModel->isSelected(
index);
1822 d->pressedModifiers =
event->modifiers();
1828#if QT_CONFIG(draganddrop)
1831 d->pressedPosition =
d->draggedPosition;
1836 d->currentSelectionStartIndex =
index;
1838 else if (!
d->currentSelectionStartIndex.isValid())
1844 if (
index.isValid() &&
d->isIndexEnabled(
index)) {
1848 d->autoScroll =
false;
1854 command |=
d->ctrlDragSelectionFlag;
1866 if (
d->autoScroll) {
1886 QPoint bottomRight =
event->position().toPoint();
1888 d->draggedPosition = bottomRight +
d->offset();
1893#if QT_CONFIG(draganddrop)
1895 d->maybeStartDrag(bottomRight);
1907 d->selectionMode !=
SingleSelection ?
d->pressedPosition -
d->offset() : bottomRight;
1909 d->checkMouseMove(
index);
1911#if QT_CONFIG(draganddrop)
1912 if (
d->pressedIndex.isValid()
1916 && !
d->selectedDraggableIndexes().isEmpty()) {
1918 d->maybeStartDrag(bottomRight);
1928 command |=
d->ctrlDragSelectionFlag;
1932 QRect selectionRect =
QRect(topLeft, bottomRight);
1936 if (
index.isValid() && (
index !=
d->selectionModel->currentIndex()) &&
d->isIndexEnabled(
index))
1938 else if (
d->shouldAutoScroll(
event->pos()) && !
d->autoScrollTimer.isActive())
1953 const bool releaseFromDoubleClick =
d->releaseFromDoubleClick;
1954 d->releaseFromDoubleClick =
false;
1956 QPoint pos =
event->position().toPoint();
1960 if (
d->isIndexValid(
index)
1961 &&
d->isIndexEnabled(
index)
1967 bool click = (
index ==
d->pressedIndex &&
index.isValid() && !releaseFromDoubleClick);
1968 bool selectedClicked = click &&
d->pressedAlreadySelected
1972 const bool edited = click && !
d->pressClosedEditor ?
edit(
index, trigger,
event) :
false;
1976 if (
d->selectionModel &&
d->noSelectionOnMousePress) {
1977 d->noSelectionOnMousePress =
false;
1978 if (!
d->pressClosedEditor)
1982 d->pressClosedEditor =
false;
1990 QStyleOptionViewItem
option;
1992 if (
d->pressedAlreadySelected)
2010 if (!
index.isValid()
2011 || !
d->isIndexEnabled(
index)
2012 || (
d->pressedIndex !=
index)) {
2026 d->releaseFromDoubleClick =
true;
2029#if QT_CONFIG(draganddrop)
2038void QAbstractItemView::dragEnterEvent(QDragEnterEvent *
event)
2040 if (dragDropMode() == InternalMove
2044 if (d_func()->canDrop(
event)) {
2060void QAbstractItemView::dragMoveEvent(QDragMoveEvent *
event)
2063 d->draggedPosition =
event->position().toPoint() +
d->offset();
2064 if (dragDropMode() == InternalMove
2076 if (
index.isValid() &&
d->showDropIndicator) {
2078 d->dropIndicatorPosition =
d->position(
event->position().toPoint(),
rect,
index);
2079 switch (
d->dropIndicatorPosition) {
2081 if (
d->isIndexDropEnabled(
index.parent())) {
2083 event->acceptProposedAction();
2085 d->dropIndicatorRect =
QRect();
2089 if (
d->isIndexDropEnabled(
index.parent())) {
2091 event->acceptProposedAction();
2093 d->dropIndicatorRect =
QRect();
2097 if (
d->isIndexDropEnabled(
index)) {
2098 d->dropIndicatorRect =
rect;
2099 event->acceptProposedAction();
2101 d->dropIndicatorRect =
QRect();
2105 d->dropIndicatorRect =
QRect();
2107 event->acceptProposedAction();
2112 d->dropIndicatorRect =
QRect();
2113 d->dropIndicatorPosition = OnViewport;
2115 event->acceptProposedAction();
2118 d->viewport->update();
2121 if (
d->shouldAutoScroll(
event->position().toPoint()))
2134 if (
q->dragDropMode() == QAbstractItemView::InternalMove)
2156void QAbstractItemView::dragLeaveEvent(QDragLeaveEvent *)
2162 d->viewport->update();
2172void QAbstractItemView::dropEvent(QDropEvent *
event)
2175 if (dragDropMode() == InternalMove) {
2185 if (
d->model->dropMimeData(
event->mimeData(), action,
row, col,
index)) {
2186 if (action !=
event->dropAction()) {
2187 event->setDropAction(action);
2190 event->acceptProposedAction();
2196 d->viewport->update();
2210bool QAbstractItemViewPrivate::dropOn(QDropEvent *
event,
int *dropRow,
int *dropCol,
QModelIndex *dropIndex)
2213 if (
event->isAccepted())
2218 if (
viewport->rect().contains(
event->position().toPoint())) {
2220 if (!
index.isValid() || !
q->visualRect(
index).contains(
event->position().toPoint()))
2230 switch (dropIndicatorPosition) {
2231 case QAbstractItemView::AboveItem:
2233 col =
index.column();
2236 case QAbstractItemView::BelowItem:
2238 col =
index.column();
2241 case QAbstractItemView::OnItem:
2242 case QAbstractItemView::OnViewport:
2246 dropIndicatorPosition = QAbstractItemView::OnViewport;
2257QAbstractItemView::DropIndicatorPosition
2260 QAbstractItemView::DropIndicatorPosition
r = QAbstractItemView::OnViewport;
2263 if (
pos.y() -
rect.top() < margin) {
2264 r = QAbstractItemView::AboveItem;
2265 }
else if (
rect.bottom() -
pos.y() < margin) {
2266 r = QAbstractItemView::BelowItem;
2267 }
else if (
rect.contains(
pos,
true)) {
2268 r = QAbstractItemView::OnItem;
2272 touchingRect.
adjust(-1, -1, 1, 1);
2273 if (touchingRect.contains(
pos,
false)) {
2274 r = QAbstractItemView::OnItem;
2279 r =
pos.y() <
rect.center().y() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem;
2295 QAbstractScrollArea::focusInEvent(
event);
2301 && !
d->currentIndexSet
2302 && !currentIndexValid) {
2304 d->autoScroll =
false;
2308 currentIndexValid =
true;
2313 if (
model && currentIndexValid)
2315 else if (!currentIndexValid)
2318 d->viewport->update();
2330 QAbstractScrollArea::focusOutEvent(
event);
2331 d->viewport->update();
2348 d->delayedAutoScroll.stop();
2350#ifdef QT_KEYPAD_NAVIGATION
2351 switch (
event->key()) {
2353 if (QApplicationPrivate::keypadNavigationEnabled()) {
2354 if (!hasEditFocus()) {
2361 if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()) {
2362 setEditFocus(
false);
2372 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()
2381 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()
2382 && (QWidgetPrivate::canKeypadNavigate(
Qt::Horizontal) || QWidgetPrivate::inTabWidget(
this))) {
2388 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
2395#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)
2398 if (
index.isValid() &&
d->model) {
2408 d->moveCursorUpdatedView =
false;
2409 switch (
event->key()) {
2435 if (
d->tabKeyNavigation)
2439 if (
d->tabKeyNavigation)
2445 if (newCurrent != oldCurrent && newCurrent.
isValid() &&
d->isIndexEnabled(newCurrent)) {
2454 if (!
d->currentSelectionStartIndex.isValid())
2455 d->currentSelectionStartIndex = oldCurrent;
2459 d->selectionModel->setCurrentIndex(newCurrent, command);
2460 d->currentSelectionStartIndex = newCurrent;
2461 if (newCurrent.isValid()) {
2472 switch (
event->key()) {
2476#ifdef QT_KEYPAD_NAVIGATION
2477 if (QApplicationPrivate::keypadNavigationEnabled()
2485#ifdef QT_KEYPAD_NAVIGATION
2488 || (QWidgetPrivate::inTabWidget(
this) &&
d->model->columnCount(
d->root) > 1))) {
2507 if (
d->selectionModel)
2514#ifdef QT_KEYPAD_NAVIGATION
2552#ifndef QT_NO_SHORTCUT
2573 if (
d->moveCursorUpdatedView)
2585 QAbstractScrollArea::resizeEvent(
event);
2598 if (
event->timerId() ==
d->fetchMoreTimer.timerId())
2600 else if (
event->timerId() ==
d->delayedReset.timerId())
2602 else if (
event->timerId() ==
d->autoScrollTimer.timerId())
2604 else if (
event->timerId() ==
d->updateTimer.timerId())
2605 d->updateDirtyRegion();
2606 else if (
event->timerId() ==
d->delayedEditing.timerId()) {
2607 d->delayedEditing.stop();
2609 }
else if (
event->timerId() ==
d->delayedLayout.timerId()) {
2610 d->delayedLayout.stop();
2612 d->interruptDelayedItemsLayout();
2618 }
else if (
event->timerId() ==
d->delayedAutoScroll.timerId()) {
2619 d->delayedAutoScroll.stop();
2622 if (
d->pressedIndex.isValid() &&
d->pressedIndex ==
currentIndex())
2624 }
else if (
event->timerId() ==
d->pressClosedEditorWatcher.timerId()) {
2625 d->pressClosedEditorWatcher.stop();
2641 bool forwardEventToEditor =
false;
2642 const bool commit = !
event->commitString().isEmpty();
2643 const bool preediting = !
event->preeditString().isEmpty();
2645 if (
d->waitForIMCommit) {
2646 if (
commit || !preediting) {
2648 d->waitForIMCommit =
false;
2654 d->selectAllInEditor(currentEditor);
2657 currentEditor->setFocus();
2664 }
else if (preediting) {
2666 d->waitForIMCommit =
true;
2668 forwardEventToEditor =
true;
2674 d->waitForIMCommit =
false;
2678 }
else if (
QWidget *currentEditor; forwardEventToEditor
2684#if QT_CONFIG(draganddrop)
2708QAbstractItemView::DropIndicatorPosition QAbstractItemView::dropIndicatorPosition()
const
2711 return d->dropIndicatorPosition;
2726 if (
d->selectionModel) {
2727 indexes =
d->selectionModel->selectedIndexes();
2753 if (!
d->isIndexValid(
index))
2756 if (
QWidget *
w = (
d->persistent.isEmpty() ?
static_cast<QWidget*
>(
nullptr) :
d->editorForIndex(
index).widget.data())) {
2759 if (!
d->waitForIMCommit)
2767 d->delayedEditing.stop();
2768 d->delayedAutoScroll.stop();
2770 d->delayedEditing.stop();
2781 if (!safeIndex.isValid()) {
2786 EditTriggers lastTrigger =
d->lastTrigger;
2787 d->lastTrigger = trigger;
2789 if (!
d->shouldEdit(trigger,
d->model->buddy(safeIndex)))
2792 if (
d->delayedEditing.isActive())
2804 d->openEditor(safeIndex,
d->shouldForwardEvent(trigger,
event) ?
event :
nullptr);
2826 if (
d->editorIndexHash.isEmpty())
2828 if (
d->delayedPendingLayout) {
2830 d->executePostedLayout();
2833 QStyleOptionViewItem
option;
2838 while (
it !=
d->editorIndexHash.
end()) {
2841 if (
index.isValid() && editor) {
2843 if (
option.rect.isValid()) {
2849 editorsToHide << editor;
2855 editorsToRelease << editor;
2861 for (
int i = 0;
i < editorsToHide.size(); ++
i) {
2862 editorsToHide.at(
i)->hide();
2864 for (
int i = 0;
i < editorsToRelease.size(); ++
i) {
2865 d->releaseEditor(editorsToRelease.at(
i));
2878 d->fetchMoreTimer.start(0,
this);
2879 d->updateGeometry();
2888 if (verticalScrollBar()->maximum() ==
value &&
d->model->canFetchMore(
d->root))
2889 d->model->fetchMore(
d->root);
2892 d->checkMouseMove(posInVp);
2901 if (horizontalScrollBar()->maximum() ==
value &&
d->model->canFetchMore(
d->root))
2902 d->model->fetchMore(
d->root);
2905 d->checkMouseMove(posInVp);
2939 const bool isPersistent =
d->persistent.contains(editor);
2941 if (!
index.isValid()) {
2942 if (!editor->isVisible()) {
2950 qWarning(
"QAbstractItemView::closeEditor called with an editor that does not belong to this view");
2954 const bool hadFocus = editor->hasFocus();
2958 d->pressClosedEditorWatcher.start(0,
this);
2959 d->lastEditedIndex =
index;
2961 if (!isPersistent) {
2965 d->removeEditor(editor);
2971 editor->clearFocus();
2973 d->checkPersistentEditorFocus();
2976 QPointer<QWidget> ed = editor;
2980 if (!isPersistent && editor)
2981 d->releaseEditor(editor,
index);
2992 if (
index.isValid()) {
2994 d->selectionModel->setCurrentIndex(persistent,
flags);
3002 if (
index.isValid()) {
3004 d->selectionModel->setCurrentIndex(persistent,
flags);
3029 if (!editor || !
d->itemDelegate ||
d->currentlyCommittingEditor)
3032 if (!
index.isValid()) {
3033 qWarning(
"QAbstractItemView::commitData called with an editor that does not belong to this view");
3036 d->currentlyCommittingEditor = editor;
3038 editor->removeEventFilter(delegate);
3040 editor->installEventFilter(delegate);
3041 d->currentlyCommittingEditor =
nullptr;
3054 d->persistent.remove(
w);
3072 if (!
d->model->rowCount(
d->root) || !
d->model->columnCount(
d->root))
3076 :
d->model->index(0, 0,
d->root);
3077 bool skipRow =
false;
3078 bool keyboardTimeWasValid =
d->keyboardInputTime.isValid();
3079 qint64 keyboardInputTimeElapsed;
3080 if (keyboardTimeWasValid)
3081 keyboardInputTimeElapsed =
d->keyboardInputTime.restart();
3083 d->keyboardInputTime.start();
3084 if (search.
isEmpty() || !keyboardTimeWasValid
3086 d->keyboardInput = search;
3089 d->keyboardInput += search;
3093 bool sameKey =
false;
3094 if (
d->keyboardInput.size() > 1) {
3095 int c =
d->keyboardInput.
count(
d->keyboardInput.at(
d->keyboardInput.size() - 1));
3096 sameKey = (
c ==
d->keyboardInput.size());
3104 int newRow = (
start.row() <
d->model->rowCount(parent) - 1) ?
start.row() + 1 : 0;
3105 start =
d->model->index(newRow,
start.column(), parent);
3116 if (
match == previous)
3118 firstMatch =
match.value(0);
3120 if (firstMatch.isValid()) {
3121 if (
d->isIndexEnabled(firstMatch)) {
3125 int row = firstMatch.row() + 1;
3126 if (
row >=
d->model->rowCount(firstMatch.parent()))
3128 current = firstMatch.
sibling(
row, firstMatch.column());
3131 if (!startMatch.isValid())
3132 startMatch = firstMatch;
3133 else if (startMatch == firstMatch)
3148 if (!
d->isIndexValid(
index))
3151 QStyleOptionViewItem
option;
3176 if (row < 0 || row >=
d->model->rowCount(
d->root))
3181 QStyleOptionViewItem
option;
3184 int colCount =
d->model->columnCount(
d->root);
3185 for (
int c = 0;
c < colCount; ++
c) {
3187 if (
QWidget *editor =
d->editorForIndex(
index).widget.data())
3207 if (column < 0 || column >=
d->model->columnCount(
d->root))
3212 QStyleOptionViewItem
option;
3215 int rows =
d->model->rowCount(
d->root);
3216 for (
int r = 0;
r < rows; ++
r) {
3218 if (
QWidget *editor =
d->editorForIndex(
index).widget.data())
3235 QStyleOptionViewItem options;
3243 d->persistent.insert(editor);
3255 if (
QWidget *editor =
d->editorForIndex(
index).widget.data()) {
3258 d->persistent.remove(editor);
3259 d->removeEditor(editor);
3260 d->releaseEditor(editor,
index);
3274 return d->editorForIndex(
index).widget;
3306 if (!
d->isIndexValid(
index))
3311 d->persistent.remove(oldWidget);
3312 d->removeEditor(oldWidget);
3313 oldWidget->removeEventFilter(
this);
3314 oldWidget->deleteLater();
3323 if (!
d->delayedPendingLayout) {
3325 d->doDelayedItemsLayout();
3338 if (
d->isIndexValid(
index))
3339 if (
QWidget *editor =
d->editorForIndex(
index).widget.data())
3354 verticalScrollBar()->setValue(verticalScrollBar()->minimum());
3367 if (
d->delayedPendingLayout) {
3368 d->executePostedLayout();
3371 verticalScrollBar()->setValue(verticalScrollBar()->maximum());
3383 if (
index.isValid()) {
3388 if (
d->viewport->rect().intersects(
rect))
3389 d->viewport->update(
rect);
3404 const QList<int> &roles)
3409 if (topLeft == bottomRight && topLeft.
isValid()) {
3410 const QEditorInfo &editorInfo =
d->editorForIndex(topLeft);
3412 if (!editorInfo.isStatic && editorInfo.widget) {
3418 if (
isVisible() && !
d->delayedPendingLayout) {
3423 d->updateEditorData(topLeft, bottomRight);
3424 if (
isVisible() && !
d->delayedPendingLayout) {
3427 topLeft.
row() > bottomRight.
row() ||
3430 d->viewport->update();
3432 const QRect updateRect =
d->intersectedRect(
d->viewport->rect(), topLeft, bottomRight);
3434 d->viewport->update(updateRect);
3439#if QT_CONFIG(accessibility)
3440 if (QAccessible::isActive()) {
3441 QAccessibleTableModelChangeEvent accessibleEvent(
this, QAccessibleTableModelChangeEvent::DataChanged);
3442 accessibleEvent.setFirstRow(topLeft.
row());
3443 accessibleEvent.setFirstColumn(topLeft.
column());
3444 accessibleEvent.setLastRow(bottomRight.
row());
3445 accessibleEvent.setLastColumn(bottomRight.
column());
3446 QAccessible::updateAccessibility(&accessibleEvent);
3449 d->updateGeometry();
3463 d_func()->fetchMoreTimer.start(0,
this);
3486 && current.
parent() == parent) {
3487 int totalToRemove =
end -
start + 1;
3488 if (
d->model->rowCount(parent) <= totalToRemove) {
3497 const int rowCount =
d->model->rowCount(parent);
3500 while (
row < rowCount && !found) {
3503 if (!
next.isValid()) {
3504 qWarning(
"Model unexpectedly returned an invalid index");
3520 if (!
next.isValid()) {
3521 qWarning(
"Model unexpectedly returned an invalid index");
3537 while (
child.isValid()) {
3538 const auto parentIndex =
child.parent();
3539 if (parentIndex == parent)
3541 child = parentIndex;
3546 while (
i !=
d->editorIndexHash.end()) {
3549 if (directChild.isValid() && directChild.row() >=
start && directChild.row() <=
end) {
3552 i =
d->editorIndexHash.erase(
i);
3554 d->releaseEditor(editor,
index);
3576 q->updateEditorGeometries();
3578#if QT_CONFIG(accessibility)
3579 if (QAccessible::isActive()) {
3580 QAccessibleTableModelChangeEvent accessibleEvent(
q, QAccessibleTableModelChangeEvent::RowsRemoved);
3581 accessibleEvent.setFirstRow(
start);
3582 accessibleEvent.setLastRow(
end);
3583 QAccessible::updateAccessibility(&accessibleEvent);
3608 int totalToRemove =
end -
start + 1;
3613 if (
index.isValid())
3614 q->setCurrentIndex(
index);
3620 while (
column < columnCount) {
3623 if (!
next.isValid()) {
3624 qWarning(
"Model unexpectedly returned an invalid index");
3631 q->setCurrentIndex(
next);
3667 q->updateEditorGeometries();
3669#if QT_CONFIG(accessibility)
3670 if (QAccessible::isActive()) {
3671 QAccessibleTableModelChangeEvent accessibleEvent(
q, QAccessibleTableModelChangeEvent::ColumnsRemoved);
3672 accessibleEvent.setFirstColumn(
start);
3673 accessibleEvent.setLastColumn(
end);
3674 QAccessible::updateAccessibility(&accessibleEvent);
3692#if QT_CONFIG(accessibility)
3694 if (QAccessible::isActive()) {
3695 QAccessibleTableModelChangeEvent accessibleEvent(
q, QAccessibleTableModelChangeEvent::RowsInserted);
3696 accessibleEvent.setFirstRow(
start);
3697 accessibleEvent.setLastRow(
end);
3698 QAccessible::updateAccessibility(&accessibleEvent);
3717 q->updateEditorGeometries();
3718#if QT_CONFIG(accessibility)
3719 if (QAccessible::isActive()) {
3720 QAccessibleTableModelChangeEvent accessibleEvent(
q, QAccessibleTableModelChangeEvent::ColumnsInserted);
3721 accessibleEvent.setFirstColumn(
start);
3722 accessibleEvent.setLastColumn(
end);
3723 QAccessible::updateAccessibility(&accessibleEvent);
3746#if QT_CONFIG(accessibility)
3748 if (QAccessible::isActive()) {
3749 QAccessibleTableModelChangeEvent accessibleEvent(
q, QAccessibleTableModelChangeEvent::ModelReset);
3750 QAccessible::updateAccessibility(&accessibleEvent);
3769 const auto parentIdx = topLeft.
parent();
3771 for (
int r = topLeft.
row();
r <= bottomRight.
row(); ++
r) {
3809 QWidget *editor =
d->editorForIndex(buddy).widget.data();
3810 if (editor && !
d->persistent.contains(editor)) {
3812 if (current.
row() != previous.
row())
3822 if (current.
isValid() && !
d->autoScrollTimer.isActive()) {
3828 if (current.
row() == (
d->model->rowCount(
d->root) - 1))
3831 d->shouldScrollToCurrentOnShow =
d->autoScroll;
3837#if QT_CONFIG(draganddrop)
3841void QAbstractItemView::startDrag(Qt::DropActions supportedActions)
3845 if (indexes.
size() > 0) {
3857 if (dragDropMode() == InternalMove)
3858 supportedActions &=
~Qt::CopyAction;
3859 if (
d->defaultDropAction !=
Qt::IgnoreAction && (supportedActions &
d->defaultDropAction))
3860 defaultDropAction =
d->defaultDropAction;
3861 else if (supportedActions &
Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove)
3863 d->dropEventMoved =
false;
3864 if (drag->
exec(supportedActions, defaultDropAction) ==
Qt::MoveAction && !
d->dropEventMoved) {
3865 if (dragDropMode() != InternalMove || drag->
target() ==
viewport())
3868 d->dropEventMoved =
false;
3870 d->dropIndicatorRect =
QRect();
3871 d->dropIndicatorPosition = OnItem;
3899 if (
d->iconSize.isValid()) {
3900 option->decorationSize =
d->iconSize;
3905 option->decorationPosition = QStyleOptionViewItem::Left;
3908 option->textElideMode =
d->textElideMode;
3911 if (
d->wrapItemText)
3912 option->features = QStyleOptionViewItem::WrapText;
3913 option->locale = locale();
3952 d->doDelayedItemsLayout();
3964 d->executePostedLayout();
3980 d->setDirtyRegion(region);
3996 d->scrollDirtyRegion(dx, dy);
4011 return d->scrollDelayOffset;
4019 d_func()->startAutoScroll();
4027 d_func()->stopAutoScroll();
4037 QScrollBar *verticalScroll = verticalScrollBar();
4038 QScrollBar *horizontalScroll = horizontalScrollBar();
4042 QHeaderView *hv = qobject_cast<QHeaderView*>(
this);
4044 QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea*>(parentWidget());
4047 if (!hv->horizontalScrollBar() || !hv->horizontalScrollBar()->isVisible())
4048 horizontalScroll = parent->horizontalScrollBar();
4050 if (!hv->verticalScrollBar() || !hv->verticalScrollBar()->isVisible())
4051 verticalScroll = parent->verticalScrollBar();
4056 const int verticalStep = verticalScroll->
pageStep();
4057 const int horizontalStep = horizontalScroll->
pageStep();
4058 if (
d->autoScrollCount <
qMax(verticalStep, horizontalStep))
4059 ++
d->autoScrollCount;
4061 const int margin =
d->autoScrollMargin;
4062 const int verticalValue = verticalScroll->
value();
4063 const int horizontalValue = horizontalScroll->
value();
4065 const QPoint pos =
d->draggedPosition -
d->offset();
4069 if (
pos.y() -
area.top() < margin)
4070 verticalScroll->
setValue(verticalValue -
d->autoScrollCount);
4071 else if (
area.bottom() -
pos.y() < margin)
4072 verticalScroll->
setValue(verticalValue +
d->autoScrollCount);
4073 if (
pos.x() -
area.left() < margin)
4074 horizontalScroll->
setValue(horizontalValue -
d->autoScrollCount);
4075 else if (
area.right() -
pos.x() < margin)
4076 horizontalScroll->
setValue(horizontalValue +
d->autoScrollCount);
4078 const bool verticalUnchanged = (verticalValue == verticalScroll->
value());
4079 const bool horizontalUnchanged = (horizontalValue == horizontalScroll->
value());
4080 if (verticalUnchanged && horizontalUnchanged) {
4083#if QT_CONFIG(draganddrop)
4084 d->dropIndicatorRect =
QRect();
4085 d->dropIndicatorPosition = QAbstractItemView::OnViewport;
4091 const QPoint globalPos =
d->viewport->mapToGlobal(
pos);
4092 const QPoint windowPos =
window()->mapFromGlobal(globalPos);
4105 d->draggedPosition =
pos +
d->offset();
4111 d->viewport->update();
4129 Qt::KeyboardModifiers keyModifiers =
event &&
event->isInputEvent()
4132 switch (
d->selectionMode) {
4137 switch (
event->type()) {
4140 if (
d->pressedAlreadySelected)
4145 if (!
index.isValid())
4163 return d->contiguousSelectionCommand(
index,
event);
4174 switch (
event->type()) {
4185 || !dragEnabled || !isIndexDragEnabled(
index)
4195 && dragEnabled && isIndexDragEnabled(
index)
4218 Qt::KeyboardModifiers
modifiers =
event &&
event->isInputEvent()
4222 switch (
event->type()) {
4235 if ((shiftKeyPressed || controlKeyPressed) && rightButtonPressed)
4237 if (!shiftKeyPressed && !controlKeyPressed && indexIsSelected)
4239 if (!
index.isValid() && !rightButtonPressed && !shiftKeyPressed && !controlKeyPressed)
4241 if (!
index.isValid())
4246 && dragEnabled && isIndexDragEnabled(
index)
4261 && !shiftKeyPressed && !controlKeyPressed && (!rightButtonPressed || !
index.isValid()))
4265 && dragEnabled && isIndexDragEnabled(
index)
4288#ifdef QT_KEYPAD_NAVIGATION
4323QItemSelectionModel::SelectionFlags
4332 switch (
flags & Mask) {
4350 fetchMoreTimer.
stop();
4368 if (!
index.isValid())
4391 switch (
event->type()) {
4420 delayedLayout.
start(delay, q_func());
4426 delayedLayout.
stop();
4433 if (sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored)
4435 if (sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents || !shownOnce)
4436 q->updateGeometry();
4449#if QT_CONFIG(lineedit)
4453#if QT_CONFIG(spinbox)
4462 const QStyleOptionViewItem &options)
4472 w->installEventFilter(delegate);
4505 ||
index.parent() != parent)))
4526#if QT_CONFIG(draganddrop)
4533 if ((*it).left() != 0)
4537 int count = (*it).bottom() - (*it).top() + 1;
4538 model->removeRows((*it).top(),
count, parent);
4568 q->setCurrentIndex(
index);
4630 QStyleOptionViewItem options;
4631 q->initViewItemOption(&options);
4632 options.rect =
q->visualRect(buddy);
4643 QStyleOptionViewItem options;
4644 q->initViewItemOption(&options);
4645 options.rect =
q->visualRect(buddy);
4657 q->updateMicroFocus();
4678 for (
const auto &
index : indexes) {
4687 rect.setRight(clipped.right());
4696 if (paintPairs.isEmpty())
4707 QStyleOptionViewItem
option;
4708 q->initViewItemOption(&
option);
4710 for (
int j = 0;
j < paintPairs.size(); ++
j) {
4711 option.rect = paintPairs.at(
j).rect.translated(-
r->topLeft());
4714 q->itemDelegateForIndex(current)->paint(&
painter,
option, current);
4735#if QT_CONFIG(draganddrop)
4736QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes()
const
4741 return !isIndexDragEnabled(
index);
4743 indexes.
removeIf(isNotDragEnabled);
4747void QAbstractItemViewPrivate::maybeStartDrag(
QPoint eventPosition)
4757 q->stopAutoScroll();
4770 return QAbstractScrollArea::eventFilter(
object,
event);
4776 return QAbstractScrollArea::eventFilter(
object,
event);
4783#include "moc_qabstractitemview.cpp"
The QAbstractItemDelegate class is used to display and edit data items from a model.
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const =0
This pure abstract function must be reimplemented if you want to provide custom rendering.
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Returns the editor to be used for editing the data item with the given index.
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
Updates the geometry of the editor for the item with the given index, according to the rectangle spec...
void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint=NoHint)
This signal is emitted when the user has finished editing an item using the specified editor.
void commitData(QWidget *editor)
This signal must be emitted when the editor widget has completed editing the data,...
virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
When editing of an item starts, this function is called with the event that triggered the editing,...
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const
Sets the contents of the given editor to the data for the item at the given index.
EndEditHint
This enum describes the different hints that the delegate can give to the model and view components t...
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Sets the data for the item at the given index in the model to the contents of the given editor.
void sizeHintChanged(const QModelIndex &)
virtual bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index)
static QAbstractItemModel * staticEmptyModel()
virtual Qt::DropActions supportedDropActions() const
void rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow, QPrivateSignal)
Q_INVOKABLE int const QModelIndex & parent
Returns the parent of the model item with the given index.
void columnsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been removed from the model.
virtual Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
void modelReset(QPrivateSignal)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
This signal is emitted whenever the data in an existing item changes.
virtual Q_INVOKABLE bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Returns {true} if parent has any children; otherwise returns {false}.
virtual Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
virtual Q_INVOKABLE void fetchMore(const QModelIndex &parent)
Fetches any available data for the items with the parent specified by the parent index.
void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before columns are removed from the model.
void layoutChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
virtual QModelIndex buddy(const QModelIndex &index) const
Returns a model index for the buddy of the item represented by index.
bool checkIndex(const QModelIndex &index, CheckIndexOptions options=CheckIndexOption::NoOption) const
virtual Q_INVOKABLE bool canFetchMore(const QModelIndex &parent) const
Returns {true} if there is more data available for parent; otherwise returns {false}.
void headerDataChanged(Qt::Orientation orientation, int first, int last)
This signal is emitted whenever a header is changed.
void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before rows are removed from the model.
virtual QMap< int, QVariant > itemData(const QModelIndex &index) const
Returns a map with values for all predefined roles in the model for the item at the given index.
virtual bool setItemData(const QModelIndex &index, const QMap< int, QVariant > &roles)
Sets the role data for the item at index to the associated value in roles, for every Qt::ItemDataRole...
virtual Qt::DropActions supportedDragActions() const
Returns the actions supported by the data in this model.
virtual Q_INVOKABLE int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
void rowsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been inserted into the model.
void columnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn, QPrivateSignal)
void columnsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been inserted into the model.
virtual Q_INVOKABLE QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const =0
Returns the data stored under the given role for the item referred to by the index.
virtual Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index.
void rowsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been removed from the model.
virtual void layoutChanged()
const QEditorInfo & editorForIndex(const QModelIndex &index) const
virtual QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const
void doDelayedItemsLayout(int delay=0)
QItemSelectionModel::SelectionFlags contiguousSelectionCommand(const QModelIndex &index, const QEvent *event) const
virtual void columnsMoved(const QModelIndex &source, int sourceStart, int sourceEnd, const QModelIndex &destination, int destinationStart)
void interruptDelayedItemsLayout() const
virtual void adjustViewOptionsForIndex(QStyleOptionViewItem *, const QModelIndex &) const
void removeEditor(QWidget *editor)
virtual void rowsRemoved(const QModelIndex &parent, int start, int end)
QSet< QWidget * > persistent
void scrollerStateChanged()
void updateEditorData(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void checkPersistentEditorFocus()
bool hasEditor(const QModelIndex &index) const
QPointer< QAbstractItemDelegate > itemDelegate
bool delayedPendingLayout
void addEditor(const QModelIndex &index, QWidget *editor, bool isStatic)
QMap< int, QPointer< QAbstractItemDelegate > > columnDelegates
QIndexEditorHash indexEditorHash
QAbstractItemView::EditTriggers editTriggers
QAbstractItemViewPrivate()
virtual QRect intersectedRect(const QRect rect, const QModelIndex &topLeft, const QModelIndex &bottomRight) const
bool viewportEnteredNeeded
bool shouldEdit(QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const
QElapsedTimer keyboardInputTime
QAbstractItemView::ScrollMode horizontalScrollMode
QMap< int, QPointer< QAbstractItemDelegate > > rowDelegates
void setHoverIndex(const QPersistentModelIndex &index)
virtual void columnsInserted(const QModelIndex &parent, int start, int end)
QAbstractItemView::State state
QPointer< QItemSelectionModel > selectionModel
virtual ~QAbstractItemViewPrivate()
void delegateSizeHintChanged(const QModelIndex &index)
bool shouldAutoScroll(const QPoint &pos) const
bool shouldForwardEvent(QAbstractItemView::EditTrigger trigger, const QEvent *event) const
QItemSelectionModel::SelectionFlags selectionBehaviorFlags() const
QPersistentModelIndex root
bool droppingOnItself(QDropEvent *event, const QModelIndex &index)
std::array< QMetaObject::Connection, 4 > scrollbarConnections
bool openEditor(const QModelIndex &index, QEvent *event)
virtual QRect visualRect(const QModelIndex &index) const
void checkMouseMove(const QPersistentModelIndex &index)
QPersistentModelIndex pressedIndex
QPixmap renderToPixmap(const QModelIndexList &indexes, QRect *r) const
QAbstractItemModel * model
QAbstractItemView::SelectionMode selectionMode
bool sendDelegateEvent(const QModelIndex &index, QEvent *event) const
virtual void columnsRemoved(const QModelIndex &parent, int start, int end)
QItemSelectionModel::SelectionFlags extendedSelectionCommand(const QModelIndex &index, const QEvent *event) const
virtual void modelDestroyed()
virtual void columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
QPersistentModelIndex enteredIndex
QItemSelectionModel::SelectionFlags multiSelectionCommand(const QModelIndex &index, const QEvent *event) const
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
QItemSelection oldSelection
bool shouldClearStatusTip
bool pressedAlreadySelected
void releaseEditor(QWidget *editor, const QModelIndex &index=QModelIndex()) const
QWidget * editor(const QModelIndex &index, const QStyleOptionViewItem &options)
virtual void selectAll(QItemSelectionModel::SelectionFlags command)
QEditorIndexHash editorIndexHash
QModelIndex indexForEditor(QWidget *editor) const
QAbstractItemView::SelectionBehavior selectionBehavior
QAbstractItemView::ScrollMode verticalScrollMode
QPersistentModelIndex hover
bool isIndexEnabled(const QModelIndex &index) const
virtual void rowsMoved(const QModelIndex &source, int sourceStart, int sourceEnd, const QModelIndex &destination, int destinationStart)
std::array< QMetaObject::Connection, 14 > modelConnections
void selectAllInEditor(QWidget *w)
The QAbstractItemView class provides the basic functionality for item view classes.
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
void inputMethodEvent(QInputMethodEvent *event) override
\reimp
void setVerticalScrollMode(ScrollMode mode)
SelectionMode
This enum indicates how the view responds to user selections:
QWidget * indexWidget(const QModelIndex &index) const
void activated(const QModelIndex &index)
This signal is emitted when the item specified by index is activated by the user.
virtual QRegion visualRegionForSelection(const QItemSelection &selection) const =0
Returns the region from the viewport of the items in the given selection.
void setEditTriggers(EditTriggers triggers)
void iconSizeChanged(const QSize &size)
virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)=0
Applies the selection flags to the items in or touched by the rectangle, rect.
QAbstractItemModel * model() const
Returns the model that this view is presenting.
virtual void horizontalScrollbarValueChanged(int value)
virtual int verticalOffset() const =0
Returns the vertical offset of the view.
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
void setItemDelegateForRow(int row, QAbstractItemDelegate *delegate)
void doubleClicked(const QModelIndex &index)
This signal is emitted when a mouse button is double-clicked.
bool event(QEvent *event) override
\reimp
virtual void setSelectionModel(QItemSelectionModel *selectionModel)
Sets the current selection model to the given selectionModel.
QPoint dirtyRegionOffset() const
Returns the offset of the dirty regions in the view.
void timerEvent(QTimerEvent *event) override
This function is called with the given event when a timer event is sent to the widget.
ScrollMode verticalScrollMode
how the view scrolls its contents in the vertical direction
virtual void verticalScrollbarAction(int action)
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
This slot is called when the selection is changed.
void focusOutEvent(QFocusEvent *event) override
This function is called with the given event when the widget loses the focus.
void setHorizontalScrollMode(ScrollMode mode)
SelectionBehavior
\value SelectItems Selecting single items.
void focusInEvent(QFocusEvent *event) override
This function is called with the given event when the widget obtains the focus.
State state() const
Returns the item view's state.
virtual void reset()
Reset the internal state of the view.
void mouseReleaseEvent(QMouseEvent *event) override
This function is called with the given event when a mouse button is released, after a mouse press eve...
void setTextElideMode(Qt::TextElideMode mode)
QAbstractItemView(QWidget *parent=nullptr)
Constructs an abstract item view with the given parent.
~QAbstractItemView()
Destroys the view.
void setItemDelegate(QAbstractItemDelegate *delegate)
Sets the item delegate for this view and its model to delegate.
virtual QAbstractItemDelegate * itemDelegateForIndex(const QModelIndex &index) const
bool hasAutoScroll() const
bool tabKeyNavigation
whether item navigation with tab and backtab is enabled.
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
This slot is called when items with the given roles are changed in the model.
bool eventFilter(QObject *object, QEvent *event) override
\reimp
QModelIndex currentIndex() const
Returns the model index of the current item.
bool viewportEvent(QEvent *event) override
This function is used to handle tool tips, and What's This? mode, if the given event is a QEvent::Too...
void setDirtyRegion(const QRegion ®ion)
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
This slot is called when rows are about to be removed.
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
EditTriggers editTriggers
which actions will initiate item editing
ScrollMode horizontalScrollMode
how the view scrolls its contents in the horizontal direction
void setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate)
virtual void updateEditorData()
State
Describes the different states the view can be in.
EditTrigger
This enum describes actions which will initiate item editing.
virtual void setRootIndex(const QModelIndex &index)
Sets the root item to the item at the given index.
void setAlternatingRowColors(bool enable)
virtual void initViewItemOption(QStyleOptionViewItem *option) const
bool focusNextPrevChild(bool next) override
\reimp
void setIconSize(const QSize &size)
virtual void doItemsLayout()
void scrollDirtyRegion(int dx, int dy)
Prepares the view for scrolling by ({dx},{dy}) pixels by moving the dirty regions in the opposite dir...
Qt::TextElideMode textElideMode
the position of the "..." in elided text.
void keyPressEvent(QKeyEvent *event) override
This function is called with the given event when a key event is sent to the widget.
void resetVerticalScrollMode()
virtual void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
Scrolls the view if necessary to ensure that the item at index is visible.
void update(const QModelIndex &index)
void setTabKeyNavigation(bool enable)
QModelIndex rootIndex() const
Returns the model index of the model's root item.
QAbstractItemDelegate * itemDelegateForRow(int row) const
QSize iconSize
the size of items' icons
void setAutoScroll(bool enable)
virtual int horizontalOffset() const =0
Returns the horizontal offset of the view.
void executeDelayedItemsLayout()
Executes the scheduled layouts without waiting for the event processing to begin.
QAbstractItemDelegate * itemDelegate() const
Returns the item delegate used by this view and model.
bool isPersistentEditorOpen(const QModelIndex &index) const
SelectionMode selectionMode
which selection mode the view operates in
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)=0
Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction...
void setIndexWidget(const QModelIndex &index, QWidget *widget)
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
This slot is called when a new item becomes the current item.
virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
Closes the given editor, and releases it.
bool alternatingRowColors
whether to draw the background using alternating colors
void resizeEvent(QResizeEvent *event) override
This function is called with the given event when a resize event is sent to the widget.
void scheduleDelayedItemsLayout()
Schedules a layout of the items in the view to be executed when the event processing starts.
void openPersistentEditor(const QModelIndex &index)
Opens a persistent editor on the item at the given index.
QSize sizeHintForIndex(const QModelIndex &index) const
Returns the size hint for the item with the specified index or an invalid size for invalid indexes.
virtual void commitData(QWidget *editor)
Commit the data in the editor to the model.
bool autoScroll
whether autoscrolling in drag move events is enabled
void pressed(const QModelIndex &index)
This signal is emitted when a mouse button is pressed.
virtual void keyboardSearch(const QString &search)
Moves to and selects the item best matching the string search.
void mousePressEvent(QMouseEvent *event) override
This function is called with the given event when a mouse button is pressed while the cursor is insid...
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
This slot is called when rows are inserted.
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
\reimp
virtual QModelIndexList selectedIndexes() const
This convenience function returns a list of all selected and non-hidden item indexes in the view.
virtual void selectAll()
Selects all items in the view.
void setAutoScrollMargin(int margin)
void clicked(const QModelIndex &index)
This signal is emitted when a mouse button is left-clicked.
int autoScrollMargin
the size of the area when auto scrolling is triggered
virtual void updateEditorGeometries()
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.
virtual bool isIndexHidden(const QModelIndex &index) const =0
Returns true if the item referred to by the given index is hidden in the view, otherwise returns fals...
void setState(State state)
Sets the item view's state to the given state.
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event=nullptr) const
Returns the SelectionFlags to be used when updating a selection model for the specified index.
virtual int sizeHintForColumn(int column) const
Returns the width size hint for the specified column or -1 if there is no model.
void clearSelection()
Deselects all selected items.
void mouseMoveEvent(QMouseEvent *event) override
This function is called with the given event when a mouse move event is sent to the widget.
QItemSelectionModel * selectionModel() const
Returns the current selection model.
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.
virtual void editorDestroyed(QObject *editor)
This function is called when the given editor has been destroyed.
void mouseDoubleClickEvent(QMouseEvent *event) override
This function is called with the given event when a mouse button is double clicked inside the widget.
QAbstractItemDelegate * itemDelegateForColumn(int column) const
void resetHorizontalScrollMode()
void closePersistentEditor(const QModelIndex &index)
Closes the persistent editor for the item at the given index.
void setSelectionMode(QAbstractItemView::SelectionMode mode)
virtual void verticalScrollbarValueChanged(int value)
virtual void updateGeometries()
SelectionBehavior selectionBehavior
which selection behavior the view uses
QSize viewportSizeHint() const override
virtual void horizontalScrollbarAction(int action)
virtual int sizeHintForRow(int row) const
Returns the height size hint for the specified row or -1 if there is no model.
int value
the slider's current value
void valueChanged(int value)
This signal is emitted when the slider value has changed, with the new slider value as argument.
int pageStep
the page step.
void actionTriggered(int action)
This signal is emitted when the slider action action is triggered.
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or \nullptr if no widget in this ap...
int doubleClickInterval
the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks
int startDragDistance
the minimum distance required for a drag and drop operation to start.
int keyboardInputInterval
the time limit in milliseconds that distinguishes a key press from two consecutive key presses
void start(int msec, QObject *obj)
\obsolete Use chrono overload instead.
void stop()
Stops the timer.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static void sendPostedEvents(QObject *receiver=nullptr, int event_type=0)
Immediately dispatches all events which have been previously queued with QCoreApplication::postEvent(...
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
The QDoubleSpinBox class provides a spin box widget that takes doubles.
void setHotSpot(const QPoint &hotspot)
Sets the position of the hot spot relative to the top-left corner of the pixmap used to the point spe...
Qt::DropAction exec(Qt::DropActions supportedActions=Qt::MoveAction)
void setMimeData(QMimeData *data)
Sets the data to be sent to the given MIME data.
void setPixmap(const QPixmap &)
Sets pixmap as the pixmap used to represent the data in a drag and drop operation.
QObject * target() const
Returns the target of the drag and drop operation.
void invalidate() noexcept
Marks this QElapsedTimer object as invalid.
@ ApplicationLayoutDirectionChange
The QFocusEvent class contains event parameters for widget focus events.
static QClipboard * clipboard()
Returns the object for interacting with the clipboard.
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
bool remove(const Key &key)
Removes the item that has the key from the hash.
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
const_iterator constFind(const Key &key) const noexcept
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it.
iterator erase(const_iterator it)
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
friend class const_iterator
const_iterator cend() const noexcept
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
The QHelpEvent class provides an event that is used to request helpful information about a particular...
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
This signal is emitted whenever the selection changes.
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
This signal is emitted whenever the current item changes.
Q_INVOKABLE bool isSelected(const QModelIndex &index) const
Returns true if the given model item index is selected.
virtual void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged().
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged().
QAbstractItemModel * model
Q_CORE_EXPORT QModelIndexList indexes() const
Returns a list of model indexes that correspond to the selected items.
The QKeyEvent class describes a key event.
The QLineEdit widget is a one-line text editor.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
const_iterator constBegin() const noexcept
qsizetype removeIf(Predicate pred)
void append(parameter_type t)
const_iterator constEnd() const noexcept
constexpr int row() const noexcept
Returns the row this model index refers to.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
constexpr const QAbstractItemModel * model() const noexcept
Returns a pointer to the model containing the item that this index refers to.
Qt::ItemFlags flags() const
constexpr int column() const noexcept
Returns the column this model index refers to.
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void deleteLater()
\threadsafe
The QPainter class performs low-level painting on widgets and other paint devices.
bool isValid() const
Returns {true} if this persistent model index is valid; otherwise returns {false}.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
T * data() const noexcept
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
bool intersects(const QRect &r) const noexcept
Returns true if this rectangle intersects with the given rectangle (i.e., there is at least one pixel...
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
QRect intersected(const QRect &other) const noexcept
constexpr void setLeft(int pos) noexcept
Sets the left edge of the rectangle to the given x coordinate.
The QRegion class specifies a clip region for a painter.
The QResizeEvent class contains event parameters for resize events.
bool remove(const T &value)
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
iterator erase(const_iterator i)
bool contains(const T &value) const
The QSpinBox class provides a spin box widget.
The QStatusTipEvent class provides an event that is used to show messages in a status bar.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype count(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
@ SH_ItemView_MovementWithoutUpdatingSelection
@ SH_ItemView_ActivateItemOnSingleClick
@ SH_ItemView_ShowDecorationSelected
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
void * data()
Returns a pointer to the contained object as a generic void* that can be written to.
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
bool canConvert(QMetaType targetType) const
EGLImageKHR int int EGLuint64KHR * modifiers
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ NavigationModeKeypadDirectional
@ NavigationModeKeypadTabOrder
@ MouseEventSynthesizedByQt
QList< QItemViewPaintPair > QItemViewPaintPairs
static jboolean copy(JNIEnv *, jobject)
DBusConnection * connection
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr auto emptyString
int qRound(qfloat16 d) noexcept
static int area(const QSize &s)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLint GLint GLint GLsizei GLsizei GLsizei GLboolean commit
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLenum GLenum GLenum GLenum GLenum scale
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define QT_CONFIG(feature)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
QSqlQueryModel * model
[16]
if(qFloatDistance(a, b)<(1<< 7))
[0]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]
view viewport() -> scroll(dx, dy, deviceRect)
QItemSelection * selection
[0]
app setAttribute(Qt::AA_DontShowIconsInMenus)
QPointer< QWidget > widget
bool contains(const AT &t) const noexcept