Merge branch 'crosshair2'
[situare] / src / ui / mapviewscreen.cpp
index bfcd6e5..2a0cc16 100644 (file)
@@ -25,8 +25,7 @@
 #include "panelsidebar.h"
 
 MapViewScreen::MapViewScreen(QWidget *parent)
-   : QWidget(parent),
-     m_autoCenteringEnabled(false)
+   : QWidget(parent)
 {
     MapView *mapView = new MapView(this);
     m_mapEngine = new MapEngine(this);
@@ -69,10 +68,16 @@ MapViewScreen::MapViewScreen(QWidget *parent)
     connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
             friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
 
-    connect(m_zoomButtonPanel->m_zoomInBtn, SIGNAL(clicked()),
+    connect(m_zoomButtonPanel->m_zoomInButton, SIGNAL(clicked()),
             m_mapEngine, SLOT(zoomIn()));
-    connect(m_zoomButtonPanel->m_zoomOutBtn, SIGNAL(clicked()),
+    connect(m_zoomButtonPanel->m_zoomOutButton, SIGNAL(clicked()),
             m_mapEngine, SLOT(zoomOut()));
+    connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)),
+            m_zoomButtonPanel, SLOT(resetButtons()));
+    connect(m_mapEngine, SIGNAL(maxZoomLevelReached()),
+            m_zoomButtonPanel, SLOT(disableZoomInButton()));
+    connect(m_mapEngine, SIGNAL(minZoomLevelReached()),
+            m_zoomButtonPanel, SLOT(disableZoomOutButton()));
 
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
@@ -84,8 +89,15 @@ MapViewScreen::MapViewScreen(QWidget *parent)
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
 
-    connect(m_mapEngine, SIGNAL(mapScrolled()),
-            this, SLOT(locationChanged()));
+    connect(m_mapEngine, SIGNAL(mapScrolledManually()),
+            this, SIGNAL(mapLocationChanged()));
+
+    connect(this, SIGNAL(positionReceived(QPointF,qreal)),
+            m_mapEngine, SLOT(gpsPositionUpdate(QPointF,qreal)));
+    connect(this, SIGNAL(enableAutoCentering(bool)),
+            m_mapEngine, SLOT(setAutoCentering(bool)));
+    connect(this, SIGNAL(gpsEnabled(bool)),
+            m_mapEngine, SLOT(gpsEnabled(bool)));
 
     connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
             this, SLOT(drawOwnLocationCrosshair(int, int)));
@@ -136,29 +148,6 @@ void MapViewScreen::drawOsmLicense(int width, int height)
                         height - m_osmLicense->fontMetrics().height());
 }
 
-void MapViewScreen::locationChanged()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    if (m_autoCenteringEnabled)
-        emit mapLocationChanged();
-}
-
-void MapViewScreen::positionReceived(QPointF position, qreal accuracy)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    if (m_autoCenteringEnabled)
-        m_mapEngine->setViewLocation(position);
-}
-
-void MapViewScreen::enableAutoCentering(bool enabled)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_autoCenteringEnabled = enabled;
-    m_mapEngine->setAutoCentering(enabled);
-}
 
 void MapViewScreen::drawOwnLocationCrosshair(int width, int height)
 {