-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgriditem.h
47 lines (36 loc) · 1.07 KB
/
griditem.h
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
38
39
40
41
42
43
44
45
46
47
#ifndef GRIDITEM_H
#define GRIDITEM_H
#include <QGraphicsItem>
#include <QObject>
#include <QPainter>
#include "cell.h"
typedef QVector<QVector<Cell>> qmatrix;
typedef QVector<Cell> qrow;
class GridItem : public QGraphicsItem
{
Q_PROPERTY(int rows READ getRows WRITE setRows)
Q_PROPERTY(int cols READ getCols WRITE setCols)
int _rows;
int _cols;
int _defaultWidth;
int _defaultHeight;
qmatrix _grid;
public:
explicit GridItem(int row = 0, int cols = 0, QGraphicsItem *parent = 0);
~GridItem();
QPainterPath shape() const override;
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
int getRows() {return _rows;}
int getCols() {return _cols;}
void setRows(int r);
void setCols(int c);
QMap<int, int> fixedCells(int row);
void createNewGrid();
qmatrix *getGrid() {return &_grid;};
Cell *getCell(int row, int col) {return &_grid[row][col];};
private:
void compose();
void defaultFrame();
};
#endif // GRIDITEM_H