Stellarium 0.15.2
List of all members | Public Member Functions
PropertyBasedTableModel Class Reference

This class provides a table model for just about any QObject. More...

#include <PropertyBasedTableModel.hpp>

+ Inheritance diagram for PropertyBasedTableModel:
+ Collaboration diagram for PropertyBasedTableModel:

Public Member Functions

 PropertyBasedTableModel (QObject *parent=0)
 
void init (QList< QObject * > *content, QObject *model, QMap< int, QString > mappings)
 Initializes this instance for use. More...
 
virtual QVariant data (const QModelIndex &item, int role=Qt::DisplayRole) const
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const
 
virtual bool insertRows (int position, int rows, const QModelIndex &index=QModelIndex())
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 
virtual bool removeRows (int position, int rows, const QModelIndex &index=QModelIndex())
 
void moveRowUp (int position)
 
void moveRowDown (int position)
 

Detailed Description

This class provides a table model for just about any QObject.

It it nice, as a table model implementation per class is not required. It does this by using the Qt meta object system.

To use this class, your domain objects basically just need to use properties (for any properties you want to make available to the model), and have a Q_INVOKABLE copy constructor. Then, when you instantiate an instance, you must call the init methd. The init method takes the data to model, as well as an instance of your model class (to use as a model for creating new instances), and a map to know the ordering of the properties to their position (as you want them displayed).

Author
Timothy Reaves treav.nosp@m.es@s.nosp@m.ilver.nosp@m.fiel.nosp@m.dstec.nosp@m.h.co.nosp@m.m http://doc.qt.nokia.com/latest/properties.html

Definition at line 36 of file PropertyBasedTableModel.hpp.

Member Function Documentation

void PropertyBasedTableModel::init ( QList< QObject * > *  content,
QObject *  model,
QMap< int, QString >  mappings 
)

Initializes this instance for use.

If you do not call this method, and use this class, your app will crash.

Parameters
contentthe domain objects you want to model. They should all be the same type. This isnstance does not take ownership of content, or the elements in it.
modelan instance of the same type as in content, this instance is used to create new instances of your domain objects by calling the model objects copy constructor. This instance takes ownership of model.
mappingsmas an integer positional index to the property.

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