Vidalia 0.3.1
CircuitListWidget.h
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 CircuitListWidget.h
13** \brief Collection of Tor circuits as CircuitItems
14*/
15
16#ifndef _CIRCUITLISTWIDGET_H
17#define _CIRCUITLISTWIDGET_H
18
19#include "CircuitItem.h"
20#include "StreamItem.h"
21
22#include <QTreeWidget>
23#include <QList>
24#include <QMenu>
25#include <QAction>
26#include <QMouseEvent>
27
28
29class CircuitListWidget : public QTreeWidget
30{
31 Q_OBJECT
32
33public:
34 /** Circuit list columns. */
35 enum Columns {
36 ConnectionColumn = 0, /**< Column for either the circuit or stream */
37 StatusColumn = 1 /**< Status of the connection. */
38 };
39
40 /** Default constructor */
41 CircuitListWidget(QWidget *parent = 0);
42
43 /** Adds a circuit to the list. If the circuit already exists in the list,
44 * the status and path will be updated. */
45 void addCircuit(const Circuit &circuit);
46 /** Adds a stream to the list. If the stream already exists in the list, the
47 * status and path will be updated. */
48 void addStream(const Stream &stream);
49 /** Returns a list of circuits currently in the widget. */
50 QList<Circuit> circuits();
51 /** Called when the user changes the UI translation. */
52 void retranslateUi();
53
54signals:
55 /** Emitted when a circuit item is selected. */
56 void circuitSelected(Circuit circuit);
57 /** Emitted when a circuit is removed from the list. */
59 /** Emitted when the user selects a circuit to be closed. */
60 void closeCircuit(CircuitId circid);
61 /** Emitted when the user selects a stream to be closed. */
62 void closeStream(StreamId streamid);
63 /** Emitted when the user selects a circuit to zoom to. */
65
66public slots:
67 /** Clears all circuits and streams from the list. */
68 void clearCircuits();
69
70private slots:
71 /** Removes the first circuit scheduled to be removed.*/
72 void removeCircuit();
73 /** Removes the first stream scheduled to be removed. */
74 void removeStream();
75 /** Called when the current item selectio has changed. */
76 void onSelectionChanged(QTreeWidgetItem *cur, QTreeWidgetItem *prev);
77 /** Called when the user requests a context menu on a circuit or stream in
78 * the list and displays a context menu appropriate for whichever type of
79 * item is currently selected. */
80 void customContextMenuRequested(const QPoint &pos);
81 /** Closes all selected circuits or streams. */
83
84private:
85 /** Removes the given circuit item and all streams on that circuit. */
86 void removeCircuit(CircuitItem *circuit);
87 /** Removes the given stream item. */
88 void removeStream(StreamItem *stream);
89 /** Finds the circuit with the given ID. */
91 /** Finds the stream with the given ID. */
92 StreamItem* findStreamItem(const StreamId &streamid);
93 /** Schedules the given circuit item to be removed after the given timeout. */
94 void scheduleCircuitRemoval(CircuitItem *circuit, int delay);
95 /** Schedules a stream to be removed after the given timeout. */
96 void scheduleStreamRemoval(StreamItem *stream, int delay);
97
98 /** List of circuit items to be removed. */
99 QList<CircuitItem *> _circuitRemovalList;
100 /** List of stream items to be removed. */
101 QList<StreamItem *> _streamRemovalList;
102};
103
104#endif
105
QString CircuitId
Definition: Circuit.h:24
QString StreamId
Definition: Stream.h:28
QList< CircuitItem * > _circuitRemovalList
void closeStream(StreamId streamid)
CircuitItem * findCircuitItem(const CircuitId &circid)
QList< Circuit > circuits()
void scheduleCircuitRemoval(CircuitItem *circuit, int delay)
void closeCircuit(CircuitId circid)
StreamItem * findStreamItem(const StreamId &streamid)
void zoomToCircuit(CircuitId circid)
void scheduleStreamRemoval(StreamItem *stream, int delay)
CircuitListWidget(QWidget *parent=0)
void circuitSelected(Circuit circuit)
QList< StreamItem * > _streamRemovalList
void addCircuit(const Circuit &circuit)
void customContextMenuRequested(const QPoint &pos)
void onSelectionChanged(QTreeWidgetItem *cur, QTreeWidgetItem *prev)
void circuitRemoved(CircuitId circid)
void addStream(const Stream &stream)
Definition: Stream.h:32