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