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
27void
28StatusEventItem::setTimestamp(const QDateTime &timestamp)
29{
30 setData(0, TimestampRole, timestamp);
31}
32
33QDateTime
35{
36 return data(0, TimestampRole).toDateTime();
37}
38
39void
40StatusEventItem::setIcon(const QPixmap &pixmap)
41{
42 setData(0, IconRole, pixmap);
43}
44
45QPixmap
47{
48 return data(0, IconRole).value<QPixmap>();
49}
50
51void
52StatusEventItem::setTitle(const QString &title)
53{
54 setData(0, TitleRole, title);
55}
56
57QString
59{
60 return data(0, TitleRole).toString();
61}
62
63void
64StatusEventItem::setDescription(const QString &description)
65{
66 setData(0, DescriptionRole, description);
67}
68
69QString
71{
72 return data(0, DescriptionRole).toString();
73}
74
75void
76StatusEventItem::setHelpUrl(const QString &url)
77{
78 setData(0, HelpUrlRole, url);
79}
80
81QString
83{
84 return data(0, HelpUrlRole).toString();
85}
86
87void
88StatusEventItem::setToolTip(const QString &toolTip)
89{
90 QTreeWidgetItem::setToolTip(0, toolTip);
91}
92
93QString
95{
96 return QString("[%1] %2 - %3").arg(timestamp().toString())
97 .arg(title())
98 .arg(description());
99}
100
101bool
102StatusEventItem::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 setIcon(const QPixmap &pixmap)
void setDescription(const QString &description)
void setTimestamp(const QDateTime &timestamp)
QString helpUrl() const
void setToolTip(const QString &toolTip)
QDateTime timestamp() const
QString toString() const
QPixmap icon() const
StatusEventItem(QTreeWidget *parent=0)
QString title() const
void setTitle(const QString &title)
virtual bool operator<(const QTreeWidgetItem &other) const
QString description() const
void setHelpUrl(const QString &url)
QString b(QString str)
Definition: html.cpp:39