summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/itemmodels
Commit message (Collapse)AuthorAgeFilesLines
* Enable resetting a sort model by descending orderAli Kianian3 days1-4/+7
| | | | | | | | | | | | | | | | | By this change, sort(any_negative_number) will stay unchanged, and it unsorts the model so that the order will be the same as the source model. But when the second argument of the sort is set to DescendingOrder deliberately, the result will be the same as the source model, but in reverse order. [ChangeLog][QTCore][QSortFilterProxyModel] QSortFilterProxyModel.sort sorts the proxy by the source model index descending if the sort column is less than zero and the order is descending. Fixes: QTBUG-124863 Change-Id: I73f9d3b500a929efa969cf24ef3d8fe758167645 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QItemSelectionRange: use new comparison helper macrosTatiana Borisova2024-04-181-0/+10
| | | | | | | | | | | | Replace public operators operator==(), operator!=() of QItemSelectionRange class to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Task-number: QTBUG-120304 Change-Id: Ideff990c942d5ee1c89a93ac2081cc5d7067b23f Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Change license for tests filesLucie Gérard2024-02-0414-14/+14
| | | | | | | | | | | | According to QUIP-18 [1], all tests file 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: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Introduce macros to simplify testing comparisonIvan Solovev2024-01-191-12/+6
| | | | | | | | | | | | | | | | | | | | | The problem with the QTestPrivate::testAllComparisonOperators() and QTestPrivate::testEqualityOperators() functions is that if they fail, they point into the helper function, but not into the actual test that called the helper function. This is specially annoying when some test calls the helper function multiple times. This patch introduces the helper macros QT_TEST_ALL_COMPARISON_OPS and QT_TEST_EQUALITY_OPS that wrap the respective function calls together with the QTest::currentTestFailed() check. If the test has failed, the macro generates a meaningful debug message with the original file name and line number. This patch also applies the new macros to qtbase. Task-number: QTBUG-119433 Pick-to: 6.7 Change-Id: Iad709de45e5bf53c82e7afa8e9f51e9275c1e619 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QIdentityProxyModel: add setHandleSourceLayoutChanges(bool)Ahmad Samir2023-12-151-0/+35
| | | | | | | | | | | | | | | | | | | | | | | Some sub-classes have special handling of source model layout changes (abbreviated as SMLC from here on out), they relied on disconnecting the connections to the _q_*layout* slots in the private class using the SLOT macro. This isn't possible any more after recent changes (and the method were renamed to remove _q_ prefix). Sub-classes resorting to using private API is a clear sign some functionality is missing from the public API, so a cleaner solution for this issue is adding this setter which enables sub-classes to tell QIdentityProxyModel to leave handling of the SMLC to them. Thanks to David Faure for the idea/solution. [ChangeLog][QtCore][QIdentityProxyModel] Added setHandleSourceLayoutChanges(bool) method to allow sub-classes to indicate to QIdentityProxyModel that they will handle source model layout changes on their own. Also added a getter, isHandleSourceLayoutChanges(). Change-Id: I1de79dd693ce32a6e2df9a7c81dd4abdc5f00248 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Q(Persistent)ModelIndex: use new test framework for op==Marc Mutz2023-11-132-0/+31
| | | | | | | | | | | All good, except missing noexcept. Can't test ordered relational operators because the classes provide only op<, not the full set, so this has to wait until we port Q*ModelIndex to the new comparison framework. Change-Id: I05e26c88f0bd8c035ef0461c7c50b218c513da08 Reviewed-by: David Faure <david.faure@kdab.com>
* QItemSelectionModel: don't warn when destroying the modelVolker Hilsheimer2023-09-221-0/+17
| | | | | | | | | | | | | | | | | | | Amends 4f4a8e75ab34003a4a49b89392ae7712415ac788, after which QItemSelectionModel printed a warning when destroying the model. We reset the selection model in response to the model getting destroyed, and since the model is already set to be nullptr at this point the select() function complains about changing the selection with no model set being a no-op. Fix this by not calling reset() when the model gets destroyed - the stored selection and currentIndex are already reset at this point - and instead only call reset() when a new model is set in initModel. Fixes: QTBUG-117200 Pick-to: 6.6.0 6.6 6.5 6.2 Change-Id: I12fc6b3fb2f2ff2a34b46988d5f58151123f9976 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QAbstractProxyModel: fix binding loopsIvan Solovev2023-09-031-3/+3
| | | | | | | | | | | | | | | | ... by using valueBypassingBindings() when accessing the properties from the setters. This commit is mostly trivial. Had to change the template parameters in the unit-test, because the updated QTestPrivate::testReadWritePropertyBasics() creates an instance of the TestedClass, and QAbstractProxyModel cannot be instantiated, since it has pure virtual methods. Task-number: QTBUG-116346 Pick-to: 6.6 6.5 Change-Id: I0cae29263ea9bb92c9de06891b0ba8633fb9fd72 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QItemSelectionModelPrivate: use QObjectPrivate::connectAxel Spoerl2023-09-011-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | QItemSelectionModelPrivate::initModel() uses string based connections, to connect/disconnet its QAbstractItemModel. The QObject::destroyed signal is connected to modelDestroyed(), which does not disconnect other signals. QQuickTableView's selection model binds to its QAbstractItemModel. The binding also reacts to QObject::destroyed Eventually, QItemSelectionModel::setModel(nullptr) is called. At this point, only a QOBject is left from the QAbstractItemModel. That leads to warnings about disconnecting string based signals, which belong to QAbstractItemModel. This patch changes the connect syntax to the QObjectPrivate::connect API. Instead of keeping a list of string based connections around, the connections themselves are kept in a list member. Disconnecting happens based on that list. Connections are also disconnected in QAbstractItemModelPrivate::modelDestroyed. An auto test is added in tst_QItemSelectionModel. Fixes: QTBUG-116056 Pick-to: 6.6 6.5 6.2 Change-Id: I57e5c0f0a574f154eb312a282003774dd0613dd6 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* tst_QSortFilterProxyModel: fix mem-leaks II: sortStable()Marc Mutz2023-07-191-12/+12
| | | | | | | | | | | | | | | | | | Like in 9f8449a054a165ae560c91d3e31409bc293df80d, for doubleProxySelectionSetSourceModel(), the sortStable() test also leaked _everything_. Fix in the same way, by allocating model and view on the stack intead of the heap. With this patch, tst_QSortFilterProxyModel is now asan-, but not ubsan-clean (and, because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110704, asan still reports a leak in cp-demangle.c, which should be™ gone once we fix the rest of QTBUG-99563). Pick-to: 6.6 6.5 6.2 5.15 Task-number: QTBUG-115264 Change-Id: Ic0e833d7336435e324457f9d9667ee8573a7dafc Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* tst_QSortFilterProxyModel: fix mem-leaksMarc Mutz2023-07-151-11/+11
| | | | | | | | | | | tst_QSortFilterProxyModel::doubleProxySelectionSetSourceModel() leaked _everything_, driving asan nuts. Allocate objects on the stack instead; now it's asan-clean. Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I721e797e02b1daec9e2b5e3d4ef612a42b2e3492 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QSortFilterProxyModel test: fix failing appearsAndSortChristian Ehrlicher2023-07-071-1/+2
| | | | | | | | | | | | | | | | | Testcase appearsAndSort failed when running the complete testcase but not as single test. More irritating was the fact that the error was in QAbstractItemModelTester::headerDataChanged() but the affected test did not change any header nor does it use the blamed model... The reason for this is, that QAbstractProxyModel emits a queued headerDataChanged signal when the header item count changes and therefore only evaluated when the event loop is run. Fix it by calling processEvents() after the rowCount change in filterColumns(). Amends 72e802f3b0cc7a0f36fe3c445d401d38af97ca99 Pick-to: 6.6 6.5 Change-Id: I10cb5aa9c40a6925113cc9c23616774bf15784a4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* CMake: Make corelib tests standalone projectsAlexandru Croitor2023-07-0511-0/+66
| | | | | | | | | | | | | | | | | | 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: I28b6d3815c5f43d2c33ea65764f6f3f8f129eaf3 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAbstractProxyModel: delay headerDataChanged emissions when ↵Giuseppe D'Angelo2023-06-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | inserting/removing rows/columns 33c88f86b5b8714977719a8ccff0f7c15c9cbd44 added some logic to QAPM in order to have it automatically emit headerDataChanged when rows/columns were added or removed in the model. This was done as a stopgap measure to prevent QAPM from asking for illegal indices in order to implement automatic remapping of the section headings (since there's no mapSectionToSource). The commit seems to have introduced a regression in QHeaderView, which isn't prepared to receive headerDataChanged while a row/column count change is in progress. When receiving headerDataChanged, QHeaderView will try to read the row/column count and will store it internally. When it will then receive the signals for insertion/removal of rows/columns, it will interpret it as a modification of the previously stored value -- even if the value it stored was already correct. Fix this by avoiding to have two signals in flight at the same time; emit headerDataChanged as a queued invocation. Task-number: QTBUG-114225 Change-Id: I521465a852b8c7135f22f730ead41dca760ba428 Pick-to: 6.5 6.6 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove unused variablesAmir Masoud Abdol2023-04-191-6/+0
| | | | | | | | | Removing a few unused variables in auto tests that were triggering `-Wunused-but-set-variable`. Pick-to: 6.5 Change-Id: I74bd0d7335d8bddeb18687b18c8a8be965f9fa20 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QAbstractItemModel: fix match() with Qt::MatchWildcardGiuseppe D'Angelo2023-03-091-8/+9
| | | | | | | | | | | | | | | | | | | QAIM::match() supports different matching modes. The wildcard match mode was never meant to be specifically a filepath globbing wildcard, but rather a generic one -- something like "*" should match into a string like "a/b/c". This is a regression from Qt 5, where QRegExp::Wildcard was ported to only allow for path globbing rather than generic matching. [ChangeLog][QtCore][QAbstractItemModel] QAbstractItemModel::match() now uses more generic wildcard matches rather than file path globbing. Please refer to the documentation of QRegularExpression::wildcardToRegularExpression() for more information about the differences. Change-Id: I28b8a76b01fdd9c5dd8f99528fac1c7b704564bc Fixes: QTBUG-104585 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-1710-20/+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>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-039-350/+350
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-112-6/+6
| | | | | | | | | | | | | | | | 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>
* Port from container.count()/length() to size()Marc Mutz2022-10-045-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QtBase tests: remove QT_DISABLE_DEPRECATED_UP_TO definesIvan Solovev2022-08-243-6/+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-2312-12/+12
| | | | | | | 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-193-3/+3
| | | | | | | | | | | | | | 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>
* Add license headers to cmake filesLucie Gérard2022-08-0312-0/+36
| | | | | | | | | | | | 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-286-6/+6
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-1614-400/+28
| | | | | | | | | | | | | 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>
* QAbstractProxyModel: do not access invalid indexesGiuseppe D'Angelo2022-04-131-0/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QAbstractProxyModel::headerData tries to do the "smart" thing and map sections in the proxy to sections in the source. However there's no "mapSectionToSource" virtual. Instead, to map horizontal headers, the code builds a proxy index at row 0 and section N, maps it to the source, and finds out which source column it gets mapped to. (Same story for the vertical headers). ... in general this can obviously fail, say you've got a "horizontal scrambling" proxy model, but in the common case this is OK. Except, if the proxy is empty (e.g. 0 rows or columns). In this case, it asks for an illegal index, and if you reimplemented index() yourself (which you must, since it's a pure virtual in QAPM) and you do bounds checking, you'll not be pleased at the result. This turns out to be a massive API liability. To fix this somehow properly, we can decide that empty models don't get the section remapped (easy). Less easy is the fact that, when the model does get some data, we have to emit headerDataChanged() otherwise the views will get broken. So add this logic too. Note that QAPM does not normally forward any source model's signal -- a subclass has to connect to them and handle them explicitly. That's *another* API liability, all over the place -- data(), headerData(), flags(), etc. What I mean by this is that one can create a valid QAPM (by implementing its pure virtuals) that however is immediately broken by the convenience that QAPM provides for the rest (data(), headerData(), etc.). This commit doesn't try and change this in any way, but I'm less and less convinced of the usefulness of QAPM in its current shape. Change-Id: I45a8c2139f2c1917ffbf429910fdb92f005f4feb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Faure <david.faure@kdab.com>
* Fix test to pass with QT_FORCE_ASSERTSFriedemann Kleint2022-02-181-1/+2
| | | | | | | | Add QT_FORCE_ASSERTS to condition with standard comment. Pick-to: 6.3 6.2 Change-Id: If493c7cdea8164f010228a755915a211c1cf1b39 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tst_QItemModel: fix memleaksMarc Mutz2022-01-051-3/+3
| | | | | | | | | | | When creating proxied models, make the source model a QObject child of the proxy model, so the source isn't leaked when the proxy is deleted. This drove asan nuts. Pick-to: 6.3 6.2 5.15 Change-Id: I0f7fc9ab8e99d030c941cfb336ee4e2323b362ae Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QAbstractItemModelTester in all QSortFilterProxyModel testsAndreas Buhr2021-12-141-0/+1
| | | | | | | | This patch installs a QAbstractItemModelTester in the QSortFilterProxyModel tests. Change-Id: I9bdcc21ba12f919c91c5b9514a5f4362437318c2 Reviewed-by: David Faure <david.faure@kdab.com>
* Shorten target name for qsortfilterproxymodel auto testsOliver Wolff2021-11-292-2/+2
| | | | | | | | | These long target names can quickly lead to exceeding Windows' max path length. Pick-to: 6.2 Change-Id: Ibd77e53464a71221f9302d490afbe9c41c16646d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Make QAbstractProxyModel itemData() behave like data()Luca Beldi2021-11-261-1/+10
| | | | | | | | | | | | | | | | | | | | | | QAbstractProxyModel::itemData/setItemData should behave just like data()/setData() instead of calling the QAbstractItemModel implementation. Before this change the QAbstractProxyModel implementation calls its the QAbstractItemModel implementation, which ends up calling data()/setData() in a loop bypassing the convenience of itemData/setItemData. [ChangeLog][QtCore][QAbstractProxyModel] The itemData() and setItemData() functions will now call the respective implementations in the source model (after mapping the index to a source index), matching what data() and setData() already did. Before, the proxy model simply called the default implementations of itemData()/setItemData() in its own base class (QAbstractItemModel). Change-Id: I9e680d355f44fa130660dd7e1c8ac37484c1566e Reviewed-by: David Faure <david.faure@kdab.com>
* Untangle qsortfilterproxymodel unittestsDavid Faure2021-10-016-18/+20
| | | | | | | | | | | | | | With the QRegExp variant removed, it was weird to have all QSFPM tests in "tst_qsortfilterproxymodel_regularexpression", even those completely unrelated to regexps. Instead of reuniting into a single executable as before, I simply split it out in separate executables: * tst_qsortfilterproxymodel has the "standard" QSFPM tests * tst_qsortfilterproxymodel_regularexpression has the regexp-related tests * tst_qsortfilterproxymodel_recursive is separate as before Change-Id: I345530b4352671164008bba4805af7b12ac90247 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* emit layoutAboutToBeChanged timelyLuca Beldi2021-07-206-2/+221
| | | | | | | | | | | layoutAboutToBeChanged must be called before persistentIndexList as the user might create persistent indexes as a response to the signal Fixes: QTBUG-93466 Pick-to: 6.2 5.15 Change-Id: I73c24501f536ef9b6092c3374821497f0a8f0de4 Reviewed-by: David Faure <david.faure@kdab.com>
* Consistent handling of disabled items in QItemSelectionModelAndreas Buhr2021-07-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | In QItemSelectionModel, items which are disabled or marked as not selectable should not be considered as selected. But this was not handled consistently. The following methods considered only items which are enabled and marked selectable: selectedIndexes(), rowIntersectsSelection(), and columnIntersectsSelection(). The following methods considered only items which are marked selectable, but did not check whether they are enabled: selectedRows(), selectedColumns(), isRowSelected(), isColumnSelected(), isSelected(). Finally there is hasSelection(), which did not check for enabled nor for selectable. This patch introduces consistent behavior. All methods check both whether the items are enabled and whether they are selectable now. [ChangeLog][QtCore][QItemSelectionModel][Important Behavior Changes] All methods in QItemSelectionModel now consider only items which are marked as enabled and selectable as part of the selection. Fixes: QTBUG-93829 Pick-to: 6.2 Change-Id: I4725243ea6b0db4f289ce34ada22c7a9d3282713 Reviewed-by: David Faure <david.faure@kdab.com>
* QSortFilterProxyModel: create mappings on demand againDavid Faure2021-06-032-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling create_mapping in setSourceModel as introduced by 8455bfee76ed3f1bd3bba8bd3688a7afa94ae0bb can lead to an early call to filterAcceptsRow, and some existing applications may crash. It is also an incomplete solution since it was only done for the toplevel index but not for child indexes. Instead, go back to creating mappings on demand. This means coming up with a different fix for QTBUG-87781 (dataChanged not emitted for indexes that haven't been mapped yet, i.e. not queried or shown anywhere). When this happens, we can't know if the index was previously filtered out or not (for lack of a dataAboutToBeChanged signal...). Creating the mapping with the new data only gives us the new state of affairs, there's no reference state to compare to. Therefore, when the mapping is missing (during dataChanged handling), create it, but skip all the logic about row insertion/removal, just forward the dataChanged signal if the row isn't filtered out. Creating the mapping might require creating first mappings for parents, recursively, which wasn't done anywhere in QSFPM yet, hence the new create_mapping_recursive() method. In addition to all this, the handling of removed items was incorrect, remove_source_items did nothing if the parent was gone, and then source_items_removed was trying to adjust indexes in an incorrect list. If the parent is gone, clear the proxy_to_source list, so there's nothing to adjust afterwards. This bug actually doesn't happen anymore in this version of the patch, but the change still seems right and might prevent repeating a long debugging session in the future. Thanks to ChunLin Wang for the unittest in this commit. Done-with: ChunLin Wang Pick-to: 6.1 6.0 5.15 Change-Id: Id543d0cc98f1a03b5852bda01d2f49b980e06be7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix QItemSelectionModel::selectionChanged emissionAndreas Buhr2021-05-181-0/+43
| | | | | | | | | | | | | | | | | | | | QItemSelectionModel has the property selectedIndexes with the notification signal selectionChanged. When a row is deleted or inserted above the current selection, the row number of the current selection changes and thus the return value of selectedIndexes changes. This should trigger its notification signal. This signal was not emitted. This patch fixes this and adds a unit test to verify this. [ChangeLog][Important Behavior Changes][QtCore] QItemSelectionModel now emits the selectionChanged signal if only the indexes of the selected items change. Fixes: QTBUG-93305 Change-Id: Ia5fb5ca32d658c9c0e1d7093c57cc08a966b9402 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* QSFPM: make filterRegularExpression and filterCaseSensitivity bindableIvan Solovev2021-05-112-0/+99
| | | | | | | | | | | | | | | | | This takes care of the last two QSFPM properties. They were postponed because of the tricky relation between them and some bugs in handling the changes. The bug was fixed in bcbbbdb2d640c059c19e9337c7418b83b1b7e4ea and now the behavior is well-determined: updating filter regexp does trigger case sensitivity change and vice versa. However updating only regexp pattern (via QString overload or setFilterFixedString or setFilterWildcard) does not change case sensitivity. Task-number: QTBUG-85520 Change-Id: Idc41cf817de9e6263ed65a80fa40fc8415c8c856 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QSortFilterProxyModel: port to new property systemIvan Solovev2021-05-113-3/+78
| | | | | | | | | | filterRegularExpression and filterCaseSensitivity will be handled in a separate commit Task-number: QTBUG-85520 Change-Id: I848c5c6cbe8642efa156f4f5d33467976bbf0351 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* QAbstractProxyModel: port to new property systemIvan Solovev2021-05-042-2/+33
| | | | | | | | | | | | | | The biggest trick here is the getter (QAbstractProxyModel::sourceModel), which is returning nullptr, while internally using a global staticEmptyModel() instance. This lead to inconsistency while binding to a proxy model without source model. The bound object would point to staticEmptyModel() instance, while sourceModel() getter returns nullptr. To solve this issue a custom QBindableInterface is implemented. Task-number: QTBUG-85520 Change-Id: I597df891c7e425d51b55f50ccbacabdfe935cbac Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QSFPM: fix filterCaseSensitivityChanged signal emission logicIvan Solovev2021-04-301-0/+19
| | | | | | | | | | | | | | | | | | This patch amends bcbbbdb2d640c059c19e9337c7418b83b1b7e4ea. It fixes the logic of filterCaseSensitivityChanged signal emission. The call to QRegularExpression overload of setFilterRegularExpression could change the filterCaseSensitivity, but the signal was never emitted. [ChangeLog][QtCore][QSortFilterProxyModel] A call to QRegularExpression overload of setFilterRegularExpression now emits a filterCaseSensitivityChanged signal, if required. Pick-to: 6.0 Pick-to: 6.1 Change-Id: Id4ef04227c1f8ed98153fa5107ec3fbe4c0c77fb Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port of QItemSelectionModel::model to new property systemAndreas Buhr2021-04-272-1/+28
| | | | | | | | | | The property 'model' is ported to a bindable property. The properties hasSelection, selection, selectedIndexes, and currentIndex are left for later patches. Task-number: QTBUG-85520 Change-Id: Ia424ce99fc80c3d807c634c21d161a3ad94b27d2 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Fix case sensitivity handling QSFPMSamuel Gaist2021-04-221-0/+66
| | | | | | | | | | | | | | | | | | | | | | This patch fixes the breaking of case sensitivity handling. The removal of QRegExp killed the wrong code paths which leads to inconsistencies when changing the regular expression throuh methods like setFilterWildCard or setFilterFixedString. Changing the case sensitivity also nukes the original options that were set on the regular expression if it was set through setFilterRegularExpression. [ChangeLog][QtCore][QSortFilterProxyModel] Case sensitivity as well as regular expression options handling have been fixed. The original value is properly kept when using setFilterWildCard and setFilterFixedString. The regular expression options are now also properly kept when changing the case senstitivity through setFilterCaseSensitivity. Fixes: QTBUG-92260 Pick-to: 6.1 Pick-to: 6.0 Change-Id: Ifb4732306f0c7d79ad0b18d3f5437c4523bb40e5 Reviewed-by: Igor Kushnir <igorkuo@gmail.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix get out of bounds index in QSortFilterProxyModel::filterAcceptsRowChunLin Wang2021-04-071-0/+17
| | | | | | | | | Before calling the index function, we need to check the validity of the parameters. Fixes: QTBUG-91878 Pick-to: 5.15 6.0 6.1 Change-Id: I9ec7265fff3f81b8a288c4ba8fae606a2ec808a6 Reviewed-by: David Faure <david.faure@kdab.com>
* Fix removing columns when QSortFilterProxyModel has not been sorted yetJoni Poikelin2021-03-251-0/+14
| | | | | | | Fixes: QTBUG-91788 Pick-to: 6.1 6.0 5.15 Change-Id: Iddcafd3171f0f3703b94893a32b4ccaaeea9e713 Reviewed-by: David Faure <david.faure@kdab.com>
* QConcatenateTablesProxyModel: skip dataChanged in hidden columnsDavid Faure2021-03-091-0/+11
| | | | | | | | | | | | | | | | When the source models don't have the same number of columns, the proxy keeps only the smallest number of columns across all source models. Afterwards, if a source model emits dataChanged in a column past that number (a "hidden" column), the proxy needs to ignore it rather than assert. But also, if the source model emits a dataChanged signal across both visible and hidden columns, then the last column number needs to be adjusted so that the signal is correctly processed and forwarded. Task-number: QTBUG-91253 Pick-to: 6.1 6.0 5.15 Change-Id: I939e8ec0faf41370472f86785851292e4372f72c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Make sure QMimeData is fully declaredVolker Hilsheimer2021-01-111-0/+2
| | | | | | | | | | The test deletes instances of QMimeData in the dropMimeData function. The compiler warns about deleting objects of incomplete type if QMimeDate is only forward declared. Change-Id: I3423a7ea334180ff0b68efbecb3d3feeb0632239 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-0711-90/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Replace QtTest headers with QTestDavid Skoland2020-12-228-9/+17
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix invalid QSortFilterProxyModel::dataChanged parametersWang ChunLin2020-11-302-0/+168
| | | | | | | | | QSortFilterModel shouldn't forward dataChanged() when the source model changes data in columns that the filter model refuses Fixes: QTBUG-86850 Pick-to: 5.15 Change-Id: I26565d119d2aa36ea07b3de0c15f1b137bc002f8 Reviewed-by: David Faure <david.faure@kdab.com>