Loading...
Searching...
No Matches
SimpleExpressionEditorWidget.hpp
1#pragma once
2
3#include <State/Expression.hpp>
4
5#include <Scenario/Inspector/ExpressionValidator.hpp>
6
7#include <QString>
8#include <QWidget>
9
10#include <verdigris>
11
12namespace score
13{
14struct DocumentContext;
15}
16class QComboBox;
17class QLabel;
18class QLineEdit;
19class QToolButton;
20class QMenu;
21namespace Process
22{
23class AddressAccessorEditWidget;
24}
25
26namespace Scenario
27{
28
29enum ExpressionEditorComparator
30{
31 // Same as in Relation
32 Equal,
33 Different,
34 Greater,
35 Lower,
36 GreaterEqual,
37 LowerEqual,
38 Contains,
39
40 // Additional ones
41 Pulse,
42 AlwaysTrue,
43 AlwaysFalse
44};
45
46class SimpleExpressionEditorWidget final : public QWidget
47{
49public:
51 const score::DocumentContext&, int64_t index, QWidget* parent = nullptr,
52 QMenu* menu = nullptr);
53
54 State::Expression relation();
55 std::optional<State::BinaryOperator> binOperator();
56
57 int64_t id = -1;
58
59 void setRelation(const State::Relation& r);
60 void setPulse(const State::Pulse& r);
61 void setOperator(State::BinaryOperator o);
62 void setOperator(State::UnaryOperator u);
63
64 QString currentRelation();
65 QString currentOperator();
66
67 void enableRemoveButton(bool);
68 void enableAddButton(bool);
69 void enableMenuButton(bool);
70
71 void decreaseId();
72
73public:
74 void editingFinished() W_SIGNAL(editingFinished);
75 void addTerm() W_SIGNAL(addTerm);
76 void removeTerm(int index) W_SIGNAL(removeTerm, index);
77
78private:
79 void on_editFinished();
80 void on_comparatorChanged(int i);
81 // TODO on_modelChanged() -> done in parent inspector (i.e. event), no ?
82
83 QLabel* m_ok{};
84
86 QComboBox* m_comparator{};
87 QLineEdit* m_value{};
88 QComboBox* m_binOperator{};
89 QToolButton* m_rmBtn{};
90 QToolButton* m_addBtn{};
91 QToolButton* m_menuBtn{};
92
94 QString m_relation{};
95 QString m_op{};
96};
97}
98
99Q_DECLARE_METATYPE(Scenario::ExpressionEditorComparator)
100W_REGISTER_ARGTYPE(Scenario::ExpressionEditorComparator)
Definition ExpressionValidator.hpp:10
Definition AddressAccessorEditWidget.hpp:28
Definition SimpleExpressionEditorWidget.hpp:47
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13
Base toolkit upon which the software is built.
Definition Application.cpp:90
Definition Relation.hpp:71
Definition Relation.hpp:19
Definition DocumentContext.hpp:18