circuititem.cpp

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 circuititem.cpp
00013 ** \version $Id: circuititem.cpp 2977 2008-08-17 01:28:25Z edmanm $
00014 ** \brief Item representing a Tor circuit and its status
00015 */
00016 
00017 #include "circuitlistwidget.h"
00018 #include "circuititem.h"
00019 
00020 
00021 /** Constructor */
00022 CircuitItem::CircuitItem(const Circuit &circuit)
00023 {
00024   /* Update the displayed text */
00025   update(circuit);
00026 }
00027 
00028 /** Updates the status and path of this circuit item. */
00029 void
00030 CircuitItem::update(const Circuit &circuit)
00031 {
00032   QString displayedPath;
00033 
00034   /* Save the Circuit object */
00035   _circuit = circuit;
00036   
00037   /* Use a semi-meaningful value if the path is empty */
00038   displayedPath = circuit.length() > 0 ? circuit.routerNames().join(",")
00039                                        : tr("<Path Empty>");
00040 
00041   /* Update the column fields */
00042   setText(CircuitListWidget::ConnectionColumn, displayedPath);
00043   setToolTip(CircuitListWidget::ConnectionColumn, displayedPath);
00044   setText(CircuitListWidget::StatusColumn, circuit.statusString());
00045   setToolTip(CircuitListWidget::StatusColumn, circuit.statusString());
00046 }
00047 
00048 /** Adds a stream as a child of this circuit. */
00049 void
00050 CircuitItem::addStream(StreamItem *stream)
00051 {
00052   addChild(stream);
00053 }
00054 
00055 /** Removes the stream item from this circuit and frees its memory */
00056 void
00057 CircuitItem::removeStream(StreamItem *stream)
00058 {
00059   int index = indexOfChild(stream);
00060   if (index > -1) {
00061     delete takeChild(index);
00062   }
00063 }
00064 
00065 /** Returns a list of all stream items on this circuit. */
00066 QList<StreamItem *>
00067 CircuitItem::streams() const
00068 {
00069   QList<StreamItem *> streams;
00070   int n = childCount();
00071   for (int i = 0; i < n; i++) {
00072     streams << (StreamItem *)child(i);
00073   }
00074   return streams;
00075 }
00076 

Generated on Wed Nov 26 21:02:38 2008 for Vidalia by  doxygen 1.5.6