Merge branch 'master' into settings_auto_update
[situare] / src / map / gpslocationitem.cpp
index 55019eb..2585513 100644 (file)
@@ -19,8 +19,6 @@
     USA.
 */
 
-const int ACCURATE_LIMIT = 250; // this and lower values (in meters) are considered as accurate
-
 #include <QDebug>
 #include <QGraphicsPixmapItem>
 
@@ -42,20 +40,37 @@ GPSLocationItem::GPSLocationItem()
     setFlag(QGraphicsItem::ItemIgnoresTransformations);
 }
 
+void GPSLocationItem::setEnabled(bool enable)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (enable) {
+        show();
+    }
+    else {
+        m_currentAccuracy = NOT_SET;
+        hide();
+        setPixmap(QPixmap());
+    }
+
+}
+
 void GPSLocationItem::updatePosition(QPoint scenePosition, qreal accuracy)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     setPos(scenePosition);
 
-    if (accuracy != GPS_ACCURACY_UNDEFINED  // accuracy must be defined
-        && accuracy <= ACCURATE_LIMIT       // and smaller than limit
-        && m_currentAccuracy != ACCURATE) { // and accurate pixmap not yet set
+    if (accuracy == GPS_ACCURACY_UNDEFINED) { // fix is NOT accurate
+        if (m_currentAccuracy != COARSE) { // coarse pixmap not yet set
+            setPixmap(m_coarsePixmap);
+            m_currentAccuracy = COARSE;
+        }
+    }
+    else { // fix is accurate
+        if (m_currentAccuracy != ACCURATE) { // accurate pixmap not yet set
             setPixmap(m_accuratePixmap);
             m_currentAccuracy = ACCURATE;
-    }
-    else if (m_currentAccuracy != COARSE) { // coarse pixmap not yet set
-        setPixmap(m_coarsePixmap);
-        m_currentAccuracy = COARSE;
+        }
     }
 }