aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix tst_qquicktableview on AndroidAndreas Buhr2022-04-151-1/+1
| | | | | | | Pick-to: 6.2 6.3 Task-number: QTBUG-101865 Change-Id: Ieed455d57fad310b82a2b5d8f5dcf0a7f06301e4 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QQuickTableView: for cells bigger than the view, prefer showing the top-left ↵Richard Moe Gustavsen2022-04-131-0/+47
| | | | | | | | | | | | | | | | | 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: keep selection model and tableview model in syncRichard Moe Gustavsen2022-04-111-0/+23
| | | | | | | | | | | | | | | 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: add new function: cellAtPosition()Richard Moe Gustavsen2022-04-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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: implement support for currentIndexRichard Moe Gustavsen2022-03-301-0/+666
| | | | | | | | | | | | | | | | | | | | | | | 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>
* QQuickTableView: add "Visible" and "Contain" to PositionModeRichard Moe Gustavsen2022-03-231-0/+75
| | | | | | | | | | | | | | | | | 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: implement PositionMode, deprecate usage of Qt::AlignmentRichard Moe Gustavsen2022-03-181-101/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-5/+91
| | | | | | | | | | | | | | | | | | | | 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: change cellAtPos() so that any loaded cell is foundRichard Moe Gustavsen2022-03-051-22/+36
| | | | | | | | | | | | | 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: don't position the table contents outside the viewportRichard Moe Gustavsen2022-02-141-55/+148
| | | | | | | | | | | | | | | | | | | 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>
* Do not rely on transitive includes in testsFabian Kosmale2022-02-141-0/+1
| | | | | Change-Id: Icb68dbecab6f675352cd58333c82fa6648025367 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQuickTableView: replace two QFlatMaps with ordered QListsMarc Mutz2022-01-291-6/+6
| | | | | | | | | | | | | 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>
* Consolidate test helpers into private librariesMitch Curtis2021-09-131-5/+6
| | | | | | | | | | | | | | | | | | | | Previously each test would include and build sources from the shared folder. Now we make those sources a library, build it once, then have each test link to it instead. We also take the opportunity to move some helpers that qtquickcontrols2 had added into the quicktestutils library where it makes sense, and for the helpers that don't make sense to be there, move them into quickcontrolstestutils. We add the libraries to src/ so that they are internal modules built as part of Qt, rather than tests. That way we can use them in a standalone test outside of qtdeclarative. Task-number: QTBUG-95621 Pick-to: 6.2 Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Selection support: make TableView selectableRichard Moe Gustavsen2021-06-031-0/+197
| | | | | | | | | | | Let QQuickTableView implement the QQuickSelectable interface. The functions implemented from the interface will be used by a SelectionRectangle in Controls to enable selecting cells in the table visually using pointer drag and selection handles. Change-Id: I6e87ffdc63a97a9dd83b8279fa08762772ce4e03 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Selection support: support setting a QItemSelectionModel on TableViewRichard Moe Gustavsen2021-06-021-0/+115
| | | | | | | | | | | | | | | | | | | | Add support for assigning a QItemSelectionModel to TableView. By doing so, delegate items that has a "required property selected" defined will get this updated according to the state of the selection model. It's essential that the property is defined as "required". If not, the property will simply be ignored by TableView. This is done to ensure that existing applications that already has a "selected" property defined, will continue to work as before, unaffected by the new selection API. [ChangeLog][QtQuick] TableView now supports selections by using an ItemSelectionModel. Task-number: QTBUG-74750 Change-Id: I4f4d75e9e65563b9aab0c54f3aa4aad2f6883952 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* qquicktableview: upon forceLayout(), check for visible rows/columns at the ↵Richard Moe Gustavsen2021-05-061-0/+78
| | | | | | | | | | | | | | | | | | | | | origin There is a bug in TableView which will stop the user from scrolling/flicking back to the first column if it has become visible after first being hidden. The reason is that this is somewhat of a special case that happens only if the current left column is already at the origin of the viewport, since that will fool tableview into thinking that there can be no more columns in front of it. This patch add an extra section to the function that checks for visibility changes, to detect this special case. Fixes: QTBUG-93264 Pick-to: 6.1 5.15 Change-Id: Ieaad507b45ea11dc231519e9f49cbf182d6443ba Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: add API to get column widths and row heightsRichard Moe Gustavsen2021-04-131-0/+28
| | | | | | | | | | | | | | | | | | Add a set of functions that can be used to query both the actual row and column sizes, but also what the implicit sizes are. The implicit size of a column is defined as the maximum implicit width found among the items in that column. This implicit size is just a recommendation that can be used by e.g HeaderView to resize a column to perfectly fit the contents. [ChangeLog][QtQuick][TableView] Added API to query row heights and column widths: columnWidth(col), rowHeight(row), implicitColumnWidth(col), implicitRowHeight(row). Fixes: QTBUG-92124 Change-Id: Id8adbd558dab670d4d1c0bb268105b56b898b72a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: add isColumnLoaded() and isRowLoaded()Richard Moe Gustavsen2021-04-131-0/+21
| | | | | | | | | | | | | | | | | | | | TableView needs an API that lets you check if the delegate items inside a row or column is available for iteration from within the columnWidth/rowHeightProvider. This is especially needed since we call the providers several times when loading a new row or column - once to figure out if it's visible, and another time later, to get the width to use for layout when the items are loaded. [ChangeLog][QtQuick][TableView] Added API to query if a row or column is loaded and available for iteration: isRowLoaded(row) and isColumnLoaded(column). Fixes: QTBUG-92151 Change-Id: Iad0c9953a794bb6464b973f79e18826b4727fb47 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: always update content size when rebuilding small tablesRichard Moe Gustavsen2021-03-261-0/+25
| | | | | | | | | | | | | | | | | | | | If you have a TableView with only a couple of rows, and you add a third one, the contentHeight doesn't update. This is fine if not all rows are loaded (some are outside the viewport), but when they are all inside, it should update to reflect the exact height. The same is also the case for the contentWidth. If you add a new row that increases the with of a column (and all columns are visible), the contentWidth should update. This patch adds an extra check when we do a rebuild (which we do when you add a new row), to see if all rows or columns are loaded. And if that is the case, we update contentHeight or contentWidth, respecitively. Pick-to: 6.1 6.0 5.15 Fixes: QTBUG-92099 Change-Id: I806bfb7c3606fca97c5d27cbb91856cc40df9fb8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: forceLayout() should work, even when no items are loadedRichard Moe Gustavsen2021-03-231-0/+33
| | | | | | | | | | | | | | | | | As it stood, we would return early from forceLayout if no items were loaded. This made sense, since when no items are loaded, there would be no items to lay out. But after we changed the logic so that an application can show or hide rows and columns by returning an empty size from the size providers, we now always need to do a layout to check if some rows or columns should become visible. Pick-to: 5.15 6.0 6.1 Fixes: QTBUG-92076 Change-Id: I2a07bf8e62cfeebcbe36c01aa92eca3ed8227cd3 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Show a tableview even if the syncView has an empty modelAndy Shaw2020-12-091-0/+43
| | | | | | | | | | By showing the tableview, we can be sure that headerviews will be visible even in the syncView has an empty model. Fixes: QTBUG-87526 Change-Id: I68c8b119122a2d2f88c2afbeb2d6c71a83a3ce33 Pick-to: 5.15 6.0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Use metatype and remove unused variableDavid Skoland2020-11-181-3/+0
| | | | | Change-Id: I709c6a74dc6a3eb0cdd3e94168921274f90df4a4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* TableView: ensure we rebuild the sync view, even when flicking on a sync ↵Richard Moe Gustavsen2020-10-231-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | view child When two table views are connect through the syncView property, both views will flick when you flick on either of them. This also means that if you fast-flick more than a page on the sync view child, the sync view needs to rebuild, like if you did the fast-flick directly on the sync view. Because we updated the sync view's viewportRect too soon while fast-flicking on the the sync child, we didn't detect that it was a fast-flick, and that a rebuild was needed. The result is that you could sometimes end up with the views getting out-of-sync. This patch will allow TableView to only move the viewport without updating the internal viewportRect while flicking. The viewportRect will instead be sync-ed at a later point, like we do when you flick on the sync view directly. This will ensure that we rebuild if needed, also while fast-flicking on the child view. Task-number: QTBUG-87821 Pick-to: 5.15 Change-Id: Ifc74473eb43406acaa8e24880066fb4ca89d3a4e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TableView: ensure we update content size upon model changesRichard Moe Gustavsen2020-10-211-10/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For tables of non-trivial sizes, we usually don't know what the content size will be unless we load all rows and columns, which we simply cannot do. Because of this, we have up till now chosen a strategy where we normally just calculate a predicted content size up-front, when we table is built, and afterwards just stick to that prediction. This strategy works for big tables that fills more than one size of the viewport, and if the number of rows and column in the model stays around the same. But for tables that start off smaller than the viewport, and later expands to grow out of it, it simply fails. And the failure is such that the tableview can get stuck, with no way way for the user to flick around to see the rest of the contents. An example is TreeView that might only show the root node at start-up, but as you start to expand the tree, it will quickly add more rows than what fits inside the viewport. And in that case, the contentHeight will be totally off, and in turn, make the scrollbar be based on wrong values, and sometimes not work at all (e.g if it has the flag Flickable::StopAtBounds). This patch will change the implementation so that we recalculate the content size whenever it should logially change. That is, if e.g the model add or remove rows and columns, or if you change spacing. This still doesn't mean that contentWidth/Height reports the correct size of the table, but at least it will be a better guestimate for smaller tables, and at the same time, work together with Flickable and ScrollBars. Pick-to: 5.15 Fixes: QTBUG-87680 Change-Id: Ie2d2e7c1f1519dc7a5d5269a6d25e34cf441b3fe Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add ; to Q_UNUSEDLars Schmertmann2020-06-281-1/+1
| | | | | | | | | | | This is required to remove the ; from the macro with Qt 6. It is not required in GET_QML_TABLEVIEW because it is the last instruction of the macro. Task-number: QTBUG-82978 Change-Id: I17458daea8f10fd5a211d76bddc60320b3714df3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* TableView: allow negative spacingRichard Moe Gustavsen2020-05-071-4/+11
| | | | | | | | | | | There is no apparent reason why negative spacing should not be allowed. And in fact, you can use negative spacing to eliminate double edges in the grid when the delegate is e.g a rectangle with a border. Fixes: QTBUG-83956 Pick-to: 5.15 Change-Id: I3be9d58ac8c43142e26e75165274e41872e878f4 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: add functions to get current rows and columnsRichard Moe Gustavsen2020-04-091-0/+48
| | | | | | | | | | | | This API can be used to query and iterate the currently loaded rows and columns inside the view. [ChangeLog][QtQuick][TableView] Added the properties leftColumn, rightColumn, topRow, and bottomRow, which can be used to query which part of the model is currently visible inside the view. Change-Id: I06f99cc1e8da1004dc8614977f149192e1880ba4 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: add cellAtPos() functionsRichard Moe Gustavsen2020-04-091-0/+66
| | | | | | | | [ChangeLog][QtQuick][TableView] cellAtPos(x, y) has been added to query which cell is under the given position. Change-Id: I69523868158b589ea3bb9facba815000d2a058d7 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: add function: itemAtCell(const QPoint)Richard Moe Gustavsen2020-04-081-0/+38
| | | | | | | | | | | | Add a function to the API to let the application get the item loaded for a specific cell. [ChangeLog][TableView] A function 'itemAtCell()' has now been added to let the application get the delegate item loaded for a specific cell. Change-Id: Ie84ef44ea2a0a901487812c4d611b98d4c86ee22 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: add positionViewAtRow()/Column()Richard Moe Gustavsen2020-04-081-0/+186
| | | | | | | | | | | | | | Add functions to let the application scroll the table to a specific row or column using a specific mode. This API partially mirrors the API found in ListView. [ChangeLog][QtQuick][TableView] positionViewAtCell(), positionViewAtRow(), and positionViewAtColumn() have been added to enable the application to position the contents to show a specific cell. Fixes: QTBUG-83215 Change-Id: I321588041977f9ded40f84fc0499ea1c5f6ac801 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-12-101-8/+16
|\ | | | | | | Change-Id: Iadbdd0fb63ca2a9e0b186343f8b730e4114cd71b
| * QQuickTableView: set empty content size when table is emptyRichard Moe Gustavsen2019-12-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | From before we would bail out early from the rebuild process if we detected an empty table. A result from this is that we left both contentWidth and contentHeight unchanged. This patch will set an empty content size when the table is empty. The effect will be that the user cannot flick the view around based on the old size. Fixes: QTBUG-80505 Change-Id: I3ac080476269fd5906ce79fa007eabb59b5ff4b1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| * QQuickTableView: ensure we release items in the old model and not the newRichard Moe Gustavsen2019-12-091-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As it stood, we would wait to release loaded items until we started the rebuild process, if the old model was a DelegateModel. But at that time, the model would alread have been changed, so we would release the items by calling out to the wrong model. This patch will ensure that we always release the items immediately when syncing the model, which will also cover the case when the model is a DelegateModel. Fixes: QTBUG-80570 Change-Id: I1b06011f4795727d04d9cd8c20381f65552b8fe8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
| * QQuickTableView: support assigning a DelegateModelRichard Moe Gustavsen2019-12-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Normally you either assign a model to TableView that already has a delegate (or don't need one), like DelegateModel or ObjectModel. Or instead you assign a QAIM model and a delegate directly. But if you assign both a delegate and an ObjectModel, TableView would be confused, and ignore the assigned model and instead create an internal wrapper model that ends up empty. This patch will ensure that we don't create a wrapper model in such cases, but instead forward the delegate to whichever model is assigned, even if it ends up as a no-op for models that don't use one. Task-number: QTBUG-80534 Change-Id: Idd220df08617c379dc7808ee1f41c862b78cc201 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * tst_qquicktableview: ensure test checks for correct error messageRichard Moe Gustavsen2019-12-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Change 631ef67458 fixed a bug that wrote a wrong error message to the console. But there is a test that checks for that message that was also wrong (but for some reason the test passed in the CI, but it has started to fail locally). This patch will ensure that the test don't fail because we check for a wrong error message. Change-Id: I27e16b0f4aa6a0ffeb8c42f846c344436a41ad3c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-12-051-1/+16
|\| | | | | | | | | | | | | | | Conflicts: tests/auto/quick/qquicklistview/tst_qquicklistview.cpp tests/auto/quick/qquicktableview/tst_qquicktableview.cpp Change-Id: Ib46bc1c717cf524eea2fb3d876810c8d55747c91
| * QQuickTableView: Clear items before deleting the modelUlf Hermann2019-12-041-0/+15
| | | | | | | | | | | | Fixes: QTBUG-71374 Change-Id: I534b7612268bb9407844961267865f490d7ff7b2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
| * tst_qquicktableview: fix warning about missing JS functionRichard Moe Gustavsen2019-12-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change 35fdf3a7b7 added a binding to a function in one of the QML files used for testing (plaintableview.qml). The problem is that this file is also used from other places where we wrap a QSharedPointer that points to the model inside a QVariant. And when assigning that variant to a TableView, the QML binding will see the QSharedPointer, and not the model it points to. And hence complain that the model doesn't have the API that is exported from the model. The easy fix is to just create a new QML file for the new test added, that has the binding, but assigns a QVariant that wraps the model directly without usign a QSharedPointer. Change-Id: Ic2b77426c2d700479a9b5f4007384661e2ca0801 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Liang Qi2019-11-221-3/+84
|\| | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlextensionplugin.cpp tests/auto/quick/qquicktableview/tst_qquicktableview.cpp Change-Id: Ic58d36a8532015bae30f2690063db9829b3bf372
| * TableView: use fetchMore() when scrolling to the end of the tableKari Hormi2019-11-201-0/+21
| | | | | | | | | | | | | | | | | | | | | | QQmlTableInstanceModel implements canFetchMore and fetchMore functions, but these are not called at any point in QQuickTableView. This change checks if additional data can be fetched when atYEndChanged signal is emitted. Fixes: QTBUG-78273 Change-Id: I49b41b09d9a218826b34f32cd9fe4724a6097b52 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
| * QQmlTableInstanceModel: always emit index changed when an item is reusedRichard Moe Gustavsen2019-11-141-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When reusing a delegate item, it can sometimes happen that the item ends up being reused at the same location in the table as it had before it was pooled. And in that case, we don't emit changes to index, row and column since they technically didn't change. The problem is that the model might have changed in-between, e.g if a row has been removed. And in that case, row and column will, even when unchanged, point to other parts of the model. So all bindings needs to be reevaluated to ensure that the values they use are refreshed. This patch will therefore ensure that we always emit changes to the mentioned properties when an item is reused, regardless if they change or not. Fixes: QTBUG-79209 Change-Id: Icec201a43a30b9f677303fbf652baf6487621deb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
| * autotest, tableview: silence compiler warningRichard Moe Gustavsen2019-11-121-1/+1
| | | | | | | | | | Change-Id: I311f0c21baa73521717ad98b2398d5469b9ac208 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
| * QQuickTableView::forceLayout(): rebuild table if the size of the model has ↵Richard Moe Gustavsen2019-11-121-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | changed An assert will trigger if forceLayout() is called while the model is being reset. The reason is that the forceLayout() schedules a relayout which assumes that the size of the model hasn't changed. But while layouting, it will try to fetch data from the model according to the old size, which will trigger an assert. This patch will add an extra path to forceLayout() that checks if the size of the model has changed, and if so, schedule a complete rebuild instead of just a relayout. Fixes: QTBUG-79395 Change-Id: If61658912d9e90c1a5aef9bc28083da20fa6ec76 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-10-041-0/+27
|\| | | | | | | | | | | | | | | Conflicts: src/imports/qtquick2/plugins.qmltypes src/quick/items/qquickitemsmodule.cpp Change-Id: I841c65c9c131354788b4f3fcfe3d7ed27be316d5
| * Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-121-0/+27
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4engine.cpp src/quick/handlers/qquicktaphandler.cpp src/quick/items/qquicktableview.cpp Done-With: Richard Moe Gustavsen <richard.gustavsen@qt.io> Done-With: Ulf Hermann <ulf.hermann@qt.io> Done-With: Shawn Rutledge <shawn.rutledge@qt.io> Change-Id: If9558a33f01693ce96420c094e0b57dfff0626cd
| | * QQuickTableView: always relayout after a rebuildRichard Moe Gustavsen2019-08-281-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current logic was based on the idea that if both rowHeight-, and columnWidthProveders were set, we didn't have to relayout the items at the end of a rebuild. Because in that case, the row and column sizes would already be correct after the initial load. This assumption turns out to be false, because the providers are allowed to return -1 to signal that the size of a row or column should use default values (meaning, calculated by TableView). And for those cases, we need to do a relayout at the end of a rebuild. Fixes: QTBUG-77074 Change-Id: I0e0f2fdca1cfa9e98f2a0a2b227c3715c16a70f9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | | Support required properties in model delegatesFabian Kosmale2019-09-121-0/+45
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a delegates declares a required property of a given name, and that name exists as a role in the model, we set the property accordingly. The same holds true for the special properties that come from the QQmlDelegateModel like "index" and "model". All roles are still injected into scope and thus accessible; changing this in Qt5 would be tedious or even impossible while still maintaining backwardscompatibility with delegates that do not use required properties. Change-Id: I4f388ba549c42f1ff9822bdb3b8357c4d45e4b66 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Fix some compiler warnings in testsFriedemann Kleint2019-07-121-1/+0
| | | | | | | | | | | | | | | | | | | | - Signedness of integer comparison - Unused parameters and variables - Ignored return values of QTest::qWaitForWindowExposed() (nodiscard) - float to int conversions Change-Id: Ibece620d3c980a5af3b7717486c841d8072ed8af Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QQuickTableView: don't recalculate content width while flickingRichard Moe Gustavsen2019-05-151-72/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are now three mechanisms in TableView that works together to ensure that the table ends up edge-to-edge with the content view. They are applied in the following order: 1. Adjust the content size, based on the predicted size of the table. 2. Adjust the origin and endExtend on the fly, if the content size is wrong. 3. Move the table directly to where it should be, in case we don't have time to wait for the origin to change. We could have, strictly speaking, setteled with just one of them, but choose to use them all at the same time for best flicking experience. Still, 1. and 2. sometimes step on each others feet when they both detect that something is a bit off, and adjust. So rather than adjusting the size of the content view every time we load a new row or column, we just keep the first prediction. And then we leave all later ajustments to 2. and 3. This turns out to be a more stable, and will avoid some glitches that occur when flicking using a scrollbar, if several mechanisms kick in at the same time. Change-Id: Ib551a0bf8f6ee59ac9b3556b9462c91adb9cc80b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | QQuickTableView: change implementation of enforceTableAtOrigin()Richard Moe Gustavsen2019-05-111-0/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We set the size of the content view to be the size of the complete table. The problem is that the exact size will always be just a prediction, since we would otherwise need to iterate over all rows and column up front, to be able calculate the exact size. This is not acceptable when using non-trival table models. A side effect of this, is that is will be possible to flick the viewport further out than the actual end of the table, if the content view turns out to be larger than the table itself. From before we used to just move the whole table back into the viewport when that happened, which could be seen as a sudden jump of the table to a new position. This change will improve this logic so that we can avoid most visual jumps. Instead of moving the table around, QQuickFlickable supports moving the origin instead. So when we see that the table is not in sync with the content view, we simple move the origin to the edge of the table. The effect is that any flicking or ongoing momentum animation in QQuickFlickable will continue as if nothing happened. This is also the same logic used by QQuickListView. Change-Id: I6060b7e84b9489c8fa569e6ff41b958e3871f8e7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>