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

#include <SchemaMethodEditor.hpp>

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

Signals

void RebuildModel ()
 

Public Member Functions

 ~SchemaMethodEditor ()
 
 SchemaMethodEditor (dunedaq::oks::OksClass *ClassInfo, dunedaq::oks::OksMethod *Method, QWidget *parent=nullptr)
 
 SchemaMethodEditor (dunedaq::oks::OksClass *ClassInfo, QWidget *parent=nullptr)
 
void SetController ()
 
void InitialSettings ()
 
void ParseToSave ()
 
void ParseToCreate ()
 
void BuildModels ()
 

Protected Member Functions

void FillInfo ()
 

Private Slots

void ProxySlot ()
 
void AddNewMethodImplementation ()
 
void OpenMethodImplementationEditor (QModelIndex Index)
 
void BuildModelImplementationSlot ()
 
void ClassUpdated (QString ClassName)
 

Private Member Functions

bool ShouldOpenMethodImplementationEditor (QString Name)
 
bool create ()
 

Private Attributes

std::unique_ptr< dbse::Ui::SchemaMethodEditor > ui
 
dunedaq::oks::OksClassm_class
 
dunedaq::oks::OksMethodm_method
 
CustomMethodImplementationModelImplementationModel
 
bool UsedNew
 
bool m_writable
 

Detailed Description

Definition at line 20 of file SchemaMethodEditor.hpp.

Constructor & Destructor Documentation

◆ ~SchemaMethodEditor()

dbse::SchemaMethodEditor::~SchemaMethodEditor ( )
default

◆ SchemaMethodEditor() [1/2]

dbse::SchemaMethodEditor::SchemaMethodEditor ( dunedaq::oks::OksClass * ClassInfo,
dunedaq::oks::OksMethod * Method,
QWidget * parent = nullptr )
explicit

Definition at line 14 of file SchemaMethodEditor.cpp.

16 : QWidget ( parent ),
17 ui ( new Ui::SchemaMethodEditor ),
18 m_class ( ClassInfo ),
19 m_method ( Method ),
20 ImplementationModel ( nullptr ),
21 UsedNew ( false )
22{
23 QWidget::setAttribute(Qt::WA_DeleteOnClose);
25 ui->setupUi ( this );
29}
static KernelWrapper & GetInstance()
bool IsFileWritable(const std::string &FileName) const
CustomMethodImplementationModel * ImplementationModel
dunedaq::oks::OksClass * m_class
dunedaq::oks::OksMethod * m_method
std::unique_ptr< dbse::Ui::SchemaMethodEditor > ui
OksFile * get_file() const noexcept
Definition class.hpp:338
const std::string & get_full_file_name() const
Definition file.hpp:523

◆ SchemaMethodEditor() [2/2]

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

Definition at line 31 of file SchemaMethodEditor.cpp.

32 : QWidget ( parent ),
33 ui ( new Ui::SchemaMethodEditor ),
34 m_class ( ClassInfo ),
35 m_method ( nullptr ),
36 ImplementationModel ( nullptr ),
37 UsedNew ( true )
38{
39 QWidget::setAttribute(Qt::WA_DeleteOnClose);
41 ui->setupUi ( this );
44}

Member Function Documentation

◆ AddNewMethodImplementation

void dbse::SchemaMethodEditor::AddNewMethodImplementation ( )
privateslot

Definition at line 196 of file SchemaMethodEditor.cpp.

197{
198 if (UsedNew) {
199 if (create()) {
200 m_method = m_class->find_method(ui->MethodName->text().toStdString());
201 }
202 else {
203 QMessageBox::question (
204 0, tr ( "SchemaEditor" ),
205 tr ( "You must set the method name before you can set an implementation" ),
206 QMessageBox::Ok );
207 return;
208 }
209 }
210 SchemaMethodImplementationEditor * Editor = new SchemaMethodImplementationEditor (
211 m_class, m_method );
212 connect ( Editor, SIGNAL ( RebuildModel() ), this,
213 SLOT ( BuildModelImplementationSlot() ) );
214 Editor->show();
215}
OksMethod * find_method(const std::string &name) const noexcept
Find method (search in this and base classes).
Definition class.cpp:1341

◆ BuildModelImplementationSlot

void dbse::SchemaMethodEditor::BuildModelImplementationSlot ( )
privateslot

Definition at line 231 of file SchemaMethodEditor.cpp.

232{
233 BuildModels();
234}

◆ BuildModels()

void dbse::SchemaMethodEditor::BuildModels ( )

Definition at line 147 of file SchemaMethodEditor.cpp.

148{
149 QStringList MethodHeaders { "Language", "Prototype" };
150
151 if ( ImplementationModel != nullptr ) {
152 delete ImplementationModel;
153 }
154 ImplementationModel = new CustomMethodImplementationModel ( m_method, MethodHeaders );
155
156 ui->ImplementationsView->setModel ( ImplementationModel );
157 ui->ImplementationsView->horizontalHeader()->setSectionResizeMode ( QHeaderView::ResizeToContents );
158}

◆ ClassUpdated

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

Definition at line 58 of file SchemaMethodEditor.cpp.

59{
60 if(!UsedNew && ClassName.toStdString() == m_class->get_name()) {
61 if(m_class->find_direct_method(m_method->get_name()) != nullptr) {
62 FillInfo();
64 } else {
65 QWidget::close();
66 }
67 }
68}
const std::string & get_name() const noexcept
Definition class.hpp:363
OksMethod * find_direct_method(const std::string &name) const noexcept
Find direct method.
Definition class.cpp:1330
const std::string & get_name() const noexcept
Definition method.hpp:196

◆ create()

bool dbse::SchemaMethodEditor::create ( )
private

Definition at line 129 of file SchemaMethodEditor.cpp.

129 {
130 std::string method_name = ui->MethodName->text().toStdString();
131 if (method_name.empty()) {
132 return false;
133 }
134 std::string method_description = ui->DescriptionTextBox->toPlainText().toStdString();
136 method_description );
137 emit RebuildModel();
138 UsedNew = false;
139 return true;
140}
void PushAddMethodCommand(dunedaq::oks::OksClass *Class, std::string name, std::string description)

◆ FillInfo()

void dbse::SchemaMethodEditor::FillInfo ( )
protected

Definition at line 70 of file SchemaMethodEditor.cpp.

71{
72 auto name = QString::fromStdString (
73 m_class->get_name() + "::" + m_method->get_name() );
74 setObjectName ( name );
75 setWindowTitle ( QString ( "Method Editor : %1" ).arg ( name ) );
76 ui->MethodName->setText ( QString::fromStdString ( m_method->get_name() ) );
77 ui->DescriptionTextBox->setPlainText (
78 QString::fromStdString ( m_method->get_description() ) );
79}
const std::string & get_description() const noexcept
Definition method.hpp:214

◆ InitialSettings()

void dbse::SchemaMethodEditor::InitialSettings ( )

Definition at line 81 of file SchemaMethodEditor.cpp.

82{
83 if ( UsedNew )
84 {
85 setWindowTitle ( "New Method" );
86 setObjectName ( "NEW" );
87 ui->AddButton->setEnabled ( true );
88 }
89 else
90 {
91 if (!m_writable) {
92 ui->MethodName->setEnabled (false);
93 ui->DescriptionTextBox->setEnabled (false);
94 ui->AddButton->setEnabled (false);
95 ui->ImplementationsView->setEnabled (false);
96 }
97 FillInfo();
98 }
99}

◆ OpenMethodImplementationEditor

void dbse::SchemaMethodEditor::OpenMethodImplementationEditor ( QModelIndex Index)
privateslot

Definition at line 217 of file SchemaMethodEditor.cpp.

218{
219 QStringList Row = ImplementationModel->getRowFromIndex ( Index );
220 if ( !Row.isEmpty() ) {
221 QString name = QString::fromStdString(
222 m_class->get_name()+m_method->get_name()).append(Row.at ( 0 ));
224 SchemaMethodImplementationEditor * Editor = new SchemaMethodImplementationEditor (
225 m_class, m_method, m_method->find_implementation ( Row.at ( 0 ).toStdString() ) );
226 Editor->show();
227 }
228 }
229}
QStringList getRowFromIndex(QModelIndex &index)
bool ShouldOpenMethodImplementationEditor(QString Name)
OksMethodImplementation * find_implementation(const std::string &language) const
Find method implementation.
Definition method.cpp:354

◆ ParseToCreate()

void dbse::SchemaMethodEditor::ParseToCreate ( )

Definition at line 141 of file SchemaMethodEditor.cpp.

142{
143 create();
144 close();
145}

◆ ParseToSave()

void dbse::SchemaMethodEditor::ParseToSave ( )

Definition at line 101 of file SchemaMethodEditor.cpp.

102{
103 bool changed = false;
104 std::string method_name = ui->MethodName->text().toStdString();
105 std::string method_description = ui->DescriptionTextBox->toPlainText().toStdString();
106
107 if ( method_name != m_method->get_name() )
108 {
110 changed = true;
111 }
112
113 if ( method_description != m_method->get_description() )
114 {
116 m_method,
117 method_description );
118 changed = true;
119 }
120
121 if ( changed )
122 {
123 emit RebuildModel();
124 }
125
126 close();
127}
void PushSetDescriptionMethodCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string description)
void PushSetNameMethodCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string name)
Method commands.
Only Configuration DB opened by rdbconfig or oksconflibs plug in can be changed

◆ ProxySlot

void dbse::SchemaMethodEditor::ProxySlot ( )
privateslot

Definition at line 184 of file SchemaMethodEditor.cpp.

185{
186 if ( UsedNew )
187 {
189 }
190 else
191 {
192 ParseToSave();
193 }
194}

◆ RebuildModel

void dbse::SchemaMethodEditor::RebuildModel ( )
signal

◆ SetController()

void dbse::SchemaMethodEditor::SetController ( )

Definition at line 46 of file SchemaMethodEditor.cpp.

47{
48 connect ( ui->buttonBox, SIGNAL ( accepted() ), this, SLOT ( ProxySlot() ) );
49 connect ( ui->buttonBox, SIGNAL ( rejected() ), this, SLOT ( close() ) );
50 connect ( ui->AddButton, SIGNAL ( clicked() ), this,
51 SLOT ( AddNewMethodImplementation() ) );
52 connect ( ui->ImplementationsView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
53 SLOT ( OpenMethodImplementationEditor ( QModelIndex ) ) );
54 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassUpdated ( QString ) ), this,
55 SLOT ( ClassUpdated ( QString ) ) );
56}
void ClassUpdated(QString ClassName)
void OpenMethodImplementationEditor(QModelIndex Index)

◆ ShouldOpenMethodImplementationEditor()

bool dbse::SchemaMethodEditor::ShouldOpenMethodImplementationEditor ( QString Name)
private

Definition at line 160 of file SchemaMethodEditor.cpp.

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

Member Data Documentation

◆ ImplementationModel

CustomMethodImplementationModel* dbse::SchemaMethodEditor::ImplementationModel
private

Definition at line 40 of file SchemaMethodEditor.hpp.

◆ m_class

dunedaq::oks::OksClass* dbse::SchemaMethodEditor::m_class
private

Definition at line 38 of file SchemaMethodEditor.hpp.

◆ m_method

dunedaq::oks::OksMethod* dbse::SchemaMethodEditor::m_method
private

Definition at line 39 of file SchemaMethodEditor.hpp.

◆ m_writable

bool dbse::SchemaMethodEditor::m_writable
private

Definition at line 42 of file SchemaMethodEditor.hpp.

◆ ui

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

Definition at line 37 of file SchemaMethodEditor.hpp.

◆ UsedNew

bool dbse::SchemaMethodEditor::UsedNew
private

Definition at line 41 of file SchemaMethodEditor.hpp.


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