Skui 0.0.1
Build fast and easy to use control software with Skui.
 
Loading...
Searching...
No Matches
document.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <QJsonObject>
5#include <QLoggingCategory>
6#include <QObject>
7
8#include "nodeeditor.hpp"
9#include "nodes/label.hpp"
10#include "nodes/lineedit.hpp"
11#include "nodes/serialsend.hpp"
12#include "nodes/slider.hpp"
13#include "nodes/textcombine.hpp"
14#include "panel.hpp"
15
22class Document : QObject
23{
24 Q_OBJECT
25
26public:
27 Document(QObject *parent = nullptr);
28 ~Document();
29
37 static Document *activeDocument() { return s_active_document; }
38
46 Panel *panel() const { return m_panel; }
47
55 NodeEditor *nodeEditor() const { return m_nodeeditor; }
56
64 QList<QString> availableNodes() const;
65
73 void createNode(const QString &name, const QPoint position_hint = QPoint(0, 0));
74
75 void deleteNode(Node *node);
76
77private:
78 const QMap<QString, std::function<Node *()>> m_node_factories
79 = {{"Label", [this]() { return new Label(this); }},
80 {"Slider", [this]() { return new Slider(this); }},
81 {"SerialSend", [this]() { return new SerialSend(this); }},
82 {"LineEdit", [this]() { return new LineEdit(this); }},
83 {"TextCombine", [this]() { return new TextCombine(this); }}};
84
85 Panel *m_panel = nullptr;
86 NodeEditor *m_nodeeditor = nullptr;
87 static Document *s_active_document;
88};
NodeEditor * nodeEditor() const
Returns the node editor of the document.
Definition document.hpp:55
Panel * panel() const
Returns the panel of the document.
Definition document.hpp:46
void deleteNode(Node *node)
Definition document.cpp:41
QList< QString > availableNodes() const
Returns the list of available node types.
Definition document.cpp:22
void createNode(const QString &name, const QPoint position_hint=QPoint(0, 0))
Creates a node of the specified type.
Definition document.cpp:27
~Document()
Definition document.cpp:16
Document(QObject *parent=nullptr)
Definition document.cpp:8
static Document * activeDocument()
Returns the active document.
Definition document.hpp:37
Definition label.hpp:8
Definition nodeeditor.hpp:12
Definition node.hpp:11
Definition panel.hpp:22