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 StatusEventItem.cpp 00013 ** \brief Represents a single status event item in a StatusEventWidget 00014 */ 00015 00016 #include "StatusEventItem.h" 00017 00018 #include <QDateTime> 00019 #include <QPixmap> 00020 #include <QString> 00021 00022 StatusEventItem::StatusEventItem(QTreeWidget *parent) 00023 : QTreeWidgetItem(parent, QTreeWidgetItem::UserType) 00024 { 00025 } 00026 00027 void 00028 StatusEventItem::setTimestamp(const QDateTime ×tamp) 00029 { 00030 setData(0, TimestampRole, timestamp); 00031 } 00032 00033 QDateTime 00034 StatusEventItem::timestamp() const 00035 { 00036 return data(0, TimestampRole).toDateTime(); 00037 } 00038 00039 void 00040 StatusEventItem::setIcon(const QPixmap &pixmap) 00041 { 00042 setData(0, IconRole, pixmap); 00043 } 00044 00045 QPixmap 00046 StatusEventItem::icon() const 00047 { 00048 return data(0, IconRole).value<QPixmap>(); 00049 } 00050 00051 void 00052 StatusEventItem::setTitle(const QString &title) 00053 { 00054 setData(0, TitleRole, title); 00055 } 00056 00057 QString 00058 StatusEventItem::title() const 00059 { 00060 return data(0, TitleRole).toString(); 00061 } 00062 00063 void 00064 StatusEventItem::setDescription(const QString &description) 00065 { 00066 setData(0, DescriptionRole, description); 00067 } 00068 00069 QString 00070 StatusEventItem::description() const 00071 { 00072 return data(0, DescriptionRole).toString(); 00073 } 00074 00075 void 00076 StatusEventItem::setHelpUrl(const QString &url) 00077 { 00078 setData(0, HelpUrlRole, url); 00079 } 00080 00081 QString 00082 StatusEventItem::helpUrl() const 00083 { 00084 return data(0, HelpUrlRole).toString(); 00085 } 00086 00087 void 00088 StatusEventItem::setToolTip(const QString &toolTip) 00089 { 00090 QTreeWidgetItem::setToolTip(0, toolTip); 00091 } 00092 00093 QString 00094 StatusEventItem::toString() const 00095 { 00096 return QString("[%1] %2 - %3").arg(timestamp().toString()) 00097 .arg(title()) 00098 .arg(description()); 00099 } 00100 00101 bool 00102 StatusEventItem::operator<(const QTreeWidgetItem &other) const 00103 { 00104 QDateTime a = data(0, TimestampRole).toDateTime(); 00105 QDateTime b = other.data(0, TimestampRole).toDateTime(); 00106 00107 return (a < b); 00108 } 00109