aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* TableView: don't emit rows and columns changed while rebuildingRichard Moe Gustavsen2023-11-091-16/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We should be careful about emitting signals while we do a rebuild. The reason is that the application might listen to those signals and change Flickable properties (especially contentX/Y) behind TableView's back. A bug is seen from this if the application is setting a very large contentY upon receiving rowsChanged(). In that case TableView will not detect that it should do a "fast-flick" directly to the new contentY, but instead start to loadAndUnloadVisibleEdges() until it reaches the current viewport. And this can take a really long time, and therefore block the UI. This patch will wait to emit rows/columnsChanged until we're done rebuilding. At that point, it's safe to change properties such as contentX/Y from the application. The main usecase this patch is solving, is to be able to always position the viewport on the last row as new rows are added to the model. This can now be done by listening to onRowsChanged or onContentHeightChanged, and position the viewport at the end. The included auto test will therefore test this exact use case. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-118897 Change-Id: I6124fbd0e7097a2bbb89c887fe594c3028726aa7 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* QML TableView: resizable{Rows|Columns} scroll fixJonas Karlsson2023-09-211-0/+4
| | | | | | | | | | | The problem was that the table view resize handler accepted scroll events but did nothing with them. The fix is to simply not accept these events. Pick-to: 6.2 6.5 6.6 Fixes: QTBUG-116566 Change-Id: Ica4afc45908e1b4c0b8aac11a3798981b6250baf Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: let the subclass decide which model to use for selectionsRichard Moe Gustavsen2023-09-201-8/+33
| | | | | | | | | | | | | | | | | | | When a subclass that has a proxy model is in use, it's not given if the selection model should be using the application model or the proxy model to store selections. Rather, this is subclass specific. In case of TreeView, the application model should be used. In case of HeaderView, the proxy model should be used. Until now, we always used the application model, which would fail if trying to select cells in HeaderView. The reason for the latter is that the proxy model in HeaderView doesn't share any common model items with the application model, and therefore cannot use the application model for selections. Fixes: QTBUG-115227 Pick-to: 6.6 6.5 6.2 Change-Id: I39f0687e0396392039234787fda0df6d7d4d7da4 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableViewResizeHandler: Silence warning about switch fall throughFriedemann Kleint2023-08-251-1/+1
| | | | | | | | Amends 8733b01ce3e8eadbbe62b9e9a264d4ce699a6be8. Pick-to: 6.6 6.5 Change-Id: I2571c9b741e731a7937d3ddc25aef7eb3155557d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableViewResizeHandler: don't accept events outside of usMitch Curtis2023-07-061-2/+5
| | | | | | | | | | Handlers can be sent events that are outside of the target item, so check for that in wantsEventPoint. Fixes: QTBUG-111013 Pick-to: 6.2 6.5 6.6 Change-Id: I52f17fc7030a93d999188fe7608411f11d235858 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Doc: Fix linking issuesTopi Reinio2023-07-051-19/+24
| | | | | | | | | | | | | | | | | | | * Remove broken links to 'Scene Graph - Rendering FBOs' example as it no longer exists. * Remove a link to 'Calendar Example' from a list of QML examples; this was a widgets example. * TableView: Fix linking to enumeration values and change enum properties to use \value commands. * LayoutItemProxy: Fix linking to Item.visible property. * Shape: Fix broken links to enumeration values. Pick-to: 6.6 Change-Id: Id3a33cac722dd62c61792eeb7163a01d6fd2b6e5 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
* Fix crash while positioning zero sized table viewSanthosh Kumar2023-06-281-2/+8
| | | | | | | | | | | | | | | | | | | | TableView expects view size to be specified for loading model items within it. If not specified, it doesn't load any items (change made after patch set ebefb583c886dba86aa51012fb377762235f2379). If user positions the view through positionViewAtCell or positionViewAtColumn or positionViewAtRow without specifying view size, then the TableView crashes and its an unexpected behavior. This patch set adds validation in the TableView to check for loaded columns or rows during positioning. The document also been updated to show the expected behavior of TableView when size not specified. Fixes: QTBUG-113738 Pick-to: 6.5 6.6 Change-Id: Ibd72caada5bfeb290ab5eff3b9ead1e07b3a7176 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* TableView: implement SelectionModeRichard Moe Gustavsen2023-06-021-5/+62
| | | | | | | | | | | | | | | | | | | | | | | This patch will implement support for setting a selectionMode. This API mirrors the selectionMode API in QTableView. Currently only SingleSelection, ContiguousSelection and ExtendedSelection are implemented. The last mode, MultiSelection, is postponed for now since its unclear which use-case it supports, and also seems to overlap too much with ExtendedSelection (if holding down Control modifier). NoSelection is already supported by setting selectionBehavior to TableView.SelectionDisabled. [ChangeLog][Quick][TableView] You can now set a selectionMode in TableView, to control if the user should be allowed to select single or multiple cells. Fixes: QTBUG-112836 Fixes: QTBUG-112835 Change-Id: I0f96d9fb68882aededc42d653c861cfd22e3d03a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix delegate loading issue when valid size is specifiedSanthosh Kumar2023-05-301-2/+8
| | | | | | | | | | | | | | The patchset ebefb583c886dba86aa51012fb377762235f2379 is made to avoid loading delegate when view port size is zero. But this affects the scenario when any of its size is valid in delegates. This patchset fixes delegate loading issue when valid size is specified in it. Fixes: QTBUG-113852 Pick-to: 6.5 Change-Id: Ib8b527175b91fefb8062f7ea5abc0c9b7860a0e7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Ignore tap events for table view when interactive is disabledSanthosh Kumar2023-04-111-1/+15
| | | | | | | | | | | | | | | | | | TableView uses QQuickTapHandler internally to handle tap events. This handler accepts tap events considering pointerNavigationEnabled property of table view. TableView accepts mouse events if either 'interactive' or 'pointerNavigationEnabled' property is set as true, otherwise, it has to pass mouse or touch events to the below item. This patch introduces QQuickTableViewTapHandler inherited from QQuickTapHandler that can explicitly check pointerNavigationEnabled property of QQuickTableView during wantsEventPoint to either accept or ignore tap events. Fixes: QTBUG-108596 Pick-to: 6.4 6.5 Change-Id: I330ae319706b6dbadc3a7319f62d636708aab995 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* doc: Fix some warnings (broken links)Shawn Rutledge2023-03-281-21/+21
| | | | | | Change-Id: I9ef36d761860b7b28c5e5e6e37826abfda9d998f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickTableView: fix minor documentation issuesRichard Moe Gustavsen2023-03-221-28/+11
| | | | | | | | | Several documentation errors have sneaked in here and there. This patch will fix those issues. Pick-to: 6.5 Change-Id: I57beb9a39a06a8302e1e83f91078a8f3c1c50670 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QQuickTableView: only clear selections when selections are enabledRichard Moe Gustavsen2023-03-221-2/+4
| | | | | | | | | | | | | TableView should only modify a selection (which includes clearing it) when selections are enabled. Otherwise it should leave it to the application to modify the selection model explicitly. This can be used to set a selection that "sticks", regardless of what the user does. Pick-to: 6.5 Change-Id: I264946d1b3513846794e1fe12b7d94cfaef050ed Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* doc, HeaderView: add a code snippet to the documentationRichard Moe Gustavsen2023-03-211-0/+4
| | | | | | | | | Add a doc snippet to the HeaderView documentation that shows how can use it together with a TableView. Pick-to: 6.5 Change-Id: Id1043d2b6561f6e68e0ac120b7ba040760263314 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* QQuickTableView: implement SelectedTapped correctlyRichard Moe Gustavsen2023-03-171-15/+20
| | | | | | | | | | | | | | | | The current implementation of SelectedTapped allowed the user to start editing when tapping on the _current_ cell. This is not correct, SelectedTapped is supposed to (like the name suggests) let the user start editing when tapping on a _selected_ cell. This patch will change the implementation so that the user can tap on a selected cell to edit it. Pick-to: 6.5 Change-Id: Ice5de9250c23f5f57e71077d4f46d1a3f31e9b80 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: add more docs related to required propertiesRichard Moe Gustavsen2023-03-021-6/+33
| | | | | | | | | | The docs informing which required properties TableView supports are scattered a bit around. Document/mention them once more collected under the docs for the delegate. Pick-to: 6.5 Change-Id: Idacef9ceb486e936bef3800a8564b5cdc373f7a2 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Doc: Fix warnings for undocumented parametersTopi Reinio2023-02-211-0/+3
| | | | | | | | | | | | Fix undocumented parameters for TableView::positionViewAtIndex(), and increase the warning limit by one to address another warning that exists only on the dev branch. Pick-to: 6.5 Fixes: QTBUG-111290 Task-number: QTBUG-111289 Change-Id: I1da384a082163f1fd7fa9dbfa1e2afc3793d5c88 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* qquicktableview.cpp: Fix qdoc warningFriedemann Kleint2023-02-131-1/+1
| | | | | | | | qquicktableview.cpp:1318: (qdoc) warning: Unknown macro 'l' Pick-to: 6.5 6.4 Change-Id: I4d5c2df45ad6eaa3f974b1ab6bd4cb5e6e3cf235 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* TableView: deprecate positionViewAtCell(column, row) in favor of ↵Richard Moe Gustavsen2023-02-131-8/+40
| | | | | | | | | | | | | | | | | | | | positionViewAtIndex(modelIndex) After deprecating modelIndex(column, row) in favor of index(row, column), we should now do the same to positionViewAtCell(column, row), to be consistent. This function will therefore deprecate positionViewAtCell(column, row) and instead offer a new function positionViewAtIndex(modelIndex). [ChangeLog][Quick][TableView] positionViewAtCell(column, row) has been deprecated in favor of positionViewAtIndex(modelIndex). Task-number: QTBUG-109542 Pick-to: 6.5 Change-Id: Id47f990a6148acdb7c1185c7f654d6f2b261b2ad Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* TableView: deprecate itemAtCell(column, row) in favor of itemAtIndex(modelIndex)Richard Moe Gustavsen2023-02-131-1/+31
| | | | | | | | | | | | | | | | | | After deprecating modelIndex(column, row) in favor of index(row, column), we should now do the same to itemAtCell(column, row), to be consistent. This function will therefore deprecate itemAtCell(column, row) and instead offer a new function itemAtIndex(modelIndex). [ChangeLog][Quick][TableView] itemAtCell(column, row) has been deprecated in favor of itemAtIndex(modelIndex). Task-number: QTBUG-109542 Pick-to: 6.5 Change-Id: Ibd009cb3b9d6ce7ba19da5e20df9e307a31f5090 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* TableView: deprecate modelIndex(row, column) in favor of index(row, column)Richard Moe Gustavsen2023-02-131-10/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Deprecate modelIndex(row, column) in favor of a new function index(row, column), starting from Qt 6.4.3. This has the advantage that we can print out a deprecation warning when modelIndex() is is used at run-time from QML. This will inform the developer early on that he should avoid using modelIndex(row, column), since the argument order differs between different versions of Qt. Relying on compile time deprecation macros alone will not work, since the API break is in a private class and only used publicly from QML (except for our own internal auto tests). Since the equivalent function in QAIM is also called index(row, column), this will additionally make the naming more consistent with the model classes. [ChangeLog][Quick][TableView] modelIndex(row, column) has been deprecated in favor of index(row, column). Task-number: QTBUG-109542 Pick-to: 6.5 6.4 Change-Id: Iec8f5f8fa2a0ca714153128717b546bbd62c7e2c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Add snippet to demonstrate keyboard navigationAndreas Eliasson2023-01-301-1/+5
| | | | | | | | | | | Add example to showcase keybord navigation for the TableView QML type together with 'current' and 'selected' properties. Fixes: QTBUG-107889 Pick-to: 6.5 6.4 Change-Id: Ie95d85aa09e574bee16c23a2dff27056bc0bcd05 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: Don't fallthrough from tab/backtab to esc keyUlf Hermann2023-01-261-0/+1
| | | | | | | | | | | We probably don't want to close the editor if we didn't handle the tab key. Amends commit ed83f0f795132ef20ee6fafbad911a3da0a6c481. Pick-to: 6.5 Change-Id: I11c8f52d5ec8e1b67074ebf25d4cf4b35eb6b7e8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: set active focus directly on the edit itemRichard Moe Gustavsen2023-01-201-64/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When starting to edit a cell, the current implementation calls editItem->nextItemInFocusChain(true) to resolve the child to get active focus. But a better way is to instead rely on the edit item being a FocusScope. That way, we can simply set active focus on the edit item directly, and rely on the FocusScope forwarding active focus to the right child. After all, that is what FocusScopes are for. This patch will therefore change the implementation to set active focus directly on the edit item. But doing so turns out to cause tabbing from one cell to the next to stop working. The reason is that QQuickItem refuses to change setActiveFocusOnTab() on an item that has active focus. Instead, the focus item will eat the tab event, and use it to transfer focus to the next control in the chain. We therefore change the implementation to use an event filter on the focus object. That way, we're are guaranteed to always get a first shot at handling all critical key events that are needed for editing to work correctly. This includes tabbing, but even more imporantant, also Qt::Key_Enter, which is needed to allow the user to commit and close the editor. Pick-to: 6.5 Change-Id: I215b7efc52093eb0bd7f6a4fb60a57f83101e288 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: reposition selection handles whenever TableView updates the ↵Richard Moe Gustavsen2023-01-201-48/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | layout After TableView got support for resizable rows and columns, a side effect is that any overlay, like the selection handles, will need to be repositioned when rows and columns are resized. Currenly the selection handles will instead stay put at the initial location. This patch will make sure that SelectionRectangle listens to the layoutChanged() signal from TableView, and reposition the handles. Because the current selection rectangle implementation in TableView didn't take row and column resizing into account either, the logic that calculates the rectangle is also changed. Rather than storing the selection rectangle after each mouse drag, we now calculate the exact (and updated) rectangle when queried instead. Fixes: QTBUG-109448 Pick-to: 6.5 Change-Id: I80171f992bea1035c1410ede384a2d847ee3aa46 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Fix content position of table view controlSanthosh Kumar2023-01-181-9/+16
| | | | | | | | | | | | | | | | | | The estimated width in the table view has been used to layout and accordingly, edges of the table be loaded. This estimated width will be passed to flickable to adjust its parameters and width/position of scroll bar. This in turn change geometry of table view with respect to view port. In some scenarios, this estimated width during layout causes table view to be misaligned. This can be avoided by calculating and updating latest content width of the table view once after loading the edges of table. Fixes: QTBUG-108664 Pick-to: 6.5 6.4 6.2 Change-Id: I47c3325bc9e51f75c87564a2ec1de4522e4a7e60 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix build with -no-feature-cursorTasuku Suzuki2023-01-171-0/+16
| | | | | | Pick-to: 6.5 Change-Id: Ibb89885c6cde3e49fffbc02f9c83880f2f2dda5d Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* QQuickTableView: don't load any delegates if viewport has zero sizeRichard Moe Gustavsen2023-01-121-0/+11
| | | | | | | | | | | | | | | | When TableView has a zero size, the viewport will have zero size as well, and there is no reason to load any delegates. This patch will ensure that we return early from loadInitialTable() when we detect that this is the case. This will also stop a warning from being printed when the delegate has it's implicitWidth bound to tableView.width, and tableView.width == 0. Pick-to: 6.5 Change-Id: I659eb098f7c5c25c8359876f7664499381f94b98 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: change the order of row and column to modelIndex()Richard Moe Gustavsen2022-12-211-8/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Qt 6.3, TreeView had a function called modelIndex(). This function took two arguments: row and column. In Qt 6.4, This function was moved into TableView (the superclass) instead, since it was needed in both classes. And in that process (probably because this was done in several patches), the order of the arguments got swapped, to conform with two other functions in TableView that took a column and row as argument. But this was a source incompatible change. The result is that TreeView in Qt 6.3 has a function modelIndex(row, column) that works differently compared to Qt 6.4.0. The signature there is modelIndex(column, row). This patch will therefore effectively revert that SiC, and let modelIndex() again take row and column as arguments, like in Qt 6.3. The downside is that we already have two versions of Qt released (6.4.0 and 6.4.1) that contains the SiC. We therefore offer an environment variable that can be set to use the swapped version, if needed. [ChangeLog][Quick][TreeView] Because of a source incompatible change in Qt 6.4.0 and Qt 6.4.1, modelIndex(column, row) has been reverted back to modelIndex(row, column), equal to how it was in Qt 6.3. This also affects modelIndex() in TableView. If the order used in Qt 6.4.1 is needed, you can set the environment variable QT_QUICK_TABLEVIEW_COMPAT_VERSION=6.4 Pick-to: 6.5 6.4 6.4.2 Fixes: QTBUG-109542 Change-Id: I6af5e978d42b06c61ab0728e5e8b71f2a0300d13 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QQuickTableView: fix C++20 buildGiuseppe D'Angelo2022-12-181-2/+2
| | | | | | | | | Implicit capture of `*this` by reference when using [=] is deprecated. We can capture using [&] instead: all the variables used in the lambda are `const` anyways. Change-Id: Ib165e99945a5f673d97f0abdefcd4b4adee31624 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QQuickTableView: never start to edit from a modifier key aloneRichard Moe Gustavsen2022-12-121-1/+14
| | | | | | | | | | | | | When TableView.editTriggers is set to AnyKeyPressed, the user can start to edit the current cell by pressing any key on the keyboard. But there are some exceptions, like the arrow keys. But it turns out that we also need to ignore the modifier keys, otherwise the user cannot e.g do a shift-drag to select cells without also starting to edit. Change-Id: I26ca954349823b50a605908633eb9c1d4996076a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: support multi-selectionRichard Moe Gustavsen2022-12-081-7/+16
| | | | | | | | | | | | Implement support for doing multiple selections in TableView by holding down the shift modifier while dragging. [ChangeLog][Quick][TableView] Added multi-selection support if using a SelectionRectangle and holding down the shift-modifier. Change-Id: Ife622aeea2ed60a5741df01f3aac2fb647108aa9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QQuickTableView: let the edit delegate be a child of the cell delegateRichard Moe Gustavsen2022-12-071-29/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first version parented the edit delegate to the content item of QQuickTableView. This approach, however, turned out make it really difficult to implement an edit delegate that relied on the geometry of items inside the tableview delegate. E.g for a TreeViewDelegate, we would like to show an editable TextField on top of the label while editing. But only on top of the label, not the whole delegate (including e.g the expanded/collapsed indicator). Moreover, we don't want to hide the whole delegate while editing, only the label that is underneatch (a possible semi-transparent) edit delegate. For this to be possible, we therefore need to parent the edit delegate to the TableView delegate instead, so that the edit delegate can e.g more easily query the geometry of the items inside the delegate (like the label) to position its own items (like a TextField). Since we also want the developer to then have more control over which items get hidden, we offer a property: "required property bool editing" to the tableview delegate. This can be used to e.g hide items inside the delegate while its being edited (or to implement other kinds of transitions). This new solution should also be easier to work with, and understand, for application developers, since the parent-child structure now mirrors the location where the edit delegate is written in QML. Change-Id: Ieeae28c8297f8bb1fb2d90d152fd575b4f41f36f Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QQuickTableView: improve edit docsRichard Moe Gustavsen2022-12-051-1/+6
| | | | | Change-Id: I3f8a7a8fc89274258c65f87699c510295b4a127b Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QQuickTableView: add layoutChanged() signalRichard Moe Gustavsen2022-12-051-0/+36
| | | | | | | | | | | | Add a new signal to TableView that tells when the layout has changed. This signal can be used to reposition any overlay on the content item, including e.g SelectionHandles. [ChangeLog][Quick][TableView] Added new signal 'layoutChanged()' Change-Id: I5b89a064521c2831279accbc889deb768d9b1a1b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: implement TableView.editDelegateRichard Moe Gustavsen2022-12-011-33/+542
| | | | | | | | | | | | | | | | | | | This patch will implement support for editing cells in TableView. It enables you to attach an edit delegate to the tableview delegate, using the attached property TableView.editDelegate. The application can initiate editing by calling TableView.edit() (and TableView.closeEditor()) explicitly, or implicitly by using edit triggers. The EditTriggers enum in TableView mirrors the EditTriggers in QTableView (Widgets). [ChangeLog][Quick][TableView] Added support for editing cells Fixes: QTBUG-108838 Change-Id: I25df93a7eeabf9d8a4c4c6248e020d8eba6d5bd7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: respect activeFocusOnTabRichard Moe Gustavsen2022-11-251-0/+9
| | | | | | | | | | | QQuickItem has a activeFocusOnTab property which should also be respected by TableView. When disabled, TableView should not transfer focus between the cells when the user hits the tab key. Change-Id: I234286926b58753fa50923321302d4fa108a4515 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* QQuickTableView: factor out common press/tapp code to handleTap()Richard Moe Gustavsen2022-11-181-27/+27
| | | | | | | | | | | The signal handlers for 'pressedChanged' and 'singleTapped' contained a lot of duplicated code. Factor that out to a sepearate function 'handleTap()'. This will also avoid the need for duplicating the code even more, once support for cell editing is added. Change-Id: I80990b550bc13d9afff3969e931b5f44874e10ee Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: factor out parts of the key handling into private functionRichard Moe Gustavsen2022-11-171-156/+191
| | | | | | | | | | | | Factor out most of the code in the keyPress() handler that deals with changing the current index into a private function. This will reduce a lot of d-pointer indirection, but more importantly, simplify and prepare the keyPress handler to be able to support the new editDelegate API in later patches. Change-Id: I2710a34261b4a28e45a03f3eb436d87dd1605c7a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: don't change index if tapping on the resize areaRichard Moe Gustavsen2022-11-161-16/+22
| | | | | | | | | | | | | | | | | | | | | The current implementation would change the current index when a single tap was done on the resize area between the cells. But doing that was not ideal if the tap turned out to be a double tap instead, since a double tap should only reset the column size. The current solution would solve this by using exclusive signals on the tap handler. But despite of that, it would still look wrong that a tap on the resize area, while the cursor has a resize appearance, changed the index. Using exclusive signals also comes with a small signal delay. So, all in all, it's simply better to change the logic so that the resize area is reserved for resizing only. And then, to change the current index, the tap needs to happen outside the resize area. Change-Id: I1e7cb8d1031d1b86c14d777c322f1717fa5eb171 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: add tab supportRichard Moe Gustavsen2022-11-161-1/+45
| | | | | | | | | | | Add support to TableView for navigating the current index using Tab and Backtab. [ChangeLog][Quick][TableView] Added support for navigating the current index using Tab and Backtab. Change-Id: I609ecce6e35a50ed436514ba38e0a0992807072f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: detect if syncView topLeft has changedRichard Moe Gustavsen2022-11-111-0/+14
| | | | | | | | | | | | | | | | It can happen that the top left cell in syncView changes after a normal relayout. This is especially prone to happen if the cells used to be large, but are suddenly made much smaller, such that the top left cell ends up outside the viewport. This patch will detect this case, and ensure that the top left is being recalculated when they are no longer in sync. Pick-to: 6.4 6.2 Change-Id: I80cad2859a35e0f3bc58f101696112be7c084175 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: do a relayout whenever the view is resizedRichard Moe Gustavsen2022-11-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | If you place a TableView in e.g a StackLayout, it will have a zero size until it becomes the active view the layout. If the delegate then has a binding that e.g looks like: implicitWidth: TableView.view.width it will fail, since the width of the view is zero at time of creation, but at the same time, never updated again once the view becomes visible (and resized). This patch will therefore ensure that we do a relayout each time the view is resized, since having such a dependency in the delegate (or in the columnWidthProvider) must be expected to be quite common. Pick-to: 6.4 6.2 Change-Id: I92f4f51f6b6c634c2627716c41ea4971fb8d1653 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: emit changes to leftColumn() _after_ it has been updatedRichard Moe Gustavsen2022-11-101-14/+16
| | | | | | | | | | | | An application might listen for e.g the leftColumnChanged signal and query the position to the delegate items in the new left column. But for this to work, be sure to layout the items (and basically finish loading the column) before emitting the signals, so that leftColumn(), rightColumn(), topRow() and bottomRow() return the correct values. Change-Id: I0e64bd2b240b0dac03120a944815ee2e5e43a6a0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: implement support for letting the user resize rows and columnsRichard Moe Gustavsen2022-11-091-6/+297
| | | | | | | | | | | | | | | | | | | | | | | | | This patch will add support to TableView for resizing rows and columns by dragging between the cells. To achieve this, a custom pointer handler (QQuickTableViewResizeHandler) is implemented. This handler can detect if the pointer is hovering between the cells, and if the user starts a drag. This information is used to call out to the new setColumnWidth()/setRowHeight() API for adjusting the row and column sizes while the user is dragging. The pointer handler is careful to make sure that you can only start to resize by dragging _between_ the cells. If the drag starts elsewhere, the solution will fall back to normal contentItem dragging/flicking instead. Resizing is off by default. The user can enable it by setting the resizableRows/resizableColumns properties. In addition, an API that lets you query the state of the resizing has been added. [ChangeLog][Quick][TableView] Added resizableColumns and resizableRows properties to enable resizing by dragging between cells. Change-Id: I05d4170f30b8c6461a5877c2b831a1ab044d2b5b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: ensure that column sizes are in sync when using a sync viewRichard Moe Gustavsen2022-10-241-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When a TableView has a sync child, it will decide the row and column sizes for it, so that the views are kept in sync. It can happen, though, that the geometry of the sync view is smaller than the geometry of the sync child. In that case, the sync child will show more rows and column than the sync view. This caused a bug when a TableView was placed inside a ScrollView with a HorizontalHeaderView on top (as a sibling of the ScrollView). In that case, the HorizontalHeaderView would actually be wider than the TableView, since the latter would be shrinked a bit to make room for a vertical scrollbar. The result would be that the HorizontalHeaderView would end up showing more columns than TableView. But Since TableView doesn't always know the width of a column that has not yet been loaded, the size of the header column would also end up wrong. This patch will make sure that the "virtual" viewport of the sync view is at least as large as the size of the sync children. This will ensure that we end up filling up a TableView with the same amount of rows and columns as any of the connected header views. Pick-to: 6.4 6.2 Fixes: QTBUG-107837 Change-Id: I32926738d48d6bd3b0892e6256a8f8d1ed5f1fa2 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* SelectionRectangle: ask TableView for acceptance before starting a selectionRichard Moe Gustavsen2022-10-181-0/+6
| | | | | | | | | | | | | | Add a new virtual function to QQuickSelectable that lets SelectionRectangle ask TableView up front if it's OK to start a new selection at the given pos. This will be useful once TableView adds its own pointer/drag handler for resizing columns, and will be used to avoid a situation where a selection starts at the same time as a resize. Task-number: QTBUG-106792 Change-Id: Ib0ed2d46802a05b717844ea6278ceef03f28840e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: forward sync view calls to setColumnWidth/RowHeightRichard Moe Gustavsen2022-10-141-0/+46
| | | | | | | | | | | | | | | | | | | When a TableView has a sync view, the sync view will always decide the size of the rows and the columns. As such, also forward any calls to setColumnWidth/RowHeight to the sync view, otherwise it will have no effect. This is needed to e.g allow the application to resize the columns in a TableView by setting the size on the HeaderView instead. The opposite solution would be to just ignore any such assignments when having a sync view, but this would need to be documented as well, so then we might as well just forward the calls. Task-number: QTBUG-106792 Change-Id: Iadcd8c75677a69ab19fa2455274d340b5a4ad340 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TableView/TreeViewDelegate: clearify the use of pointerNavigationEnabledRichard Moe Gustavsen2022-10-131-0/+6
| | | | | | | Pick-to: 6.4 Task-number: QTBUG-107591 Change-Id: Ic63a7c32cb598935c75f2038324bde8045254c11 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that on() was replaced with a matcher that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>