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_EditCombo.h"
12#include "ui_NumericAttributeWidgetForm.h"
13#include "ui_RelationshipWidgetForm.h"
14#include "ui_StringAttributeWidgetForm.h"
15
16#include <QAction>
17#include <QMenu>
18#include <QPlainTextEdit>
19#include <QPushButton>
20#include <QSortFilterProxyModel>
21#include <QStatusBar>
22#include <QWidget>
23
24#include <memory>
25
26namespace dbe {
27//------------------------------------------------------------------------------------------------
28
30{
31
32public:
34
35 bool is_valid() const { return m_valid; }
36
37 bool must_not_be_null() const { return m_notnull; }
38
39 bool must_be_set() const { return m_obligatory; }
40
41protected:
42 explicit editor_data_state(bool isvalid, bool isnotnull, bool isobligatory)
43 : m_valid(isvalid)
44 , m_notnull(isnotnull)
45 , m_obligatory(isobligatory)
46 {
47 }
48
49 bool m_valid;
52};
53
54//------------------------------------------------------------------------------------------------
55
56//------------------------------------------------------------------------------------------------
60
61template<typename T>
62
64{
65
66public:
67 typedef T t_virtue;
68
69 explicit editor_data(T const& virtue)
70 : editor_data_state(true, virtue.p_is_not_null, true)
71 , this_virtue(virtue)
72 {
73 }
74
75 virtual ~editor_data();
76
77 t_virtue const& get() const { return this_virtue; }
78
79 void set_obligatory(bool is) { m_obligatory = is; }
80
81 void set_valid(bool const is) { m_valid = is; }
82
83 void set_not_null(bool const is) { m_notnull = is; }
84
85private:
87};
88
89//------------------------------------------------------------------------------------------------
90
91namespace widgets {
92namespace editors {
93//------------------------------------------------------------------------------------------------
94
95class base : public QWidget
96{
97 Q_OBJECT
98
99public:
100 virtual void SetEditor() = 0;
101
102 template<typename T = editor_data_state>
103 std::shared_ptr<T> dataeditor()
104 {
105 return std::dynamic_pointer_cast<T>(p_data_editor);
106 }
107
108 virtual void setdata(QStringList const&);
109 virtual void setdefaults(QString const&);
110
111 void setchanged(bool);
112 bool ischanged() const;
113
114 virtual QStringList getdata();
115
116 const QString c_input_placeholder{ "Add a new value" };
117 const QString c_no_object_placeholder{ "No Object currently set" };
118
119protected:
120 base(std::shared_ptr<editor_data_state> editordata, QWidget* parent = nullptr, bool owned = false);
121
122 virtual void buildtooltip() = 0;
123 virtual void closeEvent(QCloseEvent* Event);
124
125 std::shared_ptr<editor_data_state> p_data_editor;
126
128 QStringList this_data;
129
133
134signals:
139
140public slots:
141 virtual void slot_set_initial_loaded();
142};
143
144//------------------------------------------------------------------------------------------------
145
146//------------------------------------------------------------------------------------------------
147
149 : public base
150 , private dbe::Ui::RelationshipForm
151{
152 Q_OBJECT
153
154public:
157
158 relation(t_virtue const& relation, QWidget* parent = nullptr, bool owned = false, bool readonly = false);
159
160 bool GetIsMultiValue() const;
161
162 bool eventFilter(QObject* Target, QEvent* Event);
163
164 void SetEditor() override;
165
166private:
167 void SetController();
168 void SetFirstItem();
169
170 void buildtooltip() override;
171
172 void CreateObjectEditor(const std::string& objectID);
173
174 std::shared_ptr<t_build_block_editor> p_base_data_editor;
175
178
179 QStatusBar* StatusBar;
180 QStringList CurrentDataList;
182 QAction* RemoveAction;
183 QAction* MoveTop;
184 QAction* MoveBottom;
185 QAction* MoveUp;
186 QAction* MoveDown;
187 QAction* EditAction;
188 QListWidgetItem* FirstItem;
189 QListWidgetItem* CurrentItem;
190
191private slots:
192 void FetchData();
193 void EndSignal();
194 void AddToDataList(const QString& DataValue);
195 void RemoveFromDataList();
196 void UpdateActions();
197 void closeEvent(QCloseEvent* Event);
198 void DataWasFetched(QStringList ListOfObjects);
199 void CreateObjectEditor(QListWidgetItem* Item);
200 void CustomContextMenuRequested(const QPoint& pos);
201 void RemoveSlot();
202 void MoveTopSlot();
203 void MoveBottomSlot();
204 void MoveUpSlot();
205 void MoveDownSlot();
206 void EditSlot();
207 void DummyMovement();
208 void EditItemEntered(QListWidgetItem* Item);
209
210signals:
211 void FetchDataDone(QStringList Data);
213};
214
215//------------------------------------------------------------------------------------------------
216
217//------------------------------------------------------------------------------------------------
218
220 : public base
221 , private Ui::StringAttributeWidgetForm
222{
223 Q_OBJECT
224
225public:
228
229 stringattr(t_virtue const& attr, QWidget* parent = nullptr, bool owned = false, bool readonly = false);
230 ~stringattr();
231
232 void SetEditor() override;
233
234 QTextEdit* GetLineEdit() const;
235
236 void SetNullCheck(bool Check);
237 void SetMultiCheck(bool Multi);
238 void SetCheckDefaults(bool Default);
239 void SetFocusOnLine();
240
241 bool eventFilter(QObject*, QEvent*);
242 void ClearText();
243
244private:
245 void buildtooltip() override;
246 void closeEvent(QCloseEvent*);
247 void SetController();
248 void setdefaults(const QString&);
249 void ShowPopupButton();
250 void HidePopupButton();
251
252 std::shared_ptr<t_build_block_editor> m_base_data_editor;
253
256 QPushButton* PopUpButton;
257 QDialog* Dialog;
258 QPushButton* OkButtonDialog;
259 QPlainTextEdit* TextEditDialog;
260
261signals:
263
264private slots:
265 void UpdateActions();
266 void AddToDataList();
267 void ShowDialog();
268 void UpdateFromTextEdit();
270};
271
272//------------------------------------------------------------------------------------------------
273
274//------------------------------------------------------------------------------------------------
275
277 : public base
278 , private Ui::NumericAttributeWidgetForm
279{
280 Q_OBJECT
281
282public:
285
286 numericattr(t_virtue const& attr, QWidget* parent = nullptr, bool owned = false, bool readonly = false);
287
288 void SetEditor() override;
289
290 QLineEdit* GetLineEdit() const;
291
292 virtual void setdefaults(const QString& ValueDefault);
293
294private:
295 void buildtooltip() override;
296 void closeEvent(QCloseEvent* Event);
297 void SetController();
298 void ShowWarning(QString Format = "", QString Range = "");
299 bool ValidateIntegerValue(QString const&);
300 bool ValidateFloatValue(QString const&);
301 bool checkRange(QString const&);
302
303 std::shared_ptr<t_build_block_editor> this_base_data_editor;
304
308
309signals:
311
312private slots:
313 void checkIfDuplicated();
314 void AddToList();
315 void ChangeFormat(int i);
316 void UpdateActions(QString Dummy);
317 void ChangeFormatDec();
318 void ChangeFormatHex();
319 void ChangeFormatOct();
320};
321
322//------------------------------------------------------------------------------------------------
323
324//------------------------------------------------------------------------------------------------
325
326class combo
327 : public base
328 , public Ui::EditCombo
329{
330 Q_OBJECT
331
332public:
335
336 combo(t_virtue const& attr, QWidget* parent = nullptr, bool owned = false, bool readonly = false);
337
338 void SetEditor() override;
339
340 void SetData(QStringList const&);
341 void SetValidatorData(QStringList const& Data, bool AcceptNoMatch = false);
342
343 void setdata(QStringList const&);
344
345 QStringList getdata() override;
346
347private:
348 void buildtooltip() override;
349 bool eventFilter(QObject*, QEvent*);
350 void wheelEvent(QWheelEvent*);
351 void SetController();
352
353 std::shared_ptr<t_build_block_editor> m_base_data_editor;
355private slots:
356 void TryValidate(QString);
357 void ChangeDetected(QString const&);
358 void CheckDefaults(int);
359 bool CompareDefaults();
360};
361
362//------------------------------------------------------------------------------------------------
363
364//------------------------------------------------------------------------------------------------
365
366class multiattr : public base
367{
368 Q_OBJECT
369
370public:
373
374 multiattr(t_virtue const& attr, QWidget* parent = nullptr, bool owned = false, bool readonly = false);
375
376 void SetEditor() override;
377
378private:
379 void buildtooltip();
380 void closeEvent(QCloseEvent* Event);
381 void SetStatusBar();
382 bool eventFilter(QObject* Target, QEvent* Event);
383
384 std::shared_ptr<t_build_block_editor> m_base_data_editor;
385
387 QStatusBar* StatusBar;
388 QPushButton* OkButton;
389 QPushButton* RemoveButton;
390 QListWidget* ListWidget;
393 QAction* RemoveAction;
394
395private slots:
396 void AddToDataList(const QString& Data);
397 void RemoveFromDataList();
398 void UpdateActions();
399 void LineValueChanged();
400 void LineValueChanged(QListWidgetItem* p);
401 void ListOrderChange(const QModelIndexList& IndexList);
402 void EndSignal();
403 void CustomContextMenuRequested(const QPoint& pos);
404 void RemoveSlot();
405};
406
407//------------------------------------------------------------------------------------------------
408} // end namespace editors
409} // end widgets
410
411} // end namespace dbe
412
413#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.