ExpressionEditorWidget.hpp
1 #pragma once
2 #include <State/Expression.hpp>
3 
4 #include <Scenario/Inspector/ExpressionValidator.hpp>
5 
6 #include <QString>
7 #include <QWidget>
8 
9 #include <verdigris>
10 
11 namespace score
12 {
13 struct DocumentContext;
14 }
15 /* ****************************************************************
16  * This class contain an aggregation of simples expressions.
17  *
18  * We assume that the global expression is "linear"
19  * (without parenthesis)
20  *
21  * ****************************************************************/
22 
23 class QVBoxLayout;
24 class QMenu;
25 
26 namespace Scenario
27 {
28 class SimpleExpressionEditorWidget;
29 
30 // TODO move in State lib
31 class ExpressionEditorWidget : public QWidget
32 {
33  W_OBJECT(ExpressionEditorWidget)
34 public:
35  explicit ExpressionEditorWidget(
36  const score::DocumentContext& doc, QWidget* parent = nullptr);
37 
38  State::Expression expression();
39  void setExpression(State::Expression e);
40  void setMenu(QMenu* btn);
41 
42  void addNewTerm();
43  void addNewTermAndFinish();
44  void on_editFinished();
45 
46 public:
47  void editingFinished() W_SIGNAL(editingFinished);
48  void resetExpression() W_SIGNAL(resetExpression);
49 
50 private:
51  // void on_operatorChanged(int i);
52  // TODO on_modelChanged()
53 
54  void exploreExpression(State::Expression e);
55 
56  QString currentExpr();
57  void removeTerm(int index);
58  void removeTermAndFinish(int index);
59 
60  const score::DocumentContext& m_context;
61  std::vector<SimpleExpressionEditorWidget*> m_relations;
62 
63  QVBoxLayout* m_mainLayout{};
64 
65  QMenu* m_menu{};
66 
67  QString m_expression{};
68 };
69 }
Definition: ExpressionEditorWidget.hpp:32
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: DocumentContext.hpp:18