-
Notifications
You must be signed in to change notification settings - Fork 0
/
croottreeitem.cpp
38 lines (28 loc) · 934 Bytes
/
croottreeitem.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
37
38
#include <QtNetwork>
#include "cglobals.h"
#include "ctreeitem.h"
#include "croottreeitem.h"
CRootTreeItem::CRootTreeItem(const QString &path, CTreeItem *parent):
CTreeItem(path, "ROOT", parent)
{
setHasChildren(true);
}
void CRootTreeItem::receiveListing()
{
DEBUG << "receiveListing(): path:" << m_path;
QNetworkReply *reply = static_cast<QNetworkReply*>(sender());
QByteArray data = reply->readAll();
QJsonParseError error;
QJsonDocument doc = QJsonDocument:: fromJson(data, &error);
QJsonObject obj = doc.object();
QJsonArray arr = obj.value("user_node_paths").toArray();
for(int i=0, count=arr.size(); i<count; i++) {
QJsonValue v = arr.at(i);
CTreeItem *item = new CTreeItem(v.toString(), v.toString(), this);
item->setIsFile(false);
item->setHasChildren(true);
//item->refresh();
appendChild(item);
}
emit refreshed();
}