1/*
2 Copyright 2007 Dmitry Suzdalev <dimsuz@gmail.com>
3 Copyright 2010 Brian Croom <brian.s.croom@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20#include "borderitem.h"
21
22QHash<KMinesState::BorderElement, QString> BorderItem::s_elementNames;
23
24BorderItem::BorderItem( KGameRenderer* renderer, QGraphicsItem* parent )
25 : KGameRenderedItem(renderer, QLatin1String( "" ), parent), m_element(KMinesState::BorderEast),
26 m_row(-1), m_col(-1)
27{
28 if(s_elementNames.isEmpty())
29 fillNameHash();
30 setShapeMode(BoundingRectShape);
31}
32
33void BorderItem::updatePixmap()
34{
35 setSpriteKey(s_elementNames[m_element]);
36}
37
38void BorderItem::fillNameHash()
39{
40 s_elementNames[KMinesState::BorderNorth] = QLatin1String( "border.edge.north" );
41 s_elementNames[KMinesState::BorderSouth] = QLatin1String( "border.edge.south" );
42 s_elementNames[KMinesState::BorderEast] = QLatin1String( "border.edge.east" );
43 s_elementNames[KMinesState::BorderWest] = QLatin1String( "border.edge.west" );
44 s_elementNames[KMinesState::BorderCornerNE] = QLatin1String( "border.outsideCorner.ne" );
45 s_elementNames[KMinesState::BorderCornerNW] = QLatin1String( "border.outsideCorner.nw" );
46 s_elementNames[KMinesState::BorderCornerSW] = QLatin1String( "border.outsideCorner.sw" );
47 s_elementNames[KMinesState::BorderCornerSE] = QLatin1String( "border.outsideCorner.se" );
48}
49