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 QJSValue rowHeightProvider;
403 QJSValue columnWidthProvider;
404
405 mutable EdgeRange cachedNextVisibleEdgeIndex[4];
406 mutable EdgeRange cachedColumnWidth;
407 mutable EdgeRange cachedRowHeight;
408
409 // TableView uses contentWidth/height to report the size of the table (this
410 // will e.g make scrollbars written for Flickable work out of the box). This
411 // value is continuously calculated, and will change/improve as more columns
412 // are loaded into view. At the same time, we want to open up for the
413 // possibility that the application can set the content width explicitly, in
414 // case it knows what the exact width should be from the start. We therefore
415 // override the contentWidth/height properties from QQuickFlickable, to be able
416 // to implement this combined behavior. This also lets us lazy build the table
417 // if the application needs to know the content size early on.
418 QQmlNullableValue<qreal> explicitContentWidth;
419 QQmlNullableValue<qreal> explicitContentHeight;
420
421 QSizeF averageEdgeSize;
422
423 QPointer<QQuickTableView> assignedSyncView;
424 QPointer<QQuickTableView> syncView;
425 QList<QPointer<QQuickTableView> > syncChildren;
426 Qt::Orientations assignedSyncDirection = Qt::Horizontal | Qt::Vertical;
427
428 QPointer<QItemSelectionModel> selectionModel;
429 QQuickTableView::SelectionBehavior selectionBehavior = QQuickTableView::SelectCells;
430 QQuickTableView::SelectionMode selectionMode = QQuickTableView::ExtendedSelection;
431 QItemSelectionModel::SelectionFlag selectionFlag = QItemSelectionModel::NoUpdate;
432 std::function<void(CallBackFlag)> selectableCallbackFunction;
433 bool inSelectionModelUpdate = false;
434 bool needsModelSynchronization = false;
435
436 int assignedPositionViewAtRowAfterRebuild = 0;
437 int assignedPositionViewAtColumnAfterRebuild = 0;
438 int positionViewAtRowAfterRebuild = 0;
439 int positionViewAtColumnAfterRebuild = 0;
440 qreal positionViewAtRowOffset = 0;
441 qreal positionViewAtColumnOffset = 0;
442 QRectF positionViewAtRowSubRect;
443 QRectF positionViewAtColumnSubRect;
444 Qt::Alignment positionViewAtRowAlignment = Qt::AlignTop;
445 Qt::Alignment positionViewAtColumnAlignment = Qt::AlignLeft;
446
447 QQuickPropertyAnimation positionXAnimation;
448 QQuickPropertyAnimation positionYAnimation;
449
450 QPoint selectionStartCell = {-1, -1};
451 QPoint selectionEndCell = {-1, -1};
452 QItemSelection existingSelection;
453
454 QMargins edgesBeforeRebuild;
455 QSize tableSizeBeforeRebuild;
456
457 int currentRow = -1;
458 int currentColumn = -1;
459
460 QHash<int, qreal> explicitColumnWidths;
461 QHash<int, qreal> explicitRowHeights;
462
463 QQuickTableViewHoverHandler *hoverHandler = nullptr;
464 QQuickTableViewResizeHandler *resizeHandler = nullptr;
465#if QT_CONFIG(quick_draganddrop)
466 QQuickTableViewSectionDragHandler *sectionDragHandler = nullptr;
467#endif
468 QQuickTableViewPointerHandler *activePtrHandler = nullptr;
469
470 QQmlTableInstanceModel *editModel = nullptr;
471 QQuickItem *editItem = nullptr;
472 QPersistentModelIndex editIndex;
473 QQuickTableView::EditTriggers editTriggers = QQuickTableView::DoubleTapped | QQuickTableView::EditKeyPressed;
474
475#ifdef QT_DEBUG
476 QString forcedIncubationMode = qEnvironmentVariable("QT_TABLEVIEW_INCUBATION_MODE");
477#endif
478
479 struct SectionData {
480 int index = -1;
481 int prevIndex = -1;
482 };
483
484 std::vector<SectionData> horizontalVisualIndices;
485 std::vector<SectionData> verticalVisualIndices;
486 std::vector<SectionData> horizontalLogicalIndices;
487 std::vector<SectionData> verticalLogicalIndices;
488
489 std::vector<SectionData> &visualIndicesForOrientation(Qt::Orientation orientation)
490 {
491 return orientation == Qt::Horizontal ? horizontalVisualIndices : verticalVisualIndices;
492 }
493 std::vector<SectionData> &logicalIndicesForOrientation(Qt::Orientation orientation)
494 {
495 return orientation == Qt::Horizontal ? horizontalLogicalIndices : verticalLogicalIndices;
496 }
497
498 SectionState m_sectionState = SectionState::Idle;
499
500public:
501 void init();
502
503 QQuickTableViewAttached *getAttachedObject(const QObject *object) const;
504
505 int modelIndexAtCell(const QPoint &cell) const;
506 QPoint cellAtModelIndex(int modelIndex) const;
507 int modelIndexToCellIndex(const QModelIndex &modelIndex, bool visualIndex = true) const;
508 inline bool cellIsValid(const QPoint &cell) const { return cell.x() != -1 && cell.y() != -1; }
509
510 qreal sizeHintForColumn(int column) const;
511 qreal sizeHintForRow(int row) const;
512 QSize calculateTableSize();
513 void updateTableSize();
514
515 inline bool isColumnHidden(int column) const;
516 inline bool isRowHidden(int row) const;
517
518 qreal getColumnLayoutWidth(int column);
519 qreal getRowLayoutHeight(int row);
520 qreal getColumnWidth(int column) const;
521 qreal getRowHeight(int row) const;
522 qreal getEffectiveRowY(int row) const;
523 qreal getEffectiveRowHeight(int row) const;
524 qreal getEffectiveColumnX(int column) const;
525 qreal getEffectiveColumnWidth(int column) const;
526 qreal getAlignmentContentX(int column, Qt::Alignment alignment, const qreal offset, const QRectF &subRect);
527 qreal getAlignmentContentY(int row, Qt::Alignment alignment, const qreal offset, const QRectF &subRect);
528
529 int topRow() const { return *loadedRows.cbegin(); }
530 int bottomRow() const { return *loadedRows.crbegin(); }
531 int leftColumn() const { return *loadedColumns.cbegin(); }
532 int rightColumn() const { return *loadedColumns.crbegin(); }
533
534 QQuickTableView *rootSyncView() const;
535
536 bool updateTableRecursive();
537 bool updateTable();
538 void relayoutTableItems();
539
540 void layoutVerticalEdge(Qt::Edge tableEdge);
541 void layoutHorizontalEdge(Qt::Edge tableEdge);
542 void layoutTopLeftItem();
543 void layoutTableEdgeFromLoadRequest();
544
545 void updateContentWidth();
546 void updateContentHeight();
547 void updateAverageColumnWidth();
548 void updateAverageRowHeight();
549 RebuildOptions checkForVisibilityChanges();
550 void forceLayout(bool immediate);
551
552 void updateExtents();
553 void syncLoadedTableRectFromLoadedTable();
554 void syncLoadedTableFromLoadRequest();
555
556 int nextVisibleEdgeIndex(Qt::Edge edge, int startIndex) const;
557 int nextVisibleEdgeIndexAroundLoadedTable(Qt::Edge edge) const;
558 inline bool atTableEnd(Qt::Edge edge) const { return nextVisibleEdgeIndexAroundLoadedTable(edge) == kEdgeIndexAtEnd; }
559 inline bool atTableEnd(Qt::Edge edge, int startIndex) const { return nextVisibleEdgeIndex(edge, startIndex) == kEdgeIndexAtEnd; }
560 inline int edgeToArrayIndex(Qt::Edge edge) const;
561 void clearEdgeSizeCache();
562
563 bool canLoadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const;
564 bool canUnloadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const;
565 Qt::Edge nextEdgeToLoad(const QRectF rect);
566 Qt::Edge nextEdgeToUnload(const QRectF rect);
567
568 qreal cellWidth(const QPoint &cell) const;
569 qreal cellHeight(const QPoint &cell) const;
570
571 FxTableItem *loadedTableItem(const QPoint &cell) const;
572 FxTableItem *createFxTableItem(const QPoint &cell, QQmlIncubator::IncubationMode incubationMode);
573 FxTableItem *loadFxTableItem(const QPoint &cell, QQmlIncubator::IncubationMode incubationMode);
574
575 void releaseItem(FxTableItem *fxTableItem, QQmlTableInstanceModel::ReusableFlag reusableFlag);
576 void releaseLoadedItems(QQmlTableInstanceModel::ReusableFlag reusableFlag);
577
578 void unloadItem(const QPoint &cell);
579 void loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMode incubationMode);
580 void unloadEdge(Qt::Edge edge);
581 void loadAndUnloadVisibleEdges(QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested);
582 void drainReusePoolAfterLoadRequest();
583 void processLoadRequest();
584
585 void processRebuildTable();
586 bool moveToNextRebuildState();
587 void calculateTopLeft(QPoint &topLeft, QPointF &topLeftPos);
588 void loadInitialTable();
589
590 void layoutAfterLoadingInitialTable();
591 void adjustViewportXAccordingToAlignment();
592 void adjustViewportYAccordingToAlignment();
593 void cancelOvershootAfterLayout();
594
595 void scheduleRebuildTable(QQuickTableViewPrivate::RebuildOptions options);
596
597#if QT_CONFIG(cursor)
598 void updateCursor();
599#endif
600 void updateEditItem();
601 void updateContentSize();
602
603 QTypeRevision resolveImportVersion();
604 void createWrapperModel();
605 QAbstractItemModel *qaim(QVariant modelAsVariant) const;
606
607 virtual void initItemCallback(int modelIndex, QObject *item);
608 virtual void itemCreatedCallback(int modelIndex, QObject *object);
609 virtual void itemPooledCallback(int modelIndex, QObject *object);
610 virtual void itemReusedCallback(int modelIndex, QObject *object);
611 virtual void modelUpdated(const QQmlChangeSet &changeSet, bool reset);
612
613 virtual void syncWithPendingChanges();
614 virtual void syncDelegate();
615 virtual void syncDelegateModelAccess();
616 virtual QVariant modelImpl() const;
617 virtual void setModelImpl(const QVariant &newModel);
618 virtual void syncModel();
619 virtual void syncSyncView();
620 virtual void syncPositionView();
621 virtual QAbstractItemModel *selectionSourceModel();
622 inline void syncRebuildOptions();
623
624 void connectToModel();
625 void disconnectFromModel();
626
627 void rowsMovedCallback(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row);
628 void columnsMovedCallback(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column);
629 void rowsInsertedCallback(const QModelIndex &parent, int begin, int end);
630 void rowsRemovedCallback(const QModelIndex &parent, int begin, int end);
631 void columnsInsertedCallback(const QModelIndex &parent, int begin, int end);
632 void columnsRemovedCallback(const QModelIndex &parent, int begin, int end);
633 void layoutChangedCallback(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint);
634 void modelResetCallback();
635 void dataChangedCallback(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList<int> &roles);
636 bool compareModel(const QVariant& model1, const QVariant& model2) const;
637
638 void positionViewAtRow(int row, Qt::Alignment alignment, qreal offset, const QRectF subRect = QRectF());
639 void positionViewAtColumn(int column, Qt::Alignment alignment, qreal offset, const QRectF subRect = QRectF());
640 bool scrollToRow(int row, Qt::Alignment alignment, qreal offset, const QRectF subRect = QRectF());
641 bool scrollToColumn(int column, Qt::Alignment alignment, qreal offset, const QRectF subRect = QRectF());
642
643 void scheduleRebuildIfFastFlick();
644 void setLocalViewportX(qreal contentX);
645 void setLocalViewportY(qreal contentY);
646 void syncViewportRect();
647 void syncViewportPosRecursive();
648
649 bool selectedInSelectionModel(const QPoint &cell) const;
650 void selectionChangedInSelectionModel(const QItemSelection &selected, const QItemSelection &deselected);
651 void updateSelectedOnAllDelegateItems();
652 void setSelectedOnDelegateItem(const QModelIndex &modelIndex, bool select);
653
654 bool currentInSelectionModel(const QPoint &cell) const;
655 void currentChangedInSelectionModel(const QModelIndex &current, const QModelIndex &previous);
656 void setCurrentOnDelegateItem(const QModelIndex &index, bool isCurrent);
657 void updateCurrentRowAndColumn();
658
659 void fetchMoreData();
660
661 void _q_componentFinalized();
662 void registerCallbackWhenBindingsAreEvaluated();
663
664 inline QString tableLayoutToString() const;
665 void dumpTable() const;
666
667 void setRequiredProperty(const char *property,
668 const QVariant &value,
669 int serializedModelIndex,
670 QObject *object, bool init);
671
672 void handleTap(const QQuickHandlerPoint &point);
673 void setCurrentIndexFromTap(const QPointF &pos);
674 void setCurrentIndex(const QPoint &cell);
675 bool setCurrentIndexFromKeyEvent(QKeyEvent *e);
676 bool canEdit(const QModelIndex tappedIndex, bool warn);
677 bool editFromKeyEvent(QKeyEvent *e);
678 void closeEditorAndCommit();
679 QObject *installEventFilterOnFocusObjectInsideEditItem();
680
681 // QQuickSelectable
682 QQuickItem *selectionPointerHandlerTarget() const override;
683 bool hasSelection() const override;
684 bool startSelection(const QPointF &pos, Qt::KeyboardModifiers modifiers) override;
685 void setSelectionStartPos(const QPointF &pos) override;
686 void setSelectionEndPos(const QPointF &pos) override;
687 void clearSelection() override;
688 void normalizeSelection() override;
689 QRectF selectionRectangle() const override;
690 QSizeF scrollTowardsPoint(const QPointF &pos, const QSizeF &step) override;
691 void setCallback(std::function<void(CallBackFlag)> func) override;
692 void cancelSelectionTracking();
693
694 QPoint clampedCellAtPos(const QPointF &pos) const;
695 virtual void updateSelection(const QRect &oldSelection, const QRect &newSelection);
696 QRect selection() const;
697 // ----------------
698
699 // Section drag handler
700#if QT_CONFIG(quick_draganddrop)
701 void initSectionDragHandler(Qt::Orientation orientation);
702 void destroySectionDragHandler();
703#endif
704 inline void setActivePointerHandler(QQuickTableViewPointerHandler *handler) { activePtrHandler = handler; }
705 inline QQuickTableViewPointerHandler* activePointerHandler() const { return activePtrHandler; }
706 // Row/Column reordering
707 void moveSection(int source , int destination, Qt::Orientation orientation);
708 void initializeIndexMapping();
709 void clearIndexMapping();
710 void clearSection(Qt::Orientation orientation);
711 virtual int logicalRowIndex(const int visualIndex) const;
712 virtual int logicalColumnIndex(const int visualIndex) const;
713 virtual int visualRowIndex(const int logicalIndex) const;
714 virtual int visualColumnIndex(const int logicalIndex) const;
715 void setContainsDragOnDelegateItem(const QModelIndex &modelIndex, bool overlay);
716 int getEditCellIndex(const QModelIndex &index) const;
717};
718
720{
721public:
722 FxTableItem(QQuickItem *item, QQuickTableView *table, bool own)
724 {
725 }
726
727 qreal position() const override { return 0; }
728 qreal endPosition() const override { return 0; }
729 qreal size() const override { return 0; }
730 qreal sectionSize() const override { return 0; }
731 bool contains(qreal, qreal) const override { return false; }
732
734};
735
736Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickTableViewPrivate::RebuildOptions)
737
738QT_END_NAMESPACE
739
740#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:2582
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
QT_REQUIRE_CONFIG(quick_tableview)
static const qreal kDefaultColumnWidth
static const int kEdgeIndexAtEnd
static QT_BEGIN_NAMESPACE const qreal kDefaultRowHeight
static const int kEdgeIndexNotSet