-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjsonitem.cpp
97 lines (80 loc) · 1.92 KB
/
jsonitem.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "jsonitem.h"
#include <QtGlobal>
#include <QIcon>
#include "jsonobject.h"
JsonItem::JsonItem(JsonItem* parent){
parentItem = parent;
}
JsonItem::~JsonItem(){
}
JsonItem* JsonItem::child(int row){
Q_UNUSED(row);
return nullptr;
}
JsonItem* JsonItem::parent() const{
return parentItem;
}
int JsonItem::row(){
if (parentItem)
return parentItem->indexOf(this);
else
return 0;
}
int JsonItem::indexOf(JsonItem *item) const{
Q_UNUSED(item);
return 0;
}
int JsonItem::rowCount() const{
return 0;
}
QVariant JsonItem::data(int role, int column){
if (role == Qt::DisplayRole || role == Qt::EditRole){
if (column == 1)
return "null";
else
return parent()->labelForChild(this);
} else if (role == Qt::DecorationRole && column == 0)
return QIcon("://icons/null.svg");
else if (role == Qt::UserRole)
return QVariant::fromValue(type());
else
return QVariant();
}
QString JsonItem::labelForChild(JsonItem *child) const{
Q_UNUSED(child);
return "";
}
QJsonValue JsonItem::toJson() const{
return QJsonValue();
}
bool JsonItem::insertChild(QPair<QString, JsonItem *> child, int position){
Q_UNUSED(child);
Q_UNUSED(position);
return false;
}
ItemType JsonItem::type() const{
return ItemType::Null;
}
bool JsonItem::setData(const QVariant &data){
Q_UNUSED(data);
return false;
}
bool JsonItem::setLabelInContainer(QString label){
if (parentItem->type() == ItemType::Object){
JsonObject* parent = static_cast<JsonObject*>(parentItem);
return parent->setLabel(this, label);
} else
return false;
}
bool JsonItem::removeChildrenAt(int i){
Q_UNUSED(i);
return false;
}
bool JsonItem::appendItem(JsonItem *item, QString label){
Q_UNUSED(label);
Q_UNUSED(item);
return false;
}
void JsonItem::setParent(JsonItem* parent){
parentItem = parent;
}