Vidalia 0.3.1
TorMapWidget.h
Go to the documentation of this file.
1/*
2** This file is part of Vidalia, and is subject to the license terms in the
3** LICENSE file, found in the top level directory of this distribution. If you
4** did not receive the LICENSE file with this file, you may obtain it from the
5** Vidalia source package distributed by the Vidalia Project at
6** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7** including this file, may be copied, modified, propagated, or distributed
8** except according to the terms described in the LICENSE file.
9*/
10
11/*
12** \file TorMapWidget.h
13** \brief Displays Tor servers and circuits on a map of the world
14*/
15
16#ifndef _TORMAPWIDGET_H
17#define _TORMAPWIDGET_H
18
19#include "RouterDescriptor.h"
20#include "GeoIpRecord.h"
21
22#include "Circuit.h"
23#include "Stream.h"
24
25#include <MarbleWidget.h>
26#include <GeoPainter.h>
27#include <GeoDataCoordinates.h>
28#include <GeoDataLineString.h>
29
30#include <QHash>
31#include <QPair>
32#include <QPainterPath>
33
34typedef QPair<Marble::GeoDataLineString, bool> CircuitGeoPath;
35
36
37class TorMapWidget : public Marble::MarbleWidget
38{
39 Q_OBJECT
40
41public:
42 /** Default constructor. */
43 TorMapWidget(QWidget *parent = 0);
44 /** Destructor. */
46
47 /** Plots the given router on the map using the given coordinates. */
48 void addRouter(const RouterDescriptor &desc, const GeoIpRecord &geoip);
49 /** Plots the given circuit on the map. */
50 void addCircuit(const CircuitId &circid, const QStringList &path);
51 /** Selects and hightlights a router on the map. */
52 void selectRouter(const QString &id);
53 /** Selects and highlights a circuit on the map. */
54 void selectCircuit(const CircuitId &circid);
55
56public slots:
57 /** Removes a circuit from the map. */
58 void removeCircuit(const CircuitId &circid);
59 /** Deselects all the highlighted circuits and routers */
60 void deselectAll();
61 /** Clears the known routers and removes all the data from the map */
62 void clear();
63 /** Zooms the map to fit entirely within the constraints of the current
64 * viewport size. */
65 void zoomToFit();
66 /** Zoom to a particular router on the map. */
67 void zoomToRouter(const QString &id);
68 /** Zoom to the circuit on the map with the given <b>circid</b>. */
69 void zoomToCircuit(const CircuitId &circid);
70
71signals:
72 /** Emitted when the user selects a router placemark on the map. <b>id</b>
73 * contain's the selected router's fingerprint. */
74 void displayRouterInfo(const QString &id);
75
76protected:
77 /** Paints the current circuits and streams on the image. */
78 virtual void customPaint(Marble::GeoPainter *painter);
79
80private:
81 /** Stores placemark IDs for Tor routers. */
82 QHash<QString, Marble::GeoDataCoordinates> _routers;
83 /** Stores circuit information */
84 QHash<CircuitId, CircuitGeoPath*> _circuits;
85};
86
87#endif
88
QString CircuitId
Definition: Circuit.h:24
QPair< Marble::GeoDataLineString, bool > CircuitGeoPath
Definition: TorMapWidget.h:34
void removeCircuit(const CircuitId &circid)
void addRouter(const RouterDescriptor &desc, const GeoIpRecord &geoip)
void zoomToRouter(const QString &id)
void selectCircuit(const CircuitId &circid)
virtual void customPaint(Marble::GeoPainter *painter)
void displayRouterInfo(const QString &id)
QHash< CircuitId, CircuitGeoPath * > _circuits
Definition: TorMapWidget.h:84
void deselectAll()
void zoomToCircuit(const CircuitId &circid)
QHash< QString, Marble::GeoDataCoordinates > _routers
Definition: TorMapWidget.h:82
void selectRouter(const QString &id)
void addCircuit(const CircuitId &circid, const QStringList &path)
TorMapWidget(QWidget *parent=0)