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

#include <ObjectEditor.hpp>

Inheritance diagram for dbe::ObjectEditor:
[legend]
Collaboration diagram for dbe::ObjectEditor:
[legend]

Public Slots

void ResetObjectChanged ()

Signals

void LoadedInitials ()
void WidgetUpdated ()

Public Member Functions

 ObjectEditor (QWidget *parent=nullptr)
 ObjectEditor (std::string const &classname, QWidget *parent=nullptr)
 ObjectEditor (tref const &objref, QWidget *parent=nullptr, bool const iscopy=false)
 ~ObjectEditor ()
void HideDetailWidget (bool Hide)
bool CanCloseWindow ()
bool IsEditorValid () const
bool WasObjectChanged () const
bool ParseToCreate (std::string const &name, std::string const &filename)
void SetUsedForCopy (bool Used)

Private Slots

void save_and_close ()
void UpdateActions ()
void ObjectChanged ()
void ParseToSave ()
void LaunchRenameObject ()
void LaunchMoveObject ()
void RenameObject ()
void slot_external_rename_object (QString const &src, dref const &obj)
void MoveObject ()
void ActiveFileChanged (const QString &File)
void UpdateObjectEditor (QString const &, dref)
void UpdateObjectEditor (const QList< QPair< QString, QString > > &)
void UpdateObjectEditor ()
void ShouldCloseThisWindow (QString src, dref key)

Private Member Functions

void keyPressEvent (QKeyEvent *event) override
void init ()
void SetStatusBar ()
void SetController ()
void BuildWidgets ()
void set_tooltip (dunedaq::conffwk::attribute_t const &, widgets::editors::base *)
void set_tooltip (dunedaq::conffwk::relationship_t const &, widgets::editors::base *)
void set_attribute_widget (dunedaq::conffwk::attribute_t const &, widgets::editors::base *)
void register_attribute_widget (QString const &name, widgets::editors::base *widget)
void register_relation_widget (QString const &name, widgets::editors::base *widget)
void BuildFileInfo ()
tref Object ()

Private Attributes

std::unique_ptr< dbe::Ui::ObjectEditor > ui
std::string classname
std::unique_ptr< drefm_object_to_edit
QStatusBar * StatusBar
std::map< QString, widgets::editors::base * > this_widgets
bool IsValid
bool this_is_in_copy_mode
bool this_editor_is_owned
bool this_is_in_creation_mode
bool this_editor_values_changed
int CurrentRow
QString FilePermission
QHBoxLayout * MainLayout
QTableWidget * WidgetTable
QDialog * RenameWidget
 Rename widget.
QLineEdit * LineEdit
QPushButton * GoButton
QDialog * MoveWidget
 Move widget.
CustomFileViewFileView
FileModelIncludedFileModel
QPushButton * MoveGoButton
QString ActivateFile
QStringList HorizontalHeaders
QUuid const uuid

Detailed Description

Definition at line 32 of file ObjectEditor.hpp.

Constructor & Destructor Documentation

◆ ObjectEditor() [1/3]

dbe::ObjectEditor::ObjectEditor ( QWidget * parent = nullptr)
explicit

Definition at line 40 of file ObjectEditor.cpp.

41 :
42 QWidget(parent),
43 ui ( new Ui::ObjectEditor ),
44 IsValid ( false ),
46 CurrentRow ( 0 ),
47 MainLayout ( new QHBoxLayout() ),
48 WidgetTable ( new NoScrollingTable() ),
49 RenameWidget ( nullptr ),
50 LineEdit ( nullptr ),
51 GoButton ( nullptr ),
52 MoveWidget ( nullptr ),
53 FileView ( nullptr ),
54 IncludedFileModel ( nullptr ),
55 MoveGoButton ( nullptr ),
56 uuid ( QUuid::createUuid() )
57{
58 ui->setupUi ( this );
59}
QTableWidget * WidgetTable
QPushButton * GoButton
QDialog * MoveWidget
Move widget.
std::unique_ptr< dbe::Ui::ObjectEditor > ui
QPushButton * MoveGoButton
CustomFileView * FileView
QHBoxLayout * MainLayout
FileModel * IncludedFileModel
QDialog * RenameWidget
Rename widget.

◆ ObjectEditor() [2/3]

dbe::ObjectEditor::ObjectEditor ( std::string const & classname,
QWidget * parent = nullptr )

Definition at line 64 of file ObjectEditor.cpp.

65 : ObjectEditor ( parent ) {
66
67 classname = cname;
68 m_object_to_edit = nullptr;
72
73 ui->RenameButton->setDisabled ( true ); // Cannot rename an object that does not exist
74 ui->ClassLabel->setText ( QString ( "New Object" ) );
75
76 init();
77}
std::unique_ptr< dref > m_object_to_edit
ObjectEditor(QWidget *parent=nullptr)
std::string classname

◆ ObjectEditor() [3/3]

dbe::ObjectEditor::ObjectEditor ( tref const & objref,
QWidget * parent = nullptr,
bool const iscopy = false )

Definition at line 81 of file ObjectEditor.cpp.

82 : ObjectEditor ( parent ) {
83
84 classname = object.class_name();
85 m_object_to_edit.reset(new dref ( object ));
86 this_is_in_copy_mode = iscopy;
89
90 ui->ClassLabel->setText (
91 QString ( "Full object name : %1@%2" ).arg ( Object().UID().c_str() ).arg (
92 Object().class_name().c_str() ) );
93
94 this->setWindowTitle (
95 QString ( "Edit Object %1 of Class %2" ).arg ( Object().UID().c_str() ).arg (
96 Object().class_name().c_str() ) );
97
98 this->setObjectName (
99 QString ( "%1@%2" ).arg ( Object().UID().c_str() ).arg ( Object().class_name().c_str() ) );
100
101 init();
102}
config_object_description dref

◆ ~ObjectEditor()

dbe::ObjectEditor::~ObjectEditor ( )
default

Member Function Documentation

◆ ActiveFileChanged

void dbe::ObjectEditor::ActiveFileChanged ( const QString & File)
privateslot

Definition at line 987 of file ObjectEditor.cpp.

988{
989 if ( File.isEmpty() )
990 {
991 return;
992 }
993
994 ActivateFile = File;
995}

◆ BuildFileInfo()

void dbe::ObjectEditor::BuildFileInfo ( )
private

Definition at line 694 of file ObjectEditor.cpp.

695{
696 if ( m_object_to_edit and not Object().is_null() )
697 {
698 QString FileName = QString ( Object().contained_in().c_str() );
699 QList<QStringList> FileCache = confaccessor::ref().GetIncludedFileCache();
700 QFileInfo FileInfo = QFileInfo ( FileName );
701
702 for ( QStringList File : FileCache )
703 {
704 if ( FileName.contains ( File.at ( 1 ) ) )
705 {
706 FilePermission = File.at ( 2 );
707 break;
708 }
709 }
710
711 ui->FileLabel->setText ( QString ( "File: %1" ).arg ( FileInfo.fileName() ) );
712 ui->DirLabel->setText ( QString ( "Dir: %1" ).arg ( FileInfo.absolutePath() ) );
713 ui->WriteLabel->setText ( QString ( "Permission: %1" ).arg ( FilePermission ) );
714 }
715}
QList< QStringList > GetIncludedFileCache() const
static confaccessor & ref()

◆ BuildWidgets()

void dbe::ObjectEditor::BuildWidgets ( )
private

Some connections are missing

Definition at line 393 of file ObjectEditor.cpp.

394{
395 dunedaq::conffwk::class_t const & classdef =
397 std::vector<dunedaq::conffwk::attribute_t> attributes = classdef.p_attributes;
398 std::vector<dunedaq::conffwk::relationship_t> relations = classdef.p_relationships;
399
400 for ( dunedaq::conffwk::attribute_t const & attr : attributes ) // Build widgets for attributes
401
402 {
403 QString name = QString::fromStdString ( attr.p_name );
404
405 if ( attr.p_is_multi_value )
406 {
407 widgets::editors::multiattr * widget = new widgets::editors::multiattr ( attr, this,
408 true );
409 set_attribute_widget ( attr, widget );
410
411 set_tooltip ( attr, widget );
412 register_attribute_widget ( name, widget );
413 connect ( widget, SIGNAL ( signal_value_change() ), this, SLOT ( UpdateActions() ),
414 Qt::UniqueConnection );
415 connect ( widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
416 Qt::UniqueConnection );
417 emit LoadedInitials();
418 }
419 else
420 {
421 switch ( attr.p_type )
422 {
423
425
427 {
428 widgets::editors::combo * Widget = new widgets::editors::combo ( attr, this, true );
429 set_attribute_widget ( attr, Widget );
430 set_tooltip ( attr, Widget );
431 register_attribute_widget ( name, Widget );
432 connect ( Widget->Combo, SIGNAL ( activated ( QString ) ), this, SLOT ( UpdateActions() ),
433 Qt::UniqueConnection );
434 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
435 Qt::UniqueConnection );
436 emit LoadedInitials();
437 break;
438 }
439
441
443
445
447
449
451
453
455
457
459 {
460 widgets::editors::numericattr * Widget = new widgets::editors::numericattr ( attr, this,
461 true );
462 set_attribute_widget ( attr, Widget );
463 set_tooltip ( attr, Widget );
464 register_attribute_widget ( name, Widget );
465 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( UpdateActions() ),
466 Qt::UniqueConnection );
467 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
468 Qt::UniqueConnection );
469 emit LoadedInitials();
470 break;
471 }
472
474
476
478 {
479 widgets::editors::stringattr * Widget = new widgets::editors::stringattr ( attr, this,
480 true );
481 set_attribute_widget ( attr, Widget );
482 set_tooltip ( attr, Widget );
483 register_attribute_widget ( name, Widget );
484 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( UpdateActions() ),
485 Qt::UniqueConnection );
486 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
487 Qt::UniqueConnection );
488 emit LoadedInitials();
489 break;
490 }
491
493 {
494 widgets::editors::combo * Widget = new widgets::editors::combo ( attr, this, true );
495 set_attribute_widget ( attr, Widget );
496 set_tooltip ( attr, Widget );
497 register_attribute_widget ( name, Widget );
498 connect ( Widget->Combo, SIGNAL ( activated ( QString ) ), this, SLOT ( UpdateActions() ),
499 Qt::UniqueConnection );
500 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
501 Qt::UniqueConnection );
502 emit LoadedInitials();
503 break;
504 }
505 }
506 }
507 }
508
509 for ( dunedaq::conffwk::relationship_t const & arelation :
510 relations ) // Build widgets for relations ( relationships )
511 {
512 widgets::editors::relation * widget = new widgets::editors::relation ( arelation, this,
513 true );
514 QString name = QString::fromStdString ( arelation.p_name );
515 QStringList Data;
516
517 if ( m_object_to_edit and not Object().is_null() )
518 {
519 std::vector<tref> DataList;
520
521 if ( config::api::info::relation::is_simple ( arelation ) )
522 {
523 try
524 {
525 DataList.push_back (
527 }
528 catch ( daq::dbe::config_object_retrieval_result_is_null const & e )
529 {
530 // nothing needs be done to handle cases that a relation has not been set
531 }
532 }
533 else
534 {
536 }
537
538 for ( tref const & i : DataList )
539 {
540 if ( not i.is_null() )
541 {
542 Data.push_back ( QString::fromStdString ( i.UID() ) );
543 }
544 }
545 }
546
547 widget->setdata ( Data );
548 widget->SetEditor();
549 set_tooltip ( arelation, widget );
550 register_relation_widget ( name, widget );
551 connect ( widget, SIGNAL ( signal_value_change() ), this, SLOT ( UpdateActions() ),
552 Qt::UniqueConnection );
553 connect ( widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
554 Qt::UniqueConnection );
555 connect ( widget, SIGNAL ( LoadedInitials() ), this, SLOT ( ResetObjectChanged() ),
556 Qt::UniqueConnection );
557 connect ( this, SIGNAL ( LoadedInitials() ), widget, SLOT ( slot_set_initial_loaded() ),
558 Qt::UniqueConnection );
560 emit LoadedInitials();
561 }
562}
void set_attribute_widget(dunedaq::conffwk::attribute_t const &, widgets::editors::base *)
void set_tooltip(dunedaq::conffwk::attribute_t const &, widgets::editors::base *)
void register_attribute_widget(QString const &name, widgets::editors::base *widget)
void register_relation_widget(QString const &name, widgets::editors::base *widget)
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)
std::vector< T > attributes(tref const &item)
tref relation< tref >(tref object, dunedaq::conffwk::relationship_t const &r)
T relation(tref item, dunedaq::conffwk::relationship_t const &relation)
std::vector< T > relations(tref const &item)
bool is_simple(dunedaq::conffwk::relationship_t const &)
inner::configobject::tref tref
Definition tref.hpp:35
nlohmann::json Data
Definition Structs.hpp:24
const std::vector< attribute_t > p_attributes
Definition Schema.hpp:170
const std::vector< relationship_t > p_relationships
Definition Schema.hpp:171

◆ CanCloseWindow()

bool dbe::ObjectEditor::CanCloseWindow ( )

Definition at line 191 of file ObjectEditor.cpp.

192{
194 ui->ApplyButton->isEnabled() )
195 {
196 int ret =
197 QMessageBox::question (
198 0,
199 tr ( "DBE - ObjectEditor" ),
200 QString (
201 "There are unsaved changes for object\n'%1.%2'\n\nDo you want to apply changes?\n" )
202 .arg ( QString::fromStdString ( Object().full_name() ) ),
203 QMessageBox::Apply | QMessageBox::Discard | QMessageBox::Cancel,
204 QMessageBox::Apply );
205
206 switch ( ret )
207 {
208
209 case QMessageBox::Discard:
211 break;
212
213 case QMessageBox::Apply:
214 ParseToSave();
215 break;
216
217 case QMessageBox::Cancel:
218 return false;
219 break;
220 }
221
222 return true;
223 }
224 else
225 {
226 return true;
227 }
228}

◆ HideDetailWidget()

void dbe::ObjectEditor::HideDetailWidget ( bool Hide)

Definition at line 161 of file ObjectEditor.cpp.

162{
163 if ( Hide )
164 {
165 ui->DetailWidget->hide();
166 ui->DetailsGroupBox->hide();
167 }
168 else
169 {
170 ui->DetailWidget->show();
171 ui->DetailsGroupBox->show();
172 }
173}

◆ init()

void dbe::ObjectEditor::init ( )
private

Definition at line 105 of file ObjectEditor.cpp.

105 {
106 dunedaq::conffwk::class_t const & Class =
108 int NumberOfRows = Class.p_attributes.size() + Class.p_relationships.size();
109 int NumberOfColumns = 1;
110 WidgetTable->setRowCount ( NumberOfRows );
111 WidgetTable->setColumnCount ( NumberOfColumns );
112 setAttribute ( Qt::WA_DeleteOnClose, true );
113
115 BuildWidgets();
118
119 ui->DetailsGroupBox->setVisible ( false );
120
121 WidgetTable->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding );
122 WidgetTable->horizontalHeader()->setVisible ( false );
123 WidgetTable->horizontalHeader()->setSectionResizeMode ( QHeaderView::ResizeToContents );
124 WidgetTable->horizontalHeader()->setSectionResizeMode ( 0, QHeaderView::Stretch );
125 WidgetTable->setVerticalHeaderLabels ( HorizontalHeaders );
126 WidgetTable->setSelectionMode ( QAbstractItemView::NoSelection );
127
129 {
130 ui->RenameButton->setDisabled ( true );
131 ui->MoveButton->setDisabled ( true );
132 }
133 else {
135 QString::fromStdString ( Object().contained_in() ));
136 if (!rw) {
137 WidgetTable->setDisabled(true);
138 ui->RenameButton->setDisabled(true);
139 ui->MoveButton->setDisabled(true);
140 }
141 }
142 ui->TableLayout->addWidget ( WidgetTable );
143
144 ui->ApplyButton->setEnabled ( false );
145
146 ui->RenameButton->setToolTip ( "Rename object" );
147
148
149 this->show();
150}
QStringList HorizontalHeaders
static bool check_file_rw(const QString &FileName)

◆ IsEditorValid()

bool dbe::ObjectEditor::IsEditorValid ( ) const

Definition at line 178 of file ObjectEditor.cpp.

179{
180 return IsValid;
181}

◆ keyPressEvent()

void dbe::ObjectEditor::keyPressEvent ( QKeyEvent * event)
overrideprivate

Definition at line 152 of file ObjectEditor.cpp.

152 {
153 if (event->key() == Qt::Key_Escape) {
154 close();
155 }
156 QWidget::keyPressEvent(event);
157}

◆ LaunchMoveObject

void dbe::ObjectEditor::LaunchMoveObject ( )
privateslot

Definition at line 905 of file ObjectEditor.cpp.

906{
907 if ( MoveWidget == nullptr )
908 {
909 MoveWidget = new QDialog ( this );
910 MoveWidget->setSizePolicy ( QSizePolicy::Preferred, QSizePolicy::Preferred );
911 MoveWidget->setToolTip ( "Choose file and press Move." );
912 MoveWidget->setWindowTitle ( "Choose new file for object" );
913
914 QVBoxLayout * Layout = new QVBoxLayout ( MoveWidget );
915 QLabel * Label = new QLabel ( QString ( "Choose new file" ), MoveWidget );
916 MoveGoButton = new QPushButton ( "Move !" );
917
918 if ( IncludedFileModel == nullptr )
919 {
920 QList<QStringList> List = confaccessor::ref().GetIncludedFileCache();
921 IncludedFileModel = new FileModel ( List );
922 }
923
924 FileView = new CustomFileView ( MoveWidget );
925 FileView->setModel ( IncludedFileModel );
926 FileView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
927
928 Layout->addWidget ( Label );
929 Layout->addWidget ( FileView );
930 Layout->addWidget ( MoveGoButton );
931
932 MoveWidget->setLayout ( Layout );
933 connect ( FileView, SIGNAL ( stateChanged ( const QString & ) ), this,
934 SLOT ( ActiveFileChanged ( const QString & ) ), Qt::UniqueConnection );
935 connect ( MoveGoButton, SIGNAL ( clicked() ), this, SLOT ( MoveObject() ) );
936 }
937
938 MoveWidget->show();
939}
void ActiveFileChanged(const QString &File)

◆ LaunchRenameObject

void dbe::ObjectEditor::LaunchRenameObject ( )
privateslot

Definition at line 875 of file ObjectEditor.cpp.

876{
877 if ( RenameWidget == nullptr )
878 {
879 RenameWidget = new QDialog ( this );
880 RenameWidget->setSizePolicy ( QSizePolicy::Preferred, QSizePolicy::Preferred );
881 RenameWidget->setToolTip ( "Type string to edit line and press Enter." );
882 RenameWidget->setWindowTitle ( "Choose a new object id" );
883
884 QHBoxLayout * Layout = new QHBoxLayout ( RenameWidget );
885 QLabel * Label = new QLabel ( QString ( "Rename Object:" ), RenameWidget );
886 GoButton = new QPushButton ( "Rename !" );
887
888 LineEdit = new QLineEdit ( RenameWidget );
889 LineEdit->setToolTip ( "Type string and press Enter" );
890
891 Layout->addWidget ( Label );
892 Layout->addWidget ( LineEdit );
893 Layout->addWidget ( GoButton );
894 RenameWidget->setLayout ( Layout );
895
896 connect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( RenameObject() ) );
897 connect ( GoButton, SIGNAL ( clicked() ), this, SLOT ( RenameObject() ) );
898 connect ( &confaccessor::ref(), SIGNAL ( object_renamed ( QString, dref ) ), this,
899 SLOT ( slot_external_rename_object ( QString, dref ) ) );
900 }
901
902 RenameWidget->show();
903}
void slot_external_rename_object(QString const &src, dref const &obj)

◆ LoadedInitials

void dbe::ObjectEditor::LoadedInitials ( )
signal

◆ MoveObject

void dbe::ObjectEditor::MoveObject ( )
privateslot

Definition at line 977 of file ObjectEditor.cpp.

978{
980 {
981 ui->FileLabel->setText ( QString ( "File: %1" ).arg ( Object().contained_in().c_str() ) );
982 }
983
984 MoveWidget->close();
985}
bool movobj(inner::configobject::tref obj, std::string const &destination, QUuid const &src)

◆ Object()

tref dbe::ObjectEditor::Object ( )
inlineprivate

Definition at line 81 of file ObjectEditor.hpp.

82 {
83 return m_object_to_edit->ref();
84 }

◆ ObjectChanged

void dbe::ObjectEditor::ObjectChanged ( )
privateslot

Definition at line 801 of file ObjectEditor.cpp.

802{
804
806 or confaccessor::check_file_rw ( QString::fromStdString ( Object().contained_in() ) ) ))
807 {
808 ui->ApplyButton->setEnabled ( true );
809 }
810}

◆ ParseToCreate()

bool dbe::ObjectEditor::ParseToCreate ( std::string const & name,
std::string const & filename )

Definition at line 1000 of file ObjectEditor.cpp.

1002{
1003 if ( not config::api::info::has_obj ( classname, objectname ) )
1004 {
1005 try
1006 {
1009
1010 // Build [attribute , new values ] map and [ relation , new relations ] map
1011 // by looping through all widgets contained in this objects
1012
1013 for ( auto const & awidget : this_widgets )
1014 {
1015 widgets::editors::base * editor = awidget.second;
1016
1017 // Retrieve data held by the editor
1018 QStringList editordata = editor->getdata();
1019
1020 if ( std::shared_ptr<editor_data<dunedaq::conffwk::attribute_t>> accessor =
1021 editor->dataeditor<editor_data<dunedaq::conffwk::attribute_t>>() )
1022 {
1023 dunedaq::conffwk::attribute_t attribute = accessor->get();
1024
1025 /*
1026 * Convert to the preimage value type
1027 */
1028
1029 for ( auto const & element : editordata )
1030 {
1031 object_attributes[attribute.p_name].push_back ( element.toStdString() );
1032 }
1033 }
1034 else if ( std::shared_ptr<editor_data<dunedaq::conffwk::relationship_t>> accessor =
1035 editor->dataeditor<editor_data<dunedaq::conffwk::relationship_t>>() )
1036 {
1037 dunedaq::conffwk::relationship_t relation = accessor->get();
1038
1039 /*
1040 * Convert to the preimage value type
1041 */
1042
1043 for ( auto const & element : editordata )
1044 {
1045 object_relations[relation.p_name].push_back (
1046 { element.toStdString(), relation.p_type } );
1047 }
1048 }
1049
1050 // editor->SetValueList(editordata);
1051 editor->setchanged ( false );
1052 }
1053
1055 filename, classname, objectname,
1056 object_attributes, object_relations, uuid );
1057
1058 }
1059 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & e )
1060 {
1061 ERROR ( "Object creation did not complete successfully", dbe::config::errors::parse ( e ) );
1062 return false;
1063 }
1064 catch ( dunedaq::conffwk::Exception const & e )
1065 {
1066 ERROR ( "Object could not be created", dbe::config::errors::parse ( e ) );
1067 return false;
1068 }
1069
1070 return true;
1071 }
1072 else
1073 {
1074 ERROR ( "Object cannot be created for", "Object already exists", "with name (UID):",
1075 objectname, " in class ", classname );
1076 return false;
1077 }
1078}
std::map< QString, widgets::editors::base * > this_widgets
#define ERROR(...)
Definition messenger.hpp:93
void newobj(std::string const &fn, std::string const &class_name, std::string const &UID, dbe::t_config_object_preimage::type_attrmap const &attributes, dbe::t_config_object_preimage::type_relmap const &relations, QUuid const &src)
T attribute(tref item, dunedaq::conffwk::attribute_t const &attr)
bool has_obj(std::string const &classname, std::string const &object_uid)
std::string const parse(ers::Issue const &)

◆ ParseToSave

void dbe::ObjectEditor::ParseToSave ( )
privateslot

Definition at line 821 of file ObjectEditor.cpp.

822{
823 if ( FilePermission != "RO" )
824 {
825 if ( not IsValid )
826 {
827 ERROR ( "Changes cannot be applied for object", "Changes are invalid", "with UID:",
828 Object().UID(), "of class:", Object().class_name() );
829 return;
830 }
831
832 for ( auto const & i : this_widgets )
833 {
834 widgets::editors::base * ceditor = i.second;
835 bool Changed = ceditor->ischanged();
836
837 if ( Changed || this_is_in_copy_mode )
838 {
839 QStringList DataList = ceditor->getdata();
840
841 if ( auto attreditor = ceditor->dataeditor<editor_data<dunedaq::conffwk::attribute_t>>() )
842 {
843 dunedaq::conffwk::attribute_t Attribute = attreditor->get();
844
845 dbe::config::api::set::attribute ( Object(), Attribute, DataList );
846 ceditor->setdata ( DataList );
847 ceditor->setchanged ( false );
848 }
849 else if ( auto releditor =
850 ceditor->dataeditor<editor_data<dunedaq::conffwk::relationship_t>>() )
851 {
852 dunedaq::conffwk::relationship_t Relationship = releditor->get();
853 dbe::config::api::set::relation ( Object(), Relationship, DataList );
854 ceditor->setdata ( DataList );
855 ceditor->setchanged ( false );
856 }
857 }
858 }
859
861
862 ui->ApplyButton->setDisabled ( true );
863
865 }
866 else
867 {
868 ERROR ( "Changes cannot be applied", "File access permission error" );
869 }
870}
void build_file_model()
static MainWindow * findthis()
void relation(dbe::inner::configobject::tref src, dunedaq::conffwk::relationship_t const &edge, QStringList const &targets)
void attribute(dbe::inner::configobject::tref objectref, dunedaq::conffwk::attribute_t const &attribute_info, QStringList const &attribute_values)

◆ register_attribute_widget()

void dbe::ObjectEditor::register_attribute_widget ( QString const & name,
widgets::editors::base * widget )
private

Definition at line 650 of file ObjectEditor.cpp.

652{
653 HorizontalHeaders.append(name);
654 WidgetTable->setCellWidget(CurrentRow, 0, widget);
655
656 if(dynamic_cast<widgets::editors::multiattr *>(widget)) {
657 WidgetTable->setRowHeight(CurrentRow, 100);
658 } else if(widgets::editors::stringattr * sa = dynamic_cast<widgets::editors::stringattr *>(widget)) {
659 QTextEdit* le = sa->GetLineEdit();
660 const auto& textSize = QFontMetrics(le->document()->defaultFont()).size(0, le->toPlainText());
661 WidgetTable->setRowHeight(CurrentRow, std::min(150, textSize.height() + 15));
662 } else {
663 WidgetTable->verticalHeader()->setSectionResizeMode(CurrentRow, QHeaderView::Fixed);
664 }
665
666 CurrentRow++;
667 this_widgets[name] = widget;
668}

◆ register_relation_widget()

void dbe::ObjectEditor::register_relation_widget ( QString const & name,
widgets::editors::base * widget )
private

Definition at line 673 of file ObjectEditor.cpp.

675{
676 HorizontalHeaders.append ( name );
677 WidgetTable->setCellWidget ( CurrentRow, 0, widget );
678
679 if(widgets::editors::relation * w = dynamic_cast<widgets::editors::relation *>(widget)) {
680 if(w->GetIsMultiValue() == true) {
681 WidgetTable->setRowHeight(CurrentRow, 100);
682 } else {
683 WidgetTable->verticalHeader()->setSectionResizeMode(CurrentRow, QHeaderView::Fixed);
684 }
685 }
686
687 CurrentRow++;
688 this_widgets[name] = widget;
689}

◆ RenameObject

void dbe::ObjectEditor::RenameObject ( )
privateslot

Definition at line 951 of file ObjectEditor.cpp.

952{
953 std::string newname = LineEdit->text().toStdString();
955 RenameWidget->close();
956}
bool renobj(inner::configobject::tref obj, std::string const &newuuid, QUuid const &src)

◆ ResetObjectChanged

void dbe::ObjectEditor::ResetObjectChanged ( )
slot

Definition at line 812 of file ObjectEditor.cpp.

813{
815 ui->ApplyButton->setEnabled ( false );
816}

◆ save_and_close

void dbe::ObjectEditor::save_and_close ( )
privateslot

Definition at line 943 of file ObjectEditor.cpp.

943 {
944 if (ui->ApplyButton->isEnabled() ) {
945 ParseToSave();
946 }
947 close();
948}

◆ set_attribute_widget()

void dbe::ObjectEditor::set_attribute_widget ( dunedaq::conffwk::attribute_t const & Attribute,
widgets::editors::base * Widget )
private

Definition at line 616 of file ObjectEditor.cpp.

618{
619 {
620 QStringList values;
621
622 if ( not Widget->ischanged() and m_object_to_edit and not Object().is_null() )
623 {
625 }
626 else
627 {
628 values = Widget->getdata();
629 }
630
631 Widget->setdata ( values );
632 }
633
634 {
635 QStringList defaults_values
637 Widget->setdefaults ( defaults_values.at ( 0 ) );
638
640 Widget->setdata(defaults_values);
641 }
642 }
643
644 Widget->SetEditor();
645}
static T list(dbe::inner::configobject::tref obj, dunedaq::conffwk::attribute_t const &attr)
static QStringList value(dunedaq::conffwk::attribute_t const &)

◆ set_tooltip() [1/2]

void dbe::ObjectEditor::set_tooltip ( dunedaq::conffwk::attribute_t const & Attribute,
widgets::editors::base * Widget )
private

Definition at line 567 of file ObjectEditor.cpp.

569{
570 QString ToolTip;
571 ToolTip.append ( QString ( "Attribute Name: %1 \n" ).arg (
572 Attribute.p_name.c_str() ) );
573 ToolTip.append (
574 QString ( " Type: %1 \n" ).arg (
575 dunedaq::conffwk::attribute_t::type2str ( Attribute.p_type ) ) );
576 ToolTip.append ( QString ( " Range: %1 \n" ).arg (
577 Attribute.p_range.c_str() ) );
578 ToolTip.append (
579 QString ( " Format: %1 \n" ).arg (
580 dunedaq::conffwk::attribute_t::format2str ( Attribute.p_int_format ) ) );
581 ToolTip.append ( QString ( " Not Null: %1 \n" ).arg (
582 Attribute.p_is_not_null ) );
583 ToolTip.append (
584 QString ( " Is Multi Value: %1 \n" ).arg ( Attribute.p_is_multi_value ) );
585 ToolTip.append (
586 QString ( " Default Value: %1 \n" ).arg ( Attribute.p_default_value.c_str() ) );
587 ToolTip.append (
588 QString ( " Description: %1 \n" ).arg ( Attribute.p_description.c_str() ) );
589 Widget->setToolTip ( ToolTip );
590}
static const char * type2str(type_t type)
static const char * format2str(int_format_t format)

◆ set_tooltip() [2/2]

void dbe::ObjectEditor::set_tooltip ( dunedaq::conffwk::relationship_t const & relation,
widgets::editors::base * widget )
private

Definition at line 595 of file ObjectEditor.cpp.

597{
598 QString ToolTip;
599 ToolTip.append (
600 QString ( "Relationship Name: %1 \n" ).arg ( relation.p_name.c_str() ) );
601 ToolTip.append (
602 QString ( " Type: %1 \n" ).arg ( relation.p_type.c_str() ) );
603 ToolTip.append (
604 QString ( " Cardinality %1 \n" ).arg (
606 ToolTip.append (
607 QString ( " Is Aggregation: %1 \n" ).arg ( relation.p_is_aggregation ) );
608 ToolTip.append (
609 QString ( " Description: %1 \n" ).arg ( relation.p_description.c_str() ) );
610 widget->setToolTip ( ToolTip );
611}
static const char * card2str(cardinality_t cardinality)

◆ SetController()

void dbe::ObjectEditor::SetController ( )
private

Definition at line 242 of file ObjectEditor.cpp.

243{
244 connect ( ui->DetailButton, SIGNAL ( toggled ( bool ) ), ui->DetailsGroupBox,
245 SLOT ( setVisible ( bool ) ), Qt::UniqueConnection );
246 connect ( ui->CloseButton, SIGNAL ( clicked ( bool ) ), this, SLOT ( close() ),
247 Qt::UniqueConnection );
248 connect ( ui->ApplyButton, SIGNAL ( clicked() ), this, SLOT ( ParseToSave() ),
249 Qt::UniqueConnection );
250
251 connect ( ui->RenameButton, SIGNAL ( clicked() ), this, SLOT ( LaunchRenameObject() ) );
252 connect ( ui->MoveButton, SIGNAL ( clicked() ), this, SLOT ( LaunchMoveObject() ) );
253
254 connect ( &confaccessor::ref(), SIGNAL ( object_changed ( QString, dref ) ), this,
255 SLOT ( UpdateObjectEditor ( QString, dref ) ) );
256
257 connect ( &confaccessor::ref(), SIGNAL ( object_deleted ( QString, dref ) ), this,
258 SLOT ( ShouldCloseThisWindow ( QString, dref ) ) );
259
260 MainWindow * mainwin = MainWindow::findthis();
261 if(mainwin != nullptr) {
262 connect (mainwin, SIGNAL(signal_batch_change_stopped(const QList<QPair<QString, QString>>&)),
263 this, SLOT(UpdateObjectEditor(const QList<QPair<QString, QString>>&)), Qt::UniqueConnection);
264 connect (mainwin, SIGNAL(signal_externalchanges_processed()),
265 this, SLOT(UpdateObjectEditor()), Qt::UniqueConnection);
266 }
267}
void UpdateObjectEditor(QString const &, dref)
void ShouldCloseThisWindow(QString src, dref key)

◆ SetStatusBar()

void dbe::ObjectEditor::SetStatusBar ( )
private

Definition at line 233 of file ObjectEditor.cpp.

234{
235 StatusBar->setSizeGripEnabled ( false );
236 StatusBar->setAutoFillBackground ( true );
237}
QStatusBar * StatusBar

◆ SetUsedForCopy()

void dbe::ObjectEditor::SetUsedForCopy ( bool Used)

Definition at line 1080 of file ObjectEditor.cpp.

1081{
1082 this_is_in_copy_mode = Used;
1083}

◆ ShouldCloseThisWindow

void dbe::ObjectEditor::ShouldCloseThisWindow ( QString src,
dref key )
privateslot

Definition at line 377 of file ObjectEditor.cpp.

378{
379 Q_UNUSED ( src );
380
381 std::string const & fullname = key.UID() + "@" + key.class_name();
382
383 if ( ( m_object_to_edit and not m_object_to_edit->is_valid() )
384 or ( this->objectName().toStdString() == fullname ) )
385 {
386 this->close();
387 }
388}

◆ slot_external_rename_object

void dbe::ObjectEditor::slot_external_rename_object ( QString const & src,
dref const & obj )
privateslot

Definition at line 958 of file ObjectEditor.cpp.

960{
961 // Rename can only occur by undoing a command issued from an ObjectEditor therefore
962 // the uuid and src have to be equal. We also check the UID
963
964 if ( src == uuid.toString() )
965 {
966 ui->ClassLabel->setText (
967 QString ( "Object : %1@%2" ).arg ( Object().UID().c_str() ).arg (
968 Object().class_name().c_str() ) );
969 setWindowTitle (
970 QString ( "Edit Object %1 of Class %2" ).arg ( Object().UID().c_str() ).arg (
971 Object().class_name().c_str() ) );
972 setObjectName (
973 QString ( "%1@%2" ).arg ( Object().UID().c_str() ).arg ( Object().class_name().c_str() ) );
974 }
975}

◆ UpdateActions

void dbe::ObjectEditor::UpdateActions ( )
privateslot

This signal will be caught by object editor

Definition at line 739 of file ObjectEditor.cpp.

740{
741 int NotNullCounter = 0;
742 int NotValidCounter = 0;
743
744 QStringList NotValidList;
745
746 for ( auto & i : this_widgets )
747 {
748 std::shared_ptr<editor_data_state> Editor = i.second->dataeditor<editor_data_state>();
749
750 if ( Editor != nullptr )
751 {
752 if ( not Editor->is_valid() )
753 {
754 NotValidCounter++;
755 NotValidList.append ( i.first );
756 }
757
758 if ( Editor->must_not_be_null() )
759 {
760 NotNullCounter++;
761 }
762 }
763 }
764
765 QLabel * StatusLabel = new QLabel();
766 StatusLabel->setWordWrap ( true );
767 StatusLabel->setFrameStyle ( QFrame::NoFrame );
768
769 if ( NotValidCounter == 0 )
770 {
771 StatusLabel->setText (
772 QString ( "All minimal necessary attributes and relationships are set" ) );
773
775 confaccessor::check_file_rw ( QString::fromStdString ( Object().contained_in() ) ) )
776 {
777 ui->ApplyButton->setEnabled ( true );
778 }
779
780 IsValid = true;
781 }
782 else
783 {
784 QString MexHead = QString ( "From %1 NOT NULL attributes/relationships, %2 are not set: " )
785 .arg ( NotNullCounter ).arg ( NotValidCounter );
786 QString Mex = MexHead + NotValidList.join ( "," );
787 StatusLabel->setText ( Mex );
788
789 ui->ApplyButton->setEnabled ( false );
790
791 IsValid = false;
792 }
793
795 emit WidgetUpdated();
796}

◆ UpdateObjectEditor [1/3]

void dbe::ObjectEditor::UpdateObjectEditor ( )
privateslot

Definition at line 278 of file ObjectEditor.cpp.

278 {
279 const auto& ref = inner::dbcontroller::get({Object().UID(), Object().class_name()});
280 if(ref.is_null() == false) {
282 } else {
283 // The object has been deleted
284 this->close();
285 }
286}
static configobject::tref get(dbe::cokey const &desc)

◆ UpdateObjectEditor [2/3]

void dbe::ObjectEditor::UpdateObjectEditor ( const QList< QPair< QString, QString > > & objs)
privateslot

Definition at line 269 of file ObjectEditor.cpp.

269 {
270 for(const auto& p : objs) {
271 if((p.first.toStdString() == Object().class_name()) && (p.second.toStdString() == Object().UID())) {
273 break;
274 }
275 }
276}

◆ UpdateObjectEditor [3/3]

void dbe::ObjectEditor::UpdateObjectEditor ( QString const & src,
dref updated_object )
privateslot

Definition at line 291 of file ObjectEditor.cpp.

292{
293 // src is ignored even in the case of this being the source
294 // changes must always be applied since it is developer responsibility
295 // to emit signals as needed
296 Q_UNUSED ( src );
297
298 if ( not this_editor_is_owned and m_object_to_edit and Object().UID() == updated_object.UID()
299 and Object().class_name() == updated_object.class_name() )
300 {
301
302 m_object_to_edit.reset ( new dref ( updated_object ) );
303
304 dunedaq::conffwk::class_t const & classdef =
306 std::vector<dunedaq::conffwk::attribute_t> class_attributes = classdef.p_attributes;
307 std::vector<dunedaq::conffwk::relationship_t> class_relations = classdef.p_relationships;
308
309 for ( dunedaq::conffwk::attribute_t attr : class_attributes )
310 {
311 if ( widgets::editors::base * attreditor =
312 this_widgets[QString::fromStdString ( attr.p_name )] )
313 {
314 set_attribute_widget ( attr, attreditor );
315 }
316 }
317
318 for ( dunedaq::conffwk::relationship_t arelation : class_relations )
319 {
320 QStringList relvalues;
321 QString relname = QString ( arelation.p_name.c_str() );
322
323 if ( widgets::editors::relation * relwidget =
324 dynamic_cast<widgets::editors::relation *> ( this_widgets[relname] ) )
325 {
326 if ( relwidget->ischanged() )
327 {
328 relvalues = relwidget->getdata();
329 }
330 else
331 {
332 std::vector<tref> connected;
333
334 if ( config::api::info::relation::is_simple ( arelation ) )
335 {
336 try
337 {
338 connected.push_back (
340 }
341 catch ( daq::dbe::config_object_retrieval_result_is_null const & e )
342 {
343 // nothing needs be done to handle the case that a relation has no object set
344 }
345 }
346 else
347 {
348 connected =
350 }
351
352 std::transform ( connected.begin(), connected.end(), std::back_inserter ( relvalues ),
353 [] ( decltype ( connected ) ::value_type const & x )
354 {
355 return QString::fromStdString ( x.UID() );
356 }
357
358 );
359
360 }
361
362 relwidget->setdata ( relvalues );
363 relwidget->SetEditor();
364 }
365 }
366 }
367
368 // Trick to properly refresh the window (repaint and update does not seem to work)
369 const auto& s = size();
370 resize(s.width() + 1, s.height() +1);
371 resize(s.width(), s.height());
372}
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size

◆ WasObjectChanged()

bool dbe::ObjectEditor::WasObjectChanged ( ) const

Definition at line 183 of file ObjectEditor.cpp.

184{
186}

◆ WidgetUpdated

void dbe::ObjectEditor::WidgetUpdated ( )
signal

Member Data Documentation

◆ ActivateFile

QString dbe::ObjectEditor::ActivateFile
private

Definition at line 111 of file ObjectEditor.hpp.

◆ classname

std::string dbe::ObjectEditor::classname
private

Definition at line 78 of file ObjectEditor.hpp.

◆ CurrentRow

int dbe::ObjectEditor::CurrentRow
private

Definition at line 93 of file ObjectEditor.hpp.

◆ FilePermission

QString dbe::ObjectEditor::FilePermission
private

Definition at line 95 of file ObjectEditor.hpp.

◆ FileView

CustomFileView* dbe::ObjectEditor::FileView
private

Definition at line 107 of file ObjectEditor.hpp.

◆ GoButton

QPushButton* dbe::ObjectEditor::GoButton
private

Definition at line 103 of file ObjectEditor.hpp.

◆ HorizontalHeaders

QStringList dbe::ObjectEditor::HorizontalHeaders
private

Definition at line 112 of file ObjectEditor.hpp.

◆ IncludedFileModel

FileModel* dbe::ObjectEditor::IncludedFileModel
private

Definition at line 108 of file ObjectEditor.hpp.

◆ IsValid

bool dbe::ObjectEditor::IsValid
private

Definition at line 90 of file ObjectEditor.hpp.

◆ LineEdit

QLineEdit* dbe::ObjectEditor::LineEdit
private

Definition at line 102 of file ObjectEditor.hpp.

◆ m_object_to_edit

std::unique_ptr<dref> dbe::ObjectEditor::m_object_to_edit
private

Definition at line 79 of file ObjectEditor.hpp.

◆ MainLayout

QHBoxLayout* dbe::ObjectEditor::MainLayout
private

Definition at line 97 of file ObjectEditor.hpp.

◆ MoveGoButton

QPushButton* dbe::ObjectEditor::MoveGoButton
private

Definition at line 109 of file ObjectEditor.hpp.

◆ MoveWidget

QDialog* dbe::ObjectEditor::MoveWidget
private

Move widget.

Definition at line 106 of file ObjectEditor.hpp.

◆ RenameWidget

QDialog* dbe::ObjectEditor::RenameWidget
private

Rename widget.

Definition at line 101 of file ObjectEditor.hpp.

◆ StatusBar

QStatusBar* dbe::ObjectEditor::StatusBar
private

Definition at line 86 of file ObjectEditor.hpp.

◆ this_editor_is_owned

bool dbe::ObjectEditor::this_editor_is_owned
private

Definition at line 90 of file ObjectEditor.hpp.

◆ this_editor_values_changed

bool dbe::ObjectEditor::this_editor_values_changed
private

Definition at line 91 of file ObjectEditor.hpp.

◆ this_is_in_copy_mode

bool dbe::ObjectEditor::this_is_in_copy_mode
private

Definition at line 90 of file ObjectEditor.hpp.

◆ this_is_in_creation_mode

bool dbe::ObjectEditor::this_is_in_creation_mode
private

Definition at line 90 of file ObjectEditor.hpp.

◆ this_widgets

std::map<QString, widgets::editors::base *> dbe::ObjectEditor::this_widgets
private

Definition at line 88 of file ObjectEditor.hpp.

◆ ui

std::unique_ptr<dbe::Ui::ObjectEditor> dbe::ObjectEditor::ui
private

Definition at line 76 of file ObjectEditor.hpp.

◆ uuid

QUuid const dbe::ObjectEditor::uuid
private

Definition at line 138 of file ObjectEditor.hpp.

◆ WidgetTable

QTableWidget* dbe::ObjectEditor::WidgetTable
private

Definition at line 98 of file ObjectEditor.hpp.


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