1
/* *************************************************************************
2
* Copyright 2012 Jakob Gruber <jakob.gruber@gmail.com> *
4
* This program is free software: you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation, either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
16
************************************************************************* */
22
#include <QGraphicsPixmapItem>
24
#include "reloadableitem.h"
25
#include "src/logic/picmi.h"
30
class CellItem : public QGraphicsPixmapItem, public ReloadableItem
33
CellItem(int x, int y, QSharedPointer<Picmi> game, QGraphicsItem *parent = 0);
35
/* updates displayed pixmap according to current cell state */
36
virtual void refresh();
38
virtual void reload(const QSize &size);
41
virtual int getTilesize() const = 0;
42
virtual QPixmap getPixmap() const = 0;
44
const QSharedPointer<Picmi> m_game;
47
class OverviewCellItem : public CellItem
50
/* creates the item with field coordinates (x,y) and the specified
52
OverviewCellItem(int x, int y, QSharedPointer<Picmi> game, QGraphicsItem *parent = 0);
55
virtual int getTilesize() const;
56
virtual QPixmap getPixmap() const;
59
class GameCellItem : public CellItem
62
/* creates the item with field coordinates (x,y) and the specified
64
GameCellItem(int x, int y, QSharedPointer<Picmi> game, Scene *scene, QGraphicsItem *parent = 0);
66
void keyPressEvent(QKeyEvent *event);
69
void mousePressEvent(QGraphicsSceneMouseEvent *event);
70
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
71
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
72
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
74
virtual int getTilesize() const;
75
virtual QPixmap getPixmap() const;
79
int drag_offset(int pos) const;
83
QSharedPointer<DragManager> m_dragmanager;
84
Qt::MouseButton m_dragbutton;