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