-
Notifications
You must be signed in to change notification settings - Fork 0
/
Field.cpp
71 lines (61 loc) · 1.39 KB
/
Field.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "Field.h"
#include "Data.h"
#include <QPixmap>
#include <QPainter>
Field::Field(QColor color, int row, int column) :
QLabel()
{
this->setFixedSize(Data::WIDTH_FIELD, Data::HEIGTH_FIELD);
internColor = color;
this->row = row;
this->column = column;
isFree = true;
isClicked = false;
tile = 0;
if (internColor == Qt::black){
QPixmap blackPixmap(":/images/black.bmp");
this->setPixmap(blackPixmap);
} else if (internColor == Qt::white){
QPixmap whitePixmap(":/images/white.bmp");
this->setPixmap(whitePixmap);
}
//connect(this, SIGNAL(clicked()), this , SLOT(changePixmap()));
}
void Field::mousePressEvent(QMouseEvent *ev){
if (ev->button() == Qt::LeftButton){
emit clicked();
}
}
/*void Field::selectMe(){
if(internColor == Qt::black){
this->isClicked = true;
}
}*/
void Field::renewBlackColor(){
QPixmap blackPixmap(":/images/black.bmp");
this->setPixmap(blackPixmap);
}
bool Field::getIsFree(){
return this->isFree;
}
bool Field::getIsClicked(){
return isClicked;
}
int Field::getRow(){
return row;
}
int Field::getColumn(){
return column;
}
QColor Field::getInternColor(){
return internColor;
}
void Field::setTile(Tile* newTile){
this->tile = newTile;
}
void Field::setFree(bool b){
this->isFree = b;
}
Tile* Field::getTile() const{
return tile;
}