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 2922 2008-08-03 01:19:40Z edmanm $ 00014 ** \brief Contains a collection of log messages as LogTreeItems 00015 */ 00016 00017 #ifndef _LOGTREEWIDGET_H 00018 #define _LOGTREEWIDGET_H 00019 00020 #include <QList> 00021 #include <QString> 00022 #include <QStringList> 00023 #include <QTreeWidget> 00024 #include <QHeaderView> 00025 #include <QShowEvent> 00026 #include <logevent.h> 00027 00028 #include "logtreeitem.h" 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(LogEvent::Severity type, 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 /** Casts a QList of one pointer type to another. */ 00080 QList<LogTreeItem *> qlist_cast(QList<QTreeWidgetItem *> inlist); 00081 /** Sortrs a QList of pointers to tree items. */ 00082 QList<LogTreeItem *> qlist_sort(QList<LogTreeItem *> inlist); 00083 00084 int _maxItemCount; /**< Maximum number of items in the tree. */ 00085 bool _scrollOnNewItem; /**< Set to true if we are to scroll to the new item 00086 after adding a message to the log. */ 00087 }; 00088 00089 #endif 00090