12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /*
- * Copyright (c) 2011 Nokia Corporation.
- */
- #ifndef LEVELMODEL_H
- #define LEVELMODEL_H
- #include <QAbstractListModel>
- #include "leveldata.h"
- /***************************************************************************************************
- *Class representing an item model, used for IAP user interaction. *
- ***************************************************************************************************/
- class LevelModel : public QAbstractListModel
- {
- Q_OBJECT
- public:
- /***********************************************************************************************
- *Custom model roles. *
- ***********************************************************************************************/
- enum LevelRole
- {
- LevelIdRole = Qt::UserRole + 1,
- LevelNameRole,
- LevelPriceRole,
- LevelUnlockedRole,
- LevelShortDescriptionRole,
- LevelLongDescriptionRole,
- LevelType
- };
- /**********************************************************************************************/
- explicit LevelModel(QObject *parent = 0);
- /***********************************************************************************************
- *Standard Qt model view methods. *
- ***********************************************************************************************/
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role);
- Qt::ItemFlags flags(const QModelIndex &index) const;
- bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
- bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
- /**********************************************************************************************/
- /***********************************************************************************************
- *A method used to overwrite the entire model data. *
- ***********************************************************************************************/
- void setModelData(const QList<LevelData>& data);
- /***********************************************************************************************
- *A method used to overwrite/add a single model item. *
- ***********************************************************************************************/
- void setLevelData(const LevelData& data);
- /***********************************************************************************************
- *A method used to retrieve the leveldata withe the given id. *
- ***********************************************************************************************/
- LevelData getById(QString itemId) const;
- private:
- /***********************************************************************************************
- *A simple list representing the models data. *
- ***********************************************************************************************/
- QList<LevelData> modelData;
- };
- #endif // LEVELMODEL_H
|