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