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::OksClass * m_class
dunedaq::oks::OksMethod * m_method
CustomMethodImplementationModel * ImplementationModel
bool UsedNew
bool m_writable

Detailed Description

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

20 : QWidget(parent)
21 , ui(new Ui::SchemaMethodEditor)
22 , m_class(ClassInfo)
23 , m_method(Method)
24 , ImplementationModel(nullptr)
25 , UsedNew(false)
26{
27 QWidget::setAttribute(Qt::WA_DeleteOnClose);
29 ui->setupUi(this);
33}
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:352
const std::string & get_full_file_name() const
Definition file.hpp:528

◆ SchemaMethodEditor() [2/2]

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

Definition at line 35 of file SchemaMethodEditor.cpp.

36 : QWidget(parent)
37 , ui(new Ui::SchemaMethodEditor)
38 , m_class(ClassInfo)
39 , m_method(nullptr)
40 , ImplementationModel(nullptr)
41 , UsedNew(true)
42{
43 QWidget::setAttribute(Qt::WA_DeleteOnClose);
45 ui->setupUi(this);
48}

Member Function Documentation

◆ AddNewMethodImplementation

void dbse::SchemaMethodEditor::AddNewMethodImplementation ( )
privateslot

Definition at line 194 of file SchemaMethodEditor.cpp.

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

◆ BuildModelImplementationSlot

void dbse::SchemaMethodEditor::BuildModelImplementationSlot ( )
privateslot

Definition at line 227 of file SchemaMethodEditor.cpp.

228{
229 BuildModels();
230}

◆ BuildModels()

void dbse::SchemaMethodEditor::BuildModels ( )

Definition at line 149 of file SchemaMethodEditor.cpp.

150{
151 QStringList MethodHeaders{ "Language", "Prototype" };
152
153 if (ImplementationModel != nullptr) {
154 delete ImplementationModel;
155 }
157
158 ui->ImplementationsView->setModel(ImplementationModel);
159 ui->ImplementationsView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
160}
CustomMethodImplementationModel(dunedaq::oks::OksMethod *Method, QStringList Headers)

◆ ClassUpdated

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

Definition at line 64 of file SchemaMethodEditor.cpp.

65{
66 if (!UsedNew && ClassName.toStdString() == m_class->get_name()) {
67 if (m_class->find_direct_method(m_method->get_name()) != nullptr) {
68 FillInfo();
70 } else {
71 QWidget::close();
72 }
73 }
74}
const std::string & get_name() const noexcept
Definition class.hpp:374
OksMethod * find_direct_method(const std::string &name) const noexcept
Find direct method.
Definition class.cpp:1290
const std::string & get_name() const noexcept
Definition method.hpp:185

◆ create()

bool dbse::SchemaMethodEditor::create ( )
private

Definition at line 129 of file SchemaMethodEditor.cpp.

130{
131 std::string method_name = ui->MethodName->text().toStdString();
132 if (method_name.empty()) {
133 return false;
134 }
135 std::string method_description = ui->DescriptionTextBox->toPlainText().toStdString();
136 KernelWrapper::GetInstance().PushAddMethodCommand(m_class, method_name, 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 77 of file SchemaMethodEditor.cpp.

78{
79 auto name = QString::fromStdString(m_class->get_name() + "::" + m_method->get_name());
80 setObjectName(name);
81 setWindowTitle(QString("Method Editor : %1").arg(name));
82 ui->MethodName->setText(QString::fromStdString(m_method->get_name()));
83 ui->DescriptionTextBox->setPlainText(QString::fromStdString(m_method->get_description()));
84}
const std::string & get_description() const noexcept
Definition method.hpp:201

◆ InitialSettings()

void dbse::SchemaMethodEditor::InitialSettings ( )

Definition at line 87 of file SchemaMethodEditor.cpp.

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

◆ OpenMethodImplementationEditor

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

Definition at line 213 of file SchemaMethodEditor.cpp.

214{
215 QStringList Row = ImplementationModel->getRowFromIndex(Index);
216 if (!Row.isEmpty()) {
217 QString name = QString::fromStdString(m_class->get_name() + m_method->get_name()).append(Row.at(0));
219 SchemaMethodImplementationEditor* Editor =
221 Editor->show();
222 }
223 }
224}
QStringList getRowFromIndex(QModelIndex &index)
bool ShouldOpenMethodImplementationEditor(QString Name)
OksMethodImplementation * find_implementation(const std::string &language) const
Find method implementation.
Definition method.cpp:357

◆ ParseToCreate()

void dbse::SchemaMethodEditor::ParseToCreate ( )

Definition at line 142 of file SchemaMethodEditor.cpp.

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

◆ ParseToSave()

void dbse::SchemaMethodEditor::ParseToSave ( )

Definition at line 105 of file SchemaMethodEditor.cpp.

106{
107 bool changed = false;
108 std::string method_name = ui->MethodName->text().toStdString();
109 std::string method_description = ui->DescriptionTextBox->toPlainText().toStdString();
110
111 if (method_name != m_method->get_name()) {
113 changed = true;
114 }
115
116 if (method_description != m_method->get_description()) {
118 changed = true;
119 }
120
121 if (changed) {
122 emit RebuildModel();
123 }
124
125 close();
126}
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.
Changes could not be no object was changed

◆ ProxySlot

void dbse::SchemaMethodEditor::ProxySlot ( )
privateslot

Definition at line 184 of file SchemaMethodEditor.cpp.

185{
186 if (UsedNew) {
188 } else {
189 ParseToSave();
190 }
191}

◆ 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, SLOT(AddNewMethodImplementation()));
56 connect(ui->ImplementationsView,
57 SIGNAL(doubleClicked(QModelIndex)),
58 this,
59 SLOT(OpenMethodImplementationEditor(QModelIndex)));
60 connect(&KernelWrapper::GetInstance(), SIGNAL(ClassUpdated(QString)), this, SLOT(ClassUpdated(QString)));
61}
void ClassUpdated(QString ClassName)
void OpenMethodImplementationEditor(QModelIndex Index)

◆ ShouldOpenMethodImplementationEditor()

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

Definition at line 163 of file SchemaMethodEditor.cpp.

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

Member Data Documentation

◆ ImplementationModel

CustomMethodImplementationModel* dbse::SchemaMethodEditor::ImplementationModel
private

Definition at line 44 of file SchemaMethodEditor.hpp.

◆ m_class

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

Definition at line 42 of file SchemaMethodEditor.hpp.

◆ m_method

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

Definition at line 43 of file SchemaMethodEditor.hpp.

◆ m_writable

bool dbse::SchemaMethodEditor::m_writable
private

Definition at line 46 of file SchemaMethodEditor.hpp.

◆ ui

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

Definition at line 41 of file SchemaMethodEditor.hpp.

◆ UsedNew

bool dbse::SchemaMethodEditor::UsedNew
private

Definition at line 45 of file SchemaMethodEditor.hpp.


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