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 1641 2007-02-20 17:33:03Z 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 #include <QMenu>
00034 #include <QAction>
00035 #include <QMouseEvent>
00036 
00037 #include "circuititem.h"
00038 #include "streamitem.h"
00039 
00040 
00041 class CircuitListWidget : public QTreeWidget
00042 {
00043   Q_OBJECT
00044   
00045 public:
00046   /** Circuit list columns. */
00047   enum Columns {
00048     ConnectionColumn = 0, /**< Column for either the circuit or stream */
00049     StatusColumn = 1      /**< Status of the connection. */
00050   };
00051   
00052   /** Default constructor */
00053   CircuitListWidget(QWidget *parent = 0);
00054 
00055   /** Adds a circuit to the list. If the circuit already exists in the list,
00056    * the status and path will be updated. */
00057   void addCircuit(Circuit circuit, QString displayedPath);
00058   /** Adds a stream to the list. If the stream already exists in the list, the
00059    * status and path will be updated. */
00060   void addStream(Stream stream);
00061   /** Returns a list of circuits currently in the widget. */
00062   QList<Circuit> circuits();
00063 
00064 signals:
00065   /** Emitted when a circuit item is selected. */
00066   void circuitSelected(Circuit circuit);
00067   /** Emitted when a circuit is removed from the list. */
00068   void circuitRemoved(quint64 circid);
00069   /** Emitted when the user selects a circuit to be closed. */
00070   void closeCircuit(quint64 circid);
00071   /** Emitted when the user selects a stream to be closed. */
00072   void closeStream(quint64 streamid);
00073   /** Emitted when the user selects a circuit to zoom to. */
00074   void zoomToCircuit(quint64 circid);
00075   
00076 public slots:
00077   /** Clears all circuits and streams from the list. */
00078   void clearCircuits();
00079 
00080 protected:
00081   /** Called when the user presses and releases a mouse button. */ 
00082   virtual void mouseReleaseEvent(QMouseEvent *e);
00083 
00084 private slots:
00085   /** Removes the first circuit scheduled to be removed.*/
00086   void removeCircuit(); 
00087   /** Removes the first stream scheduled to be removed. */
00088   void removeStream();
00089   /** Called when the current item selectio has changed. */
00090   void onSelectionChanged(QTreeWidgetItem *cur, QTreeWidgetItem *prev);
00091   
00092 private:
00093   /** Removes the given circuit item and all streams on that circuit. */
00094   void removeCircuit(CircuitItem *circuit);
00095   /** Removes the given stream item. */
00096   void removeStream(StreamItem *stream);
00097   /** Finds the circuit with the given ID. */
00098   CircuitItem* findCircuitItem(quint64 circid);
00099   /** Finds the stream with the given ID. */
00100   StreamItem* findStreamItem(quint64 streamid);
00101   /** Schedules the given circuit item to be removed after the given timeout. */
00102   void scheduleCircuitRemoval(CircuitItem *circuit, int delay);
00103   /** Schedules a stream to be removed after the given timeout. */
00104   void scheduleStreamRemoval(StreamItem *stream, int delay);
00105 
00106   /* Circuit and stream context menus and items */
00107   QMenu* _circuitContextMenu; /**< Context menu for circuit items. */
00108   QAction* _closeCircuitAct;  /**< Closes a circuit. */
00109   QAction* _zoomCircuitAct;   /**< Zoom to a circuit. */
00110   QMenu* _streamContextMenu;  /**< Context menu for stream items. */
00111   QAction* _closeStreamAct;   /**< Closes a stream. */
00112 
00113   /** List of circuit items to be removed. */
00114   QList<CircuitItem *> _circuitRemovalList;
00115   /** List of stream items to be removed. */
00116   QList<StreamItem *> _streamRemovalList;
00117 };
00118 
00119 #endif
00120 

Generated on Wed Sep 5 15:49:27 2007 for Vidalia by  doxygen 1.5.3