1 #include "qnstgraphicslink.h"
6 setnstType(Qnst::Link);
18 setTop(parent->getHeight()/2 - DEFAULT_AGGREGATOR_HEIGHT/2);
19 setLeft(parent->getWidth()/2 - DEFAULT_AGGREGATOR_WIDTH/2);
27 setWidth(DEFAULT_AGGREGATOR_WIDTH);
28 setHeight(DEFAULT_AGGREGATOR_HEIGHT);
31 QnstGraphicsLink::~QnstGraphicsLink()
36 void QnstGraphicsLink::createObjects()
39 menu->actionCut->setEnabled(
true);
40 menu->actionCopy->setEnabled(
true);
42 menu->actionDelete->setEnabled(
true);
44 menu->actionExport->setEnabled(
true);
47 void QnstGraphicsLink::createConnections()
52 connect(menu, SIGNAL(cutRequested()), SIGNAL(cutRequested()));
53 connect(menu, SIGNAL(copyRequested()), SIGNAL(copyRequested()));
54 connect(menu, SIGNAL(pasteRequested()), SIGNAL(pasteRequested()));
56 connect(menu, SIGNAL(deleteRequested()), SIGNAL(deleteRequested()));
58 connect(menu, SIGNAL(exportRequested()), SIGNAL(exportRequested()));
60 connect(menu, SIGNAL(zoominRequested()), SIGNAL(zoominRequested()));
61 connect(menu, SIGNAL(zoomoutRequested()), SIGNAL(zoomoutRequested()));
62 connect(menu, SIGNAL(zoomresetRequested()), SIGNAL(zoomresetRequested()));
63 connect(menu, SIGNAL(fullscreenRequested()), SIGNAL(fullscreenRequested()));
66 void QnstGraphicsLink::draw(QPainter* painter)
68 painter->setRenderHint(QPainter::Antialiasing,
true);
70 painter->setBrush(Qt::black);
72 painter->drawEllipse(4 + 8/2, 4 + 8/2, getWidth()-8, getHeight()-8);
75 if (!isSelected() && hasMouseHover())
77 painter->setBrush(Qt::NoBrush);
78 painter->setPen(QPen(QBrush(QColor(
"#999999")), 0, Qt::DashLine));
80 painter->drawRect(4, 4, getWidth(), getHeight());
85 painter->setBrush(Qt::NoBrush);
86 painter->setPen(QPen(QBrush(Qt::black), 0));
88 painter->setRenderHint(QPainter::Antialiasing,
false);
89 painter->drawRect(getMoveLeft()+4-getLeft(), getMoveTop()+4-getTop(),
90 getWidth()-1, getHeight()-1);
94 void QnstGraphicsLink::delineate(QPainterPath* painter)
const
96 painter->addRect(4, 4, getWidth(), getHeight());
99 QString QnstGraphicsLink::getxConnector()
const
104 void QnstGraphicsLink::setxConnector(QString xconnector)
106 this->xconnector = xconnector;
109 QString QnstGraphicsLink::getxConnectorUID()
const
111 return xconnectorUID;
114 void QnstGraphicsLink::setxConnectorUID(QString xconnectorUID)
116 this->xconnectorUID = xconnectorUID;
119 QMap<QString, QnstGraphicsBind*> QnstGraphicsLink::getActions()
const
128 actions.insert(action->getnstUid(), action);
129 action->setLink(
this);
137 actions.remove(action->getnstUid());
138 action->setLink(NULL);
142 QMap<QString, QnstGraphicsBind*> QnstGraphicsLink::getConditions()
const
149 if (condition != NULL)
151 conditions.insert(condition->getnstUid(), condition);
152 condition->setLink(
this);
158 if (condition != NULL)
160 conditions.remove(condition->getnstUid());
161 condition->setLink(NULL);
165 void QnstGraphicsLink::setProperties(
const QMap<QString, QString> &properties)
167 QnstGraphicsNode::setProperties(properties);
169 if (properties[
"xconnector"] !=
"")
170 setxConnector(properties[
"xconnector"]);
172 if (properties[
"xconnectorUID"] !=
"")
173 setxConnectorUID(properties[
"xconnectorUID"]);
176 void QnstGraphicsLink::getProperties(QMap<QString, QString> &properties)
178 QnstGraphicsNode::getProperties(properties);
180 properties[
"xconnector"] = getxConnector();
181 properties[
"xconnectorUID"] = getxConnectorUID();