[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r3455: Make the "Zoom to Relay" button work again, except make it d (vidalia/branches/marble/src/vidalia/network)



Author: edmanm
Date: 2009-01-18 00:46:55 -0500 (Sun, 18 Jan 2009)
New Revision: 3455

Modified:
   vidalia/branches/marble/src/vidalia/network/tormapwidget.cpp
   vidalia/branches/marble/src/vidalia/network/tormapwidget.h
Log:

Make the "Zoom to Relay" button work again, except make it do the zooming
with a bit more pizzazz this time. Also rename an awkwardly named variable.


Modified: vidalia/branches/marble/src/vidalia/network/tormapwidget.cpp
===================================================================
--- vidalia/branches/marble/src/vidalia/network/tormapwidget.cpp	2009-01-18 02:38:30 UTC (rev 3454)
+++ vidalia/branches/marble/src/vidalia/network/tormapwidget.cpp	2009-01-18 05:46:55 UTC (rev 3455)
@@ -14,9 +14,15 @@
 ** \brief Displays Tor servers and circuits on a map of the world
 */
 
+#include <QPoint>
+#include <QVector>
+#include <QPersistentModelIndex>
 #include <QStringList>
 #include <vidalia.h>
 
+#include <MarbleModel.h>
+#include <MarblePlacemarkModel.h>
+
 #include "tormapwidgetinputhandler.h"
 #include "tormapwidget.h"
 
@@ -34,6 +40,7 @@
   setMapThemeId("earth/srtm/srtm.dgml");
   setShowScaleBar(false);
   setShowCrosshairs(false);
+  setAnimationsEnabled(true);
 
   setCursor(Qt::OpenHandCursor);
   setInputHandler(new TorMapWidgetInputHandler());
@@ -77,8 +84,8 @@
 
   QString id = desc.id();
   addPlaceMarkData(kml, id);
-  _routerPlacemarks.insert(id, GeoDataCoordinates(lon, lat, 0.0,
-                                                  GeoDataCoordinates::Degree));
+  _routers.insert(id, GeoDataCoordinates(lon, lat, 0.0,
+                                         GeoDataCoordinates::Degree));
 }
 
 /** Adds a circuit to the map using the given ordered list of router IDs. */
@@ -100,8 +107,8 @@
     CircuitGeoPath *geoPath = _circuits.value(circid);
 
     QString router = path.at(path.size()-1);
-    if (_routerPlacemarks.contains(router)) {
-      GeoDataCoordinates coords = _routerPlacemarks.value(router);
+    if (_routers.contains(router)) {
+      GeoDataCoordinates coords = _routers.value(router);
       geoPath->first.append(new GeoDataCoordinates(coords));
     }
   } else {
@@ -110,8 +117,8 @@
     geoPath->second = false; /* initially unselected */
 
     foreach (QString router, path) {
-      if (_routerPlacemarks.contains(router)) {
-        GeoDataCoordinates coords = _routerPlacemarks.value(router);
+      if (_routers.contains(router)) {
+        GeoDataCoordinates coords = _routers.value(router);
         geoPath->first.append(new GeoDataCoordinates(coords));
       }      
     }
@@ -184,7 +191,7 @@
 void
 TorMapWidget::clear()
 {
-  foreach (QString id, _routerPlacemarks.keys()) {
+  foreach (QString id, _routers.keys()) {
     removePlaceMarkKey(id);
   }
 
@@ -243,16 +250,14 @@
 void
 TorMapWidget::zoomToRouter(const QString &id)
 {
-#if 0
-  QPair<QPointF,bool> *routerPair;
-  
   if (_routers.contains(id)) {
-    deselectAll();
-    routerPair = _routers.value(id);
-    routerPair->second = true;  /* Set the router point to "selected" */
-    zoom(routerPair->first.toPoint(), 1.0); 
+    qreal lon, lat;
+    GeoDataCoordinates coords = _routers.value(id);
+    coords.geoCoordinates(lon, lat, GeoDataPoint::Degree);
+
+    zoomView(maximumZoom());
+    centerOn(lon, lat, true);
   }
-#endif
 }
 
 /** Paints the current circuits and streams on the image. */
@@ -265,4 +270,3 @@
   }
 }
 
-

Modified: vidalia/branches/marble/src/vidalia/network/tormapwidget.h
===================================================================
--- vidalia/branches/marble/src/vidalia/network/tormapwidget.h	2009-01-18 02:38:30 UTC (rev 3454)
+++ vidalia/branches/marble/src/vidalia/network/tormapwidget.h	2009-01-18 05:46:55 UTC (rev 3455)
@@ -72,7 +72,7 @@
 
 private:
   /** Stores placemark IDs for Tor routers. */
-  QHash<QString, Marble::GeoDataCoordinates> _routerPlacemarks;
+  QHash<QString, Marble::GeoDataCoordinates> _routers;
   /** Stores circuit information */
   QHash<CircuitId, CircuitGeoPath*> _circuits;
 };