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 1238 2006-09-25 17:50:57Z 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)
00034 {
00035   /* Update the displayed text */
00036   update(circuit);
00037 }
00038 
00039 /** Updates the status and path of this circuit item. */
00040 void
00041 CircuitItem::update(Circuit circuit)
00042 {
00043   /* Save the Circuit object */
00044   _circuit = circuit;
00045   
00046   /* Get the path, or put in a semi-meaningful value if the path is empty */
00047   QString path = circuit.path();
00048   if (path.isEmpty()) {
00049     path = tr("<Path Empty>");
00050   }
00051 
00052   /* Update the column fields */
00053   setText(CircuitListWidget::ConnectionColumn, path);
00054   setText(CircuitListWidget::StatusColumn, circuit.statusString());
00055 }
00056 
00057 /** Adds a stream as a child of this circuit. */
00058 void
00059 CircuitItem::addStream(StreamItem *stream)
00060 {
00061   addChild(stream);
00062 }
00063 
00064 /** Removes the stream item from this circuit and frees its memory */
00065 void
00066 CircuitItem::removeStream(StreamItem *stream)
00067 {
00068   int index = indexOfChild(stream);
00069   if (index > -1) {
00070     delete takeChild(index);
00071   }
00072 }
00073 
00074 /** Returns a list of all stream items on this circuit. */
00075 QList<StreamItem *>
00076 CircuitItem::streams()
00077 {
00078   QList<StreamItem *> streams;
00079   QList<QTreeWidgetItem *> items = this->takeChildren();
00080   foreach (QTreeWidgetItem *item, items) {
00081     streams << (StreamItem *)item;
00082   }
00083   return streams;
00084 }
00085 

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