Vidalia 0.3.1
RouterListWidget.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 RouterListWidget.h
13** \brief Displays a list of Tor servers and their status
14*/
15
16#ifndef _ROUTERLISTWIDGET_H
17#define _ROUTERLISTWIDGET_H
18
19#include "RouterDescriptor.h"
20
21#include <QHash>
22#include <QList>
23#include <QMenu>
24#include <QObject>
25#include <QAction>
26#include <QKeyEvent>
27#include <QTreeWidget>
28#include <QHostAddress>
29#include <QMouseEvent>
30
31class RouterListItem;
32
33class RouterListWidget : public QTreeWidget
34{
35 Q_OBJECT
36
37public:
38 /** Columns in the list. */
39 enum Columns {
40 StatusColumn = 0, /**< Status column, indicating bandwidth. */
41 CountryColumn = 1, /**< Router's country flag. */
42 NameColumn = 2, /**< Router's name. */
43 };
44
45 /** Default constructor. */
46 RouterListWidget(QWidget *parent = 0);
47
48 /** Adds a new descriptor the list. */
50 /** Finds the list item whose key ID matches <b>id</b>. Returns 0 if not
51 * found. */
52 RouterListItem* findRouterById(QString id);
53 /** Deselects all currently selected routers. */
54 void deselectAll();
55 /** Called when the user changes the UI translation. */
56 void retranslateUi();
57 /** Selects the following router whose name starts by routerNickname. */
58 void searchNextRouter(const QString routerNickname);
59
60signals:
61 /** Emitted when the user selects a router from the list. */
62 void routerSelected(QList<RouterDescriptor> rd);
63 /** Emitted when the user selects a router to zoom in on. */
64 void zoomToRouter(QString id);
65
66public slots:
67 /** Clears the list of router items. */
68 void clearRouters();
69 /** Called when the search of a router is triggered by the signal
70 * textChanged from the search field. */
71 void onRouterSearch(const QString routerNickname);
72
73private slots:
74 /** Called when the user clicks on an item in the list. */
75 void onSelectionChanged();
76 /** Copies the nicknames for all currently selected relays to the clipboard.
77 * Nicknames are formatted as a comma-delimited list, suitable for doing
78 * dumb things with your torrc. */
80 /** Copies the fingerprints for all currently selected relays to the
81 * clipboard. Fingerprints are formatted as a comma-delimited list, suitable
82 * for doing dumb things with your torrc. */
84 /** Emits a zoomToRouter() signal containing the fingerprint of the
85 * currently selected relay. */
87
88protected:
89 /** Called when the user presses a key while the list has focus. */
90 void keyPressEvent(QKeyEvent *event);
91 /** Displays a context menu for the user when they right-click on the
92 * widget. */
93 virtual void contextMenuEvent(QContextMenuEvent *event);
94
95private:
96 /** Maps a server ID to that server's list item. */
97 QHash<QString,RouterListItem*> _idmap;
98};
99
100#endif
101
void onRouterSearch(const QString routerNickname)
void routerSelected(QList< RouterDescriptor > rd)
void keyPressEvent(QKeyEvent *event)
QHash< QString, RouterListItem * > _idmap
RouterListItem * addRouter(const RouterDescriptor &rd)
RouterListItem * findRouterById(QString id)
virtual void contextMenuEvent(QContextMenuEvent *event)
RouterListWidget(QWidget *parent=0)
void searchNextRouter(const QString routerNickname)
void zoomToRouter(QString id)