oopapidocs  2.0
dataobjecttablemodel.h
00001 #ifndef DATAOBJECTTABLEMODEL_H
00002 #define DATAOBJECTTABLEMODEL_H
00003 
00004 #include <QSharedPointer>
00005 #include <QAbstractTableModel>
00006 #include <QVariant>
00007 #include <QModelIndex>
00008 #include <QStringList>
00009 #include <QTimer>
00010 using namespace Qt;
00011 
00012 #include "dataobject.h"
00013 
00019 //start id=dotm
00020 class DOBJS_EXPORT DataObjectTableModel : public QAbstractTableModel {
00021     Q_OBJECT
00022   public:
00029     explicit DataObjectTableModel(DataObject* headerModel = 0, 
00030                                   QObject* parent=0);
00031 
00038     virtual bool insertRecord(QSharedPointer<DataObject> newRecord,
00039                               int position = -1,
00040                               const QModelIndex& = QModelIndex());
00041 
00045     QStringList toStringList() const;
00046 
00047     QString toString() const;
00048 
00049     virtual int fieldIndex(const QString& fieldName) const;
00050 
00053     virtual ~DataObjectTableModel();
00054 //end
00055 //start id=abstract
00056     /* Methods which are required to be overridden
00057        because of QAbstractTableModel */
00058     int rowCount(const QModelIndex& parent = QModelIndex()) const;
00059     int columnCount(const QModelIndex& parent = QModelIndex()) const;
00060 
00066     QVariant data(const QModelIndex& index, int role) const;
00067     QVariant headerData(int section,
00068                         Qt::Orientation orientation = Qt::Horizontal,
00069                         int role = DisplayRole) const;
00070     ItemFlags flags(const QModelIndex& index) const;
00071     bool setData(const QModelIndex& index, const QVariant& value,
00072                  int role = EditRole);
00073     bool insertRows(int position, int rows,
00074                     const QModelIndex& index = QModelIndex());
00075     bool removeRows(int position, int rows,
00076                     const QModelIndex& index = QModelIndex());
00077 //end
00078     virtual int findRow(const QString& name);
00079 //start id=dotm
00080   public slots:
00081     void clear();
00083     void rowChanged(const QString& fileName);
00084 
00085   protected:
00086     QList<QSharedPointer<DataObject> > m_Data;
00087     QList<bool> m_isEditable;
00088     QStringList m_Headers;
00089     DataObject* m_Original;
00094     void extractHeaders(DataObject* hmodel);
00095   public:
00096 
00099     DataObjectTableModel& operator<<(QSharedPointer<DataObject> newObj) {
00100         insertRecord(newObj);
00101         return *this;
00102     }
00103 };
00104 //end
00105 #endif
00106 
 All Classes Namespaces Functions Enumerations