circuititem.cpp

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 circuititem.cpp
00024  * \version $Id: circuititem.cpp 1767 2007-06-03 03:34:14Z edmanm $
00025  * \brief Item representing a Tor circuit and its status
00026  */
00027 
00028 #include "circuitlistwidget.h"
00029 #include "circuititem.h"
00030 
00031 
00032 /** Constructor */
00033 CircuitItem::CircuitItem(Circuit circuit, QString displayedPath)
00034 {
00035   /* Update the displayed text */
00036   update(circuit, displayedPath);
00037 }
00038 
00039 /** Updates the status and path of this circuit item. */
00040 void
00041 CircuitItem::update(Circuit circuit, QString displayedPath)
00042 {
00043   /* Save the Circuit object */
00044   _circuit = circuit;
00045   
00046   /* Use a semi-meaningful value if the path is empty */
00047   if (displayedPath.isEmpty()) {
00048     displayedPath = tr("<Path Empty>");
00049   }
00050 
00051   /* Update the column fields */
00052   setText(CircuitListWidget::ConnectionColumn, displayedPath);
00053   setToolTip(CircuitListWidget::ConnectionColumn, displayedPath);
00054   setText(CircuitListWidget::StatusColumn, circuit.statusString());
00055   setToolTip(CircuitListWidget::StatusColumn, circuit.statusString());
00056 }
00057 
00058 /** Adds a stream as a child of this circuit. */
00059 void
00060 CircuitItem::addStream(StreamItem *stream)
00061 {
00062   addChild(stream);
00063 }
00064 
00065 /** Removes the stream item from this circuit and frees its memory */
00066 void
00067 CircuitItem::removeStream(StreamItem *stream)
00068 {
00069   int index = indexOfChild(stream);
00070   if (index > -1) {
00071     delete takeChild(index);
00072   }
00073 }
00074 
00075 /** Returns a list of all stream items on this circuit. */
00076 QList<StreamItem *>
00077 CircuitItem::streams()
00078 {
00079   QList<StreamItem *> streams;
00080   int n = childCount();
00081   for (int i = 0; i < n; i++) {
00082     streams << (StreamItem *)child(i);
00083   }
00084   return streams;
00085 }
00086 

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