Microblog Library
20 #include "statusitem.h"
24 #include <QDomElement>
26 #include <QStringList>
28 #include <kpimutils/linklocator.h>
30 using namespace Microblog;
32 class StatusItem::Private :
public QSharedData
36 Private(
const Private& other ) : QSharedData( other ) {
38 status = other.status;
39 dateTime = other.dateTime;
45 QHash<QString, QString> status;
49 void StatusItem::Private::init()
51 QDomDocument document;
52 document.setContent( data );
53 QDomElement root = document.documentElement();
54 QDomNode node = root.firstChild();
55 while ( !node.isNull() ) {
56 const QString key = node.toElement().tagName();
57 if ( key ==
"user" || key ==
"sender" || key ==
"recipient" ) {
58 QDomNode node2 = node.firstChild();
59 while ( !node2.isNull() ) {
60 const QString key2 = node2.toElement().tagName();
61 const QString val2 = node2.toElement().text();
62 status[ key +
"_-_" + key2 ] = val2;
63 node2 = node2.nextSibling();
66 const QString value = node.toElement().text();
69 node = node.nextSibling();
73 dateTime = QDateTime::fromString( status.value(
"created_at" ).toLower().mid( 4 ),
74 "MMM dd H:mm:ss +0000 yyyy" );
75 dateTime.setTimeSpec( Qt::UTC );
76 dateTime = dateTime.toLocalTime();
78 if ( !dateTime.isValid() ) {
79 kDebug() <<
"Unable to parse" << status.value(
"created_at" ).toLower().mid( 4 );
104 if ( &other !=
this ) {
120 return d->status.value(
"id" ).toLongLong();
130 return d->status.value( value );
135 return d->status.keys();
140 using KPIMUtils::LinkLocator;
141 int flags = LinkLocator::PreserveSpaces | LinkLocator::HighlightText | LinkLocator::ReplaceSmileys;
142 return KPIMUtils::LinkLocator::convertToHtml( d->status.value(
"text" ), flags );
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:26:13 by
doxygen 1.8.3.1 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.