| Line | Branch | Decision | Call | Exec | Source |
|---|---|---|---|---|---|
| 1 | #ifndef CHRYSALIS_BASEMODEL_H | ||||
| 2 | #define CHRYSALIS_BASEMODEL_H | ||||
| 3 | |||||
| 4 | #include <QMetaType> | ||||
| 5 | #include <QAbstractListModel> | ||||
| 6 | |||||
| 7 | #include "Parameter.h" | ||||
| 8 | |||||
| 9 | ✗ | Q_DECLARE_METATYPE(Chrysalis::Parameter*) | |||
| 10 | |||||
| 11 | namespace CLO3D::UI { | ||||
| 12 | template<typename T> | ||||
| 13 | class BaseModel: public QAbstractListModel { | ||||
| 14 | protected: | ||||
| 15 | ✗ | explicit BaseModel(T* data): data_(data) {} | |||
| 16 | public: | ||||
| 17 | ✗ | int rowCount(const QModelIndex& parent) const override { | |||
| 18 | ✗ | return data_->count(); | |||
| 19 | } | ||||
| 20 | ✗ | QVariant data(const QModelIndex& index, const int role) const override { | |||
| 21 | ✗ | if (role != Qt::UserRole) return {}; | |||
| 22 | ✗ | return QVariant::fromValue((*data_)[index.row()]); | |||
| 23 | } | ||||
| 24 | private: | ||||
| 25 | T* data_; | ||||
| 26 | }; | ||||
| 27 | } | ||||
| 28 | |||||
| 29 | #endif //CHRYSALIS_BASEMODEL_H | ||||
| 30 |