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

#include <SchemaClassEditor.hpp>

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

Public Member Functions

 ~SchemaClassEditor ()
 
 SchemaClassEditor (dunedaq::oks::OksClass *ClassInfo, QWidget *parent=nullptr)
 

Static Public Member Functions

static void createNewClass ()
 

Private Slots

void OpenSuperClass (QModelIndex Index)
 
void OpenSubClass (QModelIndex Index)
 
void ProxySlot ()
 
void ParseToSave ()
 
void AddNewSuperClass ()
 
void AddNewAttribute ()
 
void AddNewRelationship ()
 
void AddNewMethod ()
 
void OpenAttributeEditor (QModelIndex Index)
 
void OpenRelationshipEditor (QModelIndex Index)
 
void OpenMethodEditor (QModelIndex Index)
 
void BuildAttributeModelSlot ()
 
void BuildRelationshipModelSlot ()
 
void BuildSuperClassModelSlot ()
 
void BuildSubClassModelSlot ()
 
void BuildMethodModelSlot ()
 
void CustomMenuAttributeView (QPoint pos)
 Context Menu Functions.
 
void CustomMenuRelationshipView (QPoint pos)
 
void CustomMenuMethodView (QPoint pos)
 
void CustomMenuClassView (QPoint pos)
 
void RemoveAttribute ()
 Remove Functions.
 
void RemoveRelationship ()
 
void RemoveMethod ()
 
void RemoveSuperClass ()
 
void ClassRemoved (QString className)
 
void ClassUpdated (QString className)
 

Private Member Functions

void SetController ()
 
void BuildModels ()
 
void InitialSettings ()
 
bool ShouldOpenAttributeEditor (QString Name)
 Helper functions.
 
bool ShouldOpenRelationshipEditor (QString Name)
 
bool ShouldOpenMethodEditor (QString Name)
 
void OpenNewClassEditor (const QString &ClassName)
 

Private Attributes

std::unique_ptr< dbse::Ui::SchemaClassEditor > ui
 
dunedaq::oks::OksClassSchemaClass
 
CustomMethodModelMethodModel
 
CustomAttributeModelAttributeModel
 
CustomRelationshipModelRelationshipModel
 
CustomSuperClassModelSuperClassModel
 
CustomSubClassModelSubClassModel
 
QMenu * ContextMenuAttribute
 
QMenu * ContextMenuRelationship
 
QMenu * ContextMenuMethod
 
QMenu * ContextMenuClass
 
QStringList CurrentRow
 

Detailed Description

Definition at line 25 of file SchemaClassEditor.hpp.

Constructor & Destructor Documentation

◆ ~SchemaClassEditor()

dbse::SchemaClassEditor::~SchemaClassEditor ( )
default

◆ SchemaClassEditor()

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

Settings

Settings

Editing Settings

Definition at line 16 of file SchemaClassEditor.cpp.

17 : QWidget ( parent ),
18 ui ( new Ui::SchemaClassEditor ),
19 SchemaClass ( ClassInfo ),
20 MethodModel ( nullptr ),
21 AttributeModel ( nullptr ),
22 RelationshipModel ( nullptr ),
23 SuperClassModel ( nullptr ),
24 SubClassModel ( nullptr ),
25 ContextMenuAttribute ( nullptr ),
26 ContextMenuRelationship ( nullptr ),
27 ContextMenuMethod ( nullptr ),
28 ContextMenuClass ( nullptr )
29{
30 QWidget::setAttribute(Qt::WA_DeleteOnClose);
31
33 ui->setupUi ( this );
34 setWindowTitle (
35 QString ( "Class Editor : %1" ).arg ( QString::fromStdString (
36 SchemaClass->get_name() ) ) );
37 setObjectName ( QString::fromStdString ( SchemaClass->get_name() ) );
43}
CustomRelationshipModel * RelationshipModel
CustomSuperClassModel * SuperClassModel
CustomMethodModel * MethodModel
dunedaq::oks::OksClass * SchemaClass
CustomAttributeModel * AttributeModel
std::unique_ptr< dbse::Ui::SchemaClassEditor > ui
CustomSubClassModel * SubClassModel
const std::string & get_name() const noexcept
Definition class.hpp:363

Member Function Documentation

◆ AddNewAttribute

void dbse::SchemaClassEditor::AddNewAttribute ( )
privateslot

Definition at line 338 of file SchemaClassEditor.cpp.

339{
340 SchemaAttributeEditor * Editor = new SchemaAttributeEditor ( SchemaClass );
341 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildAttributeModelSlot() ) );
342 Editor->show();
343}

◆ AddNewMethod

void dbse::SchemaClassEditor::AddNewMethod ( )
privateslot

Definition at line 352 of file SchemaClassEditor.cpp.

353{
354 SchemaMethodEditor * Editor = new SchemaMethodEditor ( SchemaClass );
355 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildMethodModelSlot() ) );
356 Editor->show();
357}

◆ AddNewRelationship

void dbse::SchemaClassEditor::AddNewRelationship ( )
privateslot

Definition at line 345 of file SchemaClassEditor.cpp.

346{
347 SchemaRelationshipEditor * Editor = new SchemaRelationshipEditor ( SchemaClass );
348 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildRelationshipModelSlot() ) );
349 Editor->show();
350}

◆ AddNewSuperClass

void dbse::SchemaClassEditor::AddNewSuperClass ( )
privateslot

Definition at line 304 of file SchemaClassEditor.cpp.

305{
306 QWidget* w = new QWidget();
307
308 QLabel* label = new QLabel("Double click on a list item to add the corresponding super-class");
309 label->setWordWrap(true);
310
311 QLabel* status = new QLabel();
312 status->setStyleSheet("QLabel { color : green; }");
313
314 QListWidget* qlw = new QListWidget();
315 QStringList allClasses;
317 qlw->addItems(allClasses);
318
319 connect ( qlw, &QListWidget::itemDoubleClicked,
320 this, [=] () {
321 const std::string& className = qlw->currentItem()->text().toStdString();
323 BuildModels();
324 status->setText(QString::fromStdString(className + " added as a super-class of " + SchemaClass->get_name()));
325 });
326
327 QVBoxLayout* l = new QVBoxLayout();
328 l->addWidget(label);
329 l->addWidget(qlw);
330 l->addWidget(status);
331
332 w->setWindowTitle("Select super-classe(s)");
333 w->setLayout(l);
334 w->setParent(this, Qt::Dialog);
335 w->show();
336}
void GetClassListString(QStringList &ClassListString) const
static KernelWrapper & GetInstance()
void PushAddSuperClassCommand(dunedaq::oks::OksClass *Class, std::string SuperClass)

◆ BuildAttributeModelSlot

void dbse::SchemaClassEditor::BuildAttributeModelSlot ( )
privateslot

Definition at line 451 of file SchemaClassEditor.cpp.

452{
453 QStringList AttributeHeaders
454 { "Name", "Type" };
455
456 if ( AttributeModel == nullptr ) AttributeModel = new CustomAttributeModel ( SchemaClass,
457 AttributeHeaders,
458 ui->ShowDerivedAttributes->isChecked());
459 else
460 {
461 delete AttributeModel;
462 AttributeModel = new CustomAttributeModel ( SchemaClass, AttributeHeaders, ui->ShowDerivedAttributes->isChecked() );
463 }
464
465 ui->AttributeView->setModel ( AttributeModel );
466 ui->AttributeView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
467 ui->AttributeView->setSelectionBehavior ( QAbstractItemView::SelectRows );
468}

◆ BuildMethodModelSlot

void dbse::SchemaClassEditor::BuildMethodModelSlot ( )
privateslot

Definition at line 488 of file SchemaClassEditor.cpp.

489{
490 QStringList MethodHeaders
491 { "Method Name" };
492
493 if ( MethodModel == nullptr )
494 {
495 MethodModel = new CustomMethodModel ( SchemaClass, MethodHeaders, ui->ShowDerivedMethods->isChecked() );
496 }
497 else
498 {
499 delete MethodModel;
500 MethodModel = new CustomMethodModel ( SchemaClass, MethodHeaders, ui->ShowDerivedMethods->isChecked() );
501 }
502
503 ui->MethodsView->setModel ( MethodModel );
504 ui->MethodsView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
505 ui->MethodsView->setSelectionBehavior ( QAbstractItemView::SelectRows );
506}

◆ BuildModels()

void dbse::SchemaClassEditor::BuildModels ( )
private

◆ BuildRelationshipModelSlot

void dbse::SchemaClassEditor::BuildRelationshipModelSlot ( )
privateslot

Definition at line 470 of file SchemaClassEditor.cpp.

471{
472 QStringList RelationshipHeaders
473 { "Name", "Type", "Low cc", "High cc" };
474
475 if ( RelationshipModel == nullptr ) RelationshipModel = new CustomRelationshipModel (
476 SchemaClass, RelationshipHeaders, ui->ShowDerivedRelationships->isChecked() );
477 else
478 {
479 delete RelationshipModel;
480 RelationshipModel = new CustomRelationshipModel ( SchemaClass, RelationshipHeaders, ui->ShowDerivedRelationships->isChecked() );
481 }
482
483 ui->RelationshipView->setModel ( RelationshipModel );
484 ui->RelationshipView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
485 ui->RelationshipView->setSelectionBehavior ( QAbstractItemView::SelectRows );
486}

◆ BuildSubClassModelSlot

void dbse::SchemaClassEditor::BuildSubClassModelSlot ( )
privateslot

Definition at line 528 of file SchemaClassEditor.cpp.

529{
530 QStringList SubClassHeaders
531 { "Class Name" };
532
533 if ( SubClassModel == nullptr )
534 {
535 SubClassModel = new CustomSubClassModel ( SchemaClass, SubClassHeaders );
536 }
537 else
538 {
539 delete SubClassModel;
540 SubClassModel = new CustomSubClassModel ( SchemaClass, SubClassHeaders );
541 }
542
543 ui->SubClassView->setModel ( SubClassModel );
544 ui->SubClassView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
545 ui->SubClassView->setSelectionBehavior ( QAbstractItemView::SelectRows );
546}

◆ BuildSuperClassModelSlot

void dbse::SchemaClassEditor::BuildSuperClassModelSlot ( )
privateslot

Definition at line 508 of file SchemaClassEditor.cpp.

509{
510 QStringList SuperClassHeaders
511 { "Class Name" };
512
513 if ( SuperClassModel == nullptr )
514 {
515 SuperClassModel = new CustomSuperClassModel ( SchemaClass, SuperClassHeaders, ui->ShowAllSuperClasses->isChecked() );
516 }
517 else
518 {
519 delete SuperClassModel;
520 SuperClassModel = new CustomSuperClassModel ( SchemaClass, SuperClassHeaders, ui->ShowAllSuperClasses->isChecked() );
521 }
522
523 ui->SuperClassView->setModel ( SuperClassModel );
524 ui->SuperClassView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
525 ui->SuperClassView->setSelectionBehavior ( QAbstractItemView::SelectRows );
526}

◆ ClassRemoved

void dbse::SchemaClassEditor::ClassRemoved ( QString className)
privateslot

Definition at line 83 of file SchemaClassEditor.cpp.

84{
85 if(className == objectName()) {
86 QWidget::close();
87 }
88}

◆ ClassUpdated

void dbse::SchemaClassEditor::ClassUpdated ( QString className)
privateslot

Definition at line 90 of file SchemaClassEditor.cpp.

91{
92 if(className == objectName()) {
95 }
96}

◆ createNewClass()

void dbse::SchemaClassEditor::createNewClass ( )
static

Definition at line 664 of file SchemaClassEditor.cpp.

665{
666 auto createNewClass = [] (const std::string& className) -> bool {
667 if ( !KernelWrapper::GetInstance().IsActive() )
668 {
669 QMessageBox::warning (
670 0,
671 "Schema editor",
672 QString (
673 "There is no active schema set!\n\nPlease set a schema file as active and continue!" ) );
674
675 return false;
676 }
677
678 if ( !KernelWrapper::GetInstance().FindClass ( className ) )
679 {
681 "", false );
682 return true;
683 }
684 else
685 {
686 QMessageBox::warning ( 0, "Schema editor",
687 QString ( "Can not create class because class already exist !" ) );
688
689 return false;
690 }
691 };
692
693 bool ok;
694 QString text = QInputDialog::getText(nullptr, "Schema editor: create new class",
695 "New class name:", QLineEdit::Normal,
696 "NewOksClass", &ok);
697
698 if(ok && !text.isEmpty()) {
699 if(createNewClass(text.toStdString())) {
700 SchemaClassEditor * Editor = new SchemaClassEditor(KernelWrapper::GetInstance().FindClass(text.toStdString()));
701 Editor->show();
702 }
703 }
704}
void PushCreateClassCommand(std::string ClassName, std::string ClassDescription, bool Abstract)
SchemaClassEditor(dunedaq::oks::OksClass *ClassInfo, QWidget *parent=nullptr)

◆ CustomMenuAttributeView

void dbse::SchemaClassEditor::CustomMenuAttributeView ( QPoint pos)
privateslot

Context Menu Functions.

Definition at line 577 of file SchemaClassEditor.cpp.

578{
579 if ( ContextMenuAttribute == nullptr )
580 {
581 ContextMenuAttribute = new QMenu ( this );
582
583 QAction * Add = new QAction ( tr ( "&Add" ), this );
584 Add->setShortcut ( tr ( "Ctrl+A" ) );
585 Add->setShortcutContext ( Qt::WidgetShortcut );
586 connect ( Add, SIGNAL ( triggered() ), this, SLOT ( AddNewAttribute() ) );
587
588 QAction * Remove = new QAction ( tr ( "&Remove" ), this );
589 Remove->setShortcut ( tr ( "Ctrl+R" ) );
590 Remove->setShortcutContext ( Qt::WidgetShortcut );
591 connect ( Remove, SIGNAL ( triggered() ), this, SLOT ( RemoveAttribute() ) );
592
593 ContextMenuAttribute->addAction ( Add );
594 ContextMenuAttribute->addAction ( Remove );
595 }
596
597 QModelIndex Index = ui->AttributeView->currentIndex();
598
599 if ( Index.isValid() )
600 {
602 ContextMenuAttribute->exec ( ui->AttributeView->mapToGlobal ( pos ) );
603 }
604}
QStringList getRowFromIndex(QModelIndex &index)
void RemoveAttribute()
Remove Functions.

◆ CustomMenuClassView

void dbse::SchemaClassEditor::CustomMenuClassView ( QPoint pos)
privateslot

Definition at line 548 of file SchemaClassEditor.cpp.

549{
550 if ( ContextMenuClass == nullptr )
551 {
552 ContextMenuClass = new QMenu ( this );
553
554 QAction * Add = new QAction ( tr ( "&Add" ), this );
555 Add->setShortcut ( tr ( "Ctrl+A" ) );
556 Add->setShortcutContext ( Qt::WidgetShortcut );
557 connect ( Add, SIGNAL ( triggered() ), this, SLOT ( AddNewSuperClass() ) );
558
559 QAction * Remove = new QAction ( tr ( "&Remove" ), this );
560 Remove->setShortcut ( tr ( "Ctrl+R" ) );
561 Remove->setShortcutContext ( Qt::WidgetShortcut );
562 connect ( Remove, SIGNAL ( triggered() ), this, SLOT ( RemoveSuperClass() ) );
563
564 ContextMenuClass->addAction ( Add );
565 ContextMenuClass->addAction ( Remove );
566 }
567
568 QModelIndex Index = ui->SuperClassView->currentIndex();
569
570 if ( Index.isValid() )
571 {
573 ContextMenuClass->exec ( ui->SuperClassView->mapToGlobal ( pos ) );
574 }
575}

◆ CustomMenuMethodView

void dbse::SchemaClassEditor::CustomMenuMethodView ( QPoint pos)
privateslot

Definition at line 635 of file SchemaClassEditor.cpp.

636{
637 if ( ContextMenuMethod == nullptr )
638 {
639 ContextMenuMethod = new QMenu ( this );
640
641 QAction * Add = new QAction ( tr ( "&Add" ), this );
642 Add->setShortcut ( tr ( "Ctrl+A" ) );
643 Add->setShortcutContext ( Qt::WidgetShortcut );
644 connect ( Add, SIGNAL ( triggered() ), this, SLOT ( AddNewMethod() ) );
645
646 QAction * Remove = new QAction ( tr ( "&Remove" ), this );
647 Remove->setShortcut ( tr ( "Ctrl+R" ) );
648 Remove->setShortcutContext ( Qt::WidgetShortcut );
649 connect ( Remove, SIGNAL ( triggered() ), this, SLOT ( RemoveMethod() ) );
650
651 ContextMenuMethod->addAction ( Add );
652 ContextMenuMethod->addAction ( Remove );
653 }
654
655 QModelIndex Index = ui->MethodsView->currentIndex();
656
657 if ( Index.isValid() )
658 {
660 ContextMenuMethod->exec ( ui->MethodsView->mapToGlobal ( pos ) );
661 }
662}

◆ CustomMenuRelationshipView

void dbse::SchemaClassEditor::CustomMenuRelationshipView ( QPoint pos)
privateslot

Definition at line 606 of file SchemaClassEditor.cpp.

607{
608 if ( ContextMenuRelationship == nullptr )
609 {
610 ContextMenuRelationship = new QMenu ( this );
611
612 QAction * Add = new QAction ( tr ( "&Add" ), this );
613 Add->setShortcut ( tr ( "Ctrl+A" ) );
614 Add->setShortcutContext ( Qt::WidgetShortcut );
615 connect ( Add, SIGNAL ( triggered() ), this, SLOT ( AddNewRelationship() ) );
616
617 QAction * Remove = new QAction ( tr ( "&Remove" ), this );
618 Remove->setShortcut ( tr ( "Ctrl+R" ) );
619 Remove->setShortcutContext ( Qt::WidgetShortcut );
620 connect ( Remove, SIGNAL ( triggered() ), this, SLOT ( RemoveRelationship() ) );
621
622 ContextMenuRelationship->addAction ( Add );
623 ContextMenuRelationship->addAction ( Remove );
624 }
625
626 QModelIndex Index = ui->RelationshipView->currentIndex();
627
628 if ( Index.isValid() )
629 {
631 ContextMenuRelationship->exec ( ui->RelationshipView->mapToGlobal ( pos ) );
632 }
633}

◆ InitialSettings()

void dbse::SchemaClassEditor::InitialSettings ( )
private

Class Name

Schema File

Description

Abstract

Definition at line 107 of file SchemaClassEditor.cpp.

108{
109 ui->AttributeView->setContextMenuPolicy ( Qt::ContextMenuPolicy::CustomContextMenu );
110 ui->RelationshipView->setContextMenuPolicy ( Qt::ContextMenuPolicy::CustomContextMenu );
111 ui->MethodsView->setContextMenuPolicy ( Qt::ContextMenuPolicy::CustomContextMenu );
112 ui->SuperClassView->setContextMenuPolicy ( Qt::ContextMenuPolicy::CustomContextMenu );
113 ui->SubClassView->setContextMenuPolicy ( Qt::ContextMenuPolicy::CustomContextMenu );
114
116 ui->ClassNameLineEdit->setText ( QString::fromStdString ( SchemaClass->get_name() ) );
117 ui->ClassNameLineEdit->setEnabled ( false );
119 ui->SchemaFileLineEdit->setText ( QString::fromStdString ( SchemaClass->get_file()->get_short_file_name() ) );
120 ui->SchemaFileLineEdit->setEnabled ( false );
122 ui->DescriptionTextEdit->setPlainText ( QString::fromStdString ( SchemaClass->get_description() ) );
123
126 {
127 ui->AbstractComboBox->setCurrentIndex ( 0 );
128 }
129 else
130 {
131 ui->AbstractComboBox->setCurrentIndex ( 1 );
132 }
133}
bool get_is_abstract() const noexcept
Definition class.hpp:384
const std::string & get_description() const noexcept
Definition class.hpp:368
OksFile * get_file() const noexcept
Definition class.hpp:338
const std::string & get_short_file_name() const
Definition file.hpp:518

◆ OpenAttributeEditor

void dbse::SchemaClassEditor::OpenAttributeEditor ( QModelIndex Index)
privateslot

Definition at line 359 of file SchemaClassEditor.cpp.

360{
361 QStringList Row = AttributeModel->getRowFromIndex ( Index );
362 bool ShouldOpen = ShouldOpenAttributeEditor ( Row.at ( 0 ) );
363
364 if ( !Row.isEmpty() && ShouldOpen )
365 {
366 SchemaAttributeEditor * Editor = new SchemaAttributeEditor (
367 SchemaClass, SchemaClass->find_attribute ( Row.at ( 0 ).toStdString() ) );
368 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildAttributeModelSlot() ) );
369 Editor->show();
370 }
371}
bool ShouldOpenAttributeEditor(QString Name)
Helper functions.
OksAttribute * find_attribute(const std::string &name) const noexcept
Find attribute (search in this and base classes).
Definition class.cpp:1026

◆ OpenMethodEditor

void dbse::SchemaClassEditor::OpenMethodEditor ( QModelIndex Index)
privateslot

Definition at line 387 of file SchemaClassEditor.cpp.

388{
389 QStringList Row = MethodModel->getRowFromIndex ( Index );
390 bool ShouldOpen = ShouldOpenMethodEditor ( Row.at ( 0 ) );
391
392 if ( !Row.isEmpty() && ShouldOpen )
393 {
394 SchemaMethodEditor * Editor = new SchemaMethodEditor (
395 SchemaClass, SchemaClass->find_method ( Row.at ( 0 ).toStdString() ) );
396 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildMethodModelSlot() ) );
397 Editor->show();
398 }
399}
bool ShouldOpenMethodEditor(QString Name)
OksMethod * find_method(const std::string &name) const noexcept
Find method (search in this and base classes).
Definition class.cpp:1341

◆ OpenNewClassEditor()

void dbse::SchemaClassEditor::OpenNewClassEditor ( const QString & ClassName)
private

Definition at line 423 of file SchemaClassEditor.cpp.

424{
425 bool WidgetFound = false;
426 OksClass * ClassInfo = KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() );
427
428 for ( QWidget * Editor : QApplication::allWidgets() )
429 {
430 SchemaClassEditor * Widget = dynamic_cast<SchemaClassEditor *> ( Editor );
431
432 if ( Widget != nullptr )
433 {
434 if ( ( Widget->objectName() ).compare ( ClassName ) == 0 )
435 {
436 Widget->raise();
437 Widget->setVisible ( true );
438 Widget->activateWindow();
439 WidgetFound = true;
440 }
441 }
442 }
443
444 if ( !WidgetFound )
445 {
446 SchemaClassEditor * Editor = new SchemaClassEditor ( ClassInfo );
447 Editor->show();
448 }
449}
dunedaq::oks::OksClass * FindClass(std::string ClassName) const
The OKS class.
Definition class.hpp:200

◆ OpenRelationshipEditor

void dbse::SchemaClassEditor::OpenRelationshipEditor ( QModelIndex Index)
privateslot

Definition at line 373 of file SchemaClassEditor.cpp.

374{
375 QStringList Row = RelationshipModel->getRowFromIndex ( Index );
376 bool ShouldOpen = ShouldOpenRelationshipEditor ( Row.at ( 0 ) );
377
378 if ( !Row.isEmpty() && ShouldOpen )
379 {
380 SchemaRelationshipEditor * Editor = new SchemaRelationshipEditor (
381 SchemaClass, SchemaClass->find_relationship ( Row.at ( 0 ).toStdString() ) );
382 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildRelationshipModelSlot() ) );
383 Editor->show();
384 }
385}
bool ShouldOpenRelationshipEditor(QString Name)
OksRelationship * find_relationship(const std::string &name) const noexcept
Find relationship (search in this and base classes).
Definition class.cpp:1184

◆ OpenSubClass

void dbse::SchemaClassEditor::OpenSubClass ( QModelIndex Index)
privateslot

Definition at line 412 of file SchemaClassEditor.cpp.

413{
414 QStringList Row = SubClassModel->getRowFromIndex ( Index );
415
416 if ( !Row.isEmpty() )
417 {
418 QString ClassName = Row.at ( 0 );
419 OpenNewClassEditor(ClassName);
420 }
421}
void OpenNewClassEditor(const QString &ClassName)

◆ OpenSuperClass

void dbse::SchemaClassEditor::OpenSuperClass ( QModelIndex Index)
privateslot

Definition at line 401 of file SchemaClassEditor.cpp.

402{
403 QStringList Row = SuperClassModel->getRowFromIndex ( Index );
404
405 if ( !Row.isEmpty() )
406 {
407 QString ClassName = Row.at ( 0 );
408 OpenNewClassEditor(ClassName);
409 }
410}

◆ ParseToSave

void dbse::SchemaClassEditor::ParseToSave ( )
privateslot

Definition at line 276 of file SchemaClassEditor.cpp.

277{
278 std::string NewDescription = ui->DescriptionTextEdit->toPlainText().toStdString();
279
280 bool Abstract = false;
281
282 if ( ui->AbstractComboBox->currentIndex() == 0 )
283 {
284 Abstract = true;
285 }
286 else
287 {
288 Abstract = false;
289 }
290
291 if ( Abstract != SchemaClass->get_is_abstract() )
292 {
294 }
295
296 if ( NewDescription != SchemaClass->get_description() )
297 {
299 }
300
301 close();
302}
void PushSetAbstractClassCommand(dunedaq::oks::OksClass *Class, bool Value)
void PushSetDescriptionClassCommand(dunedaq::oks::OksClass *Class, std::string Description)

◆ ProxySlot

void dbse::SchemaClassEditor::ProxySlot ( )
privateslot

Definition at line 271 of file SchemaClassEditor.cpp.

272{
273 ParseToSave();
274}

◆ RemoveAttribute

void dbse::SchemaClassEditor::RemoveAttribute ( )
privateslot

Remove Functions.

Definition at line 204 of file SchemaClassEditor.cpp.

205{
206 const std::string& attributeName = CurrentRow.at ( 0 ).toStdString();
207 OksAttribute * SchemaAttribute = SchemaClass->find_direct_attribute( attributeName );
208 if(SchemaAttribute != nullptr) {
210 SchemaClass, SchemaAttribute, SchemaAttribute->get_name(), SchemaAttribute->get_type(),
211 SchemaAttribute->get_is_multi_values(), SchemaAttribute->get_range(),
212 SchemaAttribute->get_init_value(), SchemaAttribute->get_description(),
213 SchemaAttribute->get_is_no_null(), SchemaAttribute->get_format() );
214 } else {
215 QMessageBox::warning ( 0, "Schema editor",
216 QString::fromStdString( "Cannot remove attribute \"" + attributeName +
217 "\" because it is not a direct attribute of \"" + SchemaClass->get_name() + "\"") );
218 }
219}
void PushRemoveAttributeCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, 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)
OKS attribute class.
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_name() const noexcept
out stream operator
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.
OksAttribute * find_direct_attribute(const std::string &name) const noexcept
Find direct attribute.
Definition class.cpp:1014

◆ RemoveMethod

void dbse::SchemaClassEditor::RemoveMethod ( )
privateslot

Definition at line 240 of file SchemaClassEditor.cpp.

241{
242 const std::string& methodName = CurrentRow.at ( 0 ).toStdString();
243 OksMethod * SchemaMethod = SchemaClass->find_direct_method ( methodName );
244 if(SchemaMethod != nullptr) {
246 SchemaMethod->get_name(),
247 SchemaMethod->get_description() );
248 } else {
249 QMessageBox::warning ( 0, "Schema editor",
250 QString::fromStdString( "Cannot remove method \"" + methodName +
251 "\" because it is not a direct method of \"" + SchemaClass->get_name() + "\"") );
252 }
253}
void PushRemoveMethodCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string name, std::string description)
OksMethod * find_direct_method(const std::string &name) const noexcept
Find direct method.
Definition class.cpp:1330
OKS method class.
Definition method.hpp:153
const std::string & get_description() const noexcept
Definition method.hpp:214
const std::string & get_name() const noexcept
Definition method.hpp:196

◆ RemoveRelationship

void dbse::SchemaClassEditor::RemoveRelationship ( )
privateslot

Definition at line 221 of file SchemaClassEditor.cpp.

222{
223 const std::string& relationshipName = CurrentRow.at ( 0 ).toStdString();
224 OksRelationship * SchemaRelationship = SchemaClass->find_direct_relationship( relationshipName );
225 if(SchemaRelationship != nullptr) {
227 SchemaClass, SchemaRelationship, SchemaRelationship->get_name(),
228 SchemaRelationship->get_description(), SchemaRelationship->get_type(),
229 SchemaRelationship->get_is_composite(), SchemaRelationship->get_is_exclusive(),
230 SchemaRelationship->get_is_dependent(),
231 SchemaRelationship->get_low_cardinality_constraint(),
232 SchemaRelationship->get_high_cardinality_constraint() );
233 } else {
234 QMessageBox::warning ( 0, "Schema editor",
235 QString::fromStdString( "Cannot remove relationship \"" + relationshipName +
236 "\" because it is not a direct relationship of \"" + SchemaClass->get_name() + "\"") );
237 }
238}
void PushRemoveRelationship(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, std::string Name, std::string Description, std::string Type, bool Composite, bool Exclusive, bool Dependent, dunedaq::oks::OksRelationship::CardinalityConstraint LowCc, dunedaq::oks::OksRelationship::CardinalityConstraint HighCc)
OksRelationship * find_direct_relationship(const std::string &name) const noexcept
Find direct relationship.
Definition class.cpp:1173
bool get_is_exclusive() const noexcept
bool get_is_composite() const noexcept
bool get_is_dependent() const noexcept
const std::string & get_name() const noexcept
CardinalityConstraint get_high_cardinality_constraint() const noexcept
Get relationship high cardinality constraint.
const std::string & get_description() const noexcept
CardinalityConstraint get_low_cardinality_constraint() const noexcept
Get relationship low cardinality constraint.
const std::string & get_type() const noexcept

◆ RemoveSuperClass

void dbse::SchemaClassEditor::RemoveSuperClass ( )
privateslot

Definition at line 255 of file SchemaClassEditor.cpp.

256{
257 const std::string& superClassName = CurrentRow.at ( 0 ).toStdString();
258 if(SchemaClass->has_direct_super_class(superClassName))
259 {
261 }
262 else
263 {
264 QMessageBox::warning ( 0, "Schema editor",
265 QString::fromStdString( "Cannot remove super-class \"" + superClassName +
266 "\" because it is not a direct super-class of \"" + SchemaClass->get_name() + "\"") );
267 }
268}
void PushRemoveSuperClassCommand(dunedaq::oks::OksClass *Class, std::string SuperClass)
bool has_direct_super_class(const std::string &) const noexcept
Definition class.cpp:754

◆ SetController()

void dbse::SchemaClassEditor::SetController ( )
private

Definition at line 47 of file SchemaClassEditor.cpp.

48{
49 connect ( ui->SaveButton, SIGNAL ( clicked() ), this, SLOT ( ProxySlot() ) );
50 connect ( ui->AddButtonAttribute, SIGNAL ( clicked() ), this, SLOT ( AddNewAttribute() ) );
51 connect ( ui->AddButtonSuperClass, SIGNAL ( clicked() ), this, SLOT ( AddNewSuperClass() ) );
52 connect ( ui->AddButtonRelationship, SIGNAL ( clicked() ), this,
53 SLOT ( AddNewRelationship() ) );
54 connect ( ui->AddButtonMethod, SIGNAL ( clicked() ), this, SLOT ( AddNewMethod() ) );
55 connect ( ui->RelationshipView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
56 SLOT ( OpenRelationshipEditor ( QModelIndex ) ) );
57 connect ( ui->MethodsView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
58 SLOT ( OpenMethodEditor ( QModelIndex ) ) );
59 connect ( ui->AttributeView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
60 SLOT ( OpenAttributeEditor ( QModelIndex ) ) );
61 connect ( ui->SuperClassView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
62 SLOT ( OpenSuperClass ( QModelIndex ) ) );
63 connect ( ui->SubClassView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
64 SLOT ( OpenSubClass ( QModelIndex ) ) );
65 connect ( ui->AttributeView, SIGNAL ( customContextMenuRequested ( QPoint ) ), this,
66 SLOT ( CustomMenuAttributeView ( QPoint ) ) );
67 connect ( ui->RelationshipView, SIGNAL ( customContextMenuRequested ( QPoint ) ), this,
68 SLOT ( CustomMenuRelationshipView ( QPoint ) ) );
69 connect ( ui->MethodsView, SIGNAL ( customContextMenuRequested ( QPoint ) ), this,
70 SLOT ( CustomMenuMethodView ( QPoint ) ) );
71 connect ( ui->SuperClassView, SIGNAL ( customContextMenuRequested ( QPoint ) ), this,
72 SLOT ( CustomMenuClassView ( QPoint ) ) );
73 connect ( ui->ShowDerivedAttributes, &QCheckBox::toggled, this, &SchemaClassEditor::BuildAttributeModelSlot );
74 connect ( ui->ShowDerivedRelationships, &QCheckBox::toggled, this, &SchemaClassEditor::BuildRelationshipModelSlot );
75 connect ( ui->ShowDerivedMethods, &QCheckBox::toggled, this, &SchemaClassEditor::BuildMethodModelSlot );
76 connect ( ui->ShowAllSuperClasses, &QCheckBox::toggled, this, &SchemaClassEditor::BuildSuperClassModelSlot );
77 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassRemoved ( QString ) ), this,
78 SLOT ( ClassRemoved ( QString ) ) );
79 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassUpdated ( QString ) ), this,
80 SLOT ( ClassUpdated ( QString ) ) );
81}
void CustomMenuMethodView(QPoint pos)
void OpenRelationshipEditor(QModelIndex Index)
void ClassUpdated(QString className)
void CustomMenuRelationshipView(QPoint pos)
void ClassRemoved(QString className)
void OpenSuperClass(QModelIndex Index)
void CustomMenuClassView(QPoint pos)
void OpenMethodEditor(QModelIndex Index)
void OpenSubClass(QModelIndex Index)
void OpenAttributeEditor(QModelIndex Index)
void CustomMenuAttributeView(QPoint pos)
Context Menu Functions.

◆ ShouldOpenAttributeEditor()

bool dbse::SchemaClassEditor::ShouldOpenAttributeEditor ( QString Name)
private

Helper functions.

Definition at line 135 of file SchemaClassEditor.cpp.

136{
137 bool WidgetFound = false;
138
139 for ( QWidget * Editor : QApplication::allWidgets() )
140 {
141 SchemaAttributeEditor * Widget = dynamic_cast<SchemaAttributeEditor *> ( Editor );
142
143 if ( Widget != nullptr )
144 {
145 if ( ( Widget->objectName() ).compare ( Name ) == 0 )
146 {
147 Widget->raise();
148 Widget->setVisible ( true );
149 Widget->activateWindow();
150 WidgetFound = true;
151 }
152 }
153 }
154
155 return !WidgetFound;
156}

◆ ShouldOpenMethodEditor()

bool dbse::SchemaClassEditor::ShouldOpenMethodEditor ( QString Name)
private

Definition at line 181 of file SchemaClassEditor.cpp.

182{
183 bool WidgetFound = false;
184
185 for ( QWidget * Editor : QApplication::allWidgets() )
186 {
187 SchemaMethodEditor * Widget = dynamic_cast<SchemaMethodEditor *> ( Editor );
188
189 if ( Widget != nullptr )
190 {
191 if ( ( Widget->objectName() ).compare ( Name ) == 0 )
192 {
193 Widget->raise();
194 Widget->setVisible ( true );
195 Widget->activateWindow();
196 WidgetFound = true;
197 }
198 }
199 }
200
201 return !WidgetFound;
202}

◆ ShouldOpenRelationshipEditor()

bool dbse::SchemaClassEditor::ShouldOpenRelationshipEditor ( QString Name)
private

Definition at line 158 of file SchemaClassEditor.cpp.

159{
160 bool WidgetFound = false;
161
162 for ( QWidget * Editor : QApplication::allWidgets() )
163 {
164 SchemaRelationshipEditor * Widget = dynamic_cast<SchemaRelationshipEditor *> ( Editor );
165
166 if ( Widget != nullptr )
167 {
168 if ( ( Widget->objectName() ).compare ( Name ) == 0 )
169 {
170 Widget->raise();
171 Widget->setVisible ( true );
172 Widget->activateWindow();
173 WidgetFound = true;
174 }
175 }
176 }
177
178 return !WidgetFound;
179}

Member Data Documentation

◆ AttributeModel

CustomAttributeModel* dbse::SchemaClassEditor::AttributeModel
private

Definition at line 48 of file SchemaClassEditor.hpp.

◆ ContextMenuAttribute

QMenu* dbse::SchemaClassEditor::ContextMenuAttribute
private

Definition at line 52 of file SchemaClassEditor.hpp.

◆ ContextMenuClass

QMenu* dbse::SchemaClassEditor::ContextMenuClass
private

Definition at line 55 of file SchemaClassEditor.hpp.

◆ ContextMenuMethod

QMenu* dbse::SchemaClassEditor::ContextMenuMethod
private

Definition at line 54 of file SchemaClassEditor.hpp.

◆ ContextMenuRelationship

QMenu* dbse::SchemaClassEditor::ContextMenuRelationship
private

Definition at line 53 of file SchemaClassEditor.hpp.

◆ CurrentRow

QStringList dbse::SchemaClassEditor::CurrentRow
private

Definition at line 56 of file SchemaClassEditor.hpp.

◆ MethodModel

CustomMethodModel* dbse::SchemaClassEditor::MethodModel
private

Definition at line 47 of file SchemaClassEditor.hpp.

◆ RelationshipModel

CustomRelationshipModel* dbse::SchemaClassEditor::RelationshipModel
private

Definition at line 49 of file SchemaClassEditor.hpp.

◆ SchemaClass

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

Definition at line 46 of file SchemaClassEditor.hpp.

◆ SubClassModel

CustomSubClassModel* dbse::SchemaClassEditor::SubClassModel
private

Definition at line 51 of file SchemaClassEditor.hpp.

◆ SuperClassModel

CustomSuperClassModel* dbse::SchemaClassEditor::SuperClassModel
private

Definition at line 50 of file SchemaClassEditor.hpp.

◆ ui

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

Definition at line 44 of file SchemaClassEditor.hpp.


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