Vidalia 0.3.1
LogTreeWidget.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 LogTreeWidget.h
13** \brief Contains a collection of log messages as LogTreeItems
14*/
15
16#ifndef _LOGTREEWIDGET_H
17#define _LOGTREEWIDGET_H
18
19#include "LogTreeItem.h"
20
21#include "TorControl.h"
22
23#include <QList>
24#include <QString>
25#include <QStringList>
26#include <QTreeWidget>
27#include <QHeaderView>
28#include <QShowEvent>
29
30
31class LogTreeWidget : public QTreeWidget
32{
33 Q_OBJECT
34
35public:
36 /** Log tree column indices. */
38 TimeColumn = 0, /**< Timestamp column. */
39 TypeColumn = 1, /**< Message severity type column. */
40 MessageColumn = 2 /**< Message text column. */
41 };
42
43 /** Default constructor. */
44 LogTreeWidget(QWidget *parent = 0);
45
46 /** Returns a list of all currently selected messages. */
47 QStringList selectedMessages();
48 /** Returns a list of all messages in the tree. */
49 QStringList allMessages();
50 /** Deselects all currently selected messages. */
51 void deselectAll();
52
53 /** Returns the number of items currently in the tree. */
54 int messageCount();
55 /** Sets the maximum number of items in the tree. */
56 void setMaximumMessageCount(int max);
57 /** Filters the log according to the specified filter. */
58 void filter(uint filter);
59
60 /** Adds a log item to the tree. */
61 LogTreeItem* log(tc::Severity severity, const QString &message);
62
63 /** Searches the log for entries that contain the given text. */
64 QList<LogTreeItem *> find(QString text, bool highlight = true);
65
66public slots:
67 /** Clears all contents on the message log and resets the counter. */
68 void clearMessages();
69
70protected:
71 /** Sets the default, initial column header widths. */
72 void showEvent(QShowEvent *event);
73
74private slots:
75 /** Called when the user moves the vertical scroll bar. */
77
78private:
79 /** Adds <b>item</b> as a top-level item in the tree. */
80 void addLogTreeItem(LogTreeItem *item);
81 /** Casts a QList of one pointer type to another. */
82 QList<LogTreeItem *> qlist_cast(QList<QTreeWidgetItem *> inlist);
83 /** Sortrs a QList of pointers to tree items. */
84 QList<LogTreeItem *> qlist_sort(QList<LogTreeItem *> inlist);
85
86 /**< List of pointers to all log message items currently in the tree. */
87 QList<LogTreeItem *> _itemHistory;
88 int _maxItemCount; /**< Maximum number of items in the tree. */
89 bool _scrollOnNewItem; /**< Set to true if we are to scroll to the new item
90 after adding a message to the log. */
91};
92
93#endif
94
QList< LogTreeItem * > _itemHistory
Definition: LogTreeWidget.h:87
void showEvent(QShowEvent *event)
void addLogTreeItem(LogTreeItem *item)
QStringList allMessages()
void setMaximumMessageCount(int max)
void filter(uint filter)
QStringList selectedMessages()
QList< LogTreeItem * > find(QString text, bool highlight=true)
QList< LogTreeItem * > qlist_sort(QList< LogTreeItem * > inlist)
bool _scrollOnNewItem
Definition: LogTreeWidget.h:89
void verticalSliderReleased()
LogTreeWidget(QWidget *parent=0)
QList< LogTreeItem * > qlist_cast(QList< QTreeWidgetItem * > inlist)
LogTreeItem * log(tc::Severity severity, const QString &message)
Severity
Definition: tcglobal.h:69