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

The iModel class is base model for GUI models. Works with ModelStorage. All models after adding can get access to any othe models that located on same storage object. More...

#include <imodel.h>

Inheritance diagram for ViewSolutions::iModel:
Inheritance graph
Collaboration diagram for ViewSolutions::iModel:
Collaboration graph

Public Member Functions

 iModel ()=default
virtual ~iModel ()=default
virtual QString modelId () const =0
 modelId returns text model id. override this method to provide access to model in qml or other models.
const QWeakPointer< ModelStorage > & storage () const
 storage returns storage object. this method return context of the model's storage.
QQmlEngine * engine () const
 engine returns qml engine.

Protected Member Functions

virtual void initStorage (const QWeakPointer< ModelStorage > &newStorage)
 initStorage This method is called by storage object after adding model to storage.

Friends

class ModelStorage

Detailed Description

The iModel class is base model for GUI models. Works with ModelStorage. All models after adding can get access to any othe models that located on same storage object.

To create a new model implement the iModel interface. Every model must provide a unique model id with the modelId method.

Example:

class MyModel: public QObject, public ViewSolutions::iModel
{
Q_OBJECT
public:
explicit MyModel(): QObject() {}
// iModel interface
QString modelId() const override { return "myModel"; }
};
The iModel class is base model for GUI models. Works with ModelStorage. All models after adding can g...
Definition imodel.h:51
virtual QString modelId() const =0
modelId returns text model id. override this method to provide access to model in qml or other models...

Register the model in the model storage:

auto model = QSharedPointer<MyModel>::create();
models->addModel(model); // models is a ViewSolutions::ModelStorage object
// Access another model from inside MyModel:
auto other = storage().lock()->get<MyOtherModel>("otherModel");
const QWeakPointer< ModelStorage > & storage() const
storage returns storage object. this method return context of the model's storage.
Definition imodel.cpp:15

Definition at line 50 of file imodel.h.

Constructor & Destructor Documentation

◆ iModel()

ViewSolutions::iModel::iModel ( )
default

◆ ~iModel()

virtual ViewSolutions::iModel::~iModel ( )
virtualdefault

Member Function Documentation

◆ engine()

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

engine returns qml engine.

Returns
qml engine.
Note
can be return nullptr if the models system initialized without qml engine.
this method convert weak pointer to shared pointer, so you can use it without any restrictions, but it may be slowly then dirrect access.

Definition at line 19 of file imodel.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initStorage()

void ViewSolutions::iModel::initStorage ( const QWeakPointer< ModelStorage > & newStorage)
protectedvirtual

initStorage This method is called by storage object after adding model to storage.

Parameters
newStorageis storage object.

Definition at line 27 of file imodel.cpp.

Here is the caller graph for this function:

◆ modelId()

virtual QString ViewSolutions::iModel::modelId ( ) const
pure virtual

modelId returns text model id. override this method to provide access to model in qml or other models.

Returns
model id.

Implemented in ViewSolutions::iGUITokensModel, ViewSolutions::NotificationService, and ViewSolutions::QMLColorPicker.

Here is the call graph for this function:

◆ storage()

const QWeakPointer< ModelStorage > & ViewSolutions::iModel::storage ( ) const

storage returns storage object. this method return context of the model's storage.

Returns
storage object.

Definition at line 15 of file imodel.cpp.

Here is the caller graph for this function:

◆ ModelStorage

friend class ModelStorage
friend

Definition at line 90 of file imodel.h.


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