summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels/qabstractitemmodel.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QEmptyItemModel: add Q_OBJECT macroJuha Vuolle2024-04-181-0/+2
| | | | | | | | Task-number: QTBUG-122619 Change-Id: Ie84e13d64071d2735e0f873b26a73e476d761742 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Fix \fn template arguments for Qt CoreLuca Di Sera2023-11-301-1/+1
| | | | | | | | | Upcoming changes to QDoc require accurate definition for template arguments in \fn commands. Task-number: QTBUG-118080 Change-Id: I64d50919bc6ffab61ef5ead553d1da99d63a9f21 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: Fix template information for a QModelRoleDataSpan constructorLuca Di Sera2023-11-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When QDoc parses a project, it parses the source code to extract the user-provided documentation and perform sanity checkings based on the code itself on it. When QDoc parses an "\fn" command as part of this process, it tries to understand, based on its intermediate representation built on the information extracted from the code-base, which "documentable element" the "\fn" refers to. When QDoc performs this "matching" process, it takes into consideration only a certain amount of information. For example, no checking is performed over the template declaration of a callable. Due to some upcoming documentation, where two callables are indistinguishable to the current process, as they differ only in their template declaration, QDoc will start to take into consideration the template declaration of a callable when matching. This implies that an "\fn" command should now provide information parity, with regards to template declaration for callables, with the code-base so that QDoc can perform the match correctly. The documentation for `QModelRoleDataSpan::QModelRoleDataSpan(Container&)` is not in sync with the intended target template declaration. Hence, add the missing information to the relevant "\fn" commands. Task-number: QTBUG-118080 Change-Id: I08c7adf901fac81bb1c115a5017908cba4656bea Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: Fix warnings and linking issuesTopi Reinio2023-10-091-1/+7
| | | | | | | | | | | | | | | | | | | | Remove or replace links to examples that were removed or moved under manual tests. Replace code snippets that were quoting the now-missing examples. Fix documentation of QSet::removeIf(). Fix typo in documentation macro: Unknown command '\examplecateogry'. Add qtopengl, qtshadertools dependencies to Qt Widgets documentation project to enable correct linking to those topics. Mark all documentation sets in qtbase as free of warnings. Pick-to: 6.6 6.5 Change-Id: I058cd5f2063aa933ea310bceff906f05422a7cb2 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: state that models are not thread-safeMitch Curtis2023-10-021-1/+3
| | | | | | | Fixes: QTBUG-107598 Pick-to: 5.15 6.2 6.5 6.6 Change-Id: I0e7ea8d4b2094d92b3cad5eec5b30e6e3ac64018 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QPersistentModelIndex: fix relational operators not being noexceptMarc Mutz2023-09-301-4/+4
| | | | | | | | | | | | | They actually can be, so the implementation need not change. Just add the noexcept tag (which is BC, it's not part of the name mangling on any compiler). Silences a bunch of XFAIL in the test (the test is automatically picking up the change, no need, and no way, to manually remove the QEXPECT_FAIL). Change-Id: I24b6ba1248001056de64f341617943e7aea5ae93 Reviewed-by: David Faure <david.faure@kdab.com>
* QPersistentModelIndex: fix UB (op< on unrelated pointers)Marc Mutz2023-09-301-1/+3
| | | | | | | | | | | | | | Pointers can only be legitimately compared with less-than (<) if they point into the same array (or one past the end). This is decidedly not the case for heap-allocated objects like QPersistentModelIndexPrivates, so doing it is UB. Fix by using std::less, which is guaranteed to be a total order, even for unrelated pointer values. Pick-to: 6.6 6.5 6.2 5.15 Change-Id: If04341b4b55784e7732782f3ae829f53b0ceab9c Reviewed-by: David Faure <david.faure@kdab.com>
* Doc: Remove links to removed examplesAndreas Eliasson2023-08-281-5/+4
| | | | | | | | These examples have been removed as part of the examples revamp project. Pick-to: 6.6 6.5 Change-Id: I2a8237334a2acae2735c2dbd86004048d288896a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractItemModel: fix match() with Qt::MatchWildcardGiuseppe D'Angelo2023-03-091-2/+4
| | | | | | | | | | | | | | | | | | | 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>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-8/+8
| | | | | | | | | | | | | | | | 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-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-39/+3
| | | | | | | | | | | | | 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>
* Exploit the new macro varargs form of Q_GLOBAL_STATICEdward Welbourne2022-04-221-3/+3
| | | | | | | | Convert various uses of Q_GLOBAL_STATIC_WITH_ARGS() to the less verbose form the recent reworking makes possible. Change-Id: I57820660b5d00d39bf54b5a08cb921ebaec57c7c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Core: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+1
| | | | | Change-Id: I2c71188a4d27692a2d6ef1aa447b329627214b17 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QAbstractItemModel: fix persistent index corruption when moving columnsDavid Faure2022-02-281-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QAbstractItemModel: make naming of arguments consistentAndreas Buhr2022-02-191-8/+8
| | | | | | | | | The signals rowsAboutToBeMoved/rowsMoved have the same arguments, but use different argument names. This patch aligns the naming, making it consistent. Same for columnsAboutToBeMoved/columnsMoved. Change-Id: I1cefe54319e569b8d57f6579ae9d5c3e33b66dc2 Reviewed-by: David Faure <david.faure@kdab.com>
* Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] ↵Marc Mutz2022-01-211-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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>
* Prevent repeated instantiations of ↵Marc Mutz2022-01-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qRegisterNormalizedMetaType<QList<QModelIndex>>() This, finally, shows some expected results: Clang -ftime-trace: $ ClangBuildAnalyzer --analyze qtgui-spec-before.trace | head -n6 Analyzing build trace from 'qtgui-spec-before.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 665.7 s Codegen & opts (backend): 298.9 s $ ClangBuildAnalyzer --analyze qtgui-spec-after.trace | head -n6 Analyzing build trace from 'qtgui-spec-after.trace'... **** Time summary: Compilation (525 times): Parsing (frontend): 628.3 s Codegen & opts (backend): 301.0 s GCC 11 time (bash builtin): $ time for ((i=0; i < 3; ++i)) do touch ../qt5/qtbase/src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so real 4m10,918s user 49m10,099s sys 3m11,719s $ git revert --no-commit HEAD $ time for ((i=0; i < 3; ++i)) do touch ../qt5/qtbase/src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so real 4m18,630s user 51m11,491s sys 3m16,479s The technique in the comment in qmetatype.h doesn't work on Clang - it runs into -Winstantiation-after-specialization. The whole extern template stuff so miserably fails to meet the goals set out in N1448, not only for MSVC and class templates, but, it seems, on all compilers, and for function templates, too, that I'm giving up on it for now. Unfortunately, I'm not really seeing a way to hide this stuff behind a macro, yet. Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: I500fd04555e0bd76ac021f75582bd8d8cf339378 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Reword, fix typos and some formattingIvan Tkachenko2021-12-081-1/+1
| | | | | Change-Id: I0929f7653cb07665842d0aa7bf18dc80471febdc Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Consistent handling of disabled items in QItemSelectionModelAndreas Buhr2021-07-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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-2/+2
| | | | | | | | 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>
* QAbstractItemModel::match: code tidiesGiuseppe D'Angelo2021-05-121-1/+1
| | | | | | | | Remove a magic number from the code, by adding it (as a private value) to the right enumeration. Use toInt() to convert to integer. Change-Id: Id1b00dde900619684b5a3df247d46938439150ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Dont' return a const ref to QModelIndexLars Knoll2020-12-041-5/+4
| | | | | | | | | | | The conversion operator from QPMI to QModelIndex should return by value, to hide implementation details and so that we don't have to rely on a static empty QModelIndex. Change-Id: I92b3f8451422f2b69bf31f28b387a124fd24ec46 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 0cd2935ed9d772f0eb06d03201baabd60764ec80) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Resolve corelib's remaining ### Qt 6 commentsEdward Welbourne2020-11-021-1/+1
| | | | | | | | | | | | | No action taken at Qt 6, suggesting it shall never happen. Four removed, one converted to Qt 7, others converted to unversioned TODOs. Filed Jira tasks, and referenced in comments, for those retained. There remain two "once bootstrap builds are obsolete" comments and one other on which pending action may yet happen. Fixes: QTBUG-85700 Change-Id: Ib140a6a21c63370e51e4734cc591f67573a29d9a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAIM docs: use \nullptr instead of 0Giuseppe D'Angelo2020-10-021-2/+2
| | | | | | Pick-to: 5.15 Change-Id: I30b541f28ba8271eb4234c7f642485a1614808bf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: link QModelRoleData and QModelRoleDataSpan documentationVolker Hilsheimer2020-09-221-17/+17
| | | | | Change-Id: I49bb356d5296dc73effd18399b7a205f00c24252 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Long live QAIM::multiData!Giuseppe D'Angelo2020-09-021-0/+298
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Views / delegates absolutely *adore* hammering data(). A simple QListView showing a couple of dozens entries can call data() a hundred of times on the first show. Back of the hand calculation, * 2 times per visible item (sizeHint() + paint()), * times 9 roles used by the default delegate, * times 20 visible items = 360 as a bare minimum, assuming the view doesn't redraw twice accidentally. Move the mouse over the view, and that'll cause a full update with certain styles: 360 calls to data() per update. This has an overhead visible in profilers. The model's data() has to re-fetch the index from its data structure and extract the requested field every time. Also, QVariant is used for the data interexchange, meaning anything that won't fit in one is also a memory allocation. This problem will likely be gone in Qt6Variant as that will store sizeof(void*) * 3, meaning QImage/QPixmap and similar polymorphic classes will fit in a QVariant now... So I'm trying to to remove part of that overhead by allowing views to request all the data they need in one go. For now, one index a a time. A view might also store the data returned. The idea is that the same role on different indexes will _very likely_ return variants of the same type. So a model could move-assign the data into the variant, avoiding the memory allocation /deallocation for the variant's private. This patch: 1) Introduces QModelRoleData as a holder for role+data. 2) Introduces QModelRoleDataSpan as a span over QModelRoleData. The idea of a span type is twofold. First and foremost, we are in no position to choose which kind of container a view should use to store the QModelRoleData objects for a multiData() call; a span abstracts any contiguous sequence, leaving the view free to do whatever it wants (statically allocate, use a vector, etc.). It also solves the problem of efficient passing the roles and gathering the returned variants from multiData(). 3) Add multiData(), which populates a span of roles for a given model index. The main advantage here is that a model can fetch all the needed information for a given index just once, then iterate on the span and provide data for each requested role. Cf. this with data(), where every call has to re-fetch the information for the index. A couple of models have been ported to multiData(), as well as QStyledItemDelegate. [ChangeLog][QtCore][QModelRoleData] New class. [ChangeLog][QtCore][QModelRoleDataSpan] New class. [ChangeLog][QtCore][QAbstractItemModel] Added the multiData() function. Change-Id: Icce0d108ad4e156c9fb05c83ce6df5f58f99f118 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Disentangle QIODevice dependenciesLars Knoll2020-08-151-4/+4
| | | | | | | | | | | | | | | | | Move the QIODevice::OpenMode enum into a base class, so that we can remove the full QIODevice (and thus QObject) dependency from qdatastream.h and qtextstream.h. This is required so that we can include QDataStream in qmetatype.h without getting circular dependencies. As a nice side effect, QDataStream and QTextStream can now inherit QIODeviceBase and provide the OpenMode enum directly in their class scope. Change-Id: Ifa68b7b1d8d95687ed032f6c9206f92e63bfacdf Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Add ; to Q_UNUSEDLars Schmertmann2020-07-071-3/+3
| | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Use QList instead of QVector in corelib implementationJarek Kobus2020-06-291-84/+52
| | | | | | | | Omitting state machine and docs for now. Task-number: QTBUG-84469 Change-Id: Ibfa5e7035515773461f6cdbff35299315ef65737 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* ItemModels: remove deprecated functionsChristian Ehrlicher2020-06-071-90/+1
| | | | | Change-Id: Id3430493a62b11977f64e146f7668ca30935b959 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractItemModel: remove deprecated setRoleNames()Christian Ehrlicher2020-06-071-28/+2
| | | | | | | Remove setRoleNames() and all its now unneeded helper functions. Change-Id: I0a83751aace35700655d4cc7c79278325994cbdd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QModelIndex/QAIM: improve const correctnessGiuseppe D'Angelo2020-05-061-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QAIM::createIndex() takes a non-const void*. It's typically called from inside QAIM::index(), which is a const member function. If the data storage wrapped by the model is const correct, it means that we have to drop constness somewhere before calling createIndex(). To support this: change createIndex() to take a const void * instead. This is painless. Accessing the pointer is a bit more troubling, because the accessor (QModelIndex::internalPointer()) returns void *. (Effectively, now it does a const_cast...). To avoid a massive source break, I've left it alone, and instead added another function to retrieve a const void *. Read-only models can now be fully (deep) const correct. [ChangeLog][QtCore][QAbstractItemModel] The createIndex() function now takes a const void *, rather than a void *. [ChangeLog][QtCore][QModelIndex] Added the constInternalPointer() function, to retrieve the internal pointer as a pointer-to-const. Change-Id: I108912b6814fcd5fe0c5cb7db6c721ba51e83de0 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove some leftover includes of QRegExpLars Knoll2020-05-061-1/+0
| | | | | | | and include qrefularexpression.h in the pch for Qt Core. Change-Id: Ibfa84c911dfcffd3e5a5cf11e48b186cff6e7d7a Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Change qHash() to work with size_t instead of uintLars Knoll2020-04-091-1/+1
| | | | | | | | | | | This is required, so that QHash and QSet can hold more than 2^32 items on 64 bit platforms. The actual hashing functions for strings are still 32bit, this will be changed in a follow-up commit. Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make MatchRegExp an alias to MatchRegularExpressionLars Knoll2020-03-301-7/+0
| | | | | | | All matching happens using QRegularExpression now. Change-Id: I10bfcefbf4d9c79d235242e3e05116cdf7af02d1 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Don't call QSet::erase() on an end iteratorLars Knoll2020-03-251-1/+3
| | | | | | | | hash.erase(hash.constFind()) is bound to crash if the hash doesn't contain the item we're looking for. Change-Id: Icbefca87b0258970373ec55d5dc113e6ab39c5f0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix compilation with -no-feature-regularexpressionEskil Abrahamsen Blomfeldt2020-03-171-2/+12
| | | | | | | | | This -no-feature has probably not been tested for a while and seems to have rotted a bit, both some unprotected uses and some warnings on unused parameters. Change-Id: Ie20a06c78d3b4c36860dab49d6615eaa8ffc9077 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devLiang Qi2020-02-131-0/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/widgets/graphicsview/boxes/scene.h src/corelib/Qt5CoreMacros.cmake src/corelib/Qt6CoreMacros.cmake src/network/ssl/qsslsocket.cpp src/network/ssl/qsslsocket.h src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp src/testlib/CMakeLists.txt src/testlib/.prev_CMakeLists.txt tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp Disabled building manual tests with CMake for now, because qmake doesn't do it, and it confuses people. Done-With: Alexandru Croitor <alexandru.croitor@qt.io> Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: I865ae347bd01f4e59f16d007b66d175a52f1f152
| * Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-02-081-0/+3
| |\ | | | | | | | | | Change-Id: I5d80d84d1fd9f52e7c8e4895cc34d4d29043f400
| | * Doc: QPersistentModelIndex cannot be stored in a QStandardItemVolker Hilsheimer2020-02-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in the bug report, making sure that the reference counts are correct in such scenarios adds substantial complexity to the code, only to support a bad use-case for which QStandardItemModel was not designed. Change-Id: I663b490ed3471875386add17e7eadb7d8df50489 Fixes: QTBUG-78142 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | | Don't rely on iterators being stable while modifying the hashLars Knoll2020-02-091-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Mapping struct referred to where it got inserted into the source_index mapping table by a const iterator to the table. That is rather fragile, as changing the table invalidates the iterator. It happened to work with QHash in Qt 5, but will break with the new implementation in Qt 6. Instead simply store the key in the Mapping struct so that it can be quickly found in the hash. Also fix one place, where we unconditionally call erase on an iterator returned by constFind(). Turns out constFind() did sometimes not find the item in question and returns end(). Change-Id: I0420a06d496f640a3150478e8c644d4cc669ceff Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-281-20/+20
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsettings.cpp src/corelib/kernel/qvariant.cpp src/corelib/serialization/qjsoncbor.cpp src/corelib/serialization/qjsonvalue.cpp src/corelib/tools/tools.pri src/gui/image/qimage.cpp src/gui/kernel/qguivariant.cpp src/widgets/kernel/qshortcut.cpp tests/auto/tools/moc/allmocs_baseline_in.json tests/auto/tools/moc/tst_moc.cpp src/opengl/qglframebufferobject.cpp Done-With: Edward Welbourne <edward.welbourne@qt.io> Done-With: Leander Beernaert <leander.beernaert@qt.io> Change-Id: Ie7f5fa646c607fe70c314bf7195f7578ded1d271
| * | Replace most use of QVariant::type and occurrences of QVariant::TypeOlivier Goffart2020-01-231-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I made a clazy automated check that replaced the use of QVariant::Type by the equivalent in QMetaType. This has been deprecated since Qt 5.0, but many uses were not yet removed. In addition, there was some manual changes to fix the compilation errors. Adapted the Private API of QDateTimeParser and QMimeDataPrivate and adjust QDateTimeEdit and QSpinBox. QVariant(QVariant::Invalid) in qstylesheet made no sense. But note that in QVariant::save, we actually wanted to use the non-user type. In the SQL module, many changes were actually reverted because the API still expects QVarient::Type. Change-Id: I98c368490e4ee465ed3a3b63bda8b8eaa50ea67e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Don't mix QHash and QMultiHashLars Knoll2020-01-061-17/+11
| | | | | | | | | | | | | | | Change-Id: I8a6ec788f995ef2609e971e0a2f330973975657a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-12-091-10/+10
|\| | | | | | | | | | | Change-Id: Ia24cc8b86def0d9d9c17d6775cc519e491b860b1
| * | Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-11-251-2/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qhash.h src/gui/kernel/qevent.h src/widgets/kernel/qshortcut.cpp src/widgets/kernel/qshortcut.h Change-Id: If61c206ee43ad1d97f5b07f58ac93c4583ce5620
| * | Deprecate constructing QFlags from a pointerAllan Sandfeld Jensen2019-11-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>