Vidalia
0.2.21
Main Page
Namespaces
Classes
Files
File List
File Members
src
vidalia
network
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 */
21
CircuitItem::CircuitItem
(
const
Circuit
&circuit)
22
{
23
/* Update the displayed text */
24
update
(circuit);
25
}
26
27
/** Updates the status and path of this circuit item. */
28
void
29
CircuitItem::update
(
const
Circuit
&circuit)
30
{
31
QString displayedPath;
32
33
/* Save the Circuit object */
34
_circuit
=
circuit
;
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);
43
setText(
CircuitListWidget::StatusColumn
, circuit.
statusString
());
44
setToolTip(
CircuitListWidget::StatusColumn
, circuit.
statusString
());
45
}
46
47
/** Adds a stream as a child of this circuit. */
48
void
49
CircuitItem::addStream
(
StreamItem
*stream)
50
{
51
addChild(stream);
52
}
53
54
/** Removes the stream item from this circuit and frees its memory */
55
void
56
CircuitItem::removeStream
(
StreamItem
*stream)
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. */
65
QList<StreamItem *>
66
CircuitItem::streams
()
const
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
Generated on Thu Dec 6 2012 04:33:16 for Vidalia by
1.8.2