Vidalia 0.2.10
|
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 LogTreeWidget.h 00013 ** \version $Id: LogTreeWidget.h 4054 2009-08-17 02:25:08Z edmanm $ 00014 ** \brief Contains a collection of log messages as LogTreeItems 00015 */ 00016 00017 #ifndef _LOGTREEWIDGET_H 00018 #define _LOGTREEWIDGET_H 00019 00020 #include "LogTreeItem.h" 00021 00022 #include "TorControl.h" 00023 00024 #include <QList> 00025 #include <QString> 00026 #include <QStringList> 00027 #include <QTreeWidget> 00028 #include <QHeaderView> 00029 #include <QShowEvent> 00030 00031 00032 class LogTreeWidget : public QTreeWidget 00033 { 00034 Q_OBJECT 00035 00036 public: 00037 /** Log tree column indices. */ 00038 enum LogColumns { 00039 TimeColumn = 0, /**< Timestamp column. */ 00040 TypeColumn = 1, /**< Message severity type column. */ 00041 MessageColumn = 2 /**< Message text column. */ 00042 }; 00043 00044 /** Default constructor. */ 00045 LogTreeWidget(QWidget *parent = 0); 00046 00047 /** Returns a list of all currently selected messages. */ 00048 QStringList selectedMessages(); 00049 /** Returns a list of all messages in the tree. */ 00050 QStringList allMessages(); 00051 /** Deselects all currently selected messages. */ 00052 void deselectAll(); 00053 00054 /** Returns the number of items currently in the tree. */ 00055 int messageCount(); 00056 /** Sets the maximum number of items in the tree. */ 00057 void setMaximumMessageCount(int max); 00058 /** Filters the log according to the specified filter. */ 00059 void filter(uint filter); 00060 00061 /** Adds a log item to the tree. */ 00062 LogTreeItem* log(tc::Severity severity, const QString &message); 00063 00064 /** Searches the log for entries that contain the given text. */ 00065 QList<LogTreeItem *> find(QString text, bool highlight = true); 00066 00067 public slots: 00068 /** Clears all contents on the message log and resets the counter. */ 00069 void clearMessages(); 00070 00071 protected: 00072 /** Sets the default, initial column header widths. */ 00073 void showEvent(QShowEvent *event); 00074 00075 private slots: 00076 /** Called when the user moves the vertical scroll bar. */ 00077 void verticalSliderReleased(); 00078 00079 private: 00080 /** Adds <b>item</b> as a top-level item in the tree. */ 00081 void addLogTreeItem(LogTreeItem *item); 00082 /** Casts a QList of one pointer type to another. */ 00083 QList<LogTreeItem *> qlist_cast(QList<QTreeWidgetItem *> inlist); 00084 /** Sortrs a QList of pointers to tree items. */ 00085 QList<LogTreeItem *> qlist_sort(QList<LogTreeItem *> inlist); 00086 00087 /**< List of pointers to all log message items currently in the tree. */ 00088 QList<LogTreeItem *> _itemHistory; 00089 int _maxItemCount; /**< Maximum number of items in the tree. */ 00090 bool _scrollOnNewItem; /**< Set to true if we are to scroll to the new item 00091 after adding a message to the log. */ 00092 }; 00093 00094 #endif 00095