ViewSolutions 1.0.100.30ae2aa
View solutions of qml for quasarapp projects
Loading...
Searching...
No Matches
ViewSolutions::ModelStorage Class Reference

The ModelStorage class is the main model storage object. More...

#include <modelstorage.h>

Inheritance diagram for ViewSolutions::ModelStorage:
Inheritance graph
Collaboration diagram for ViewSolutions::ModelStorage:
Collaboration graph

Public Member Functions

 ModelStorage (QQmlEngine *engine=nullptr)
bool addModel (const QSharedPointer< iModel > &model)
 addModel adds new model into storage.
Q_INVOKABLE QObject * getModel (const QString &modeId) const
 getModel This method isible on The QML and using for gettings required GUI models.
template<class Type>
QSharedPointer< Type > get (const QString &modeId) const
 get returns a typed shared pointer to the model with the given id.
QQmlEngine * engine () const
 engine returns context qml engine.

Detailed Description

The ModelStorage class is the main model storage object.

It provides access to all models in the application. Models that are added to the storage get access to the QML engine and can find any other model that is located in the same storage.

Example:

auto models = QSharedPointer<ViewSolutions::ModelStorage>::create(&engine);
auto notify = QSharedPointer<ViewSolutions::NotificationService>::create();
models->addModel(notify);
// Access a model from C++:
auto service = models->get<ViewSolutions::NotificationService>("NotificationService");
QQmlEngine * engine() const
engine returns context qml engine.
The NotificationService class. This class used for working with notify.

In QML the storage is available as the modelsStorage context property (set by ViewSolutions::init):

Item {
property var picker: modelsStorage.getModel("ColorPicker")
}

Definition at line 45 of file modelstorage.h.

Constructor & Destructor Documentation

◆ ModelStorage()

ViewSolutions::ModelStorage::ModelStorage ( QQmlEngine * engine = nullptr)

Definition at line 14 of file modelstorage.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addModel()

bool ViewSolutions::ModelStorage::addModel ( const QSharedPointer< iModel > & model)

addModel adds new model into storage.

Parameters
modelis model object.
Returns
true if model added succesfful, if model alredy exists or model is invalid return false.
Note
All valid models should be inherited from QObject, and inited using a QSharedPointer::create() method.

Definition at line 19 of file modelstorage.cpp.

◆ engine()

QQmlEngine * ViewSolutions::ModelStorage::engine ( ) const

engine returns context qml engine.

Returns
qml engine.

Definition at line 38 of file modelstorage.cpp.

Here is the caller graph for this function:

◆ get()

template<class Type>
QSharedPointer< Type > ViewSolutions::ModelStorage::get ( const QString & modeId) const
inline

get returns a typed shared pointer to the model with the given id.

Template Parameters
Typeis the expected type of the model.
Parameters
modeIdis the id of the required model.
Returns
shared pointer to the model, nullptr if the model does not exist or does not match the expected type.

Definition at line 74 of file modelstorage.h.

Here is the caller graph for this function:

◆ getModel()

QObject * ViewSolutions::ModelStorage::getModel ( const QString & modeId) const

getModel This method isible on The QML and using for gettings required GUI models.

Parameters
modeIdThis is id of required model.
Returns
model raw pointer.

Definition at line 34 of file modelstorage.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: