Commit Graph

33 Commits

Author SHA1 Message Date
Santhosh Kumar b803c5baaf Update manual test for row and column reordering in the table view
The quick table view enhanced with row and column reordering feature
(as part of patch 332385ffbf51a9abb03b3abdde1db2a62b6fe25a). This
patch updates the manual test of table view to accommodate row and
column reordering change.

Task-number: QTBUG-100440
Change-Id: I06e19b0a2b39434245133e148534eb3079e1e77f
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-05-28 06:53:32 +02:00
Richard Moe Gustavsen f0fbedbe69 SelectionRectangle: ensure we remove or update selection handles if selection changes
If you make a selection with SelectionRectangle and then resize a
row, the selection handles will not move to the resized position.
Likewise, if you do a selection, but then clear the selection
by interacting with the ItemSelectionModel directly, the
selection handles will not be updated to reflect the changes.

To fix this bug, this patch will add a callback from TableView to
SelectionRectangle that can be used to notify when changes are
done outside of SelectionRectangle. This especially allows us to:

- Remove the selection handles if the active selection is cleared
  or changed programatically (or anyway not by SelectionRectangle).
- Keep the selection handles, and update their position, when rows
  or columns are merely resized.

This change also allows us to clean up qquickselectionrectangle.cpp
a bit, and remove e.g a now superfluous tap handler listener.

Task-number: QTBUG-121143
Pick-to: 6.7 6.6 6.5
Change-Id: Id170520d49bc92c0bb9d16deaba741cab6f5c553
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-03-26 21:33:04 +01:00
Lucie Gérard 9c5fc88388 Correct license for test files
According to QUIP-18 [1], all test files should be
LicenseRef-Qt-Commercial OR GPL-3.0-only

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: I26d72e8de04d4c7c57b3b7838af5d033265de5ba
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-02-27 10:32:21 +01:00
Santhosh Kumar 8d3ed392bb Update manual tests and examples for change in default size policy
The size policy of item updated as part of task QTBUG-117597. This
patch update existing examples and manual tests that depends on quick
layout to embrace size policy change.

Task-number: QTBUG-117597
Pick-to: 6.7
Change-Id: I68469a3bba3c4d3e5ed4b6eae0fd765b5206efc0
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2024-02-21 14:27:54 +01:00
Richard Moe Gustavsen 517d0efb7b TableView: implement SelectionMode
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>
2023-06-02 09:06:19 +02:00
Richard Moe Gustavsen 54f6159d4d QQuickTableView: reposition selection handles whenever TableView updates the 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>
2023-01-20 09:45:25 +01:00
Richard Moe Gustavsen 84d3c382f8 QQuickTableView: let the edit delegate be a child of the cell delegate
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>
2022-12-07 01:17:19 +01:00
Richard Moe Gustavsen ed83f0f795 QQuickTableView: implement TableView.editDelegate
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>
2022-12-01 12:01:46 +01:00
Richard Moe Gustavsen 8733b01ce3 QQuickTableView: implement support for letting the user resize rows and columns
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>
2022-11-09 12:15:07 +01:00
Lucie Gérard 1b9808737a Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: Id89ed14990804a5024183e75382cc539d4293da1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-09-07 17:01:30 +02:00
Alexandru Croitor a8431a4067 CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers
Change-Id: I1cd769f85d5f82c43639d6787d98e536619249e6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-28 14:58:42 +02:00
Lucie Gérard 5a7b716474 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I72c89a98c42bbc9234d8495e9e503bec81d11037
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-08 10:41:06 +02:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
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>
2022-06-11 08:05:15 +02:00
Richard Moe Gustavsen b9dcf12a46 QQuickTableView: keep selection model and tableview model in sync
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>
2022-04-11 19:37:20 +02:00
Mitch Curtis d55fa705f0 Make tableview manual tests directly openable in Creator
This avoids the need to run qt-cmake-standalone-test and then import
the test, as described in QTCREATORBUG-25389.

Task-number: QTBUG-93020
Pick-to: 6.2
Change-Id: I7e0685aff91e82fc834b91b08878d48ba21fba9b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-26 09:04:21 +02:00
Richard Moe Gustavsen d44dfbbff7 manual tests, abstracttablemodel: add SelectionRectangle
Tweak the abstracttablemodel manual test so that can
select table cells. And enhance the look and feel in
the same go.

Pick-to: 6.2
Change-Id: Ia1f2544fde26d24e7761f2eb0c96e1194e6a644f
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-08-25 20:31:52 +02:00
Fabian Kosmale 78ab4b8d8b Remove the qmake project files
Remove all qmake project files, except for examples which are used to
test that qmake continues to work.

Change-Id: Ic4abb72dc2dcd75df7a797c56056b6b3c5fe62ac
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-15 15:34:22 +01:00
Alexandru Croitor 08adbefa13 CMake: Regenerate projects to use new qt_internal_ API
Modify special case locations to use the new API as well.

Task-number: QTBUG-86815
Change-Id: I3b964e3baf0cc7040830156dac30358ea1152801
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-06 13:19:37 +02:00
Tor Arne Vestbø d0eb261836 Remove use of deprecated High-DPI application attributes
Change-Id: Ibfb50fdcbb51ba93d6e5d11f9e8ce0e7b3bfde79
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-09-02 17:17:33 +02:00
Leander Beernaert 1d333d3375 Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I0c5b939c70bdb91ccdf7068784308416dcaa5736
2020-01-16 16:25:06 +01:00
Richard Moe Gustavsen 41cf477a2a manual test, tableview: Ensure we modify the right model
An old, unused, model was just lying around in the code. And the
buttons in the test was modifying it. But after introducing the
syncView concept in 5.14, all the TableViews in the test got their own
separate model. So fix up the test to work as it should with the new setup.

Change-Id: Ic3e6e3013186ef1c2998566b84b3b94e809296e8
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2019-11-21 15:21:53 +01:00
Alexandru Croitor ba494aaa24 Regenerate all projects with new CMake API version
Change-Id: Ie0db35f674137c229eaf049616f38f8e818f7092
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-15 12:24:51 +00:00
Alexandru Croitor 91e32f86b5 Regenerate remaining tests to be in sync
Change-Id: I200c8f58ad13bc1bc78409a3ce49348584ba5b51
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-15 12:24:38 +00:00
Leander Beernaert 4e14f6e70a Add QtDeclarative Test Coverage
All tests compile and run on a developer build.

These tests are failing:
tst_qqmlsqldatabase Fails due to missing sql driver
tst_qqmlsqldatabase Fails in wip/qt6
tst_ququicklayouts Fails in wip/qt6
tst_flickableinterop Fails in wip/qt6
tst_qquickpinchandler Fails in wip/qt6
tst_qquickflickable Fails in wip/qt6
tst_qquickgridview Fails in wip/qt6
tst_qquickimage Fails due to missing jpeg plugin
tst_qquicklistview Fails in wip/qt6
tst_qquicktext Fails in wip/qt6
tst_qquickcanvasitem Fails in wip/qt6
tst_scenegraph Fails due to missing jpeg plugin
tst_TestFiltering Fails in wip/qt6

Change-Id: I4b9d69c118e23c095cb72ad5a67653fc30943bb1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-14 14:01:58 +00:00
Richard Moe Gustavsen 4ce9717c6d Manual test, TableView: improve test with syncView functionality
Add some more TableViews and buttons that can
be used to test the new syncView functionality.

Change-Id: I0ad649598ef2ff08487c9a0b450861c27535c62c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2019-05-23 09:46:07 +02:00
Richard Moe Gustavsen 34948d35f6 Manual test, TableView, abstracttablemodel: add more logic to the test
Add buttons for adding and removing rows and columns

Change-Id: I8d391db4f61ff4ec4273adc7134bd30ffc73fa3c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-09-27 06:45:00 +00:00
Richard Moe Gustavsen 409f302326 QQuickTableView: move TableView from Qt.labs to QtQuick
TableView is now ready for Qt-5.12. The only thing missing
is documentation, which is currently being written, and on the
way. So remove the temporary labs plugin that used to register
TableView, and register it together with the other QtQuick items.

Change-Id: I7f360eac3934d228904a4133363e336afe0c451a
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2018-08-22 05:46:24 +00:00
Richard Moe Gustavsen 9e73c8f3ac test, abstractitemmodel: improve manual test
Improve the test so that you can click on
the cells to change their color.

Change-Id: Ia74620894f2885242f587c4c863bcf3544b13488
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-08-15 08:48:22 +00:00
Richard Moe Gustavsen 0bd3c9cda6 QQuickTableView: remove cacheBuffer from the public API
As discussed during API review, remove cacheBuffer from the public API.
The cache buffer was a feature inherited from ListView to avoid loading
a lot of items (and affect performance) when the user started to flick.
But now that TableView has support for reusing items, the point of the
cache buffer is more or less gone. At least we choose to remove it from
the public API until we have better understanding if this is really needed.

Note that the cacheBuffer still plays a small role internally, so we
don't remove it from the implementation. We want to preload an extra row
and column for reuse at start-up, since you often cannot reuse the first
row and column during the first flick (they will still be visible
on the screen).

Change-Id: Ie62835a04ac29a84c9a76151b73fe2f75d9ae844
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-08-10 15:00:19 +00:00
Richard Moe Gustavsen 379ba8640a QQuickTableView: remove TableView.cellWidth/Height
The attached properties TableView.cellWidth/Height were added
for corner cases where you couldn't set/override implicit size
for a delegate item. But now that we have added rowHeightProvider
and columnWidthProvider (and we know that we're going to offer a
broader API to set row/column size from a HeaderView), you have
a way out for those cases as well. So lets remove the attached
properties until we know for sure if they will be needed.

Change-Id: I7d20fb02c36aebd3f24964630ccb68d4c813e93e
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-07-18 22:12:18 +00:00
Richard Moe Gustavsen 58c988e090 TableView: remove row and column from attached object
TableView.row and TableView.column is no different from the row
and column properties that are injected into the context from the
model classes. So just remove them to not bloat the API.

This attached properties where added at an early stage where we
thought that it should be possible to set a different row and
column count on the view than compared to the model (to e.g to
"fake" a table layout when just assigning an integer as a model).
Also, we consider supporting right-to-left etc, where we might
end up with cells that have a different row/column in the view
compared to where the cell is in the model. If we decide to
do this later (not for the first release), we can consider
adding the attached properties back again at that point.

Change-Id: I588a45913b968db789978339bc9a63cd2ccfad49
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-07-10 12:39:52 +00:00
Richard Moe Gustavsen 7dc48bb0b5 TableView: switch to use TableView.cellWidth/cellHeight
This is logically more correct since TableView will override
width / height anyway to make the delegates fit into the table if
they are not as wide/tall as the widest column/row.
And it gets even more problematic when we recycle delegates, since
in that case we need to keep the original width binding of the
delegate to calulate the size of new columns. And this all
fits better by using attached properties instead.

Change-Id: Ia5f2acd2bfc45f3fb160c3782191ad8da9f780e6
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
2018-05-28 09:29:47 +00:00
Richard Moe Gustavsen b17576fe8f Tests: add new manual tests for TableView
This patch will add three new manual tests for testing
TableView.  The first uses a standard ListModel; the second
uses a custom QAbstractTableModel. The third is a port
of the storageview example in widgets.

Change-Id: Ic8ac1aaf9951d0e2982f512b570caa059a212a17
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2018-04-12 12:30:44 +00:00