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