entitylist.h
Go to the documentation of this file.
1 #ifndef DNAI_MODELS_GUI_ENTITYLIST_H
2 #define DNAI_MODELS_GUI_ENTITYLIST_H
3 
4 #include <QAbstractListModel>
5 
6 namespace dnai
7 {
8  namespace models
9  {
10  class Entity;
11  namespace gui
12  {
13  class EntityList : public QAbstractListModel
14  {
15  Q_OBJECT
16 
17  public:
18  EntityList(QObject *parent = nullptr) : QAbstractListModel(parent), m_list(nullptr)
19  {
20  }
21  enum Roles {
22  Name = Qt::UserRole + 1,
25  };
26  explicit EntityList(QList<models::Entity*> *);
27  explicit EntityList(const QList<models::Entity*> &);
28  int rowCount(const QModelIndex& parent) const override;
29  QVariant data(const QModelIndex& index, int role) const override;
30  void append(models::Entity *var);
31  void moveUp(int index);
32  void moveDown(int index);
33  void remove(const QString &name);
34 
35  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
36  bool setData(int index, const QVariant& value, int role);
37 
38  private:
39  QList<models::Entity*> *m_list;
40  QHash<int, QByteArray> roleNames() const override;
41 
42  };
43  }
44  }
45 }
46 
47 #endif
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Definition: entitylist.cpp:86
Definition: entitylist.h:22
void append(models::Entity *var)
Definition: entitylist.cpp:41
Roles
Definition: entitylist.h:21
Definition: entitylist.h:13
int rowCount(const QModelIndex &parent) const override
Definition: entitylist.cpp:21
void moveUp(int index)
Definition: entitylist.cpp:49
void moveDown(int index)
Definition: entitylist.cpp:60
Definition: entitylist.h:23
EntityList(QObject *parent=nullptr)
Definition: entitylist.h:18
QVariant data(const QModelIndex &index, int role) const override
Definition: entitylist.cpp:28
Definition: api.h:13
QHash< int, QByteArray > roleNames() const override
Definition: entitylist.cpp:108
Definition: entity.h:71
QList< models::Entity * > * m_list
Definition: entitylist.h:39