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
virtual int type() const
virtual QRectF boundingRect() const
void moveBy(qreal dx, qreal dy)
QList< QGraphicsItem * > items() const
void setRight(qreal x)
void lineDrawn(int)
Emits the index of the closet (undrawn) line when a click is detected.
QGraphicsRectItem * addRect(const QRectF &rect, const QPen &pen, const QBrush &brush)
const T & at(int i) const
void setBackgroundBrush(const QBrush &brush)
QRectF sceneRect() const
qreal top() const
Definition: aicontroller.h:15
QPointF scenePos() const
void hide()
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: gameboardscene.cpp:254
qreal height() const
qreal left() const
void setLeft(qreal x)
int size() const
QGraphicsLineItem * indicatorLine
Moves to show where the next line will be drawn.
Definition: gameboardscene.h:107
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: aicontroller.h:15
qreal bottom() const
void append(const T &value)
const QSize minimumSizeHint() const
The smallest the view can be when 'auto-zoom' is off.
Definition: gameboardscene.cpp:215
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
void setLine(const QLineF &line)
Qt::MouseButton button() const
void setColor(const QColor &color)
void drawLine(int index, const QColor &colour)
Add the line to the scene so it shows up in the view.
Definition: gameboardscene.cpp:82
void setPen(const QPen &pen)
qreal right() const
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
QGraphicsLineItem * addLine(const QLineF &line, const QPen &pen)
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: gameboardscene.cpp:226
void setWidth(int width)
void setBottom(qreal y)
void setTop(qreal y)
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
void update(qreal x, qreal y, qreal w, qreal h)
QLineF lineFromIndex(int index) const
Takes a line-index and returns a QLineF located at that position.
Definition: gameboardscene.cpp:147
void setBrush(const QBrush &brush)
void show()
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
void addItem(QGraphicsItem *item)
void setZValue(qreal z)
bool acceptEvents
This property holds whether mouse events are enabled for this widget.
Definition: gameboardscene.h:121
qreal width() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.