-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTreeStateSaver.xcsm
More file actions
34 lines (27 loc) · 992 Bytes
/
Copy pathTreeStateSaver.xcsm
File metadata and controls
34 lines (27 loc) · 992 Bytes
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
//xlang Source, Name:TreeStateSaver.xcsm
//Date: Tue Nov 16:38:29 2019
class TreeStateSaver{
public static JsonNode saveState(@NotNilptr QTreeWidget tree, long parent){
JsonArray jsonitem = new JsonArray();
long [] items;
if (parent == 0){
items = tree.getTopItems();
}else{
items = tree.getItemChildren(parent);
}
if (items != nilptr){
for (int i = 0; i < items.length; i++){
JsonObject item = new JsonObject();
item.put("label", tree.getItemText(items[i], 0));
item.put("value", tree.getItemText(items[i], 2));
bool isExp = tree.isItemExpand(items[i]);
item.put("exp",isExp);
if (isExp){
item.put("child", saveState(tree, items[i]));
}
jsonitem.put(item);
}
}
return jsonitem;
}
};