Commit Graph

23 Commits

Author SHA1 Message Date
Sze Howe Koh 130d46f2c7 Spreadsheets example: Bump minimum required Qt version
Amends 9601b74dab

The example no longer runs with Qt 6.9 or older as it uses the new
(Horizontal|Vertical)HeaderViewDelegate types.

Change-Id: I8430f4e9a48ddc9f72b20a4e998fde21480c4032
Pick-to: 6.10.0 6.10
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2025-09-11 18:00:47 +00:00
Fabian Kosmale 22b08c7348 Move SPDX header comment back to the top of the file
Amends 728028280a

Pick-to: 6.10
Change-Id: Id65cca4a2189e798ae99c6997bdcbb0a6df2f786
Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2025-07-21 15:21:58 +02:00
Fabian Kosmale ef84bfb5e8 spreadsheets example: Configure qmllint
The example is now warning free, so we can configure qmllint to fail if
there is any additional warning.
This is unfortunately not enforced in CI yet, as the all_qmllint target
is (intentionally) not part of the all target; so we don't run qmllint
in CI so far.

Pick-to: 6.10
Change-Id: Ib179364ac5bda033ad6a2c3d87bc3738a98d1489
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-07-18 09:00:33 +02:00
Fabian Kosmale 728028280a spreadsheets example: Fix warnings (and code)
- Use qualified lookups
- Set the ComponentBehavior pragma where needed
- There's no implicitRowWidth, use implicitRowHeight
- Query styleHints from Application, where it has the correct type,
  instead of from the global Qt object, where it's only known as QObject
  (as it needs to provide something even when QtQuick is not available)
- Remove unused import

Pick-to: 6.10
Change-Id: Ia4ff94aa8f66754d0a374ade7ff6c8cad4329530
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-07-18 09:00:30 +02:00
Tor Arne Vestbø 2ff0975e8d spreadsheets: Make HeaderToolBar a regular ToolBar
Which gives us safe area padding automatically.

Change-Id: Id8c68f857813740d1b22a19cfe4d1a86520310aa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2025-05-31 14:18:52 +02:00
MohammadHossein Qanbari 9601b74dab QuickControls: Add vertical and horizontal header view delegates
Implement QQuickHeaderViewDelegate as the base class for header view
delegates, introducing 'headerView' and 'orientation' properties.
Separate previous delegate settings into HorizontalHeaderViewDelegate
and VerticalHeaderViewDelegate components for Basic, Fusion, and Imagine
styles.

This change improves the modularity and reusability of header view
delegates across different styles. It also allows for more consistent
behavior and easier customization of header views.

A test suite has been added to verify default property settings and
ensure the new components work without warnings.

[ChangeLog][QtQuickControls][HeaderView] Add dedicated delegate
components for vertical and horizontal header views.

Task-number: QTBUG-70326
Change-Id: I8831e77f6909bdae13c3a7262145ab156f63a59a
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2025-03-06 03:08:26 +01:00
MohammadHossein Qanbari 2e9f2c9a1d Spreadsheets: Fix drag and drop issue after scrolling in table view
This patch fixes an issue with drag and drop functionality in the
example, particularly after long scrolling. The problem stemmed from two
main factors:
- The table view was stealing DropArea events when interactive.
- The drop area was positioned behind the table view's contentItem,
preventing it from receiving the events.

The drop area is now positioned above the table view, ensuring it can
receive events during dragging operations. The table view's interactive
mode is temporarily disabled when dragging begins and restored to its
previous state when dragging ends.

Task-number: QTBUG-125767
Change-Id: I8920284f4652464bccd92109a2a9685228e11783
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-01-28 12:48:00 +01:00
MohammadHossein Qanbari 89dc227e7c Spreadsheets: Prevent data loss when dropping cells in invalid locations
Before this patch, dropping selected cells into an invalid place in the
TableView could result in partial data loss. This occurred because some
of the selected data couldn't be set to the new cells, and the data was
copied at the start of the drag operation.

This patch improves the drag-and-drop functionality by:
- Checking the possibility of copying selected data to target cells
before the drop occurs (and during dragging).
- Avoiding highlighting of invalid target cells during the drag
operation.

Task-number: QTBUG-125767
Change-Id: Iff1058c2239f4bad3430f4f01ccea619f1ac8773
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2025-01-24 15:57:33 +01:00
MohammadHossein Qanbari 21883adaf3 Spreadsheets Example: Use TableViewDelegate
This update removes the custom table cell and uses the TableViewDelegate
type as the main TableView's delegate.

Task-number: QTBUG-114636
Change-Id: Icc2fd121d66f2bd1a6102e8575b75abd46940b96
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-11-30 20:10:33 +01:00
Santhosh Kumar 65263fe2fc SpreadSheet: Use SpreadModel to invoke the required mapping functions
The 'model' used when invoking mapColumn/mapRow during section
reordering seems incorrect as the model here has been referred to as
QHeaderProxyModel and not the SpreadModel. Updated the corresponding qml
to refer to the correct model.

Pick-to: 6.8
Change-Id: Ia8fe900eb0574319fd4c967b6f85cf8dd11bddd8
Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-11-11 21:30:28 +01:00
MohammadHossein Qanbari 1e02f013a5 Spreadsheets Example: Fix hang on dragging header through selected cells
The bug occurred when dragging a column over a selected column cells.
The DropArea in TableView attempted to process inconsistent drag data
for all the selected cells (up to 1000), causing the application to
hang.

Fix: Enable DropArea only for dragging TableView cells; disable for
other cases.

Fixes: QTBUG-130928
Pick-to: 6.8
Change-Id: I162a57638d89b97f3f1ef553850e3be3be389f1d
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-11-07 20:06:02 +01:00
MohammadHossein Qanbari c2ff06f90e Spreadsheets Example: Remove circular dependency
The example fails to compile on some platforms due to an existing
circular dependency. To fix this issue, the inclusion of
`spreadformula.h` has been moved to the related .cpp files, and a
forward declaration is used in the `spreadmodel.h` file instead.

Fixes: QTBUG-128272
Pick-to: 6.8
Change-Id: Ic2c589f9126e0ba0eed6ffe5150bacd4afa6d239
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-09-10 15:49:10 +02:00
MohammadHossein Qanbari c07b32d6de Spreadsheets Example: Add Documentation
The documentation was missing for the example. This patch provides a
screenshot image of the application and a documentation file.

Fixes: QTBUG-128224
Task-number: QTBUG-125767
Pick-to: 6.8
Change-Id: I2aa73ea7e82eb019db84a7ce685837b89e62f300
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-08-30 00:28:36 +02:00
MohammadHossein Qanbari 371efb4ca2 Spreadsheets Example: Fix Installation and Deployment
After installing the example outside the build directory using
`cmake --install --prefix`, the installed application could not run
because the Spreadsheet subproject library was not found at runtime.

To fix this issue, the Spreadsheets subproject has been added as a
static library to the project. Now, it can be found in the installed
directory.

Fixes: QTBUG-127846
Pick-to: 6.8
Change-Id: I30968afa958ec6bda6017969de157e27550a7616
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-08-22 21:35:38 +02:00
MohammadHossein Qanbari b1ae89155b Spreadsheets Example: Some improvements
The following changes are applied:
- Using ScrollView
- Cut action removes the data from the model
- Selection handle: smaller size, lighter color and border is used

Pick-to: 6.8
Change-Id: Id09c12db5f5c38c2254e1bf81970616e7e84f38d
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-08-17 11:00:06 +02:00
MohammadHossein Qanbari 6db74d7340 Spreadsheets Example: Check if clipboard is supported
The Spreadsheets example does not build on QNX as it uses the clipboard,
which is not supported on QNX.

To fix this issue, it checks `QT_NO_CLIPBOARD` macro around the
clipboard usage and prints a warning if it is not supported.

Fixes: QTBUG-127273
Pick-to: 6.8
Change-Id: Ib677ecd79c216f4e7dde20d82875ee3f492a21ea
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-07-23 18:38:20 +02:00
MohammadHossein Qanbari 33b5ba74ed Spreadsheets Example: Fix bug in inserting a new row
When inserting a new row (above or below an existing row), it was
causing a crash.

There was a forgotten call of the previous() method on the iterator
that was supposed to iterate backward.

It has been fixed by adding this function call inside the loop.

Task-number: QTBUG-125767
Pick-to: 6.8
Change-Id: I6a4436bacb0348c1b6bccd929f715e36d0279754
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-07-12 20:59:51 +02:00
MohammadHossein Qanbari 74fef51927 Spreadsheets Example: Separate HeaderViews and TapHandlers as types
The Main.qml file was growing larger due to modifications in header
views. To prevent this, the header views have been separated into
ColumnHeaderView and RowHeaderView QML module types.

Similar to the header views, the tap handlers have been separated into
a QML module type to maintain consistent behavior for header views.

Additionally, the mouse tap handlers have been merged into a single
tap handler to manage mouse events with different combinations of
buttons and modifiers.

Task-number: QTBUG-125767
Pick-to: 6.8
Change-Id: Ib465b8b631cb8fe2aeeaaea229e2c4985619d2e9
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-07-10 13:37:32 +02:00
MohammadHossein Qanbari 1d344045a9 Spreadsheets Example: Use TapHandler instead of MouseArea
When MouseArea is used for the header views, it blocks events for the
column/row reordering event handler.

To fix this issue, TapHandler is used instead of MouseArea. With proper
configuration of TapHandler properties, the column/row reordering event
handler can access events when they're not accepted by TapHandler.

Task-number: QTBUG-125767
Pick-to: 6.8
Change-Id: Ie59dfc681bb3d853e0a73a05d46bdcd2607091b0
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-07-09 16:47:25 +02:00
Lucie Gérard 746ee15415 Correct license for example files
According to QUIP-18 [1], all example files
should be LicenseRef-Qt-Commercial OR BSD-3-Clause
Example takes precedence over build system

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

Pick-to: 6.8
Task-number: QTBUG-121787
Change-Id: Ia60be3cc375a3a16af7e6ea7755a61cfe6e1573b
Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-06-27 09:17:10 +02:00
MohammadHossein Qanbari 5bdf12fc6a Spreadsheet Example: Fix bug in update and minor improvement
If the user drags a column from outside the visible area and drops it
into the visible area when the column contains a formula that depends
on a visible cell, updating that cell will not update the cell
containing the formula.

The reason is that the update method in the SpreadModel updates the
wrong rows and columns. The visible rows and columns need to be mapped
to the model's rows and columns.

The improvement is that the update uses a mutex instead of enabling or
disabling the connection in the view. However, the blockConnection()
function has been kept because some actions need to update a large
amount of data in the model, and then the view can be updated without
any extra view updates.

The pan and reset_reordering icons are updated. The new icons have
been designed by the designers.

Task-number: QTBUG-125767
Pick-to: 6.8
Change-Id: I20ea1ef0bb777b5b0b04e7ae74df172ffc5b5ed8
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2024-06-11 05:23:07 +02:00
MohammadHossein Qanbari e0e2f447ad Spreadsheets Example: some fixes and improvements
The HelpDialog is improved by defining an inline component inside it.
The column selection issue is fixed by removing the unnecessary margins
and rows as well.
When the user tries to cut cell data and paste it onto an area including
the cell itself, that cell would be deleted because it was a cut action.
However, this is not correct because the value of that cell is replaced
with the data from the clipboard (mime data) already. To fix this bug,
before deleting the data of the cutting cell, that cell should be
checked to ensure it is not part of the target cells.

Task-number: QTBUG-125767
Pick-to: 6.8
Change-Id: I1adab2c17dab1cf07245bfaed03193904d7d7a2e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-06-11 05:23:03 +02:00
MohammadHossein Qanbari 3de85ce8b9 Add the Spreadsheet example
The example demonstrates a Spreadsheet that provides adding, editing,
and deleting data, and also the ability to write formulas for numeric
data. Also, it's possible to select cells, rows, and columns for
deleting them or their data, copying or cutting the data, and dragging
them to other places. The user can hide columns or rows, and also show
them again. Thanks to the reordering API, columns and rows can be
reordered and also can be reset to the default order.

There is a SpreadModel class which handles the entered data. It only
stores the data of the cells that is provided by the user. It means
that it does not create any empty data structure for empty cells, in
order to reduce memory usage.

Task-number: QTBUG-125767
Pick-to: 6.8
Change-Id: I1d9cc5b4b8d902257e9ed508d4a712b0574490f3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-06-03 17:27:22 +02:00