00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef IMAGEMODEL_H
00031 #define IMAGEMODEL_H
00032
00033 #include <QAbstractTableModel>
00034 #include <QVector>
00035
00036 class Matrix;
00037
00038 class MatrixModel : public QAbstractTableModel
00039 {
00040 Q_OBJECT
00041
00042 public:
00043 MatrixModel(int rows = 32, int cols = 32, QObject *parent = 0);
00044 MatrixModel(const QImage& image, QObject *parent);
00045
00046 Qt::ItemFlags flags( const QModelIndex & index ) const;
00047
00048 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00049 int columnCount(const QModelIndex &parent = QModelIndex()) const;
00050
00051 bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
00052 bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
00053 bool removeColumns ( int column, int count, const QModelIndex & parent = QModelIndex());
00054 bool insertColumns ( int column, int count, const QModelIndex & parent = QModelIndex());
00055
00056 double cell(int row, int col);
00057 void setCell(int row, int col, double val);
00058
00059 QString text(int row, int col);
00060 void setText(int row, int col, const QString&);
00061
00062 QString saveToString();
00063 QImage renderImage();
00064
00065 double data(int row, int col) const;
00066 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00067 bool setData(const QModelIndex & index, const QVariant & value, int role);
00068
00069 double* dataVector(){return d_data.data();};
00070 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00071 void setDataVector(const QVector<double>& data);
00072
00073 private:
00074 int d_rows, d_cols;
00075 QVector<double> d_data;
00076 Matrix *d_matrix;
00077 };
00078
00079 #endif