summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels/qitemselectionmodel.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QItemSelectionRange: use new comparison helper macrosTatiana Borisova2024-04-181-4/+6
| | | | | | | | | | | | 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>
* Itemmodels: s/QPair/std::pair/Marc Mutz2023-12-141-5/+5
| | | | | | | | | | | | | | Also port from qMakePair() to just braced initialization and CTAD. As a drive-by, use emplacement instead of appending pairs explicitly, rewrite typedef into `using`, and remove the qpair.h include from the .cpp file (cannot affect other TUs and <utility> is considered included in qcompilerdetection.h). Pick-to: 6.7 Task-number: QTBUG-115841 Change-Id: Ia985520dfce6b77b1c0fe7669fc92d2df97e1b06 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QItemSelectionModel: remove some redundant codeAhmad Samir2023-09-231-3/+1
| | | | | | | | | | | | QObject::disconnect(connection) already sets connection.d_ptr to nullptr, and the default constructor only does that: QMetaObject::Connection::Connection() : d_ptr(nullptr) {} So calling disconnect() suffices in this case. Pick-to: 6.6 6.5 6.2 Change-Id: Icd5f9a15c83939eeecd9efb474ac3b38c0f2dfe4 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QItemSelectionModel: don't warn when destroying the modelVolker Hilsheimer2023-09-221-3/+3
| | | | | | | | | | | | | | | | | | | 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>
* QItemSelectionModel: fix binding loopsIvan Solovev2023-09-061-16/+17
| | | | | | | | | | | | | | | ... by using valueBypassingBindings() when accessing the properties from the setters. Also adjust initModel() to use the raw pointers instead of accessing the property when comparing the value and doing all connections. This change is safe, because initModel() is a private method that is only called from the constructors of the class and the setter. Task-number: QTBUG-116346 Pick-to: 6.6 6.5 Change-Id: I6ecde571aeed74077099c6bf8f66736ba14d29f8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QItemSelectionModelPrivate: improve formatting of the connectionsIvan Solovev2023-09-061-24/+25
| | | | | | | | | | | | | | The formatting of the connections in the initModel() call was confusing and made me overlook the fact that they all were directly used to initialize the connections array. Indent all the nested connections, and move the closing '}' to a separate line to make the code more readable. This commit amends 4f4a8e75ab34003a4a49b89392ae7712415ac788. Pick-to: 6.6 6.5 Change-Id: I607e09699a3b4865cb17639ffc75f754f4400c91 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QItemSelectionModelPrivate: use QObjectPrivate::connectAxel Spoerl2023-09-011-45/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix qdoc link warnings after moving a few examples to manual testsTor Arne Vestbø2023-06-271-1/+1
| | | | | | Pick-to: 6.5 6.6 Change-Id: I81a6e9d52e858c3f733d4c527c70408772813b56 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-32/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-111-2/+2
| | | | | | | | | | | | | | | | 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-041-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Use SPDX license identifiersLucie Gérard2022-05-161-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. 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>
* QItemSelectionModel: avoid 24 relocationsMarc Mutz2022-03-111-35/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use qOffsetStringArray() instead of an array of pairs of pointers. This unearthed a problem with SIGNAL and SLOT calling qFlagLocation() (meaning in debug mode, the array was runtime-initialized, not just relocated), which we work around by using the new QT_STRINGIFY_ {SIGNAL,SLOT} macros now. Saves 24 relocations, but, interestingly, saves only 4b in text size on GCC 11.2 Linux AMD64 -O2 C++20 builds (TEXT and DATA combined) while saving 760b on the equivalent Clang 10 libc++ build (expected, in both cases: 24 * (sizeof(void*) - sizeof(quint16))): Clang: $ size qtbase/lib/libQt6Core.so.6.4.0 text data bss dec hex filename 5476156 90520 16185 5582861 55300d qtbase/lib/libQt6Core.so.6.4.0 $ ~/bin/relinfo.pl qtbase/lib/libQt6Core.so.6.4.0 qtbase/lib/libQt6Core.so.6.4.0: 6528 relocations, 3598 relative (55%), 2540 PLT entries, 2227 for local syms (87%), 0 users $ ninja libQt6Core.so [6/6] Creating library symlink qtbase/lib/libQt6Core.so.6 qtbase/lib/libQt6Core.so $ size qtbase/lib/libQt6Core.so.6.4.0 text data bss dec hex filename 5475604 90312 16185 5582101 552d15 qtbase/lib/libQt6Core.so.6.4.0 $ ~/bin/relinfo.pl qtbase/lib/libQt6Core.so.6.4.0 qtbase/lib/libQt6Core.so.6.4.0: 6504 relocations, 3574 relative (54%), 2540 PLT entries, 2227 for local syms (87%), 0 users GCC: $ ~/bin/relinfo.pl qtbase/lib/libQt6Core.so.6.4.0 qtbase/lib/libQt6Core.so.6.4.0: 6300 relocations, 5343 relative (84%), 318 PLT entries, 1 for local syms (0%), 0 users $ size qtbase/lib/libQt6Core.so.6.4.0 text data bss dec hex filename 6019871 75896 16952 6112719 5d45cf qtbase/lib/libQt6Core.so.6.4.0 $ ninja libQt6Core.so [6/6] Creating library symlink qtbase/lib/libQt6Core.so.6 qtbase/lib/libQt6Core.so $ ~/bin/relinfo.pl qtbase/lib/libQt6Core.so.6.4.0 qtbase/lib/libQt6Core.so.6.4.0: 6276 relocations, 5319 relative (84%), 318 PLT entries, 1 for local syms (0%), 0 users $ size qtbase/lib/libQt6Core.so.6.4.0 text data bss dec hex filename 6020091 75672 16952 6112715 5d45cb qtbase/lib/libQt6Core.so.6.4.0 Pick-to: 6.3 Change-Id: I60749953f1a63d23d696a5a547cd924ec259ead3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] ↵Marc Mutz2022-01-211-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (QtGui) Create macros that wrap the magic developed in 7d63efc16f65f98c657caa90e0d7e9b72a879ade and apply it to all Q_DECLARE_METATYPE invocations that show up in Clang -ftime-trace for a PCH'ed QtGui build. Effects on compile times: Clang 10 -ftme-trace: $ ClangBuildAnalyzer --analyze qtgui-before.trace | head -n6 Analyzing build trace from 'qtgui-before.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 628.3 s Codegen & opts (backend): 304.5 s $ ClangBuildAnalyzer --analyze qtgui-after.trace | head -n6 Analyzing build trace from 'qtgui-after.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 546.0 s Codegen & opts (backend): 304.4 s GCC 11 time (bash builtin): before: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 4m13,539s user 49m24,416s sys 3m18,177s after: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 3m55,697s user 45m19,941s sys 3m7,370s Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: Ia8e37a58937568a7ed21cfeb4b27274deca4d53b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QItemSelection: fix (some) O(n²) behavior in merge()Marc Mutz2021-11-161-9/+7
| | | | | | | | | | | | | | | Instead of taking a copy of the incoming data, followed by a quadratic modifying algorithm (single-element erase loop), guaranteeing a deep-copy detach of the original, just iterate over the incoming data, building the new dataset by appending only valid items. Also port to ranged for loop. There's more quadratic behavior in that function, later on, but that's for another patch. Change-Id: I284f3b7c9694c8eb226a198f6f97538765113b19 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix segfault in QItemSelectionModel::hasSelectionAndreas Buhr2021-10-141-2/+5
| | | | | | | | | | | Amends 0c2125458a9fdddaf3385b257ba4350da872a1d1. The code assumed that a QItemSelectionModel always has a model. But during initialization from QML, it hasn't. Fixes: QTBUG-97475 Pick-to: 6.2 6.2.1 Change-Id: Ie9c680f8989a23ef732faaf5da7ef7ae273126aa Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Consistent handling of disabled items in QItemSelectionModelAndreas Buhr2021-07-151-22/+46
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Item models: code tidiesGiuseppe D'Angelo2021-05-181-1/+1
| | | | | | | | Use QFlags::testAnyFlag instead of relying on implicit conversions. Change-Id: I7ac8149535ad28e47fbf3e250042892bdf8c3a72 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
* Fix QItemSelectionModel::selectionChanged emissionAndreas Buhr2021-05-181-8/+32
| | | | | | | | | | | | | | | | | | | | 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>
* Port of QItemSelectionModel::model to new property systemAndreas Buhr2021-04-271-20/+74
| | | | | | | | | | 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>
* Use (new) erase()/erase_if() algorithmsMarc Mutz2020-12-051-7/+2
| | | | | Change-Id: I45c18fd45c20b226e44d16315e3ebb6c305d4ab0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove QItemSelectionRange's operator<()Edward Welbourne2020-10-281-41/+0
| | | | | | | | | | | | As advocated in a ### Qt 6 comment. [ChangeLog][QtCore][QItemSelectionRange] QItemSelectionRange no longer supports ordering. The prior ordering was inconsistent with equality and should not be needed. Task-number: QTBUG-85700 Change-Id: I5eb372c203cae19db40fa67f706d911785652d5f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Deprecate ordering on QItemSelectionRangeEdward Welbourne2020-10-281-1/+3
| | | | | | | | | | | | | | | Ready for removal at Qt 6, as advocated in a ### comment. It was never done consistently with operator==(), apparently, and should not be needed in any case. [ChangeLog][QtCore][QItemSelectionRange] Ordering of QItemSelectionRange is now deprecated. It was not consistent with equality and should not be needed. Task-number: QTBUG-85700 Pick-to: 5.15 5.15.2 Change-Id: Ie99294bd7fc18f2a497598ae08840886b0a6d62d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-2/+2
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Use QList instead of QVector in corelib implementationJarek Kobus2020-06-291-7/+7
| | | | | | | | Omitting state machine and docs for now. Task-number: QTBUG-84469 Change-Id: Ibfa5e7035515773461f6cdbff35299315ef65737 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QItemSelectionModel: simplify QItemSelectionRangeChristian Ehrlicher2020-05-231-15/+0
| | | | | | | | Simplify QItemSelectionRange by removing the unneeded user-defined functions - the compiler can generate them by it's own. Change-Id: I49c00f937df98bb1ad18057b7bae7a0e06919909 Reviewed-by: David Faure <david.faure@kdab.com>
* QItemSelectionModel: port a local QSet to QDuplicateTrackerMarc Mutz2020-05-051-8/+7
| | | | | | | | | Apart from a more fitting, minimal, API, QDuplicateTracker also transparently uses C++17 pmr::monotonic_buffer_resource to avoid, or at least reduce, memory allocations. Change-Id: I5d7d32c52ad19d37c0e1191e822304349944d7e6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QItemSelectionModel: replace a QPair with a dedicated structMarc Mutz2020-05-051-8/+23
| | | | | | | | | | | | | | Pairs are easy to use, but they have no semantics attached: Two QPair<int, int> compare equal, e.g., even though one is used as a coordinate and the other as, say, a fraction. It also carries no information for the reader of the code, as exemplified by the urge to comment on the content of the pairs in both functions that use them. So, write a minimal struct with equality and qHash() instead. The comments are now no longer needed. Change-Id: I51f6ff049a5f8fa61c51856376ac2fcbfb8dd506 Reviewed-by: David Faure <david.faure@kdab.com>
* Doc: QItemSelectionModel: Note when function default arguments were addedTopi Reinio2020-03-261-0/+12
| | | | | Change-Id: I4b7a9269b68c86548035b57211c4c1b5ad451767 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Liang Qi2019-12-161-8/+9
|\ | | | | | | | | | | | | | | Conflicts: src/network/ssl/qsslsocket.cpp src/widgets/kernel/qapplication.cpp Change-Id: Ib7421cc2df59d0969f89b3fbd65a17ea76ffef3b
| * Let QItemSelectionModel::columnIntersectsSelection honor the parentChristian Ehrlicher2019-12-141-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | QItemSelectionModel::columnIntersectsSelection() should honor the parent according to the docs. For rowIntersectsSelection() this was fixed a long time ago but columnIntersectsSelection() was forgotten. Sync the both functions and use range-based for loops as a drive-by. Fixes: QTBUG-80644 Change-Id: Iaf08f85e2225204d1e6564fa4bb0bc826352ed53 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* | Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-1/+1
|/ | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove remaining Q_DECL_NOEXCEPT/Q_DECL_NOTHROW usageAllan Sandfeld Jensen2019-04-041-2/+2
| | | | | Change-Id: I91ac9e714a465cab226b211812aa46e8fe5ff2ab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: Unify license headersKai Koehne2018-12-221-1/+1
| | | | | Change-Id: Iff4f6da9f0bbf7a0627101f455dd8467681b2783 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QItemSelectionModel: More fixes for is(Column/Row)SelectedDaniel Teske2018-04-301-27/+46
| | | | | | | | | | | | | | Replace the code for isRowSelected and isColumnSelected with a much simpler algorithm for deciding if a row/column is selected. In a model with a cross-hatch of unselectable indexes, the return values of is(Column/Row)Selected would depend on the order in which the selections were done. Task-number: QTBUG-18001 Change-Id: I6aa4b1df7c07fae469a686041927fa8c42bc9b16 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QitemSelectionModel: Fix a bug in isColumnSelectedDaniel Teske2018-04-301-2/+6
| | | | | | | | | | | | | | | | Previously the code for isColumnSelected and isRowSelected differed slightly, in how unselectable indexes would be treated. This made isColumnSelected return false for a column, which mixed unselectable indexes and selected indexes. Thus in some situations, the user could not deselect a column via a QTableView header. By copying the isRowSelected code to isColumnSelected, rows and columns behave identical. Task-number: QTBUG-18001 Change-Id: I6ca85ac64b31a481fafeaa3bec958b18283eed8d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QItemSelectionRange: speedup intersects() in negative caseChristian Ehrlicher2017-11-301-4/+6
| | | | | | | | | | | | | | QItemSelectionRange::intersects() needs to check if the parent of both QItemSelectionRanges is the same. This is a very expensive operation which should be done last. Same goes for isValid() which itself calls parent() for two indexes. This rearrangement speeds up some worst-case usecases by at least 30% as shown in the bug report. Task-number: QTBUG-60940 Change-Id: If6111a73cb8b97a8a0d0640527b34448d21f3143 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
* Convert features.itemviews to QT_[REQUIRE_]CONFIGStephan Binner2017-07-251-4/+0
| | | | | | | The QT_NO_ITEMVIEWS queries in corelib/ seem to had no effect at all. Change-Id: I494ee2309a96b0cf25de18781fc9a675878a2ee9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* QItemSelection: fix a quadratic loopMarc Mutz2017-05-221-12/+20
| | | | | | | | | | | | | | | | | | | | QList::erase(it) is a linear operation. Calling it in a loop constitutes quadratic behavior. Fix by using the erase-remove idiom. Write a generic function object QtFunctionObjects::IsNotValid, instead of a lambda, because I am building up a collection of such function objects in my tree, to be submitted any time now™, so this will reduce the churn once that gets merged. Wrap it in the unnamed namespace to avoid ODR violations in case this pattern repeats. Replace an existing erase-remove idiom's isNotValid lambda function with the new function object. Change-Id: I4f0af04e7b201eb168e79beeda332eee3c6f33c3 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Merge remote-tracking branch 'origin/5.9.0' into 5.9Liang Qi2017-05-191-1/+4
|\ | | | | | | Change-Id: Ia8ac1960387c0f78c32f9d0385bb0aa9a8209af1
| * QItemSelectionRange: don't compare pointers with op<Marc Mutz2017-04-301-1/+4
| | | | | | | | | | | | | | | | ... use std::less<> to avoid undefined behavior. Change-Id: Ib6736f86359c4a16fd90ca63b57a8517c6137ead Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* | Fix missing handling of columns when merging selection rangesFilippo Cucchetto2017-05-091-1/+2
|/ | | | | | | | | | | | | | | | | This commit fixes two bugs: 1) Two ranges should not be merged if they are of different columns. The old code would have merged (0,0) with (1, 1). Tranforming a selection of just two indexes in a rectangle of four indexes. 2) The QItemSelectionRange appended had wrong column and worked only for indexes of the first column. For example if 'tl' was (0, 1) than br was (0, 1) so the QItemSelectionRange would have be ((0,1), (0, 1-1)) so ((0,1), (0,0)). This QItemSelectionRange is invalid because topLeft columns is greater than bottomRight column. The fix take in consideration the bottomRight column. Task-number: QTBUG-58871 Change-Id: I591ef0bcc63926f24a7b1ced002af9b7737a4b6e Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QItemSelectionRange: de-inline op<Marc Mutz2016-12-021-2/+27
| | | | | | | | | It's a bit large for an inline function. Note for Qt 6 that this function is nonsense. Change-Id: If6af5d3538aac86d55313ba6accdb13f892e6564 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* CoreLib: use const (and const APIs) moreAnton Kudryavtsev2016-04-181-1/+1
| | | | | | | | | | For CoW types const methods will be called. Mark store_persistent_indexes() as const, because this method does not modify the object. Change-Id: Ic867913b4fb5aaebfbaaffe1d3be45cf7b646403 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtBase: use erase and std::remove_if with QList and QVectorAnton Kudryavtsev2016-04-081-7/+7
| | | | | | | ... instead of using removeAt in a loop, with quadratic complexity. Change-Id: I38b49e56b12c396db9fc0f1b75d8fb43c503a7f6 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QItemSelectionModel: refactoring of internal functionsAnton Kudryavtsev2016-03-111-16/+12
| | | | | | | | | | | | Introduce template helper function qSelectionIndexes(). Template argument is container. Now we have the same code for QVector and QList. Also it's needed for a follow-up change in this file: add method QModelIndex QItemSelection::index(). Change-Id: I7f86a9b96e5feac9873cf0df7a1cbca74f9191ec Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QtCore: eradicate all Q_FOREACH loops [itemmodels]Marc Mutz2016-01-041-1/+1
| | | | | | | | Saves more than 4KiB in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: Ice3fe915622a399d1ed10e0ce364cf54b4b835fe Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Revert "Doc: Added info about sorting in QItemSelectionModel::selectedIndexes"Nico Vertriest2015-12-031-1/+0
| | | | | | | | This reverts commit d0f57439d02582cf7564d1509d13f715eadc7f05. This commit had introduced a wrong statement about the sorting. Change-Id: I2f6ea6f7cfb318bca7bd44c686956ba135b65b20 Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
* Doc: Added info about sorting in QItemSelectionModel::selectedIndexesNico Vertriest2015-11-161-0/+1
| | | | | | Task-number: QTBUG-40726 Change-Id: I450f9735fbbdc6574e8a14ea0076a28ee65077de Reviewed-by: Martin Smith <martin.smith@digia.com>