Vidalia 0.3.1
CircuitItem.cpp
Go to the documentation of this file.
1/*
2** This file is part of Vidalia, and is subject to the license terms in the
3** LICENSE file, found in the top level directory of this distribution. If you
4** did not receive the LICENSE file with this file, you may obtain it from the
5** Vidalia source package distributed by the Vidalia Project at
6** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7** including this file, may be copied, modified, propagated, or distributed
8** except according to the terms described in the LICENSE file.
9*/
10
11/*
12** \file CircuitItem.cpp
13** \brief Item representing a Tor circuit and its status
14*/
15
16#include "CircuitItem.h"
17#include "CircuitListWidget.h"
18
19
20/** Constructor */
22{
23 /* Update the displayed text */
25}
26
27/** Updates the status and path of this circuit item. */
28void
30{
31 QString displayedPath;
32
33 /* Save the Circuit object */
35
36 /* Use a semi-meaningful value if the path is empty */
37 displayedPath = circuit.length() > 0 ? circuit.routerNames().join(",")
38 : tr("<Path Empty>");
39
40 /* Update the column fields */
41 setText(CircuitListWidget::ConnectionColumn, displayedPath);
42 setToolTip(CircuitListWidget::ConnectionColumn, displayedPath);
45}
46
47/** Adds a stream as a child of this circuit. */
48void
50{
51 addChild(stream);
52}
53
54/** Removes the stream item from this circuit and frees its memory */
55void
57{
58 int index = indexOfChild(stream);
59 if (index > -1) {
60 delete takeChild(index);
61 }
62}
63
64/** Returns a list of all stream items on this circuit. */
65QList<StreamItem *>
67{
68 QList<StreamItem *> streams;
69 int n = childCount();
70 for (int i = 0; i < n; i++) {
71 streams << (StreamItem *)child(i);
72 }
73 return streams;
74}
75
uint length() const
Definition: Circuit.h:57
QStringList routerNames() const
Definition: Circuit.h:59
QString statusString() const
Definition: Circuit.cpp:107
Circuit _circuit
Definition: CircuitItem.h:50
void addStream(StreamItem *stream)
Definition: CircuitItem.cpp:49
QList< StreamItem * > streams() const
Definition: CircuitItem.cpp:66
CircuitItem(const Circuit &circuit)
Definition: CircuitItem.cpp:21
void removeStream(StreamItem *stream)
Definition: CircuitItem.cpp:56
Circuit circuit() const
Definition: CircuitItem.h:45
void update(const Circuit &circuit)
Definition: CircuitItem.cpp:29
QString i(QString str)
Definition: html.cpp:32