Advertisement
Guest User

Untitled

a guest
Jan 12th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef PLAYBOARDMODEL_H
  2. #define PLAYBOARDMODEL_H
  3. #include <QAbstractListModel>
  4. #include <QStringList>
  5.  
  6. class Tile
  7. {
  8. public:
  9.     Tile(int index, const int value);
  10.  
  11.     int index() const;
  12.     int value() const;
  13.  
  14. private:
  15.     int m_index;
  16.     int m_value;
  17. };
  18.  
  19. class PlayBoardModel : public QAbstractListModel
  20. {
  21.     Q_OBJECT
  22. public:
  23.     enum TileRoles {
  24.         IndexRole = Qt::UserRole + 1,
  25.         ValueRole
  26.     };
  27.  
  28.     PlayBoardModel(QObject *parent = 0);
  29.  
  30.     void appendTile(const Tile &tile);
  31.     void shufflePlayBoard();
  32.  
  33.     int rowCount(const QModelIndex & parent = QModelIndex()) const;
  34.  
  35.     QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
  36.  
  37. protected:
  38.     QHash<int, QByteArray> roleNames() const;
  39.  
  40. private:
  41.     QList<Tile> m_tiles;
  42. };
  43.  
  44. #endif // PLAYBOARDMODEL_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement