aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview.cpp
Commit message (Collapse)AuthorAgeFilesLines
* TableView: fix initial topRow/bottomRow/leftColumn/rightColumn signalsMiika Pernu8 days1-1/+1
| | | | | | | | | | Property changed signals weren't correctly emitted due to comparison against old values that were incorrect. When constructing the view for the first time, the properties have initial value of -1 and not 0. Fixes: QTBUG-142067 Change-Id: I86bde8abd65e6f135a9f03f35913da914d762d26 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* tableview: fix build with -no-feature-cursorNick Shaforostov2025-11-131-1/+3
| | | | | | | Pick-to: 6.10 Change-Id: I2667210311de7ee41db1d90fff71d4d4bb388ee2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* doc: delegateModelAccess was added in Qt 6.10Kai Uwe Broulik2025-11-061-0/+1
| | | | | | Pick-to: 6.10 Change-Id: I795c2a35e2fec71d8dbe481ff334b9bcfdf6692a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Set explicit default security level of all files with default securityJan Arve Sæther2025-09-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The files (folders) already processed are listed in each issue in epic QTBUG-134547 These files were processed half a year ago. In order to make it clear that all of these files are already processed, mark them with an explicit default security header. For the record, this was generated with this script: find -E . -regex ".*\.(cpp|h|hpp|mm|qml|js)$" | xargs python3 ~/bin/add-cra-header.py in the folders listed in each subtask of QTBUG-134547 (add-cra-header.py only exist at my desktop, but it simply adds the default security header if it doesn't already have any existing security header) QUIP: 23 Fixes: QTBUG-134547 Pick-to: 6.10 6.9 6.8 Change-Id: Ieb8c78ea6561fdbdd27c7b13185ece853eedf80f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* QQuickTableView: Expose internal model changes via the model propertyUlf Hermann2025-09-151-1/+17
| | | | | | | | | | | | | | | If the delegate changes the model, those changes need to be visible in the "model" property of the view. To this end, use QQmlTableInstanceModel's model variant instead of the assigned one once it has been synchronized. The inner change signaling from the delegates to the view will be added in a separate change. Pick-to: 6.10 Task-number: QTBUG-139941 Change-Id: I1296fa2c886dad063b6b39defef56cb7faf1e943 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQuick: Simplify TableView model handlingUlf Hermann2025-09-131-17/+15
| | | | | | | | | Unwrap any QJSValues right away and eliminate a copy of the model. Pick-to: 6.10 Task-number: QTBUG-139941 Change-Id: I7f4a3ea97ae64cf0bb24aa032f8307c56bf7a597 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Make it explicit that TableView's rowHeight and columnWidthProvider's can ↵Kai Köhne2025-07-241-4/+4
| | | | | | | | also return undefined Pick-to: 6.9 6.10 Change-Id: I074c817a9e29a385ba2b6b8ee32c06c84853ac99 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: use correct model when checking if an item is editableRichard Moe Gustavsen2025-06-061-2/+2
| | | | | | | | | | | | | | | | When TableView needs to resolve if a model item is editable, it needs to call QAbstractItemModel::flags(modelIndex). But as it stood, it would call this function on the internal proxy model set by TreeModel, using a QModelIndex from the application model (tappedIndex). Since tappedIndex belongs to the application model, this patch makes sure that we ask the application model, and not the proxy model, if the given model item is editable. Fixes: QTBUG-136492 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I0011c46f1b07470ebcb83d93aa3d592e7339345e Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Doc: Fix \sa in rowHeightProviderKai Köhne2025-05-221-1/+1
| | | | | | | | | | There's no point in linking to the very same property. Probably a copy-and-paste error ... Pick-to: 6.9 Change-Id: I42231076955d625765d2a1687c9de5766c2198fb Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix TableView::view attached property being null in certain situationsDavid Redondo2025-05-201-0/+3
| | | | | | | | | | | When a delegate modifies a property or connected to a signal of the attached object the attached object is created before the parent item of the delegate is set so view would end up unset. Fixes: QTBUG-133562 Pick-to: 6.9 Change-Id: Ia227c9ee009ea719656f802a99cf43afc02d28d9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: ensure focus transfer within the edit delegate worksRichard Moe Gustavsen2025-04-031-10/+22
| | | | | | | | | | | | | | | | | | Commit 48cb120c5f0bb5ce093b46bfe63751b4bd01caf9 broke focus transfer within an edit delegate, since we would always close the editor upon receiving a focus out event. A typical use case is an edit delegate that contains an editable ComboBox. In that case, focus will be transferred within the delegate if the combo's textfield gains focus. This patch will make sure that we only close the editor if the edit item as a whole loses focus. Task-number: QTBUG-134247 Pick-to: 6.9 6.8 Change-Id: If092ca91a96667eb2ee8ba271a2239086f5a2998 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: remove wrong documentationRichard Moe Gustavsen2025-03-271-2/+1
| | | | | | | | | | | Calling TableView.edit() will _not_ ignore the ItemIsEditable flag. It doesn't make sense to ignore it either, since opening up an edit delegate on a cell that cannot be modified is pointless. So remove the faulty line from the documentation. Pick-to: 6.9 6.8 Change-Id: Ife7dfd8649edce57945f977329d3c1ea2f247b01 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Quick: Expose delegateModelAccess from QQuickTableViewUlf Hermann2025-03-181-0/+37
| | | | | | | | | | | | | | | It mirrors the same property from any internal table instance model. If the internal model is not a table instance model, the value is "Qt5ReadWrite". [ChangeLog][QtQuick] TableView and TreeView now have a new property delegateModelAccess. Setting it to DelegateModel.ReadWrite allows you to write values into the model via required properties just as you could with context properties. Task-number: QTBUG-132420 Change-Id: Ie3ee1da3a8ec56390a645f95e9862e42dcd01deb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* TableView: emit commit on editor loss of focus, unless Qt::Key_EscapeRichard Moe Gustavsen2025-03-061-12/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | As it stood, we would only commit changes in the edit delegate when the user pressed Enter, Return, or Tab/BackTab. The result was that the changes would be not be committed (and hence lost) if the user clicked somewhere else in the UI to transfer focus. This behavior is basically wrong. Instead, it should be the opposite, meaning that we should _always_ commit the changes unless the user explicitly cancelled editing by pressed Escape. This behavior is also verified by testing macOS "Numbers", and Google "Sheets" (both spreadsheet apps). This patch will therefore change the faulty behavior, so that we commit the changes whenever the edit item loses focus, unless it happened because the user hit Escape. [ChangeLog][Quick][TableView] The edit delegate will now emit the onCommit signal when it loses focus, unless it was closed from Qt::Key_Escape. Fixes: QTBUG-134247 Pick-to: 6.9 6.8 Change-Id: I1afab7bce9ba159330203d5a8d2b1af57ce9875b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix TableView crash when reordering if are either no rows or no columnsJoni Poikelin2025-02-041-8/+6
| | | | | | | Fixes: QTBUG-133301 Pick-to: 6.9 6.8 Change-Id: I3032d790ecf850dce93ad719a3ab63d0773d53c3 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Replace QBoolBlocker with QScopedValueRoolbackThiago Macieira2025-01-251-13/+13
| | | | | | | | | | | It was pre-Qt 4.5 (so pre-C++11), while QScopedValueRollback is 4.8. Both are still old, but with Qt 6 and C++17, we can use CTAD. QScopedValueRollback requires a value change to be explicit, which is less surprising. Change-Id: Ia930b1a2ed1e465a826ffffd179c1909e16583db Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* SelectionRectangle: Deactivate when the last cell is unselectedMohammadHossein Qanbari2025-01-091-0/+5
| | | | | | | | | | | | | | | | | | | | This commit introduces changes to ensure that the SelectionRectangle is properly deactivated when the last selected cell in QQuickTableView is unselected. Key changes include: - Added a virtual method `hasSelection()` to QQuickSelectable interface - Implemented `hasSelection()` for QQuickTableViewPrivate, which checks if any items are selected - Updated QQuickSelectionRectangle to utilize the new `hasSelection()` method to determine its active state The test case checks that after deselecting the last selected cell, both the SelectionRectangle and its handles are properly deactivated. Pick-to: 6.8 6.9 Change-Id: I97214bb0d91dda8a902a4725918b60209b853acf Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* TableView: fix -no-feature-quick-draganddrop buildShawn Rutledge2025-01-061-0/+3
| | | | | | | | | Now it builds if Qt is configured without DnD. Fixes: QTBUG-132355 Pick-to: 6.8 6.9 Change-Id: I76c7660e32c19dcb96a72a116eb6475ffb56183b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: Fix crash when selecting uninitialized TableViewMohammadHossein Qanbari2024-12-121-5/+15
| | | | | | | | | | | | | | | | | | | | This patch addresses an issue where TableView would crash when attempting to select cells without an initialized delegate. The problem occurred because the selection rectangle calculation did not account for empty columns or rows. The fix includes the following changes: - Validate selection rectangle to ensure non-zero width or height. - Check loaded rows/columns before change current index on key event. A new test case is added to verify that selection works correctly when the TableView delegate is not initialized. Some tests are just added to verify no crashes happen. Pick-to: 6.8 6.9 Change-Id: I5060976c721d3625d016f7dc88d94b7277e2d0cb Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TableView: fix documentation linksMohammadHossein Qanbari2024-12-111-2/+2
| | | | | | | | Update the documentation for positionViewAtRow and positionViewAtColumn methods in TableView to use proper linking for Flickable properties. Change-Id: Icc7268d2ff76be71d801ba7f3b9c66e012f9af5f Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
* TableView: only create attached object when usedRichard Moe Gustavsen2024-12-051-4/+22
| | | | | | | | | | | | | | | | | | | | As it stood, we created an attached TableView delegate for every delegates inside a TableView, even if they were never used. This was not the intention from the start, and must have been an oversight. Instead, we want to reduce memory overhead for each delegate, and only create attached objects on a per-need basis. This was also the rationale behind using required properties over attached properties, to avoid having to allocate so many extra attached objects (one for each cell). This patch will therefore avoid creating attached objects for every delegate, and instead resolve the TableView.view property when the attached object is actually constructed (if ever). Change-Id: I69528371e59d7ef4007f63029db9a46a41c40d0b Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* TableView: ensure we position the syncView in the right directionRichard Moe Gustavsen2024-12-031-2/+2
| | | | | | | | | | | | | | | | If a TableView has a syncView, a call to positionViewAtCell() will instead be forwarded to the syncview, according to the syncDirection. But as it stood, this was flipped, so that we ended up forwarding a horizontal positioning call to a vertically synced syncView, and vice versa. This patch will correct this, so that the forwarded positioning call matches the syncDirection. Pick-to: 6.8 6.5 Fixes: QTBUG-131776 Change-Id: Ibeaf5ce3d1d18c1ef0a0184c38336860fdee67be Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* QQuickSelectable: Fix selection in TableView and TreeView on AndroidMohammadHossein Qanbari2024-11-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The issue was that the TableView was not selectable on the Android platform. This was due to `dynamic_cast<QQuickSelectable*>(QQuickTableViewPrivate*)` returning null, which prevented the QQuickSelectionRectangle's DragHandler (responsible for selecting cells by dragging) from being added to the TableView. Since dynamic_cast is not fully supported on Android, it fails sometimes (returns null instead of performing the cast), when interface types lack a key function (a non-inline and non-pure virtual function). To resolve this, we need at least one key function. References: * https://developer.android.com/ndk/guides/cpp-support under "RTTI" section * https://developer.android.com/ndk/guides/common-problems under "RTTI/exceptions not working across library boundaries" section This patch adds a destructor (key function) for the QQuickSelectable type to address this issue. Additionally, related tests in TableViewDelegate and TreeViewDelegate have been removed from the BLACKLIST. Fixes: QTBUG-101159 Task-number: QTBUG-114636 Pick-to: 6.8 6.5 Change-Id: I91440b0b2f746e866d242d12fb20918a4830cd39 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Controls: Add TableViewDelegateMohammadHossein Qanbari2024-11-271-12/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces TableViewDelegate to the Controls module. Key features: - Ready-made delegate assignable to TableView - Handles table drawing using predefined styles - Usable without customization - Implements all required properties set by TableView - Provides API for changing background and label Test Suite: - Verifies TableViewDelegate properties and functionalities - Tests include: - Verification of selected, current, and content text properties - Validation of selection behavior and item clicking BLACKLISTing two tests (dragToSelect and pressAndHoldToSelect), which will be removed from the BLACKLIST in the next patch (to fix cell selection on the Android platform). Implementation derived from TreeViewDelegate, adapted for TableView use. TreeViewDelegate patch: 0ddb0d4b9b0c70c4fd4058ef4660e38fd933523e [ChangeLog][Controls] New delegate added: TableViewDelegate Fixes: QTBUG-114636 Change-Id: Ibb8b0a7622016e0c6fd58d696e507e7bb76daced Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Reset section drag handler to nullptr in the table viewSanthosh Kumar2024-11-121-1/+3
| | | | | | | | | | The section drag handler in the table view can sometimes leads to crash with invalid reference. Its better that we reset the state of the drag handler to nullptr. Pick-to: 6.8 Change-Id: I75a10bea0f98e853a728d8376f3de78ecbc33d79 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: accept rearrange drop event, to avoid misleading animationRichard Moe Gustavsen2024-11-111-0/+1
| | | | | | | | | | | | | | | | | As it stood, when you dragged and dropped a column, the drag image would animate back to the start. This is an indication that the drop was not accepted, which is not correct, since the drag'n'drop operation actually succeeds. This patch will therefore make sure that we accept the drop event, to indicate that the operation was successful. This will stop the drag image from animating back to start. Pick-to: 6.8 Change-Id: I9c39a88520a09b0fd77eb2009f767fdc6be2ffd5 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Fix TreeView cell editKaj Grönholm2024-11-071-2/+10
| | | | | | | | | | TableView sections moving (QTBUG-100440) affected also TreeView so that wrong cell index was edited. Task-number: QTBUG-130589 Pick-to: 6.8 Change-Id: I88c7cbebc1409dcaa511b03038bf3875f0378b69 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* QQuickTableView: ensure VerticalHeaderView stays in syncRichard Moe Gustavsen2024-09-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Bacuse of a copy-paste error in QQuickTableView, TableView would calulcate the wrong viewport rect for vertically synced views if the views were not also synced horizontally. The result of this mistake was that the rows in the two views would end up with with different heights (and y pos) while flicking. This bug has been there for a very long time, but was hidden becuse of anther bug that was recently fixed (25348bc0e6). After that fix, this new bug became evident. This patch will make sure that the offending if-test checks the correct sync direction, and thereby also calculate the correctly combined viewport rect. Fixes: QTBUG-128508 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: Idf4d93830933c9a28786adaba14e068015564fcc Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: don't leave the viewport in an overshooting state after resizeRichard Moe Gustavsen2024-08-211-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we need to change the extents of the Flickable (that is, which point should be considered the top-left and bottom-right corner of the contentItem inside the viewport), it can sometimes happen that that Flickable is left suspended in an overshooting state (that is, it looks as if the user dragged the contentItem out-of-bounds, which will normally make it bounce back upon a release). And this comes across as a bug. This patch will therefore call returnToBounds() explicitly whenever we change the extents (unless the contentItem is being dragged, as we don't want to interrupt that). As it stood, we would also call markExtentsDirty() far too often from updateExtents(), even when the extents didn't change. Depending on what Flickable does to handle dirty extents, this causes uneccessary overhead and might slow down performance. It also produces a lot of superfluous logging output in TableView. This patch will therefore also check if the extents change before calling markExtentsDirty() (and as such, avoid calling returnToBounds() all the time). Task-number: QTBUG-127809 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: Id801f3e62b3dcde1b59d49e4efc9d6631d5672bb Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* QQuickTableView: detect if sync view and sync child is out of syncRichard Moe Gustavsen2024-08-161-10/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When syncView is requested to do a relayout, it will tell the sync children to do relayout as well. A relayout alone will not change the top-left delegate item in the viewport, only layout the existing delegate items. But as it turns out, it can happen that the relayout leaves empty space in the viewport that needs to be refilled with new rows and columns. This is typically the case if some of the columns were resized smaller than what they used to be. And this can change which cell ends up as top-left, or move it to a different position. We therefore need to extend the check in syncSyncView to also include the _position_ of the top-left cell, and not only if the top-left cell itself has changed. As it stood, we also did a viewportOnly rebuild every time a new row or column was flicked into the viewport. This is very unnecessary, and slows down performance. Instead, we only need to do this when if the sync child is told to do (at least) a LayoutOnly. Only then can any of the visible rows or columns have been resized. Fixes: QTBUG-127809 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: I815a47e9d6453871172ff7136f8cfbd51a5bc789 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* QQuickTableView: remove unused functionRichard Moe Gustavsen2024-08-151-12/+0
| | | | | Change-Id: I48e648d26d7954ed4b4709fa4812e8846d1f92eb Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Reset handler state when dragged item dropped outside the drop areaSanthosh Kumar2024-08-131-0/+4
| | | | | | | | | | | | | | | | | The handler state had been reset only after the release state. This causes the handler to be inconsistent when the dragged item is dropped outside the corresponding drop area. It can even lead to a crash (as mentioned in the bug report) when the next drop happens over the same location. This patch resets the state of the handler whenever a drop happens (as this causes the drag event loop to exit). Fixes: QTBUG-127865 Pick-to: 6.8 Change-Id: I14cac162df8af8b7b6b9eed99631e29bada410d1 Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix crash when dragging an invalid item in the header viewSanthosh Kumar2024-08-091-0/+2
| | | | | | | | | | | | | | | Dragging an invalid item in the header view leads to a crash. It's better to safeguard before operating anything w.r.t. to the dragged item. This patch fixes that issue by validating the invalid item before performing drag operation. Also added an test case to verify the same. Fixes: QTBUG-127782 Pick-to: 6.8 Change-Id: I95398c7410d6fb6427ec06ff4b7da42472bc6d18 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
* Fix table view to provide the right index to the section size providersSanthosh Kumar2024-08-071-2/+2
| | | | | | | | | | | | | | | | The reordering of sections updates the logical and visual index mapping table internally, which is further used to provide the correct index to the public APIs. However, this creates an issue when the index provided to the columnWidthProvider() or rowHeightProvider() was already a logical index and this once again converted in explicitColumnWidth() or explicitRowHeight(). This patch fixes it by providing the column or row view index to the section size providers. Pick-to: 6.8 Change-Id: If0be55b1039e5fcea7b366570da020ae5e32b517 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Doc: fix links in documentation of Quick itemsVolker Hilsheimer2024-07-121-4/+4
| | | | | | | | | implicitWidth/Height are properties of Item, and parent is not a property of the Window type, but a method in the QQuickWindow class. Pick-to: 6.8 Change-Id: I3136cf6e8775f51e761b2000f5a92765717a8e26 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: update the docs for implicitRowHeight/ColumnWidthRichard Moe Gustavsen2024-06-251-16/+10
| | | | | | | | | | | The current text was talking about the rowHeightProvider, which is just confusing, as that function would never be used for calculating implicit sizes anyway. So remove those lines, and take the time to rewrite the text a bit. Pick-to: 6.8 6.7 6.5 Change-Id: If637510ae1d14e547610b79800ebe8e06fddcce4 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* QQuickTableView: update modelIndex() docsRichard Moe Gustavsen2024-06-251-1/+3
| | | | | | | | | | | There is no longer a function called modelIndex() that takes a row and column as argument. This function was renamed to index(row, column) in Qt 6.4. So update the docs to reflect this. Pick-to: 6.8 6.7 6.5 Change-Id: I2bbb33265f246a062b1adfedb18fab8025b70e31 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Reset section drag handler state in the quick table viewSanthosh Kumar2024-06-171-3/+9
| | | | | | | | | | | | | | | The section drag handler used to drag column (and row) doesn't reset its internal pointer state after dropping it. This stale internal pointer state causes an issue for the next drag operation. This patch resets the stale pointer state within the section drag handler. Fixes: QTBUG-126039 Pick-to: 6.8 Change-Id: I2b7dc1679caa3efe4a34334b99caa5a8966e2778 Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* SelectionRectangle: clear selection from TableViewRichard Moe Gustavsen2024-06-111-2/+5
| | | | | | | | | | | | | | | | | | | If the TableView delegate has a TapHandler, it will shadow the TapHandler in TableView that normally clears the old selection when a new drag selection begins. This means that the SelectionRectangle will keep on extending the current selection, even when no modifiers are being held. This patch will make the selection logic more robust by leaving it to QQuickTableView::startSelection() to clear (or not clear) the existing selection. Then we don't depend on the TapHandler in TableView to be called, and we can also simplify SelectionRectangle a bit. Pick-to: 6.8 6.7 6.6 Task-number: QTBUG-125867 Change-Id: Iaa3c6414d916773f62de4faec5a2fcb7b2f3e6d0 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Support drag and drop section reordering in the table viewSanthosh Kumar2024-05-271-18/+294
| | | | | | | | | | | | | | | | | | | | The new drag handler (QQuickTableViewDragHandler) in the header view allows the user to drag and drop row or column at the required index. At any point in time, there can be only one active handler, and depending on the type of operation, the corresponding handler consumes the pointer events. The user can customize the delegate using the new property 'containsDrag' when any corresponding drop section is activated while dragging a column or row. [ChangeLog][QtQuick][TableView] Added new property 'containsDrag' for the delegate, and it is set when a user drags a column or row on top of another delegate. This property is applicable only for HorizontalHeaderView and VerticalHeaderView. Task-number: QTBUG-100440 Change-Id: I52b1079559192f406e295aa34ca1d86acef61a6d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Support moving sections (row and column) in quick table viewSanthosh Kumar2024-05-211-30/+329
| | | | | | | | | | | | | | | | | | | | | Add support in quick table view to reorder rows and columns. The properties 'movableColumns' and 'movableRows' enable the header view to reorder columns and rows, which are disabled by default. These properties allow the user to drag and drop sections for the row and column reordering. It is to be noted that these properties apply only to the header view (HorizontalHeaderView and VerticalHeaderView) and do not apply to the TableView directly. The change in the header view will be synced to the table view by setting the corresponding view to the syncView property in the header view. The TableView can also explicitly reorder columns and rows through the public API moveColumn() and moveRow(). Task-number: QTBUG-100440 Change-Id: I320b91c5541836fa0c885f75c59dcde3608cf3c2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: support unselecting cellsRichard Moe Gustavsen2024-04-171-14/+50
| | | | | | | | | | | | | | | | | | | | | | As it stood, SelectionRectangle and TableView didn't support unselecting cells by ctrl-dragging or ctrl-clicking a selected cell. This is considered a bug. This patch will therefore make sure that we support doing that. In order to implement this, we need to provide the held keyboard modifiers to startSelection(), so that TableView can choose if the selected cells should become selected or unselected in the selection model. By making this change, it also became clear that some of the auto tests didn't call startSelection() before setSelectionStartPos(). We therefore now also assert that we always do this, and fix up the failing auto tests that violated this rule. Fixes: QTBUG-121143 Pick-to: 6.7 6.6 6.5 Change-Id: Icd58b551234f3c6145165771de599e46b62014dc Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* SelectionRectangle: ensure we remove or update selection handles if ↵Richard Moe Gustavsen2024-03-261-8/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | selection changes If you make a selection with SelectionRectangle and then resize a row, the selection handles will not move to the resized position. Likewise, if you do a selection, but then clear the selection by interacting with the ItemSelectionModel directly, the selection handles will not be updated to reflect the changes. To fix this bug, this patch will add a callback from TableView to SelectionRectangle that can be used to notify when changes are done outside of SelectionRectangle. This especially allows us to: - Remove the selection handles if the active selection is cleared or changed programatically (or anyway not by SelectionRectangle). - Keep the selection handles, and update their position, when rows or columns are merely resized. This change also allows us to clean up qquickselectionrectangle.cpp a bit, and remove e.g a now superfluous tap handler listener. Task-number: QTBUG-121143 Pick-to: 6.7 6.6 6.5 Change-Id: Id170520d49bc92c0bb9d16deaba741cab6f5c553 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* QQuickTableView: remove syncView from destructorRichard Moe Gustavsen2024-02-291-0/+8
| | | | | | | | | | | | If a TableView has a syncView, we need to ensure that it detaches itself from the syncView when it's destroyed. Otherwise the syncView will have a dangling pointer to the deleted TableView afterwards, which can cause a crash. Fixes: QTBUG-120760 Pick-to: 6.7 6.6 6.5 Change-Id: I4c6acfaa0c623ea43ba8b938585fcd9c9247f66c Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Doc: Fix broken linkVenugopal Shivashankar2024-02-231-1/+1
| | | | | | | | | | | | | | Fixed the following qdoc warnings: - src/quick/items/qquickitem.cpp:[7966,7974]: (qdoc) warning: Can't link to 'QQuickControl' - src/quick/items/context2d/qquickcontext2d.cpp:3412: (qdoc) warning: Undocumented parameter 'imageData' in Context2D::createImageData() - src/quick/items/qquicktableview.cpp:1230: (qdoc) warning: Undocumented parameter 'cell' in TableView::modelIndex() - examples/quick/quickshapes/weatherforecast/doc/src/weatherforecast.qdoc:[13,21,27,45,78,83,93,102,105]: (qdoc) warning: Can't link to 'Qt Quick Shapes' Fixes: QTBUG-122230 Pick-to: 6.7 Change-Id: I4f533ed95c13a99d649568d7b773437712b5b2d1 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* TableView: improve debug outputRichard Moe Gustavsen2024-01-301-13/+47
| | | | | | | | | | Add QDebug operators for RebuildOptions and RebuildState. This will make the output more readable if e.g enabling "qt.quick.tableview.lifecycle" categorized output. Change-Id: I2a5812e9536585f73cfe68fa7af10aa77b7abb39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* TableView: don't clear existing selectionRichard Moe Gustavsen2024-01-181-5/+17
| | | | | | | | | | | | | | | | | If TableView.selectionMode is ExtendedSelection, and the user starts a second selection (by pressing ControlModifier while dragging), the second selection can end up clearing the first if they temporarily overlap. This change will make sure that we save the current selection when a new extended selection starts, to ensure that a cell will stay selected if either the first or the second selection selects it. Pick-to: 6.7 6.6 Fixes: QTBUG-121132 Change-Id: I7bd6eeb4b0cc2372aa683c3c71d8e1b25c5ef17e Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* TableView: start a new selection when using Qt::ShiftModifierRichard Moe Gustavsen2024-01-091-3/+12
| | | | | | | | | | | | | | | If no selection exists in TableView from before, and the user shift-clicks on a cell, then start a new selection from the current cell towards the clicked cell. This is already how it works if a selection is started using the keyboard, and also standard selection behavior for other item view implementations outside of Qt (e.g Finder on macOS). Fixes: QTBUG-120628 Pick-to: 6.7 6.6 6.5 Change-Id: I2fd34e680eed9992dd7c405fbd58ae4f5b0834ec Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Fix crash issue in quick table view controlSanthosh Kumar2023-11-131-4/+10
| | | | | | | | | | | | | | | | | | | The quick table view can have both QAbstractItemModel and JS value as its model. The table view release and load the items (or rebuild) when its assigned with new model. The newmodel always be compared with existing model before rebuild via QQuickTableViewPrivate::syncModel. This comparison works with QAbstractItemModel but the same fails with JS model. This patch adds additional validation in QQuickTableViewPrivate::syncModel and QQuickTableViewPrivate::setModel for comparing JS model to avoid rebuild when existing model overwritten with same model again. Fixes: QTBUG-117917 Pick-to: 6.6 6.5 6.2 Change-Id: Ic15145c4b8998c68ae6471a2abf4aef727041eea Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* TableView: don't rebuild everything if row count changedRichard Moe Gustavsen2023-11-131-13/+14
| | | | | | | | | | | | | | | | | | | | | As it stood, TableView would rebuild the whole table if we got a call to forceLayout before a pending rowsInsertedCallback was delivered. This was far too harsh, as we a RebuildOption::All will throw away all existing delegates, and reset the contentItem back to zero. The correct thing to do, is to do the same that we already do in rowsInsertedCallback; just schedule RebuildOption::ViewportOnly. But since we don't know what else might have changed, we now also need to take the previous "else" case path in the function. Pick-to: 6.6 6.5 6.2 Task-number: QTBUG-118897 Change-Id: I23fe30c7d9e6abf32a6565c18bd9249de459636c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>