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 25 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 19 of file SchemaMethodEditor.cpp.

21 : QWidget ( parent ),
22 ui ( new Ui::SchemaMethodEditor ),
23 m_class ( ClassInfo ),
24 m_method ( Method ),
25 ImplementationModel ( nullptr ),
26 UsedNew ( false )
27{
28 QWidget::setAttribute(Qt::WA_DeleteOnClose);
29 m_writable = KernelWrapper::GetInstance().IsFileWritable(m_class->get_file()->get_full_file_name());
30 ui->setupUi ( this );
34}
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

◆ SchemaMethodEditor() [2/2]

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

Definition at line 36 of file SchemaMethodEditor.cpp.

37 : QWidget ( parent ),
38 ui ( new Ui::SchemaMethodEditor ),
39 m_class ( ClassInfo ),
40 m_method ( nullptr ),
41 ImplementationModel ( nullptr ),
42 UsedNew ( true )
43{
44 QWidget::setAttribute(Qt::WA_DeleteOnClose);
45 m_writable = KernelWrapper::GetInstance().IsFileWritable(m_class->get_file()->get_full_file_name());
46 ui->setupUi ( this );
49}

Member Function Documentation

◆ AddNewMethodImplementation

void dbse::SchemaMethodEditor::AddNewMethodImplementation ( )
privateslot

Definition at line 201 of file SchemaMethodEditor.cpp.

202{
203 if (UsedNew) {
204 if (create()) {
205 m_method = m_class->find_method(ui->MethodName->text().toStdString());
206 }
207 else {
208 QMessageBox::question (
209 0, tr ( "SchemaEditor" ),
210 tr ( "You must set the method name before you can set an implementation" ),
211 QMessageBox::Ok );
212 return;
213 }
214 }
215 SchemaMethodImplementationEditor * Editor = new SchemaMethodImplementationEditor (
216 m_class, m_method );
217 connect ( Editor, SIGNAL ( RebuildModel() ), this,
218 SLOT ( BuildModelImplementationSlot() ) );
219 Editor->show();
220}

◆ BuildModelImplementationSlot

void dbse::SchemaMethodEditor::BuildModelImplementationSlot ( )
privateslot

Definition at line 236 of file SchemaMethodEditor.cpp.

237{
238 BuildModels();
239}

◆ BuildModels()

void dbse::SchemaMethodEditor::BuildModels ( )

Definition at line 152 of file SchemaMethodEditor.cpp.

153{
154 QStringList MethodHeaders { "Language", "Prototype" };
155
156 if ( ImplementationModel != nullptr ) {
157 delete ImplementationModel;
158 }
159 ImplementationModel = new CustomMethodImplementationModel ( m_method, MethodHeaders );
160
161 ui->ImplementationsView->setModel ( ImplementationModel );
162 ui->ImplementationsView->horizontalHeader()->setSectionResizeMode ( QHeaderView::ResizeToContents );
163}

◆ ClassUpdated

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

Definition at line 63 of file SchemaMethodEditor.cpp.

64{
65 if(!UsedNew && ClassName.toStdString() == m_class->get_name()) {
66 if(m_class->find_direct_method(m_method->get_name()) != nullptr) {
67 FillInfo();
69 } else {
70 QWidget::close();
71 }
72 }
73}

◆ create()

bool dbse::SchemaMethodEditor::create ( )
private

Definition at line 134 of file SchemaMethodEditor.cpp.

134 {
135 std::string method_name = ui->MethodName->text().toStdString();
136 if (method_name.empty()) {
137 return false;
138 }
139 std::string method_description = ui->DescriptionTextBox->toPlainText().toStdString();
141 method_description );
142 emit RebuildModel();
143 UsedNew = false;
144 return true;
145}
void PushAddMethodCommand(dunedaq::oks::OksClass *Class, std::string name, std::string description)

◆ FillInfo()

void dbse::SchemaMethodEditor::FillInfo ( )
protected

Definition at line 75 of file SchemaMethodEditor.cpp.

76{
77 auto name = QString::fromStdString (
78 m_class->get_name() + "::" + m_method->get_name() );
79 setObjectName ( name );
80 setWindowTitle ( QString ( "Method Editor : %1" ).arg ( name ) );
81 ui->MethodName->setText ( QString::fromStdString ( m_method->get_name() ) );
82 ui->DescriptionTextBox->setPlainText (
83 QString::fromStdString ( m_method->get_description() ) );
84}

◆ InitialSettings()

void dbse::SchemaMethodEditor::InitialSettings ( )

Definition at line 86 of file SchemaMethodEditor.cpp.

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

◆ OpenMethodImplementationEditor

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

Definition at line 222 of file SchemaMethodEditor.cpp.

223{
224 QStringList Row = ImplementationModel->getRowFromIndex ( Index );
225 if ( !Row.isEmpty() ) {
226 QString name = QString::fromStdString(
227 m_class->get_name()+m_method->get_name()).append(Row.at ( 0 ));
229 SchemaMethodImplementationEditor * Editor = new SchemaMethodImplementationEditor (
230 m_class, m_method, m_method->find_implementation ( Row.at ( 0 ).toStdString() ) );
231 Editor->show();
232 }
233 }
234}
bool ShouldOpenMethodImplementationEditor(QString Name)

◆ ParseToCreate()

void dbse::SchemaMethodEditor::ParseToCreate ( )

Definition at line 146 of file SchemaMethodEditor.cpp.

147{
148 create();
149 close();
150}

◆ ParseToSave()

void dbse::SchemaMethodEditor::ParseToSave ( )

Definition at line 106 of file SchemaMethodEditor.cpp.

107{
108 bool changed = false;
109 std::string method_name = ui->MethodName->text().toStdString();
110 std::string method_description = ui->DescriptionTextBox->toPlainText().toStdString();
111
112 if ( method_name != m_method->get_name() )
113 {
115 changed = true;
116 }
117
118 if ( method_description != m_method->get_description() )
119 {
121 m_method,
122 method_description );
123 changed = true;
124 }
125
126 if ( changed )
127 {
128 emit RebuildModel();
129 }
130
131 close();
132}
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 189 of file SchemaMethodEditor.cpp.

190{
191 if ( UsedNew )
192 {
194 }
195 else
196 {
197 ParseToSave();
198 }
199}

◆ RebuildModel

void dbse::SchemaMethodEditor::RebuildModel ( )
signal

◆ SetController()

void dbse::SchemaMethodEditor::SetController ( )

Definition at line 51 of file SchemaMethodEditor.cpp.

52{
53 connect ( ui->buttonBox, SIGNAL ( accepted() ), this, SLOT ( ProxySlot() ) );
54 connect ( ui->buttonBox, SIGNAL ( rejected() ), this, SLOT ( close() ) );
55 connect ( ui->AddButton, SIGNAL ( clicked() ), this,
56 SLOT ( AddNewMethodImplementation() ) );
57 connect ( ui->ImplementationsView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
58 SLOT ( OpenMethodImplementationEditor ( QModelIndex ) ) );
59 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassUpdated ( QString ) ), this,
60 SLOT ( ClassUpdated ( QString ) ) );
61}
void ClassUpdated(QString ClassName)
void OpenMethodImplementationEditor(QModelIndex Index)

◆ ShouldOpenMethodImplementationEditor()

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

Definition at line 165 of file SchemaMethodEditor.cpp.

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

Member Data Documentation

◆ ImplementationModel

CustomMethodImplementationModel* dbse::SchemaMethodEditor::ImplementationModel
private

Definition at line 45 of file SchemaMethodEditor.hpp.

◆ m_class

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

Definition at line 43 of file SchemaMethodEditor.hpp.

◆ m_method

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

Definition at line 44 of file SchemaMethodEditor.hpp.

◆ m_writable

bool dbse::SchemaMethodEditor::m_writable
private

Definition at line 47 of file SchemaMethodEditor.hpp.

◆ ui

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

Definition at line 42 of file SchemaMethodEditor.hpp.

◆ UsedNew

bool dbse::SchemaMethodEditor::UsedNew
private

Definition at line 46 of file SchemaMethodEditor.hpp.


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