/
feedmodel.cpp
36 lines (29 loc) · 896 Bytes
/
feedmodel.cpp
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
#include "feedmodel.h"
#include "resourcemanager.h"
#include "newsapplication.h"
FeedModel::FeedModel(QObject *parent) :
QStandardItemModel(parent)
{
}
bool FeedModel::initFromRPC(QVariant *resp)
{
QList<QVariant> elements(resp->toList());
for (int i = 0; i < elements.size(); ++i) {
// parse element
QMap<QString, QVariant> tags = elements[i].toMap();
QString rssTitle;
QString imageUrl;
int rssId;
rssTitle = tags.value("title").toString();
rssId = tags.value("iid").toInt();
imageUrl = tags.value("image").toString();
QStandardItem *item = new QStandardItem(rssTitle);
item->setCheckable( true );
if(!imageUrl.isEmpty()) {
ResourceManager *rm = static_cast<NewsApplication*>(qApp)->getRM();
}
item->setData(rssId);
// m_root->appendRow(item);
}
return true;
}