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 {
|
|
|
|
|
2022-05-08 22:51:47 +00:00
|
|
|
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();
|
|
|
|
});
|
2022-05-08 22:51:47 +00:00
|
|
|
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();
|
|
|
|
});
|
2022-05-08 22:51:47 +00:00
|
|
|
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
|