Vidalia  0.3.1
StatusEventItem.cpp
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 StatusEventItem.cpp
13 ** \brief Represents a single status event item in a StatusEventWidget
14 */
15 
16 #include "StatusEventItem.h"
17 
18 #include <QDateTime>
19 #include <QPixmap>
20 #include <QString>
21 
23  : QTreeWidgetItem(parent, QTreeWidgetItem::UserType)
24 {
25 }
26 
27 void
29 {
30  setData(0, TimestampRole, timestamp);
31 }
32 
33 QDateTime
35 {
36  return data(0, TimestampRole).toDateTime();
37 }
38 
39 void
40 StatusEventItem::setIcon(const QPixmap &pixmap)
41 {
42  setData(0, IconRole, pixmap);
43 }
44 
45 QPixmap
47 {
48  return data(0, IconRole).value<QPixmap>();
49 }
50 
51 void
53 {
54  setData(0, TitleRole, title);
55 }
56 
57 QString
59 {
60  return data(0, TitleRole).toString();
61 }
62 
63 void
65 {
66  setData(0, DescriptionRole, description);
67 }
68 
69 QString
71 {
72  return data(0, DescriptionRole).toString();
73 }
74 
75 void
76 StatusEventItem::setHelpUrl(const QString &url)
77 {
78  setData(0, HelpUrlRole, url);
79 }
80 
81 QString
83 {
84  return data(0, HelpUrlRole).toString();
85 }
86 
87 void
88 StatusEventItem::setToolTip(const QString &toolTip)
89 {
90  QTreeWidgetItem::setToolTip(0, toolTip);
91 }
92 
93 QString
95 {
96  return QString("[%1] %2 - %3").arg(timestamp().toString())
97  .arg(title())
98  .arg(description());
99 }
100 
101 bool
102 StatusEventItem::operator<(const QTreeWidgetItem &other) const
103 {
104  QDateTime a = data(0, TimestampRole).toDateTime();
105  QDateTime b = other.data(0, TimestampRole).toDateTime();
106 
107  return (a < b);
108 }
109 
void setDescription(const QString &description)
QPixmap icon() const
QString helpUrl() const
QString toString() const
QString description() const
StatusEventItem(QTreeWidget *parent=0)
virtual bool operator<(const QTreeWidgetItem &other) const
void setHelpUrl(const QString &url)
void setIcon(const QPixmap &pixmap)
QString title() const
QString b(QString str)
Definition: html.cpp:39
void setTimestamp(const QDateTime &timestamp)
QDateTime timestamp() const
void setTitle(const QString &title)
void setToolTip(const QString &toolTip)