| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/qmlcomponentfactory.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "qmlcomponentfactory.h"cxx . . $ `<file>/src/core/qmlcomponentfactory.h`/ |
| 5 | |
| 6 | #include "qmlcomponentregistry.h"cxx . . $ `<file>/src/core/qmlcomponentregistry.h`/ |
| 7 | #include "qmlitem.h"cxx . . $ `<file>/src/core/qmlitem.h`/ |
| 8 | #include <QQmlApplicationEngine> |
| 9 | #include <QQmlEngine> |
| 10 | #include <QQuickItem> |
| 11 | #include <QString> |
| 12 | #include <utility> |
| 13 | |
| 14 | QMLComponentFactorycxx . . $ QMLComponentFactory#::QMLComponentFactorycxx . . $ QMLComponentFactory#QMLComponentFactory(e8462a2bf8d64ffc).( |
| 15 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IQMLComponentRegistrycxx . . $ IQMLComponentRegistry#> &&qmlComponentRegistry) noexcept |
| 16 | : qmlComponentRegistry_cxx . . $ QMLComponentFactory#qmlComponentRegistry_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(qmlComponentRegistry)) |
| 17 | { |
| 18 | } |
| 19 | |
| 20 | void QMLComponentFactorycxx . . $ QMLComponentFactory#::registerQMLTypescxx . . $ QMLComponentFactory#registerQMLTypes(83f5f38750778ac8).() const |
| 21 | { |
| 22 | auto const &qmlTypeRegisterers = qmlComponentRegistry_cxx . . $ QMLComponentFactory#qmlComponentRegistry_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).qmlTypeRegistererscxx . . $ IQMLComponentRegistry#qmlTypeRegisterers(d58a39ac34c07e90).(); |
| 23 | for (auto const &qmlTypeRegisterer : qmlTypeRegisterers) |
| 24 | qmlTypeRegisterer(cxx . . $ std/function#`operator()`(39e0826ffb540481).); |
| 25 | } |
| 26 | |
| 27 | QMLItemcxx . . $ QMLItem# *QMLComponentFactorycxx . . $ QMLComponentFactory#::createQMLItemcxx . . $ QMLComponentFactory#createQMLItem(308271eb1161825f).(stdcxx . . $ std/::stringcxx . . $ std/string# const &itemID, |
| 28 | QQuickItemcxx . . $ QQuickItem# *parent, |
| 29 | QQmlApplicationEnginecxx . . $ QQmlApplicationEngine# &qmlEngine) const |
| 30 | { |
| 31 | auto &qmlItemProviders = qmlComponentRegistry_cxx . . $ QMLComponentFactory#qmlComponentRegistry_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).qmlItemProviderscxx . . $ IQMLComponentRegistry#qmlItemProviders(f255daa6b8e24c63).(); |
| 32 | auto const providerIt = qmlItemProviders.findcxx . . $ std/unordered_map#find(f39fe4bedfa7a693).(itemID); |
| 33 | if (providerIt != qmlItemProviders.cendcxx . . $ std/unordered_map#cend(f3c6e12ee1fe7252).()) { |
| 34 | auto item = providerIt->cxx . . $ std/__detail/_Node_const_iterator#`operator->`(8e614c7de0b1573e).secondcxx . . $ std/pair#second.(cxx . . $ std/function#`operator()`(39e0826ffb540481).qmlEngine); |
| 35 | QQmlEnginecxx . . $ QQmlEngine#::setObjectOwnershipcxx . . $ QJSEngine#setObjectOwnership(eb7177570cb17b31).(item, QQmlEnginecxx . . $ QQmlEngine#::CppOwnershipcxx . . $ QJSEngine#CppOwnership.); |
| 36 | |
| 37 | auto parentName = parent->objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).(); |
| 38 | if (!parentName.containscxx . . $ QString#contains(8cce4688c16f48f3).(QMLItemcxx . . $ QString#QString(85c52e162fed56f9).::ParentObjectSuffixcxx . . $ QMLItem#ParentObjectSuffix..datacxx . . $ std/basic_string_view#data(8e614c7de0b1573e).())) |
| 39 | parentName.appendcxx . . $ QString#append(d02845eef0c33901).(QMLItemcxx . . $ QMLItem#::ParentObjectSuffixcxx . . $ QMLItem#ParentObjectSuffix..datacxx . . $ std/basic_string_view#data(8e614c7de0b1573e).()); |
| 40 | |
| 41 | parentItemcxx . . $ QMLComponentFactory#parentItem(68d7ab0ff596b04d).(item, parent, parentName.toStdStringcxx . . $ QString#toStdString(219584694fe2b248).()); |
| 42 | |
| 43 | return item; |
| 44 | } |
| 45 | |
| 46 | return nullptr; |
| 47 | } |
| 48 | |
| 49 | QQuickItemcxx . . $ QQuickItem# * |
| 50 | QMLComponentFactorycxx . . $ QMLComponentFactory#::createQuickItemcxx . . $ QMLComponentFactory#createQuickItem(60769b42a50f5a21).(stdcxx . . $ std/::stringcxx . . $ std/string# const &itemID, |
| 51 | QQuickItemcxx . . $ QQuickItem# *parent, |
| 52 | stdcxx . . $ std/::stringcxx . . $ std/string# const &parentObjectName) const |
| 53 | { |
| 54 | auto quickItemProviders = qmlComponentRegistry_cxx . . $ std/unordered_map#unordered_map(d1702721d56b98b0).->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).quickItemProviderscxx . . $ IQMLComponentRegistry#quickItemProviders(73a8d04f826783bd).(); |
| 55 | auto providerIt = quickItemProviders.findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(itemID); |
| 56 | if (providerIt != quickItemProviders.cendcxx . . $ std/unordered_map#cend(f3c6e12ee1fe7252).()) { |
| 57 | auto item = providerIt->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second.(cxx . . $ std/function#`operator()`(39e0826ffb540481).); |
| 58 | QQmlEnginecxx . . $ QQmlEngine#::setObjectOwnershipcxx . . $ QJSEngine#setObjectOwnership(eb7177570cb17b31).(item, QQmlEnginecxx . . $ QQmlEngine#::CppOwnershipcxx . . $ QJSEngine#CppOwnership.); |
| 59 | parentItemcxx . . $ QMLComponentFactory#parentItem(68d7ab0ff596b04d).(item, parent, parentObjectName); |
| 60 | |
| 61 | return item; |
| 62 | } |
| 63 | |
| 64 | return nullptr; |
| 65 | } |
| 66 | |
| 67 | void QMLComponentFactorycxx . . $ QMLComponentFactory#::parentItemcxx . . $ QMLComponentFactory#parentItem(68d7ab0ff596b04d).(QQuickItemcxx . . $ QQuickItem# *item, QQuickItemcxx . . $ QQuickItem# *parent, |
| 68 | stdcxx . . $ std/::string_viewcxx . . $ std/string_view# parentObjectName) const |
| 69 | { |
| 70 | QQuickItemcxx . . $ QQuickItem# *parentItem = parent; |
| 71 | if (parent->objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).() != parentObjectName.datacxx . . $ std/basic_string_view#data(8e614c7de0b1573e).()) { |
| 72 | parentItem = parent->findChildcxx . . $ QObject#findChild(8f4dc8480f36c61a).<QQuickItemcxx . . $ QQuickItem# *>(parentObjectNamecxx . . $ QAnyStringView#QAnyStringView(80d8335016fb1bdc)..datacxx . . $ std/basic_string_view#data(8e614c7de0b1573e).()); |
| 73 | if (parentItem == nullptr) |
| 74 | parentItem = parent; |
| 75 | } |
| 76 | item->setParentItemcxx . . $ QQuickItem#setParentItem(28aa4acb8f529eea).(parentItem); |
| 77 | item->setParentcxx . . $ QObject#setParent(749de1b6ae65bddd).(parentItem); |
| 78 | } |