ViewSolutions 1.0.100.30ae2aa
View solutions of qml for quasarapp projects
Loading...
Searching...
No Matches
ViewSolutions::BaseListModel< TYPE > Class Template Reference

The BaseListModel class is the base class of all GUI list models. More...

#include <baselistmodel.h>

Inheritance diagram for ViewSolutions::BaseListModel< TYPE >:
Inheritance graph
Collaboration diagram for ViewSolutions::BaseListModel< TYPE >:
Collaboration graph

Public Member Functions

 BaseListModel (QObject *parent=nullptr)
int rowCount (const QModelIndex &) const override
QHash< int, QByteArray > roleNames () const override
QVariant data (const QModelIndex &index, int role) const override
Q_INVOKABLE void setDataList (const QList< TYPE > &newData)
 setDataList sets new date of model, and reset all model;
Q_INVOKABLE const QList< TYPE > & dateList () const

Additional Inherited Members

Signals inherited from ViewSolutions::__PrvateBaseListModel
void listDateChanged ()
Protected Member Functions inherited from ViewSolutions::__PrvateBaseListModel
 __PrvateBaseListModel (QObject *parent=nullptr)

Detailed Description

template<class TYPE>
class ViewSolutions::BaseListModel< TYPE >

The BaseListModel class is the base class of all GUI list models.

A BaseListModel stores its items in a simple list and exposes them to QML as a list model. The list of all items is also available in QML through the listDate property (see the BASE_LIST_MODEL_DATA_PROPERTY macro).

Template Parameters
TYPE- is main stored delegate model of all list items.

Concepts and usage rules:

  • All models should provide delegate models based on QObject
  • If the model requires a fast solution, just implement a BaseListModel<int> model
Note
To access the delegate model use the Qt::EditRole role: it is available in QML by the delegateModel keyword.

Example of a model based on the BaseListModel:

{
Q_OBJECT
public:
VariantListModel(QObject* ptr = nullptr):
ViewSolutions::BaseListModel<QVariant>(ptr) {}
};
#define BASE_LIST_MODEL_DATA_PROPERTY(Type)
The BaseListModel class is the base class of all GUI list models.
BaseListModel(QObject *parent=nullptr)
The VariantListModel class is universal implementation for all atomic types.
The ViewSolutions namespace.

C++ usage:

QList<QVariant> items;
items << "one" << "two" << "three";
model.setDataList(items);
const QList<QVariant>& values = model.dateList();
Q_INVOKABLE const QList< TYPE > & dateList() const
Q_INVOKABLE void setDataList(const QList< TYPE > &newData)
setDataList sets new date of model, and reset all model;

QML usage (after the model was registered as context property):

ListView {
model: variantListModel
delegate: Text { text: delegateModel }
}

Definition at line 86 of file baselistmodel.h.

Constructor & Destructor Documentation

◆ BaseListModel()

template<class TYPE>
ViewSolutions::BaseListModel< TYPE >::BaseListModel ( QObject * parent = nullptr)
inline

Definition at line 90 of file baselistmodel.h.

Here is the call graph for this function:

Member Function Documentation

◆ data()

template<class TYPE>
QVariant ViewSolutions::BaseListModel< TYPE >::data ( const QModelIndex & index,
int role ) const
inlineoverride

Definition at line 104 of file baselistmodel.h.

◆ dateList()

template<class TYPE>
Q_INVOKABLE const QList< TYPE > & ViewSolutions::BaseListModel< TYPE >::dateList ( ) const
inline

Definition at line 166 of file baselistmodel.h.

◆ roleNames()

template<class TYPE>
QHash< int, QByteArray > ViewSolutions::BaseListModel< TYPE >::roleNames ( ) const
inlineoverride

Definition at line 98 of file baselistmodel.h.

◆ rowCount()

template<class TYPE>
int ViewSolutions::BaseListModel< TYPE >::rowCount ( const QModelIndex & ) const
inlineoverride

Definition at line 94 of file baselistmodel.h.

◆ setDataList()

template<class TYPE>
Q_INVOKABLE void ViewSolutions::BaseListModel< TYPE >::setDataList ( const QList< TYPE > & newData)
inline

setDataList sets new date of model, and reset all model;

Parameters
newData

Definition at line 136 of file baselistmodel.h.

Here is the call graph for this function:

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