summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews
Commit message (Collapse)AuthorAgeFilesLines
...
* Ensure stable sort in QListWidgetWladimir Leuschner2023-09-261-0/+60
| | | | | | | | | | | | | | | | | | | | | QlistWidgets with sorting enabled do not sort stable. A re-sort is triggered when any Qt::ItemDataRole is changed and not only when Qt::DisplayRole is changed. Due to an unstable optimization, the changed element gets inserted at the beginning of their respective "equivalence group". This patch disables the optimization and ensures stable sorting with std::stable_sort. Sorting is only performed, if the subset of changed items in the range [begin, end] is not already sorted in the whole list. For this purpose, it is assumed that the list has already been sorted before begin and after end. This assumption minimizes the subset to check. Limits / side effect: The patch focuses on the most common use case, which is a single item being changed. Replacing the optimization by std:stable_sort can potentially slow down the sorting performance of large data sets. Task-number: QTBUG-113123 Pick-to: 6.5 6.6 Change-Id: Ib2bd08f21422eb7d6aeff7cdd6a91be7114ebcba Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QAbstractItemDelegate: Update spinbox editor value before committingDoris Verria2023-09-251-0/+58
| | | | | | | | | | | | | | | | | | | | | QAbstractItemView installs the delegate as an event filter on the editor, so the delegate will get the focusOut event (and other events) before the editor does. QAbstractItemDelegate will then emit commitData, signaling that the "updated" data should be written back to the model. In the case where the editor of a delegate (QAbstractItemDelegate) is a QSpinBox with keyboardTracking set to false, the value of the spinbox won't be updated while typing, but only when the spinbox's text edit focus is lost. In this case, the delegate's commitData will be emitted before the spinbox has had a chance to update the value in its handling of the focusOut event. To fix, make sure to update the value before the data is committed to the model in the delegate's tryFixup method. Fixes: QTBUG-116926 Pick-to: 6.5 6.6 Change-Id: I68540964342407d23387e4404a0fe3f00d80eb5f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractScrollArea: Don't include size of invisible scrollbarsVolker Hilsheimer2023-07-113-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amend 3e59a88e8968c6cdac788926bec34c259146b6a8, which incorrectly used isHidden() to test whether the scrollbar is visible or not. QWidget::isHidden() is only true for child widgets that are explicitly hidden (or created for visible parents, which the scrollbars are not). Since the scrollbars are children of a container that is hidden and shown, isHidden always returns false. Instead, use QWidget::isVisibleTo, passing the scroll area, as that tells us if the scrollbar's visibility is relevant for the layout of the scroll area. Add a test case for QAbstractScrollArea, verifying that the scrollbar's size is correctly taken into account when calculating the size hint. This change revealed an instability in the tests introduced in the earlier commit: the layout process is asynchronous, requiring event processing to update the visibility of the scrollbars. Add a call to processEvents before storing the reference size hint. Also, explicitly set a style that doesn't use transient scrollbars as otherwise we cannot control when the scrollbars are shown. The chagne also revealed an inaccuracy in the QListView test, which only passed because the width of the vertical scrollbar was included. We cannot use font metrics results to compare expected width, as the item delegate's text rendering uses text layouts. Task-number: QTBUG-69120 Fixes: QTBUG-109326 Fixes: QTBUG-113552 Pick-to: 6.6 6.5 Change-Id: I1f06f9e88046a77722291ac17c56090f8dff7cf3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* CMake: Make widgets tests standalone projectsAlexandru Croitor2023-07-0515-0/+90
| | | | | | | | | | | | | | | | | Add the boilerplate standalone test prelude to each test, so that they can be opened with an IDE without the qt-cmake-standalone-test script, but directly with qt-cmake or cmake. Boilerplate was added using the following scripts: https://git.qt.io/alcroito/cmake_refactor Manual adjustments were made where the code was inserted in the wrong location. Task-number: QTBUG-93020 Change-Id: I3c0d1a63c474969e5eaee5fdbb1bb0229482fc5b Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* tests: blacklist tst_QAbstractItemView::selectionAutoScrolling() on WaylandLiang Qi2023-07-021-0/+2
| | | | | | | | | because it's flaky in current CI setup. Task-number: QTBUG-109776 Pick-to: 6.6 6.5 Change-Id: I3e432e632622f47b8125344187daf238a03a7372 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QHeaderView: Don't add new sections on no-opAxel Spoerl2023-06-231-0/+21
| | | | | | | | | | | | | | | | | | | | | | | When a table view adds its first row, QHeaderView::initializeSections() is called. It initializes the vertical header view with the number of added sections. Subsequently QHeaderView::sectionsInserted() is called with the same amount of newly added rows/sections. That leads to the initial amount of sections being 2x the number of rows added in the first go. In other words, the table view will display at least one row more than the underlying table model has. This patch adds an OR condition to the early return check at the beginning of QHeaderView::sectionsInserted(). The method returns early if the number of sections equals the number of respective sections (rows in this case) in the model. An autotest is added in tst_QTableView::rowsInVerticalHeader(). Fixes: QTBUG-114225 Pick-to: 6.6 6.5 Change-Id: I895444f025591981965562e54e2335391db52357 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Use boolean to indicate QTableWidgetItem is header itemAntti Määttä2023-05-051-0/+20
| | | | | | | | | | | | | | | QTableWidgetItem uses additional enum flag ItemIsHeaderItem which has the same numerical value as ItemFlag ItemNeverHasChildren. This causes conflict since the user can set the latter flag using the setFlags, while the ItemIsHeaderItem is only used internally to mark header items. Remove the additional flag and use boolean instead to fix the conflict. Pick-to: 6.2 6.5 6.5.1 Fixes: QTBUG-113209 Change-Id: Icff549c7e452d9f84575a524361719204817274e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QListView: No-op, when a list item is dropped directly behind itselfAxel Spoerl2023-03-311-0/+54
| | | | | | | | | | | | | | | | | QListView generates a move, when an item is dropped directly behind itself. This causes unexpected behavior, e.g. item widgets getting discarded. This patch prevents a move from being generated in that case. It adds an autotest to tst_QWidget, to verify item widgets and item data do not get discarded in case of a no-op drag&drop. Fixes: QTBUG-100128 Pick-to: 6.5 6.2 Change-Id: I02a755320a7b71dad218293c9c94c88da6507423 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QAbtractItemView: deselect before click opens editorVolker Hilsheimer2023-02-281-16/+13
| | | | | | | | | | | | | | A click on the selected item should deselect all other items before editing starts. Remove the part of the test case that assumes that we can have multiple items selected in ExtendedSelection mode, and click on an item to start editing while maintaining selection. That can never happen. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-111131 Change-Id: I0312eed4614502cfb77eca26d3f7615427493d7d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QListView: Reset style after using a temporary proxyVolker Hilsheimer2023-02-271-0/+5
| | | | | | | | | Amends 0242be90606b377864c6fd02d5a8e0afaf635acf, and removes unwanted side effect of having a modified style behavior for later functions. Pick-to: 6.5 6.4 6.2 Change-Id: If3dff0d7ab9e6c6c10e7a92d0a3eaff98fa1457f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-1716-32/+0
| | | | | | | Pick-to: 6.5 Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QAbstractItemView: don't start editing on Ctrl-ClickVolker Hilsheimer2023-02-161-1/+43
| | | | | | | | | | | | | | | | | | | Amends 17c1ebf8bfd254ff75cc55e335d1c1fb01da547f, after which dragEnabled item views toggled selection on click rather than on press. If the edit trigger included SelectedClicked at the same time, then Ctrl-Clicking a selected item would start editing the item, instead of toggling selection. Fix this by ignoring clicks with modifier when evaluating whether editing should start. Extend the mouseSelection test case by including a column for the editTrigger, and cover the respective combinations. Fixes: QTBUG-111131 Pick-to: 6.5 6.4 6.2 Change-Id: I9605f9b3d5a49e292551a34c3c4c7a5f9ecb2a89 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QAbstractItemView: Don't unselect on click on empty area in SingleSelectSebastian Beckmann2023-02-111-0/+32
| | | | | | | | | | | | | | | | dfb4697e4a4828acd47292a89207b3975ec6766e made a change to selection behavior that resulted in a regression where clicking on an item view but not on an item would cause the current item to get unselected. Changes the behavior to not update in this case. Added a new test that specifially checks for this scenario and ensures that the current item is still selected, even after the user clicks on empty area. Fixes: QTBUG-105870 Pick-to: 6.2 6.4 6.5 Change-Id: I191c3878819b99897083039fba0ab43908da5429 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix two variables' "may be used uninitialized" compiler warningsAhmad Samir2023-01-221-1/+1
| | | | | Change-Id: Ie6063d7124b16681b3e39d465da21dd67206ebc3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QListView: Prevent infinite loop when wrapping text of item with null-iconVolker Hilsheimer2023-01-041-0/+17
| | | | | | | | | | | | | | | | | | If an item in a list view has a null icon, then the decorationSize gets calculated as -1, -1. The style would then try to wrap the text to a lineWidth of -1, ending up in an infinite loop in viewItemTextLayout. To prevent that, don't set the HasDecoration flag of the style option when the icon is null, and don't fall back ot the decorationSize unless the flag is set. Add a test for this particular item configuration. This also fixes the widget baseline test with styles that don't provide all standard icons. Pick-to: 6.5 Change-Id: I691db6abede9a9b2ad300f3ee7fbfdae5fb6097f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* QHeaderView test: Remove unused variablesVolker Hilsheimer2022-12-121-8/+0
| | | | | | | | | Silence warnings such as: variable 'sum_lookup_visual' set but not used [-Wunused-but-set-variable] Change-Id: If38515d9753cf7b79a250985890a139e96e92329 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Adapt to QTimeZone replacing Qt::TimeSpec usageEdward Welbourne2022-12-101-5/+6
| | | | | | | | | | | | In the process actually handle all time-spec cases in various places that only handled UTC or LocalTime, or at least note that they don't where that's not practical. Also tidy up header ordering and ensure QDateTime's header is included wherever it's used, while adding the include for QTimeZone where needed. Task-number: QTBUG-108199 Change-Id: Ic1a5cdf0aaf737bf1396aa8ac58ce2004cef7e19 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-0312-330/+330
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-113-5/+5
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* tests: skip two tests in tst_QAbstractItemView on WaylandLiang Qi2022-10-071-0/+6
| | | | | | | | | QWindow::requestActivate() is not supported. Task-number: QTBUG-107153 Pick-to: 6.4 6.2 Change-Id: I9080fbb0ae0a604ad4a7ffa55ba3243d1cf96be8 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-048-72/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = 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'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deprecate QApplication::setActiveWindow() and mark as internalTor Arne Vestbø2022-08-279-42/+53
| | | | | | | | | | | | | | The function is used the internal window activation machinery and should not be called by user code. Many tests still use this function, and should be ported over to QWidget::activateWindow(). For now they are using the private helper in QApplicationPrivate, so that we can progress with the public API deprecation. Change-Id: I29f1575acf9efdcbae4c005ee9b2eb1bb0c8e5b5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QAbstractItemDelegate: tolerate that editor gets reparentedVolker Hilsheimer2022-08-251-0/+70
| | | | | | | | | | | | | | | | | | | An item delegate might override destroyEditor to merely reparent the existing editor out of the item view for later reuse, rather than actually destroying the editor. As of d0dffdfc012574da4a75241097b667d09bb39ba2, the code calling closeEditor() - which calls destroyEditor - might explicitly set focus back to the item view parent of the editor. This needs to handle that the parent of the editor might no longer be valid after the closeEditor call returns, and rather store the old parent widget explicitly. Add a test case that segfaults with nullptr access without the fix. Fixes: QTBUG-105231 Pick-to: 6.4 6.3 6.2 Change-Id: I04a355673823c4941865f7a575864e991ceeb5f0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QtBase tests: remove QT_DISABLE_DEPRECATED_UP_TO definesIvan Solovev2022-08-241-2/+0
| | | | | | | | | The value will be propagated from Qt build. Task-number: QTBUG-104858 Change-Id: Iae2c32c3037438f41b92f9ee28004f30eb4e3210 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-2316-16/+16
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Rename QT_DISABLE_DEPRECATED_BEFORE -> QT_DISABLE_DEPRECATED_UP_TOIvan Solovev2022-08-191-1/+1
| | | | | | | | | | | | | | The new name describes the behavior in a better way. [ChangeLog][Build System] The QT_DISABLE_DEPRECATED_BEFORE macro is renamed to QT_DISABLE_DEPRECATED_UP_TO. The old name is deprecated, but is still recognized if it is defined during configuration and the new name is not defined. Task-number: QTBUG-104944 Change-Id: Ifc34323e0bbd9e3dc2f86c3e80d4d0940ebccbb8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Unblacklist tests that are no longer flakyDimitrios Apostolou2022-08-171-4/+0
| | | | | | | | | | | Couldn't reproduce flakiness on OpenSUSE KDE/X11 and can't see any history of flakiness in the last 3 months in our testresults database. Task-number: QTBUG-62967 Task-number: QTBUG-63262 Change-Id: Id50291798eda922283e04b45205ae9105e9fdab2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Wait for window focus instead of expose eventDimitrios Apostolou2022-08-112-3/+1
| | | | | | | | | | This fixes the flakiness seen in OpenSUSE KDE/X11 desktop. Fixes: QTBUG-70590 Task-number: QTBUG-105177 Change-Id: I7c2431e58b2a60ea04e26d4e70c0f2867d544ff2 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-0316-0/+48
| | | | | | | | | | | | 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: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-2815-17/+17
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QListview: PageDown/Up infinite loopTang Haixiang2022-07-051-0/+21
| | | | | | | | | | | When item.height > viewport.height, the next item is not found correctly, resulting in an infinite loop. In this case, move directly to the next item. Pick-to: 6.4 6.3 6.2 Change-Id: I67a40a079ca9dd9189bf84ae550758c685b83d75 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix memory leak in tst_qtreewidgetAndreas Buhr2022-05-181-0/+2
| | | | | | | | | | | Invalid inserts of items are tested. However, on an invalid insert of QTreeWidgetItem into QTreeWidget, the QTreeWidget does not take ownership of the to-be-inserted items. These items were leaked in the past. This patch introduces a scope-guard, so the items are not leaked. Change-Id: Ib53ac02605c3a3c0bd1ae69bbd0876f860d08093 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtWidgets: restore Qt 5 compatibility for save/restore stateGiuseppe D'Angelo2022-05-181-5/+32
| | | | | | | | | | | | | | | | | | | | | | | Several classes in QWidget use QDataStream internally in order to save and restore state. These QDataStream usages were not versioned, meaning that if Qt changes the serialization for some datatype, then the data saved between different Qt versions becomes incompatible. Note that the save/restore API in question just produce opaque blobs as QByteArrays -- the user has no control over the QDataStream objects and thus versions. Fix by version the usages. In QHeaderView this has caused a regression because QBitArray *did* change version between Qt 5 and 6. In general, using QDataStream without explicit versioning is a mistake, so deploy the same fix elsewhere as well. Fixes: QTBUG-99487 Pick-to: 5.15 6.2 6.3 Change-Id: I82bb5c266f4e5dedc0887cbef855dccab1015e29 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: <doctor.whom@gmail.com>
* Use SPDX license identifiersLucie Gérard2022-05-1616-433/+33
| | | | | | | | | | | | | 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. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* tst_qitemdelegate: make it more robustGiuseppe D'Angelo2022-04-271-2/+1
| | | | | | | | | Remove a processEvents() call followed by a QCOMPARE and turn it into a QTRY_COMPARE. Otherwise it seems to be randomly failing on Ubuntu 22.04. Change-Id: I3c1b9d55c857c79ffd36aeb98971db60267adace Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractItemView: with single selection, deselect on Ctrl+ReleaseVolker Hilsheimer2022-03-241-0/+8
| | | | | | | | | | | | | | | | | After cbf1b4bc60bca3994b8f8685ee922e53a6b4eed2 the selected item got deselected on Ctrl+Press, which made Ctrl+dragging a selected item impossible. Only deselect on Ctrl+Release. Add scenario to existing test case, and update the documentation to clarify the properties involved, and to point out that the event parameter might be nullptr. Fixes: QTBUG-101647 Pick-to: 6.3 6.2 Change-Id: I749b1cb1a0a311f5c1d4c333984716f05f2c90b5 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Volker Enderlein <volker.enderlein@ifm-chemnitz.de> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Repair some of tst_qtableview tests on AndroidAndreas Buhr2022-03-152-3/+2
| | | | | | | | | | | | | The test task191545_dragSelectRows relied on the fact that the view is not scrolling. But on a small screen, it scrolls automatically. Fixes: QTBUG-87407 Pick-to: 6.2 6.3 Change-Id: I691361c965ab03d8a012f2b83715c7c96d990ec5 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QAbstractItemModel: fix persistent index corruption when moving columnsDavid Faure2022-02-281-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | QHeaderView creates persistent indexes in _q_sectionsAboutToBeChanged(), called by the slot connected to rowsAboutToBeMoved/columnsAboutToBeMoved. In the case of rows, QAbstractItemModel emits the signal *before* preparing to update persistent indexes in itemsAboutToBeMoved(), so it can see the ones newly created by QHeaderView, all is well. In the case of columns, the emit was done *after* calling itemsAboutToBeMoved(), so the additional persistent indexes created by QHeaderView were ignored, and in endMoveRows() we could end up with: ASSERT failure in QPersistentModelIndex::~QPersistentModelIndex: "persistent model indexes corrupted" This bug has been there since the very beginning of beginMoveColumns(), but was undetected because moving columns in a model is pretty rare (in my case there's a QTransposeProxyModel that turns columns into rows in the underlying model, and a proxy that handles dropMimeData...) Pick-to: 6.3 6.2 5.15 Change-Id: I74bad137594019a04c2a19c2abb351ff3065c25a Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Remove unused Qt4-compat testAndreas Buhr2022-02-241-41/+0
| | | | | | | | | | There was a test for Qt4 compatibility in tst_qheaderview. We don't run it since Qt 6. This patch removes the unused code. Change-Id: I751829ac5a142e79379e81e9e739107544cf7406 Reviewed-by: Arnaud Bienner <arnaud.bienner@gmail.com> Reviewed-by: David Faure <david.faure@kdab.com>
* Repair some of tst_qtableview tests on AndroidAndreas Buhr2022-02-222-32/+28
| | | | | | | | | | | | | | | | The view.resize() command has no effect if the requested size is smaller than the screen. So the view has space for the whole model. It then won't scroll, so scrolling cannot be tested. This patch enlarges the model so that scrolling is always necessary and thus possible. Task-number: QTBUG-87407 Pick-to: 6.2 6.3 Change-Id: Ibff512158d9c16be120a69c7328b6d0ae2c3b551 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Repair tst_qtreeview on AndroidAndreas Buhr2022-02-162-8/+3
| | | | | | | | | | | | Scroll tests relied on having a small window. On Android, the window can not be smaller than the screen. This patch changes the tests so that the windows have large enough content so scrolling can happen. Fixes: QTBUG-87408 Pick-to: 6.2 6.3 Change-Id: I26a444518fd934527089297c594673937f0ecf88 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Repair tst_qabstractitemview in case of no cursorAndreas Buhr2022-02-162-6/+7
| | | | | | | | | | | tst_qabstractitemview requires a movable cursor. This patch skips the test if there is no movable cursor. Pick-to: 6.2 6.3 Fixes: QTBUG-87400 Change-Id: I4e917b2ad062ce068f23603410aa9209edb9828d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Deprecate QContextMenuEvent and QMouseEvent ctors without globalPosShawn Rutledge2022-02-053-24/+42
| | | | | | | | | | | | | As with QHoverEvent, it's better to require globalPos rather than "initialized to QCursor::pos(), which may not be appropriate" as the docs have pointed out for many years now. This removes the remaining calls to QCursor::pos() in event constructors. Task-number: QTBUG-52430 Task-number: QTBUG-69433 Task-number: QTBUG-100324 Change-Id: I076dae56f37abaad7085cc95dddee453a80a45f3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add a QHoverEvent ctor taking global mouse position; deprecate the otherShawn Rutledge2022-02-031-3/+3
| | | | | | | | | | | | | | | | | The QSinglePointEvent ctor assumes that the given globalPos is correct, so it was wrong that the QHoverEvent ctor passed along a local position as global. It's better to require globalPos as an argument; and in fact it seems that everywhere we construct a QHoverEvent, global position is available, or possible to get by transformation (which is better than resorting to QCursor::pos()). Also, don't convert to QPoint: pointer events have qreal resolution and there's no reason to truncate them. Fixes: QTBUG-100324 Change-Id: I919455da36265988d3d149eb97563c9ed0d2c660 Pick-to: 6.3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTableView: correctly toggle column selection when scrolledVolker Hilsheimer2021-12-021-0/+56
| | | | | | | | | | | | | | | | We need to check whether the horizontal header's selection includes the index for the row at the top, rather than for row 0, as the index we check is based on the scrolled position of the header, so would never be included in the top row when the view is scrolled. This is correctly done in selectRow already. Add a test case that simulates selection of rows and columns by clicking on the header. Fixes: QTBUG-98444 Pick-to: 6.2 Change-Id: I2fa1b32bf75dc96225b40145b713bf7e2ffc29dd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QtBase: replace windows.h with qt_windows.hYuhang Zhao2021-11-232-2/+2
| | | | | | | | | | We have some special handling in qt_windows.h, use it instead of the original windows.h Change-Id: I12fa45b09d3f2aad355573dce45861d7d28e1d77 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QAIV: Reset double-click flag in mousePressEventVolker Hilsheimer2021-11-051-0/+38
| | | | | | | | | | | | | | | Amends 17c1ebf8bfd254ff75cc55e335d1c1fb01da547f, which introduced logic that recognizes double clicks to avoid duplicate clicked() emits. If a slot connected to doubleClicked opens a dialog, then the release-event will not be seen by the item view, leaving the flag incorrectly set and preventing the next clicked signal. Fixes: QTBUG-97853 Pick-to: 6.2 5.15 Change-Id: Iced83e8c66a763672f522265435dc52a745227e4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QAbstractItemView: auto-scroll with selection rectangleVolker Hilsheimer2021-10-222-0/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | Some item views, such as QListView in icon mode, implement a selection rectangle with which the user can "lasso" items. So far, dragging that rectangle did not trigger auto scroll, so unless an item near the edge was selected, the user had to stop the lassoing and scroll manually to reach more items. Since QAbtractItemView implements auto scrolling for drag'n'drop, we can use that mechanism also when the selection rectangle is dragged. This requires some modifications: We need to make sure that scrolling the view during a drag-selection generates mouse move events so that the selection is extended and the rectangle is updated in subclasses. And we need to stop using QCursor::pos to get the position of the mouse pointer, as this makes the auto-scrolling untestable. Instead, record the mouse position last seen during a mouseMove or dragMoveEvent in content-coordinates (identical to pressedPosition). As a drive-by, fix some coding-style issues in nearby code. Done-with: Zhang Hao <zhanghao@uniontech.com> Fixes: QTBUG-96124 Change-Id: I426f786e5842ae9f9fb04e9d34dc6d3379a6207f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Select a single range of cells in QTableView, away from merged cellsShawn Rutledge2021-10-121-0/+71
| | | | | | | | | | | | | | | | | | | | | - when there is no intersection between the current selection and the spans collection, get ranges for all cells, just as if no span exists - when there is an intersection between the current selection and the spans collection, get separate ranges for each cell (as before) This fixes the regular case of selecting multiple non-spanned cells after some cells are merged (get a single range for all cells instead of separate range for each cell). However, when selecting together a group of spanned and non-spanned cells, you still get a separate range for each cell. But this is normal behavior in similar applications; for example in LibreOffice, you cannot select and merge spanned and non-spanned cells: an error dialog tells you that it's not allowed. Done-with: Christos Kokkinidis Pick-to: 6.2 Fixes: QTBUG-255 Change-Id: Ic38f9a064a1f499825e7f750668013fc2dc564ba Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTableWidgetSelectionRange: Make it possible to compare for equalityVolker Hilsheimer2021-10-121-0/+14
| | | | | | | | | Add operators as hidden friends, add test case to make sure that basic value-type operations are possible with this type. Task-number: QTBUG-255 Change-Id: I7fbf453aa16084c0b2a0079487cacb4e092ff664 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>