aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickcontrols2/qquicktreeviewdelegate/tst_qquicktreeviewdelegate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove "2" from Qt Quick Controls directoriesMitch Curtis2022-12-011-401/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-131-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that on() was replaced with a matcher that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-2/+2
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <[email protected]>
* QQuickTreeViewDelegate: use pointerhandlers instead of event handlersRichard Moe Gustavsen2022-08-191-19/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TreeViewDelegate was using mouse event handlers to detect clicks on the delegate and its indicator (to e.g toggle the expanded state of a tree node). This had the effect that any pointer handlers installed on the TreeView itself would be blocked from working, since the delegate would accept the mouse events, and thereby stop propagation. Since TreeView uses drag-, and tap handlers to perform selections (installed by SelectionRectangle), using TreeViewDelegate as delegate would basically stop selections from working. Therefore, this patch will switch to use pointer handlers instead. Pointer handlers are by default non-blocking, and will naturally work better with other pointer handlers in the application, including of course the pointer handlers installed on the TreeView itself. The reason QQuickTreeViewDelegate was using mouse event handlers from the start, was because it inherits QQuickAbstractButton, which does the same. For that reason, we still need to override mouseButtonPressed(), and ignore the mouse events, to make sure that the QAbstractButton implementation doesn't block. Instead we now call the appropriate mouse handling functions in QAbstractButton directly from the pointer handlers. Since we don't use mouse event handlers anymore, this also has the advantage that we no longer need to recommend users to install custom pointer handlers on a child item of the delegate - they can now be installed directly on the delegate. Docs that described that work-around are therefore removed/changed. Fixes: QTBUG-105570 Pick-to: 6.4 Change-Id: I46d82175c577a27d083494960f1cad645f4d75a4 Reviewed-by: Shawn Rutledge <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | 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 <[email protected]>
* QQuickTreeViewDelegate: toggle expanded on pressRichard Moe Gustavsen2022-06-041-2/+30
| | | | | | | | | | | | | When TreeView is interactive, it should expand tree nodes on mouse release (to not interfere with flicking). Otherwise, if interactive is false, it should expand already on mouse press (equal to how e.g Widgets work). The current if-test that implemented this logic was broken, and would fail when TreeView was not interactive. Change-Id: I801a694b2dfd03875893bb2bda5c8ef3883dec75 Reviewed-by: Shawn Rutledge <[email protected]>
* QQuickTreeViewDelegate: remove selection on pointer clickRichard Moe Gustavsen2022-06-041-0/+19
| | | | | | | | | Removing the selection after a pointer click is normally done by TableView. But since TreeViewDelegate accepts mouse events, it needs to do this explicitly. Change-Id: Id0d6879f5b0e014aa05f50487f89dd0a08bb21f5 Reviewed-by: Shawn Rutledge <[email protected]>
* tst_qquicktreeviewdelegate: Fix click position inside indicatorDoris Verria2022-06-031-1/+1
| | | | | | | | | | Take into account the indicator position inside the parent delegate when attempting to click inside the indicator. This may not be 0 depending on the delegate's margins. Pick-to: 6.3 Change-Id: I7ddde6734dba3290947e51c787fee0128a90cd9e Reviewed-by: Mitch Curtis <[email protected]>
* QtQuickTest: add API for checking for polish at window levelMitch Curtis2022-06-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a qIsPolishScheduled(QQuickWindow *) overload of qIsPolishScheduled(QQuickItem *) (added in 40d6072bc8a4df0fe1a16025fe30fe653463a446) and deprecates qWaitForItemPolished() (added in 7a3cad0619662b992154e075ec6b840bfc8a46a7) in favor of qWaitForPolish(), which has QQuickItem* and QQuickWindow* overloads. The existing functions that take QQuickItem are useful, but testing Qt Quick applications can be made even easier by allowing users to check if a window has any items that need to be polished. This information is already present (in QQuickWindowPrivate::itemsToPolish), so it's very efficient to check for. This is especially useful now that Qt Quick Layouts using polishing for their layouting, for example, as it's no longer necessary to find individual polishable items in complex hierarchies before proceeding to interact with child items. [ChangeLog][QtQuickTest][QQuickTest] Added QQuickTest::qIsPolishScheduled(QQuickWindow *) and QQuickTest::qWaitForPolish(QQuickWindow *) functions for verifying that updatePolish() was called on one or more items managed by a window. [ChangeLog][QtQuickTest][QQuickTest] Deprecated QQuickTest::qWaitForItemPolished(QQuickItem *). Use the new QQuickTest::qWaitForPolish(QQuickItem *) function instead. Fixes: QTBUG-93757 Change-Id: I95b6e051b3c9fd2fa93604f4d9ccda486bb29f9d Reviewed-by: Richard Moe Gustavsen <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* QQuickTreeViewDelegate: respect TreeView.pointerNavigationEnabledRichard Moe Gustavsen2022-05-101-0/+30
| | | | | | | | | | If the application has pointerNavigationEnabled set to false, we should not expand or collapse the tree. The application has the possibility to set this property to set aside all our internal pointer navigation, and implement their own solution instead. Change-Id: I3055c459f0ce5eac8d55f44b93fd50d3d8afef64 Reviewed-by: Shawn Rutledge <[email protected]>
* QQuickTreeViewDelegate: implement 'current' and 'selected' propertiesRichard Moe Gustavsen2022-04-111-53/+58
| | | | | | | | | | | | | | | | | | | | | In order for the delegate to be shown as current and/or selected, it needs to implement the 'current' and 'selected' properties that TableView will use. We only change currentIndex when the user is clicking on the the label and not the indicator. This is also how QTreeView works. Likewise, we also only emit 'clicked' when the user is clicking on the label, and not the indicator. Expanding and collapsing the tree should not select the delegate at the same time. This patch will also remove the logic (and test) that allows you to add custom pointer handlers on top of a button, since the current way of solving it in the delegate was not very robust. The application should instead connect to the clicked signals coming directly from the QAbstractButton superclass. Change-Id: Ib07f08dfe2194303a8975082af785024da82c3e0 Reviewed-by: Shawn Rutledge <[email protected]>
* TreeViewDelegate: allow app to add custom pointer handlersRichard Moe Gustavsen2022-02-101-0/+53
| | | | | | | | | | | | | | As it stood, it was not possible to add custom pointer handlers to a TreeViewDelegate, to e.g do an expandRecursive() if using the right mouse button, or holding down ctrl during a click. This patch will change this, so that we only perform the default collapse/expand operations when using a plain left (double) click, and ignore the event otherwise. Pick-to: 6.3 Change-Id: Ifbdf0903158b65c50d0e36e98ab7e48efaa3e3ab Reviewed-by: Shawn Rutledge <[email protected]>
* controls: add TreeViewDelegateRichard Moe Gustavsen2021-12-091-0/+231
This patch adds TreeViewDelegate to Controls. TreeViewDelegate is a ready-made delegate that can be assigned to TreeView. It takes care of drawing the tree using the style, and can be used directly without the need for customization. It implements all the required properties set by TreeView, and offers in addition a small API that lets the developer change the indicator and the label. [ChangeLog][Controls] New delegate added: TreeViewDelegate Change-Id: I50fbc059afbc2b896d23d9d59717c8571e94bae6 Reviewed-by: Volker Hilsheimer <[email protected]>