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 LogTreeItem.h 00013 ** \brief Item representing a single message in the message log 00014 */ 00015 00016 #ifndef _LOGTREEITEM_H 00017 #define _LOGTREEITEM_H 00018 00019 #include "TorControl.h" 00020 00021 #include <QTreeWidgetItem> 00022 #include <QDateTime> 00023 #include <QString> 00024 00025 00026 class LogTreeItem : public QTreeWidgetItem 00027 { 00028 Q_DECLARE_TR_FUNCTIONS(LogTreeItem) 00029 00030 public: 00031 /** Default constructor. */ 00032 LogTreeItem(tc::Severity type, const QString &message, 00033 const QDateTime ×tamp = QDateTime::currentDateTime()); 00034 00035 /** Sets the item's log time. */ 00036 void setTimestamp(const QDateTime ×tamp); 00037 /** Sets the item's severity and appropriate background color. */ 00038 void setSeverity(tc::Severity type); 00039 /** Sets the item's message text. */ 00040 void setMessage(const QString &message); 00041 00042 /** Returns this message's sequence number. */ 00043 quint32 id() const { return _seqnum; } 00044 /** Returns the timestamp for this log message. */ 00045 QDateTime timestamp() const; 00046 /** Returns the severity associated with this log item. */ 00047 tc::Severity severity() const; 00048 /** Returns the message associated with this log item. */ 00049 QString message() const; 00050 00051 /** Returns a printable string representation of the item's contents.*/ 00052 QString toString() const; 00053 /** Compares <b>other</b> to this log message item based on the current sort 00054 * column and order. */ 00055 virtual bool operator<(const QTreeWidgetItem &other) const; 00056 00057 /** Converts a tc::Severity enum value to a localized string description.*/ 00058 static QString severityToString(tc::Severity severity); 00059 00060 private: 00061 quint32 _seqnum; /**< Sequence number used to disambiguate messages with 00062 the same timestamp. */ 00063 }; 00064 00065 #endif 00066