Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://astro.uni-altai.ru/~aw/stellarium/api/classPropertyBasedTableModel.html
Дата изменения: Unknown Дата индексирования: Fri Feb 28 07:52:57 2014 Кодировка: Поисковые слова: earth's atmosphere |
![]() |
Stellarium 0.12.3
|
This class provides a table model for just about any QObject. More...
#include <PropertyBasedTableModel.hpp>
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) |
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).
Definition at line 35 of file PropertyBasedTableModel.hpp.
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.
content | the 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. |
model | an 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. |
mappings | mas an integer positional index to the property. |