ksquares
gameboardscene.cpp
Go to the documentation of this file.
21 GameBoardScene::GameBoardScene(int newWidth, int newHeight, QObject *parent) : QGraphicsScene(parent), width(newWidth), height(newHeight), acceptEvents(true)
104 addRect(QRectF(qreal((index%width)*spacing), qreal((index/width)*spacing), qreal(spacing), qreal(spacing)), QPen(), brush)->setZValue(-1);
176 bool GameBoardScene::isLineAlready(const QList<QGraphicsEllipseItem*> &pointPair) const //TODO does this work?
202 //cout << "itemList.at(i)->scenePos():" << qgraphicsitem_cast<QGraphicsEllipseItem*>(itemList.at(i))->scenePos().x() << "," << qgraphicsitem_cast<QGraphicsEllipseItem*>(itemList.at(i))->scenePos().y() << endl;
205 //if (distMod < (spacing*0.7071)) //there will only ever be either 1 or 2 items that fulfil this [0.7071 ~ 2^(-0.5)]
217 return QSize((width*spacing)+10, (height*spacing)+10); // the +10 is to provide padding and to avoid scrollbars
260 //kDebug() << "mouseEvent->scenePos():" << mouseEvent->scenePos().x() << "," << mouseEvent->scenePos().y();
266 indicatorLine->setLine(QLineF(connectList.at(0)->scenePos(), connectList.at(1)->scenePos())); //where
void acknowledgeMove(int x1, int y1, int x2, int y2)
Definition: gameboardscene.cpp:247
void lineDrawn(int)
Emits the index of the closet (undrawn) line when a click is detected.
Definition: aicontroller.h:15
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: gameboardscene.cpp:254
QGraphicsLineItem * indicatorLine
Moves to show where the next line will be drawn.
Definition: gameboardscene.h:107
Definition: aicontroller.h:15
const QSize minimumSizeHint() const
The smallest the view can be when 'auto-zoom' is off.
Definition: gameboardscene.cpp:215
void drawLine(int index, const QColor &colour)
Add the line to the scene so it shows up in the view.
Definition: gameboardscene.cpp:82
int indexFromPointPair(const QList< QGraphicsEllipseItem * > &pointPair) const
Takes a pair of QGraphicsEllipseItems and finds the index that relates to the line that's between the...
Definition: gameboardscene.cpp:107
void addLineToIndex(const QList< QGraphicsEllipseItem * > &pointPair)
Adds the line to the index for a specified pair of points.
Definition: gameboardscene.cpp:185
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: gameboardscene.cpp:226
GameBoardScene(int newWidth, int newHeight, QObject *parent=0)
Create a new gameboard scene with the appropriate size.
Definition: gameboardscene.cpp:21
QList< QGraphicsEllipseItem * > getTwoNearestPoints(const QPointF &pos) const
Given a single location in the scene, gives the two nearest QGraphicsEllipseItem. ...
Definition: gameboardscene.cpp:194
QLineF lineFromIndex(int index) const
Takes a line-index and returns a QLineF located at that position.
Definition: gameboardscene.cpp:147
bool isLineAlready(const QList< QGraphicsEllipseItem * > &pointPair) const
Given a pair of points, returns whether there is already a line there.
Definition: gameboardscene.cpp:176
void drawSquare(int index, const QColor &colour)
Fill a box to show it is owned be a particular player.
Definition: gameboardscene.cpp:100
bool acceptEvents
This property holds whether mouse events are enabled for this widget.
Definition: gameboardscene.h:121
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:44:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:44:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.