Vidalia
0.2.17
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 00007 ** including this file, may be copied, modified, propagated, or distributed 00008 ** except according to the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file RouterListWidget.h 00013 ** \brief Displays a list of Tor servers and their status 00014 */ 00015 00016 #ifndef _ROUTERLISTWIDGET_H 00017 #define _ROUTERLISTWIDGET_H 00018 00019 #include "RouterDescriptor.h" 00020 00021 #include <QHash> 00022 #include <QList> 00023 #include <QMenu> 00024 #include <QObject> 00025 #include <QAction> 00026 #include <QKeyEvent> 00027 #include <QTreeWidget> 00028 #include <QHostAddress> 00029 #include <QMouseEvent> 00030 00031 class RouterListItem; 00032 00033 class RouterListWidget : public QTreeWidget 00034 { 00035 Q_OBJECT 00036 00037 public: 00038 /** Columns in the list. */ 00039 enum Columns { 00040 StatusColumn = 0, /**< Status column, indicating bandwidth. */ 00041 CountryColumn = 1, /**< Router's country flag. */ 00042 NameColumn = 2, /**< Router's name. */ 00043 }; 00044 00045 /** Default constructor. */ 00046 RouterListWidget(QWidget *parent = 0); 00047 00048 /** Adds a new descriptor the list. */ 00049 RouterListItem* addRouter(const RouterDescriptor &rd); 00050 /** Finds the list item whose key ID matches <b>id</b>. Returns 0 if not 00051 * found. */ 00052 RouterListItem* findRouterById(QString id); 00053 /** Deselects all currently selected routers. */ 00054 void deselectAll(); 00055 /** Called when the user changes the UI translation. */ 00056 void retranslateUi(); 00057 00058 signals: 00059 /** Emitted when the user selects a router from the list. */ 00060 void routerSelected(QList<RouterDescriptor> rd); 00061 /** Emitted when the user selects a router to zoom in on. */ 00062 void zoomToRouter(QString id); 00063 00064 public slots: 00065 /** Clears the list of router items. */ 00066 void clearRouters(); 00067 00068 private slots: 00069 /** Called when the user clicks on an item in the list. */ 00070 void onSelectionChanged(); 00071 /** Copies the nicknames for all currently selected relays to the clipboard. 00072 * Nicknames are formatted as a comma-delimited list, suitable for doing 00073 * dumb things with your torrc. */ 00074 void copySelectedNicknames(); 00075 /** Copies the fingerprints for all currently selected relays to the 00076 * clipboard. Fingerprints are formatted as a comma-delimited list, suitable 00077 * for doing dumb things with your torrc. */ 00078 void copySelectedFingerprints(); 00079 /** Emits a zoomToRouter() signal containing the fingerprint of the 00080 * currently selected relay. */ 00081 void zoomToSelectedRelay(); 00082 00083 protected: 00084 /** Called when the user presses a key while the list has focus. */ 00085 void keyPressEvent(QKeyEvent *event); 00086 /** Displays a context menu for the user when they right-click on the 00087 * widget. */ 00088 virtual void contextMenuEvent(QContextMenuEvent *event); 00089 00090 private: 00091 /** Maps a server ID to that server's list item. */ 00092 QHash<QString,RouterListItem*> _idmap; 00093 }; 00094 00095 #endif 00096