Fixed schema generation
This commit is contained in:
1 parent
9b7ede933a
commit
1ec8b10ef5
7 files changed
+196
-20
No files matched your search
@@ -3,6 +3,7 @@
|
||||
#include "name_dialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "application.h"
|
||||
#include "single_automatic_dialog.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QLine>
|
||||
@@ -225,6 +226,8 @@ namespace display {
|
||||
connection), component(component), bus(bus) {
|
||||
updateConnection();
|
||||
|
||||
setCursor(Qt::CrossCursor);
|
||||
|
||||
setHandlesChildEvents(false);
|
||||
}
|
||||
|
||||
@@ -249,23 +252,35 @@ namespace display {
|
||||
QMenu menu;
|
||||
menu.addAction("Ukloni poveznicu", [this]() {});
|
||||
menu.addSeparator();
|
||||
for (int i = 0; i < this->connection->attributes.size(); i++) {
|
||||
auto *attr = &this->connection->attributes[i];
|
||||
bool enabled = attr->attribute.getPopup().has_value();
|
||||
|
||||
auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name),
|
||||
[attr]() {
|
||||
auto dialog = new AttributeDialog(attr);
|
||||
dialog->exec();
|
||||
});
|
||||
action->setEnabled(enabled);
|
||||
if(connection->bus->bus.getType() == domain::Bus::SINGLE_AUTOMATIC) {
|
||||
auto &attributes = this->connection->attributes;
|
||||
menu.addAction(QString::fromStdString("Izmjeni poveznicu"),
|
||||
[&attributes]() {
|
||||
auto dialog = new display::SingleAutomaticDialog(attributes);
|
||||
dialog->exec();
|
||||
});
|
||||
} else {
|
||||
for (int i = 0; i < this->connection->attributes.size(); i++) {
|
||||
auto *attr = &this->connection->attributes[i];
|
||||
bool enabled = attr->attribute.getPopup().has_value();
|
||||
|
||||
auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name),
|
||||
[attr]() {
|
||||
auto dialog = new AttributeDialog(attr);
|
||||
dialog->exec();
|
||||
});
|
||||
action->setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
menu.exec(event->screenPos());
|
||||
}
|
||||
|
||||
DirectConnection::DirectConnection(domain::DirectConnectionInstance *connection, ComponentGroup *first,
|
||||
ComponentGroup *second): connection(connection), first(first), second(second) {
|
||||
updateConnection();
|
||||
setCursor(Qt::CrossCursor);
|
||||
setHandlesChildEvents(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +285,11 @@ namespace domain {
|
||||
} else {
|
||||
// if no connection exists than defaults must exist
|
||||
for (auto &wire: *pin.getWires()) {
|
||||
tempOutput << wire.stringify() << ", ";
|
||||
if(wire.isType(Value::NIL)) {
|
||||
tempOutput << "*, ";
|
||||
} else {
|
||||
tempOutput << wire.stringify() << ", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,22 +315,26 @@ namespace domain {
|
||||
std::vector<Value> defaults;
|
||||
if (connection->instance->name == name && connection->connection.getComponent().pin == pin) {
|
||||
wires = connection->connection.getWires();
|
||||
selected = connection->attributes[0].value.asReference();
|
||||
selected = connection->attributes[0].value.asString();
|
||||
defaults = *connection->instance->component.getPin(pin).getWires();
|
||||
} else {
|
||||
wires = *connection->connection.getSecondWires();
|
||||
selected = connection->attributes[1].value.asReference();
|
||||
selected = connection->attributes[1].value.asString();
|
||||
defaults = *connection->secondInstance->component.getPin(pin).getWires();
|
||||
}
|
||||
|
||||
for (int i = 0; i < wires.size(); i++) {
|
||||
if (wires[i].isType(Value::STRING)) {
|
||||
if (wires[i].asString() == selected) {
|
||||
buffer << wireNames[connection->bus->name + "." + connection->bus->bus.getWires()[0].getName()]
|
||||
<< ", ";
|
||||
auto wireName = connection->bus->name + "." + connection->bus->bus.getWires()[0].getName();
|
||||
buffer << wireNames[wireName] << ", ";
|
||||
} else if(defaults[i].isType(Value::NIL)) {
|
||||
buffer << "*, ";
|
||||
} else {
|
||||
buffer << defaults[i].stringify();
|
||||
buffer << defaults[i].stringify() << ", ";
|
||||
}
|
||||
} else if(defaults[i].isType(Value::NIL)) {
|
||||
buffer << "*, ";
|
||||
} else {
|
||||
buffer << wires[i].stringify() << ", ";
|
||||
}
|
||||
|
||||
@@ -736,7 +736,7 @@ namespace domain {
|
||||
|
||||
std::optional<Popup> popup;
|
||||
if (node.popup) {
|
||||
popup = loadPopup(*node.popup, name, value.getType());
|
||||
popup = loadPopup(*node.popup, name, toType(node.type));
|
||||
}
|
||||
|
||||
pop();
|
||||
@@ -958,7 +958,7 @@ namespace domain {
|
||||
errors.emplace_back(attr.span, "invalid value");
|
||||
}
|
||||
|
||||
attributes.emplace_back(attribute.getName(), toType(attr.value), attribute);
|
||||
attributes.emplace_back(attribute.getName(), value, attribute);
|
||||
} else {
|
||||
errors.emplace_back(attr.name.span, "unknown attribute");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user