[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r1309: Add a context menu for items in the server list, with an opt (in trunk/src/gui: network res res/16x16)
Author: edmanm
Date: 2006-10-07 19:47:01 -0400 (Sat, 07 Oct 2006)
New Revision: 1309
Added:
trunk/src/gui/res/16x16/zoom.png
Modified:
trunk/src/gui/network/netviewer.cpp
trunk/src/gui/network/routerlistwidget.cpp
trunk/src/gui/network/routerlistwidget.h
trunk/src/gui/network/tormapwidget.cpp
trunk/src/gui/network/tormapwidget.h
trunk/src/gui/res/vidalia_common.qrc
Log:
Add a context menu for items in the server list, with an option to zoom in to
the selected server. Finishes the other half of Ticket #176, minus the pony and
the exclude nodes business.
Modified: trunk/src/gui/network/netviewer.cpp
===================================================================
--- trunk/src/gui/network/netviewer.cpp 2006-10-07 18:51:57 UTC (rev 1308)
+++ trunk/src/gui/network/netviewer.cpp 2006-10-07 23:47:01 UTC (rev 1309)
@@ -98,7 +98,9 @@
connect(ui.actionHelp, SIGNAL(triggered()), this, SLOT(help()));
connect(ui.actionRefresh, SIGNAL(triggered()), this, SLOT(refresh()));
connect(ui.treeRouterList, SIGNAL(routerSelected(RouterDescriptor)),
- this, SLOT(routerSelected(RouterDescriptor)));
+ this, SLOT(routerSelected(RouterDescriptor)));
+ connect(ui.treeRouterList, SIGNAL(zoomToRouter(QString)),
+ _map, SLOT(zoomToRouter(QString)));
connect(ui.treeCircuitList, SIGNAL(circuitSelected(Circuit)),
this, SLOT(circuitSelected(Circuit)));
connect(ui.treeCircuitList, SIGNAL(circuitRemoved(quint64)),
Modified: trunk/src/gui/network/routerlistwidget.cpp
===================================================================
--- trunk/src/gui/network/routerlistwidget.cpp 2006-10-07 18:51:57 UTC (rev 1308)
+++ trunk/src/gui/network/routerlistwidget.cpp 2006-10-07 23:47:01 UTC (rev 1309)
@@ -30,7 +30,9 @@
#include "routerlistwidget.h"
+#define IMG_ZOOM ":/images/16x16/zoom.png"
+
RouterListWidget::RouterListWidget(QWidget *parent)
: QTreeWidget(parent)
{
@@ -46,8 +48,36 @@
/* Find out when the selected item has changed. */
connect(this, SIGNAL(itemSelectionChanged()),
this, SLOT(onSelectionChanged()));
+
+ /* Set up the router item context menu */
+ _routerContextMenu = new QMenu(this);
+ _zoomToRouterAct = new QAction(QIcon(IMG_ZOOM), tr("Zoom to Server"), this);
+ _routerContextMenu->addAction(_zoomToRouterAct);
}
+/** Called when the user presses and releases a mouse button. If the event
+ * indicates a right-click on a router item, a context menu will be displayed
+ * providing a list of actions, including zooming in on the server. */
+void
+RouterListWidget::mouseReleaseEvent(QMouseEvent *e)
+{
+ if (e->button() == Qt::RightButton) {
+ /* Find out which server was right-clicked */
+ RouterListItem *item = (RouterListItem *)itemAt(e->pos());
+ if (!item) {
+ return;
+ }
+
+ /* Display a context menu for this router item */
+ QPoint pos = e->globalPos();
+ QAction *action = _routerContextMenu->exec(pos);
+ if (action == _zoomToRouterAct) {
+ /* Zoom in on this router */
+ emit zoomToRouter(item->id());
+ }
+ }
+}
+
/** Deselects all currently selected routers. */
void
RouterListWidget::deselectAll()
Modified: trunk/src/gui/network/routerlistwidget.h
===================================================================
--- trunk/src/gui/network/routerlistwidget.h 2006-10-07 18:51:57 UTC (rev 1308)
+++ trunk/src/gui/network/routerlistwidget.h 2006-10-07 23:47:01 UTC (rev 1309)
@@ -28,11 +28,14 @@
#ifndef _ROUTERLISTWIDGET_H
#define _ROUTERLISTWIDGET_H
+#include <QHash>
+#include <QMenu>
#include <QObject>
-#include <QHash>
+#include <QAction>
+#include <QKeyEvent>
#include <QTreeWidget>
#include <QHostAddress>
-#include <QKeyEvent>
+#include <QMouseEvent>
#include "routerlistitem.h"
@@ -69,12 +72,18 @@
void deselectAll();
signals:
- /** Called when the user selects a router from the list. */
+ /** Emitted when the user selects a router from the list. */
void routerSelected(RouterDescriptor rd);
-
+ /** Emitted when the user selects a router to zoom in on. */
+ void zoomToRouter(QString id);
+
public slots:
/** Clears the list of router items. */
void clearRouters();
+
+protected:
+ /** Called when the user presses and releases a moust button. */
+ virtual void mouseReleaseEvent(QMouseEvent *e);
private slots:
/** Called when the user clicks on an item in the list. */
@@ -90,6 +99,10 @@
/** Maps a server ID to that server's list item. */
QHash<QString,RouterListItem*> _idmap;
+
+ /** Router item context menu and items. */
+ QMenu* _routerContextMenu; /**< Context menu for router items. */
+ QAction* _zoomToRouterAct; /**< Zooms in on the selected router. */
};
#endif
Modified: trunk/src/gui/network/tormapwidget.cpp
===================================================================
--- trunk/src/gui/network/tormapwidget.cpp 2006-10-07 18:51:57 UTC (rev 1308)
+++ trunk/src/gui/network/tormapwidget.cpp 2006-10-07 23:47:01 UTC (rev 1309)
@@ -284,6 +284,20 @@
}
}
+/** Zooms in on the router with the given <b>id</b>. */
+void
+TorMapWidget::zoomToRouter(QString id)
+{
+ 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);
+ }
+}
+
/** Computes a bounding box around all currently displayed circuit paths on
* the map. */
QRectF
Modified: trunk/src/gui/network/tormapwidget.h
===================================================================
--- trunk/src/gui/network/tormapwidget.h 2006-10-07 18:51:57 UTC (rev 1308)
+++ trunk/src/gui/network/tormapwidget.h 2006-10-07 23:47:01 UTC (rev 1309)
@@ -66,11 +66,13 @@
void clear();
/** Zooms to fit all currently displayed circuits on the map. */
void zoomToFit();
-
+ /** Zoom to a particular router on the map. */
+ void zoomToRouter(QString id);
+
protected:
/** Paints the current circuits and streams on the image. */
virtual void paintImage(QPainter *painter);
-
+
private:
/** Converts world space coordinates into map space coordinates */
QPointF toMapSpace(float latitude, float longitude);
Added: trunk/src/gui/res/16x16/zoom.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/gui/res/16x16/zoom.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/gui/res/vidalia_common.qrc
===================================================================
--- trunk/src/gui/res/vidalia_common.qrc 2006-10-07 18:51:57 UTC (rev 1308)
+++ trunk/src/gui/res/vidalia_common.qrc 2006-10-07 23:47:01 UTC (rev 1309)
@@ -24,6 +24,7 @@
<file>16x16/tor-off.png</file>
<file>16x16/tor-on.png</file>
<file>16x16/utilities-system-monitor.png</file>
+ <file>16x16/zoom.png</file>
</qresource>
<qresource prefix="/images">
<file>22x22/edit-clear.png</file>