aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/qqmllistmodel.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/tqtc/lts-6.2.8' into ↵Tarja Sundqvist2024-02-201-91/+46
|\ | | | | | | | | | | | | | | | | tqtc/lts-6.2-opensource Conflicts solved in a file: dependencies.yaml Change-Id: Ib4083daa41a689b937d2aeb522e93e3aab0be1c4
| * ListModel: Use PersistentValue to keep track of objectsUlf Hermann2023-01-311-91/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | This is the simplest way to prevent the garbage collector from destroying the object while at the same time allowing a manual destruction. Task-number: QTBUG-95895 Task-number: QTBUG-96167 Fixes: QTBUG-91390 Change-Id: Ic3f3146bc555991068ce3367971e050f745d235d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 718f3469f693eb179f1504a41b18280656a2325d)
* | Merge remote-tracking branch 'origin/tqtc/lts-6.2.7' into ↵Tarja Sundqvist2023-10-031-0/+10
|\| | | | | | | | | | | tqtc/lts-6.2-opensource Change-Id: Ib72ded968b7ac6b75b499392162e3cf3b761ec48
| * QQmlListModel: emit dataChange signal when updating the translationsUlf Hermann2022-10-121-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | We can't really track the individual bindings. Updating all string fields is a blunt thing to do, but it always works and it's not worse than what we did before the translation binding optimization. Fixes: QTBUG-107208 Change-Id: I96b86c979b3168f052af4685874741f674e3337f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 53fa870971c23f932aebcaca6e5393aadd081e54) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* | Merge remote-tracking branch 'origin/tqtc/lts-6.2.6' into ↵Tarja Sundqvist2023-03-011-0/+2
|\| | | | | | | | | | | tqtc/lts-6.2-opensource Change-Id: Ie5a87ae61d8ed0429225353ad46e5232d60f4daa
| * QmlModels: includemocsMarc Mutz2022-07-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Manual conflict resolutions: - dropped all includes into non-existing files Task-number: QTBUG-102948 Change-Id: I080e266e1a23f03efd4acdf48fa51a555429ceac Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 69f7039ada381591f751d1e213c94d48307657a1)
* | Revert "Update commercial license headers"Tarja Sundqvist2022-11-241-21/+21
|/ | | | | | | | | | | This reverts commit 74089697cf2a4961fb697100555b17ae2342d734. Revert of commercial license headers is required for the Qt 6.2.x opensource releases, Qt 6.2.5 onwards. Task-number: QTBUG-107760 Change-Id: Id49069cb5e5f261da185fd082dfb71deb259d387 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Port QV4::CompiledData::Binding to new special integer bitfieldUlf Hermann2022-06-131-8/+9
| | | | | | | Task-number: QTBUG-99545 Change-Id: I9f8bc5fa45c61f77ee95b055a3d8de001da8f8c5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 36ebee4e69182f0e44d87691d4740b271e1dcf38)
* Update commercial license headersTarja Sundqvist2022-06-041-21/+21
| | | | | | | | | | | | | | | Updated header.COMM to the files in tqtc-qtdeclarative. Examples, tests, or documentation files are not updated. The commercial license header may contain some additional lines so that its line count equals with the earlier license header. Reason for this is that some autotests use hard coded line numbers and a change in the line count causes failures in tests. Task-number: QTQAINFRA-4941 Change-Id: I32f554b0a8cb527f74d46f3c02b0e745d9fc5ddf Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlEngine: Fine grained translation binding trackingFabian Kosmale2021-10-111-1/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes translation bindings in such a way that they always depend on the a newly introduced translationLanguage property of the QML engine. Moreover, captureTranslationBinding is changed in the same way, hence any binding containing a call to a translation function like qsTr will also be refreshed. After those changes, QQmlEngine::retranslate can be implemented as a notify on translationLanguage. Finally, QQmlTranslationPropertyBinding is also changed to depend on translationLanguage instead of uiLanguage to ensure consistency between the various binding types. Note that we do not use the existing uiLanguage property of QJSEngine. If we were to do this, changing uiLanguage would already trigger the binding reevaluation, which is a behavior change. In case someone is manually connecting uiLanguageChanged to QQmlEngine::retranslate, this would cause a double evaluation of translation bindings. In a future change, we can however introduce a new enableAutoTranslationUpdate method, which would cause binding evaluation as soon as uiLanguage is changed. Special care is taken for ListModel/ListElement, which does not store a proper translation binding, but instead operates on QV4::CompiledData::Binding. For now, we simply refresh the complete ListModel in case it contains a translation binding. It should be possible to optimize this further in a future change. Note that only "static" ListElement properties can contain translations: The dynamic insertion API makes it impossible to insert a translation, as it would already be resolved to a string when insert is called. [ChangeLog][QQmlEngine] QQmlEngine::retranslate no longer refreshes all bindings, but only translation bindings. Fixes: QTBUG-96192 Change-Id: I54d213fd46b6914e8f686843b49e155909117218 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit d4039298e710b6b79c018589bcc2145e22e1d5aa)
* QQmlListModel: Don't return from the middle of a loopUlf Hermann2021-09-131-6/+5
| | | | | | | | | We still have to process the other properties there. Change-Id: I043596dc55de885e6b746020633ec8b97d043ff2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 75f957f87a9341af5d3266166ae9996dbf79da2b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QQmlListModel: Fix C++ owned object getting destroyedJaeyoon Jung2021-09-021-5/+3
| | | | | | | | | | | | | | | | | If an object is explicitly set as C++ owned, it should not be turned to destructible in any case. explicitIndestructibleSet flag is used for that and thus it should not be unset in any case. This fixes an issue where a C++ owned object could be destroyed by GC when it is added to a ListModel. An object is supposed to be set as destructible implicitly when it is used as a return value from JS unless explicitIndestructibleSet is set. Fixes: QTBUG-96167 Change-Id: Iad06847e56e29dd1b20146be108d7f747d8474dc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com> (cherry picked from commit 219ca3bf2be65fb4f1741bdc7b53d6dc4a41dd31) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qqmllistmodel: Fix QObjects setting indestructibleCathy Park2021-08-261-1/+1
| | | | | | | | | | | | | | It makes a QObject indestructable only if its ownership is determined. This fixes an issue where a QObject created by createObject() in QML becomes indestructable once it is appended to a ListModel. Fixes: QTBUG-95895 Change-Id: I30647298977d7901dab938626e8f94b9910c21e3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 69e07c55ad9b49b7643ffddfedc9a558983272ad) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* ListModel: Fix accessing empty strings in ListElementFabian Kosmale2021-06-301-0/+2
| | | | | | | | | | | | | | | | | | We store empty strings as null strings in StringOrTranslation; consequently isSet will return false for such a string. However, we still know that we are storing a string, and therefore need to return a QVariant containing an empty string, instead of a null QVariant. Amends 5022b91b31370e2afde0426f94ff2ce6843b92e6. This fixes the "undefined" warning in Calqlatr (but changes nothing about the fact that the example isn't reflective of modern QML practices). Task-number: QTBUG-54267 Change-Id: I83d871a79cd2bc0484f0eaf62d4ca345e39218aa Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 9be6a9327af1ac96bccca087ef24100d89a5f8c5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QQmlListModel: Guard QObject pointers in the listUlf Hermann2021-06-301-23/+26
| | | | | | | | | | | | | | If a QObject in the list is deleted from elsewhere, we need to zero it. Amends commit 3edac1d0a70961e6f86564cc0a98339df6ac5964. Fixes: QTBUG-94833 Change-Id: Ic33a5a0baa160824a34f353806dbfd876fa7123a Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit b2ee7364be2f11dc16b80a85141cfdd54e801b10) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmllistmodel: Fix QObjects getting garbage collectedMaximilian Goldstein2021-06-301-16/+63
| | | | | | | | | | | | | Previously QObject's could get garbage collected while in use. This change fixes this by making them indestructible while in use and then restoring their previous state. [ChangeLog][QtQml][QQmlListModel][Important Behavior Changes] ListModels now take ownership of the objects added to them, only releasing them after the object has been removed again. This may break existing solutions which rely on the object not being owned by the model. Fixes: QTBUG-91390 Change-Id: Ifd37c90e13fb0b6ad8a5a06e89f9fc9a429f6316 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 16fc4cf366961e50b5bdf29af5c0546fe3c69495) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QV4::Engine::toVariant: Use metatype instead of metatype idFabian Kosmale2021-03-251-3/+3
| | | | | | | | | | This way, we can avoid the costly id to metatype lookup in case where we actually need the full metatype. Task-number: QTBUG-88766 Change-Id: Ibe29b323007f00d2f8d1807fb9b64f9a8f87e807 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlListModel: Don't discern between empty and null stringsUlf Hermann2021-01-281-0/+2
| | | | | | | | | If we store an empty, rather than null, string, the retrieval mechanism crashes when getting it out again. Therefore, always store a null string. Change-Id: I799293845dd2a72c04cbef3ed1dda68ea782e191 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* ListModel: Fix move handling in syncFabian Kosmale2021-01-131-3/+23
| | | | | | | | | | | | | | | | When a ListModel is modified in a workerscript, we reconciliate the state in ListModel::sync. However, the logic for moving elements was wrong, causing crashes in endMoveRows due to invalid moves. This patch ensures that elements are moved to the correct position. Notably, whenever an element is moved, we must update the targetIndex of all elements affected by that move. Amends 3accc1dae76575120e71cadb547e961ecd50bcb0. Task-number: QTBUG-85557 Pick-to: 5.15 6.0 Change-Id: I1a1ffa43eab39ed2315f1916527d897b208c2c3b Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* qqmlistmodel: Fix crash when modelCache is nullMaximilian Goldstein2020-12-081-1/+1
| | | | | | | Fixes: QTBUG-89173 Pick-to: 5.15 Change-Id: Ife82518808fc5504ec42407e80ed3de89ed4adeb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlListModel: use alignof for alignmentFabian Kosmale2020-11-121-1/+1
| | | | | Change-Id: I1dac3e33289516ec677d6db0d8d7cf1e02addc16 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* ListModel: support URLsFabian Kosmale2020-11-121-3/+93
| | | | | | Fixes: QTBUG-88379 Change-Id: I6e2ea550d8f8972c5fdcdc21a5e3851992c591a5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Fix documentation warnings for QML Models and Test modulesTopi Reinio2020-11-051-1/+1
| | | | | | Fixes: QTBUG-88156 Change-Id: Ie9723f1bb612f4603d15455a0320cc01b27ff181 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* StringOrTranslation::toString: fix string checkFabian Kosmale2020-07-091-2/+3
| | | | | | | | | arrayData can now be null, because shared null for QString has been removed. Instead of checking for arrayData, we now check whether the stringSize is larger than 0. Change-Id: I81e683bb8394ee84b291098add3f62636a697a8d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Compile against latest qtbaseLars Knoll2020-07-091-1/+2
| | | | | | | Adjust to the lastest changes in QList and QString. Change-Id: I216b2746a3305222a21c5aead3aec6106ac1f035 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QVariant::setValue: do not force the template parametersGiuseppe D'Angelo2020-06-171-1/+1
| | | | | Change-Id: I198bfd703efe7ad675e4076d1976f2414816dec5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Store a QV4::ReturnedValue in QJSValueUlf Hermann2020-03-181-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Being careful, we can now save primitive values inline. We use the heap pointer of QV4::Value as either QString* or QV4::Value* for complex types. We cannot store persistent managed QV4::Value without the double indirection as those need to be allocated in a special place. The generic QVariant case is not supported anymore. The only place where it was actually needed were the stream operators for QJSValue. Those were fundamentally broken: * A managed QJSValue saved and loaded from a stream was converted to a QVariant-type QJSValue * QVariant-type QJSValues were not callable, could not be objects or arrays, or any of the special types. * Cyclic references were forcibly broken when saving to a data stream. In general the support for saving and loading of managed types to/from a data stream was so abysmally bad that we don't lose much by dropping it. [ChangeLog][QML][Important Behavior Changes] When saving a QJSValue to a QDataStream only primitive values or strings will be retained. Support for objects and arrays was incomplete and unreliable already before. It cannot work correctly as we don't necessarily have a JavaScript heap when loading a QJSValue from a stream. Therefore, we don't have a proper place to keep any managed values. Using QVariant to keep them instead is a bad idea because QVariant cannot represent everything a QJSValue can contain. Fixes: QTBUG-75174 Change-Id: I75697670639bca8d4b1668763d7020c4cf871bda Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-301-3/+5
|\ | | | | | | Change-Id: I1e1d9585d876a8eacd4c24afc894a33075f51a13
| * Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-291-3/+5
| |\ | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp Change-Id: I133bfd4bd9dd6f704252c956c90f05e8a8a40d6a
| | * V4: Check for exceptions before we use the result of a JS callUlf Hermann2020-01-231-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | If the call resulted in an exception the return value is undefined. Task-number: QTBUG-81581 Change-Id: Ibfdd5e1229cf5437f270232d3b1a91308adeec72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-201-12/+14
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlvaluetype.cpp tests/auto/qml/qml.pro Change-Id: I78f992f83212bb9fd5e09b64163f15f046185224
| * | Replace QVariant::type with QVariant::userTypeOlivier Goffart2020-01-171-12/+14
| |/ | | | | | | | | | | | | | | | | | | | | as type is going to be deprecated. This change was done automatically with the help of clazy. In addition, ColumnRoleMetadata was changed to take an int instead of a QVariant::Type Change-Id: Ibc02d7b52e7d931a56c19fdebc4788b5e6df2a39 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* / Make QtQml work with the latest changes in qtbaseLars Knoll2020-01-141-39/+21
|/ | | | | | | | | | | | Adjust the code to work with the new QString and QVector data structures that have inlined size and data pointers. Fix a large bunch of compiler warnings from QFlags. Update dependencies for qtbase and qtsvg Change-Id: Iba237aed90c140b822e0cf501b9fb7156ec27c2d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Fix documentation warningsTopi Reinio2019-11-111-2/+2
| | | | | | | | | | | | | | | | | | There were a lot of documentation warnings introduced by the separation of QtQml.Models and QtQml.WorkerScript modules from the QtQml documentation project into their own sub-projects. Fix the above, and also ensure that the experimental Qt.labs.qmlmodels QML types are listed in the documentation, and add them also on the QML module page for QtQml.Models. A few warnings remain, they may be indicative of issues not in the scope of this commit. Fixes: QTBUG-79812 Change-Id: Idc25c976e4c96feab4aae893519d6c9245f57a64 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QML ListModel: Emit a warning when adding an object with undefined or null ↵Fabian Kosmale2019-10-101-7/+14
| | | | | | | | | | | | | | | | | | | member The current code in ListModel simply did a reset of an existing property, in case a role existed and was set to null/undefined. If the role did not exist, the code would simply skip over the member and do nothing. However, this does not make any sense for newly inserted items, and most likely indicates a misunderstanding of how ListModel works. Creating an undefined/null role does not really make sense, as those could only ever store a undefined/null value. Change-Id: I4c1361647a82146565eaffe064598c94c748b4f5 Task-number: QTBUG-63569 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlListModel: handle nested list models during iterationFabian Kosmale2019-10-081-1/+11
| | | | | | | | | | | | | | | ListElement::getProperty returns in turn a list model The ModelObjectOwnPropertyKeyIterator should however return the concrete values, and not some proxy object. This would cause funny return values in the best case, and a crash in case of QTBUG-79083. We therefore convert the nested model to a JavaScript array in ModelObjectOwnPropertyKeyIterator::next, which avoids beforementioned issues. Fixes: QTBUG-79083 Change-Id: If038598ff1c3c59090e994aaba5fba94a6964224 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split qqmltypeloader{_p.h|.cpp} into a several filesUlf Hermann2019-07-111-0/+1
| | | | | | | No one can read this mess. Change-Id: Icec4f2afc466435c1ae5e4e80fa2c1b5baf7d087 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move valueAsNumber into ExecutableCompilationUnitUlf Hermann2019-05-131-1/+1
| | | | | | | | | | | This reduces our dependence on QV4::Value in the devtools. Change-Id: I4b3f937bc08c16f7e2543fdc5cc34c0cfb121f8f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split CompiledData::CompilationUnit in twoUlf Hermann2019-05-161-8/+10
| | | | | | | | We need a CompilationUnit that only holds the data needed for compilation and another one that is executable by the runtime. Change-Id: I704d859ba028576a18460f5e3a59f210f64535d3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move model types into their own libraryUlf Hermann2019-05-021-0/+2900
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 <erik.verbruggen@me.com>