From 12507ecd4e94cb6f9082bb124f2a3bdf35d3db0b Mon Sep 17 00:00:00 2001 From: Ville Tiensuu Date: Mon, 17 May 2010 16:34:08 +0300 Subject: [PATCH] fixed review issues Reviewed by: Henri Lampela --- src/engine/engine.h | 29 ++++++++++++++--------------- src/map/mapengine.cpp | 7 ++----- src/map/mapengine.h | 35 +++++++++++++++++++++++------------ src/map/mapview.h | 9 +++++++++ src/ui/mainwindow.cpp | 2 +- src/ui/mainwindow.h | 20 ++++++++++---------- src/ui/mapviewscreen.cpp | 26 ++++++++++++++------------ src/ui/mapviewscreen.h | 19 ++++++++++++------- 8 files changed, 85 insertions(+), 62 deletions(-) diff --git a/src/engine/engine.h b/src/engine/engine.h index e3ad2b0..426d1a5 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -61,14 +61,6 @@ public: * MEMBER FUNCTIONS AND SLOTS ******************************************************************************/ public slots: - - /** - * @brief Slot to receive location of crosshair - * - * @param ownLocation (Latitude and Longitude) - */ - void receiveOwnLocation(QPointF ownLocation); - /** * @brief Slot to intercept error signal from ImageFetcher and SituareService * @@ -82,6 +74,13 @@ public slots: void loginOk(); /** + * @brief Slot to receive location of crosshair + * + * @param ownLocation (Latitude and Longitude) + */ + void receiveOwnLocation(QPointF ownLocation); + + /** * @brief Calls reverseGeo from SituareService to translate coordinates to street address * */ @@ -141,13 +140,6 @@ public slots: ******************************************************************************/ signals: /** - * @brief Signals when new user data is ready - * - * @param user Instance of User - */ - void userLocationReady(User *user); - - /** * @brief Signals when new friends data is ready * * @param friendList List of User instances (friends) @@ -160,6 +152,13 @@ signals: */ void requestOwnLocation(); + /** + * @brief Signals when new user data is ready + * + * @param user Instance of User + */ + void userLocationReady(User *user); + /******************************************************************************* * DATA MEMBERS ******************************************************************************/ diff --git a/src/map/mapengine.cpp b/src/map/mapengine.cpp index e11b8d7..03fc198 100644 --- a/src/map/mapengine.cpp +++ b/src/map/mapengine.cpp @@ -378,7 +378,7 @@ QPointF MapEngine::convertSceneCoordinateToLatLon(int zoomLevel, QPoint sceneCoo return QPointF(longitude, latitude); } -QPointF MapEngine::ownLocation() +void MapEngine::ownLocation() { qDebug() << __PRETTY_FUNCTION__; @@ -386,14 +386,11 @@ QPointF MapEngine::ownLocation() QPointF ownLatitudeLongitudeLocation = convertSceneCoordinateToLatLon(m_zoomLevel, m_viewArea.center()); emit ownLocation(ownLatitudeLongitudeLocation); - - return ownLatitudeLongitudeLocation; } -QRect MapEngine::receiveViewSceneRect(QRect viewSceneRect) +void MapEngine::receiveViewSceneRect(QRect viewSceneRect) { qDebug() << __PRETTY_FUNCTION__; m_viewArea = viewSceneRect; - return m_viewArea; } diff --git a/src/map/mapengine.h b/src/map/mapengine.h index 604e824..98516a7 100644 --- a/src/map/mapengine.h +++ b/src/map/mapengine.h @@ -121,6 +121,12 @@ public: */ static QString tilePath(int zoomLevel, int x, int y); + /** + * @brief converts scene coordinates to latitude and longitude + * + * @param current zoom level + * @param sceneCoordinate that will be converted + */ QPointF convertSceneCoordinateToLatLon(int zoomLevel, QPoint sceneCoordinate); public slots: @@ -155,26 +161,24 @@ public slots: void viewResized(const QSize &size); /** - * @brief Slot to catch user own location data + * @brief Returns own location crosshair's latitude and longitude coordinates * - * @param user User info */ - void receiveOwnLocation(User *user); + void ownLocation(); /** - * @brief Returns own location crosshair's latitude and longitude coordinates + * @brief Slot to catch user own location data * - * @return own location + * @param user User info */ - QPointF ownLocation(); + void receiveOwnLocation(User *user); /** * @brief Slot to receive visible area of map scene * - * @ - * @return visible area of map scene + * @param visible area of map scene */ - QRect receiveViewSceneRect(QRect viewSceneRect); + void receiveViewSceneRect(QRect viewSceneRect); private: /** @@ -298,7 +302,16 @@ signals: */ void mapScrolled(); -void requestToGetViewPortContents(); + /** + * @brief Signal request mapView to update view port contents + */ + void requestToGetViewPortContents(); + + /** + * @brief Signal sends location of crosshair + * + * @param ownLocation location of crosshair (Latitude, Longitude) + */ void ownLocation(const QPointF ownLocation); /** @@ -324,9 +337,7 @@ private: QSize m_viewSize; ///< Current view size bool m_zoomedIn; ///< Flag for checking if zoomed in when zoom is finished int m_zoomLevel; ///< Current zoom level - QRect m_viewArea; ///< Visible area of map scene - }; #endif // MAPENGINE_H diff --git a/src/map/mapview.h b/src/map/mapview.h index 99ad531..e6547d9 100644 --- a/src/map/mapview.h +++ b/src/map/mapview.h @@ -111,6 +111,10 @@ public slots: */ void updateViewPortContent(); + /** + * @brief Slot for catching request to get view port contents. + * implementation of this slot sends signal that includes visble area of view port. + */ QRect viewportContent(); private: @@ -162,6 +166,11 @@ signals: */ void viewContentChanged(QPoint viewTopLeft); + /** + * @brief Signal that sends visible area of map scene + * + * @param viewArea visible area of map scene + */ void updateViewContent(QRect viewArea); /** diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index f1063bc..35d23b3 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -121,7 +121,7 @@ void MainWindow::createMenus() connect(m_gpsToggleAct, SIGNAL(toggled(bool)), this, SLOT(gpsToggled(bool))); connect(m_gpsToggleAct, SIGNAL(toggled(bool)), - m_mapViewScreen, SLOT(setOwnLocationCrosshairVisibility(bool))); + m_mapViewScreen, SLOT(setOwnLocationCrosshairVisibility(bool))); m_autoCenteringAct = new QAction(tr("Auto centering"), this); m_autoCenteringAct->setCheckable(true); m_autoCenteringAct->setChecked(true); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 7dd0ad2..c7be87f 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -236,6 +236,11 @@ signals: void friendsLocationsReady(QList &friendsList); /** + * @brief Signal from MapEngine to SituareEngine is travelling here + */ + void ownLocation(QPointF ownLatitudeLongitudeLocation); + + /** * @brief Signal for gps position. * * @param position longitude and latitude values @@ -250,6 +255,11 @@ signals: void refreshUserData(); /** + * @brief Signal from SituareEngine to MapEngine is travelling here + */ + void requestOwnLocation(); + + /** * @brief Signal for requesting reverseGeo from SituareEngine * */ @@ -294,16 +304,6 @@ signals: */ void zoomOutKeyPressed(); - /** - * @brief Signal from SituareEngine to MapEngine is travelling here - */ - void requestOwnLocation(); - - /** - * @brief Signal from MapEngine to SituareEngine is travelling here - */ - void ownLocation(QPointF ownLatitudeLongitudeLocation); - /******************************************************************************* * DATA MEMBERS ******************************************************************************/ diff --git a/src/ui/mapviewscreen.cpp b/src/ui/mapviewscreen.cpp index d4aa294..bfcd6e5 100644 --- a/src/ui/mapviewscreen.cpp +++ b/src/ui/mapviewscreen.cpp @@ -38,13 +38,9 @@ MapViewScreen::MapViewScreen(QWidget *parent) PanelSideBar *friendsListPanelSidebar = new PanelSideBar(this, RIGHT); m_zoomButtonPanel = new ZoomButtonPanel(this, ZOOM_BUTTON_PANEL_POSITION_X, - ZOOM_BUTTON_PANEL_POSITION_Y); + ZOOM_BUTTON_PANEL_POSITION_Y); - ownLocationCrosshair = new QLabel(this); - QPixmap crosshairImage(":/res/images/sight.png"); - ownLocationCrosshair->setPixmap(crosshairImage); - ownLocationCrosshair->setFixedSize(crosshairImage.size()); - ownLocationCrosshair->hide(); + m_ownLocationCrosshair = 0; connect(mapView, SIGNAL(viewScrolled(QPoint)), m_mapEngine, SLOT(setLocation(QPoint))); @@ -54,8 +50,6 @@ MapViewScreen::MapViewScreen(QWidget *parent) mapView, SLOT(setZoomLevel(int))); connect(mapView, SIGNAL(viewResized(QSize)), m_mapEngine, SLOT(viewResized(QSize))); -// connect(mapView, SIGNAL(viewContentChanged(QRect)), -// m_mapEngine, SLOT(alignImmovableItems(QRect))); connect(mapView, SIGNAL(updateViewContent(QRect)), m_mapEngine, SLOT(receiveViewSceneRect(QRect))); connect(mapView, SIGNAL(viewZoomFinished()), @@ -171,21 +165,29 @@ void MapViewScreen::drawOwnLocationCrosshair(int width, int height) qDebug() << __PRETTY_FUNCTION__; if (m_drawOwnLocationCrosshair) { - ownLocationCrosshair->move(width/2 - ownLocationCrosshair->pixmap()->width()/2, - height/2 - ownLocationCrosshair->pixmap()->height()/2); + m_ownLocationCrosshair->move(width/2 - m_ownLocationCrosshair->pixmap()->width()/2, + height/2 - m_ownLocationCrosshair->pixmap()->height()/2); } } void MapViewScreen::setOwnLocationCrosshairVisibility(bool visibility) { if (visibility == false) { - ownLocationCrosshair->show(); + + if (m_ownLocationCrosshair == 0) { + m_ownLocationCrosshair = new QLabel(this); + QPixmap crosshairImage(":/res/images/sight.png"); + m_ownLocationCrosshair->setPixmap(crosshairImage); + m_ownLocationCrosshair->setFixedSize(crosshairImage.size()); + } + + m_ownLocationCrosshair->show(); m_drawOwnLocationCrosshair = true; drawOwnLocationCrosshair(m_viewPortWidth, m_viewPortHeight); } else { - ownLocationCrosshair->hide(); + m_ownLocationCrosshair->hide(); m_drawOwnLocationCrosshair = false; } } diff --git a/src/ui/mapviewscreen.h b/src/ui/mapviewscreen.h index c918851..533072d 100644 --- a/src/ui/mapviewscreen.h +++ b/src/ui/mapviewscreen.h @@ -50,7 +50,12 @@ public: /******************************************************************************* * MEMBER FUNCTIONS AND SLOTS ******************************************************************************/ -public slots: +public slots: + /** + * @brief Slot for setting own location crosshair visibility + * + * @param visibility false <-> show, true <-> hide + */ void setOwnLocationCrosshairVisibility(bool visibility); private slots: @@ -88,7 +93,7 @@ private slots: * @param width Width of the viewport * @param height Height of the viewport */ - void setViewPortSize(const int width, const int height); // rename: storeviewportsize + void setViewPortSize(const int width, const int height); /** * @brief Slot for GPS position. @@ -117,14 +122,14 @@ signals: void mapLocationChanged(); /** - * @brief Signal from SituareEngine to MapEngine is travelling here + * @brief Signal from MapEngine to SituareEngine is travelling here */ - void requestOwnLocation(); + void ownLocation(QPointF ownLatitudeLongitudeLocation); /** - * @brief Signal from MapEngine to SituareEngine is travelling here + * @brief Signal from SituareEngine to MapEngine is travelling here */ - void ownLocation(QPointF ownLatitudeLongitudeLocation); + void requestOwnLocation(); /** * @brief Signal when user location is fetched @@ -153,7 +158,7 @@ private: ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel QLabel *m_osmLicense; ///< Label for Open Street Map license bool m_autoCenteringEnabled; ///< Enable - QLabel *ownLocationCrosshair; ///< Label that show ownLocationCrosshair + QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not int m_viewPortWidth; ///< Width of view port int m_viewPortHeight; ///< Height of view port -- 1.7.9.5