oopapidocs
2.0
|
An example TableModel for a QList<QSharedPointer<DataObject> > This class uses the metaproperties API to extract the header information to display in the table, and contains a QList<DataObject*> for row data. More...
#include <dataobjecttablemodel.h>
Public Slots | |
void | rowChanged (const QString &fileName) |
Mark the corresponding row for this dataobject changed. | |
Public Member Functions | |
DataObjectTableModel (DataObject *headerModel=0, QObject *parent=0) | |
virtual bool | insertRecord (QSharedPointer< DataObject > newRecord, int position=-1, const QModelIndex &=QModelIndex()) |
Inserts a new record into the table. | |
QStringList | toStringList () const |
virtual | ~DataObjectTableModel () |
Deletes all of the contained DataObjects which were added to this model. | |
QVariant | data (const QModelIndex &index, int role) const |
DataObjectTableModel & | operator<< (QSharedPointer< DataObject > newObj) |
A convenience function for insertRecord. | |
Protected Member Functions | |
void | extractHeaders (DataObject *hmodel) |
sets the headerModel based on property names/types. |
An example TableModel for a QList<QSharedPointer<DataObject> > This class uses the metaproperties API to extract the header information to display in the table, and contains a QList<DataObject*> for row data.
Definition at line 20 of file dataobjecttablemodel.h.
DataObjectTableModel::DataObjectTableModel | ( | DataObject * | headerModel = 0 , |
QObject * | parent = 0 |
||
) | [explicit] |
headerModel | - an example DataObject-derived class with properties defined, used to determine the name/type of the column headers. |
Definition at line 7 of file dataobjecttablemodel.cpp.
References extractHeaders().
DataObjectTableModel::~DataObjectTableModel | ( | ) | [virtual] |
Deletes all of the contained DataObjects which were added to this model.
Definition at line 32 of file dataobjecttablemodel.cpp.
QVariant DataObjectTableModel::data | ( | const QModelIndex & | index, |
int | role | ||
) | const |
index | location of data |
role | if Qt::UserRole, then return the objectName of the DataObject at index.row() |
Definition at line 59 of file dataobjecttablemodel.cpp.
void DataObjectTableModel::extractHeaders | ( | DataObject * | hmodel | ) | [protected] |
sets the headerModel based on property names/types.
TODO: Use setRoleNames(roles), a feature added to Qt 4.6, so it works from QML views also.
Definition at line 20 of file dataobjecttablemodel.cpp.
References DataObject::propertyNames().
Referenced by DataObjectTableModel().
bool DataObjectTableModel::insertRecord | ( | QSharedPointer< DataObject > | newRecord, |
int | position = -1 , |
||
const QModelIndex & | parent = QModelIndex() |
||
) | [virtual] |
Inserts a new record into the table.
newRecord | - a DataObject to be interpreted as a row. |
position | - the row number it should be inserted at. If -1, it is appended to the end. |
Definition at line 120 of file dataobjecttablemodel.cpp.
References rowChanged().
QStringList DataObjectTableModel::toStringList | ( | ) | const |
Definition at line 198 of file dataobjecttablemodel.cpp.