Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
properties_menu.h
1#pragma once
2
3#include <QFrame>
4#include <memory>
5
6#include "../menu_base.h"
7#include "config.h"
8#include "result.h"
9#include "save_info.h"
10#include "widgets/frame.h"
11#include "widgets/widget_factory.h"
12
13class Flow;
14class NodeItem;
15class QDialog;
16class QLayout;
17class QStandardItemModel;
18class QTableView;
19class TransitionItem;
20
21class FlowSaveInfo;
22class PropertyInfo;
23
51class PropertiesMenu : public QFrame, public MenuBase
52{
53 Q_OBJECT
54
55public:
56 PropertiesMenu(QWidget* parent);
57
58 VoidResult start(std::shared_ptr<SaveInfo> storage);
59
60 VoidResult onNodeAdded(NodeItem* node) override;
61 VoidResult onNodeRemoved(const QString& nodeId) override;
62 VoidResult onNodeModified(NodeItem* node) override;
63 VoidResult onNodeSelected(NodeItem* node, bool selected) override;
64
65 VoidResult onTransitionSelected(TransitionItem* transition);
66 VoidResult onFlowAdded(Flow* flow, NodeItem* node);
67 VoidResult onCreateEvent(NodeItem* node);
68 VoidResult onFlowRemoved(const QString& flowId, NodeItem* node);
69
70 QLayout* layout() const;
71
72signals:
73 void openParameter(const QString& parameterId);
74 void nodeFocused(const QString& nodeId);
75 void flowSelected(const QString& flowId, const QString& nodeId);
76 void flowRemoved(const QString& flowId, const QString& nodeId);
77
78private:
79 enum TableRole
80 {
81 IdRole = Qt::UserRole,
82 ModifiableRole = Qt::UserRole + 1,
83 };
84
85 QString mCurrentNode;
86 QDialog* mCurrentDialog = nullptr;
87 std::shared_ptr<SaveInfo> mStorage;
88 StyledFrame* mFrame = nullptr;
89
90 // Property editors.
91 VoidResult loadProperties(NodeItem* node);
92 VoidResult loadValueProperty(const std::shared_ptr<IParameter>& property, NodeItem* node);
93 VoidResult loadColorProperty(const std::shared_ptr<IParameter>& property, NodeItem* node);
94 VoidResult loadSelectProperty(const std::shared_ptr<IParameter>& property, NodeItem* node);
95 VoidResult loadComponentSelectProperty(const std::shared_ptr<IParameter>& property, NodeItem* node);
96
97 VoidResult loadCallArguments(const std::shared_ptr<FlowSaveInfo>& call, const QString& propertyId, NodeItem* node, maki::WidgetGroup* group);
98
99 void addCompleter(maki::InputWidget* editor, const QString& nodeId, const koda::types::TypeReference& type, QStringList additionalValues = {});
100
101 // Controls for dynamically defined fields/events.
102 VoidResult loadControls(NodeItem* node);
103 Result<QTableWidget*> loadEventTable(NodeItem* node);
104 VoidResult loadControlAddEvent(QTableWidget* table, NodeItem* node);
105
106 void openEventDialog(QTableWidget* table, NodeItem* node, int row);
107 void addEventToTable(QTableWidget* table, int row, const std::shared_ptr<FlowSaveInfo>& event);
108 void removeEventFromTable(QTableWidget* table, NodeItem* node);
109
110 void updateBlockName(NodeItem* node, const QString& componentName, const QString& eventName) const;
111
112 std::shared_ptr<IFlow> getFlowConfigOfRow(const NodeItem* node, QTableWidget* table, int row) const;
113};
Represents the save information for a flow.
Definition flow_info.h:15
Represents a flow in the system.
Definition flow.h:17
Definition menu_base.h:10
Represents a graphical node item in a flowchart.
Definition node.h:26
Represents a property with configuration and options.
Definition property_info.h:16
Definition frame.h:10
Represents a transition between two nodes in a graphical representation.
Definition transition.h:15
Definition widget_factory.h:203
A labelled container widget that groups widgets in a generic layout.
Definition widget_factory.h:146