examples/tutorials/modelview/5_edit/mymodel.h
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    42 #define MYMODEL_H
    42 #define MYMODEL_H
    43 
    43 
    44 //! [Quoting ModelView Tutorial]
    44 //! [Quoting ModelView Tutorial]
    45 // mymodel.h
    45 // mymodel.h
    46 #include <QAbstractTableModel>
    46 #include <QAbstractTableModel>
    47 #include <QStringList>
    47 #include <QString>
       
    48 
       
    49 const int COLS= 3;
       
    50 const int ROWS= 2;
       
    51 
    48 
    52 
    49 class MyModel : public QAbstractTableModel
    53 class MyModel : public QAbstractTableModel
    50 {
    54 {
    51     Q_OBJECT
    55     Q_OBJECT
    52 public:
    56 public:
    55     int columnCount(const QModelIndex &parent = QModelIndex()) const;
    59     int columnCount(const QModelIndex &parent = QModelIndex()) const;
    56     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    60     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    57     bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
    61     bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
    58     Qt::ItemFlags flags(const QModelIndex & index) const ;
    62     Qt::ItemFlags flags(const QModelIndex & index) const ;
    59 private:
    63 private:
    60     QStringList m_gridData;  //holds text entered into QTableView
    64     QString m_gridData[ROWS][COLS];  //holds text entered into QTableView
    61     int modelIndexToOffset(const QModelIndex & index) const;
       
    62 signals:
    65 signals:
    63     void editCompleted(const QString &);
    66     void editCompleted(const QString &);
    64 };
    67 };
    65 //! [Quoting ModelView Tutorial]
    68 //! [Quoting ModelView Tutorial]
    66 
    69