|
ViewSolutions 1.0.100.30ae2aa
View solutions of qml for quasarapp projects
|
The ListViewModel class provides a QML list model with QObject data. More...
#include <listviewmodel.h>


Public Member Functions | |
| ListViewModel (QObject *ptr=nullptr) | |
| ~ListViewModel () | |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const |
| QVariant | data (const QModelIndex &index, int role) const |
| QHash< int, QByteArray > | roleNames () const |
| void | setExternalSource (const QList< QObject * > *newData) |
| setExternalSource sets a new external data list. The model does not take ownership of the list content. | |
| void | setSource (const QList< QObject * > &newData) |
| setSource sets a new internal data list. The model takes ownership of the list content. | |
| void | addSource (QObject *data) |
| addSource adds one new QObject to the data list. | |
| void | clear (bool fast=false) |
| clear removes all data from the model and deletes the objects of the internal data list. | |
| bool | external () const |
| external returns true if the model uses an external data list. | |
The ListViewModel class provides a QML list model with QObject data.
The model can be filled with an internal list of QObject pointers or with an external list. In the external case the model does not own the data, the data must stay valid while the model is in use.
The model exposes one role: modelData (see ListViewModelRoles::ModelData).
Example:
QML usage:
Definition at line 56 of file listviewmodel.h.
| ViewSolutions::ListViewModel::ListViewModel | ( | QObject * | ptr = nullptr | ) |
Definition at line 11 of file listviewmodel.cpp.
| ViewSolutions::ListViewModel::~ListViewModel | ( | ) |
| void ViewSolutions::ListViewModel::addSource | ( | QObject * | data | ) |
addSource adds one new QObject to the data list.
| data | is the new data object. |
Definition at line 76 of file listviewmodel.cpp.

| void ViewSolutions::ListViewModel::clear | ( | bool | fast = false | ) |
clear removes all data from the model and deletes the objects of the internal data list.
| fast | if true the objects are deleted with deleteLater, otherwise they are deleted directly. |
Definition at line 86 of file listviewmodel.cpp.

| QVariant ViewSolutions::ListViewModel::data | ( | const QModelIndex & | index, |
| int | role ) const |
Definition at line 27 of file listviewmodel.cpp.


| bool ViewSolutions::ListViewModel::external | ( | ) | const |
external returns true if the model uses an external data list.
Definition at line 98 of file listviewmodel.cpp.

| QHash< int, QByteArray > ViewSolutions::ListViewModel::roleNames | ( | ) | const |
Definition at line 39 of file listviewmodel.cpp.
| int ViewSolutions::ListViewModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Definition at line 20 of file listviewmodel.cpp.


| void ViewSolutions::ListViewModel::setExternalSource | ( | const QList< QObject * > * | newData | ) |
setExternalSource sets a new external data list. The model does not take ownership of the list content.
| newData | is pointer to the new external data list. |
Definition at line 46 of file listviewmodel.cpp.

| void ViewSolutions::ListViewModel::setSource | ( | const QList< QObject * > & | newData | ) |
setSource sets a new internal data list. The model takes ownership of the list content.
| newData | is the new internal data list. |
Definition at line 59 of file listviewmodel.cpp.
