| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "qmlcomponentregistry.h" |
| 5 | |
| 6 | #include <utility> |
| 7 | |
| 8 | std::vector<std::function<void()>> const & |
| 9 | QMLComponentRegistry::qmlTypeRegisterers() const |
| 10 | { |
| 11 | return qmlTypeRegisterers_(); |
| 12 | } |
| 13 | |
| 14 | std::unordered_map<std::string, |
| 15 | std::function<QMLItem *(QQmlApplicationEngine &)>> const & |
| 16 | QMLComponentRegistry::qmlItemProviders() const |
| 17 | { |
| 18 | return qmlItemProviders_(); |
| 19 | } |
| 20 | |
| 21 | std::unordered_map<std::string, std::function<QQuickItem *(void)>> const & |
| 22 | QMLComponentRegistry::quickItemProviders() const |
| 23 | { |
| 24 | return quickItemProviders_(); |
| 25 | } |
| 26 | |
| 27 | bool QMLComponentRegistry::addQMLTypeRegisterer(std::function<void()> &®isterer) |
| 28 | { |
| 29 | qmlTypeRegisterers_().emplace_back(std::move(registerer)); |
| 30 | return true; |
| 31 | } |
| 32 | |
| 33 | bool QMLComponentRegistry::addQMLItemProvider( |
| 34 | std::string_view componentID, |
| 35 | std::function<QMLItem *(QQmlApplicationEngine &)> &&provider) |
| 36 | { |
| 37 | qmlItemProviders_().emplace(std::string(componentID), std::move(provider)); |
| 38 | return true; |
| 39 | } |
| 40 | |
| 41 | bool QMLComponentRegistry::addQuickItemProvider( |
| 42 | std::string_view itemID, std::function<QQuickItem *(void)> &&provider) |
| 43 | { |
| 44 | quickItemProviders_().emplace(std::string(itemID), std::move(provider)); |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | std::vector<std::function<void(void)>> &QMLComponentRegistry::qmlTypeRegisterers_() |
| 49 | { |
| 50 | static std::vector<std::function<void(void)>> registerers; |
| 51 | return registerers; |
| 52 | } |
| 53 | |
| 54 | std::unordered_map<std::string, std::function<QMLItem *(QQmlApplicationEngine &)>> & |
| 55 | QMLComponentRegistry::qmlItemProviders_() |
| 56 | { |
| 57 | static std::unordered_map<std::string, |
| 58 | std::function<QMLItem *(QQmlApplicationEngine &)>> |
| 59 | providers; |
| 60 | return providers; |
| 61 | } |
| 62 | |
| 63 | std::unordered_map<std::string, std::function<QQuickItem *(void)>> & |
| 64 | QMLComponentRegistry::quickItemProviders_() |
| 65 | { |
| 66 | static std::unordered_map<std::string, std::function<QQuickItem *(void)>> providers; |
| 67 | return providers; |
| 68 | } |