KSeExpr  4.0.4.0
ExprControlCollection.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2011-2019 Disney Enterprises, Inc.
2 // SPDX-License-Identifier: LicenseRef-Apache-2.0
3 // SPDX-FileCopyrightText: 2020 L. E. Segovia <amy@amyspark.me>
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 /*
6  * @file ExprControlCollection.h
7  * @brief Manages/creates a bunch of ExprControls by using expression text
8  * @author aselle
9  */
10 
11 #pragma once
12 
13 #include <QVBoxLayout>
14 #include <QWidget>
15 #include <vector>
16 
17 
18 #include "EditableExpression.h"
19 #include "ExprControl.h"
20 
24 class ExprControlCollection : public QWidget
25 {
26  Q_OBJECT
27 
28  int _linkedId{};
29  int count{};
30  bool showAddButton{};
31 
32  // holds a representation factored into the controls
34 
35 public:
36  ExprControlCollection(QWidget *parent = nullptr, bool showAddButton = true);
37  ~ExprControlCollection() override;
38 
39 private:
40  // TODO: put back
41  std::vector<ExprControl *> _controls;
42  QVBoxLayout *controlLayout;
43 
44 public:
46  void updateText(int id, QString &text);
48  bool rebuildControls(const QString &expressionText, std::vector<QString> &variables);
49 
52  {
53  return _controls.size();
54  }
55 
56  void showEditor(int idx);
57 
58 private Q_SLOTS:
60  void addControlDialog();
62  void singleControlChanged(int id);
64  void linkColorLink(int id);
66  void linkColorEdited(int id, QColor color);
67 Q_SIGNALS:
69  void controlChanged(int id);
71  void linkColorOutput(QColor color);
74  void insertString(const QString &controlString);
75 public Q_SLOTS:
78  void linkColorInput(QColor color);
79 };
Factors a SeExpr into an editable expression with controls (i.e. value boxes, curve boxes)
void controlChanged(int id)
Notification that a specific control was changed.
void updateText(int id, QString &text)
Request new text, given taking into account control id's new values.
bool rebuildControls(const QString &expressionText, std::vector< QString > &variables)
Rebuild the controls given the new expressionText. Return any local variables found.
void insertString(const QString &controlString)
void singleControlChanged(int id)
Notification when by a control whenever it is edited.
void linkColorOutput(QColor color)
Gives information about when a link color was changed.
ExprControlCollection(QWidget *parent=nullptr, bool showAddButton=true)
void addControlDialog()
When a user clicks "Add new variable" button.
std::vector< ExprControl * > _controls
void linkColorLink(int id)
Notification by a control that a new color link is desired.
int numControls()
Number of controls.
void linkColorEdited(int id, QColor color)
Notification by a control that a color is edited (when it is linked)
EditableExpression * editableExpression
void linkColorInput(QColor color)