Vidalia  0.3.1
LogTreeItem.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 LogTreeItem.h
13 ** \brief Item representing a single message in the message log
14 */
15 
16 #ifndef _LOGTREEITEM_H
17 #define _LOGTREEITEM_H
18 
19 #include "TorControl.h"
20 
21 #include <QTreeWidgetItem>
22 #include <QDateTime>
23 #include <QString>
24 
25 
26 class LogTreeItem : public QTreeWidgetItem
27 {
28  Q_DECLARE_TR_FUNCTIONS(LogTreeItem)
29 
30 public:
31  /** Default constructor. */
32  LogTreeItem(tc::Severity type, const QString &message,
33  const QDateTime &timestamp = QDateTime::currentDateTime());
34 
35  /** Sets the item's log time. */
36  void setTimestamp(const QDateTime &timestamp);
37  /** Sets the item's severity and appropriate background color. */
38  void setSeverity(tc::Severity type);
39  /** Sets the item's message text. */
40  void setMessage(const QString &message);
41 
42  /** Returns this message's sequence number. */
43  quint32 id() const { return _seqnum; }
44  /** Returns the timestamp for this log message. */
45  QDateTime timestamp() const;
46  /** Returns the severity associated with this log item. */
47  tc::Severity severity() const;
48  /** Returns the message associated with this log item. */
49  QString message() const;
50 
51  /** Returns a printable string representation of the item's contents.*/
52  QString toString() const;
53  /** Compares <b>other</b> to this log message item based on the current sort
54  * column and order. */
55  virtual bool operator<(const QTreeWidgetItem &other) const;
56 
57  /** Converts a tc::Severity enum value to a localized string description.*/
58  static QString severityToString(tc::Severity severity);
59 
60 private:
61  quint32 _seqnum; /**< Sequence number used to disambiguate messages with
62  the same timestamp. */
63 };
64 
65 #endif
66 
LogTreeItem::setSeverity
void setSeverity(tc::Severity type)
Definition: LogTreeItem.cpp:68
LogTreeItem::severity
tc::Severity severity() const
Definition: LogTreeItem.cpp:99
LogTreeItem::message
QString message() const
Definition: LogTreeItem.cpp:113
LogTreeItem::timestamp
QDateTime timestamp() const
Definition: LogTreeItem.cpp:106
tc::Severity
Severity
Definition: tcglobal.h:69
LogTreeItem::severityToString
static QString severityToString(tc::Severity severity)
Definition: LogTreeItem.cpp:120
LogTreeItem::id
quint32 id() const
Definition: LogTreeItem.h:43
LogTreeItem
Definition: LogTreeItem.h:26
LogTreeItem::setTimestamp
void setTimestamp(const QDateTime &timestamp)
Definition: LogTreeItem.cpp:59
TorControl.h
LogTreeItem::LogTreeItem
LogTreeItem(tc::Severity type, const QString &message, const QDateTime &timestamp=QDateTime::currentDateTime())
Definition: LogTreeItem.cpp:32
LogTreeItem::setMessage
void setMessage(const QString &message)
Definition: LogTreeItem.cpp:91
LogTreeItem::operator<
virtual bool operator<(const QTreeWidgetItem &other) const
Definition: LogTreeItem.cpp:137
LogTreeItem::_seqnum
quint32 _seqnum
Definition: LogTreeItem.h:61
quint32
quint32
Definition: TorControlPrototype.cpp:222
LogTreeItem::toString
QString toString() const
Definition: LogTreeItem.cpp:50