Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef DATAMODEL_H
- #define DATAMODEL_H
- #include <QAbstractItemModel>
- #include <QList>
- #include <QMap>
- #include <QModelIndex>
- #include <QObject>
- class StationData;
- namespace DataRole {
- static const int DisplayName = Qt::DisplayRole;
- static const int StationName = Qt::UserRole + 1;
- static const int TransferFunction = Qt::UserRole +1;
- }
- class Station
- {
- public:
- QMap<QString, StationData> data_;
- QString station_id_;
- void printAll() const;
- int id;
- };
- class StationData
- {
- public:
- StationData() : x(3.14159) {}
- StationData(double xx) : x(xx) { }
- double x;
- };
- class DataModel : public QAbstractItemModel
- {
- Q_OBJECT
- public:
- explicit DataModel(QObject *parent = 0);
- virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
- virtual QModelIndex parent(const QModelIndex &child) const;
- virtual int rowCount(const QModelIndex &parent = QModelIndex() ) const;
- virtual int columnCount(const QModelIndex &parent = QModelIndex() ) const;
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- void addItem(const Station &station);
- void printModel();
- signals:
- public slots:
- private:
- QList<Station> stations_;
- };
- //// Example:
- //Station: 001
- // Ex: -2
- // Ey: -3
- // Hx: -100
- // Hy: 100
- // Hz: 200
- //Station: 002
- // Ex: 1
- // Ey: 10
- // Hz: 3.14159
- #endif // DATAMODEL_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement