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 Attributes

std::unique_ptr< dbse::Ui::SchemaAttributeEditor > ui
 
dunedaq::oks::OksClassSchemaClass
 
dunedaq::oks::OksAttributeSchemaAttribute
 
bool UsedNew
 

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 )
17{
18 QWidget::setAttribute(Qt::WA_DeleteOnClose);
19 ui->setupUi ( this );
22}
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 24 of file SchemaAttributeEditor.cpp.

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

Member Function Documentation

◆ ClassUpdated

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

Definition at line 129 of file SchemaAttributeEditor.cpp.

130{
131 if(!UsedNew && ClassName.toStdString() == SchemaClass->get_name()) {
133 FillInfo();
134 } else {
135 QWidget::close();
136 }
137 }
138}
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 40 of file SchemaAttributeEditor.cpp.

41{
42 setWindowTitle ( QString ( "Attribute Editor : %1" ).arg (
43 SchemaAttribute->get_name().c_str() ) );
44 setObjectName ( QString::fromStdString ( SchemaAttribute->get_name() ) );
45 ui->AttributeNameLineEdit->setText ( QString::fromStdString (
47 ui->AttributeTypeComboBox->setCurrentIndex (
48 ui->AttributeTypeComboBox->findData ( QString::fromStdString (
50 Qt::DisplayRole ) );
51
53 ui->AttributeIsMultivariable->setCurrentIndex (
54 0 );
55 else
56 {
57 ui->AttributeIsMultivariable->setCurrentIndex ( 1 );
58 }
59
61 {
62 ui->AttributeIsNotNull->setCurrentIndex ( 0 );
63 }
64 else
65 {
66 ui->AttributeIsNotNull->setCurrentIndex ( 1 );
67 }
68
69 ui->AttributeDescriptionTextBox->setPlainText (
70 QString::fromStdString ( SchemaAttribute->get_description() ) );
71 ui->AttributeRangeLineEdit->setText ( QString::fromStdString (
73 ui->AttributeInitialValue->setText (
74 QString::fromStdString ( SchemaAttribute->get_init_value() ) );
75
76 int Index = ui->AttributeTypeComboBox->currentIndex();
77
78 if ( Index == 0 || Index >= 9 )
79 {
80 ui->FormatLayout->setEnabled ( false );
81 ui->FormatLabel->hide();
82 ui->AttributeFormatComboBox->hide();
83 }
84 else
85 {
86 ui->FormatLayout->setEnabled ( true );
87 ui->FormatLabel->show();
88 ui->AttributeFormatComboBox->show();
89
91 ui->AttributeFormatComboBox->setCurrentIndex (
92 0 );
94 ui->AttributeFormatComboBox->setCurrentIndex (
95 1 );
96 else
97 {
98 ui->AttributeFormatComboBox->setCurrentIndex ( 2 );
99 }
100 }
101}
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 103 of file SchemaAttributeEditor.cpp.

104{
105 QStringList Items
106 {
107 "bool", "s8", "u8", "s16", "u16", "s32", "u32", "s64", "u64", "float", "double", "date",
108 "time", "string", "enum", "class" };
109 ui->AttributeTypeComboBox->addItems ( Items );
110 setWindowTitle ( QString::fromStdString ( "New Attribute" ) );
111 setObjectName ( "NEW" );
112
113 if ( !UsedNew )
114 {
115 FillInfo();
116 }
117}

◆ ParseToCreate()

void dbse::SchemaAttributeEditor::ParseToCreate ( )

Making sure we dont get anything weird

Creating attribute and updating

Definition at line 281 of file SchemaAttributeEditor.cpp.

282{
283 std::string AttributeName = ui->AttributeNameLineEdit->text().toStdString();
284 std::string AttributeType = ui->AttributeTypeComboBox->currentText().toStdString();
285 char AttributeFormatChar = ( ui->AttributeFormatComboBox->currentText().toStdString() ) [0];
286
287 OksAttribute::Format AttributeFormat;
288
289 switch ( AttributeFormatChar )
290 {
291 case 'D':
292 AttributeFormat = OksAttribute::Format::Dec;
293 break;
294
295 case 'O':
296 AttributeFormat = OksAttribute::Format::Oct;
297 break;
298
299 case 'H':
300 AttributeFormat = OksAttribute::Format::Hex;
301 break;
302
303 default:
304 AttributeFormat = OksAttribute::Format::Dec;
305 break;
306 }
307
309 int Index = ui->AttributeTypeComboBox->currentIndex();
310
311 if ( Index == 0 || Index >= 9 )
312 {
313 AttributeFormat = OksAttribute::Format::Dec;
314 }
315
316 bool IsMultivariable = false;
317
318 switch ( ui->AttributeIsMultivariable->currentIndex() )
319 {
320 case 0:
321 IsMultivariable = true;
322 break;
323
324 case 1:
325 IsMultivariable = false;
326 break;
327
328 default:
329 IsMultivariable = false;
330 break;
331 }
332
333 bool IsNotNull = false;
334
335 switch ( ui->AttributeIsNotNull->currentIndex() )
336 {
337 case 0:
338 IsNotNull = true;
339 break;
340
341 case 1:
342 IsNotNull = false;
343 break;
344
345 default:
346 IsNotNull = false;
347 break;
348 }
349
350 std::string AttributeDescription =
351 ui->AttributeDescriptionTextBox->toPlainText().toStdString();
352 std::string AttributeRange = ui->AttributeRangeLineEdit->text().toStdString();
353 std::string AttributeInitial = ui->AttributeInitialValue->text().toStdString();
354
357 AttributeType, IsMultivariable,
358 AttributeRange, AttributeInitial,
359 AttributeDescription, IsNotNull,
360 AttributeFormat );
361 emit RebuildModel();
362 close();
363}
static KernelWrapper & GetInstance()
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 140 of file SchemaAttributeEditor.cpp.

141{
142 bool Changed = false;
143 std::string AttributeName = ui->AttributeNameLineEdit->text().toStdString();
144 std::string AttributeType = ui->AttributeTypeComboBox->currentText().toStdString();
145 char AttributeFormatChar = ( ui->AttributeFormatComboBox->currentText().toStdString() ) [0];
146
147 OksAttribute::Format AttributeFormat;
148
149 switch ( AttributeFormatChar )
150 {
151 case 'D':
152 AttributeFormat = OksAttribute::Format::Dec;
153 break;
154
155 case 'O':
156 AttributeFormat = OksAttribute::Format::Oct;
157 break;
158
159 case 'H':
160 AttributeFormat = OksAttribute::Format::Hex;
161 break;
162
163 default:
164 AttributeFormat = OksAttribute::Format::Dec;
165 break;
166 }
167
169 int Index = ui->AttributeTypeComboBox->currentIndex();
170
171 if ( Index == 0 || Index >= 9 )
172 {
173 AttributeFormat = OksAttribute::Format::Dec;
174 }
175
176 bool IsMultivariable = false;
177
178 switch ( ui->AttributeIsMultivariable->currentIndex() )
179 {
180 case 0:
181 IsMultivariable = true;
182 break;
183
184 case 1:
185 IsMultivariable = false;
186 break;
187
188 default:
189 IsMultivariable = false;
190 break;
191 }
192
193 bool IsNotNull = false;
194
195 switch ( ui->AttributeIsNotNull->currentIndex() )
196 {
197 case 0:
198 IsNotNull = true;
199 break;
200
201 case 1:
202 IsNotNull = false;
203 break;
204
205 default:
206 IsNotNull = false;
207 break;
208 }
209
210 std::string AttributeDescription =
211 ui->AttributeDescriptionTextBox->toPlainText().toStdString();
212 std::string AttributeRange = ui->AttributeRangeLineEdit->text().toStdString();
213 std::string AttributeInitial = ui->AttributeInitialValue->text().toStdString();
214
215 if ( AttributeName != SchemaAttribute->get_name() )
216 {
218 Changed = true;
219 }
220
221 if ( AttributeType != SchemaAttribute->get_type() )
222 {
224 Changed = true;
225 }
226
227 if ( AttributeFormat != SchemaAttribute->get_format() )
228 {
231 AttributeFormat );
232 Changed = true;
233 }
234
235 if ( IsMultivariable != SchemaAttribute->get_is_multi_values() )
236 {
239 IsMultivariable );
240 Changed = true;
241 }
242
243 if ( IsNotNull != SchemaAttribute->get_is_no_null() )
244 {
246 Changed = true;
247 }
248
249 if ( AttributeDescription != SchemaAttribute->get_description() )
250 {
253 AttributeDescription );
254 Changed = true;
255 }
256
257 if ( AttributeRange != SchemaAttribute->get_range() )
258 {
261 AttributeRange );
262 Changed = true;
263 }
264
265 if ( AttributeInitial != SchemaAttribute->get_init_value() )
266 {
269 AttributeInitial );
270 Changed = true;
271 }
272
273 if ( Changed )
274 {
275 emit RebuildModel();
276 }
277
278 close();
279}
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 365 of file SchemaAttributeEditor.cpp.

366{
367 if ( UsedNew )
368 {
370 }
371 else
372 {
373 ParseToSave();
374 }
375}

◆ RebuildModel

void dbse::SchemaAttributeEditor::RebuildModel ( )
signal

◆ SetController()

void dbse::SchemaAttributeEditor::SetController ( )

Definition at line 119 of file SchemaAttributeEditor.cpp.

120{
121 connect ( ui->AttributeTypeComboBox, SIGNAL ( currentIndexChanged ( int ) ), this,
122 SLOT ( ToggleFormat ( int ) ) );
123 connect ( ui->buttonBox, SIGNAL ( accepted() ), this, SLOT ( ProxySlot() ) );
124 connect ( ui->buttonBox, SIGNAL ( rejected() ), this, SLOT ( close() ) );
125 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassUpdated ( QString ) ), this,
126 SLOT ( ClassUpdated ( QString ) ) );
127}
void ClassUpdated(QString ClassName)

◆ ToggleFormat

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

Definition at line 377 of file SchemaAttributeEditor.cpp.

378{
379 int Index = ui->AttributeTypeComboBox->currentIndex();
380
381 if ( Index == 0 || Index >= 9 )
382 {
383 ui->FormatLayout->setEnabled ( false );
384 ui->FormatLabel->hide();
385 ui->AttributeFormatComboBox->hide();
386 }
387 else
388 {
389 ui->FormatLayout->setEnabled ( true );
390 ui->FormatLabel->show();
391 ui->AttributeFormatComboBox->show();
392 }
393}

Member Data Documentation

◆ SchemaAttribute

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

Definition at line 36 of file SchemaAttributeEditor.hpp.

◆ SchemaClass

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

Definition at line 35 of file SchemaAttributeEditor.hpp.

◆ ui

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

Definition at line 34 of file SchemaAttributeEditor.hpp.

◆ UsedNew

bool dbse::SchemaAttributeEditor::UsedNew
private

Definition at line 37 of file SchemaAttributeEditor.hpp.


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