circuitlistwidget.h

Go to the documentation of this file.
00001 /****************************************************************
00002  *  Vidalia is distributed under the following license:
00003  *
00004  *  Copyright (C) 2006,  Matt Edman, Justin Hipple
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00019  *  Boston, MA  02110-1301, USA.
00020  ****************************************************************/
00021 
00022 /** 
00023  * \file circuitlistwidget.h
00024  * \version $Id: circuitlistwidget.h 1262 2006-10-03 07:16:16Z edmanm $
00025  * \brief Collection of Tor circuits as CircuitItems
00026  */
00027 
00028 #ifndef _CIRCUITLISTWIDGET_H
00029 #define _CIRCUITLISTWIDGET_H
00030 
00031 #include <QTreeWidget>
00032 #include <QList>
00033 
00034 #include "circuititem.h"
00035 #include "streamitem.h"
00036 
00037 
00038 class CircuitListWidget : public QTreeWidget
00039 {
00040   Q_OBJECT
00041   
00042 public:
00043   /** Circuit list columns. */
00044   enum Columns {
00045     ConnectionColumn = 0, /**< Column for either the circuit or stream */
00046     StatusColumn = 1,      /**< Status of the connection. */
00047     ConnectionColumnWidth = 235
00048   };
00049   
00050   /** Default constructor */
00051   CircuitListWidget(QWidget *parent = 0);
00052 
00053   /** Adds a circuit to the list. If the circuit already exists in the list,
00054    * the status and path will be updated. */
00055   void addCircuit(Circuit circuit);
00056   /** Adds a stream to the list. If the stream already exists in the list, the
00057    * status and path will be updated. */
00058   void addStream(Stream stream);
00059   /** Removes the given circuit item and all streams on that circuit. */
00060   void removeCircuit(CircuitItem *circuit);
00061   /** Removes the given stream item. */
00062   void removeStream(StreamItem *stream);
00063   /** Returns a list of circuits currently in the widget. */
00064   QList<Circuit> circuits();
00065 
00066 signals:
00067   /** Emitted when a circuit item is selected. */
00068   void circuitSelected(Circuit circuit);
00069   /** Emitted when a circuit is removed from the list. */
00070   void circuitRemoved(quint64 circid);
00071 
00072 public slots:
00073   /** Clears all circuits and streams from the list. */
00074   void clearCircuits();
00075 
00076 private slots:
00077   /** Removes the circuit with the given ID and any streams on this circuit.*/
00078   void removeCircuit(); 
00079   /** Removes the stream with the given ID. */
00080   void removeStream();
00081   /** Called when the current item selectio has changed. */
00082   void onSelectionChanged(QTreeWidgetItem *cur, QTreeWidgetItem *prev);
00083 
00084 private:
00085   /** Finds the circuit with the given ID. */
00086   CircuitItem* findCircuitItem(quint64 circid);
00087   /** Finds the stream with the given ID. */
00088   StreamItem* findStreamItem(quint64 streamid);
00089   /** Schedules the given circuit item to be removed after the given timeout. */
00090   void scheduleCircuitRemoval(CircuitItem *circuit, int delay);
00091   /** Schedules a stream to be removed after the given timeout. */
00092   void scheduleStreamRemoval(StreamItem *stream, int delay);
00093 
00094   /** List of circuit items to be removed. */
00095   QList<CircuitItem *> _circuitRemovalList;
00096   /** List of stream items to be removed. */
00097   QList<StreamItem *> _streamRemovalList;
00098 };
00099 
00100 #endif
00101 

Generated on Mon Oct 23 20:08:15 2006 for Vidalia by  doxygen 1.5.0