DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbse::SchemaAttributeEditor Class Reference

#include <SchemaAttributeEditor.hpp>

Inheritance diagram for dbse::SchemaAttributeEditor:
[legend]
Collaboration diagram for dbse::SchemaAttributeEditor:
[legend]

Signals

void RebuildModel ()

Public Member Functions

 ~SchemaAttributeEditor ()
 SchemaAttributeEditor (dunedaq::oks::OksClass *ClassInfo, dunedaq::oks::OksAttribute *AttributeData, QWidget *parent=nullptr)
 SchemaAttributeEditor (dunedaq::oks::OksClass *ClassInfo, QWidget *parent=nullptr)
void InitialSettings ()
void SetController ()
void ParseToSave ()
void ParseToCreate ()

Protected Member Functions

void FillInfo ()

Private Slots

void ProxySlot ()
void ToggleFormat (int)
void ClassUpdated (QString ClassName)

Private Member Functions

void keyPressEvent (QKeyEvent *event) override

Private Attributes

std::unique_ptr< dbse::Ui::SchemaAttributeEditor > ui
dunedaq::oks::OksClass * SchemaClass
dunedaq::oks::OksAttribute * SchemaAttribute
bool UsedNew
bool m_writable

Detailed Description

Definition at line 19 of file SchemaAttributeEditor.hpp.

Constructor & Destructor Documentation

◆ ~SchemaAttributeEditor()

dbse::SchemaAttributeEditor::~SchemaAttributeEditor ( )
default

◆ SchemaAttributeEditor() [1/2]

dbse::SchemaAttributeEditor::SchemaAttributeEditor ( dunedaq::oks::OksClass * ClassInfo,
dunedaq::oks::OksAttribute * AttributeData,
QWidget * parent = nullptr )
explicit

Definition at line 15 of file SchemaAttributeEditor.cpp.

16 : QWidget(parent)
17 , ui(new Ui::SchemaAttributeEditor)
18 , SchemaClass(ClassInfo)
19 , SchemaAttribute(AttributeData)
20 , UsedNew(false)
22{
23 QWidget::setAttribute(Qt::WA_DeleteOnClose);
24 ui->setupUi(this);
27}
static KernelWrapper & GetInstance()
std::unique_ptr< dbse::Ui::SchemaAttributeEditor > ui
dunedaq::oks::OksAttribute * SchemaAttribute
dunedaq::oks::OksClass * SchemaClass
OksFile * get_file() const noexcept
Definition class.hpp:352
const std::string & get_full_file_name() const
Definition file.hpp:528

◆ SchemaAttributeEditor() [2/2]

dbse::SchemaAttributeEditor::SchemaAttributeEditor ( dunedaq::oks::OksClass * ClassInfo,
QWidget * parent = nullptr )
explicit

Definition at line 29 of file SchemaAttributeEditor.cpp.

30 : QWidget(parent)
31 , ui(new Ui::SchemaAttributeEditor)
32 , SchemaClass(ClassInfo)
33 , SchemaAttribute(nullptr)
34 , UsedNew(true)
36{
37 QWidget::setAttribute(Qt::WA_DeleteOnClose);
38 ui->setupUi(this);
41}

Member Function Documentation

◆ ClassUpdated

void dbse::SchemaAttributeEditor::ClassUpdated ( QString ClassName)
privateslot

Definition at line 138 of file SchemaAttributeEditor.cpp.

139{
140 if (!UsedNew && ClassName.toStdString() == SchemaClass->get_name()) {
142 FillInfo();
143 } else {
144 QWidget::close();
145 }
146 }
147}
const std::string & get_name() const noexcept
out stream operator
OksAttribute * find_direct_attribute(const std::string &name) const noexcept
Find direct attribute.
Definition class.cpp:973
const std::string & get_name() const noexcept
Definition class.hpp:374

◆ FillInfo()

void dbse::SchemaAttributeEditor::FillInfo ( )
protected

Definition at line 46 of file SchemaAttributeEditor.cpp.

47{
48 auto name = QString::fromStdString(SchemaClass->get_name() + "::" + SchemaAttribute->get_name());
49 setWindowTitle(name);
50 setObjectName(name);
51 ui->AttributeNameLineEdit->setText(QString::fromStdString(SchemaAttribute->get_name()));
52 ui->AttributeTypeComboBox->setCurrentIndex(
53 ui->AttributeTypeComboBox->findData(QString::fromStdString(SchemaAttribute->get_type()), Qt::DisplayRole));
54
56 ui->AttributeIsMultivariable->setCurrentIndex(0);
57 else {
58 ui->AttributeIsMultivariable->setCurrentIndex(1);
59 }
60
62 ui->AttributeIsNotNull->setCurrentIndex(0);
63 } else {
64 ui->AttributeIsNotNull->setCurrentIndex(1);
65 }
66
67 ui->AttributeDescriptionTextBox->setPlainText(QString::fromStdString(SchemaAttribute->get_description()));
68 ui->AttributeRangeLineEdit->setText(QString::fromStdString(SchemaAttribute->get_range()));
69 ui->AttributeInitialValue->setText(QString::fromStdString(SchemaAttribute->get_init_value()));
70
71 int Index = ui->AttributeTypeComboBox->currentIndex();
72
73 if (Index == 0 || Index >= 9) {
74 ui->FormatLayout->setEnabled(false);
75 ui->FormatLabel->hide();
76 ui->AttributeFormatComboBox->hide();
77 } else {
78 if (m_writable) {
79 ui->FormatLayout->setEnabled(true);
80 }
81 ui->FormatLabel->show();
82 ui->AttributeFormatComboBox->show();
83
85 ui->AttributeFormatComboBox->setCurrentIndex(0);
87 ui->AttributeFormatComboBox->setCurrentIndex(1);
88 else {
89 ui->AttributeFormatComboBox->setCurrentIndex(2);
90 }
91 }
92}
bool get_is_multi_values() const noexcept
const std::string & get_type() const noexcept
Get attribute string type.
const std::string & get_range() const noexcept
Get attribute range.
const std::string & get_init_value() const noexcept
const std::string & get_description() const noexcept
bool get_is_no_null() const noexcept
Format get_format() const noexcept
Get attribute format.

◆ InitialSettings()

void dbse::SchemaAttributeEditor::InitialSettings ( )

Definition at line 104 of file SchemaAttributeEditor.cpp.

105{
106 QStringList Items{ "bool", "s8", "u8", "s16", "u16", "s32", "u32", "s64",
107 "u64", "float", "double", "date", "time", "string", "enum", "class" };
108 ui->AttributeTypeComboBox->addItems(Items);
109 auto name = SchemaClass->get_name() + "::";
110 setWindowTitle(QString::fromStdString(name + " New Attribute"));
111 setObjectName(QString::fromStdString(name));
112
113 if (!m_writable) {
114 ui->AttributeTypeComboBox->setEnabled(false);
115 ui->AttributeIsMultivariable->setEnabled(false);
116 ui->AttributeIsNotNull->setEnabled(false);
117 ui->AttributeRangeLineEdit->setEnabled(false);
118 ui->AttributeInitialValue->setEnabled(false);
119
120 ui->AttributeDescriptionTextBox->setReadOnly(true);
121 }
122
123 if (!UsedNew) {
124 FillInfo();
125 }
126}

◆ keyPressEvent()

void dbse::SchemaAttributeEditor::keyPressEvent ( QKeyEvent * event)
overrideprivate

Definition at line 95 of file SchemaAttributeEditor.cpp.

96{
97 if (event->key() == Qt::Key_Escape) {
98 close();
99 }
100 QWidget::keyPressEvent(event);
101}

◆ ParseToCreate()

void dbse::SchemaAttributeEditor::ParseToCreate ( )

Making sure we dont get anything weird

Creating attribute and updating

Definition at line 268 of file SchemaAttributeEditor.cpp.

269{
270 std::string AttributeName = ui->AttributeNameLineEdit->text().toStdString();
271 std::string AttributeType = ui->AttributeTypeComboBox->currentText().toStdString();
272 char AttributeFormatChar = (ui->AttributeFormatComboBox->currentText().toStdString())[0];
273
274 OksAttribute::Format AttributeFormat;
275
276 switch (AttributeFormatChar) {
277 case 'D':
278 AttributeFormat = OksAttribute::Format::Dec;
279 break;
280
281 case 'O':
282 AttributeFormat = OksAttribute::Format::Oct;
283 break;
284
285 case 'H':
286 AttributeFormat = OksAttribute::Format::Hex;
287 break;
288
289 default:
290 AttributeFormat = OksAttribute::Format::Dec;
291 break;
292 }
293
295 int Index = ui->AttributeTypeComboBox->currentIndex();
296
297 if (Index == 0 || Index >= 9) {
298 AttributeFormat = OksAttribute::Format::Dec;
299 }
300
301 bool IsMultivariable = false;
302
303 switch (ui->AttributeIsMultivariable->currentIndex()) {
304 case 0:
305 IsMultivariable = true;
306 break;
307
308 case 1:
309 IsMultivariable = false;
310 break;
311
312 default:
313 IsMultivariable = false;
314 break;
315 }
316
317 bool IsNotNull = false;
318
319 switch (ui->AttributeIsNotNull->currentIndex()) {
320 case 0:
321 IsNotNull = true;
322 break;
323
324 case 1:
325 IsNotNull = false;
326 break;
327
328 default:
329 IsNotNull = false;
330 break;
331 }
332
333 std::string AttributeDescription = ui->AttributeDescriptionTextBox->toPlainText().toStdString();
334 std::string AttributeRange = ui->AttributeRangeLineEdit->text().toStdString();
335 std::string AttributeInitial = ui->AttributeInitialValue->text().toStdString();
336
339 AttributeName,
340 AttributeType,
341 IsMultivariable,
342 AttributeRange,
343 AttributeInitial,
344 AttributeDescription,
345 IsNotNull,
346 AttributeFormat);
347 emit RebuildModel();
348 close();
349}
void PushAddAttributeCommand(dunedaq::oks::OksClass *Class, std::string name, std::string type, bool is_mv, std::string range, std::string init_values, std::string description, bool is_null, dunedaq::oks::OksAttribute::Format format=dunedaq::oks::OksAttribute::Format::Dec)

◆ ParseToSave()

void dbse::SchemaAttributeEditor::ParseToSave ( )

Making sure we dont get anything weird

Definition at line 150 of file SchemaAttributeEditor.cpp.

151{
152 bool Changed = false;
153 std::string AttributeName = ui->AttributeNameLineEdit->text().toStdString();
154 std::string AttributeType = ui->AttributeTypeComboBox->currentText().toStdString();
155 char AttributeFormatChar = (ui->AttributeFormatComboBox->currentText().toStdString())[0];
156
157 OksAttribute::Format AttributeFormat;
158
159 switch (AttributeFormatChar) {
160 case 'D':
161 AttributeFormat = OksAttribute::Format::Dec;
162 break;
163
164 case 'O':
165 AttributeFormat = OksAttribute::Format::Oct;
166 break;
167
168 case 'H':
169 AttributeFormat = OksAttribute::Format::Hex;
170 break;
171
172 default:
173 AttributeFormat = OksAttribute::Format::Dec;
174 break;
175 }
176
178 int Index = ui->AttributeTypeComboBox->currentIndex();
179
180 if (Index == 0 || Index >= 9) {
181 AttributeFormat = OksAttribute::Format::Dec;
182 }
183
184 bool IsMultivariable = false;
185
186 switch (ui->AttributeIsMultivariable->currentIndex()) {
187 case 0:
188 IsMultivariable = true;
189 break;
190
191 case 1:
192 IsMultivariable = false;
193 break;
194
195 default:
196 IsMultivariable = false;
197 break;
198 }
199
200 bool IsNotNull = false;
201
202 switch (ui->AttributeIsNotNull->currentIndex()) {
203 case 0:
204 IsNotNull = true;
205 break;
206
207 case 1:
208 IsNotNull = false;
209 break;
210
211 default:
212 IsNotNull = false;
213 break;
214 }
215
216 std::string AttributeDescription = ui->AttributeDescriptionTextBox->toPlainText().toStdString();
217 std::string AttributeRange = ui->AttributeRangeLineEdit->text().toStdString();
218 std::string AttributeInitial = ui->AttributeInitialValue->text().toStdString();
219
220 if (AttributeName != SchemaAttribute->get_name()) {
222 Changed = true;
223 }
224
225 if (AttributeType != SchemaAttribute->get_type()) {
227 Changed = true;
228 }
229
230 if (AttributeFormat != SchemaAttribute->get_format()) {
232 Changed = true;
233 }
234
235 if (IsMultivariable != SchemaAttribute->get_is_multi_values()) {
237 Changed = true;
238 }
239
240 if (IsNotNull != SchemaAttribute->get_is_no_null()) {
242 Changed = true;
243 }
244
245 if (AttributeDescription != SchemaAttribute->get_description()) {
247 Changed = true;
248 }
249
250 if (AttributeRange != SchemaAttribute->get_range()) {
252 Changed = true;
253 }
254
255 if (AttributeInitial != SchemaAttribute->get_init_value()) {
257 Changed = true;
258 }
259
260 if (Changed) {
261 emit RebuildModel();
262 }
263
264 close();
265}
void PushSetAttributeDescriptionCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string NewDescription)
void PushSetAttributeIsNullCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, bool NewIsNull)
void PushSetAttributeRangeCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string NewRange)
void PushSetAttributeFormatCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, dunedaq::oks::OksAttribute::Format NewFormat)
void PushSetAttributeMultiCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, bool NewIsMulti)
void PushSetAttributeInitialValuesCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string NewValues)
void PushSetAttributeTypeCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string NewType)
void PushSetAttributeNameCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string NewName)
Attribute commands.

◆ ProxySlot

void dbse::SchemaAttributeEditor::ProxySlot ( )
privateslot

Definition at line 352 of file SchemaAttributeEditor.cpp.

353{
354 if (UsedNew) {
356 } else {
357 ParseToSave();
358 }
359}

◆ RebuildModel

void dbse::SchemaAttributeEditor::RebuildModel ( )
signal

◆ SetController()

void dbse::SchemaAttributeEditor::SetController ( )

Definition at line 129 of file SchemaAttributeEditor.cpp.

130{
131 connect(ui->AttributeTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(ToggleFormat(int)));
132 connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(ProxySlot()));
133 connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
134 connect(&KernelWrapper::GetInstance(), SIGNAL(ClassUpdated(QString)), this, SLOT(ClassUpdated(QString)));
135}
void ClassUpdated(QString ClassName)

◆ ToggleFormat

void dbse::SchemaAttributeEditor::ToggleFormat ( int )
privateslot

Definition at line 362 of file SchemaAttributeEditor.cpp.

363{
364 int Index = ui->AttributeTypeComboBox->currentIndex();
365
366 if (Index == 0 || Index >= 9) {
367 ui->FormatLayout->setEnabled(false);
368 ui->FormatLabel->hide();
369 ui->AttributeFormatComboBox->hide();
370 } else {
371 ui->FormatLayout->setEnabled(true);
372 ui->FormatLabel->show();
373 ui->AttributeFormatComboBox->show();
374 }
375}

Member Data Documentation

◆ m_writable

bool dbse::SchemaAttributeEditor::m_writable
private

Definition at line 45 of file SchemaAttributeEditor.hpp.

◆ SchemaAttribute

dunedaq::oks::OksAttribute* dbse::SchemaAttributeEditor::SchemaAttribute
private

Definition at line 43 of file SchemaAttributeEditor.hpp.

◆ SchemaClass

dunedaq::oks::OksClass* dbse::SchemaAttributeEditor::SchemaClass
private

Definition at line 42 of file SchemaAttributeEditor.hpp.

◆ ui

std::unique_ptr<dbse::Ui::SchemaAttributeEditor> dbse::SchemaAttributeEditor::ui
private

Definition at line 41 of file SchemaAttributeEditor.hpp.

◆ UsedNew

bool dbse::SchemaAttributeEditor::UsedNew
private

Definition at line 44 of file SchemaAttributeEditor.hpp.


The documentation for this class was generated from the following files: