ViewSolutions
1.0.100.30ae2aa
View solutions of qml for quasarapp projects
Toggle main menu visibility
Loading...
Searching...
No Matches
modelstorage.h
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
#ifndef MODELSTORAGE_H
9
#define MODELSTORAGE_H
10
11
#include "
imodel.h
"
12
13
#include <QHash>
14
#include <QObject>
15
#include <QSharedPointer>
16
17
namespace
ViewSolutions
{
18
45
class
VIEWSOLUTION_EXPORT
ModelStorage
:
public
QObject,
public
QEnableSharedFromThis<ModelStorage>
46
{
47
Q_OBJECT
48
public
:
49
ModelStorage
(QQmlEngine*
engine
=
nullptr
);
50
57
bool
addModel
(
const
QSharedPointer<iModel>& model);
58
64
Q_INVOKABLE QObject*
getModel
(
const
QString& modeId)
const
;
65
73
template
<
class
Type>
74
QSharedPointer<Type>
get
(
const
QString& modeId)
const
{
75
return
_storage.value(modeId).staticCast<Type>();
76
}
77
82
QQmlEngine *engine()
const
;
83
84
private
:
85
QHash<QString, QSharedPointer<iModel>> _storage;
86
QQmlEngine * _engine =
nullptr
;
87
};
88
89
}
90
91
#endif
// MODELSTORAGE_H
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
imodel.h
ViewSolutions
The ViewSolutions namespace.
Definition
avatargenerator.cpp:14
VIEWSOLUTION_EXPORT
#define VIEWSOLUTION_EXPORT
VIEWSOLUTION_EXPORT marks a symbol as part of the public ViewSolutions API.
Definition
viewsolutions_global.h:33
ViewSolutions
src
modelstorage.h
Generated by
1.18.0