oopapidocs  2.0
DataObjectTableModel Class Reference

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>

Collaboration diagram for DataObjectTableModel:

List of all members.

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
DataObjectTableModeloperator<< (QSharedPointer< DataObject > newObj)
 A convenience function for insertRecord.

Protected Member Functions

void extractHeaders (DataObject *hmodel)
 sets the headerModel based on property names/types.

Detailed Description

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.


Constructor & Destructor Documentation

DataObjectTableModel::DataObjectTableModel ( DataObject headerModel = 0,
QObject *  parent = 0 
) [explicit]
Parameters:
headerModel- an example DataObject-derived class with properties defined, used to determine the name/type of the column headers.
See also:
extractHeaders()

Definition at line 7 of file dataobjecttablemodel.cpp.

References extractHeaders().

Here is the call graph for this function:

Deletes all of the contained DataObjects which were added to this model.

Definition at line 32 of file dataobjecttablemodel.cpp.


Member Function Documentation

QVariant DataObjectTableModel::data ( const QModelIndex &  index,
int  role 
) const
Returns:
data at this index.
Parameters:
indexlocation of data
roleif 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().

Here is the call graph for this function:

bool DataObjectTableModel::insertRecord ( QSharedPointer< DataObject newRecord,
int  position = -1,
const QModelIndex &  parent = QModelIndex() 
) [virtual]

Inserts a new record into the table.

Parameters:
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().

Here is the call graph for this function:

QStringList DataObjectTableModel::toStringList ( ) const
Returns:
each DataObject as a toString()

Definition at line 198 of file dataobjecttablemodel.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Enumerations