-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathComponentFactory.h
62 lines (45 loc) · 1.52 KB
/
ComponentFactory.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
#ifndef COMPONENTFACTORY_H
#define COMPONENTFACTORY_H
#include "Enumerations.h"
#include <QFile>
#include <QJsonDocument>
#include <QObject>
#include <QStandardItemModel>
namespace q2d {
// forward declaration
class ApplicationContext;
class Document;
class DocumentEntry;
namespace metamodel {
class Category;
class HierarchyElement;
class ComponentDescriptor;
}
namespace model {
class Component;
class Model;
}
class ComponentFactory : public QObject {
Q_OBJECT
private:
QStandardItemModel m_componentHierarchy;
// TODO: does not belong here
void jsonToCategoryEntry(QJsonObject json, metamodel::Category* parent = nullptr);
void jsonToTypeEntry(QJsonObject json, metamodel::Category* parent);
void jsonToEntry(QJsonObject json, metamodel::Category* parent);
public:
explicit ComponentFactory(ApplicationContext* parent = 0);
QStandardItemModel* componentHierarchy();
metamodel::Category* categoryForIndex(const QModelIndex &index);
metamodel::ComponentDescriptor* componentDescriptor(const QModelIndex &index);
metamodel::ComponentDescriptor* componentDescriptor(const QString hierarchyName);
void importHierarchy(QJsonDocument source);
public slots:
void slot_loadType(QString filePath, metamodel::Category* parent);
metamodel::Category* slot_addCategory(QString name, metamodel::Category* parent);
void slot_clearHierarchy();
void slot_saveHierarchy(QString filePath);
void slot_loadHierarchy(QString filePath);
};
} // namespace q2d
#endif // COMPONENTFACTORY_H