Chrysalis - CLO3D Extensions
Loading...
Searching...
No Matches
BaseListModel.h
Go to the documentation of this file.
1#ifndef CHRYSALIS_BASEMODEL_H
2#define CHRYSALIS_BASEMODEL_H
3
4#include <QMetaType>
5#include <QAbstractListModel>
6
7#include "Parameter.h"
8
9Q_DECLARE_METATYPE(Chrysalis::Parameter*)
10
11namespace 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
int rowCount(const QModelIndex &parent) const override
Definition BaseListModel.h:17
QVariant data(const QModelIndex &index, const int role) const override
Definition BaseListModel.h:20
BaseModel(T *data)
Definition BaseListModel.h:15
Definition BaseCommandArgumentsWidget.h:10