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 2525 2008-04-14 19:35:17Z 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 <QHash> 00021 #include <QMenu> 00022 #include <QObject> 00023 #include <QAction> 00024 #include <QKeyEvent> 00025 #include <QTreeWidget> 00026 #include <QHostAddress> 00027 #include <QMouseEvent> 00028 00029 #include "routerlistitem.h" 00030 00031 00032 class RouterListWidget : public QTreeWidget 00033 { 00034 Q_OBJECT 00035 00036 public: 00037 /** Columns in the list. */ 00038 enum Columns { 00039 StatusColumn = 0, /**< Status column, indicating bandwidth. */ 00040 CountryColumn = 1, /**< Router's country flag. */ 00041 NameColumn = 2, /**< Router's name. */ 00042 00043 }; 00044 00045 /** Default constructor. */ 00046 RouterListWidget(QWidget *parent = 0); 00047 00048 /** Adds a new descriptor the list. */ 00049 void addRouter(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 00056 signals: 00057 /** Emitted when the user selects a router from the list. */ 00058 void routerSelected(RouterDescriptor rd); 00059 /** Emitted when the user selects a router to zoom in on. */ 00060 void zoomToRouter(QString id); 00061 00062 public slots: 00063 /** Clears the list of router items. */ 00064 void clearRouters(); 00065 00066 private slots: 00067 /** Called when the user clicks on an item in the list. */ 00068 void onSelectionChanged(); 00069 /** Called when the user requests a context menu for some router in the 00070 * list. */ 00071 void customContextMenuRequested(const QPoint &pos); 00072 00073 protected: 00074 /** Called when the user presses a key while the list has focus. */ 00075 void keyPressEvent(QKeyEvent *event); 00076 00077 private: 00078 /** Maps a server ID to that server's list item. */ 00079 QHash<QString,RouterListItem*> _idmap; 00080 }; 00081 00082 #endif 00083