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
bool m_readonly {false}
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 WidgetTable ( new QTableWidget() ),
50 RenameWidget ( nullptr ),
51 LineEdit ( nullptr ),
52 GoButton ( nullptr ),
53 MoveWidget ( nullptr ),
54 FileView ( nullptr ),
55 IncludedFileModel ( nullptr ),
56 MoveGoButton ( nullptr ),
57 uuid ( QUuid::createUuid() )
58{
59 ui->setupUi ( this );
60}
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 65 of file ObjectEditor.cpp.

66 : ObjectEditor ( parent ) {
67
68 classname = cname;
69 m_object_to_edit = nullptr;
73
74 ui->RenameButton->setDisabled ( true ); // Cannot rename an object that does not exist
75 ui->ClassLabel->setText ( QString ( "New Object" ) );
76
77 init();
78}
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 82 of file ObjectEditor.cpp.

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

◆ ~ObjectEditor()

dbe::ObjectEditor::~ObjectEditor ( )
default

Member Function Documentation

◆ ActiveFileChanged

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

Definition at line 994 of file ObjectEditor.cpp.

995{
996 if ( File.isEmpty() )
997 {
998 return;
999 }
1000
1001 ActivateFile = File;
1002}

◆ BuildFileInfo()

void dbe::ObjectEditor::BuildFileInfo ( )
private

Definition at line 701 of file ObjectEditor.cpp.

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

◆ BuildWidgets()

void dbe::ObjectEditor::BuildWidgets ( )
private

Some connections are missing

Definition at line 399 of file ObjectEditor.cpp.

400{
401 dunedaq::conffwk::class_t const & classdef =
403 std::vector<dunedaq::conffwk::attribute_t> attributes = classdef.p_attributes;
404 std::vector<dunedaq::conffwk::relationship_t> relations = classdef.p_relationships;
405
406 for ( dunedaq::conffwk::attribute_t const & attr : attributes ) // Build widgets for attributes
407
408 {
409 QString name = QString::fromStdString ( attr.p_name );
410
411 if ( attr.p_is_multi_value )
412 {
413 widgets::editors::multiattr * widget = new widgets::editors::multiattr ( attr, this,
414 true, m_readonly );
415 set_attribute_widget ( attr, widget );
416
417 set_tooltip ( attr, widget );
418 register_attribute_widget ( name, widget );
419 connect ( widget, SIGNAL ( signal_value_change() ), this, SLOT ( UpdateActions() ),
420 Qt::UniqueConnection );
421 connect ( widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
422 Qt::UniqueConnection );
423 emit LoadedInitials();
424 }
425 else
426 {
427 switch ( attr.p_type )
428 {
429
431
433 {
434 widgets::editors::combo * Widget = new widgets::editors::combo ( attr, this, true );
435 set_attribute_widget ( attr, Widget );
436 set_tooltip ( attr, Widget );
437 register_attribute_widget ( name, Widget );
438 connect ( Widget->Combo, SIGNAL ( activated ( QString ) ), this, SLOT ( UpdateActions() ),
439 Qt::UniqueConnection );
440 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
441 Qt::UniqueConnection );
442 emit LoadedInitials();
443 break;
444 }
445
447
449
451
453
455
457
459
461
463
465 {
466 widgets::editors::numericattr * Widget =
467 new widgets::editors::numericattr ( attr, this, true, m_readonly );
468 set_attribute_widget ( attr, Widget );
469 set_tooltip ( attr, Widget );
470 register_attribute_widget ( name, Widget );
471 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( UpdateActions() ),
472 Qt::UniqueConnection );
473 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
474 Qt::UniqueConnection );
475 emit LoadedInitials();
476 break;
477 }
478
480
482
484 {
485 widgets::editors::stringattr * Widget =
486 new widgets::editors::stringattr ( attr, this, true, m_readonly );
487 set_attribute_widget ( attr, Widget );
488 set_tooltip ( attr, Widget );
489 register_attribute_widget ( name, Widget );
490 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( UpdateActions() ),
491 Qt::UniqueConnection );
492 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
493 Qt::UniqueConnection );
494 emit LoadedInitials();
495 break;
496 }
497
499 {
500 widgets::editors::combo * Widget = new widgets::editors::combo ( attr, this, true );
501 set_attribute_widget ( attr, Widget );
502 set_tooltip ( attr, Widget );
503 register_attribute_widget ( name, Widget );
504 connect ( Widget->Combo, SIGNAL ( activated ( QString ) ), this, SLOT ( UpdateActions() ),
505 Qt::UniqueConnection );
506 connect ( Widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
507 Qt::UniqueConnection );
508 emit LoadedInitials();
509 break;
510 }
511 }
512 }
513 }
514
515 for ( dunedaq::conffwk::relationship_t const & arelation :
516 relations ) // Build widgets for relations ( relationships )
517 {
518 widgets::editors::relation * widget = new widgets::editors::relation ( arelation, this,
519 true, m_readonly );
520 QString name = QString::fromStdString ( arelation.p_name );
521 QStringList Data;
522
523 if ( m_object_to_edit and not Object().is_null() )
524 {
525 std::vector<tref> DataList;
526
527 if ( config::api::info::relation::is_simple ( arelation ) )
528 {
529 try
530 {
531 DataList.push_back (
533 }
534 catch ( daq::dbe::config_object_retrieval_result_is_null const & e )
535 {
536 // nothing needs be done to handle cases that a relation has not been set
537 }
538 }
539 else
540 {
542 }
543
544 for ( tref const & i : DataList )
545 {
546 if ( not i.is_null() )
547 {
548 Data.push_back ( QString::fromStdString ( i.full_name() ) );
549 }
550 }
551 }
552
553 widget->setdata ( Data );
554 widget->SetEditor();
555
556 set_tooltip ( arelation, widget );
557 register_relation_widget ( name, widget );
558 connect ( widget, SIGNAL ( signal_value_change() ), this, SLOT ( UpdateActions() ),
559 Qt::UniqueConnection );
560 connect ( widget, SIGNAL ( signal_value_change() ), this, SLOT ( ObjectChanged() ),
561 Qt::UniqueConnection );
562 connect ( widget, SIGNAL ( LoadedInitials() ), this, SLOT ( ResetObjectChanged() ),
563 Qt::UniqueConnection );
564 connect ( this, SIGNAL ( LoadedInitials() ), widget, SLOT ( slot_set_initial_loaded() ),
565 Qt::UniqueConnection );
567 emit LoadedInitials();
568 }
569}
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 197 of file ObjectEditor.cpp.

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

◆ HideDetailWidget()

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

Definition at line 167 of file ObjectEditor.cpp.

168{
169 if ( Hide )
170 {
171 ui->DetailWidget->hide();
172 ui->DetailsGroupBox->hide();
173 }
174 else
175 {
176 ui->DetailWidget->show();
177 ui->DetailsGroupBox->show();
178 }
179}

◆ init()

void dbe::ObjectEditor::init ( )
private

Definition at line 106 of file ObjectEditor.cpp.

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

◆ IsEditorValid()

bool dbe::ObjectEditor::IsEditorValid ( ) const

Definition at line 184 of file ObjectEditor.cpp.

185{
186 return IsValid;
187}

◆ keyPressEvent()

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

Definition at line 158 of file ObjectEditor.cpp.

158 {
159 if (event->key() == Qt::Key_Escape) {
160 close();
161 }
162 QWidget::keyPressEvent(event);
163}

◆ LaunchMoveObject

void dbe::ObjectEditor::LaunchMoveObject ( )
privateslot

Definition at line 912 of file ObjectEditor.cpp.

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

◆ LaunchRenameObject

void dbe::ObjectEditor::LaunchRenameObject ( )
privateslot

Definition at line 882 of file ObjectEditor.cpp.

883{
884 if ( RenameWidget == nullptr )
885 {
886 RenameWidget = new QDialog ( this );
887 RenameWidget->setSizePolicy ( QSizePolicy::Preferred, QSizePolicy::Preferred );
888 RenameWidget->setToolTip ( "Type string to edit line and press Enter." );
889 RenameWidget->setWindowTitle ( "Choose a new object id" );
890
891 QHBoxLayout * Layout = new QHBoxLayout ( RenameWidget );
892 QLabel * Label = new QLabel ( QString ( "Rename Object:" ), RenameWidget );
893 GoButton = new QPushButton ( "Rename !" );
894
895 LineEdit = new QLineEdit ( RenameWidget );
896 LineEdit->setToolTip ( "Type string and press Enter" );
897
898 Layout->addWidget ( Label );
899 Layout->addWidget ( LineEdit );
900 Layout->addWidget ( GoButton );
901 RenameWidget->setLayout ( Layout );
902
903 connect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( RenameObject() ) );
904 connect ( GoButton, SIGNAL ( clicked() ), this, SLOT ( RenameObject() ) );
905 connect ( &confaccessor::ref(), SIGNAL ( object_renamed ( QString, dref ) ), this,
906 SLOT ( slot_external_rename_object ( QString, dref ) ) );
907 }
908
909 RenameWidget->show();
910}
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 984 of file ObjectEditor.cpp.

985{
987 {
988 ui->FileLabel->setText ( QString ( "File: %1" ).arg ( Object().contained_in().c_str() ) );
989 }
990
991 MoveWidget->close();
992}
bool movobj(inner::configobject::tref obj, std::string const &destination, QUuid const &src)

◆ Object()

tref dbe::ObjectEditor::Object ( )
inlineprivate

Definition at line 82 of file ObjectEditor.hpp.

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

◆ ObjectChanged

void dbe::ObjectEditor::ObjectChanged ( )
privateslot

Definition at line 808 of file ObjectEditor.cpp.

809{
811
813 or confaccessor::check_file_rw ( QString::fromStdString ( Object().contained_in() ) ) ))
814 {
815 ui->ApplyButton->setEnabled ( true );
816 }
817}

◆ ParseToCreate()

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

Definition at line 1007 of file ObjectEditor.cpp.

1009{
1010 if ( not config::api::info::has_obj ( classname, objectname ) )
1011 {
1012 try
1013 {
1016
1017 // Build [attribute , new values ] map and [ relation , new relations ] map
1018 // by looping through all widgets contained in this objects
1019
1020 for ( auto const & awidget : this_widgets )
1021 {
1022 widgets::editors::base * editor = awidget.second;
1023
1024 // Retrieve data held by the editor
1025 QStringList editordata = editor->getdata();
1026
1027 if ( std::shared_ptr<editor_data<dunedaq::conffwk::attribute_t>> accessor =
1028 editor->dataeditor<editor_data<dunedaq::conffwk::attribute_t>>() )
1029 {
1030 dunedaq::conffwk::attribute_t attribute = accessor->get();
1031
1032 /*
1033 * Convert to the preimage value type
1034 */
1035
1036 for ( auto const & element : editordata )
1037 {
1038 object_attributes[attribute.p_name].push_back ( element.toStdString() );
1039 }
1040 }
1041 else if ( std::shared_ptr<editor_data<dunedaq::conffwk::relationship_t>> accessor =
1042 editor->dataeditor<editor_data<dunedaq::conffwk::relationship_t>>() )
1043 {
1044 dunedaq::conffwk::relationship_t relation = accessor->get();
1045
1046 /*
1047 * Convert to the preimage value type
1048 */
1049
1050 for ( auto const & element : editordata )
1051 {
1052 object_relations[relation.p_name].push_back (
1053 { element.toStdString(), relation.p_type } );
1054 }
1055 }
1056
1057 // editor->SetValueList(editordata);
1058 editor->setchanged ( false );
1059 }
1060
1062 filename, classname, objectname,
1063 object_attributes, object_relations, uuid );
1064
1065 }
1066 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & e )
1067 {
1068 ERROR ( "Object creation did not complete successfully", dbe::config::errors::parse ( e ) );
1069 return false;
1070 }
1071 catch ( dunedaq::conffwk::Exception const & e )
1072 {
1073 ERROR ( "Object could not be created", dbe::config::errors::parse ( e ) );
1074 return false;
1075 }
1076
1077 return true;
1078 }
1079 else
1080 {
1081 ERROR ( "Object cannot be created for", "Object already exists", "with name (UID):",
1082 objectname, " in class ", classname );
1083 return false;
1084 }
1085}
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 828 of file ObjectEditor.cpp.

829{
830 if ( FilePermission != "RO" )
831 {
832 if ( not IsValid )
833 {
834 ERROR ( "Changes cannot be applied for object", "Changes are invalid", "with UID:",
835 Object().UID(), "of class:", Object().class_name() );
836 return;
837 }
838
839 for ( auto const & i : this_widgets )
840 {
841 widgets::editors::base * ceditor = i.second;
842 bool Changed = ceditor->ischanged();
843
844 if ( Changed || this_is_in_copy_mode )
845 {
846 QStringList DataList = ceditor->getdata();
847
848 if ( auto attreditor = ceditor->dataeditor<editor_data<dunedaq::conffwk::attribute_t>>() )
849 {
850 dunedaq::conffwk::attribute_t Attribute = attreditor->get();
851
852 dbe::config::api::set::attribute ( Object(), Attribute, DataList );
853 ceditor->setdata ( DataList );
854 ceditor->setchanged ( false );
855 }
856 else if ( auto releditor =
857 ceditor->dataeditor<editor_data<dunedaq::conffwk::relationship_t>>() )
858 {
859 dunedaq::conffwk::relationship_t Relationship = releditor->get();
860 dbe::config::api::set::relation ( Object(), Relationship, DataList );
861 ceditor->setdata ( DataList );
862 ceditor->setchanged ( false );
863 }
864 }
865 }
866
868
869 ui->ApplyButton->setDisabled ( true );
870
872 }
873 else
874 {
875 ERROR ( "Changes cannot be applied", "File access permission error" );
876 }
877}
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 657 of file ObjectEditor.cpp.

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

◆ register_relation_widget()

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

Definition at line 680 of file ObjectEditor.cpp.

682{
683 HorizontalHeaders.append ( name );
684 WidgetTable->setCellWidget ( CurrentRow, 0, widget );
685
686 if(widgets::editors::relation * w = dynamic_cast<widgets::editors::relation *>(widget)) {
687 if(w->GetIsMultiValue() == true) {
688 WidgetTable->setRowHeight(CurrentRow, 100);
689 } else {
690 WidgetTable->verticalHeader()->setSectionResizeMode(CurrentRow, QHeaderView::Fixed);
691 }
692 }
693
694 CurrentRow++;
695 this_widgets[name] = widget;
696}

◆ RenameObject

void dbe::ObjectEditor::RenameObject ( )
privateslot

Definition at line 958 of file ObjectEditor.cpp.

959{
960 std::string newname = LineEdit->text().toStdString();
962 RenameWidget->close();
963}
bool renobj(inner::configobject::tref obj, std::string const &newuuid, QUuid const &src)

◆ ResetObjectChanged

void dbe::ObjectEditor::ResetObjectChanged ( )
slot

Definition at line 819 of file ObjectEditor.cpp.

820{
822 ui->ApplyButton->setEnabled ( false );
823}

◆ save_and_close

void dbe::ObjectEditor::save_and_close ( )
privateslot

Definition at line 950 of file ObjectEditor.cpp.

950 {
951 if (ui->ApplyButton->isEnabled() ) {
952 ParseToSave();
953 }
954 close();
955}

◆ set_attribute_widget()

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

Definition at line 623 of file ObjectEditor.cpp.

625{
626 {
627 QStringList values;
628
629 if ( not Widget->ischanged() and m_object_to_edit and not Object().is_null() )
630 {
632 }
633 else
634 {
635 values = Widget->getdata();
636 }
637
638 Widget->setdata ( values );
639 }
640
641 {
642 QStringList defaults_values
644 Widget->setdefaults ( defaults_values.at ( 0 ) );
645
647 Widget->setdata(defaults_values);
648 }
649 }
650
651 Widget->SetEditor();
652}
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 574 of file ObjectEditor.cpp.

576{
577 QString ToolTip;
578 ToolTip.append ( QString ( "Attribute Name: %1 \n" ).arg (
579 Attribute.p_name.c_str() ) );
580 ToolTip.append (
581 QString ( " Type: %1 \n" ).arg (
582 dunedaq::conffwk::attribute_t::type2str ( Attribute.p_type ) ) );
583 ToolTip.append ( QString ( " Range: %1 \n" ).arg (
584 Attribute.p_range.c_str() ) );
585 ToolTip.append (
586 QString ( " Format: %1 \n" ).arg (
587 dunedaq::conffwk::attribute_t::format2str ( Attribute.p_int_format ) ) );
588 ToolTip.append ( QString ( " Not Null: %1 \n" ).arg (
589 Attribute.p_is_not_null ) );
590 ToolTip.append (
591 QString ( " Is Multi Value: %1 \n" ).arg ( Attribute.p_is_multi_value ) );
592 ToolTip.append (
593 QString ( " Default Value: %1 \n" ).arg ( Attribute.p_default_value.c_str() ) );
594 ToolTip.append (
595 QString ( " Description: %1 \n" ).arg ( Attribute.p_description.c_str() ) );
596 Widget->setToolTip ( ToolTip );
597}
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 602 of file ObjectEditor.cpp.

604{
605 QString ToolTip;
606 ToolTip.append (
607 QString ( "Relationship Name: %1 \n" ).arg ( relation.p_name.c_str() ) );
608 ToolTip.append (
609 QString ( " Type: %1 \n" ).arg ( relation.p_type.c_str() ) );
610 ToolTip.append (
611 QString ( " Cardinality %1 \n" ).arg (
613 ToolTip.append (
614 QString ( " Is Aggregation: %1 \n" ).arg ( relation.p_is_aggregation ) );
615 ToolTip.append (
616 QString ( " Description: %1 \n" ).arg ( relation.p_description.c_str() ) );
617 widget->setToolTip ( ToolTip );
618}
static const char * card2str(cardinality_t cardinality)

◆ SetController()

void dbe::ObjectEditor::SetController ( )
private

Definition at line 248 of file ObjectEditor.cpp.

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

◆ SetStatusBar()

void dbe::ObjectEditor::SetStatusBar ( )
private

Definition at line 239 of file ObjectEditor.cpp.

240{
241 StatusBar->setSizeGripEnabled ( false );
242 StatusBar->setAutoFillBackground ( true );
243}
QStatusBar * StatusBar

◆ SetUsedForCopy()

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

Definition at line 1087 of file ObjectEditor.cpp.

1088{
1089 this_is_in_copy_mode = Used;
1090}

◆ ShouldCloseThisWindow

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

Definition at line 383 of file ObjectEditor.cpp.

384{
385 Q_UNUSED ( src );
386
387 std::string const & fullname = key.UID() + "@" + key.class_name();
388
389 if ( ( m_object_to_edit and not m_object_to_edit->is_valid() )
390 or ( this->objectName().toStdString() == fullname ) )
391 {
392 this->close();
393 }
394}

◆ slot_external_rename_object

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

Definition at line 965 of file ObjectEditor.cpp.

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

◆ UpdateActions

void dbe::ObjectEditor::UpdateActions ( )
privateslot

This signal will be caught by object editor

Definition at line 746 of file ObjectEditor.cpp.

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

◆ UpdateObjectEditor [1/3]

void dbe::ObjectEditor::UpdateObjectEditor ( )
privateslot

Definition at line 284 of file ObjectEditor.cpp.

284 {
285 const auto& ref = inner::dbcontroller::get({Object().UID(), Object().class_name()});
286 if(ref.is_null() == false) {
288 } else {
289 // The object has been deleted
290 this->close();
291 }
292}
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 275 of file ObjectEditor.cpp.

275 {
276 for(const auto& p : objs) {
277 if((p.first.toStdString() == Object().class_name()) && (p.second.toStdString() == Object().UID())) {
279 break;
280 }
281 }
282}

◆ UpdateObjectEditor [3/3]

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

Definition at line 297 of file ObjectEditor.cpp.

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

◆ WasObjectChanged()

bool dbe::ObjectEditor::WasObjectChanged ( ) const

Definition at line 189 of file ObjectEditor.cpp.

190{
192}

◆ WidgetUpdated

void dbe::ObjectEditor::WidgetUpdated ( )
signal

Member Data Documentation

◆ ActivateFile

QString dbe::ObjectEditor::ActivateFile
private

Definition at line 112 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 94 of file ObjectEditor.hpp.

◆ FilePermission

QString dbe::ObjectEditor::FilePermission
private

Definition at line 96 of file ObjectEditor.hpp.

◆ FileView

CustomFileView* dbe::ObjectEditor::FileView
private

Definition at line 108 of file ObjectEditor.hpp.

◆ GoButton

QPushButton* dbe::ObjectEditor::GoButton
private

Definition at line 104 of file ObjectEditor.hpp.

◆ HorizontalHeaders

QStringList dbe::ObjectEditor::HorizontalHeaders
private

Definition at line 113 of file ObjectEditor.hpp.

◆ IncludedFileModel

FileModel* dbe::ObjectEditor::IncludedFileModel
private

Definition at line 109 of file ObjectEditor.hpp.

◆ IsValid

bool dbe::ObjectEditor::IsValid
private

Definition at line 91 of file ObjectEditor.hpp.

◆ LineEdit

QLineEdit* dbe::ObjectEditor::LineEdit
private

Definition at line 103 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.

◆ m_readonly

bool dbe::ObjectEditor::m_readonly {false}
private

Definition at line 80 of file ObjectEditor.hpp.

80{false};

◆ MainLayout

QHBoxLayout* dbe::ObjectEditor::MainLayout
private

Definition at line 98 of file ObjectEditor.hpp.

◆ MoveGoButton

QPushButton* dbe::ObjectEditor::MoveGoButton
private

Definition at line 110 of file ObjectEditor.hpp.

◆ MoveWidget

QDialog* dbe::ObjectEditor::MoveWidget
private

Move widget.

Definition at line 107 of file ObjectEditor.hpp.

◆ RenameWidget

QDialog* dbe::ObjectEditor::RenameWidget
private

Rename widget.

Definition at line 102 of file ObjectEditor.hpp.

◆ StatusBar

QStatusBar* dbe::ObjectEditor::StatusBar
private

Definition at line 87 of file ObjectEditor.hpp.

◆ this_editor_is_owned

bool dbe::ObjectEditor::this_editor_is_owned
private

Definition at line 91 of file ObjectEditor.hpp.

◆ this_editor_values_changed

bool dbe::ObjectEditor::this_editor_values_changed
private

Definition at line 92 of file ObjectEditor.hpp.

◆ this_is_in_copy_mode

bool dbe::ObjectEditor::this_is_in_copy_mode
private

Definition at line 91 of file ObjectEditor.hpp.

◆ this_is_in_creation_mode

bool dbe::ObjectEditor::this_is_in_creation_mode
private

Definition at line 91 of file ObjectEditor.hpp.

◆ this_widgets

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

Definition at line 89 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 139 of file ObjectEditor.hpp.

◆ WidgetTable

QTableWidget* dbe::ObjectEditor::WidgetTable
private

Definition at line 99 of file ObjectEditor.hpp.


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