aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-2/+2
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-2/+2
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickTableView: add API to set section sizes explicitlyRichard Moe Gustavsen2022-10-071-22/+265
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add API in TableView for setting column and row sizes explicitly. Up till now, the recommended way to set column widths in TableView, was to use a columnWidthProvider (or simply rely on the implicit width of the delegates). The reason is that this scales much better, compared to imperatively setting all the column widths up-front, e.g at application start-up. But there are several cases where this API becomes a bit cumbersome to use, epecially for smaller data models, or when the rows and columns should be allowed to be resized at run-time. One such usecase is the ongoing work of supporting section resizing in HeaderView. This patch will therefore add an API that allows HeaderView, as well as the application, to set column and row sizes explicitly. More documentation on how this works is included in the patch. [ChangeLog][Quick][TableView] Additional API for setting explicit row-, and column sizes has been made available. Task-number: QTBUG-106792 Change-Id: I1cbcd36a57470580b2548442275a818a837ea2be Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableViewPrivate: add immediate arg to forceLayout()Richard Moe Gustavsen2022-09-241-7/+9
| | | | | | | | | | | | | | Add a "immediate" argument to the _internal_ forceLayout() function(). This will be used internally when we need to update the layout as a response to explicit column/row size changes. This patch is a preparation for implementing column resizing in HeaderView. Task-number: QTBUG-106792 Change-Id: Icbf3c5cc663804f963cf2da8d77d946c57959c87 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: remove unused codeRichard Moe Gustavsen2022-09-221-78/+0
| | | | | | | | | | Remove old and unused code in TableView that was back in the days meant as an initial first step to implement section resizing. Task-number: QTBUG-106792 Change-Id: I84941bd6836e16751299e347abbbe9aa1813ade8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: document how to implement copy/paste supportRichard Moe Gustavsen2022-09-131-0/+61
| | | | | | Pick-to: 6.4 Change-Id: I9d60b4efdce4ebaf47a229325de8eb5d88cb5bff Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Doc: fix broken links and other qdoc warningsVolker Hilsheimer2022-09-081-1/+1
| | | | | | Pick-to: 6.4 Change-Id: I045b66478422a472ed1e52c83e60766bf7ad9219 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickTableView: avoid printing out incorrect warningRichard Moe Gustavsen2022-09-011-4/+12
| | | | | | | | | | | | | | | | | A warning would be printed out from TableView if you called positionViewAtCell with a mode that affected either horizontal or vertical alignment, but not both. The reason is that the overridden version would just forward the call to positionViewAtRow() and positionViewAtColumn(), without checking if the given mode allowed for it first. This patch will instead check the mode first, before deciding which functions to call. This will stop the warning from being incorrectly printed. Pick-to: 6.4 Change-Id: I58145873def7543fcffd51ade7d15c70fb755aae Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: clear selection on tap directly in TableViewRichard Moe Gustavsen2022-08-111-4/+8
| | | | | | | | | | | | | Before 6.4, it was only possible to make a selection in TableView by using a SelectionRectangle. But in 6.4, you can also make a selection directly in TableView by using the shift+arrow keys. To make sure that a selection is cleared either way on tap, move the implementation that clears the selection from SelectionRectangle to TableView. Pick-to: 6.4 Change-Id: Ic718763bf9b643cb3e3c04cc3b90c6ffcf9ca4b2 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QQuickTableView: remove unused static variablesFabian Kosmale2022-08-031-5/+0
| | | | | | | | Lest we needlessly pay the price of their initialization at runtime. Pick-to: 6.3 6.4 Change-Id: I64c1ff411a085847a2b6bfae1aa767933871351e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix several more improperly placed #include mocThiago Macieira2022-07-281-1/+1
| | | | | | | | | | | | | | Like commit qtbase/638893bea083b619b73b33a7dd5589fb2c4c4242. Script to find them: git grep -l '#include.*moc' \*.cpp \*.mm | \ xargs awk '/QT_BEGIN_NAMESPACE/ { i=1 } /QT_END_NAMESPACE/ { i=0 } /#include.*moc/ && i { print ARGV[ARGIND], $0 }' Pick-to: 6.4 Change-Id: I6f936da6f6e84d649f70fffd17058fd05cfc5c6d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Fix linking issuesTopi Reinio2022-06-291-8/+10
| | | | | | | | | | | | | | | | | | | | | These linking issues have crept through as documentation testing in CI does not capture them. * Fix link to Qml CMake command reference. * Update link targets to the Qt Creator manual as they have changed; link to Qt Design Studio if applicable and remove links that are no longer available. * Fix linking to inherited properties for DragHandler, TableView, and TreeView. * Remove explicit linking to QSGTexture::commitTextureOperations() as that function is \internal. Pick-to: 6.4 Change-Id: I2c20fef8bc12e639374caac25ed358da887c35b3 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: fix deprecated [=] capture of *thisMarc Mutz2022-06-041-2/+2
| | | | | | | | | | | | | | Reach *this through d->q_func() instead, so it doesn't need to be captured. Amends de1672713ae413b563eefec37d1aad155d78a1f8. An alternative would be to use [&], but the function is long and I was too lazy to review whether capture-by-reference would have the same effect as capture-by-value. Change-Id: If595e9b5c9c64e5a807dc999c3f0c228ff9f2cce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: document the importance of using an ItemSelectionModelRichard Moe Gustavsen2022-06-041-1/+18
| | | | | | | | Clarify that you need to assign an ItemSelectionModel to TableView in order for other parts of the API to work as expected. Change-Id: Ib0ded94ef157be13cf3ab022aadba9f2a67f9602 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* QQuickTableView: don't scroll when tapping on a cellRichard Moe Gustavsen2022-06-031-1/+0
| | | | | | | | | | | | There is no reason why tableview should scroll a cell to become completely visible when the user taps on it. This is convenient when navigating with keys, but not with mouse. If needed, the app can listen to currentIndex changes, and call postitionViewAtCell() explicitly. Change-Id: I5b34c87e2befe718d0f37b5993ecf30efd6a7f20 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: add new property 'selectionBehavior'Richard Moe Gustavsen2022-06-031-14/+72
| | | | | | | | | | | | | | | | This patch will add a 'selectionBehavior' property to TableView. It will let the developer specify if the user should be able to select individual cells, rows, columns, or if selections should be disabled. This is equal to the selectionBehavior enum in QAbstractItemView. [ChangeLog][Quick][TableView] A new property 'selectionBehavior' has been added that specifies if the user should be able to select rows, columns, or cells. Change-Id: Ia8855ae032bb02d278b284ed35049d9237523139 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: ensure we use the correct margins during key navigationRichard Moe Gustavsen2022-05-311-4/+4
| | | | | | | | | | | | | Ensure we use the correct margins when navigating with the arrow keys at the beginning and end of the table. When e.g navigating to the first column in the model, we want to flick the view all the way to the start, margins included. It should already have worked like this, but must have broke after earlier copy/pase operations. Change-Id: I438b20518602e4cc5b49e137f633a7f550a9dec8 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: add a 'subRect' argument to the positionViewAtCell() functionsRichard Moe Gustavsen2022-05-311-155/+250
| | | | | | | | | | | | | | | By providing a sub rectangle, TableView will position the view on the rectangle instead of the bounding rectangle of the whole cell. This is useful for large cells, where you either want to make sure that a specific part of the cell is visible, or you want to avoid any unnecessary scrolling if that is already the case. [ChangeLog][Quick][TableView] A new argument 'subRect' has been added to positionViewAtCell(). Change-Id: I03dce1cae050700c6c6d2165c6e975e35cbc9927 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: add a new 'alternatingRows' propertyRichard Moe Gustavsen2022-05-271-0/+38
| | | | | | | | | | | | | | | | Add a new property 'alternatingRows' that informs the delegate that it should alternate between rows. This is merely a hint, the delegate is free to ignore it. But our own internal delegates, like TreeViewDelegate, should not. [ChangeLog][Quick][TableView] Added a new property 'alternatingRows', which is a hint to the delegate to alternate between rows. Change-Id: I3f10e7280332b652d393348ff0d71cd73ce6fa4d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: make top-left cell current on first key pressRichard Moe Gustavsen2022-05-251-0/+14
| | | | | | | | | | | | If TableView has focus, but currentIndex is not yet set, the first press on an arrow key should make the top left cell current. This will also make sure that if you e.g collapse a tree node that contains the current index, you can still continue to navigate using the arrow keys. This is equal to how it works with widgets. Change-Id: I1cd6266cd1a8269f7a4f2b1af989fddfc8ccd3c0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: let sync views sync margins as wellRichard Moe Gustavsen2022-05-111-0/+6
| | | | | | | | | | | If a TableView has a sync view that has margins, it needs to have the same margins set as well. Otherwise they will not end up exactly in sync when you flick on either of them. Fixes: QTBUG-101218 Change-Id: I598bf6ebc6c2e7b9627ad18f254717296eca662b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Quick: includemocsMarc Mutz2022-04-291-0/+2
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102948 Change-Id: I695daa12613de3bada67eb69a26a8dce07c4b85e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QQuickTableView: add currentRow and currentColumnRichard Moe Gustavsen2022-04-211-0/+56
| | | | | | | | | | | | | | | | | | | Add two new properties that can be helpful when styling a delegate that should render differently depending on if it lies on the same row or column as the current item. "currentRow" will basically be the same as tableView.cellAtIndex(tableView.selectionModel.currentIndex).y. But that expression has the limitation that it will only update if currentIndex changes, and not as a result of layout changes inside the view (e.g when expanding or collapsing a node in TreeView). Using currentRow instead will not suffer from the same problem. [ChangeLog][QtQuick][TableView] Two new properties are added: currentRow and currentColumn. Change-Id: I1d4258196b299c4a3dfeb247dfc8f9b6a578b57e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: for cells bigger than the view, prefer showing the top-left ↵Richard Moe Gustavsen2022-04-131-43/+61
| | | | | | | | | | | | | | | | | part When positioning on top a cell, PositionMode::Contain promises to make the entire cell visible. However, this is not possible for cells that are larger than the view. This patch will implement support for being able to specify that positionViewOnCell should prefer to align the cell bottom and/or right inside the view, but fall back to top and/or left if the cell cannot fit inside it. This is useful when navigating the current index around with the keyboard. Change-Id: I1d1f053dacee1ffd6c657254130066ab8fe9ecb6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: use forceActiveFocus()Richard Moe Gustavsen2022-04-131-1/+2
| | | | | | | | | When the user is tapping inside the view, we want the view to get active focus. So use the forceActiveFocus() function instead, rather than setFocus(). Change-Id: I383f80fa5cc3b9d07a546bc429f929b2de1b433a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: keep selection model and tableview model in syncRichard Moe Gustavsen2022-04-111-5/+20
| | | | | | | | | | | | | | | The source model in the selection model will always need to be the same as the source model in TableView. So TableView might as well forward its own model to the selection model, so that the user don't need to worry about setting the model explicitly. The same is also done in QTableView. Still, it's always possible to force (perhaps by accident?) the two models to be different. To avoid confusion, we choose to print a warning if that happens. Change-Id: I9fec1d3de4cfe83cf28950ebdedd38a010df16a3 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: use the virtual modelIndex() function to get index for cellRichard Moe Gustavsen2022-04-111-1/+1
| | | | | | | | | Don't assume that the index that maps to a cell is in a flat table. This will fail for TreeView. Instead use the modelIndex() function that takes this into account. Change-Id: Ie7aa73c21e0f798e4a90011426cff113b0fffff6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: add new function: cellAtPosition()Richard Moe Gustavsen2022-04-081-18/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | The current "cellAtPos(pos)" function expects pos to be relative to TableView. The problem is that if you attach a Pointer Handler to TableView, it will actually install itself on the contentItem, and the positions it reports will be relative to the contentItem. Since the position used in a call to cellAtPos() is almost always coming from a Pointer Handler attached to TableView, it makes more sense to replace the cellAtPos() with a version that expects pos to be relative to the contentItem instead. This will remove a source of confusion and discrepancy, and also avoid the need to convert the pos to and from the contentItem all the time (also in QQuickTableView's own code). This patch will therefore add a new function "cellAtPosition()", and at the same time, deprecate the old "cellAtPos()". [ChangeLog][QtQuick][TableView] cellAtPos(pos) is now deprecated in favor of cellAtPosition(pos). The latter will assume pos to be relative to the contentItem. Change-Id: Iaf2f3ae81592bec4370e620c990045fdec6213b8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: change order of row and columnRichard Moe Gustavsen2022-04-071-3/+3
| | | | | | | | | | | | | | The modelIndex() function is added for Qt 6.4, and therefore not yet in any release. Looking at the other functions in QQuickTableView that takes a row and column as arguments (e.g positionViewAtCell() and itemAtCell()), they all have column as first argument, and row as second. So change the modelIndex() function to do the same, so that the TableView API ends up consistent. Change-Id: Ia85ceb3a4719c1e3c16e2023aa039263fef83f6e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView, doc: fixup some documentation errorsRichard Moe Gustavsen2022-04-051-3/+3
| | | | | | Pick-to: 6.3 6.2 Change-Id: I7e7e2444216282b1b3b81489c3ef3de5901e4d53 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: implement support for currentIndexRichard Moe Gustavsen2022-03-301-13/+288
| | | | | | | | | | | | | | | | | | | | | | | Implement support for moving the currentIndex, as specified in the selectionModel, around using either the keyboard or mouse/touch. Keyboard navigation can be switched off using keyNavigationEnabled, and mouse/touch can be switched off using pointerNavigationEnabled. In addition, a 'required property bool current' can be set in the delegate in order to style it differently depending on if it represents the current index or not. [ChangeLog][QtQuick][TableView] Two new properties are added, keyNavigationEnabled and pointerNavigationEnabled, that lets the user navigate the current index around in the table. A 'required property bool current' can also be set in the delegate to style the item that is current. Fixes: QTBUG-100696 Change-Id: Ie99b2159ea13fa8d3439b7ce4e82aeb2b22d9e3f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix C++20 buildGiuseppe D'Angelo2022-03-241-1/+1
| | | | | | | | Another case of [=] capture capturing `this`, which is deprecated in C++20 (and we build under -Werror). Capture what's needed instead. Change-Id: I49d6cc7cea2fd6884a1be2bb2d9ac75631cb6fde Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QQuickTableView: add "Visible" and "Contain" to PositionModeRichard Moe Gustavsen2022-03-231-6/+65
| | | | | | | | | | | | | | | | | This patch will add two new PositionModes to TableView: "Visible" and "Contain". Those can be used in a call to positionViewAtCell() to instruct TableView to move the content item (if necessary) to ensure that the cell is visible (Contain), or partly visible (Visible), inside the view. [ChangeLog][QtQuick][TableView] Two new PositionModes added: "Visible" and "Contain". Those can be used in a call to positionViewAtCell() to ensure that a cell is visible in the view. Task-number: QTBUG-100696 Change-Id: I29c585bda319d9872c3a84f6d600f0081763d09b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: refactor positionViewAtCell() into two functionsRichard Moe Gustavsen2022-03-211-46/+51
| | | | | | | | | | | | | Rather than having one positionViewAtCell() (not the public API, but the private helper function), split it up into two functions instead, one for row and one for column. From all the places we call this function, we already know which direction we want to position the view anyway. This is also a preparation to ease the implementation for the upcoming support for new PositionModes. Change-Id: I2f5593cd85c7cd165cbec6fb999867380b8fe598 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: refactor scrollToCell() into two separate functionsRichard Moe Gustavsen2022-03-211-93/+96
| | | | | | | | | | | | ScrollToCell() is a large function, and when used, we always scroll either horizontal or vertical. Whenever we need to scroll in both directions, we end up calling the function twice instead. So to simplify things (especially as a preparation for later patches that implements support for more PositionModes), split it up into two functions. Change-Id: Ie4b5085d0ed9f782d4d481a8de56ea316161409c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: rename a couple of private variablesRichard Moe Gustavsen2022-03-211-11/+11
| | | | | | | | | | A couple of new functions are on the way that should be named positionViewAtRow() and positionViewAtColumn(). So rename a couple of existing variables to make room for them. Change-Id: Id90e1d5e22dda839e54e54907f270f5afcdab9b7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: implement PositionMode, deprecate usage of Qt::AlignmentRichard Moe Gustavsen2022-03-181-62/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | As we need to support more enum options for the second argument to positionViewAtCell() (like "Visible" and "Contain"), using Qt::Alignment alone is no longer enough. This patch will therefore follow the same API as in ListView and GridView, and switch to use PositionMode. The enum values will however differ from ListView::PositionMode, since values like "beginning" and "end" are not applicable to a two dimensional table view. To support backwards compatibility when used from QML, the values will match the values in Qt::Alignment. So e.g Qt.AlignLeft can be used instead of TableView.AlignLeft. Since QQuickTableView is a private class, the same concerns are not relevant for the c++ API. [ChangeLog][QtQuick][TableView] The function positionViewAtCell() now takes TableView.PositionMode instead of Qt.Alignment as the second argument. For backwards compatibility, Qt.Alignment can still be used. Change-Id: Ib99262035ef43186d911c2fc2e0420205adbbf84 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: implement scrollToCell()Richard Moe Gustavsen2022-03-121-16/+227
| | | | | | | | | | | | | | | | | | | | Implement a new private function "scrollToCell" that can be used whenever TableView needs to position the content item for an already visible cell. For those cases, there is no need to rebuild the whole table. Since we know the geometry of the target cell, we can simply scroll/flick the content item to the correct position instead. Included is also a property "animate" that can be set by the application to control if animations should be used. [ChangeLog][QtQuick][TableView] Added a new property "animate" that can be set by the application to control if animations should be used for positioning the content item. Task-number: QTBUG-100696 Change-Id: I74a35f655cbcf6e3897eb90e9b33be1ada458644 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: refactor cancelOvershoot()Richard Moe Gustavsen2022-03-071-50/+17
| | | | | | | | | | | | | Since Flickable already has horizontalOvershoot() and verticalOvershoot() functions, there is no reason to calculate this again in TableView. This patch will refactor the overshoot code to use the already available API in Flickable. Task-number: QTBUG-100696 Change-Id: Ifc666e079b0147c3e1cfc6bba2beb287977b303e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: change cellAtPos() so that any loaded cell is foundRichard Moe Gustavsen2022-03-051-11/+13
| | | | | | | | | | | | | The current implementation would only find cells that were inside the bounding rect of the view. By changing the function so that it also find cells that are halfway outside the view (as long as they are loaded), it becomes useful also for implementing selection support (finding cells under the current selection, even those cells that are halfway outside the viewport). Task-number: QTBUG-100696 Change-Id: Ie54dc9b8773e7295ead0c9644dbbc5052b8e40fc Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: implement private helper function: atTableEnd()Richard Moe Gustavsen2022-03-051-32/+10
| | | | | | | | | | The pattern of checking if there are more rows or columns that can be loaded around the currently loaded table, is a reoccuring pattern. So factor it out into a more readable function. Task-number: QTBUG-100696 Change-Id: Ia0117a6db0495f3ac1173e24084d074581ff5e7d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: refactor mapping functions from QQuickTreeViewRichard Moe Gustavsen2022-03-051-6/+99
| | | | | | | | | | | | | | | | It turns out we need the modelIndex() and cellAtIndex() mapping functions in QQuickTableView as well, and not only in QQuickTreeView. The reason is that functionality for moving the current index around need to use them in order for the logic to end up correctly for both QQuickTreeView and QQuickTableView. [ChangeLog][QtQuick][TableView] Added a set of functions to get the model index for a cell, and vice versa. Task-number: QTBUG-100696 Change-Id: Ifd2cd3e42bf8141a51c48635e57fb3a22358f1f6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: implement getEffectiveRowY/ColumnX()Richard Moe Gustavsen2022-03-021-0/+14
| | | | | | | | | There two functions will be used in subsequent patches to be able to determine the geometry of loaded rows and columns. Task-number: QTBUG-100696 Change-Id: I8619957bcfeafe11b3965e9179a4b7e8c612bbd4 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: be able to specify incubation mode to ↵Richard Moe Gustavsen2022-03-021-2/+2
| | | | | | | | | | | | | | loadAndUnloadVisibleEdges() Later patches that implements animation support for moving the currentIndex around will need to load edges synchronously, even if it can theoretically be inside an asynchronous loader. Add an extra argument to loadAndUnloadVisibleEdges() to be able to specify this from the caller. Task-number: QTBUG-100696 Change-Id: I3dc8e2c137ba0223cd820b7b7286829942f79821 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: make some functions constRichard Moe Gustavsen2022-03-021-9/+9
| | | | | Change-Id: Ib552f25b5bdb252a5447cb49681a8fc9b72953cf Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTreeView: refactor 'setRequiredProperty()' into QQuickTableViewRichard Moe Gustavsen2022-02-221-37/+49
| | | | | | | | | | | | | Both TableView and TreeView needs to be able to set and update required properties. So move this helper function from QQuickTreeView into QQuickTableView, so that they both can use it. This will also make it easier to update how we deal with required properties in TableView/TreeView once QMetaProperty::isRequired() works. Task-number: QTBUG-100696 Change-Id: Iff0a86fe46cecdc4db8d307787fe148c7e71bbf6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: don't position the table contents outside the viewportRichard Moe Gustavsen2022-02-141-0/+66
| | | | | | | | | | | | | | | | | | | If you call positionViewAtCell(row, Qt.AlignTop) for the last row in the table, the row will be aligned to the top of the view, as requested. But this looks really wrong , since it will cause the table to be flicked to a position that causes it to overshoot by a distance close to the height of the whole view, effectively leaving a big empty gap at the bottom. This looks really buggy. This patch will correct this behavior by ensuring that we never flick the table to an "invalid" position while positioning table at a cell using the requested alignment. Instead we clamp the table to the edges of the viewport. Fixes: QTBUG-100680 Pick-to: 6.3 6.2 Change-Id: Id3003df784a0128df28ee2e78e2456e1fa1e11e8 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: replace two QFlatMaps with ordered QListsMarc Mutz2022-01-291-49/+33
| | | | | | | | | | | | | The mapped_type of the QFlatMaps wasn't used at all, so don't maintain a separate QList full of zeroes shuffled around with the keys, just use an ordered QList of the keys. Write a minimal wrapper around said ordered QList, because it might come in handy elsewhere. Change-Id: I502b0628d492da792db343ed6ef81b537c258007 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add \since 6.2 to TableView.selectionModel property docShawn Rutledge2021-11-191-0/+1
| | | | | | | Fixes: QTBUG-98440 Pick-to: 6.2 Change-Id: Ic8c6ccc81a2bf74a2739b3634b5816f2da356b8b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>