aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview_p_p.h
Commit message (Collapse)AuthorAgeFilesLines
...
* QQuickTableView: implement support for reusing delegate itemsRichard Moe Gustavsen2018-08-021-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | This patch will make use of the recent changes in QQmlTableInstanceModel to support reusing delegate items. The API in TableView to enable this will mainly be a new property "reuseItems". This property is true by default. By setting it to false, reusing items will never happen. When an item is reused, the signal "TableView.reused" is emitted after the fact, in case the delegate item needs to execute some extra code during the process. Likewise, a signal "TableView.pooled" is emitted when the item is pooled. From an implementation point of view, TableView only need to do two things to enable reusing of items. First, whenever it releases items, it provides a second argument to release(), informing QQmlTableInstanceModel if the item can be reused. Second, it needs to call drainReusePool() at appropriate times to ensure that no item will be kept alive in the pool for too long. Change-Id: I830e2eace776302ac58946733566208aa8954159 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: be more careful when calling updatePolish() directlyRichard Moe Gustavsen2018-07-301-0/+1
| | | | | | | | | | | Like QQuickListView, QQuickTableView also calls updatePolish() directly for a smoother drag/flick experience. But this can easily result in recursive callbacks to viewportMoved() if the application, upon receiving signals, changes contentX/Y. So add some extra code to protect from this. Change-Id: Ie4b29bdcf4dc650d89759f9a8a1e3378074ade6e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TableView: invalidate table when rows or columns are movedMitch Curtis2018-07-191-0/+2
| | | | | | | | Similar to e792c08ef2bb4d4676df2fe7cc4537ea993d07d2, except for rows and columns being moved. Change-Id: I2ffa18a7447730fdc32e298b2870cd3180c3bee8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Qt Quick Table View: set the default row and column spacing to 0Nicolas Ettlin2018-07-181-1/+1
| | | | | | | | | | | | | | | Currently, in the TableView QML component, the initial row and column spacing is set to (-1, -1), as in the default QSizeF constructor. As the negative spacing was ignored when positioning the items, but taken in account when computing the total content size, it caused an issue where the user wouldn’t be able to scroll to the bottom right corner of the TableView. This commit fixes this issue by setting a default spacing to (0, 0). It also prevents the developer from using invalid spacing values (such as negative numbers, NaN or Infinite). Task-number: QTBUG-69454 Change-Id: I343475790c384954372afad0a778f8da7dff0b0d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: change how tableview resolves column width and row heightRichard Moe Gustavsen2018-07-181-33/+7
| | | | | | | | | | | | | | | | | | | | | | The current solution of storing column widths as the user flicks around turns out to not scale so well for huge data models. We basically don't want to take on the responsibility of storing column widths and row heights for e.g 100 000 rows/columns. Instead, we now choose to ask the application for the sizes, whenever we need them. This way, the application developer can optimize how to store/calculate/determine/persist row and column sizes locally. To implement this functionality, we add two new properties: rowHeightProvider and columnWidthProvider. They both accept a javascript function that takes one argument (row or column), and returns the corresponing row height or column width. If no function is assigned to the properties, TableView will calculate the row height / column width based on the currently visible items, as before. Change-Id: I6e5552599f63c896531cf3963e8745658ba4d45a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TableView: invalidate table when model is resetMitch Curtis2018-07-171-0/+1
| | | | | | | | Signals like rowsInserted() were already accounted for in QQuickTableViewPrivate::connectToModel(), but modelReset() was not. Change-Id: I6b8248d745d507d4ea846e9bee717182915792b3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuikTableView: use TableViewModel instead of QQmlDelegateModelRichard Moe Gustavsen2018-07-171-4/+13
| | | | | | | | | | | | Swap out QQmlDelegateModel in favor of the new QQmlTableInstanceModel. QQmlTableInstanceModel skips using QQmlChangeSets all together, and lets us subscribe to model changes directly from the underlying QAIM instead. This will make it much easier to handle model changes more gracefully later. Change-Id: I0315e91f39671744fb48d1869e4b73b1becbb929 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: use QHash instead of QList to store delegate itemsRichard Moe Gustavsen2018-06-261-1/+1
| | | | | | | | | | Using a QList to store all loaded delegate items was a legacy solution inherited from QQuickItemView. But we look-up items in the list based on index all the time, so switching to use QHash instead should be more optimal. Change-Id: I1aa8d23b3ac208a9424982491faaa5dd42775280 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickTableView: make functions constRichard Moe Gustavsen2018-06-251-2/+2
| | | | | | Change-Id: Id2f4c9ad64fafbf7d65f4597250aef86871ff5b5 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Add missing 'we mean it' warning to private headerKai Koehne2018-06-221-0/+11
| | | | | | | | Fixes syncqt warning: QtQuick: WARNING: src/quick/items/qquicktableview_p_p.h does not have the "We mean it." warning Change-Id: Iebda5832bb6a931aec9b34db149c062cf5e03343 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQmlDelegateModelItem: move row and column up to the base classRichard Moe Gustavsen2018-06-091-1/+1
| | | | | | | | | | | | | | | | Change 8c33c70 injected row and column (alongside index) into the QML context of a delegate when the view had a QAbstractItemModel as model. Rather than only inject those properties when using QAIM, this patch will move the code to the base class. This way, if a view uses e.g a javascript list as model, row and column is still be available. This is useful, since then the delegate can bind to both row and column regardless of what kind of model the view uses. In the case of a list model, the column property will always be 0. Change-Id: I1d9f11c0b7d7a5beb83198184ba12cc1e48cd100 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TableView: fall back to use implicit size for delegate itemsRichard Moe Gustavsen2018-06-041-0/+3
| | | | | | | | | | Rather than forcing users to set TableView.cellWidth/cellHeight (and therefore also force them to create an attached object for every cell), we now also accept setting implict size as a fall back. Change-Id: I4c4c4d23fe7fc193581728d3878cf2c7e40c0745 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* TableView: load and unload edges in the same loopRichard Moe Gustavsen2018-05-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | Normally when you flick the table around, a column (row) will be flicked out of view on one side, while another column will be flicked in and loaded on the opposite side. But if you flick really fast, you sometimes manage to flick in and out several columns in one go before tableview gets an updatePolish call to catch up. In the latter case, we would then first unload all flicked-out columns, and then afterwards continue loading all flicked-in columns. This approach is currently not a big problem, but it will be once we start recycling delegate items. Because then we should take care to not overflow the pool with unloaded column items, since the pool will most likely have a maximum size. So we therefore change the algorithm a bit so that we always alternate between unloading and loading one column at a time, rather than unload several columns in one go before we start loading new ones. Change-Id: Ia0f1968a4b3579e4445e1f7b6e68a28a1d2b360b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TableView: fall back to use default column/row sizeRichard Moe Gustavsen2018-05-231-2/+4
| | | | | | | | | | | | If we cannot determine the size of a row or column, we need to fall back to some size other than 0 while layouting. The reason for this is that we fill up with as many rows and columns that fits inside the viewport. But if e.g the width of column is zero, we will never make any progress, and therefore just keep loading and loading columns. Change-Id: I96ea410dc5a75831e44c2924172254634598b680 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TableView: keep a pointer to the delegate model to reduce the amount of castingRichard Moe Gustavsen2018-05-151-1/+5
| | | | | Change-Id: I04b8ac5781d54e257906880d283a2473f4daa718 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TableView: add support for table marginsRichard Moe Gustavsen2018-05-141-0/+2
| | | | | | | | | | Instead of always drawing the table at 0,0 in the content view of the flickable, add support for setting margins. The margins will let the developer add some extra space around the table to e.g make space for custom headers etc. Change-Id: I4a69b2cf3594bd72255d21372b5bf0d3220676dc Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* TableView: factor out private header into separate fileRichard Moe Gustavsen2018-05-041-0/+320
Change-Id: I7cc787328772e955076f701a1bc2fa49d36b6342 Reviewed-by: J-P Nurmi <jpnurmi@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>