39 object_to_edit ( nullptr ),
41 this_is_in_copy_mode ( true ),
42 this_editor_is_owned ( true ),
43 this_is_in_creation_mode ( true ),
44 this_editor_values_changed ( false ),
47 MainLayout ( new QHBoxLayout() ),
48 WidgetTable ( new NoScrollingTable() ),
50 RenameWidget ( nullptr ),
54 MoveWidget ( nullptr ),
56 IncludedFileModel ( nullptr ),
57 MoveGoButton ( nullptr ),
58 uuid ( QUuid::createUuid() )
62 ui->RenameButton->setDisabled (
true );
63 ui->ClassLabel->setText ( QString (
"New Object" ) );
68 int NumberOfColumns = 1;
71 setAttribute ( Qt::WA_DeleteOnClose,
true );
78 ui->DetailsGroupBox->setVisible (
false );
80 WidgetTable->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding );
81 WidgetTable->horizontalHeader()->setVisible (
false );
82 WidgetTable->horizontalHeader()->setSectionResizeMode ( QHeaderView::ResizeToContents );
83 WidgetTable->horizontalHeader()->setSectionResizeMode ( 0, QHeaderView::Stretch );
85 WidgetTable->setSelectionMode ( QAbstractItemView::NoSelection );
89 ui->ApplyButton->setEnabled (
false );
91 ui->RenameButton->setToolTip (
"Rename object" );
95 ui->RenameButton->setDisabled (
true );
96 ui->MoveButton->setDisabled (
true );
110 object_to_edit ( new
dref ( object ) ),
112 this_is_in_copy_mode ( iscopy ),
113 this_editor_is_owned ( false ),
114 this_is_in_creation_mode ( false ),
115 this_editor_values_changed ( false ),
117 MainLayout ( new QHBoxLayout() ),
118 WidgetTable ( new NoScrollingTable() ),
119 RenameWidget ( nullptr ),
120 LineEdit ( nullptr ),
121 GoButton ( nullptr ),
122 MoveWidget ( nullptr ),
123 FileView ( nullptr ),
124 IncludedFileModel ( nullptr ),
125 MoveGoButton ( nullptr ),
126 uuid ( QUuid::createUuid() )
128 ui->setupUi (
this );
130 ui->ClassLabel->setText (
131 QString (
"Full object name : %1@%2" ).arg (
Object().UID().c_str() ).arg (
132 Object().class_name().c_str() ) );
134 this->setWindowTitle (
135 QString (
"Edit Object %1 of Class %2" ).arg (
Object().UID().c_str() ).arg (
136 Object().class_name().c_str() ) );
138 this->setObjectName (
139 QString (
"%1@%2" ).arg (
Object().UID().c_str() ).arg (
Object().class_name().c_str() ) );
144 int NumberOfColumns = 1;
147 setAttribute ( Qt::WA_DeleteOnClose,
true );
154 ui->DetailsGroupBox->setVisible (
false );
156 WidgetTable->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding );
157 WidgetTable->horizontalHeader()->setVisible (
false );
158 WidgetTable->horizontalHeader()->setSectionResizeMode ( QHeaderView::ResizeToContents );
159 WidgetTable->horizontalHeader()->setSectionResizeMode ( 0, QHeaderView::Stretch );
161 WidgetTable->setSelectionMode ( QAbstractItemView::NoSelection );
165 ui->ApplyButton->setEnabled (
false );
167 ui->RenameButton->setToolTip (
"Rename object" );
171 ui->RenameButton->setDisabled (
true );
172 ui->MoveButton->setDisabled (
true );
263 connect ( ui->DetailButton, SIGNAL ( toggled (
bool ) ), ui->DetailsGroupBox,
264 SLOT ( setVisible (
bool ) ), Qt::UniqueConnection );
266 connect ( ui->CloseButton, SIGNAL ( clicked (
bool ) ),
this, SLOT ( close() ),
267 Qt::UniqueConnection );
269 connect ( ui->ApplyButton, SIGNAL ( clicked() ),
this, SLOT ( ParseToSave() ),
270 Qt::UniqueConnection );
272 connect ( ui->RenameButton, SIGNAL ( clicked() ),
this, SLOT ( LaunchRenameObject() ) );
273 connect ( ui->MoveButton, SIGNAL ( clicked() ),
this, SLOT ( LaunchMoveObject() ) );
276 SLOT ( UpdateObjectEditor ( QString,
dref ) ) );
279 SLOT ( ShouldCloseThisWindow ( QString,
dref ) ) );
282 if(mainwin !=
nullptr) {
283 connect (mainwin, SIGNAL(signal_batch_change_stopped(
const QList<QPair<QString, QString>>&)),
284 this, SLOT(UpdateObjectEditor(
const QList<QPair<QString, QString>>&)), Qt::UniqueConnection);
285 connect (mainwin, SIGNAL(signal_externalchanges_processed()),
286 this, SLOT(UpdateObjectEditor()), Qt::UniqueConnection);
319 if ( not this_editor_is_owned and object_to_edit and Object().UID() == updated_object.
UID()
320 and Object().class_name() == updated_object.
class_name() )
323 object_to_edit.reset (
new dref ( updated_object ) );
327 std::vector<dunedaq::conffwk::attribute_t> class_attributes = classdef.
p_attributes;
328 std::vector<dunedaq::conffwk::relationship_t> class_relations = classdef.
p_relationships;
333 this_widgets[QString::fromStdString ( attr.p_name )] )
335 set_attribute_widget ( attr, attreditor );
341 QStringList relvalues;
342 QString relname = QString ( arelation.p_name.c_str() );
347 if ( relwidget->ischanged() )
349 relvalues = relwidget->getdata();
353 std::vector<tref> connected;
359 connected.push_back (
362 catch ( daq::dbe::config_object_retrieval_result_is_null
const & e )
370 dbegraph::linked::through::relation<std::vector<tref>> ( Object(), arelation );
373 std::transform ( connected.begin(), connected.end(), std::back_inserter ( relvalues ),
374 [] ( decltype ( connected ) ::value_type
const & x )
376 return QString::fromStdString ( x.UID() );
383 relwidget->setdata ( relvalues );
384 relwidget->SetEditor();
390 const auto& s = size();
391 resize(s.width() + 1, s.height() +1);
392 resize(s.width(), s.height());
418 std::vector<dunedaq::conffwk::attribute_t> attributes = classdef.
p_attributes;
419 std::vector<dunedaq::conffwk::relationship_t> relations = classdef.
p_relationships;
424 QString name = QString::fromStdString ( attr.p_name );
426 if ( attr.p_is_multi_value )
430 set_attribute_widget ( attr, widget );
431 set_tooltip ( attr, widget );
432 register_attribute_widget ( name, widget );
433 connect ( widget, SIGNAL ( signal_value_change() ),
this, SLOT ( UpdateActions() ),
434 Qt::UniqueConnection );
435 connect ( widget, SIGNAL ( signal_value_change() ),
this, SLOT ( ObjectChanged() ),
436 Qt::UniqueConnection );
437 emit LoadedInitials();
441 switch ( attr.p_type )
449 set_attribute_widget ( attr, Widget );
450 set_tooltip ( attr, Widget );
451 register_attribute_widget ( name, Widget );
452 connect ( Widget->Combo, SIGNAL ( activated ( QString ) ),
this, SLOT ( UpdateActions() ),
453 Qt::UniqueConnection );
454 connect ( Widget, SIGNAL ( signal_value_change() ),
this, SLOT ( ObjectChanged() ),
455 Qt::UniqueConnection );
456 emit LoadedInitials();
482 set_attribute_widget ( attr, Widget );
483 set_tooltip ( attr, Widget );
484 register_attribute_widget ( name, Widget );
485 connect ( Widget, SIGNAL ( signal_value_change() ),
this, SLOT ( UpdateActions() ),
486 Qt::UniqueConnection );
487 connect ( Widget, SIGNAL ( signal_value_change() ),
this, SLOT ( ObjectChanged() ),
488 Qt::UniqueConnection );
489 emit LoadedInitials();
501 set_attribute_widget ( attr, Widget );
502 set_tooltip ( attr, Widget );
503 register_attribute_widget ( name, Widget );
504 connect ( Widget, SIGNAL ( signal_value_change() ),
this, SLOT ( UpdateActions() ),
505 Qt::UniqueConnection );
506 connect ( Widget, SIGNAL ( signal_value_change() ),
this, SLOT ( ObjectChanged() ),
507 Qt::UniqueConnection );
508 emit LoadedInitials();
515 set_attribute_widget ( attr, Widget );
516 set_tooltip ( attr, Widget );
517 register_attribute_widget ( name, Widget );
518 connect ( Widget->Combo, SIGNAL ( activated ( QString ) ),
this, SLOT ( UpdateActions() ),
519 Qt::UniqueConnection );
520 connect ( Widget, SIGNAL ( signal_value_change() ),
this, SLOT ( ObjectChanged() ),
521 Qt::UniqueConnection );
522 emit LoadedInitials();
534 QString name = QString::fromStdString ( arelation.p_name );
537 if ( object_to_edit and not Object().is_null() )
539 std::vector<tref> DataList;
546 dbegraph::linked::through::relation<tref> ( Object(), arelation ) );
548 catch ( daq::dbe::config_object_retrieval_result_is_null
const & e )
555 DataList = dbegraph::linked::through::relation<std::vector<tref>> ( Object(), arelation );
558 for (
tref const & i : DataList )
560 if ( not i.is_null() )
562 Data.push_back ( QString::fromStdString ( i.UID() ) );
569 set_tooltip ( arelation, widget );
570 register_relation_widget ( name, widget );
571 connect ( widget, SIGNAL ( signal_value_change() ),
this, SLOT ( UpdateActions() ),
572 Qt::UniqueConnection );
573 connect ( widget, SIGNAL ( signal_value_change() ),
this, SLOT ( ObjectChanged() ),
574 Qt::UniqueConnection );
575 connect ( widget, SIGNAL ( LoadedInitials() ),
this, SLOT ( ResetObjectChanged() ),
576 Qt::UniqueConnection );
577 connect (
this, SIGNAL ( LoadedInitials() ), widget, SLOT ( slot_set_initial_loaded() ),
578 Qt::UniqueConnection );
580 emit LoadedInitials();
716 if ( object_to_edit and not Object().is_null() )
718 QString FileName = QString ( Object().contained_in().c_str() );
720 QFileInfo FileInfo = QFileInfo ( FileName );
722 for ( QStringList File : FileCache )
724 if ( FileName.contains ( File.at ( 1 ) ) )
726 FilePermission = File.at ( 2 );
731 ui->FileLabel->setText ( QString (
"File: %1" ).arg ( FileInfo.fileName() ) );
732 ui->DirLabel->setText ( QString (
"Dir: %1" ).arg ( FileInfo.absolutePath() ) );
733 ui->WriteLabel->setText ( QString (
"Permission: %1" ).arg ( FilePermission ) );
761 int NotNullCounter = 0;
762 int NotValidCounter = 0;
764 QStringList NotValidList;
766 for (
auto & i : this_widgets )
768 std::shared_ptr<editor_data_state> Editor = i.second->dataeditor<
editor_data_state>();
770 if ( Editor !=
nullptr )
772 if ( not Editor->is_valid() )
775 NotValidList.append ( i.first );
778 if ( Editor->must_not_be_null() )
785 QLabel * StatusLabel =
new QLabel();
786 StatusLabel->setWordWrap (
true );
787 StatusLabel->setFrameStyle ( QFrame::NoFrame );
789 if ( NotValidCounter == 0 )
791 StatusLabel->setText (
792 QString (
"All minimal necessary attributes and relationships are set" ) );
794 if ( this_is_in_copy_mode or this_is_in_creation_mode or
797 ui->ApplyButton->setEnabled (
true );
804 QString MexHead = QString (
"From %1 NOT NULL attributes/relationships, %2 are not set: " )
805 .arg ( NotNullCounter ).arg ( NotValidCounter );
806 QString Mex = MexHead + NotValidList.join (
"," );
807 StatusLabel->setText ( Mex );
809 ui->ApplyButton->setEnabled (
false );
814 emit WidgetUpdated();
893 if ( RenameWidget ==
nullptr )
895 RenameWidget =
new QDialog (
this );
896 RenameWidget->setSizePolicy ( QSizePolicy::Preferred, QSizePolicy::Preferred );
897 RenameWidget->setToolTip (
"Type string to edit line and press Enter." );
898 RenameWidget->setWindowTitle (
"Choose a new object id" );
900 QHBoxLayout * Layout =
new QHBoxLayout ( RenameWidget );
901 QLabel * Label =
new QLabel ( QString (
"Rename Object:" ), RenameWidget );
902 GoButton =
new QPushButton (
"Rename !" );
904 LineEdit =
new QLineEdit ( RenameWidget );
905 LineEdit->setToolTip (
"Type string and press Enter" );
907 Layout->addWidget ( Label );
908 Layout->addWidget ( LineEdit );
909 Layout->addWidget ( GoButton );
910 RenameWidget->setLayout ( Layout );
912 connect ( LineEdit, SIGNAL ( returnPressed() ),
this, SLOT ( RenameObject() ) );
913 connect ( GoButton, SIGNAL ( clicked() ),
this, SLOT ( RenameObject() ) );
915 SLOT ( slot_external_rename_object ( QString,
dref ) ) );
918 RenameWidget->show();
923 if ( MoveWidget ==
nullptr )
925 MoveWidget =
new QDialog (
this );
926 MoveWidget->setSizePolicy ( QSizePolicy::Preferred, QSizePolicy::Preferred );
927 MoveWidget->setToolTip (
"Choose file and press Move." );
928 MoveWidget->setWindowTitle (
"Choose new file for object" );
930 QVBoxLayout * Layout =
new QVBoxLayout ( MoveWidget );
931 QLabel * Label =
new QLabel ( QString (
"Choose new file" ), MoveWidget );
932 MoveGoButton =
new QPushButton (
"Move !" );
934 if ( IncludedFileModel ==
nullptr )
937 IncludedFileModel =
new FileModel ( List );
941 FileView->setModel ( IncludedFileModel );
942 FileView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
944 Layout->addWidget ( Label );
945 Layout->addWidget ( FileView );
946 Layout->addWidget ( MoveGoButton );
948 MoveWidget->setLayout ( Layout );
949 connect ( FileView, SIGNAL ( stateChanged (
const QString & ) ),
this,
950 SLOT ( ActiveFileChanged (
const QString & ) ), Qt::UniqueConnection );
951 connect ( MoveGoButton, SIGNAL ( clicked() ),
this, SLOT ( MoveObject() ) );