Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquicktableview_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKTABLEVIEW_P_P_H
6#define QQUICKTABLEVIEW_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
20
21#include <QtCore/qtimer.h>
22#include <QtCore/qitemselectionmodel.h>
23#include <QtQmlModels/private/qqmltableinstancemodel_p.h>
24#include <QtQml/private/qqmlincubator_p.h>
25#include <QtQmlModels/private/qqmlchangeset_p.h>
26#include <QtQml/qqmlinfo.h>
27
28#include <QtQuick/private/qquickflickable_p_p.h>
29#include <QtQuick/private/qquickitemviewfxitem_p_p.h>
30#include <QtQuick/private/qquickanimation_p.h>
31#include <QtQuick/private/qquickselectable_p.h>
32#include <QtQuick/private/qquicksinglepointhandler_p.h>
33#include <QtQuick/private/qquickhoverhandler_p.h>
34#include <QtQuick/private/qquicktaphandler_p.h>
35
36#include <QtCore/private/qminimalflatset_p.h>
37
38#if QT_CONFIG(quick_draganddrop)
39#include <QtGui/qdrag.h>
40#include <QtQuick/private/qquickdroparea_p.h>
41#endif
42
43#include <vector>
44
46
48
49static const qreal kDefaultRowHeight = 50;
50static const qreal kDefaultColumnWidth = 50;
51static const int kEdgeIndexNotSet = -2;
52static const int kEdgeIndexAtEnd = -3;
53
54class FxTableItem;
55class QQuickTableSectionSizeProviderPrivate;
56class QTypeRevision;
57
58/*! \internal
59 * TableView uses QQuickTableViewHoverHandler to track where the pointer is
60 * on top of the table, and change the cursor at the places where a drag
61 * would start a resize of a row or a column.
62 */
64{
66
67public:
69 inline bool isHoveringGrid() const { return m_row != -1 || m_column != -1; };
70
71 int m_row = -1;
72 int m_column = -1;
73
74 friend class QQuickTableViewPrivate;
75
76protected:
77 void handleEventPoint(QPointerEvent *event, QEventPoint &point) override;
78};
79
81{
83
84public:
85 enum State {
86 Listening, // the pointer is not being pressed between the cells
87 Tracking, // the pointer is being pressed between the cells
88 DraggingStarted, // dragging started
89 Dragging, // a drag is ongoing
90 DraggingFinished // dragging was finished
91 };
92
93 QQuickTableViewPointerHandler(QQuickTableView *view);
94
96 State state() { return m_state; }
97
98protected:
99 bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point) override;
100};
101
102/*! \internal
103 * TableView uses QQuickTableViewResizeHandler to enable the user to resize
104 * rows and columns. By using a custom pointer handler, we can get away with
105 * using a single pointer handler for the whole content item, rather than
106 * e.g having to split it up into multiple items with drag handlers placed
107 * between the cells.
108 */
110{
112
113public:
115
116 int m_row = -1;
119
120 int m_column = -1;
123
124 void updateState(QEventPoint &point);
125 void updateDrag(QPointerEvent *event, QEventPoint &point);
126
127 friend class QQuickTableViewPrivate;
128
129protected:
130 void handleEventPoint(QPointerEvent *event, QEventPoint &point) override;
131 void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition,
132 QPointerEvent *ev, QEventPoint &point) override;
133};
134
135#if QT_CONFIG(quick_draganddrop)
136class QQuickTableViewSectionDragHandler : public QQuickTableViewPointerHandler
137{
138 Q_OBJECT
139
140public:
141 QQuickTableViewSectionDragHandler(QQuickTableView *view);
142 ~QQuickTableViewSectionDragHandler();
143
144 void grabSection();
145
146 void handleDrag(QQuickDragEvent *event);
147 void handleDrop(QQuickDragEvent *event);
148 void handleDragDropAction(Qt::DropAction action);
149
150 void setSectionOrientation(Qt::Orientation orientation) { m_sectionOrientation = orientation; }
151
152 friend class QQuickTableViewPrivate;
153
154protected:
155 void handleEventPoint(QPointerEvent *event, QEventPoint &point) override;
156
157private:
158 void resetDragData();
159 void resetSectionOverlay();
160
161 QSharedPointer<QQuickItemGrabResult> m_grabResult;
162 QPointer<QDrag> m_drag;
163 int m_source = -1;
164 int m_destination = -1;
165 QPointer<QQuickDropArea> m_dropArea;
166 Qt::Orientation m_sectionOrientation;
167
168 QPointF m_dragPoint;
169 QSizeF m_step = QSizeF(1, 1);
170 QTimer m_scrollTimer;
171};
172#endif // quick_draganddrop
173
174/*! \internal
175 * QQuickTableViewTapHandler used to handle tap events explicitly for table view
176 */
178{
180
181public:
183 bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point) override;
184
185 friend class QQuickTableViewPrivate;
186};
187
188class Q_QUICK_EXPORT QQuickTableViewPrivate : public QQuickFlickablePrivate, public QQuickSelectable
189{
190public:
191 Q_DECLARE_PUBLIC(QQuickTableView)
192
193 class TableEdgeLoadRequest
194 {
195 // Whenever we need to load new rows or columns in the
196 // table, we fill out a TableEdgeLoadRequest.
197 // TableEdgeLoadRequest is just a struct that keeps track
198 // of which cells that needs to be loaded, and which cell
199 // the table is currently loading. The loading itself is
200 // done by QQuickTableView.
201
202 public:
203 void begin(const QPoint &cell, const QPointF &pos, QQmlIncubator::IncubationMode incubationMode)
204 {
205 Q_ASSERT(!m_active);
206 m_active = true;
207 m_edge = Qt::Edge(0);
208 m_mode = incubationMode;
209 m_edgeIndex = cell.x();
210 m_visibleCellsInEdge.clear();
211 m_visibleCellsInEdge.append(cell.y());
212 m_currentIndex = 0;
213 m_startPos = pos;
214 qCDebug(lcTableViewDelegateLifecycle()) << "begin top-left:" << toString();
215 }
216
217 void begin(Qt::Edge edgeToLoad, int edgeIndex, const QList<int> visibleCellsInEdge, QQmlIncubator::IncubationMode incubationMode)
218 {
219 Q_ASSERT(!m_active);
220 m_active = true;
221 m_edge = edgeToLoad;
222 m_edgeIndex = edgeIndex;
223 m_visibleCellsInEdge = visibleCellsInEdge;
224 m_mode = incubationMode;
225 m_currentIndex = 0;
226 qCDebug(lcTableViewDelegateLifecycle()) << "begin:" << toString();
227 }
228
229 inline void markAsDone() { m_active = false; }
230 inline bool isActive() const { return m_active; }
231
232 inline QPoint currentCell() const { return cellAt(m_currentIndex); }
233 inline bool hasCurrentCell() const { return m_currentIndex < m_visibleCellsInEdge.size(); }
234 inline void moveToNextCell() { ++m_currentIndex; }
235
236 inline Qt::Edge edge() const { return m_edge; }
237 inline int row() const { return cellAt(0).y(); }
238 inline int column() const { return cellAt(0).x(); }
239 inline QQmlIncubator::IncubationMode incubationMode() const { return m_mode; }
240
241 inline QPointF startPosition() const { return m_startPos; }
242
243 QString toString() const
244 {
245 QString str;
246 QDebug dbg(&str);
247 dbg.nospace() << "TableSectionLoadRequest(" << "edge:"
248 << m_edge << ", edgeIndex:" << m_edgeIndex << ", incubation:";
249
250 switch (m_mode) {
251 case QQmlIncubator::Asynchronous:
252 dbg << "Asynchronous";
253 break;
254 case QQmlIncubator::AsynchronousIfNested:
255 dbg << "AsynchronousIfNested";
256 break;
257 case QQmlIncubator::Synchronous:
258 dbg << "Synchronous";
259 break;
260 }
261
262 return str;
263 }
264
265 private:
266 Qt::Edge m_edge = Qt::Edge(0);
267 QList<int> m_visibleCellsInEdge;
268 int m_edgeIndex = 0;
269 int m_currentIndex = 0;
270 bool m_active = false;
271 QQmlIncubator::IncubationMode m_mode = QQmlIncubator::AsynchronousIfNested;
272 QPointF m_startPos;
273
274 inline QPoint cellAt(int index) const {
275 return !m_edge || (m_edge & (Qt::LeftEdge | Qt::RightEdge))
276 ? QPoint(m_edgeIndex, m_visibleCellsInEdge[index])
277 : QPoint(m_visibleCellsInEdge[index], m_edgeIndex);
278 }
279 };
280
281 class EdgeRange {
282 public:
283 EdgeRange();
284 bool containsIndex(Qt::Edge edge, int index);
285
286 int startIndex;
287 int endIndex;
288 qreal size;
289 };
290
291 enum class RebuildState {
292 Begin = 0,
293 LoadInitalTable,
294 VerifyTable,
295 LayoutTable,
296 CancelOvershoot,
297 UpdateContentSize,
298 PreloadColumns,
299 PreloadRows,
300 MovePreloadedItemsToPool,
301 Done
302 };
303
304 enum class SectionState {
305 Idle = 0,
306 Moving
307 };
308
309 enum class RebuildOption {
310 None = 0,
311 All = 0x1,
312 LayoutOnly = 0x2,
313 ViewportOnly = 0x4,
314 CalculateNewTopLeftRow = 0x8,
315 CalculateNewTopLeftColumn = 0x10,
316 CalculateNewContentWidth = 0x20,
317 CalculateNewContentHeight = 0x40,
318 PositionViewAtRow = 0x80,
319 PositionViewAtColumn = 0x100,
320 };
321 Q_DECLARE_FLAGS(RebuildOptions, RebuildOption)
322
323public:
324 QQuickTableViewPrivate();
325 ~QQuickTableViewPrivate() override;
326
327 static inline QQuickTableViewPrivate *get(QQuickTableView *q) { return q->d_func(); }
328
329 void updatePolish() override;
330 void fixup(AxisData &data, qreal minExtent, qreal maxExtent) override;
331
332public:
333 QHash<int, FxTableItem *> loadedItems;
334
335 // model, tableModel and modelVariant all point to the same model. modelVariant
336 // is the model assigned by the user. And tableModel is the wrapper model we create
337 // around it. But if the model is an instance model directly, we cannot wrap it, so
338 // we need a pointer for that case as well.
339 QQmlInstanceModel* model = nullptr;
340 QPointer<QQmlTableInstanceModel> tableModel = nullptr;
341
342 // When the applications assignes a new model or delegate to the view, we keep them
343 // around until we're ready to take them into use (syncWithPendingChanges).
344 QVariant assignedModel = QVariant(int(0));
345 QQmlGuard<QQmlComponent> assignedDelegate;
346
347 // loadedRows/Columns describes the rows and columns that are currently loaded (from top left
348 // row/column to bottom right row/column). loadedTableOuterRect describes the actual
349 // pixels that all the loaded delegate items cover, and is matched agains the viewport to determine when
350 // we need to fill up with more rows/columns. loadedTableInnerRect describes the pixels
351 // that the loaded table covers if you remove one row/column on each side of the table, and
352 // is used to determine rows/columns that are no longer visible and can be unloaded.
353 QMinimalFlatSet<int> loadedColumns;
354 QMinimalFlatSet<int> loadedRows;
355 QRectF loadedTableOuterRect;
356 QRectF loadedTableInnerRect;
357
358 QPointF origin = QPointF(0, 0);
359 QSizeF endExtent = QSizeF(0, 0);
360
361 QRectF viewportRect = QRectF(0, 0, -1, -1);
362
363 QSize tableSize;
364
365 RebuildState rebuildState = RebuildState::Done;
366 RebuildOptions rebuildOptions = RebuildOption::All;
367 RebuildOptions scheduledRebuildOptions = RebuildOption::All;
368
369 TableEdgeLoadRequest loadRequest;
370
371 QSizeF cellSpacing = QSizeF(0, 0);
372
373 QQmlTableInstanceModel::ReusableFlag reusableFlag = QQmlTableInstanceModel::Reusable;
374
375 bool blockItemCreatedCallback = false;
376 mutable bool layoutWarningIssued = false;
377 bool polishing = false;
378 bool syncVertically = false;
379 bool syncHorizontally = false;
380 bool inSetLocalViewportPos = false;
381 bool inSyncViewportPosRecursive = false;
382 bool inUpdateContentSize = false;
383 bool animate = true;
384 bool keyNavigationEnabled = true;
385 bool pointerNavigationEnabled = true;
386 bool alternatingRows = true;
387 bool resizableColumns = false;
388 bool resizableRows = false;
389#if QT_CONFIG(cursor)
390 bool m_cursorSet = false;
391#endif
392
393 // isTransposed is currently only used by HeaderView.
394 // Consider making it public.
395 bool isTransposed = false;
396
397 bool warnNoSelectionModel = true;
398
399 QQmlDelegateModel::DelegateModelAccess assignedDelegateModelAccess
400 = QQmlDelegateModel::Qt5ReadWrite;
401
402 bool componentFinalized = false;
403
404 // sorting
405 void requestSort(int logicalColumn, bool clearable);
406 void sortByColumn(int column, Qt::SortOrder order);
407 void updateSortState(int column, Qt::SortOrder order);
408
409 bool sortingEnabled = false;
410 int sortColumn = -1;
411 Qt::SortOrder sortOrder = Qt::AscendingOrder;
412
413 QJSValue rowHeightProvider;
414 QJSValue columnWidthProvider;
415
416 mutable EdgeRange cachedNextVisibleEdgeIndex[4];
417 mutable EdgeRange cachedColumnWidth;
418 mutable EdgeRange cachedRowHeight;
419
420 // TableView uses contentWidth/height to report the size of the table (this
421 // will e.g make scrollbars written for Flickable work out of the box). This
422 // value is continuously calculated, and will change/improve as more columns
423 // are loaded into view. At the same time, we want to open up for the
424 // possibility that the application can set the content width explicitly, in
425 // case it knows what the exact width should be from the start. We therefore
426 // override the contentWidth/height properties from QQuickFlickable, to be able
427 // to implement this combined behavior. This also lets us lazy build the table
428 // if the application needs to know the content size early on.
429 QQmlNullableValue<qreal> explicitContentWidth;
430 QQmlNullableValue<qreal> explicitContentHeight;
431
432 QSizeF averageEdgeSize;
433
434 QPointer<QQuickTableView> assignedSyncView;
435 QPointer<QQuickTableView> syncView;
436 QList<QPointer<QQuickTableView> > syncChildren;
437 Qt::Orientations assignedSyncDirection = Qt::Horizontal | Qt::Vertical;
438
439 QPointer<QItemSelectionModel> selectionModel;
440 QQuickTableView::SelectionBehavior selectionBehavior = QQuickTableView::SelectCells;
441 QQuickTableView::SelectionMode selectionMode = QQuickTableView::ExtendedSelection;
442 QItemSelectionModel::SelectionFlag selectionFlag = QItemSelectionModel::NoUpdate;
443 std::function<void(CallBackFlag)> selectableCallbackFunction;
444 bool inSelectionModelUpdate = false;
445 bool needsModelSynchronization = false;
446
447 int assignedPositionViewAtRowAfterRebuild = 0;
448 int assignedPositionViewAtColumnAfterRebuild = 0;
449 int positionViewAtRowAfterRebuild = 0;
450 int positionViewAtColumnAfterRebuild = 0;
451 qreal positionViewAtRowOffset = 0;
452 qreal positionViewAtColumnOffset = 0;
453 QRectF positionViewAtRowSubRect;
454 QRectF positionViewAtColumnSubRect;
455 Qt::Alignment positionViewAtRowAlignment = Qt::AlignTop;
456 Qt::Alignment positionViewAtColumnAlignment = Qt::AlignLeft;
457
458 QQuickPropertyAnimation positionXAnimation;
459 QQuickPropertyAnimation positionYAnimation;
460
461 QPoint selectionStartCell = {-1, -1};
462 QPoint selectionEndCell = {-1, -1};
463 QItemSelection existingSelection;
464
465 QMargins edgesBeforeRebuild;
466 QSize tableSizeBeforeRebuild;
467
468 int currentRow = -1;
469 int currentColumn = -1;
470#if QT_CONFIG(accessibility)
471 QPointer<QQuickItem> accessibleFocusItem;
472#endif
473
474 QHash<int, qreal> explicitColumnWidths;
475 QHash<int, qreal> explicitRowHeights;
476
477 QQuickTableViewHoverHandler *hoverHandler = nullptr;
478 QQuickTableViewResizeHandler *resizeHandler = nullptr;
479#if QT_CONFIG(quick_draganddrop)
480 QQuickTableViewSectionDragHandler *sectionDragHandler = nullptr;
481#endif
482 QQuickTableViewPointerHandler *activePtrHandler = nullptr;
483
484 QQmlTableInstanceModel *editModel = nullptr;
485 QQuickItem *editItem = nullptr;
486 QPersistentModelIndex editIndex;
487 QQuickTableView::EditTriggers editTriggers = QQuickTableView::DoubleTapped | QQuickTableView::EditKeyPressed;
488
489#ifdef QT_DEBUG
490 QString forcedIncubationMode = qEnvironmentVariable("QT_TABLEVIEW_INCUBATION_MODE");
491#endif
492
493 struct SectionData {
494 int index = -1;
495 int prevIndex = -1;
496 };
497
498 std::vector<SectionData> horizontalVisualIndices;
499 std::vector<SectionData> verticalVisualIndices;
500 std::vector<SectionData> horizontalLogicalIndices;
501 std::vector<SectionData> verticalLogicalIndices;
502
503 std::vector<SectionData> &visualIndicesForOrientation(Qt::Orientation orientation)
504 {
505 return orientation == Qt::Horizontal ? horizontalVisualIndices : verticalVisualIndices;
506 }
507 std::vector<SectionData> &logicalIndicesForOrientation(Qt::Orientation orientation)
508 {
509 return orientation == Qt::Horizontal ? horizontalLogicalIndices : verticalLogicalIndices;
510 }
511
512 SectionState m_sectionState = SectionState::Idle;
513
514public:
515 void init();
516
517 QQuickTableViewAttached *getAttachedObject(const QObject *object) const;
518
519 int modelIndexAtCell(const QPoint &cell) const;
520 QPoint cellAtModelIndex(int modelIndex) const;
521 int modelIndexToCellIndex(const QModelIndex &modelIndex, bool visualIndex = true) const;
522 inline bool cellIsValid(const QPoint &cell) const { return cell.x() != -1 && cell.y() != -1; }
523
524 qreal sizeHintForColumn(int column) const;
525 qreal sizeHintForRow(int row) const;
526 QSize calculateTableSize();
527 void updateTableSize();
528
529 inline bool isColumnHidden(int column) const;
530 inline bool isRowHidden(int row) const;
531
532 qreal getColumnLayoutWidth(int column);
533 qreal getRowLayoutHeight(int row);
534 qreal getColumnWidth(int column) const;
535 qreal getRowHeight(int row) const;
536 qreal getEffectiveRowY(int row) const;
537 qreal getEffectiveRowHeight(int row) const;
538 qreal getEffectiveColumnX(int column) const;
539 qreal getEffectiveColumnWidth(int column) const;
540 qreal getAlignmentContentX(int column, Qt::Alignment alignment, const qreal offset, const QRectF &subRect);
541 qreal getAlignmentContentY(int row, Qt::Alignment alignment, const qreal offset, const QRectF &subRect);
542
543 int topRow() const { return *loadedRows.cbegin(); }
544 int bottomRow() const { return *loadedRows.crbegin(); }
545 int leftColumn() const { return *loadedColumns.cbegin(); }
546 int rightColumn() const { return *loadedColumns.crbegin(); }
547
548 QQuickTableView *rootSyncView() const;
549
550 bool updateTableRecursive();
551 bool updateTable();
552 void relayoutTableItems();
553
554 void layoutVerticalEdge(Qt::Edge tableEdge);
555 void layoutHorizontalEdge(Qt::Edge tableEdge);
556 void layoutTopLeftItem();
557 void layoutTableEdgeFromLoadRequest();
558
559 void updateContentWidth();
560 void updateContentHeight();
561 void updateAverageColumnWidth();
562 void updateAverageRowHeight();
563 RebuildOptions checkForVisibilityChanges();
564 void forceLayout(bool immediate);
565
566 void updateExtents();
567 void syncLoadedTableRectFromLoadedTable();
568 void syncLoadedTableFromLoadRequest();
569
570 int nextVisibleEdgeIndex(Qt::Edge edge, int startIndex) const;
571 int nextVisibleEdgeIndexAroundLoadedTable(Qt::Edge edge) const;
572 inline bool atTableEnd(Qt::Edge edge) const { return nextVisibleEdgeIndexAroundLoadedTable(edge) == kEdgeIndexAtEnd; }
573 inline bool atTableEnd(Qt::Edge edge, int startIndex) const { return nextVisibleEdgeIndex(edge, startIndex) == kEdgeIndexAtEnd; }
574 inline int edgeToArrayIndex(Qt::Edge edge) const;
575 void clearEdgeSizeCache();
576
577 bool canLoadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const;
578 bool canUnloadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const;
579 Qt::Edge nextEdgeToLoad(const QRectF rect);
580 Qt::Edge nextEdgeToUnload(const QRectF rect);
581
582 qreal cellWidth(const QPoint &cell) const;
583 qreal cellHeight(const QPoint &cell) const;
584
585 FxTableItem *loadedTableItem(const QPoint &cell) const;
586 FxTableItem *createFxTableItem(const QPoint &cell, QQmlIncubator::IncubationMode incubationMode);
587 FxTableItem *loadFxTableItem(const QPoint &cell, QQmlIncubator::IncubationMode incubationMode);
588
589 void releaseItem(FxTableItem *fxTableItem, QQmlTableInstanceModel::ReusableFlag reusableFlag);
590 void releaseLoadedItems(QQmlTableInstanceModel::ReusableFlag reusableFlag);
591
592 void unloadItem(const QPoint &cell);
593 void loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMode incubationMode);
594 void unloadEdge(Qt::Edge edge);
595 void loadAndUnloadVisibleEdges(QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested);
596 void drainReusePoolAfterLoadRequest();
597 void processLoadRequest();
598
599 void processRebuildTable();
600 bool moveToNextRebuildState();
601 void calculateTopLeft(QPoint &topLeft, QPointF &topLeftPos);
602 void loadInitialTable();
603
604 void layoutAfterLoadingInitialTable();
605 void adjustViewportXAccordingToAlignment();
606 void adjustViewportYAccordingToAlignment();
607 void cancelOvershootAfterLayout();
608
609 void scheduleRebuildTable(QQuickTableViewPrivate::RebuildOptions options);
610
611#if QT_CONFIG(cursor)
612 void updateCursor();
613#endif
614 void updateEditItem();
615 void updateContentSize();
616
617 QTypeRevision resolveImportVersion();
618 void createWrapperModel();
619 QAbstractItemModel *qaim(QVariant modelAsVariant) const;
620
621 virtual void initItemCallback(int modelIndex, QObject *item);
622 virtual void itemCreatedCallback(int modelIndex, QObject *object);
623 virtual void itemPooledCallback(int modelIndex, QObject *object);
624 virtual void itemReusedCallback(int modelIndex, QObject *object);
625 virtual void modelUpdated(const QQmlChangeSet &changeSet, bool reset);
626 virtual void updateItemProperties(int flatIndex, QObject *object, bool init);
627
628 virtual void syncWithPendingChanges();
629 virtual void syncDelegate();
630 virtual void syncDelegateModelAccess();
631 virtual QVariant modelImpl() const;
632 virtual void setModelImpl(const QVariant &newModel);
633 virtual void syncModel();
634 virtual void syncSyncView();
635 virtual void syncPositionView();
636 virtual QAbstractItemModel *selectionSourceModel();
637 inline void syncRebuildOptions();
638
639 void connectToModel();
640 void disconnectFromModel();
641
642 void rowsMovedCallback(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row);
643 void columnsMovedCallback(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column);
644 void rowsInsertedCallback(const QModelIndex &parent, int begin, int end);
645 void rowsRemovedCallback(const QModelIndex &parent, int begin, int end);
646 void columnsInsertedCallback(const QModelIndex &parent, int begin, int end);
647 void columnsRemovedCallback(const QModelIndex &parent, int begin, int end);
648 void layoutChangedCallback(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint);
649 void modelResetCallback();
650 void dataChangedCallback(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList<int> &roles);
651 bool compareModel(const QVariant& model1, const QVariant& model2) const;
652
653 void positionViewAtRow(int row, Qt::Alignment alignment, qreal offset, const QRectF subRect = QRectF());
654 void positionViewAtColumn(int column, Qt::Alignment alignment, qreal offset, const QRectF subRect = QRectF());
655 bool scrollToRow(int row, Qt::Alignment alignment, qreal offset, const QRectF subRect = QRectF());
656 bool scrollToColumn(int column, Qt::Alignment alignment, qreal offset, const QRectF subRect = QRectF());
657
658 void scheduleRebuildIfFastFlick();
659 void setLocalViewportX(qreal contentX);
660 void setLocalViewportY(qreal contentY);
661 void syncViewportRect();
662 void syncViewportPosRecursive();
663
664 bool selectedInSelectionModel(const QPoint &cell) const;
665 void selectionChangedInSelectionModel(const QItemSelection &selected, const QItemSelection &deselected);
666 void updateSelectedOnAllDelegateItems();
667 void setSelectedOnDelegateItem(const QModelIndex &modelIndex, bool select);
668
669 bool currentInSelectionModel(const QPoint &cell) const;
670 void currentChangedInSelectionModel(const QModelIndex &current, const QModelIndex &previous);
671 void setCurrentOnDelegateItem(const QModelIndex &index, bool isCurrent);
672 void updateCurrentRowAndColumn();
673#if QT_CONFIG(accessibility)
674 void updateAccessibleFocus();
675#endif
676
677 void fetchMoreData();
678
679 void _q_componentFinalized();
680 void registerCallbackWhenBindingsAreEvaluated();
681
682 inline QString tableLayoutToString() const;
683 void dumpTable() const;
684
685 void setRequiredProperty(const char *property,
686 const QVariant &value,
687 int serializedModelIndex,
688 QObject *object, bool init);
689
690 void handleTap(const QQuickHandlerPoint &point);
691 virtual void executeTap(const QQuickHandlerPoint &point);
692 void setCurrentIndexFromTap(const QPointF &pos);
693 void setCurrentIndex(const QPoint &cell);
694 bool setCurrentIndexFromKeyEvent(QKeyEvent *e);
695 bool canEdit(const QModelIndex tappedIndex, bool warn);
696 bool editFromKeyEvent(QKeyEvent *e);
697 void closeEditorAndCommit();
698 QObject *installEventFilterOnFocusObjectInsideEditItem();
699
700 // QQuickSelectable
701 QQuickItem *selectionPointerHandlerTarget() const override;
702 bool hasSelection() const override;
703 bool startSelection(const QPointF &pos, Qt::KeyboardModifiers modifiers) override;
704 void setSelectionStartPos(const QPointF &pos) override;
705 void setSelectionEndPos(const QPointF &pos) override;
706 void clearSelection() override;
707 void normalizeSelection() override;
708 QRectF selectionRectangle() const override;
709 QSizeF scrollTowardsPoint(const QPointF &pos, const QSizeF &step) override;
710 void setCallback(std::function<void(CallBackFlag)> func) override;
711 void cancelSelectionTracking();
712
713 QPoint clampedCellAtPos(const QPointF &pos) const;
714 virtual void updateSelection(const QRect &oldSelection, const QRect &newSelection);
715 QRect selection() const;
716 // ----------------
717
718 // Section drag handler
719#if QT_CONFIG(quick_draganddrop)
720 void initSectionDragHandler(Qt::Orientation orientation);
721 void destroySectionDragHandler();
722#endif
723 inline void setActivePointerHandler(QQuickTableViewPointerHandler *handler) { activePtrHandler = handler; }
724 inline QQuickTableViewPointerHandler* activePointerHandler() const { return activePtrHandler; }
725 // Row/Column reordering
726 void moveSection(int source , int destination, Qt::Orientation orientation);
727 void initializeIndexMapping();
728 void clearIndexMapping();
729 void clearSection(Qt::Orientation orientation);
730 virtual int logicalRowIndex(const int visualIndex) const;
731 virtual int logicalColumnIndex(const int visualIndex) const;
732 virtual int visualRowIndex(const int logicalIndex) const;
733 virtual int visualColumnIndex(const int logicalIndex) const;
734 void setContainsDragOnDelegateItem(const QModelIndex &modelIndex, bool overlay);
735 int getEditCellIndex(const QModelIndex &index) const;
736};
737
739{
740public:
741 FxTableItem(QQuickItem *item, QQuickTableView *table, bool own)
743 {
744 }
745
746 qreal position() const override { return 0; }
747 qreal endPosition() const override { return 0; }
748 qreal size() const override { return 0; }
749 qreal sectionSize() const override { return 0; }
750 bool contains(qreal, qreal) const override { return false; }
751
753};
754
755Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickTableViewPrivate::RebuildOptions)
756
757QT_END_NAMESPACE
758
759#endif
qreal sectionSize() const override
qreal endPosition() const override
qreal size() const override
qreal position() const override
FxTableItem(QQuickItem *item, QQuickTableView *table, bool own)
bool contains(qreal, qreal) const override
void handleEventPoint(QPointerEvent *event, QEventPoint &point) override
QQuickTableViewPointerHandler(QQuickTableView *view)
bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point) override
Returns true if the given point (as part of event) could be relevant at all to this handler,...
void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *ev, QEventPoint &point) override
Notification that the grab has changed in some way which is relevant to this handler.
void updateState(QEventPoint &point)
void updateDrag(QPointerEvent *event, QEventPoint &point)
void handleEventPoint(QPointerEvent *event, QEventPoint &point) override
bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point) override
Returns true if the given point (as part of event) could be relevant at all to this handler,...
\inmodule QtCore
QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2620
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcQIORing)
#define TV_REBUILDOPTION(OPTION)
static const Qt::Edge allTableEdges[]
#define Q_TABLEVIEW_ASSERT(cond, output)
#define Q_TABLEVIEW_UNREACHABLE(output)
#define TV_REBUILDSTATE(STATE)
static const char * kRequiredProperty_current
static const char * kRequiredProperty_tableView
static const char * kRequiredProperty_editing
static const char * kRequiredProperty_selected
static const char * kRequiredProperty_containsDrag
static const char * kRequiredProperties
static constexpr Qt::SortOrder flipOrder(Qt::SortOrder order)
QT_REQUIRE_CONFIG(quick_tableview)
static const qreal kDefaultColumnWidth
static const int kEdgeIndexAtEnd
static QT_BEGIN_NAMESPACE const qreal kDefaultRowHeight
static const int kEdgeIndexNotSet