Commit 86f04f58 authored by Alexander Schuch's avatar Alexander Schuch
Browse files

Clean up code.

The method MapScene::displayPlanetInfo(Planet*, QPointF&) is public but is
wrapped by MapScene::displayPlanetInfo(Planet*) already. Make the
"internal" method private and update the calls of it to the public method.
parent a9154f8f
......@@ -170,7 +170,7 @@ void PlanetItem::hoverEnterEvent( QGraphicsSceneHoverEvent * /*event*/ )
void PlanetItem::hoverLeaveEvent( QGraphicsSceneHoverEvent * /*event*/ )
{
m_hovered = false;
m_scene->displayPlanetInfo(NULL, QPoint());
m_scene->displayPlanetInfo(NULL);
update();
}
......@@ -237,7 +237,7 @@ void PlanetInfoItem::setPlanet (Planet *planet)
QString()));
if( m_game->currentPlayer() == planet->player() )
{
int shipsNeeded = 0; // determine hw many ships will be neede by standing orders
int shipsNeeded = 0; // determine how many ships will be needed by standing orders
foreach(AttackFleet* fleet, planet->player()->standingOrders()) {
if(fleet->source == planet)
shipsNeeded += fleet->shipCount();
......
......@@ -152,25 +152,40 @@ void MapScene::drawBackground ( QPainter * painter, const QRectF & /*rect*/ ) {
}
}
void MapScene::displayPlanetInfo (Planet *planet)
void
MapScene::displayPlanetInfo(Planet *planet)
{
if (!planet && m_planetInfoItem) {
m_planetInfoItem->hide();
if (!planet) {
if (m_planetInfoItem) {
m_planetInfoItem->hide();
}
return;
}
if (planet) {
QPointF pos(planet->sector()->coord().y() * getSectorSize() + itemsHorizontalOffset(),
planet->sector()->coord().x() * getSectorSize());
displayPlanetInfo(planet, pos);
}
/**
* @todo Figure out why coord.y and coord.x seem to be used the other way
* around.
*/
QPointF pos(
planet->sector()->coord().y() * getSectorSize() + itemsHorizontalOffset(),
planet->sector()->coord().x() * getSectorSize()
);
displayPlanetInfo(planet, pos);
}
void MapScene::displayPlanetInfo (Planet *planet, const QPointF & pos)
void
MapScene::displayPlanetInfo (Planet *planet, const QPointF &pos)
{
if (!planet) {
if (m_planetInfoItem)
if (m_planetInfoItem) {
m_planetInfoItem->hide();
}
return;
}
......
......@@ -49,8 +49,16 @@ class MapScene: public QGraphicsScene
void selectPlanet(Planet *planet);
void unselectPlanet();
void displayPlanetInfo(Planet *planet, const QPointF & pos);
void displayPlanetInfo(Planet *planet);
/**
* Show planet information box.
*
* @param planet
* planet for which to show planet information or NULL to hide possibly shown
* planet information
*/
void displayPlanetInfo(Planet *planet);
void drawBackground( QPainter * painter, const QRectF & rect );
......@@ -68,7 +76,21 @@ class MapScene: public QGraphicsScene
private slots:
void planetItemSelected (PlanetItem *);
private:
private:
/**
* Show planet information box.
*
* @param planet
* planet for which to show planet information or NULL to hide possibly shown
* planet information
*
* @param pos
* position relative to upper left edge of the board
*/
void displayPlanetInfo(Planet *planet, const QPointF &pos);
Game *m_game;
QSvgRenderer *m_renderer;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment