#ifndef HASKELL_MODEL_H #define HASKELL_MODEL_H #include "interface.h" #include #include struct HaskellModelDelegate { HaskellModelCallbacks* callbacks; QHash roles; }; class HaskellModel : public QAbstractTableModel { Q_OBJECT Q_PROPERTY(int delegate READ delegate WRITE setDelegate) public: HaskellModel(QObject* parent = 0); ~HaskellModel(); int rowCount(const QModelIndex &) const; int columnCount(const QModelIndex &) const; QVariant data(const QModelIndex &, int) const; QVariant headerData(int, Qt::Orientation, int); int delegate() const; void setDelegate(int); int instance(); QHash roleNames() const; Q_INVOKABLE QModelIndex refresh() { emit dataChanged(index(0,0), index(rowCount(QModelIndex())-1, columnCount(QModelIndex())-1)); }; private: int32_t delegateHandle; /* static */ public: static HaskellModelDelegateHandle registerDelegate(); static void unregisterDelegate(HaskellModelDelegateHandle); static void setCallbacks(HaskellModelDelegateHandle, HaskellModelCallbacks*); static void addRole(HaskellModelDelegateHandle, int, char*); private: static std::vector delegates; }; #endif