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);
106 q,
SLOT(verticalScrollbarAction(
int)));
108 q,
SLOT(horizontalScrollbarAction(
int)));
110 q,
SLOT(verticalScrollbarValueChanged(
int)));
112 q,
SLOT(horizontalScrollbarValueChanged(
int)));
148 if (
index.isValid()) {
150#if QT_CONFIG(statustip)
159#if QT_CONFIG(statustip)
166 emit q->viewportEntered();
172#if QT_CONFIG(gestures) && QT_CONFIG(scroller)
183 if (
q->selectionModel()) {
191 if (
q->selectionModel()) {
216 qWarning(
"Delegate size hint changed for a model index that does not belong to this view");
615 : QAbstractScrollArea(dd,
parent)
627 d->delayedReset.stop();
628 d->updateTimer.stop();
629 d->delayedEditing.stop();
630 d->delayedAutoScroll.stop();
631 d->autoScrollTimer.stop();
632 d->delayedLayout.stop();
633 d->fetchMoreTimer.stop();
663 this,
SLOT(_q_modelDestroyed()));
667 this,
SLOT(_q_headerDataChanged()));
694 this,
SLOT(_q_modelDestroyed()));
698 this,
SLOT(_q_headerDataChanged()));
759 qWarning(
"QAbstractItemView::setSelectionModel() failed: "
760 "Trying to set a selection model, which works on "
761 "a different model than the view.");
768 if (
d->selectionModel) {
770 oldSelection =
d->selectionModel->selection();
771 oldCurrentIndex =
d->selectionModel->currentIndex();
782 if (
d->selectionModel) {
801 return d->selectionModel;
822 if (delegate ==
d->itemDelegate)
825 if (
d->itemDelegate) {
826 if (
d->delegateRefCount(
d->itemDelegate) == 1) {
835 if (
d->delegateRefCount(delegate) == 0) {
842 d->itemDelegate = delegate;
844 d->doDelayedItemsLayout();
855 return d_func()->itemDelegate;
868 d->waitForIMCommit && (currentEditor =
d->editorForIndex(current).
widget)) {
872 if (
result.typeId() == QMetaType::QRect) {
881 result = QAbstractScrollArea::inputMethodQuery(
query);
910 if (
d->delegateRefCount(rowDelegate) == 1) {
916 d->rowDelegates.remove(
row);
919 if (
d->delegateRefCount(delegate) == 0) {
925 d->rowDelegates.insert(
row, delegate);
928 d->doDelayedItemsLayout();
943 return d->rowDelegates.value(
row,
nullptr);
970 if (
d->delegateRefCount(columnDelegate) == 1) {
976 d->columnDelegates.remove(
column);
979 if (
d->delegateRefCount(delegate) == 0) {
985 d->columnDelegates.insert(
column, delegate);
988 d->doDelayedItemsLayout();
1003 return d->columnDelegates.value(
column,
nullptr);
1024 return d->delegateForIndex(
index);
1040 d->selectionMode =
mode;
1046 return d->selectionMode;
1062 d->selectionBehavior = behavior;
1068 return d->selectionBehavior;
1088 if (
d->selectionModel && (!
index.isValid() ||
d->isIndexEnabled(
index))) {
1090 d->selectionModel->setCurrentIndex(
index, command);
1091 d->currentIndexSet =
true;
1093 d->currentSelectionStartIndex =
index;
1105 return d->selectionModel ?
d->selectionModel->currentIndex() :
QModelIndex();
1121 d->delayedReset.stop();
1124 d->releaseEditor(
info.widget.data(),
d->indexForEditor(
info.widget.data()));
1126 d->editorIndexHash.clear();
1127 d->indexEditorHash.clear();
1128 d->persistent.clear();
1129 d->currentIndexSet =
false;
1132 if (
d->selectionModel)
1133 d->selectionModel->reset();
1134#if QT_CONFIG(accessibility)
1135 if (QAccessible::isActive()) {
1136 QAccessibleTableModelChangeEvent accessibleEvent(
this, QAccessibleTableModelChangeEvent::ModelReset);
1137 QAccessible::updateAccessibility(&accessibleEvent);
1140 d->updateGeometry();
1152 qWarning(
"QAbstractItemView::setRootIndex failed : index must be from the currently set model");
1156 d->doDelayedItemsLayout();
1157 d->updateGeometry();
1186 |
d->selectionBehaviorFlags());
1190 if (
d->model->hasChildren(
d->root))
1214 qWarning(
"edit: index was invalid");
1227 if (
d->selectionModel)
1228 d->selectionModel->clearSelection();
1240 d->interruptDelayedItemsLayout();
1242 d->viewport->update();
1257 d->editTriggers = actions;
1263 return d->editTriggers;
1279 d->verticalScrollModeSet =
true;
1280 if (
mode ==
d->verticalScrollMode)
1283 d->verticalScrollMode =
mode;
1285 verticalScrollBar()->d_func()->itemviewChangeSingleStep(1);
1287 verticalScrollBar()->setSingleStep(-1);
1295 return d->verticalScrollMode;
1302 d_func()->verticalScrollModeSet =
false;
1318 d->horizontalScrollModeSet =
true;
1319 if (
mode ==
d->horizontalScrollMode)
1321 d->horizontalScrollMode =
mode;
1323 horizontalScrollBar()->d_func()->itemviewChangeSingleStep(1);
1325 horizontalScrollBar()->setSingleStep(-1);
1332 return d->horizontalScrollMode;
1339 d_func()->horizontalScrollModeSet =
false;
1342#if QT_CONFIG(draganddrop)
1364void QAbstractItemView::setDragDropOverwriteMode(
bool overwrite)
1367 d->overwrite = overwrite;
1370bool QAbstractItemView::dragDropOverwriteMode()
const
1373 return d->overwrite;
1400 return d->autoScroll;
1414 d->autoScrollMargin = margin;
1420 return d->autoScrollMargin;
1437 return d->tabKeyNavigation;
1446 return QAbstractScrollArea::viewportSizeHint();
1449#if QT_CONFIG(draganddrop)
1457void QAbstractItemView::setDropIndicatorShown(
bool enable)
1460 d->showDropIndicator =
enable;
1463bool QAbstractItemView::showDropIndicator()
const
1466 return d->showDropIndicator;
1476void QAbstractItemView::setDragEnabled(
bool enable)
1482bool QAbstractItemView::dragEnabled()
const
1485 return d->dragEnabled;
1515void QAbstractItemView::setDragDropMode(DragDropMode behavior)
1518 d->dragDropMode = behavior;
1519 setDragEnabled(behavior == DragOnly || behavior == DragDrop || behavior == InternalMove);
1520 setAcceptDrops(behavior == DropOnly || behavior == DragDrop || behavior == InternalMove);
1523QAbstractItemView::DragDropMode QAbstractItemView::dragDropMode()
const
1526 DragDropMode setBehavior =
d->dragDropMode;
1527 if (!dragEnabled() && !acceptDrops())
1530 if (dragEnabled() && !acceptDrops())
1533 if (!dragEnabled() && acceptDrops())
1536 if (dragEnabled() && acceptDrops()) {
1537 if (setBehavior == InternalMove)
1556void QAbstractItemView::setDefaultDropAction(
Qt::DropAction dropAction)
1559 d->defaultDropAction = dropAction;
1565 return d->defaultDropAction;
1583 d->alternatingColors =
enable;
1585 d->viewport->update();
1591 return d->alternatingColors;
1604 if (
size ==
d->iconSize)
1607 d->doDelayedItemsLayout();
1627 d->textElideMode =
mode;
1632 return d_func()->textElideMode;
1641 if (
d->tabKeyNavigation && isEnabled() &&
d->viewport->isEnabled()) {
1644 if (
event.isAccepted())
1647 return QAbstractScrollArea::focusNextPrevChild(
next);
1656 switch (
event->type()) {
1660 d->executePostedLayout();
1663 d->executePostedLayout();
1664 if (
d->shouldScrollToCurrentOnShow) {
1665 d->shouldScrollToCurrentOnShow =
false;
1680 if (!
d->verticalScrollModeSet)
1682 if (!
d->horizontalScrollModeSet)
1686 d->checkPersistentEditorFocus();
1689 d->doDelayedItemsLayout();
1694 return QAbstractScrollArea::event(
event);
1711 switch (
event->type()) {
1716 d->executePostedLayout();
1726 d->viewportEnteredNeeded =
true;
1730 #if QT_CONFIG(statustip)
1731 if (
d->shouldClearStatusTip &&
d->parent) {
1735 d->shouldClearStatusTip =
false;
1745 QStyleOptionViewItem
option;
1756 d->doDelayedItemsLayout();
1760 d->viewport->update();
1764#if QT_CONFIG(gestures) && QT_CONFIG(scroller)
1772 return QAbstractScrollArea::viewportEvent(
event);
1783 d->releaseFromDoubleClick =
false;
1784 d->delayedAutoScroll.stop();
1785 QPoint pos =
event->position().toPoint();
1789 d->pressClosedEditor =
d->pressClosedEditorWatcher.isActive() &&
d->lastEditedIndex ==
index;
1794 d->pressedAlreadySelected =
d->selectionModel->isSelected(
index);
1796 d->pressedModifiers =
event->modifiers();
1802#if QT_CONFIG(draganddrop)
1805 d->pressedPosition =
d->draggedPosition;
1810 d->currentSelectionStartIndex =
index;
1812 else if (!
d->currentSelectionStartIndex.isValid())
1818 if (
index.isValid() &&
d->isIndexEnabled(
index)) {
1822 d->autoScroll =
false;
1828 command |=
d->ctrlDragSelectionFlag;
1840 if (
d->autoScroll) {
1860 QPoint bottomRight =
event->position().toPoint();
1862 d->draggedPosition = bottomRight +
d->offset();
1867#if QT_CONFIG(draganddrop)
1869 d->maybeStartDrag(bottomRight);
1881 d->selectionMode !=
SingleSelection ?
d->pressedPosition -
d->offset() : bottomRight;
1883 d->checkMouseMove(
index);
1885#if QT_CONFIG(draganddrop)
1886 if (
d->pressedIndex.isValid()
1890 && !
d->selectedDraggableIndexes().isEmpty()) {
1892 d->maybeStartDrag(bottomRight);
1902 command |=
d->ctrlDragSelectionFlag;
1906 QRect selectionRect =
QRect(topLeft, bottomRight);
1910 if (
index.isValid() && (
index !=
d->selectionModel->currentIndex()) &&
d->isIndexEnabled(
index))
1912 else if (
d->shouldAutoScroll(
event->pos()) && !
d->autoScrollTimer.isActive())
1927 const bool releaseFromDoubleClick =
d->releaseFromDoubleClick;
1928 d->releaseFromDoubleClick =
false;
1930 QPoint pos =
event->position().toPoint();
1934 if (
d->isIndexValid(
index)
1935 &&
d->isIndexEnabled(
index)
1941 bool click = (
index ==
d->pressedIndex &&
index.isValid() && !releaseFromDoubleClick);
1942 bool selectedClicked = click &&
d->pressedAlreadySelected
1946 const bool edited = click && !
d->pressClosedEditor ?
edit(
index, trigger,
event) :
false;
1950 if (
d->selectionModel &&
d->noSelectionOnMousePress) {
1951 d->noSelectionOnMousePress =
false;
1952 if (!
d->pressClosedEditor)
1956 d->pressClosedEditor =
false;
1964 QStyleOptionViewItem
option;
1966 if (
d->pressedAlreadySelected)
1984 if (!
index.isValid()
1985 || !
d->isIndexEnabled(
index)
1986 || (
d->pressedIndex !=
index)) {
2000 d->releaseFromDoubleClick =
true;
2003#if QT_CONFIG(draganddrop)
2012void QAbstractItemView::dragEnterEvent(QDragEnterEvent *
event)
2014 if (dragDropMode() == InternalMove
2018 if (d_func()->canDrop(
event)) {
2034void QAbstractItemView::dragMoveEvent(QDragMoveEvent *
event)
2037 d->draggedPosition =
event->position().toPoint() +
d->offset();
2038 if (dragDropMode() == InternalMove
2050 if (
index.isValid() &&
d->showDropIndicator) {
2052 d->dropIndicatorPosition =
d->position(
event->position().toPoint(),
rect,
index);
2053 switch (
d->dropIndicatorPosition) {
2055 if (
d->isIndexDropEnabled(
index.parent())) {
2057 event->acceptProposedAction();
2059 d->dropIndicatorRect =
QRect();
2063 if (
d->isIndexDropEnabled(
index.parent())) {
2065 event->acceptProposedAction();
2067 d->dropIndicatorRect =
QRect();
2071 if (
d->isIndexDropEnabled(
index)) {
2072 d->dropIndicatorRect =
rect;
2073 event->acceptProposedAction();
2075 d->dropIndicatorRect =
QRect();
2079 d->dropIndicatorRect =
QRect();
2081 event->acceptProposedAction();
2086 d->dropIndicatorRect =
QRect();
2087 d->dropIndicatorPosition = OnViewport;
2089 event->acceptProposedAction();
2092 d->viewport->update();
2095 if (
d->shouldAutoScroll(
event->position().toPoint()))
2108 if (
q->dragDropMode() == QAbstractItemView::InternalMove)
2130void QAbstractItemView::dragLeaveEvent(QDragLeaveEvent *)
2136 d->viewport->update();
2146void QAbstractItemView::dropEvent(QDropEvent *
event)
2149 if (dragDropMode() == InternalMove) {
2159 if (
d->model->dropMimeData(
event->mimeData(), action,
row, col,
index)) {
2160 if (action !=
event->dropAction()) {
2161 event->setDropAction(action);
2164 event->acceptProposedAction();
2170 d->viewport->update();
2184bool QAbstractItemViewPrivate::dropOn(QDropEvent *
event,
int *dropRow,
int *dropCol,
QModelIndex *dropIndex)
2187 if (
event->isAccepted())
2192 if (
viewport->rect().contains(
event->position().toPoint())) {
2194 if (!
index.isValid() || !
q->visualRect(
index).contains(
event->position().toPoint()))
2204 switch (dropIndicatorPosition) {
2205 case QAbstractItemView::AboveItem:
2207 col =
index.column();
2210 case QAbstractItemView::BelowItem:
2212 col =
index.column();
2215 case QAbstractItemView::OnItem:
2216 case QAbstractItemView::OnViewport:
2220 dropIndicatorPosition = QAbstractItemView::OnViewport;
2231QAbstractItemView::DropIndicatorPosition
2234 QAbstractItemView::DropIndicatorPosition
r = QAbstractItemView::OnViewport;
2237 if (
pos.y() -
rect.top() < margin) {
2238 r = QAbstractItemView::AboveItem;
2239 }
else if (
rect.bottom() -
pos.y() < margin) {
2240 r = QAbstractItemView::BelowItem;
2241 }
else if (
rect.contains(
pos,
true)) {
2242 r = QAbstractItemView::OnItem;
2246 touchingRect.
adjust(-1, -1, 1, 1);
2248 r = QAbstractItemView::OnItem;
2253 r =
pos.y() <
rect.center().y() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem;
2269 QAbstractScrollArea::focusInEvent(
event);
2275 && !
d->currentIndexSet
2276 && !currentIndexValid) {
2278 d->autoScroll =
false;
2282 currentIndexValid =
true;
2287 if (
model && currentIndexValid)
2289 else if (!currentIndexValid)
2292 d->viewport->update();
2304 QAbstractScrollArea::focusOutEvent(
event);
2305 d->viewport->update();
2322 d->delayedAutoScroll.stop();
2324#ifdef QT_KEYPAD_NAVIGATION
2325 switch (
event->key()) {
2327 if (QApplicationPrivate::keypadNavigationEnabled()) {
2328 if (!hasEditFocus()) {
2335 if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()) {
2336 setEditFocus(
false);
2346 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()
2355 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()
2356 && (QWidgetPrivate::canKeypadNavigate(
Qt::Horizontal) || QWidgetPrivate::inTabWidget(
this))) {
2362 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
2369#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)
2372 if (
index.isValid() &&
d->model) {
2382 d->moveCursorUpdatedView =
false;
2383 switch (
event->key()) {
2409 if (
d->tabKeyNavigation)
2413 if (
d->tabKeyNavigation)
2419 if (newCurrent != oldCurrent && newCurrent.
isValid() &&
d->isIndexEnabled(newCurrent)) {
2428 if (!
d->currentSelectionStartIndex.isValid())
2429 d->currentSelectionStartIndex = oldCurrent;
2433 d->selectionModel->setCurrentIndex(newCurrent, command);
2434 d->currentSelectionStartIndex = newCurrent;
2446 switch (
event->key()) {
2450#ifdef QT_KEYPAD_NAVIGATION
2451 if (QApplicationPrivate::keypadNavigationEnabled()
2459#ifdef QT_KEYPAD_NAVIGATION
2462 || (QWidgetPrivate::inTabWidget(
this) &&
d->model->columnCount(
d->root) > 1))) {
2481 if (
d->selectionModel)
2488#ifdef QT_KEYPAD_NAVIGATION
2526#ifndef QT_NO_SHORTCUT
2547 if (
d->moveCursorUpdatedView)
2559 QAbstractScrollArea::resizeEvent(
event);
2572 if (
event->timerId() ==
d->fetchMoreTimer.timerId())
2574 else if (
event->timerId() ==
d->delayedReset.timerId())
2576 else if (
event->timerId() ==
d->autoScrollTimer.timerId())
2578 else if (
event->timerId() ==
d->updateTimer.timerId())
2579 d->updateDirtyRegion();
2580 else if (
event->timerId() ==
d->delayedEditing.timerId()) {
2581 d->delayedEditing.stop();
2583 }
else if (
event->timerId() ==
d->delayedLayout.timerId()) {
2584 d->delayedLayout.stop();
2586 d->interruptDelayedItemsLayout();
2592 }
else if (
event->timerId() ==
d->delayedAutoScroll.timerId()) {
2593 d->delayedAutoScroll.stop();
2596 if (
d->pressedIndex.isValid() &&
d->pressedIndex ==
currentIndex())
2598 }
else if (
event->timerId() ==
d->pressClosedEditorWatcher.timerId()) {
2599 d->pressClosedEditorWatcher.stop();
2615 bool forwardEventToEditor =
false;
2616 const bool commit = !
event->commitString().isEmpty();
2617 const bool preediting = !
event->preeditString().isEmpty();
2619 if (
d->waitForIMCommit) {
2620 if (
commit || !preediting) {
2622 d->waitForIMCommit =
false;
2628 d->selectAllInEditor(currentEditor);
2631 currentEditor->setFocus();
2638 }
else if (preediting) {
2640 d->waitForIMCommit =
true;
2642 forwardEventToEditor =
true;
2648 d->waitForIMCommit =
false;
2652 }
else if (
QWidget *currentEditor; forwardEventToEditor
2658#if QT_CONFIG(draganddrop)
2682QAbstractItemView::DropIndicatorPosition QAbstractItemView::dropIndicatorPosition()
const
2685 return d->dropIndicatorPosition;
2700 if (
d->selectionModel) {
2701 indexes =
d->selectionModel->selectedIndexes();
2727 if (!
d->isIndexValid(
index))
2730 if (
QWidget *
w = (
d->persistent.isEmpty() ?
static_cast<QWidget*
>(
nullptr) :
d->editorForIndex(
index).widget.data())) {
2733 if (!
d->waitForIMCommit)
2741 d->delayedEditing.stop();
2742 d->delayedAutoScroll.stop();
2744 d->delayedEditing.stop();
2760 EditTriggers lastTrigger =
d->lastTrigger;
2761 d->lastTrigger = trigger;
2763 if (!
d->shouldEdit(trigger,
d->model->buddy(safeIndex)))
2766 if (
d->delayedEditing.isActive())
2778 d->openEditor(safeIndex,
d->shouldForwardEvent(trigger,
event) ?
event :
nullptr);
2800 if (
d->editorIndexHash.isEmpty())
2802 if (
d->delayedPendingLayout) {
2804 d->executePostedLayout();
2807 QStyleOptionViewItem
option;
2812 while (
it !=
d->editorIndexHash.end()) {
2815 if (
index.isValid() && editor) {
2817 if (
option.rect.isValid()) {
2823 editorsToHide << editor;
2827 d->indexEditorHash.remove(
it.value());
2828 it =
d->editorIndexHash.erase(
it);
2829 editorsToRelease << editor;
2835 for (
int i = 0;
i < editorsToHide.
size(); ++
i) {
2838 for (
int i = 0;
i < editorsToRelease.
size(); ++
i) {
2839 d->releaseEditor(editorsToRelease.
at(
i));
2852 d->fetchMoreTimer.start(0,
this);
2853 d->updateGeometry();
2862 if (verticalScrollBar()->maximum() ==
value &&
d->model->canFetchMore(
d->root))
2863 d->model->fetchMore(
d->root);
2866 d->checkMouseMove(posInVp);
2875 if (horizontalScrollBar()->maximum() ==
value &&
d->model->canFetchMore(
d->root))
2876 d->model->fetchMore(
d->root);
2879 d->checkMouseMove(posInVp);
2913 bool isPersistent =
d->persistent.contains(editor);
2914 bool hadFocus = editor->hasFocus();
2916 if (!
index.isValid()) {
2917 qWarning(
"QAbstractItemView::closeEditor called with an editor that does not belong to this view");
2924 d->pressClosedEditorWatcher.start(0,
this);
2925 d->lastEditedIndex =
index;
2927 if (!isPersistent) {
2931 d->removeEditor(editor);
2937 editor->clearFocus();
2939 d->checkPersistentEditorFocus();
2946 if (!isPersistent && editor)
2947 d->releaseEditor(editor,
index);
2957 if (
index.isValid()) {
2959 d->selectionModel->setCurrentIndex(persistent,
flags);
2967 if (
index.isValid()) {
2969 d->selectionModel->setCurrentIndex(persistent,
flags);
2994 if (!editor || !
d->itemDelegate ||
d->currentlyCommittingEditor)
2997 if (!
index.isValid()) {
2998 qWarning(
"QAbstractItemView::commitData called with an editor that does not belong to this view");
3001 d->currentlyCommittingEditor = editor;
3003 editor->removeEventFilter(delegate);
3005 editor->installEventFilter(delegate);
3006 d->currentlyCommittingEditor =
nullptr;
3019 d->persistent.remove(
w);
3037 if (!
d->model->rowCount(
d->root) || !
d->model->columnCount(
d->root))
3041 :
d->model->index(0, 0,
d->root);
3042 bool skipRow =
false;
3043 bool keyboardTimeWasValid =
d->keyboardInputTime.isValid();
3044 qint64 keyboardInputTimeElapsed;
3045 if (keyboardTimeWasValid)
3046 keyboardInputTimeElapsed =
d->keyboardInputTime.restart();
3048 d->keyboardInputTime.start();
3049 if (search.
isEmpty() || !keyboardTimeWasValid
3051 d->keyboardInput = search;
3054 d->keyboardInput += search;
3058 bool sameKey =
false;
3059 if (
d->keyboardInput.size() > 1) {
3060 int c =
d->keyboardInput.count(
d->keyboardInput.at(
d->keyboardInput.size() - 1));
3061 sameKey = (
c ==
d->keyboardInput.size());
3069 int newRow = (
start.row() <
d->model->rowCount(
parent) - 1) ?
start.row() + 1 : 0;
3081 if (
match == previous)
3083 firstMatch =
match.value(0);
3086 if (
d->isIndexEnabled(firstMatch)) {
3090 int row = firstMatch.
row() + 1;
3091 if (
row >=
d->model->rowCount(firstMatch.
parent()))
3097 startMatch = firstMatch;
3098 else if (startMatch == firstMatch)
3113 if (!
d->isIndexValid(
index))
3116 QStyleOptionViewItem
option;
3141 if (row < 0 || row >=
d->model->rowCount(
d->root))
3146 QStyleOptionViewItem
option;
3149 int colCount =
d->model->columnCount(
d->root);
3150 for (
int c = 0;
c < colCount; ++
c) {
3152 if (
QWidget *editor =
d->editorForIndex(
index).widget.data())
3172 if (column < 0 || column >=
d->model->columnCount(
d->root))
3177 QStyleOptionViewItem
option;
3180 int rows =
d->model->rowCount(
d->root);
3181 for (
int r = 0;
r < rows; ++
r) {
3183 if (
QWidget *editor =
d->editorForIndex(
index).widget.data())
3200 QStyleOptionViewItem options;
3208 d->persistent.insert(editor);
3220 if (
QWidget *editor =
d->editorForIndex(
index).widget.data()) {
3223 d->persistent.remove(editor);
3224 d->removeEditor(editor);
3225 d->releaseEditor(editor,
index);
3239 return d->editorForIndex(
index).widget;
3271 if (!
d->isIndexValid(
index))
3276 d->persistent.remove(oldWidget);
3277 d->removeEditor(oldWidget);
3278 oldWidget->removeEventFilter(
this);
3279 oldWidget->deleteLater();
3288 if (!
d->delayedPendingLayout) {
3290 d->doDelayedItemsLayout();
3303 if (
d->isIndexValid(
index))
3304 if (
QWidget *editor =
d->editorForIndex(
index).widget.data())
3319 verticalScrollBar()->setValue(verticalScrollBar()->minimum());
3332 if (
d->delayedPendingLayout) {
3333 d->executePostedLayout();
3336 verticalScrollBar()->setValue(verticalScrollBar()->maximum());
3348 if (
index.isValid()) {
3353 if (
d->viewport->rect().intersects(
rect))
3354 d->viewport->update(
rect);
3374 if (topLeft == bottomRight && topLeft.
isValid()) {
3375 const QEditorInfo &editorInfo =
d->editorForIndex(topLeft);
3383 if (
isVisible() && !
d->delayedPendingLayout) {
3388 d->updateEditorData(topLeft, bottomRight);
3389 if (
isVisible() && !
d->delayedPendingLayout) {
3392 topLeft.
row() > bottomRight.
row() ||
3395 d->viewport->update();
3397 const QRect updateRect =
d->intersectedRect(
d->viewport->rect(), topLeft, bottomRight);
3399 d->viewport->update(updateRect);
3404#if QT_CONFIG(accessibility)
3405 if (QAccessible::isActive()) {
3406 QAccessibleTableModelChangeEvent accessibleEvent(
this, QAccessibleTableModelChangeEvent::DataChanged);
3407 accessibleEvent.setFirstRow(topLeft.
row());
3408 accessibleEvent.setFirstColumn(topLeft.
column());
3409 accessibleEvent.setLastRow(bottomRight.
row());
3410 accessibleEvent.setLastColumn(bottomRight.
column());
3411 QAccessible::updateAccessibility(&accessibleEvent);
3414 d->updateGeometry();
3428 d_func()->fetchMoreTimer.start(0,
this);
3452 int totalToRemove =
end -
start + 1;
3453 if (
d->model->rowCount(
parent) <= totalToRemove) {
3462 const int rowCount =
d->model->rowCount(
parent);
3465 while (
row < rowCount && !found) {
3468 if (!
next.isValid()) {
3469 qWarning(
"Model unexpectedly returned an invalid index");
3485 if (!
next.isValid()) {
3486 qWarning(
"Model unexpectedly returned an invalid index");
3501 while (
i !=
d->editorIndexHash.end()) {
3506 i =
d->editorIndexHash.erase(
i);
3508 d->releaseEditor(editor,
index);
3530 q->updateEditorGeometries();
3532#if QT_CONFIG(accessibility)
3533 if (QAccessible::isActive()) {
3534 QAccessibleTableModelChangeEvent accessibleEvent(
q, QAccessibleTableModelChangeEvent::RowsRemoved);
3535 accessibleEvent.setFirstRow(
start);
3536 accessibleEvent.setLastRow(
end);
3537 QAccessible::updateAccessibility(&accessibleEvent);
3562 int totalToRemove =
end -
start + 1;
3567 if (
index.isValid())
3568 q->setCurrentIndex(
index);
3574 while (
column < columnCount) {
3577 if (!
next.isValid()) {
3578 qWarning(
"Model unexpectedly returned an invalid index");
3585 q->setCurrentIndex(
next);
3621 q->updateEditorGeometries();
3623#if QT_CONFIG(accessibility)
3624 if (QAccessible::isActive()) {
3625 QAccessibleTableModelChangeEvent accessibleEvent(
q, QAccessibleTableModelChangeEvent::ColumnsRemoved);
3626 accessibleEvent.setFirstColumn(
start);
3627 accessibleEvent.setLastColumn(
end);
3628 QAccessible::updateAccessibility(&accessibleEvent);
3646#if QT_CONFIG(accessibility)
3648 if (QAccessible::isActive()) {
3649 QAccessibleTableModelChangeEvent accessibleEvent(
q, QAccessibleTableModelChangeEvent::RowsInserted);
3650 accessibleEvent.setFirstRow(
start);
3651 accessibleEvent.setLastRow(
end);
3652 QAccessible::updateAccessibility(&accessibleEvent);
3671 q->updateEditorGeometries();
3672#if QT_CONFIG(accessibility)
3673 if (QAccessible::isActive()) {
3674 QAccessibleTableModelChangeEvent accessibleEvent(
q, QAccessibleTableModelChangeEvent::ColumnsInserted);
3675 accessibleEvent.setFirstColumn(
start);
3676 accessibleEvent.setLastColumn(
end);
3677 QAccessible::updateAccessibility(&accessibleEvent);
3700#if QT_CONFIG(accessibility)
3702 if (QAccessible::isActive()) {
3703 QAccessibleTableModelChangeEvent accessibleEvent(
q, QAccessibleTableModelChangeEvent::ModelReset);
3704 QAccessible::updateAccessibility(&accessibleEvent);
3723 const auto parentIdx = topLeft.
parent();
3725 for (
int r = topLeft.
row();
r <= bottomRight.
row(); ++
r) {
3729 return rect.intersected(updateRect);
3763 QWidget *editor =
d->editorForIndex(buddy).widget.data();
3764 if (editor && !
d->persistent.contains(editor)) {
3766 if (current.
row() != previous.
row())
3776 if (current.
isValid() && !
d->autoScrollTimer.isActive()) {
3782 if (current.
row() == (
d->model->rowCount(
d->root) - 1))
3785 d->shouldScrollToCurrentOnShow =
d->autoScroll;
3791#if QT_CONFIG(draganddrop)
3795void QAbstractItemView::startDrag(Qt::DropActions supportedActions)
3799 if (indexes.
size() > 0) {
3811 if (dragDropMode() == InternalMove)
3812 supportedActions &=
~Qt::CopyAction;
3813 if (
d->defaultDropAction !=
Qt::IgnoreAction && (supportedActions &
d->defaultDropAction))
3814 defaultDropAction =
d->defaultDropAction;
3815 else if (supportedActions &
Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove)
3817 d->dropEventMoved =
false;
3818 if (drag->
exec(supportedActions, defaultDropAction) ==
Qt::MoveAction && !
d->dropEventMoved) {
3819 if (dragDropMode() != InternalMove || drag->
target() ==
viewport())
3822 d->dropEventMoved =
false;
3824 d->dropIndicatorRect =
QRect();
3825 d->dropIndicatorPosition = OnItem;
3853 if (
d->iconSize.isValid()) {
3854 option->decorationSize =
d->iconSize;
3859 option->decorationPosition = QStyleOptionViewItem::Left;
3862 option->textElideMode =
d->textElideMode;
3865 if (
d->wrapItemText)
3866 option->features = QStyleOptionViewItem::WrapText;
3867 option->locale = locale();
3906 d->doDelayedItemsLayout();
3918 d->executePostedLayout();
3934 d->setDirtyRegion(region);
3950 d->scrollDirtyRegion(dx, dy);
3965 return d->scrollDelayOffset;
3973 d_func()->startAutoScroll();
3981 d_func()->stopAutoScroll();
3991 QScrollBar *verticalScroll = verticalScrollBar();
3992 QScrollBar *horizontalScroll = horizontalScrollBar();
3996 QHeaderView *hv = qobject_cast<QHeaderView*>(
this);
3998 QAbstractScrollArea *
parent = qobject_cast<QAbstractScrollArea*>(parentWidget());
4001 if (!hv->horizontalScrollBar() || !hv->horizontalScrollBar()->isVisible())
4002 horizontalScroll =
parent->horizontalScrollBar();
4004 if (!hv->verticalScrollBar() || !hv->verticalScrollBar()->isVisible())
4005 verticalScroll =
parent->verticalScrollBar();
4010 const int verticalStep = verticalScroll->
pageStep();
4011 const int horizontalStep = horizontalScroll->
pageStep();
4012 if (
d->autoScrollCount <
qMax(verticalStep, horizontalStep))
4013 ++
d->autoScrollCount;
4015 const int margin =
d->autoScrollMargin;
4016 const int verticalValue = verticalScroll->
value();
4017 const int horizontalValue = horizontalScroll->
value();
4019 const QPoint pos =
d->draggedPosition -
d->offset();
4023 if (
pos.y() -
area.top() < margin)
4024 verticalScroll->
setValue(verticalValue -
d->autoScrollCount);
4025 else if (
area.bottom() -
pos.y() < margin)
4026 verticalScroll->
setValue(verticalValue +
d->autoScrollCount);
4027 if (
pos.x() -
area.left() < margin)
4028 horizontalScroll->
setValue(horizontalValue -
d->autoScrollCount);
4029 else if (
area.right() -
pos.x() < margin)
4030 horizontalScroll->
setValue(horizontalValue +
d->autoScrollCount);
4032 const bool verticalUnchanged = (verticalValue == verticalScroll->
value());
4033 const bool horizontalUnchanged = (horizontalValue == horizontalScroll->
value());
4034 if (verticalUnchanged && horizontalUnchanged) {
4037#if QT_CONFIG(draganddrop)
4038 d->dropIndicatorRect =
QRect();
4039 d->dropIndicatorPosition = QAbstractItemView::OnViewport;
4045 const QPoint globalPos =
d->viewport->mapToGlobal(
pos);
4046 const QPoint windowPos =
window()->mapFromGlobal(globalPos);
4059 d->draggedPosition =
pos +
d->offset();
4065 d->viewport->update();
4083 Qt::KeyboardModifiers keyModifiers =
event &&
event->isInputEvent()
4086 switch (
d->selectionMode) {
4091 switch (
event->type()) {
4094 if (
d->pressedAlreadySelected)
4099 if (!
index.isValid())
4117 return d->contiguousSelectionCommand(
index,
event);
4128 switch (
event->type()) {
4139 || !dragEnabled || !isIndexDragEnabled(
index)
4149 && dragEnabled && isIndexDragEnabled(
index)
4172 Qt::KeyboardModifiers
modifiers =
event &&
event->isInputEvent()
4176 switch (
event->type()) {
4189 if ((shiftKeyPressed || controlKeyPressed) && rightButtonPressed)
4191 if (!shiftKeyPressed && !controlKeyPressed && indexIsSelected)
4193 if (!
index.isValid() && !rightButtonPressed && !shiftKeyPressed && !controlKeyPressed)
4195 if (!
index.isValid())
4200 && dragEnabled && isIndexDragEnabled(
index)
4215 && !shiftKeyPressed && !controlKeyPressed && (!rightButtonPressed || !
index.isValid()))
4219 && dragEnabled && isIndexDragEnabled(
index)
4242#ifdef QT_KEYPAD_NAVIGATION
4276QItemSelectionModel::SelectionFlags
4285 switch (
flags & Mask) {
4303 fetchMoreTimer.
stop();
4321 if (!
index.isValid())
4344 switch (
event->type()) {
4373 delayedLayout.
start(delay, q_func());
4379 delayedLayout.
stop();
4386 if (sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored)
4388 if (sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents || !shownOnce)
4389 q->updateGeometry();
4402#if QT_CONFIG(lineedit)
4406#if QT_CONFIG(spinbox)
4415 const QStyleOptionViewItem &options)
4479#if QT_CONFIG(draganddrop)
4486 if ((*it).left() != 0)
4490 int count = (*it).bottom() - (*it).top() + 1;
4521 q->setCurrentIndex(
index);
4580 QStyleOptionViewItem options;
4581 q->initViewItemOption(&options);
4582 options.rect =
q->visualRect(buddy);
4593 QStyleOptionViewItem options;
4594 q->initViewItemOption(&options);
4595 options.rect =
q->visualRect(buddy);
4607 q->updateMicroFocus();
4628 for (
const auto &
index : indexes) {
4657 QStyleOptionViewItem
option;
4658 q->initViewItemOption(&
option);
4660 for (
int j = 0;
j < paintPairs.
size(); ++
j) {
4661 option.rect = paintPairs.
at(
j).rect.translated(-
r->topLeft());
4664 q->itemDelegateForIndex(current)->paint(&
painter,
option, current);
4685#if QT_CONFIG(draganddrop)
4686QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes()
const
4691 return !isIndexDragEnabled(
index);
4693 indexes.
removeIf(isNotDragEnabled);
4697void QAbstractItemViewPrivate::maybeStartDrag(
QPoint eventPosition)
4707 q->stopAutoScroll();
4720 return QAbstractScrollArea::eventFilter(
object,
event);
4726 return QAbstractScrollArea::eventFilter(
object,
event);
4733#include "moc_qabstractitemview.cpp"
The QAbstractItemDelegate class is used to display and edit data items from a model.
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...
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.
virtual bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index)
static QAbstractItemModel * staticEmptyModel()
virtual Qt::DropActions supportedDropActions() const
Q_INVOKABLE int const QModelIndex & parent
Returns the parent of the model item with the given index.
virtual Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
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.
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}.
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.
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.
const QEditorInfo & editorForIndex(const QModelIndex &index) const
virtual void _q_modelDestroyed()
virtual QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const
void doDelayedItemsLayout(int delay=0)
QItemSelectionModel::SelectionFlags contiguousSelectionCommand(const QModelIndex &index, const QEvent *event) const
void interruptDelayedItemsLayout() const
virtual void adjustViewOptionsForIndex(QStyleOptionViewItem *, const QModelIndex &) const
void removeEditor(QWidget *editor)
QSet< QWidget * > persistent
void updateEditorData(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void checkPersistentEditorFocus()
virtual void _q_rowsInserted(const QModelIndex &parent, int start, int end)
bool hasEditor(const QModelIndex &index) const
bool delayedPendingLayout
virtual void _q_rowsRemoved(const QModelIndex &parent, int start, int end)
void addEditor(const QModelIndex &index, QWidget *editor, bool isStatic)
QIndexEditorHash indexEditorHash
QAbstractItemView::EditTriggers editTriggers
virtual void _q_layoutChanged()
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
void setHoverIndex(const QPersistentModelIndex &index)
virtual void _q_columnsRemoved(const QModelIndex &parent, int start, int end)
virtual void _q_rowsMoved(const QModelIndex &source, int sourceStart, int sourceEnd, const QModelIndex &destination, int destinationStart)
QAbstractItemView::State state
void _q_delegateSizeHintChanged(const QModelIndex &index)
QPointer< QItemSelectionModel > selectionModel
virtual ~QAbstractItemViewPrivate()
bool shouldAutoScroll(const QPoint &pos) const
bool shouldForwardEvent(QAbstractItemView::EditTrigger trigger, const QEvent *event) const
QItemSelectionModel::SelectionFlags selectionBehaviorFlags() const
virtual void _q_columnsMoved(const QModelIndex &source, int sourceStart, int sourceEnd, const QModelIndex &destination, int destinationStart)
QPersistentModelIndex root
bool droppingOnItself(QDropEvent *event, const QModelIndex &index)
bool openEditor(const QModelIndex &index, QEvent *event)
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
QItemSelectionModel::SelectionFlags extendedSelectionCommand(const QModelIndex &index, const QEvent *event) const
QPersistentModelIndex enteredIndex
virtual void _q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
QItemSelectionModel::SelectionFlags multiSelectionCommand(const QModelIndex &index, const QEvent *event) const
QItemSelection oldSelection
virtual void _q_columnsInserted(const QModelIndex &parent, int start, int end)
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
void _q_scrollerStateChanged()
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
int pageStep
the page step.
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.
void setText(const QString &, Mode mode=Clipboard)
Copies text into the clipboard as plain text.
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
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
const_iterator constBegin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item 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...
const QPoint & pos() const
Returns the mouse cursor position when the event was generated, relative to the widget to which the e...
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
bool isEmpty() 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.
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.
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
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
\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.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
The QRegion class specifies a clip region for a painter.
The QResizeEvent class contains event parameters for resize events.
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
Returns true if the string has no characters; otherwise returns false.
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
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
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
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
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
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextRoleName sizeHintChanged
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]
QFileInfo info(fileName)
[8]
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
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent