aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/qqmltableinstancemodel.cpp
Commit message (Collapse)AuthorAgeFilesLines
* TableInstanceModel: handle roleName invalidationRichard Moe Gustavsen2023-04-181-2/+21
| | | | | | | | | | | | | | | | | roleNames are generally guaranteed to be stable (given that QAIM has no change signal for them), except that resetting the model is allowed to invalidate them. TableInstanceModel did so far not take this into account. Handle this case correctly by snapshotting the current roleNames before the model is reset. Afterwards, if we detect that roleNames has changed, we throw the current model set up away and rebuild everything from scratch – it is unlikely that a more efficient implementation would be worth it. Fixes: QTBUG-111987 Pick-to: 6.5 6.2 Change-Id: Id1e3b8e4f983c0f00fc7b30bd4897f1f7fcc3792 Reviewed-by: Fabian Kosmale <[email protected]>
* Required properties: Use pointers instead of referencesFabian Kosmale2022-11-101-3/+3
| | | | | | | | | | | | This allows for a more natural handling of the case where there are no required properties, and will enable further refactoring of ConstructionState. Unfortunately, we lack a way to mark pointers as always non-null in Qt, else we could mark all required property pointers originating from QQmlObjectCreatorSharedState as such. Change-Id: Icaccb27654130fb57daf924bb44a70a5cf114fed Reviewed-by: Ulf Hermann <[email protected]>
* QQmlTableInstanceModel: add some extra assertsRichard Moe Gustavsen2022-11-031-0/+6
| | | | | | | | | | Now that QQuickTableView will start to use more than one QQmlTableInstanceModel (to implement editDelegate), add some extra asserts to ensure that we don't mix up which delegate items were created from which instance model. Change-Id: I0d556542ca5409a963ea05c63b3e33b643192bbd Reviewed-by: Doris Verria <[email protected]>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <[email protected]>
* QmlModels: Fix context and extra object handlingUlf Hermann2022-07-211-20/+27
| | | | | | | | | | | | | | | | | | | | | | If we have a bound context, we still need to record the information that the object's context belongs to a delegate. For this purpose we have the extra object. Even when we create the object in the component's creation context, the object creator still produces a private internal context for each object. We unconditionally attach the extra object to that one, and check the whole context hierarchy for extra objects. As we now record the creation context for model items incubated from bound components, we need to make sure not to (re)set its context object and not to forcibly invalidate it. We have QQmlRefPointer::reset() for that anyway. As a drive-by we also assert that the object ref count doesn't overflow, as that has happened during testing. Pick-to: 6.4 Fixes: QTBUG-104884 Change-Id: I836916c63656124a0f9d7b04902debba59b9f3a3 Reviewed-by: Fabian Kosmale <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <[email protected]>
* QQmlAdaptorModel::setModel: clean up signatureFabian Kosmale2022-02-031-1/+1
| | | | | | | We no longer need the parent parameter. Change-Id: I2687f051d51269abc0a74c4aafe77230ae9223c1 Reviewed-by: Ulf Hermann <[email protected]>
* Improve type conversions from/to QJSValueUlf Hermann2021-10-201-1/+2
| | | | | | | | | We can convert everything into a QJSValue if we have an engine and we can save a binding function in a QVariant by wrapping it into QJSValue. Change-Id: I48e7c13f3f744f1c50bf673b427fe9331250f313 Reviewed-by: Andrei Golubev <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* qqmltableinstancemodel: add setRequiredProperty()Richard Moe Gustavsen2021-04-301-4/+32
| | | | | | | | | | | | | | | | Add a virtual function setRequiredProperty() to QQmlInstanceModel that we override in QQmlTableInstanceModel. This function can be called from QQuickTableView, upon getting the initItem signal, to assign initial values to any required properties that the view makes use of. This patch is added as a preparation for adding selection support to QQuickTableView (which will make use of "required property isSelected" on the delegate) Change-Id: I55885bafa14da1d432c120bef807e73165f1466c Reviewed-by: Fabian Kosmale <[email protected]>
* Remove QQmlEnginePrivate::isQObjectFabian Kosmale2021-03-051-1/+1
| | | | | | | | | | | The only caller has a QMetaType available and can query that one. This leads to subsequent cleanups in QQmlListAccessor::setList and QQmlAdaptorModel::setModel which now no longer have a need to pass the QQmlEngine along. Task-number: QTBUG-82931 Change-Id: I6f38892a3a5098f07bc21f4eebcca82cf52a6838 Reviewed-by: Ulf Hermann <[email protected]>
* Fix compilation with namespacesEskil Abrahamsen Blomfeldt2020-11-101-2/+2
| | | | | | | | | | | The moc_ file was included inside the namespace, causing its includes to generate nested namespaces. Recently some changes to the meta type system turned this into a compilation error. Change-Id: I31d6c9133bf56d12457daaa219467e44c1b4a7ea Reviewed-by: Fabian Kosmale <[email protected]>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-091-4/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4executablecompilationunit.cpp src/qml/jsruntime/qv4executablecompilationunit_p.h src/qml/qml/qqmlobjectcreator.cpp src/qml/qml/qqmlpropertycachecreator_p.h src/qml/qml/qqmltypecompiler.cpp src/qml/qml/qqmltypedata.cpp tests/auto/qml/qmlformat/tst_qmlformat.cpp tools/qmllint/scopetree.cpp src/qml/qml/qqmlapplicationengine_p.h Adjusted tools/qmllint/findunqualified.cpp to use newer API Change-Id: Ibfb4678ca39d626d47527265e3c96e43313873d4
| * QQmlTableInstanceModel: Restore draining behavior of Qt 5.14Ulf Hermann2020-03-271-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In Qt 5.14 model items are directly deleted when draining the reusable items pool, rather than calling deleteLater() on them. This may be slightly more efficient and due to some unknown side effect the deleteLater() call creates a memory leak. Restore the direct delete in drainReusableItems(). Fixes: QTBUG-82000 Change-Id: Ia1027b1004c04e8aceaa5ff16a600849c46bf470 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Richard Moe Gustavsen <[email protected]>
* | Encapsulate QQmlContextDataUlf Hermann2020-03-231-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class is not a private detail of QQmlContext. And it is incredibly hard to see who owns what in there. Let's add some civilization ... We enforce refcounting for QQmlContextData across the code base, with two exceptions: 1. QQmlContextPrivate may or may not own its QQmlContextData. 2. We may request a QQmlContextData owned by its parent QQmlContextData. For these two cases we keep flags in QQmlContextData and when the respective field (m_parent or m_publicContext) is reset, we release() once. Furthermore, QQmlContextData and QQmlGuardedContextData are moved to their own files, in order to de-spaghettify qqmlcontext_p.h and qqmlcontext.cpp. When the QQmlEngine is deleted, any QQmlComponents drop their object creators now, in order to release any context data held by those. Before, the context data would be deleted, but the object creators would retain the dangling pointer. [ChangeLog][QML][Important Behavior Changes] QQmlContext::baseUrl() does what the documentation says now: It prefers explicitly set baseUrls over compilation unit URLs. Only if no baseUrl is set, the CU's URL is returned. It used to prefer the CU's URL. Change-Id: Ieeb5dcb07b45d891526191321386d5443b8f5738 Reviewed-by: Fabian Kosmale <[email protected]>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-091-1/+20
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmlirbuilder_p.h src/qml/qml/qqmlpropertycachecreator_p.h src/qmltyperegistrar/qmltypesclassdescription.cpp src/qmltyperegistrar/qmltypesclassdescription.h src/qmltyperegistrar/qmltypescreator.cpp src/quick/items/qquicktext_p.h src/quick/util/qquickvaluetypes_p.h Change-Id: Ic209741592e7b85820bf3845722023a190ebc1c5
| * Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-03-031-1/+20
| |\ | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qmlmodels/qqmltableinstancemodel.cpp src/qmlmodels/qqmltableinstancemodel_p.h Change-Id: I89339b1cb41ba27fe30c79530859a1c2bfbecc69
| | * QQuickTableView: Immediately delete delegates when possibleUlf Hermann2020-02-281-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the dtor we don't need to care about any side effects a direct delete may have. Rather, any deleteLater() may not take effect anymore as the event loop may be gone already. Task-number: QTBUG-82000 Change-Id: I97935dc47fbbfd0c050e80c333c36a05f685c45d Reviewed-by: Joni Poikelin <[email protected]> Reviewed-by: Simon Hausmann <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
| | * QQmlTableInstanceModel: Fix refcounting of metatypesUlf Hermann2020-02-271-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reusable items pool should only hold unreferenced objects. Therefore, we can immediately delete them when draining. release() is not suitable here because it unconditionally decreases and therefore underflows the refcount. Furthermore, the metatype is also refcounted, which means we should keep it in a QQmlRefCounter in order to not leak references. Task-number: QTBUG-82000 Change-Id: Iefdaaecc34342eb2e3b1e5a3281f2e46ac472347 Reviewed-by: Joni Poikelin <[email protected]> Reviewed-by: Simon Hausmann <[email protected]>
* | | Use QTypeRevision for all versions and revisionsUlf Hermann2020-02-031-2/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | In many places we carry major and minor versions or revisions that are loosely coupled to minor versions. As the Qt minor version resets now, we need to handle these things more systematically. In particular, we need to add a "major" part to revisions. QTypeRevision can express the current major/minor pairs more efficiently and can also be used to add a major version to revisions. This change does not change the semantics, yet, but only replaces the types. Change-Id: Ie58ba8114d7e4c6427f0f28716deee71995c0d24 Reviewed-by: Fabian Kosmale <[email protected]>
* | Properly refcount QQmlDelegateModelItemMetaTypeUlf Hermann2020-01-281-1/+2
| | | | | | | | | | | | | | Consistently store it in QQmlRefPointer so that it doesn't leak. Change-Id: Id1f06228f6eb477b758901d61c1b71928671dc6a Reviewed-by: Fabian Kosmale <[email protected]>
* | QQmlTableInstanceModel: factor out reuse poolRichard Moe Gustavsen2019-12-041-82/+11
| | | | | | | | | | | | | | | | | | Factor out the reuse pool logic in TableInstanceModel into a separate class, so that we can share it with the upcoming implementation for recycling items in QQmlDelegateModel. Change-Id: If8f700b7a0208bac7d1cb1de087792e2c3a9b512 Reviewed-by: Shawn Rutledge <[email protected]>
* | QQmlInstanceModel::ReleaseFlags: add enum value 'Pooled'Richard Moe Gustavsen2019-11-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Now that we're about to add support for delegate item recycling in ListView, we need to add an extra enum value to the ReleaseFlags. This will be needed later so that ListView can distinguish between items that are still referenced and visible in the viewport, and items that not referenced, but at the same time, still alive in the pool. Change-Id: I4a1110b6b43ba109ccd160d22010569dd5410829 Reviewed-by: Mitch Curtis <[email protected]>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Liang Qi2019-11-221-1/+5
|\| | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlextensionplugin.cpp tests/auto/quick/qquicktableview/tst_qquicktableview.cpp Change-Id: Ic58d36a8532015bae30f2690063db9829b3bf372
| * QQmlTableInstanceModel: always emit index changed when an item is reusedRichard Moe Gustavsen2019-11-141-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When reusing a delegate item, it can sometimes happen that the item ends up being reused at the same location in the table as it had before it was pooled. And in that case, we don't emit changes to index, row and column since they technically didn't change. The problem is that the model might have changed in-between, e.g if a row has been removed. And in that case, row and column will, even when unchanged, point to other parts of the model. So all bindings needs to be reevaluated to ensure that the values they use are refreshed. This patch will therefore ensure that we always emit changes to the mentioned properties when an item is reused, regardless if they change or not. Fixes: QTBUG-79209 Change-Id: Icec201a43a30b9f677303fbf652baf6487621deb Reviewed-by: Mitch Curtis <[email protected]>
* | Models: Move labs classes into src/imports/labsmodelsUlf Hermann2019-10-151-1/+1
| | | | | | | | | | | | | | We want to have only one import URI per library. Change-Id: I8be524cf361b12bcb423c9efccd4e047ae3d8d0e Reviewed-by: Simon Hausmann <[email protected]>
* | Support required properties in model delegatesFabian Kosmale2019-09-121-2/+7
|/ | | | | | | | | | | | | | | If a delegates declares a required property of a given name, and that name exists as a role in the model, we set the property accordingly. The same holds true for the special properties that come from the QQmlDelegateModel like "index" and "model". All roles are still injected into scope and thus accessible; changing this in Qt5 would be tedious or even impossible while still maintaining backwardscompatibility with delegates that do not use required properties. Change-Id: I4f388ba549c42f1ff9822bdb3b8357c4d45e4b66 Reviewed-by: Ulf Hermann <[email protected]>
* Move model types into their own libraryUlf Hermann2019-05-021-0/+547
The model types are not part of the core QML runtime and should only be loaded if you explicitly import them. We cannot enforce that in Qt5 as some of them are available from the QtQml import, but we can change it in Qt6. Change-Id: I1e49e84d748e352537ec2d4af901c034c91d038f Reviewed-by: Erik Verbruggen <[email protected]>