-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCell.cpp
More file actions
50 lines (41 loc) · 809 Bytes
/
Cell.cpp
File metadata and controls
50 lines (41 loc) · 809 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
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "Cell.hpp"
#include <QPainter>
#include <QGraphicsSceneMouseEvent>
Cell::Cell():QGraphicsObject()
{
}
QRectF Cell::boundingRect() const
{
return QRectF(0,0,50,50);
}
void Cell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->drawRect(0,0,50,50);
switch (m_state) {
case StateX:
painter->drawText(25,25, "X");
break;
case State0:
painter->drawText(25,25, "0");
break;
default:
break;
}
}
void Cell::setState(State stat)
{
if (m_state == stat)
{
return;
}
m_state=stat;
update();
}
void Cell::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
event->accept();
}
void Cell::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
emit clicked(this);
}