circuitlistwidget.h

Go to the documentation of this file.
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 2977 2008-08-17 01:28:25Z edmanm $
00014 ** \brief Collection of Tor circuits as CircuitItems
00015 */
00016 
00017 #ifndef _CIRCUITLISTWIDGET_H
00018 #define _CIRCUITLISTWIDGET_H
00019 
00020 #include <QTreeWidget>
00021 #include <QList>
00022 #include <QMenu>
00023 #include <QAction>
00024 #include <QMouseEvent>
00025 
00026 #include "circuititem.h"
00027 #include "streamitem.h"
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 
00053 signals:
00054   /** Emitted when a circuit item is selected. */
00055   void circuitSelected(Circuit circuit);
00056   /** Emitted when a circuit is removed from the list. */
00057   void circuitRemoved(CircuitId circid);
00058   /** Emitted when the user selects a circuit to be closed. */
00059   void closeCircuit(CircuitId circid);
00060   /** Emitted when the user selects a stream to be closed. */
00061   void closeStream(StreamId streamid);
00062   /** Emitted when the user selects a circuit to zoom to. */
00063   void zoomToCircuit(CircuitId circid);
00064   
00065 public slots:
00066   /** Clears all circuits and streams from the list. */
00067   void clearCircuits();
00068 
00069 private slots:
00070   /** Removes the first circuit scheduled to be removed.*/
00071   void removeCircuit(); 
00072   /** Removes the first stream scheduled to be removed. */
00073   void removeStream();
00074   /** Called when the current item selectio has changed. */
00075   void onSelectionChanged(QTreeWidgetItem *cur, QTreeWidgetItem *prev);
00076   /** Called when the user requests a context menu on a circuit or stream in
00077    * the list and displays a context menu appropriate for whichever type of
00078    * item is currently selected. */
00079   void customContextMenuRequested(const QPoint &pos);
00080   /** Closes all selected circuits or streams. */
00081   void closeSelectedConnections();
00082 
00083 private:
00084   /** Removes the given circuit item and all streams on that circuit. */
00085   void removeCircuit(CircuitItem *circuit);
00086   /** Removes the given stream item. */
00087   void removeStream(StreamItem *stream);
00088   /** Finds the circuit with the given ID. */
00089   CircuitItem* findCircuitItem(const CircuitId &circid);
00090   /** Finds the stream with the given ID. */
00091   StreamItem* findStreamItem(const StreamId &streamid);
00092   /** Schedules the given circuit item to be removed after the given timeout. */
00093   void scheduleCircuitRemoval(CircuitItem *circuit, int delay);
00094   /** Schedules a stream to be removed after the given timeout. */
00095   void scheduleStreamRemoval(StreamItem *stream, int delay);
00096 
00097   /** List of circuit items to be removed. */
00098   QList<CircuitItem *> _circuitRemovalList;
00099   /** List of stream items to be removed. */
00100   QList<StreamItem *> _streamRemovalList;
00101 };
00102 
00103 #endif
00104 

Generated on 22 Feb 2010 for Vidalia by  doxygen 1.6.1