PropertyBasedTableModel.hpp   PropertyBasedTableModel.hpp 
#ifndef PROPERTYBASEDTABLEMODEL_H #ifndef PROPERTYBASEDTABLEMODEL_H
#define PROPERTYBASEDTABLEMODEL_H #define PROPERTYBASEDTABLEMODEL_H
#include <QAbstractTableModel> #include <QAbstractTableModel>
//! This class provides a table model for just about any QObject. It it ni
ce, 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 prope
rties (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 t
o know the ordering of the properties to
//! their position (as you want them displayed).
//!
//! @author Timothy Reaves <treaves@silverfieldstech.com>
//! @ref http://doc.qt.nokia.com/latest/properties.html
class PropertyBasedTableModel : public QAbstractTableModel class PropertyBasedTableModel : public QAbstractTableModel
{ {
Q_OBJECT Q_OBJECT
public: public:
PropertyBasedTableModel(QObject *parent = 0); PropertyBasedTableModel(QObject *parent = 0);
virtual ~PropertyBasedTableModel(); virtual ~PropertyBasedTableModel();
//! Initializes this instance for use. If you do not call this meth
od, and use this class, your app will crash.
//! @param content the domain objects you want to model. They shoul
d all be the same type. This isnstance does not
//! take ownership of content, or the elements i
n it.
//! @param model an instance of the same type as in content, this in
stance is used to create new instances of your
//! domain objects by calling the model objects
copy constructor. This instance takes ownership of model.
//! @param mappings mas an integer positional index to the property.
void init(QList<QObject *>* content, QObject *model, QMap<int, QStri ng> mappings); void init(QList<QObject *>* content, QObject *model, QMap<int, QStri ng> mappings);
//Over-rides from QAbstractTableModel //Over-rides from QAbstractTableModel
virtual QVariant data(const QModelIndex &item, int role = Qt::Displa yRole) const; virtual QVariant data(const QModelIndex &item, int role = Qt::Displa yRole) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) cons t; virtual int rowCount(const QModelIndex &parent = QModelIndex()) cons t;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) c onst; virtual int columnCount(const QModelIndex &parent = QModelIndex()) c onst;
virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool insertRows(int position, int rows, const QModelIndex &i ndex=QModelIndex()); virtual bool insertRows(int position, int rows, const QModelIndex &i ndex=QModelIndex());
 End of changes. 2 change blocks. 
0 lines changed or deleted 28 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/