{
//qDebug() << __PRETTY_FUNCTION__;
- /// @todo Jussi: convertTi.... returns QPoint
- QPointF topLeft = convertTileNumberToSceneCoordinate(m_zoomLevel, m_viewGrid.topLeft());
- QPointF bottomRight = convertTileNumberToSceneCoordinate(m_zoomLevel, m_viewGrid.bottomRight()
+ /// @todo Jussi: convertTi.... returns QPoint DONE
+ QPoint topLeft = convertTileNumberToSceneCoordinate(m_zoomLevel, m_viewGrid.topLeft());
+ QPoint bottomRight = convertTileNumberToSceneCoordinate(m_zoomLevel, m_viewGrid.bottomRight()
+ QPoint(1, 1));
qreal width = bottomRight.x() - topLeft.x();
qreal height = bottomRight.y() - topLeft.y();
- /// @todo Jussi: insert comments
+ /// @todo Jussi: insert comments DONE
+ //
QList<QGraphicsItem *> viewTiles = m_mapScene->items(topLeft.x(), topLeft.y(), width, height,
Qt::ContainsItemBoundingRect);
QList<QGraphicsItem *> allTiles = m_mapScene->items();
+ //Remove tiles which are in view from allTiles
foreach (QGraphicsItem *tile, viewTiles)
allTiles.removeOne(tile);
- QHashIterator<QString, MapTile *> i(m_mapTilesInScene);
-
- /// @todo Jussi: loop through allTiles and remove from hash also
- while (i.hasNext()) {
- i.next();
- if (allTiles.contains(i.value())) {
- MapTile *tile = i.value();
- removeTile(tile);
- }
+ //Remove tiles out of view
+ foreach (QGraphicsItem *tile, allTiles) {
+ MapTile *tileToRemove = dynamic_cast<MapTile *>(tile);
+ removeTile(tileToRemove);
}
}
getTiles(m_sceneCoordinate);
// remove unused tiles after zooming is done
- QTimer::singleShot(ZOOM_TIME, this, SLOT(removeTilesOutOfView()));
+ QTimer::singleShot(ZOOM_TIME*2, this, SLOT(removeTilesOutOfView()));
}
/// @todo DONE: Sami: return only to end
}