-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrss.cpp
More file actions
56 lines (48 loc) · 1.45 KB
/
rss.cpp
File metadata and controls
56 lines (48 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "rss.h"
Rss::Rss(QWidget *parent) :
QWidget(parent)
{
/* Set up the network manager. */
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
openRssFeed();
}
QStringList Rss::showFeeds()
{
qDebug()<<"Feeds-:"<<feeds;
return feeds;
}
void Rss::getFeedDatas(QStringList list)
{
feeds<<list;
//qDebug()<<"FeedsGetFeed-:"<<feeds;
}
void Rss::openRssFeed()
{
/* Set the RSS URL */
reply = manager->get(QNetworkRequest(QUrl("http://localhost/feed.xml")));
}
void Rss::replyFinished(QNetworkReply * netReply)
{
QString str(netReply->readAll());
if (!doc.setContent(str, false, &error))
{
qDebug()<<"Error, Something terribly went wrong";
}
else
{
docElem = doc.documentElement();
nodeList = docElem.elementsByTagName("item");
for (uint i = 0; i < nodeList.length(); i++)
{
node = nodeList.item(i);
e = node.toElement();
strTitle = e.elementsByTagName("title").item(0).firstChild().nodeValue();
strLink = e.elementsByTagName("link").item(0).firstChild().nodeValue();
strDescription = e.elementsByTagName("description").item(0).firstChild().nodeValue();
feedDatas << strTitle << ":" << strLink << ":" << strDescription;
}
getFeedDatas(feedDatas);
}
//qDebug()<<"RSS -:" << feedDatas;
}