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::OksClassSchemaClass
dunedaq::oks::OksAttributeSchemaAttribute
bool UsedNew
bool m_writable

Detailed Description

Definition at line 21 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 14 of file SchemaAttributeEditor.cpp.

17 : QWidget ( parent ),
18 ui ( new Ui::SchemaAttributeEditor ),
19 SchemaClass ( ClassInfo ),
20 SchemaAttribute ( AttributeData ),
21 UsedNew ( false ),
23 SchemaClass->get_file()->get_full_file_name()))
24{
25 QWidget::setAttribute(Qt::WA_DeleteOnClose);
26 ui->setupUi ( this );
29}
static KernelWrapper & GetInstance()
std::unique_ptr< dbse::Ui::SchemaAttributeEditor > ui
dunedaq::oks::OksAttribute * SchemaAttribute
dunedaq::oks::OksClass * SchemaClass

◆ SchemaAttributeEditor() [2/2]

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

Definition at line 31 of file SchemaAttributeEditor.cpp.

33 : QWidget ( parent ),
34 ui ( new Ui::SchemaAttributeEditor ),
35 SchemaClass ( ClassInfo ),
36 SchemaAttribute ( nullptr ),
37 UsedNew ( true ),
39 SchemaClass->get_file()->get_full_file_name()))
40{
41 QWidget::setAttribute(Qt::WA_DeleteOnClose);
42 ui->setupUi ( this );
45}

Member Function Documentation

◆ ClassUpdated

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

Definition at line 159 of file SchemaAttributeEditor.cpp.

160{
161 if(!UsedNew && ClassName.toStdString() == SchemaClass->get_name()) {
162 if(SchemaClass->find_direct_attribute(SchemaAttribute->get_name()) != nullptr) {
163 FillInfo();
164 } else {
165 QWidget::close();
166 }
167 }
168}

◆ FillInfo()

void dbse::SchemaAttributeEditor::FillInfo ( )
protected

Definition at line 49 of file SchemaAttributeEditor.cpp.

50{
51 auto name = QString::fromStdString(SchemaClass->get_name() + "::" +
52 SchemaAttribute->get_name());
53 setWindowTitle (name);
54 setObjectName (name);
55 ui->AttributeNameLineEdit->setText ( QString::fromStdString (
56 SchemaAttribute->get_name() ) );
57 ui->AttributeTypeComboBox->setCurrentIndex (
58 ui->AttributeTypeComboBox->findData ( QString::fromStdString (
59 SchemaAttribute->get_type() ),
60 Qt::DisplayRole ) );
61
62 if ( SchemaAttribute->get_is_multi_values() )
63 ui->AttributeIsMultivariable->setCurrentIndex (
64 0 );
65 else
66 {
67 ui->AttributeIsMultivariable->setCurrentIndex ( 1 );
68 }
69
70 if ( SchemaAttribute->get_is_no_null() )
71 {
72 ui->AttributeIsNotNull->setCurrentIndex ( 0 );
73 }
74 else
75 {
76 ui->AttributeIsNotNull->setCurrentIndex ( 1 );
77 }
78
79 ui->AttributeDescriptionTextBox->setPlainText (
80 QString::fromStdString ( SchemaAttribute->get_description() ) );
81 ui->AttributeRangeLineEdit->setText ( QString::fromStdString (
82 SchemaAttribute->get_range() ) );
83 ui->AttributeInitialValue->setText (
84 QString::fromStdString ( SchemaAttribute->get_init_value() ) );
85
86 int Index = ui->AttributeTypeComboBox->currentIndex();
87
88 if ( Index == 0 || Index >= 9 )
89 {
90 ui->FormatLayout->setEnabled ( false );
91 ui->FormatLabel->hide();
92 ui->AttributeFormatComboBox->hide();
93 }
94 else
95 {
96 if (m_writable) {
97 ui->FormatLayout->setEnabled ( true );
98 }
99 ui->FormatLabel->show();
100 ui->AttributeFormatComboBox->show();
101
102 if ( SchemaAttribute->get_format() == OksAttribute::Dec )
103 ui->AttributeFormatComboBox->setCurrentIndex (
104 0 );
105 else if ( SchemaAttribute->get_format() == OksAttribute::Oct )
106 ui->AttributeFormatComboBox->setCurrentIndex (
107 1 );
108 else
109 {
110 ui->AttributeFormatComboBox->setCurrentIndex ( 2 );
111 }
112 }
113}

◆ InitialSettings()

void dbse::SchemaAttributeEditor::InitialSettings ( )

Definition at line 122 of file SchemaAttributeEditor.cpp.

123{
124 QStringList Items
125 {
126 "bool", "s8", "u8", "s16", "u16", "s32", "u32", "s64", "u64", "float", "double", "date",
127 "time", "string", "enum", "class" };
128 ui->AttributeTypeComboBox->addItems ( Items );
129 auto name = SchemaClass->get_name() + "::";
130 setWindowTitle ( QString::fromStdString ( name + " New Attribute" ) );
131 setObjectName ( QString::fromStdString(name) );
132
133 if (!m_writable) {
134 ui->AttributeTypeComboBox->setEnabled(false);
135 ui->AttributeIsMultivariable->setEnabled(false);
136 ui->AttributeIsNotNull->setEnabled(false);
137 ui->AttributeRangeLineEdit->setEnabled(false);
138 ui->AttributeInitialValue->setEnabled(false);
139
140 ui->AttributeDescriptionTextBox->setReadOnly(true);
141 }
142
143 if ( !UsedNew )
144 {
145 FillInfo();
146 }
147}

◆ keyPressEvent()

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

Definition at line 115 of file SchemaAttributeEditor.cpp.

115 {
116 if (event->key() == Qt::Key_Escape) {
117 close();
118 }
119 QWidget::keyPressEvent(event);
120}

◆ ParseToCreate()

void dbse::SchemaAttributeEditor::ParseToCreate ( )

Making sure we dont get anything weird

Creating attribute and updating

Definition at line 311 of file SchemaAttributeEditor.cpp.

312{
313 std::string AttributeName = ui->AttributeNameLineEdit->text().toStdString();
314 std::string AttributeType = ui->AttributeTypeComboBox->currentText().toStdString();
315 char AttributeFormatChar = ( ui->AttributeFormatComboBox->currentText().toStdString() ) [0];
316
317 OksAttribute::Format AttributeFormat;
318
319 switch ( AttributeFormatChar )
320 {
321 case 'D':
322 AttributeFormat = OksAttribute::Format::Dec;
323 break;
324
325 case 'O':
326 AttributeFormat = OksAttribute::Format::Oct;
327 break;
328
329 case 'H':
330 AttributeFormat = OksAttribute::Format::Hex;
331 break;
332
333 default:
334 AttributeFormat = OksAttribute::Format::Dec;
335 break;
336 }
337
339 int Index = ui->AttributeTypeComboBox->currentIndex();
340
341 if ( Index == 0 || Index >= 9 )
342 {
343 AttributeFormat = OksAttribute::Format::Dec;
344 }
345
346 bool IsMultivariable = false;
347
348 switch ( ui->AttributeIsMultivariable->currentIndex() )
349 {
350 case 0:
351 IsMultivariable = true;
352 break;
353
354 case 1:
355 IsMultivariable = false;
356 break;
357
358 default:
359 IsMultivariable = false;
360 break;
361 }
362
363 bool IsNotNull = false;
364
365 switch ( ui->AttributeIsNotNull->currentIndex() )
366 {
367 case 0:
368 IsNotNull = true;
369 break;
370
371 case 1:
372 IsNotNull = false;
373 break;
374
375 default:
376 IsNotNull = false;
377 break;
378 }
379
380 std::string AttributeDescription =
381 ui->AttributeDescriptionTextBox->toPlainText().toStdString();
382 std::string AttributeRange = ui->AttributeRangeLineEdit->text().toStdString();
383 std::string AttributeInitial = ui->AttributeInitialValue->text().toStdString();
384
387 AttributeType, IsMultivariable,
388 AttributeRange, AttributeInitial,
389 AttributeDescription, IsNotNull,
390 AttributeFormat );
391 emit RebuildModel();
392 close();
393}
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 170 of file SchemaAttributeEditor.cpp.

171{
172 bool Changed = false;
173 std::string AttributeName = ui->AttributeNameLineEdit->text().toStdString();
174 std::string AttributeType = ui->AttributeTypeComboBox->currentText().toStdString();
175 char AttributeFormatChar = ( ui->AttributeFormatComboBox->currentText().toStdString() ) [0];
176
177 OksAttribute::Format AttributeFormat;
178
179 switch ( AttributeFormatChar )
180 {
181 case 'D':
182 AttributeFormat = OksAttribute::Format::Dec;
183 break;
184
185 case 'O':
186 AttributeFormat = OksAttribute::Format::Oct;
187 break;
188
189 case 'H':
190 AttributeFormat = OksAttribute::Format::Hex;
191 break;
192
193 default:
194 AttributeFormat = OksAttribute::Format::Dec;
195 break;
196 }
197
199 int Index = ui->AttributeTypeComboBox->currentIndex();
200
201 if ( Index == 0 || Index >= 9 )
202 {
203 AttributeFormat = OksAttribute::Format::Dec;
204 }
205
206 bool IsMultivariable = false;
207
208 switch ( ui->AttributeIsMultivariable->currentIndex() )
209 {
210 case 0:
211 IsMultivariable = true;
212 break;
213
214 case 1:
215 IsMultivariable = false;
216 break;
217
218 default:
219 IsMultivariable = false;
220 break;
221 }
222
223 bool IsNotNull = false;
224
225 switch ( ui->AttributeIsNotNull->currentIndex() )
226 {
227 case 0:
228 IsNotNull = true;
229 break;
230
231 case 1:
232 IsNotNull = false;
233 break;
234
235 default:
236 IsNotNull = false;
237 break;
238 }
239
240 std::string AttributeDescription =
241 ui->AttributeDescriptionTextBox->toPlainText().toStdString();
242 std::string AttributeRange = ui->AttributeRangeLineEdit->text().toStdString();
243 std::string AttributeInitial = ui->AttributeInitialValue->text().toStdString();
244
245 if ( AttributeName != SchemaAttribute->get_name() )
246 {
248 Changed = true;
249 }
250
251 if ( AttributeType != SchemaAttribute->get_type() )
252 {
254 Changed = true;
255 }
256
257 if ( AttributeFormat != SchemaAttribute->get_format() )
258 {
261 AttributeFormat );
262 Changed = true;
263 }
264
265 if ( IsMultivariable != SchemaAttribute->get_is_multi_values() )
266 {
269 IsMultivariable );
270 Changed = true;
271 }
272
273 if ( IsNotNull != SchemaAttribute->get_is_no_null() )
274 {
276 Changed = true;
277 }
278
279 if ( AttributeDescription != SchemaAttribute->get_description() )
280 {
283 AttributeDescription );
284 Changed = true;
285 }
286
287 if ( AttributeRange != SchemaAttribute->get_range() )
288 {
291 AttributeRange );
292 Changed = true;
293 }
294
295 if ( AttributeInitial != SchemaAttribute->get_init_value() )
296 {
299 AttributeInitial );
300 Changed = true;
301 }
302
303 if ( Changed )
304 {
305 emit RebuildModel();
306 }
307
308 close();
309}
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 395 of file SchemaAttributeEditor.cpp.

396{
397 if ( UsedNew )
398 {
400 }
401 else
402 {
403 ParseToSave();
404 }
405}

◆ RebuildModel

void dbse::SchemaAttributeEditor::RebuildModel ( )
signal

◆ SetController()

void dbse::SchemaAttributeEditor::SetController ( )

Definition at line 149 of file SchemaAttributeEditor.cpp.

150{
151 connect ( ui->AttributeTypeComboBox, SIGNAL ( currentIndexChanged ( int ) ), this,
152 SLOT ( ToggleFormat ( int ) ) );
153 connect ( ui->buttonBox, SIGNAL ( accepted() ), this, SLOT ( ProxySlot() ) );
154 connect ( ui->buttonBox, SIGNAL ( rejected() ), this, SLOT ( close() ) );
155 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassUpdated ( QString ) ), this,
156 SLOT ( ClassUpdated ( QString ) ) );
157}
void ClassUpdated(QString ClassName)

◆ ToggleFormat

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

Definition at line 407 of file SchemaAttributeEditor.cpp.

408{
409 int Index = ui->AttributeTypeComboBox->currentIndex();
410
411 if ( Index == 0 || Index >= 9 )
412 {
413 ui->FormatLayout->setEnabled ( false );
414 ui->FormatLabel->hide();
415 ui->AttributeFormatComboBox->hide();
416 }
417 else
418 {
419 ui->FormatLayout->setEnabled ( true );
420 ui->FormatLabel->show();
421 ui->AttributeFormatComboBox->show();
422 }
423}

Member Data Documentation

◆ m_writable

bool dbse::SchemaAttributeEditor::m_writable
private

Definition at line 44 of file SchemaAttributeEditor.hpp.

◆ SchemaAttribute

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

Definition at line 42 of file SchemaAttributeEditor.hpp.

◆ SchemaClass

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

Definition at line 41 of file SchemaAttributeEditor.hpp.

◆ ui

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

Definition at line 40 of file SchemaAttributeEditor.hpp.

◆ UsedNew

bool dbse::SchemaAttributeEditor::UsedNew
private

Definition at line 43 of file SchemaAttributeEditor.hpp.


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