NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
headerview.h
1 #ifndef HEADERVIEW_H
2 #define HEADERVIEW_H
3 
4 // Widget to edit motionName, preState, playState, postState
5 // If some variable is being set to invalid value, corresponding QLineEdit becomes red
6 // If value is valid, QLineEdit is white
7 // Author: Dmytro Pavlichenko <dm.mark999@gmail.com>
8 
9 #include <QWidget>
10 #include <QObject>
11 
12 struct HeaderData
13 {
14  std::string motion_name;
15 
16  std::string pre_state;
17  std::string play_state;
18  std::string post_state;
19 
20  bool pid_enabled;
21 };
22 
23 namespace Ui
24 {
25  class HeaderView;
26 }
27 
28 class HeaderView : public QWidget
29 {
30 Q_OBJECT
31 public:
32  HeaderView(QWidget *parent = 0);
33  virtual ~HeaderView();
34 
35  void enableEdit(bool flag); // set all edits editable/not editable
36  void setValues(std::string const name, std::string const preState
37  , std::string const playState, std::string const postState, bool pidEnabled);
38 
39  // If values are valid - return true. If not - show warning and ask if user still would like to save it
40  // If user click 'yes' - return true. Otherwise - false
41  bool requestSave();
42 
43  void setFileName(QString name);
44  std::string getFileNameFromPath(QString path); // Parse name from full path to file
45 
46  std::string getMotionName();
47  std::string getPreState();
48  std::string getPlayState();
49  std::string getPostState();
50  std::string getNameForMirrored();
51 
52  double getFactor();
53  bool getPIDEnabled();
54 
55  QString getFileName();
56  QString getWarningString(); // String includes warning for each invalid value. Empty if everything is ok
57 
58 Q_SIGNALS:
59  void dataChanged(HeaderData); // Emmited when data is changed
60  void pidEnabledChanged(bool);
61 
62 public Q_SLOTS:
63  void setData(HeaderData data);
64 
65 private Q_SLOTS:
66  void checkValues();
67  void handleFieldChanged();
68 
69 private:
70  Ui::HeaderView *ui;
71 
72  QString fileName; // Name of file without ".yaml"
73  QString warningString;
74 };
75 
76 
77 #endif // HEADERVIEW_H