DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
BuildingBlockEditors.hpp
Go to the documentation of this file.
1#ifndef BUILDINGBLOCKEDITORS_H
2#define BUILDINGBLOCKEDITORS_H
3
4#include "conffwk/Schema.hpp"
5
6#include "ui_RelationshipWidgetForm.h"
7#include "ui_StringAttributeWidgetForm.h"
8#include "ui_NumericAttributeWidgetForm.h"
9#include "ui_EditCombo.h"
10
11#include <QWidget>
12#include <QStatusBar>
13#include <QPushButton>
14#include <QPlainTextEdit>
15#include <QMenu>
16#include <QAction>
17#include <QSortFilterProxyModel>
18
19#include<memory>
20
21namespace dbe
22{
23//------------------------------------------------------------------------------------------------
24
26{
27
28public:
30
31 bool is_valid() const
32 {
33 return m_valid;
34 }
35
36 bool must_not_be_null() const
37 {
38 return m_notnull;
39 }
40
41 bool must_be_set() const
42 {
43 return m_obligatory;
44 }
45
46protected:
47 explicit editor_data_state ( bool isvalid, bool isnotnull, bool isobligatory )
48 : m_valid ( isvalid ),
49 m_notnull ( isnotnull ),
50 m_obligatory ( isobligatory )
51 {}
52
53 bool m_valid;
56
57};
58
59//------------------------------------------------------------------------------------------------
60
61//------------------------------------------------------------------------------------------------
66template<typename T>
67
69{
70
71public:
72 typedef T t_virtue;
73
74 explicit editor_data ( T const & virtue )
75 : editor_data_state ( true, virtue.p_is_not_null, true ),
76 this_virtue ( virtue )
77 {}
78
79 virtual ~editor_data();
80
81 t_virtue const & get() const
82 {
83 return this_virtue;
84 }
85
86 void set_obligatory ( bool is )
87 {
88 m_obligatory = is;
89 }
90
91 void set_valid ( bool const is )
92 {
93 m_valid = is;
94 }
95
96 void set_not_null ( bool const is )
97 {
98 m_notnull = is;
99 }
100
101private:
103};
104
105//------------------------------------------------------------------------------------------------
106
107namespace widgets
108{
109namespace editors
110{
111//------------------------------------------------------------------------------------------------
112
113class base: public QWidget
114{
115 Q_OBJECT
116
117public:
118 virtual void SetEditor() = 0;
119
120 template<typename T = editor_data_state> std::shared_ptr<T> dataeditor()
121 {
122 return std::dynamic_pointer_cast<T> ( p_data_editor );
123 }
124
125 virtual void setdata ( QStringList const & );
126 virtual void setdefaults ( QString const & );
127
128 void setchanged ( bool );
129 bool ischanged() const;
130
131 virtual QStringList getdata();
132
133protected:
134 base ( std::shared_ptr<editor_data_state> editordata, QWidget * parent =
135 nullptr, bool owned = false );
136
137 virtual void buildtooltip() = 0;
138 virtual void closeEvent ( QCloseEvent * Event );
139
140 std::shared_ptr<editor_data_state> p_data_editor;
141
143 QStringList this_data;
144
148
149signals:
154
155public slots:
156 virtual void slot_set_initial_loaded();
157
158};
159
160//------------------------------------------------------------------------------------------------
161
162
163//------------------------------------------------------------------------------------------------
164
165class relation: public base, private dbe::Ui::RelationshipForm
166{
167 Q_OBJECT
168
169public:
170
173
174 relation ( t_virtue const & relation, QWidget * parent = nullptr, bool owned = false );
175
176 bool GetIsMultiValue() const;
177
178 bool eventFilter ( QObject * Target, QEvent * Event );
179
180 void SetEditor() override;
181
182private:
183
184 void SetController();
185 void SetFirstItem();
186
187 void buildtooltip() override;
188
189 void CreateObjectEditor ( const std::string& objectID );
190
191 std::shared_ptr<t_build_block_editor> p_base_data_editor;
192
194
195 QStatusBar * StatusBar;
196 QStringList CurrentDataList;
197 QMenu * ContextMenu;
198 QAction * RemoveAction;
199 QAction * MoveTop;
200 QAction * MoveBottom;
201 QAction * MoveUp;
202 QAction * MoveDown;
203 QAction * EditAction;
204 QListWidgetItem * FirstItem;
205 QListWidgetItem * CurrentItem;
206
207private slots:
208 void FetchData();
209 void EndSignal();
210 void AddToDataList ( const QString & DataValue );
211 void RemoveFromDataList();
212 void UpdateActions();
213 void closeEvent ( QCloseEvent * Event );
214 void DataWasFetched ( QStringList ListOfObjects );
215 void CreateObjectEditor ( QListWidgetItem * Item );
216 void CustomContextMenuRequested ( const QPoint & pos );
217 void RemoveSlot();
218 void MoveTopSlot();
219 void MoveBottomSlot();
220 void MoveUpSlot();
221 void MoveDownSlot();
222 void EditSlot();
223 void DummyMovement();
224 void EditItemEntered ( QListWidgetItem * Item );
225
226signals:
227 void FetchDataDone ( QStringList Data );
229};
230
231//------------------------------------------------------------------------------------------------
232
233//------------------------------------------------------------------------------------------------
234
235class stringattr: public base, private Ui::StringAttributeWidgetForm
236{
237 Q_OBJECT
238
239public:
242
243 stringattr ( t_virtue const & attr, QWidget * parent = nullptr, bool owned = false );
244 ~stringattr();
245
246 void SetEditor() override;
247
248 QTextEdit * GetLineEdit() const;
249
250 void SetNullCheck ( bool Check );
251 void SetMultiCheck ( bool Multi );
252 void SetCheckDefaults ( bool Default );
253 void SetFocusOnLine();
254
255 bool eventFilter ( QObject * , QEvent * );
256 void ClearText();
257
258private:
259 void buildtooltip() override;
260 void closeEvent ( QCloseEvent * );
261 void SetController();
262 void setdefaults ( const QString & );
263 void ShowPopupButton();
264 void HidePopupButton();
265
266 std::shared_ptr<t_build_block_editor> m_base_data_editor;
267
269 QPushButton * PopUpButton;
270 QDialog * Dialog;
271 QPushButton * OkButtonDialog;
272 QPlainTextEdit * TextEditDialog;
273
274signals:
276
277private slots:
278 void UpdateActions ( );
279 void AddToDataList();
280 void ShowDialog();
281 void UpdateFromTextEdit();
283};
284
285//------------------------------------------------------------------------------------------------
286
287//------------------------------------------------------------------------------------------------
288
289class numericattr: public base, private Ui::NumericAttributeWidgetForm
290{
291 Q_OBJECT
292
293public:
296
297 numericattr ( t_virtue const & attr, QWidget * parent = nullptr, bool owned = false );
298
299 void SetEditor() override;
300
301 QLineEdit * GetLineEdit() const;
302
303 virtual void setdefaults ( const QString & ValueDefault );
304
305private:
306 void buildtooltip() override;
307 void closeEvent ( QCloseEvent * Event );
308 void SetController();
309 void ShowWarning ( QString Format = "", QString Range = "" );
310 bool ValidateIntegerValue ( QString const & );
311 bool ValidateFloatValue ( QString const & );
312 bool checkRange( QString const & );
313
314 std::shared_ptr<t_build_block_editor> this_base_data_editor;
315
318
319signals:
321
322private slots:
323 void checkIfDuplicated();
324 void AddToList();
325 void ChangeFormat ( int i );
326 void UpdateActions ( QString Dummy );
327 void ChangeFormatDec();
328 void ChangeFormatHex();
329 void ChangeFormatOct();
330};
331
332//------------------------------------------------------------------------------------------------
333
334//------------------------------------------------------------------------------------------------
335
336class combo: public base, public Ui::EditCombo
337{
338 Q_OBJECT
339
340public:
343
344 combo ( t_virtue const & attr, QWidget * parent = nullptr, bool owned = false );
345
346 void SetEditor() override;
347
348 void SetData ( QStringList const & );
349 void SetValidatorData ( QStringList const & Data, bool AcceptNoMatch = false );
350
351 void setdata ( QStringList const & );
352
353 QStringList getdata() override;
354
355private:
356 void buildtooltip() override;
357 bool eventFilter ( QObject *, QEvent * );
358 void wheelEvent ( QWheelEvent * );
359 void SetController();
360
361 std::shared_ptr<t_build_block_editor> m_base_data_editor;
362
363private slots:
364 void TryValidate ( QString );
365 void ChangeDetected ( QString const & );
366 void CheckDefaults ( int );
367 bool CompareDefaults();
368};
369
370//------------------------------------------------------------------------------------------------
371
372//------------------------------------------------------------------------------------------------
373
374class multiattr: public base
375{
376 Q_OBJECT
377
378public:
381
382 multiattr ( t_virtue const & attr, QWidget * parent = nullptr, bool owned = false );
383
384 void SetEditor() override;
385
386private:
387 void buildtooltip();
388 void closeEvent ( QCloseEvent * Event );
389 void SetStatusBar();
390 bool eventFilter ( QObject * Target, QEvent * Event );
391
392 std::shared_ptr<t_build_block_editor> m_base_data_editor;
393
394 QStatusBar * StatusBar;
395 QPushButton * OkButton;
396 QPushButton * RemoveButton;
397 QListWidget * ListWidget;
399 QMenu * ContextMenu;
400 QAction * RemoveAction;
401
402private slots:
403 void AddToDataList ( const QString & Data );
404 void RemoveFromDataList();
405 void UpdateActions();
406 void LineValueChanged();
407 void LineValueChanged ( QListWidgetItem * p );
408 void ListOrderChange ( const QModelIndexList & IndexList );
409 void EndSignal();
410 void CustomContextMenuRequested ( const QPoint & pos );
411 void RemoveSlot();
412};
413
414//------------------------------------------------------------------------------------------------
415} // end namespace editors
416} // end widgets
417
418
419}//end namespace dbe
420
421#endif // BUILDINGBLOCKEDITORS_H
virtual ~editor_data_state()
editor_data_state(bool isvalid, bool isnotnull, bool isobligatory)
void set_not_null(bool const is)
void set_valid(bool const is)
t_virtue const & get() const
virtual ~editor_data()
editor_data(T const &virtue)
virtual void setdata(QStringList const &)
virtual void SetEditor()=0
base(std::shared_ptr< editor_data_state > editordata, QWidget *parent=nullptr, bool owned=false)
std::shared_ptr< editor_data_state > p_data_editor
virtual void closeEvent(QCloseEvent *Event)
virtual void buildtooltip()=0
virtual void setdefaults(QString const &)
void SetValidatorData(QStringList const &Data, bool AcceptNoMatch=false)
std::shared_ptr< t_build_block_editor > m_base_data_editor
editor_data< t_virtue > t_build_block_editor
combo(t_virtue const &attr, QWidget *parent=nullptr, bool owned=false)
void setdata(QStringList const &)
dunedaq::conffwk::attribute_t t_virtue
bool eventFilter(QObject *, QEvent *)
void SetData(QStringList const &)
void CustomContextMenuRequested(const QPoint &pos)
dunedaq::conffwk::attribute_t t_virtue
multiattr(t_virtue const &attr, QWidget *parent=nullptr, bool owned=false)
std::shared_ptr< t_build_block_editor > m_base_data_editor
bool eventFilter(QObject *Target, QEvent *Event)
void ListOrderChange(const QModelIndexList &IndexList)
editor_data< t_virtue > t_build_block_editor
numericattr(t_virtue const &attr, QWidget *parent=nullptr, bool owned=false)
virtual void setdefaults(const QString &ValueDefault)
std::shared_ptr< t_build_block_editor > this_base_data_editor
void ShowWarning(QString Format="", QString Range="")
dunedaq::conffwk::attribute_t t_virtue
void DataWasFetched(QStringList ListOfObjects)
dunedaq::conffwk::relationship_t t_virtue
relation(t_virtue const &relation, QWidget *parent=nullptr, bool owned=false)
void AddToDataList(const QString &DataValue)
void CustomContextMenuRequested(const QPoint &pos)
void FetchDataDone(QStringList Data)
std::shared_ptr< t_build_block_editor > p_base_data_editor
void CreateObjectEditor(const std::string &objectID)
editor_data< t_virtue > t_build_block_editor
void EditItemEntered(QListWidgetItem *Item)
bool eventFilter(QObject *Target, QEvent *Event)
stringattr(t_virtue const &attr, QWidget *parent=nullptr, bool owned=false)
std::shared_ptr< t_build_block_editor > m_base_data_editor
dunedaq::conffwk::attribute_t t_virtue
Include QT Headers.