Added log display
This commit is contained in:
parent
883eaeb10a
commit
23e63f7b6f
|
@ -9,7 +9,7 @@ Schema::Schema()
|
|||
}
|
||||
|
||||
|
||||
void Schema::setSchema(std::optional<domain::Schema>& schema)
|
||||
void Schema::setSchema(std::optional<domain::Schema> schema)
|
||||
{
|
||||
scene.clear();
|
||||
this->schema = schema;
|
||||
|
|
|
@ -14,7 +14,7 @@ class Schema: public QGraphicsView
|
|||
public:
|
||||
Schema();
|
||||
|
||||
void setSchema(std::optional<domain::Schema>& schema);
|
||||
void setSchema(std::optional<domain::Schema> schema);
|
||||
|
||||
private:
|
||||
QGraphicsScene scene;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <comdel/domain/schemacreator.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <QPlainTextEdit>
|
||||
#include <sstream>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
|
@ -40,45 +42,60 @@ void MainWindow::setupUi()
|
|||
|
||||
// setup central content
|
||||
libraryDisplay = new display::Library();
|
||||
|
||||
auto schemaParent = new QWidget();
|
||||
auto schemaLayout = new QVBoxLayout();
|
||||
schemaParent->setLayout(schemaLayout);
|
||||
|
||||
schemaDisplay = new display::Schema();
|
||||
schemaLayout->setMargin(0);
|
||||
schemaLayout->addWidget(schemaDisplay, 1);
|
||||
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(libraryDisplay);
|
||||
layout->addWidget(schemaDisplay, 1);
|
||||
|
||||
layout->addWidget(schemaParent, 1);
|
||||
|
||||
log = new QPlainTextEdit();
|
||||
log->setFont(QFont("Courier"));
|
||||
schemaLayout->addWidget(log);
|
||||
}
|
||||
|
||||
void MainWindow::onTestModal() {
|
||||
QString filename = "/home/bbr/Documents/personal/projects/modeler/schema.csl";
|
||||
|
||||
std::ostringstream buffer;
|
||||
|
||||
if(!filename.isEmpty()) {
|
||||
clear();
|
||||
|
||||
ParseContext parseContext;
|
||||
auto schemaNode = loadSchemaFromFile(&parseContext, filename.toStdString().c_str(), std::cout);
|
||||
auto schemaNode = loadSchemaFromFile(&parseContext, filename.toStdString().c_str(), buffer);
|
||||
|
||||
if(schemaNode) {
|
||||
domain::SchemaCreator generator(signatures);
|
||||
library = generator.loadLibrary(*schemaNode->library);
|
||||
|
||||
for (auto& error : generator.getErrors()) {
|
||||
parseContext.formatError(error, std::cout, "GENERATOR ERROR: ");
|
||||
}
|
||||
|
||||
if(library) {
|
||||
schema = generator.loadSchema(*schemaNode, *library);
|
||||
|
||||
for (auto& error : generator.getErrors()) {
|
||||
parseContext.formatError(error, std::cout, "LIBRARY ERROR: ");
|
||||
}
|
||||
}
|
||||
|
||||
libraryDisplay->setLibrary(library);
|
||||
schemaDisplay->setSchema(schema);
|
||||
for (auto& error : generator.getErrors()) {
|
||||
parseContext.formatError(error, buffer, "ERROR: ");
|
||||
}
|
||||
|
||||
if(generator.getErrors().empty()) {
|
||||
libraryDisplay->setLibrary(library);
|
||||
schemaDisplay->setSchema(schema);
|
||||
} else {
|
||||
libraryDisplay->setLibrary(std::nullopt);
|
||||
schemaDisplay->setSchema(std::nullopt);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
log->appendPlainText(QString::fromStdString(buffer.str()));
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::onLoadLibrary() {
|
||||
|
@ -131,6 +148,8 @@ void MainWindow::onLoadSchema() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
libraryDisplay->setLibrary(library);
|
||||
schemaDisplay->setSchema(schema);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <comdel/domain/library.h>
|
||||
#include <comdel/domain/schema.h>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
|
@ -40,5 +41,6 @@ private slots:
|
|||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QPlainTextEdit *log;
|
||||
};
|
||||
#endif // MAIN_WINDOW_H
|
||||
|
|
Loading…
Reference in New Issue