-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathgridmodel.h
More file actions
37 lines (27 loc) · 779 Bytes
/
gridmodel.h
File metadata and controls
37 lines (27 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include <QAbstractListModel>
#include <QImage>
#include <QList>
#define GRID_CELL_SIZE 80
struct GridCell
{
QImage image;
QString label;
};
using GridCellList = QList<GridCell>;
class GridModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit GridModel(QObject *parent = nullptr);
~GridModel() override;
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
void setCellList(const GridCellList &cellList);
void clearCells();
void setCellSize(int width, int height);
QSize cellSize() const;
private:
class GridModelPrivate;
QScopedPointer<GridModelPrivate> d_ptr;
};