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
 

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);
24 ui->setupUi ( this );
28}
CustomMethodImplementationModel * ImplementationModel
dunedaq::oks::OksClass * m_class
dunedaq::oks::OksMethod * m_method
std::unique_ptr< dbse::Ui::SchemaMethodEditor > ui

◆ SchemaMethodEditor() [2/2]

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

Definition at line 30 of file SchemaMethodEditor.cpp.

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

Member Function Documentation

◆ AddNewMethodImplementation

void dbse::SchemaMethodEditor::AddNewMethodImplementation ( )
privateslot

Definition at line 188 of file SchemaMethodEditor.cpp.

189{
190 if (UsedNew) {
191 if (create()) {
192 m_method = m_class->find_method(ui->MethodName->text().toStdString());
193 }
194 else {
195 QMessageBox::question (
196 0, tr ( "SchemaEditor" ),
197 tr ( "You must set the method name before you can set an implementation" ),
198 QMessageBox::Ok );
199 return;
200 }
201 }
202 SchemaMethodImplementationEditor * Editor = new SchemaMethodImplementationEditor (
203 m_class, m_method );
204 connect ( Editor, SIGNAL ( RebuildModel() ), this,
205 SLOT ( BuildModelImplementationSlot() ) );
206 Editor->show();
207}
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 222 of file SchemaMethodEditor.cpp.

223{
224 BuildModels();
225}

◆ BuildModels()

void dbse::SchemaMethodEditor::BuildModels ( )

Definition at line 139 of file SchemaMethodEditor.cpp.

140{
141 QStringList MethodHeaders { "Language", "Prototype" };
142
143 if ( ImplementationModel != nullptr ) {
144 delete ImplementationModel;
145 }
146 ImplementationModel = new CustomMethodImplementationModel ( m_method, MethodHeaders );
147
148 ui->ImplementationsView->setModel ( ImplementationModel );
149 ui->ImplementationsView->horizontalHeader()->setSectionResizeMode ( QHeaderView::ResizeToContents );
150}

◆ ClassUpdated

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

Definition at line 56 of file SchemaMethodEditor.cpp.

57{
58 if(!UsedNew && ClassName.toStdString() == m_class->get_name()) {
59 if(m_class->find_direct_method(m_method->get_name()) != nullptr) {
60 FillInfo();
62 } else {
63 QWidget::close();
64 }
65 }
66}
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 121 of file SchemaMethodEditor.cpp.

121 {
122 std::string method_name = ui->MethodName->text().toStdString();
123 if (method_name.empty()) {
124 return false;
125 }
126 std::string method_description = ui->DescriptionTextBox->toPlainText().toStdString();
128 method_description );
129 emit RebuildModel();
130 UsedNew = false;
131 return true;
132}
static KernelWrapper & GetInstance()
void PushAddMethodCommand(dunedaq::oks::OksClass *Class, std::string name, std::string description)

◆ FillInfo()

void dbse::SchemaMethodEditor::FillInfo ( )
protected

Definition at line 68 of file SchemaMethodEditor.cpp.

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

◆ InitialSettings()

void dbse::SchemaMethodEditor::InitialSettings ( )

Definition at line 79 of file SchemaMethodEditor.cpp.

80{
81 if ( UsedNew )
82 {
83 setWindowTitle ( "New Method" );
84 setObjectName ( "NEW" );
85 ui->AddButton->setEnabled ( true );
86 }
87 else
88 {
89 FillInfo();
90 }
91}

◆ OpenMethodImplementationEditor

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

Definition at line 209 of file SchemaMethodEditor.cpp.

210{
211 QStringList Row = ImplementationModel->getRowFromIndex ( Index );
212 if ( !Row.isEmpty() ) {
213 QString name = QString::fromStdString(m_method->get_name()).append(Row.at ( 0 ));
215 SchemaMethodImplementationEditor * Editor = new SchemaMethodImplementationEditor (
216 m_class, m_method, m_method->find_implementation ( Row.at ( 0 ).toStdString() ) );
217 Editor->show();
218 }
219 }
220}
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 133 of file SchemaMethodEditor.cpp.

134{
135 create();
136 close();
137}

◆ ParseToSave()

void dbse::SchemaMethodEditor::ParseToSave ( )

Definition at line 93 of file SchemaMethodEditor.cpp.

94{
95 bool changed = false;
96 std::string method_name = ui->MethodName->text().toStdString();
97 std::string method_description = ui->DescriptionTextBox->toPlainText().toStdString();
98
99 if ( method_name != m_method->get_name() )
100 {
102 changed = true;
103 }
104
105 if ( method_description != m_method->get_description() )
106 {
108 m_method,
109 method_description );
110 changed = true;
111 }
112
113 if ( changed )
114 {
115 emit RebuildModel();
116 }
117
118 close();
119}
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 176 of file SchemaMethodEditor.cpp.

177{
178 if ( UsedNew )
179 {
181 }
182 else
183 {
184 ParseToSave();
185 }
186}

◆ RebuildModel

void dbse::SchemaMethodEditor::RebuildModel ( )
signal

◆ SetController()

void dbse::SchemaMethodEditor::SetController ( )

Definition at line 44 of file SchemaMethodEditor.cpp.

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

◆ ShouldOpenMethodImplementationEditor()

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

Definition at line 152 of file SchemaMethodEditor.cpp.

153{
154 bool WidgetFound = false;
155
156 for ( QWidget * Editor : QApplication::allWidgets() )
157 {
158 SchemaMethodImplementationEditor * Widget =
159 dynamic_cast<SchemaMethodImplementationEditor *> ( Editor );
160
161 if ( Widget != nullptr )
162 {
163 if ( ( Widget->objectName() ).compare ( Name ) == 0 )
164 {
165 Widget->raise();
166 Widget->setVisible ( true );
167 Widget->activateWindow();
168 WidgetFound = true;
169 }
170 }
171 }
172
173 return !WidgetFound;
174}

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.

◆ 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: