No more duplicate items, huzzah! (via ugly hack!)
[squawker.git] / timelinehandler.cpp
blob2aa36261eab4e36476f334d3c3d97d3ffd3f4fc4
1 #include "timelinehandler.h"
2 #include <QDebug>
3 #include <QMessageBox>
4 #include <QDateTime>
6 TimelineHandler::TimelineHandler()
8 status = new QStandardItem();
9 inUserTag = false;
12 bool TimelineHandler::startElement(const QString & /* namespaceURI */,
13 const QString &localName,
14 const QString &,//qName
15 const QXmlAttributes &) //Attributes
17 if (localName == "status")
18 status = new QStandardItem();
19 if (localName == "user")
20 inUserTag = true;
22 // qDebug() << "Startelement " << localName ;
23 currentText.clear();
24 return true;
27 bool TimelineHandler::endElement(const QString & /* namespaceURI */,
28 const QString &localName,
29 const QString &) //qName
31 if (localName == "status")
32 emit result(status);
34 if (inUserTag)
36 if (localName == "user")
37 inUserTag = false;
38 if (localName == "id")
39 status->setData( currentText.toInt(), UserId);
40 if (localName == "name")
41 status->setData( currentText, Name);
42 if (localName == "screen_name")
43 status->setData( currentText, Screen_name);
44 if (localName == "location")
45 status->setData( currentText, Location);
46 if (localName == "description")
47 status->setData( currentText, Description);
48 if (localName == "profile_image_url")
49 status->setData( currentText, Profile_image_url);
50 if (localName == "url")
51 status->setData( currentText, Url);
53 else
55 if (localName == "created_at")
56 status->setData( QDateTime::fromString(currentText, "ddd MMM dd hh:mm:ss +0000 yyyy"), Created_at);
57 if (localName == "text")
58 status->setData( currentText, Text);
59 if (localName == "id")
60 status->setData( currentText.toInt(), Id);
63 // qDebug() << "EndElement " << qName << "and " << currentText;
64 return true;
67 bool TimelineHandler::fatalError(const QXmlParseException &) //exception
69 qDebug() << "Fatal XML error occured";
70 return false;
73 QString TimelineHandler::errorString() const
75 return errorStr;
78 bool TimelineHandler::characters(const QString &str)
80 currentText += str;
81 return true;