ViewSolutions
1.0.100.30ae2aa
View solutions of qml for quasarapp projects
Toggle main menu visibility
Loading...
Searching...
No Matches
modelstorage.cpp
Go to the documentation of this file.
1
//#
2
//# Copyright (C) 2020-2025 QuasarApp.
3
//# Distributed under the GPLv3 software license, see the accompanying
4
//# Everyone is permitted to copy and distribute verbatim copies
5
//# of this license document, but changing it is not allowed.
6
//#
7
8
#include "
modelstorage.h
"
9
10
#include <QQmlEngine>
11
12
namespace
ViewSolutions
{
13
14
ModelStorage::ModelStorage
(QQmlEngine *
engine
) {
15
QQmlEngine::setObjectOwnership(
this
, QQmlEngine::CppOwnership);
16
_engine =
engine
;
17
}
18
19
bool
ModelStorage::addModel
(
const
QSharedPointer<iModel> &model) {
20
if
(_storage.contains(model->modelId())) {
21
return
false
;
22
}
23
24
if
(QObject* qobject =
dynamic_cast<
QObject*
>
(model.get())) {
25
QQmlEngine::setObjectOwnership(qobject, QQmlEngine::CppOwnership);
26
}
27
28
_storage[model->modelId()] = model;
29
model->initStorage(sharedFromThis().toWeakRef());
30
31
return
true
;
32
}
33
34
QObject*
ModelStorage::getModel
(
const
QString &modeId)
const
{
35
return
dynamic_cast<
QObject*
>
(_storage.value(modeId).
get
());
36
}
37
38
QQmlEngine *
ModelStorage::engine
()
const
{
39
return
_engine;
40
}
41
}
ViewSolutions::ModelStorage::get
QSharedPointer< Type > get(const QString &modeId) const
get returns a typed shared pointer to the model with the given id.
Definition
modelstorage.h:74
ViewSolutions::ModelStorage::ModelStorage
ModelStorage(QQmlEngine *engine=nullptr)
Definition
modelstorage.cpp:14
ViewSolutions::ModelStorage::engine
QQmlEngine * engine() const
engine returns context qml engine.
Definition
modelstorage.cpp:38
ViewSolutions::ModelStorage::addModel
bool addModel(const QSharedPointer< iModel > &model)
addModel adds new model into storage.
Definition
modelstorage.cpp:19
ViewSolutions::ModelStorage::getModel
Q_INVOKABLE QObject * getModel(const QString &modeId) const
getModel This method isible on The QML and using for gettings required GUI models.
Definition
modelstorage.cpp:34
modelstorage.h
ViewSolutions
The ViewSolutions namespace.
Definition
avatargenerator.cpp:14
ViewSolutions
src
modelstorage.cpp
Generated by
1.18.0