schema_editor/comdel/display/component_display.cpp

44 lines
1.2 KiB
C++
Raw Normal View History

2022-04-07 22:21:23 +00:00
#include "component_display.h"
2022-05-15 14:13:29 +00:00
#include "attribute_dialog.h"
#include "name_dialog.h"
2022-04-07 22:21:23 +00:00
2022-04-10 15:24:15 +00:00
#include <QMenu>
#include <QGraphicsSceneContextMenuEvent>
2022-04-20 19:50:39 +00:00
#include <QGraphicsScene>
2022-04-10 15:24:15 +00:00
#include <iostream>
2022-04-07 22:21:23 +00:00
namespace display {
void Component::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
QMenu menu;
2022-05-15 15:00:20 +00:00
menu.addAction("Izmjeni ime", [this](){
auto dialog = new NameDialog(this->instance.get());
dialog->exec();
});
menu.addSeparator();
2022-05-15 14:13:29 +00:00
for(int i=0; i<this->instance->attributes.size(); i++) {
auto* attr = &this->instance->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());
}
void Bus::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
QMenu menu;
2022-05-15 15:00:20 +00:00
menu.addAction("Izmjeni ime", [this](){
auto dialog = new NameDialog(this->busInstance.get());
dialog->exec();
2022-04-20 19:50:39 +00:00
});
2022-04-10 15:24:15 +00:00
menu.exec(event->screenPos());
}
2022-04-07 22:21:23 +00:00
} // namespace display