Vidalia
0.2.15
|
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 CircuitListWidget.h 00013 ** \brief Collection of Tor circuits as CircuitItems 00014 */ 00015 00016 #ifndef _CIRCUITLISTWIDGET_H 00017 #define _CIRCUITLISTWIDGET_H 00018 00019 #include "CircuitItem.h" 00020 #include "StreamItem.h" 00021 00022 #include <QTreeWidget> 00023 #include <QList> 00024 #include <QMenu> 00025 #include <QAction> 00026 #include <QMouseEvent> 00027 00028 00029 class CircuitListWidget : public QTreeWidget 00030 { 00031 Q_OBJECT 00032 00033 public: 00034 /** Circuit list columns. */ 00035 enum Columns { 00036 ConnectionColumn = 0, /**< Column for either the circuit or stream */ 00037 StatusColumn = 1 /**< Status of the connection. */ 00038 }; 00039 00040 /** Default constructor */ 00041 CircuitListWidget(QWidget *parent = 0); 00042 00043 /** Adds a circuit to the list. If the circuit already exists in the list, 00044 * the status and path will be updated. */ 00045 void addCircuit(const Circuit &circuit); 00046 /** Adds a stream to the list. If the stream already exists in the list, the 00047 * status and path will be updated. */ 00048 void addStream(const Stream &stream); 00049 /** Returns a list of circuits currently in the widget. */ 00050 QList<Circuit> circuits(); 00051 /** Called when the user changes the UI translation. */ 00052 void retranslateUi(); 00053 00054 signals: 00055 /** Emitted when a circuit item is selected. */ 00056 void circuitSelected(Circuit circuit); 00057 /** Emitted when a circuit is removed from the list. */ 00058 void circuitRemoved(CircuitId circid); 00059 /** Emitted when the user selects a circuit to be closed. */ 00060 void closeCircuit(CircuitId circid); 00061 /** Emitted when the user selects a stream to be closed. */ 00062 void closeStream(StreamId streamid); 00063 /** Emitted when the user selects a circuit to zoom to. */ 00064 void zoomToCircuit(CircuitId circid); 00065 00066 public slots: 00067 /** Clears all circuits and streams from the list. */ 00068 void clearCircuits(); 00069 00070 private slots: 00071 /** Removes the first circuit scheduled to be removed.*/ 00072 void removeCircuit(); 00073 /** Removes the first stream scheduled to be removed. */ 00074 void removeStream(); 00075 /** Called when the current item selectio has changed. */ 00076 void onSelectionChanged(QTreeWidgetItem *cur, QTreeWidgetItem *prev); 00077 /** Called when the user requests a context menu on a circuit or stream in 00078 * the list and displays a context menu appropriate for whichever type of 00079 * item is currently selected. */ 00080 void customContextMenuRequested(const QPoint &pos); 00081 /** Closes all selected circuits or streams. */ 00082 void closeSelectedConnections(); 00083 00084 private: 00085 /** Removes the given circuit item and all streams on that circuit. */ 00086 void removeCircuit(CircuitItem *circuit); 00087 /** Removes the given stream item. */ 00088 void removeStream(StreamItem *stream); 00089 /** Finds the circuit with the given ID. */ 00090 CircuitItem* findCircuitItem(const CircuitId &circid); 00091 /** Finds the stream with the given ID. */ 00092 StreamItem* findStreamItem(const StreamId &streamid); 00093 /** Schedules the given circuit item to be removed after the given timeout. */ 00094 void scheduleCircuitRemoval(CircuitItem *circuit, int delay); 00095 /** Schedules a stream to be removed after the given timeout. */ 00096 void scheduleStreamRemoval(StreamItem *stream, int delay); 00097 00098 /** List of circuit items to be removed. */ 00099 QList<CircuitItem *> _circuitRemovalList; 00100 /** List of stream items to be removed. */ 00101 QList<StreamItem *> _streamRemovalList; 00102 }; 00103 00104 #endif 00105