forked from adrienkaiser/DTIAtlasBuilder
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathHierarchyModel.h
74 lines (56 loc) · 2.49 KB
/
HierarchyModel.h
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
#ifndef __HIERARCHICALMODEL_H_
#define __HIERARCHICALMODEL_H_
#include <QStandardItemModel>
#include <QStandardItem>
#include <QModelIndex>
#include <QString>
#include "nlohmann/json.hpp"
//
// treemodel for hierarchical build
//
using json = nlohmann::json;
class CaseHierarchyModel : public QStandardItemModel{
public:
CaseHierarchyModel();
CaseHierarchyModel(QString);
CaseHierarchyModel(QString,bool);
~CaseHierarchyModel();
void initialize(QString);
void initializeFromFile(QString);
void loadFile(QString filename); // load json file to store json object
void saveFile(QString filename); // save caseHiearchy to file
void generateEntries(json ha); // build entries from hierarchy json obj
void generateEntries(); // regenerate from cseHierarchy
void addNode(QString); // add node to current node (m_currentItem)
void removeNode(QStandardItem* ); // remove node
void removeCurrentNode(); // remove current Node
int changeCurrentNode(QModelIndex idx,QString newName); // change current node's name, return 0 is success, 1 is there is same name
void removeNodeRecursivelyInJson(QString node); // remove a node and its child
bool checkNodename(QString); //check node name exists in the build file (1 : exists, 0 : not existing)
bool checkCaseExists(QString); // check if the node has datasetfile entries
bool isRoot(QString);// ceck if the tag is root node
bool checkValidity(); // check the hierarchy is valid (currently checking if end nodes has at least one case)
json getHierarchy(){return m_CaseHierarchy;}; // hierarchy
QStringList getFileList(QString node); // get the list of files of a node
QStringList getRootComponents(); // get component list
QStringList getAllCasePaths(); // get all actual case files list (for sanity check)
QStandardItem* getRoot(){return m_rootNode;};
void setCurrentTag(QModelIndex i);
QString getCurrentTag(){return m_currentTag;};
QString getCurrentType();
QStandardItem* getCurrentItem(){return m_currentItem;};
void setFiles(QString nodename, QStringList ql);
//void onItemChanged(const QModelIndex &);
QString toString(); // dump json
void update(); // set things updated
protected:
void expandNode(QStandardItem*,json);
QStringList readCSV(QString filename);// load csv file
private:
QString m_projectName; // Project target node
json m_CaseHierarchy; // hierarchy json object
QStandardItem* m_rootNode; //root node ("target")
QString m_currentTag; // current tag of a node
QStandardItem* m_currentItem; //current selected node's item
};
#endif