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