-
Notifications
You must be signed in to change notification settings - Fork 3
/
cardtemp.cpp
74 lines (62 loc) · 1.21 KB
/
cardtemp.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
72
#include "cardtemp.h"
#include <QPainter>
#include "constant.h"
#include <QColor>
#include <QGraphicsSceneEvent>
#include <QWidget>
#include <QMimeData>
CardTemp::CardTemp()
{
card = NULL;
setData(GD_Type,EMPTY);
}
CardTemp::~CardTemp()
{
if(this->card != NULL)
{
card->setVisible(false);
}
this->card = NULL;
}
QRectF CardTemp::boundingRect() const
{
QRectF bound = QRectF(-3,-3,CARD_WIDTH+3,CARD_HEIGHT+3);
return bound;
}
void CardTemp::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->save();
painter->setPen(QPen(QColor(211,211,211),6));
painter->drawRect(0,0,CARD_WIDTH,CARD_HEIGHT);
painter->restore();
}
QPainterPath CardTemp::shape() const
{
QPainterPath path;
path.addRect(-3,-3,CARD_WIDTH+3,CARD_HEIGHT+3);
return path;
}
Card *CardTemp::getCard()
{
return card;
}
void CardTemp::setFull()
{
this->setData(GD_Type,FULL);
}
void CardTemp::setEmpty()
{
this->setData(GD_Type,EMPTY);
card = NULL;
}
bool CardTemp::isEmpty()
{
return this->data(GD_Type) == EMPTY;
}
void CardTemp::pushCard(Card *card)
{
this->card = card;
setFull();
}