diff --git a/SchemeEditor.pro.user b/SchemeEditor.pro.user index 2130b65..8d07bd2 100644 --- a/SchemeEditor.pro.user +++ b/SchemeEditor.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {1f5ef7b0-cf08-4d4a-b37d-18ed0b7a2084} + {391729b0-9fcc-4b56-ba51-7d7ee685fc97} ProjectExplorer.Project.ActiveTarget @@ -83,22 +83,25 @@ true + + true + ProjectExplorer.Project.Target.0 Desktop - Desktop Qt 5.15.2 clang 64bit - Desktop Qt 5.15.2 clang 64bit - qt.qt5.5152.clang_64_kit + Desktop + Desktop + {8ccd2350-ba56-4630-b9a6-4b0b4b193aaf} 0 0 0 0 - /Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Debug - /Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Debug + /home/bbr/build-SchemeEditor-Desktop-Debug + /home/bbr/build-SchemeEditor-Desktop-Debug true @@ -136,8 +139,8 @@ 2 - /Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Release - /Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Release + /home/bbr/build-SchemeEditor-Desktop-Release + /home/bbr/build-SchemeEditor-Desktop-Release true @@ -177,8 +180,8 @@ 0 - /Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Profile - /Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Profile + /home/bbr/build-SchemeEditor-Desktop-Profile + /home/bbr/build-SchemeEditor-Desktop-Profile true @@ -238,14 +241,14 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:/Users/s2ismac/Desktop/comdel/schema_editor/SchemeEditor.pro - /Users/s2ismac/Desktop/comdel/schema_editor/SchemeEditor.pro + Qt4ProjectManager.Qt4RunConfiguration:/home/bbr/SchemeEditor/SchemeEditor.pro + /home/bbr/SchemeEditor/SchemeEditor.pro false true true false true - /Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Debug/SchemeEditor.app/Contents/MacOS + /home/bbr/build-SchemeEditor-Desktop-Debug 1 diff --git a/comdel/display/schema_display.cpp b/comdel/display/schema_display.cpp index 7b18878..6564d36 100644 --- a/comdel/display/schema_display.cpp +++ b/comdel/display/schema_display.cpp @@ -9,11 +9,11 @@ Schema::Schema() } -void Schema::setSchema(std::optional schema) +void Schema::setSchema(domain::Schema* schema) { scene.clear(); this->schema = schema; - if(schema.has_value()) { + if(schema != nullptr) { for(auto &instance: schema->instances) { ComponentWrapper *group = nullptr; auto component = dynamic_cast(instance); diff --git a/comdel/display/schema_display.h b/comdel/display/schema_display.h index 6acd574..2e60997 100644 --- a/comdel/display/schema_display.h +++ b/comdel/display/schema_display.h @@ -14,12 +14,12 @@ class Schema: public QGraphicsView public: Schema(); - void setSchema(std::optional schema); + void setSchema(domain::Schema* schema); private: QGraphicsScene scene; - std::optional schema; + domain::Schema* schema; }; diff --git a/comdel/domain/schemacreator.cpp b/comdel/domain/schemacreator.cpp index 572700c..eae4383 100644 --- a/comdel/domain/schemacreator.cpp +++ b/comdel/domain/schemacreator.cpp @@ -728,28 +728,28 @@ std::optional SchemaCreator::loadCondition(ConditionNode node) } -std::optional SchemaCreator::loadSchema(SchemaNode node, Library &library) +Schema* SchemaCreator::loadSchema(SchemaNode node, Library &library) { - Schema schema; + Schema *schema = new Schema(); for(auto &instance: node.instances) { if(library.hasComponent(instance.component.value)) { - schema.instances.push_back(loadComponentInstance(instance, library)); + schema->instances.push_back(loadComponentInstance(instance, library)); } if(library.hasBus(instance.component.value)) { - schema.instances.push_back(loadBusInstance(instance, library)); + schema->instances.push_back(loadBusInstance(instance, library)); } } for(auto &wire: node.wires) { auto w = loadWireInstance(wire); if(w) { - schema.wires.push_back(*w); + schema->wires.push_back(*w); } } for(auto &conn: node.connections) { - auto firstComponent = dynamic_cast(schema.getInstance(conn.first.instance.value)); + auto firstComponent = dynamic_cast(schema->getInstance(conn.first.instance.value)); if(firstComponent == NULL) { errors.push_back(SourceError{conn.first.instance.span, "unknown component"}); continue; @@ -762,7 +762,7 @@ std::optional SchemaCreator::loadSchema(SchemaNode node, Library &librar ComponentInstance *secondComponent = NULL; if(conn.second.has_value()) { - secondComponent = dynamic_cast(schema.getInstance(conn.second->instance.value)); + secondComponent = dynamic_cast(schema->getInstance(conn.second->instance.value)); if(secondComponent == NULL) { errors.push_back(SourceError{conn.second->instance.span, "unknown component"}); continue; @@ -773,7 +773,7 @@ std::optional SchemaCreator::loadSchema(SchemaNode node, Library &librar } } - auto bus = dynamic_cast(schema.getInstance(conn.bus.value)); + auto bus = dynamic_cast(schema->getInstance(conn.bus.value)); if(bus == NULL) { errors.push_back(SourceError{conn.bus.span, "unknown bus"}); continue; @@ -808,12 +808,12 @@ std::optional SchemaCreator::loadSchema(SchemaNode node, Library &librar errors.push_back(SourceError{conn.span, "missing @wire"}); continue; } - if(!schema.hasWire(conn.wire->value)) { + if(!schema->hasWire(conn.wire->value)) { errors.push_back(SourceError{conn.wire->span, "unknown wire"}); continue; } - auto wire = schema.getWire(conn.wire->value); + auto wire = schema->getWire(conn.wire->value); std::vector attributes; for(auto& attr: conn.attributes) { @@ -837,9 +837,9 @@ std::optional SchemaCreator::loadSchema(SchemaNode node, Library &librar } if(secondComponent == NULL) { - schema.connections.push_back(new BusConnectionInstance(firstComponent, attributes, bus, wire, *connection)); + schema->connections.push_back(new BusConnectionInstance(firstComponent, attributes, bus, wire, *connection)); } else { - schema.connections.push_back(new DirectConnectionInstance(firstComponent, secondComponent, attributes, bus, wire, *connection)); + schema->connections.push_back(new DirectConnectionInstance(firstComponent, secondComponent, attributes, bus, wire, *connection)); } } diff --git a/comdel/domain/schemacreator.h b/comdel/domain/schemacreator.h index 7766d1b..fca225c 100644 --- a/comdel/domain/schemacreator.h +++ b/comdel/domain/schemacreator.h @@ -138,7 +138,7 @@ public: std::optional loadLibrary(LibraryNode node); - std::optional loadSchema(SchemaNode node, Library &library); + Schema* loadSchema(SchemaNode node, Library &library); }; } // namespace domain diff --git a/mainwindow.cpp b/mainwindow.cpp index b6bb74b..94e3bc3 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -84,7 +84,7 @@ void MainWindow::onLoadLibrary() { libraryDisplay->setLibrary(library); // on library load we create a new schema - schema = domain::Schema(); + schema = new domain::Schema(); schemaDisplay->setSchema(schema); } @@ -137,7 +137,7 @@ void MainWindow::onLoadSchema() { } void MainWindow::onValidateSchema(bool /*toggled*/) { - if(!schema.has_value()) { + if(schema == nullptr) { return; } @@ -191,7 +191,7 @@ void MainWindow::onValidateSchema(bool /*toggled*/) { void MainWindow::clear() { validationErrors.clear(); - schema = std::nullopt; + schema = nullptr; library = std::nullopt; libraryDisplay->setLibrary(library); diff --git a/mainwindow.h b/mainwindow.h index bb89262..82aa1f6 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -28,7 +28,7 @@ public: display::Schema *schemaDisplay; std::optional library = std::nullopt; - std::optional schema = std::nullopt; + domain::Schema* schema = nullptr; std::vector signatures;