Extracted schema and library management to Application
This commit is contained in:
1 parent
0c4afe87d9
commit
86b8861533
12 files changed
+334
-182
No files matched your search
@@ -5,6 +5,8 @@
|
||||
#include "attribute_dialog.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "application.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
void AttributeDialog::onUpdate() {
|
||||
@@ -15,7 +17,7 @@ namespace display {
|
||||
|
||||
domain::ValidationContext context;
|
||||
|
||||
for (auto &addressSpace: MainWindow::getLibrary()->getAddressSpaces()) {
|
||||
for (auto &addressSpace: Application::instance()->getLibrary()->getAddressSpaces()) {
|
||||
context.addressSpaces.insert(std::make_pair(addressSpace.getName(), addressSpace));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "attribute_dialog.h"
|
||||
#include "name_dialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QLine>
|
||||
@@ -24,7 +25,7 @@ namespace display {
|
||||
[attr]() {
|
||||
if (attr->value.getType() == domain::Value::MEMORY_REFERENCE) {
|
||||
auto dialog = new MemoryDialog(attr,
|
||||
MainWindow::getSchema()->componentInstances);
|
||||
Application::instance()->getSchema()->componentInstances);
|
||||
dialog->exec();
|
||||
} else {
|
||||
auto dialog = new AttributeDialog(attr);
|
||||
|
||||
@@ -10,13 +10,14 @@ namespace display {
|
||||
Schema::Schema() {
|
||||
this->selectedBrush.setColor(QColor::fromRgb(20, 20, 125));
|
||||
this->selectedPen.setColor(QColor::fromRgb(20, 20, 125));
|
||||
|
||||
schema = nullptr;
|
||||
library = std::nullopt;
|
||||
this->setScene(&scene);
|
||||
this->setAcceptDrops(true);
|
||||
}
|
||||
|
||||
|
||||
void Schema::setSchema(domain::Schema *_schema, domain::Library *_library) {
|
||||
void Schema::setSchema(domain::Schema *_schema, std::optional<domain::Library> _library) {
|
||||
components.clear();
|
||||
buses.clear();
|
||||
|
||||
@@ -216,6 +217,9 @@ namespace display {
|
||||
|
||||
for (auto bus: busInstances) {
|
||||
auto &group = buses[bus->name];
|
||||
if(group == nullptr) {
|
||||
continue;
|
||||
}
|
||||
auto rect = new QGraphicsRectItem(group->boundingRect());
|
||||
rect->setPen(selectedPen);
|
||||
rect->setPos(group->scenePos());
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace display {
|
||||
std::vector<BusConnection *> busConnections;
|
||||
std::vector<DirectConnection *> directConnections;
|
||||
|
||||
void setSchema(domain::Schema *schema, domain::Library *library);
|
||||
void setSchema(domain::Schema *schema, std::optional<domain::Library> library);
|
||||
|
||||
void updateConnections();
|
||||
|
||||
@@ -65,8 +65,8 @@ namespace display {
|
||||
private:
|
||||
QGraphicsScene scene;
|
||||
|
||||
domain::Schema *schema;
|
||||
domain::Library *library;
|
||||
domain::Schema *schema{};
|
||||
std::optional<domain::Library> library;
|
||||
|
||||
std::vector<domain::BusInstance *>
|
||||
getAvailableConnectionBusses(domain::ComponentInstance *instance, domain::Pin &pin);
|
||||
|
||||
Reference in new issue
Block a user