-
Notifications
You must be signed in to change notification settings - Fork 1
/
Hole.h
56 lines (41 loc) · 1.14 KB
/
Hole.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
48
49
50
51
52
53
54
55
56
#ifndef HOLE_H
#define HOLE_H
#include <QObject>
#include <QPushButton>
class Hole : public QPushButton {
Q_OBJECT
Q_PROPERTY(int row READ row WRITE setRow)
Q_PROPERTY(int col READ col WRITE setCol)
Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(bool marked READ isMarked WRITE setMarked NOTIFY markedChanged)
public:
enum State {
EmptyState,
WhiteState,
BlackState
};
Q_ENUM(State)
explicit Hole(QWidget *parent = nullptr);
virtual ~Hole();
int row() const { return m_row; }
void setRow(int row) { m_row = row; }
int col() const { return m_col; }
void setCol(int col) { m_col = col; }
State state() const { return m_state; }
void setState(State State);
bool isMarked() const { return m_marked; }
void setMarked(bool marked);
public slots:
void reset();
signals:
void stateChanged(Hole::State State);
void markedChanged(bool marked);
private:
int m_row, m_col;
State m_state;
bool m_marked;
static QPixmap stateToPixmap(State state);
private slots:
void updateHole();
};
#endif // HOLE_H