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
138protected:
139 base ( std::shared_ptr<editor_data_state> editordata, QWidget * parent =
140 nullptr, bool owned = false );
141
142 virtual void buildtooltip() = 0;
143 virtual void closeEvent ( QCloseEvent * Event );
144
145 std::shared_ptr<editor_data_state> p_data_editor;
146
148 QStringList this_data;
149
153
154signals:
159
160public slots:
161 virtual void slot_set_initial_loaded();
162
163};
164
165//------------------------------------------------------------------------------------------------
166
167
168//------------------------------------------------------------------------------------------------
169
170class relation: public base, private dbe::Ui::RelationshipForm
171{
172 Q_OBJECT
173
174public:
175
178
179 relation ( t_virtue const & relation, QWidget * parent = nullptr, bool owned = false );
180
181 bool GetIsMultiValue() const;
182
183 bool eventFilter ( QObject * Target, QEvent * Event );
184
185 void SetEditor() override;
186
187private:
188
189 void SetController();
190 void SetFirstItem();
191
192 void buildtooltip() override;
193
194 void CreateObjectEditor ( const std::string& objectID );
195
196 std::shared_ptr<t_build_block_editor> p_base_data_editor;
197
199
200 QStatusBar * StatusBar;
201 QStringList CurrentDataList;
202 QMenu * ContextMenu;
203 QAction * RemoveAction;
204 QAction * MoveTop;
205 QAction * MoveBottom;
206 QAction * MoveUp;
207 QAction * MoveDown;
208 QAction * EditAction;
209 QListWidgetItem * FirstItem;
210 QListWidgetItem * CurrentItem;
211
212private slots:
213 void FetchData();
214 void EndSignal();
215 void AddToDataList ( const QString & DataValue );
216 void RemoveFromDataList();
217 void UpdateActions();
218 void closeEvent ( QCloseEvent * Event );
219 void DataWasFetched ( QStringList ListOfObjects );
220 void CreateObjectEditor ( QListWidgetItem * Item );
221 void CustomContextMenuRequested ( const QPoint & pos );
222 void RemoveSlot();
223 void MoveTopSlot();
224 void MoveBottomSlot();
225 void MoveUpSlot();
226 void MoveDownSlot();
227 void EditSlot();
228 void DummyMovement();
229 void EditItemEntered ( QListWidgetItem * Item );
230
231signals:
232 void FetchDataDone ( QStringList Data );
234};
235
236//------------------------------------------------------------------------------------------------
237
238//------------------------------------------------------------------------------------------------
239
240class stringattr: public base, private Ui::StringAttributeWidgetForm
241{
242 Q_OBJECT
243
244public:
247
248 stringattr ( t_virtue const & attr, QWidget * parent = nullptr, bool owned = false );
249 ~stringattr();
250
251 void SetEditor() override;
252
253 QTextEdit * GetLineEdit() const;
254
255 void SetNullCheck ( bool Check );
256 void SetMultiCheck ( bool Multi );
257 void SetCheckDefaults ( bool Default );
258 void SetFocusOnLine();
259
260 bool eventFilter ( QObject * , QEvent * );
261 void ClearText();
262
263private:
264 void buildtooltip() override;
265 void closeEvent ( QCloseEvent * );
266 void SetController();
267 void setdefaults ( const QString & );
268 void ShowPopupButton();
269 void HidePopupButton();
270
271 std::shared_ptr<t_build_block_editor> m_base_data_editor;
272
274 QPushButton * PopUpButton;
275 QDialog * Dialog;
276 QPushButton * OkButtonDialog;
277 QPlainTextEdit * TextEditDialog;
278
279signals:
281
282private slots:
283 void UpdateActions ( );
284 void AddToDataList();
285 void ShowDialog();
286 void UpdateFromTextEdit();
288};
289
290//------------------------------------------------------------------------------------------------
291
292//------------------------------------------------------------------------------------------------
293
294class numericattr: public base, private Ui::NumericAttributeWidgetForm
295{
296 Q_OBJECT
297
298public:
301
302 numericattr ( t_virtue const & attr, QWidget * parent = nullptr, bool owned = false );
303
304 void SetEditor() override;
305
306 QLineEdit * GetLineEdit() const;
307
308 virtual void setdefaults ( const QString & ValueDefault );
309
310private:
311 void buildtooltip() override;
312 void closeEvent ( QCloseEvent * Event );
313 void SetController();
314 void ShowWarning ( QString Format = "", QString Range = "" );
315 bool ValidateIntegerValue ( QString const & );
316 bool ValidateFloatValue ( QString const & );
317 bool checkRange( QString const & );
318
319 std::shared_ptr<t_build_block_editor> this_base_data_editor;
320
323
324signals:
326
327private slots:
328 void checkIfDuplicated();
329 void AddToList();
330 void ChangeFormat ( int i );
331 void UpdateActions ( QString Dummy );
332 void ChangeFormatDec();
333 void ChangeFormatHex();
334 void ChangeFormatOct();
335};
336
337//------------------------------------------------------------------------------------------------
338
339//------------------------------------------------------------------------------------------------
340
341class combo: public base, public Ui::EditCombo
342{
343 Q_OBJECT
344
345public:
348
349 combo ( t_virtue const & attr, QWidget * parent = nullptr, bool owned = false );
350
351 void SetEditor() override;
352
353 void SetData ( QStringList const & );
354 void SetValidatorData ( QStringList const & Data, bool AcceptNoMatch = false );
355
356 void setdata ( QStringList const & );
357
358 QStringList getdata() override;
359
360private:
361 void buildtooltip() override;
362 bool eventFilter ( QObject *, QEvent * );
363 void wheelEvent ( QWheelEvent * );
364 void SetController();
365
366 std::shared_ptr<t_build_block_editor> m_base_data_editor;
367
368private slots:
369 void TryValidate ( QString );
370 void ChangeDetected ( QString const & );
371 void CheckDefaults ( int );
372 bool CompareDefaults();
373};
374
375//------------------------------------------------------------------------------------------------
376
377//------------------------------------------------------------------------------------------------
378
379class multiattr: public base
380{
381 Q_OBJECT
382
383public:
386
387 multiattr ( t_virtue const & attr, QWidget * parent = nullptr, bool owned = false );
388
389 void SetEditor() override;
390
391private:
392 void buildtooltip();
393 void closeEvent ( QCloseEvent * Event );
394 void SetStatusBar();
395 bool eventFilter ( QObject * Target, QEvent * Event );
396
397 std::shared_ptr<t_build_block_editor> m_base_data_editor;
398
399 QStatusBar * StatusBar;
400 QPushButton * OkButton;
401 QPushButton * RemoveButton;
402 QListWidget * ListWidget;
404 QMenu * ContextMenu;
405 QAction * RemoveAction;
406
407private slots:
408 void AddToDataList ( const QString & Data );
409 void RemoveFromDataList();
410 void UpdateActions();
411 void LineValueChanged();
412 void LineValueChanged ( QListWidgetItem * p );
413 void ListOrderChange ( const QModelIndexList & IndexList );
414 void EndSignal();
415 void CustomContextMenuRequested ( const QPoint & pos );
416 void RemoveSlot();
417};
418
419//------------------------------------------------------------------------------------------------
420} // end namespace editors
421} // end widgets
422
423
424}//end namespace dbe
425
426#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
combo(t_virtue const &attr, QWidget *parent=nullptr, bool owned=false)
void setdata(QStringList const &)
bool eventFilter(QObject *, QEvent *)
void SetData(QStringList const &)
void CustomContextMenuRequested(const QPoint &pos)
multiattr(t_virtue const &attr, QWidget *parent=nullptr, bool owned=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)
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)
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)
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.