Vidalia 0.2.10
|
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.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file StatusEventItem.cpp 00013 ** \version $Id: StatusEventItem.cpp 4091 2009-08-30 03:10:07Z edmanm $ 00014 ** \brief Represents a single status event item in a StatusEventWidget 00015 */ 00016 00017 #include "StatusEventItem.h" 00018 00019 #include <QTime> 00020 #include <QPixmap> 00021 #include <QString> 00022 00023 StatusEventItem::StatusEventItem(QTreeWidget *parent) 00024 : QTreeWidgetItem(parent, QTreeWidgetItem::UserType) 00025 { 00026 } 00027 00028 void 00029 StatusEventItem::setTimestamp(const QTime ×tamp) 00030 { 00031 setData(0, TimestampRole, timestamp); 00032 } 00033 00034 QTime 00035 StatusEventItem::timestamp() const 00036 { 00037 return data(0, TimestampRole).toTime(); 00038 } 00039 00040 void 00041 StatusEventItem::setIcon(const QPixmap &pixmap) 00042 { 00043 setData(0, IconRole, pixmap); 00044 } 00045 00046 QPixmap 00047 StatusEventItem::icon() const 00048 { 00049 return data(0, IconRole).value<QPixmap>(); 00050 } 00051 00052 void 00053 StatusEventItem::setTitle(const QString &title) 00054 { 00055 setData(0, TitleRole, title); 00056 } 00057 00058 QString 00059 StatusEventItem::title() const 00060 { 00061 return data(0, TitleRole).toString(); 00062 } 00063 00064 void 00065 StatusEventItem::setDescription(const QString &description) 00066 { 00067 setData(0, DescriptionRole, description); 00068 } 00069 00070 QString 00071 StatusEventItem::description() const 00072 { 00073 return data(0, DescriptionRole).toString(); 00074 } 00075 00076 void 00077 StatusEventItem::setHelpUrl(const QString &url) 00078 { 00079 setData(0, HelpUrlRole, url); 00080 } 00081 00082 QString 00083 StatusEventItem::helpUrl() const 00084 { 00085 return data(0, HelpUrlRole).toString(); 00086 } 00087 00088 void 00089 StatusEventItem::setToolTip(const QString &toolTip) 00090 { 00091 QTreeWidgetItem::setToolTip(0, toolTip); 00092 } 00093 00094 QString 00095 StatusEventItem::toString() const 00096 { 00097 return QString("[%1] %2 - %3").arg(timestamp().toString()) 00098 .arg(title()) 00099 .arg(description()); 00100 } 00101 00102 bool 00103 StatusEventItem::operator<(const QTreeWidgetItem &other) const 00104 { 00105 QTime a = data(0, TimestampRole).toTime(); 00106 QTime b = other.data(0, TimestampRole).toTime(); 00107 00108 return (a < b); 00109 } 00110