|
mkRPG
|
00001 #ifndef MAPSLISTMODEL_H 00002 #define MAPSLISTMODEL_H 00003 00004 #include <QAbstractListModel> 00005 #include <QAbstractTableModel> 00006 #include "../game.h" 00007 #include "../mappainter.h" 00008 00019 class MapsListModel : public QAbstractListModel 00020 { 00021 Q_OBJECT 00022 public: 00023 explicit MapsListModel(QObject *parent = 0); 00024 explicit MapsListModel(World &w, QObject *parent = 0); 00025 void setWorld(World &w); 00026 int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; 00027 QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; 00028 //Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; 00029 bool insertRows(int row, int count, const QModelIndex &parent) Q_DECL_OVERRIDE; 00030 bool removeRows(int row, int count, const QModelIndex &parent) Q_DECL_OVERRIDE; 00031 00032 00033 public slots: 00034 void update(); 00035 00036 private: 00037 QImage viewOf(Map *m) const; 00038 QList<Map*> maps; // WARNING : à mettre à jour ! 00039 QMap<int, MapPainter*> mps; // WARNING : supprimer les cartes enlevées ! 00040 }; 00041 00042 00047 class CellTypeListModel : public QAbstractListModel 00048 { 00049 Q_OBJECT 00050 public: 00051 explicit CellTypeListModel(QObject *parent = 0); 00052 void setGame(Game *game); 00053 int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; 00054 QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; 00055 Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; 00056 CellType &cellTypeAt(int i) const; 00057 int indexOf(CellType* ct); 00058 00059 private: 00060 void readCellTypes(CellType *ct); 00061 QList<CellType*> cellTypes; 00062 }; 00063 00064 00065 00070 class MapTypeListModel : public QAbstractListModel 00071 { 00072 Q_OBJECT 00073 public: 00074 explicit MapTypeListModel(QObject *parent = 0); 00075 void setGame(Game *game); 00076 int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; 00077 QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; 00078 Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; 00079 MapType &mapTypeAt(int i) const; 00080 int indexOf(MapType* mt); 00081 00082 private: 00083 void readMapTypes(MapType *mt); 00084 QList<MapType*> mapTypes; 00085 }; 00086 00087 00088 #endif // MAPSLISTMODEL_H
1.7.6.1