aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates/qquickselectionrectangle.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Doc: Add alternate text for Qt Quick and Qt Quick Controls imagesJerome Pasion2025-11-261-0/+1
| | | | | | | | | | Alternate text (alt text) improves the documentation experience for screen readers and for other accessibility tools. Pick-to: 6.9 6.10 Task-number: QTBUG-135120 Change-Id: I975c3de11f893882fb9a27218079f244bd38a622 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickSelectionRectanglePrivate: port away from 3-arg connectAhmad Samir2025-11-091-8/+13
| | | | | | | | Pick-to: 6.10 Task-number: QTBUG-116296 Change-Id: Ic408673f79e12708c1594577cdeb37898caf2cb6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Set explicit default security level of all files with default securityJan Arve Sæther2025-09-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The files (folders) already processed are listed in each issue in epic QTBUG-134547 These files were processed half a year ago. In order to make it clear that all of these files are already processed, mark them with an explicit default security header. For the record, this was generated with this script: find -E . -regex ".*\.(cpp|h|hpp|mm|qml|js)$" | xargs python3 ~/bin/add-cra-header.py in the folders listed in each subtask of QTBUG-134547 (add-cra-header.py only exist at my desktop, but it simply adds the default security header if it doesn't already have any existing security header) QUIP: 23 Fixes: QTBUG-134547 Pick-to: 6.10 6.9 6.8 Change-Id: Ieb8c78ea6561fdbdd27c7b13185ece853eedf80f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Allow SelectionRectangle dragging if TableView doesn't flick via mouseShawn Rutledge2025-06-201-9/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Setting `interactive: false` on TableView is drastic (except perhaps in some mode that the user can enter somehow), but setting `acceptedButtons: Qt.NoButton` should be the default, to have flicking on touchscreens but avoid dragging by mouse. This is possible since cbc694491b8431fd3dcf82c3d17a17a06cbccebc (but the default was not changed, for fear of surprising users with a behavior change). So now QQuickSelectionRectanglePrivate::updateSelectionMode() allows dragging in either case, via all devices if the TableView is not interactive, or mouse-only if the flicking is touch-only. Long-press has so far been allowed to select only in the case when dragging cannot select. But if the TableView has interactive: true, then you can flick it on a touchscreen, regardless of how acceptedButtons is set, even though we may expect the user to select dragging the mouse. So now if `selectionMode: Auto` is declared, and touch flicking works, we allow the long-press to select, because otherwise there would not be a way to make a selection on a touchscreen. We should not consider `interactive: false` to be normal (unless the developer finds a need to disable scrolling in some unique modal use case that can be exited somehow). `acceptedButtons: Qt.LeftButton` is not a very useful setting either (even though it's still the default). The snippet is improved to illustrate, along with some drive-by's. Docs explain the behavior in more detail. Test coverage is added in the manual test and the autotest. Pick-to: 6.9 6.10 Task-number: QTBUG-97111 Task-number: QTBUG-132268 Change-Id: I912dbc7bf8de536794b5bdcc1269bf2860645de9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* SelectionRectangle: Deactivate when the last cell is unselectedMohammadHossein Qanbari2025-01-091-1/+8
| | | | | | | | | | | | | | | | | | | | This commit introduces changes to ensure that the SelectionRectangle is properly deactivated when the last selected cell in QQuickTableView is unselected. Key changes include: - Added a virtual method `hasSelection()` to QQuickSelectable interface - Implemented `hasSelection()` for QQuickTableViewPrivate, which checks if any items are selected - Updated QQuickSelectionRectangle to utilize the new `hasSelection()` method to determine its active state The test case checks that after deselecting the last selected cell, both the SelectionRectangle and its handles are properly deactivated. Pick-to: 6.8 6.9 Change-Id: I97214bb0d91dda8a902a4725918b60209b853acf Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: Fix crash when selecting uninitialized TableViewMohammadHossein Qanbari2024-12-121-0/+29
| | | | | | | | | | | | | | | | | | | | This patch addresses an issue where TableView would crash when attempting to select cells without an initialized delegate. The problem occurred because the selection rectangle calculation did not account for empty columns or rows. The fix includes the following changes: - Validate selection rectangle to ensure non-zero width or height. - Check loaded rows/columns before change current index on key event. A new test case is added to verify that selection works correctly when the TableView delegate is not initialized. Some tests are just added to verify no crashes happen. Pick-to: 6.8 6.9 Change-Id: I5060976c721d3625d016f7dc88d94b7277e2d0cb Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add missing includesFabian Kosmale2024-10-241-0/+1
| | | | | | | | | | ...in preparation of trimming down includes in QQuickItem. As a drive-by, remove the superfluous qqml.h include from quick/items/qquicktextutil_p.h. Change-Id: I7ee0f459bcbfdfe07314d1f63433aaa8639870ac Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Replace \instantiates with \nativetypePaul Wicking2024-08-201-1/+1
| | | | | | | | | | | Since the implementation of the `\nativetype`-command in QDoc, the `\instantiates`-command is deprecated. Replace the use of the deprecated command in favor of its replacement. Pick-to: 6.8 Task-number: QTBUG-128216 Change-Id: I23d9f66d3f6db2e5f827d7868497a432bb9b0626 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* SelectionRectangle: clear selection from TableViewRichard Moe Gustavsen2024-06-111-13/+3
| | | | | | | | | | | | | | | | | | | If the TableView delegate has a TapHandler, it will shadow the TapHandler in TableView that normally clears the old selection when a new drag selection begins. This means that the SelectionRectangle will keep on extending the current selection, even when no modifiers are being held. This patch will make the selection logic more robust by leaving it to QQuickTableView::startSelection() to clear (or not clear) the existing selection. Then we don't depend on the TapHandler in TableView to be called, and we can also simplify SelectionRectangle a bit. Pick-to: 6.8 6.7 6.6 Task-number: QTBUG-125867 Change-Id: Iaa3c6414d916773f62de4faec5a2fcb7b2f3e6d0 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Support drag and drop section reordering in the table viewSanthosh Kumar2024-05-271-2/+2
| | | | | | | | | | | | | | | | | | | | The new drag handler (QQuickTableViewDragHandler) in the header view allows the user to drag and drop row or column at the required index. At any point in time, there can be only one active handler, and depending on the type of operation, the corresponding handler consumes the pointer events. The user can customize the delegate using the new property 'containsDrag' when any corresponding drop section is activated while dragging a column or row. [ChangeLog][QtQuick][TableView] Added new property 'containsDrag' for the delegate, and it is set when a user drags a column or row on top of another delegate. This property is applicable only for HorizontalHeaderView and VerticalHeaderView. Task-number: QTBUG-100440 Change-Id: I52b1079559192f406e295aa34ca1d86acef61a6d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickTableView: support unselecting cellsRichard Moe Gustavsen2024-04-171-8/+8
| | | | | | | | | | | | | | | | | | | | | | As it stood, SelectionRectangle and TableView didn't support unselecting cells by ctrl-dragging or ctrl-clicking a selected cell. This is considered a bug. This patch will therefore make sure that we support doing that. In order to implement this, we need to provide the held keyboard modifiers to startSelection(), so that TableView can choose if the selected cells should become selected or unselected in the selection model. By making this change, it also became clear that some of the auto tests didn't call startSelection() before setSelectionStartPos(). We therefore now also assert that we always do this, and fix up the failing auto tests that violated this rule. Fixes: QTBUG-121143 Pick-to: 6.7 6.6 6.5 Change-Id: Icd58b551234f3c6145165771de599e46b62014dc Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* SelectionRectangle: ensure we remove or update selection handles if ↵Richard Moe Gustavsen2024-03-261-15/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QQuickSelectionRectangle: Fix crash when target is nullNicolas Fella2024-03-221-1/+1
| | | | | | Pick-to: 6.7 6.6 Change-Id: I9eb92583f2cfe1a0a6bee54e3e3f31528c3b6993 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QQuickSelectionRectangle: only start a new selection if no selection is ongoingRichard Moe Gustavsen2024-01-171-6/+4
| | | | | | | | | | | | | | | Follow up of aecb62403eb067ac. Ensure we only start a new selection if no selection is currently active. If you start a drag while holding down ControlModifier, the first cell will already be selected by the time the drag handler becomes active. In that case, we just continue extending the active selection. We don't actually need to test the ShiftModifier at this point, since this will be tested already on press. Pick-to: 6.7 6.6 6.5 Change-Id: I7af892a495ad62bc540deebd62fae2267cdeb626 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* TableView: start a new selection when using Qt::ShiftModifier (PressAndHold)Richard Moe Gustavsen2024-01-151-3/+8
| | | | | | | | | | | | | | Follow up on previous patch to qquickselectionrectangle, and implement starting a new selection when using Qt::ShiftModifier also for PressAndHold. This configuration, PressAndHold + holding Shift to start a selection, is normally not used in combination. But at the same time, there seems to be no reason why it should't work either, as using selections handles on desktop is allowed. Task-number: QTBUG-120628 Pick-to: 6.7 6.6 6.5 Change-Id: I8a7589ffd4d16e339a5654605ee0916d96c8cbf0 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* TableView: start a new selection when using Qt::ShiftModifierRichard Moe Gustavsen2024-01-091-3/+8
| | | | | | | | | | | | | | | If no selection exists in TableView from before, and the user shift-clicks on a cell, then start a new selection from the current cell towards the clicked cell. This is already how it works if a selection is started using the keyboard, and also standard selection behavior for other item view implementations outside of Qt (e.g Finder on macOS). Fixes: QTBUG-120628 Pick-to: 6.7 6.6 6.5 Change-Id: I2fd34e680eed9992dd7c405fbd58ae4f5b0834ec Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Doc: Use correct module identifiers in \qmlproperty commandsTopi Reinio2023-06-091-2/+2
| | | | | | | | | | | | Multiple \qmlproperty commands used a QML module identifier different to what their parent \qmltype uses in \inqmlmodule. With upcoming changes to QDoc these will result in documentation warnings. Pick-to: 6.6 6.5 Change-Id: I07cde85801506b374a9781ae79d211813d5dad4f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* TableView: implement SelectionModeRichard Moe Gustavsen2023-06-021-25/+96
| | | | | | | | | | | | | | | | | | | | | | | 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>
* doc: Fix some warnings (broken links)Shawn Rutledge2023-03-281-2/+2
| | | | | | Change-Id: I9ef36d761860b7b28c5e5e6e37826abfda9d998f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickSelectionRectangle: Use Control to start multi-selection, not ShiftRichard Moe Gustavsen2023-03-161-2/+2
| | | | | | | | | | | | The current implementation would start a multi-selection when holding down the Shift modifier. This is not correct. Holding down Shift is normally done to extend an already active selection. The correct way to do a multi-selection is to hold down Control. Amends 52cbcd947db2219aecb2f6cb59bc6676a7c61e48 Pick-to: 6.5 Change-Id: I5dbb7c88702266e8a396dd0bdcd4fb68ffbbb0c2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Doc: Remove duplicate words (typos)Andreas Eliasson2023-03-071-2/+2
| | | | | | Pick-to: 6.5 6.4 6.2 Change-Id: Ibd29739b894598e5d7837ed5f9150e08ca07fa35 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QQuickTableView: reposition selection handles whenever TableView updates the ↵Richard Moe Gustavsen2023-01-201-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix build with -no-feature-cursorTasuku Suzuki2023-01-171-0/+6
| | | | | | Pick-to: 6.5 Change-Id: Ibb89885c6cde3e49fffbc02f9c83880f2f2dda5d Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* QQuickSelectionRectangle: disable tapping through the selection handlesRichard Moe Gustavsen2023-01-111-0/+9
| | | | | | | | | | | | | | | We need to create a dummy TapHandler on top of the selection handle to stop the user from able to trigger a TapHandler on an item underneath it. The default gesture policy will stop a TapHandler underneath from triggering, but it will not stop it from emitting "pressed". We therefore also need to set a policy on the handler that let's it take an exclusive grab. Pick-to: 6.5 6.4 Change-Id: Ia49a4632b25b6c31a9c258f92880b95ad343e020 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickTableView: support multi-selectionRichard Moe Gustavsen2022-12-081-4/+9
| | | | | | | | | | | | Implement support for doing multiple selections in TableView by holding down the shift modifier while dragging. [ChangeLog][Quick][TableView] Added multi-selection support if using a SelectionRectangle and holding down the shift-modifier. Change-Id: Ife622aeea2ed60a5741df01f3aac2fb647108aa9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Doc: remove "2" from Qt Quick Controls filesMitch Curtis2022-12-011-2/+2
| | | | | | | | | | | | | Work on this was already started for the documentation in 1abdfe5d5a052f2298b7bf657513dfa7e0c66a56. The CMake target (docs_QuickControls2) probably can't be renamed until we rename the library, which won't happen until Qt 7. Task-number: QTBUG-95413 Change-Id: Ied20805a91286436606577c3de39671a447f27dd Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove "2" from Qt Quick Controls directoriesMitch Curtis2022-12-011-0/+577
Qt Quick Controls 2 was named that way because it was a follow-up to Qt Quick Controls 1.x. Now that Qt Quick Controls 1 is no longer supported, we don't need to have "2" in the name. Work on this was already started for the documentation in 1abdfe5d5a052f2298b7bf657513dfa7e0c66a56. By doing this renaming a few weeks before feature freeze, it won't affect the release but still results in as little time possible spent manually fixing conflicts in cherry-picks from non-LTS releases as a result of the renaming. This patch does the following: - Renames directories. - Adapts CMakeLists.txt and other files to account for the new paths. A follow-up patch will handle documentation. It does not touch library names or other user-facing stuff, as that will have to be done in Qt 7. Task-number: QTBUG-95413 Change-Id: I170d8db19033ee71e495ff0c5c1a517a41ed7634 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>