ifw-fcf  4.1.0-pre2
device.h
Go to the documentation of this file.
1 
9 #ifndef DEVICE_WDG_H
10 #define DEVICE_WDG_H
11 
13 #include <fcf/gui/wdglib/spinner.h>
14 
15 #include <utils/bat/dbInterface.hpp>
16 
17 #include <QWidget>
18 #include <QtWidgets/QLabel>
19 #include <QObject>
20 
21 class QGroupBox;
22 class QLabel;
23 class QTextEdit;
24 class QLineEdit;
25 class QPushButton;
26 class QCheckBox;
27 class QComboBox;
28 class QListWidget;
29 class QRadioButton;
30 class QSpinBox;
31 class QDoubleSpinBox;
32 
33 struct CommonUi {
34 public:
35 
36  explicit CommonUi() :
37  m_spinner(nullptr) {};
38 
39  void SetName(QLabel* name) {
40  m_name = name;
41  }
42 
43  QLabel* GetName() {
44  return m_name;
45  }
46 
47  void SetEnable(QCheckBox* enable) {
48  m_enable = enable;
49  }
50 
51  QCheckBox* GetEnable() {
52  return m_enable;
53  }
54 
55  void SetSpinner(Spinner* spinner) {
56  m_spinner = spinner;
57  }
58 
60  return m_spinner;
61  }
62 
63  void SetState(QLabel* state) {
64  m_state = state;
65  }
66 
67  QLabel* GetState() {
68  return m_state;
69  }
70 
71  void SetSubstate(QLabel* substate) {
72  m_substate = substate;
73  }
74 
75  QLabel* GetSubstate() {
76  return m_substate;
77  }
78 
79  void SetSim(QPushButton* sim) {
80  m_sim = sim;
81  }
82 
83  QPushButton* GetSim() {
84  return m_sim;
85  }
86 
87  void SetLocal(QPushButton* local) {
88  m_local = local;
89  }
90 
91  QPushButton* GetLocal() {
92  return m_local;
93  }
94 
95 
96  void SetFrame(QFrame* frame) {
97  m_frame = frame;
98  }
99 
100  QFrame* GetFrame() {
101  return m_frame;
102  }
103 
104 private:
105  QLabel* m_name;
106  QCheckBox* m_enable;
107  Spinner* m_spinner;
108  QLabel* m_state;
109  QLabel* m_substate;
110  QPushButton* m_sim;
111  QPushButton* m_local;
112  QFrame* m_frame;
113 
114 };
115 
116 class DeviceWdg : public AbstractDevice {
117  Q_OBJECT
118 public:
119  explicit DeviceWdg(QWidget *parent,
120  std::unique_ptr<utils::bat::DbInterface>& dbinterface,
121  const std::string& name,
122  const int& cmd_timeout);
123  virtual ~DeviceWdg();
124  std::string GetName();
125  void Select();
126  void Deselect();
127  bool IsSelected();
128  virtual void Stop();
129  virtual void GetDbAttributes();
130  virtual void UpdateData();
131  virtual void SetEnable(bool flag);
132 
133 protected:
134  void SetupCommonUi();
135  void SetupInfoUi(const std::string& overview,
136  const std::string& desc);
137  bool IsSimulated();
138  void SetProperty(QPushButton* button, std::string property, bool flag);
139  void SetProperty(QRadioButton* button, std::string property, bool flag);
140  void SetProperty(QLabel* label, std::string property, bool flag);
141  void SetProperty(QComboBox* combo, std::string property, bool flag);
142  void SetProperty(QSpinBox* spin, std::string property, bool flag);
143  void SetProperty(QDoubleSpinBox* spin, std::string property, bool flag);
144 
145 signals:
146  void TriggerSetup(QString);
147 
148 public slots:
149  void SetActive(int index);
150  void UpdateState(int state);
151  bool UpdateSubstate(int substate);
152  void UpdateSpinner(int substate);
153  void UpdateErrorMsg(std::string msg);
154  void HandleSetupButton();
155 
156 
157 protected:
159  std::unique_ptr<utils::bat::DbInterface>& m_dbinterface;
160  std::string m_name;
163  std::string m_lcs_prefix;
164  std::string m_cfg_prefix;
165  std::vector<std::string> m_dbattribute_vector;
167 
168 };
169 
170 #endif // DEVICE_WDG_H
DeviceWdg::SetupInfoUi
void SetupInfoUi(const std::string &overview, const std::string &desc)
Definition: device.cpp:68
DeviceWdg::SetProperty
void SetProperty(QPushButton *button, std::string property, bool flag)
Definition: device.cpp:258
DeviceWdg::UpdateState
void UpdateState(int state)
Definition: device.cpp:153
CommonUi::GetSpinner
Spinner * GetSpinner()
Definition: device.h:59
DeviceWdg::m_cmd_timeout
int m_cmd_timeout
Definition: device.h:161
DeviceWdg::SetActive
void SetActive(int index)
Definition: device.cpp:91
DeviceWdg::m_lcs_prefix
std::string m_lcs_prefix
Definition: device.h:163
CommonUi::CommonUi
CommonUi()
Definition: device.h:36
DeviceWdg::Stop
virtual void Stop()
Definition: device.cpp:172
DeviceWdg::GetDbAttributes
virtual void GetDbAttributes()
Definition: device.cpp:182
DeviceWdg::SetEnable
virtual void SetEnable(bool flag)
Definition: device.cpp:247
CommonUi::GetEnable
QCheckBox * GetEnable()
Definition: device.h:51
CommonUi::GetName
QLabel * GetName()
Definition: device.h:43
AbstractDevice
Definition: abstractDevice.h:21
spinner.h
DeviceWdg::IsSimulated
bool IsSimulated()
Definition: device.cpp:324
DeviceWdg::GetName
std::string GetName()
Definition: device.cpp:74
Spinner
Definition: spinner.h:29
DeviceWdg::m_ui
CommonUi m_ui
Definition: device.h:166
CommonUi::GetFrame
QFrame * GetFrame()
Definition: device.h:100
DeviceWdg::SetupCommonUi
void SetupCommonUi()
Definition: device.cpp:48
DeviceWdg::m_dbattribute_vector
std::vector< std::string > m_dbattribute_vector
Definition: device.h:165
DeviceWdg::m_dbinterface
std::unique_ptr< utils::bat::DbInterface > & m_dbinterface
Definition: device.h:159
DeviceWdg::UpdateData
virtual void UpdateData()
Definition: device.cpp:201
CommonUi::SetLocal
void SetLocal(QPushButton *local)
Definition: device.h:87
DeviceWdg::Select
void Select()
Definition: device.cpp:78
DeviceWdg::DeviceWdg
DeviceWdg(QWidget *parent, std::unique_ptr< utils::bat::DbInterface > &dbinterface, const std::string &name, const int &cmd_timeout)
Definition: device.cpp:26
CommonUi::SetEnable
void SetEnable(QCheckBox *enable)
Definition: device.h:47
DeviceWdg::HandleSetupButton
void HandleSetupButton()
Definition: device.cpp:177
CommonUi::SetSim
void SetSim(QPushButton *sim)
Definition: device.h:79
abstractDevice.h
WDGLIB AbstractDevice class declaration file.
DeviceWdg::m_name
std::string m_name
Definition: device.h:160
CommonUi::SetSpinner
void SetSpinner(Spinner *spinner)
Definition: device.h:55
DeviceWdg::m_cfg_prefix
std::string m_cfg_prefix
Definition: device.h:164
DeviceWdg::UpdateSubstate
bool UpdateSubstate(int substate)
Definition: device.cpp:96
CommonUi::GetSubstate
QLabel * GetSubstate()
Definition: device.h:75
CommonUi::GetState
QLabel * GetState()
Definition: device.h:67
CommonUi::GetSim
QPushButton * GetSim()
Definition: device.h:83
CommonUi::SetSubstate
void SetSubstate(QLabel *substate)
Definition: device.h:71
DeviceWdg::Deselect
void Deselect()
Definition: device.cpp:82
CommonUi::SetName
void SetName(QLabel *name)
Definition: device.h:39
CommonUi::SetState
void SetState(QLabel *state)
Definition: device.h:63
DeviceWdg::m_spinner_timer
QTimer * m_spinner_timer
Definition: device.h:158
DeviceWdg::m_simulated
bool m_simulated
Definition: device.h:162
DeviceWdg::~DeviceWdg
virtual ~DeviceWdg()
Definition: device.cpp:44
DeviceWdg::IsSelected
bool IsSelected()
Definition: device.cpp:86
DeviceWdg::UpdateSpinner
void UpdateSpinner(int substate)
Definition: device.cpp:129
CommonUi::SetFrame
void SetFrame(QFrame *frame)
Definition: device.h:96
DeviceWdg::TriggerSetup
void TriggerSetup(QString)
CommonUi
Definition: device.h:33
CommonUi::GetLocal
QPushButton * GetLocal()
Definition: device.h:91
DeviceWdg::UpdateErrorMsg
void UpdateErrorMsg(std::string msg)
Definition: device.cpp:168
DeviceWdg
Definition: device.h:116