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 16 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 9 of file SchemaAttributeEditor.cpp.

12 : QWidget ( parent ),
13 ui ( new Ui::SchemaAttributeEditor ),
14 SchemaClass ( ClassInfo ),
15 SchemaAttribute ( AttributeData ),
16 UsedNew ( false ),
19{
20 QWidget::setAttribute(Qt::WA_DeleteOnClose);
21 ui->setupUi ( this );
24}
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:338
const std::string & get_full_file_name() const
Definition file.hpp:523

◆ SchemaAttributeEditor() [2/2]

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

Definition at line 26 of file SchemaAttributeEditor.cpp.

28 : QWidget ( parent ),
29 ui ( new Ui::SchemaAttributeEditor ),
30 SchemaClass ( ClassInfo ),
31 SchemaAttribute ( nullptr ),
32 UsedNew ( true ),
35{
36 QWidget::setAttribute(Qt::WA_DeleteOnClose);
37 ui->setupUi ( this );
40}

Member Function Documentation

◆ ClassUpdated

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

Definition at line 154 of file SchemaAttributeEditor.cpp.

155{
156 if(!UsedNew && ClassName.toStdString() == SchemaClass->get_name()) {
158 FillInfo();
159 } else {
160 QWidget::close();
161 }
162 }
163}
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:1014
const std::string & get_name() const noexcept
Definition class.hpp:363

◆ FillInfo()

void dbse::SchemaAttributeEditor::FillInfo ( )
protected

Definition at line 44 of file SchemaAttributeEditor.cpp.

45{
46 auto name = QString::fromStdString(SchemaClass->get_name() + "::" +
48 setWindowTitle (name);
49 setObjectName (name);
50 ui->AttributeNameLineEdit->setText ( QString::fromStdString (
52 ui->AttributeTypeComboBox->setCurrentIndex (
53 ui->AttributeTypeComboBox->findData ( QString::fromStdString (
55 Qt::DisplayRole ) );
56
58 ui->AttributeIsMultivariable->setCurrentIndex (
59 0 );
60 else
61 {
62 ui->AttributeIsMultivariable->setCurrentIndex ( 1 );
63 }
64
66 {
67 ui->AttributeIsNotNull->setCurrentIndex ( 0 );
68 }
69 else
70 {
71 ui->AttributeIsNotNull->setCurrentIndex ( 1 );
72 }
73
74 ui->AttributeDescriptionTextBox->setPlainText (
75 QString::fromStdString ( SchemaAttribute->get_description() ) );
76 ui->AttributeRangeLineEdit->setText ( QString::fromStdString (
78 ui->AttributeInitialValue->setText (
79 QString::fromStdString ( SchemaAttribute->get_init_value() ) );
80
81 int Index = ui->AttributeTypeComboBox->currentIndex();
82
83 if ( Index == 0 || Index >= 9 )
84 {
85 ui->FormatLayout->setEnabled ( false );
86 ui->FormatLabel->hide();
87 ui->AttributeFormatComboBox->hide();
88 }
89 else
90 {
91 if (m_writable) {
92 ui->FormatLayout->setEnabled ( true );
93 }
94 ui->FormatLabel->show();
95 ui->AttributeFormatComboBox->show();
96
98 ui->AttributeFormatComboBox->setCurrentIndex (
99 0 );
101 ui->AttributeFormatComboBox->setCurrentIndex (
102 1 );
103 else
104 {
105 ui->AttributeFormatComboBox->setCurrentIndex ( 2 );
106 }
107 }
108}
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 117 of file SchemaAttributeEditor.cpp.

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

◆ keyPressEvent()

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

Definition at line 110 of file SchemaAttributeEditor.cpp.

110 {
111 if (event->key() == Qt::Key_Escape) {
112 close();
113 }
114 QWidget::keyPressEvent(event);
115}

◆ ParseToCreate()

void dbse::SchemaAttributeEditor::ParseToCreate ( )

Making sure we dont get anything weird

Creating attribute and updating

Definition at line 306 of file SchemaAttributeEditor.cpp.

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

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

391{
392 if ( UsedNew )
393 {
395 }
396 else
397 {
398 ParseToSave();
399 }
400}

◆ RebuildModel

void dbse::SchemaAttributeEditor::RebuildModel ( )
signal

◆ SetController()

void dbse::SchemaAttributeEditor::SetController ( )

Definition at line 144 of file SchemaAttributeEditor.cpp.

145{
146 connect ( ui->AttributeTypeComboBox, SIGNAL ( currentIndexChanged ( int ) ), this,
147 SLOT ( ToggleFormat ( int ) ) );
148 connect ( ui->buttonBox, SIGNAL ( accepted() ), this, SLOT ( ProxySlot() ) );
149 connect ( ui->buttonBox, SIGNAL ( rejected() ), this, SLOT ( close() ) );
150 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassUpdated ( QString ) ), this,
151 SLOT ( ClassUpdated ( QString ) ) );
152}
void ClassUpdated(QString ClassName)

◆ ToggleFormat

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

Definition at line 402 of file SchemaAttributeEditor.cpp.

403{
404 int Index = ui->AttributeTypeComboBox->currentIndex();
405
406 if ( Index == 0 || Index >= 9 )
407 {
408 ui->FormatLayout->setEnabled ( false );
409 ui->FormatLabel->hide();
410 ui->AttributeFormatComboBox->hide();
411 }
412 else
413 {
414 ui->FormatLayout->setEnabled ( true );
415 ui->FormatLabel->show();
416 ui->AttributeFormatComboBox->show();
417 }
418}

Member Data Documentation

◆ m_writable

bool dbse::SchemaAttributeEditor::m_writable
private

Definition at line 39 of file SchemaAttributeEditor.hpp.

◆ SchemaAttribute

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

Definition at line 37 of file SchemaAttributeEditor.hpp.

◆ SchemaClass

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

Definition at line 36 of file SchemaAttributeEditor.hpp.

◆ ui

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

Definition at line 35 of file SchemaAttributeEditor.hpp.

◆ UsedNew

bool dbse::SchemaAttributeEditor::UsedNew
private

Definition at line 38 of file SchemaAttributeEditor.hpp.


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