-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathacespot.cpp
78 lines (70 loc) · 1.99 KB
/
acespot.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
73
74
75
76
77
78
/*
* This file is part of Freecell.
*
* Freecell is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Freecell is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Freecell. If not, see <http://www.gnu.org/licenses/>.
*/
#include "acespot.h"
#include "board.h"
#include "cardwidget.h"
#include "cardspotproxy.h"
#include <QLabel>
/*!
* \brief Constructor
* \param board The board
*/
AceSpot::AceSpot(Board* board) : CardSpot(board)
{
mProxy = new CardSpotProxy(this);
mProxy->setData(0, QVariant("acespot"));
QLabel* widget = new QLabel();
widget->resize(CardWidget::WIDTH, CardWidget::HEIGHT);
widget->setStyleSheet("background-color:#00FF00;border:1px solid black;color:#00AA00;");
widget->setText("A");
widget->setAlignment(Qt::AlignCenter);
QFont font = widget->font();
font.setPixelSize(CardWidget::HEIGHT * 0.4);
widget->setFont(font);
mProxy->setWidget(widget);
mBoard->addItem(mProxy);
}
/*!
* \brief Check if a card can be stacked on this spot
* \param card The card to check
* \return boolean
*/
bool AceSpot::canStackCard(Card* card)
{
if (CardSpot::canStackCard(card) && card->getValue() == ACE) {
return true;
}
return false;
}
/*!
* \brief Check if the cards can be stacked one after another on this spot
* \return boolean
*/
bool AceSpot::isStackable()
{
return true;
}
/*!
* \brief Set a new card as child of this spot
* \param card The card
*/
void AceSpot::setChild(Card* card)
{
CardSpot::setChild(card);
if (card) {
card->setOnAceSpot(true);
}
}