mkRPG
src/editor/Game/ItemModels/typeitemmodel.h
Go to the documentation of this file.
00001 #ifndef TYPEITEMMODEL_H
00002 #define TYPEITEMMODEL_H
00003 
00004 
00005 #include <QAbstractItemModel>
00006 #include "../game.h"
00007 
00024 class TypeTreeItem{
00025     enum State{RootItem, BaseItem, TypeItem};
00026 public:
00027     explicit TypeTreeItem(Game *game);
00028     ~TypeTreeItem();
00029 
00030     Qt::ItemFlags flags(int col) const;
00031     QVariant data(int col, int role) const;
00032     TypeTreeItem *parent() const ;
00033     TypeTreeItem *child(int row) const ;
00034     int rowCount() const;
00035     int row() const;
00036     bool setData(int col, QVariant value, int role);
00037 
00038 private:
00039     explicit TypeTreeItem(QString typeName, TypeTreeItem *parent);
00040     explicit TypeTreeItem(GameObjectType *typ, TypeTreeItem *parent);
00041 
00042     TypeTreeItem* findType(const QString &t);
00043 
00044     int rowNb;
00045     State state;
00046     QString typeName;
00047     TypeTreeItem *parentItem;
00048     GameObjectType *type;
00049     QList<TypeTreeItem*> children;
00050 };
00051 
00052 
00053 
00060 class TypeItemModel2 : public QAbstractItemModel
00061 {
00062     Q_OBJECT
00063 public:
00064     explicit TypeItemModel2(QObject *parent = nullptr);
00065 
00066     int columnCount(const QModelIndex &parent) const;
00067     int rowCount(const QModelIndex &parent) const;
00068     Qt::ItemFlags flags(const QModelIndex &index) const;
00069     QVariant data(const QModelIndex &index, int role) const;
00070     QModelIndex index(int row, int column, const QModelIndex &parent) const;
00071     QModelIndex parent(const QModelIndex &child) const;
00072     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
00073     bool setData(const QModelIndex &index, const QVariant &value, int role);
00074 
00075     void setGame(Game* g);
00076 private:
00077     TypeTreeItem *rootItem;
00078 
00079 };
00080 
00081 #endif // TYPEITEMMODEL_H
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Defines