44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#include "component_display.h"
|
|
#include "attribute_dialog.h"
|
|
#include "name_dialog.h"
|
|
|
|
#include <QMenu>
|
|
#include <QGraphicsSceneContextMenuEvent>
|
|
#include <QGraphicsScene>
|
|
#include <iostream>
|
|
|
|
namespace display {
|
|
|
|
void Component::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
|
QMenu menu;
|
|
menu.addAction("Izmjeni ime", [this](){
|
|
auto dialog = new NameDialog(this->instance.get());
|
|
dialog->exec();
|
|
});
|
|
menu.addSeparator();
|
|
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;
|
|
menu.addAction("Izmjeni ime", [this](){
|
|
auto dialog = new NameDialog(this->busInstance.get());
|
|
dialog->exec();
|
|
});
|
|
menu.exec(event->screenPos());
|
|
}
|
|
|
|
} // namespace display
|