#ifndef WAVEMODEL_H #define WAVEMODEL_H #include #include #include "../loader.h" class WavePartModel : public QAbstractTableModel { Q_OBJECT public: explicit WavePartModel(QHash &waves, QObject *parent = 0); int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent) const {return 2;} //bool insertRows(int row, int count, const QModelIndex &parent); bool removeRows(int row, int count, const QModelIndex &parent); QVariant data(const QModelIndex &index, int role) const; // void refresh(QList &anims); Qt::ItemFlags flags(const QModelIndex &index) const {Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable; if (index.column()==1) f = f | Qt::ItemIsEditable; return f;} bool setData(const QModelIndex &index, const QVariant &value, int role); QVariant headerData(int section, Qt::Orientation orientation, int role) const; // QStringList waveList(); public slots: //void setLevel(int level) {this->level = level; dataChanged(index(0,0),index(rowCount()-1,1));} void setCurrentWave(QModelIndex = QModelIndex(), QModelIndex b = QModelIndex()); void insertAlien(int alId); void removeAlien(QModelIndex index); void clearAliens(); void addWave() {int i=0; while(waves.contains(i)) i++; tbWave w; w.id=i; w.prise=0; w.timeout=10; waves.insert(w.id,w); setCurrentWave(index(waves.size()-1,0));} void updateIndex(); private: QHash &waves; int curWave; //int level; }; class WaveModel : public QAbstractTableModel { Q_OBJECT public: explicit WaveModel(QHash &waves, QObject *parent = 0); int rowCount(const QModelIndex &parent = QModelIndex()) const {return waves.size();} int columnCount(const QModelIndex &parent = QModelIndex()) const {return 4;} //bool insertRows(int row, int count, const QModelIndex &parent); //bool removeRows(int row, int count, const QModelIndex &parent); QVariant data(const QModelIndex &index, int role) const; Qt::ItemFlags flags(const QModelIndex &index) const {Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable; if (index.column()==1||index.column()==2) f = f | Qt::ItemIsEditable; return f;} bool setData(const QModelIndex &index, const QVariant &value, int role); QVariant headerData(int section, Qt::Orientation orientation, int role) const; public slots: void addWave(QModelIndex a); void copyWave(QModelIndex a); void removeWave(QModelIndex a); void upWave(QModelIndex a); void downWave(QModelIndex a); void refreshData(bool inverse = false); private: QHash &waves; QList values; signals: void needUpdateIndex(); }; #endif // WAVEMODEL_H