NCL Composer  0.1.5
 All Classes Functions Variables Pages
qnstgraphicsport.cpp
1 #include "qnstgraphicsport.h"
2 
3 QnstGraphicsPort::QnstGraphicsPort(QnstGraphicsEntity* parent)
4  : QnstGraphicsInterface(parent)
5 {
6  setnstType(Qnst::Port);
7 
8  setnstId("");
9 }
10 
11 QnstGraphicsPort::~QnstGraphicsPort()
12 {
13 
14 }
15 
16 QString QnstGraphicsPort::getComponent() const
17 {
18  return component;
19 }
20 
21 void QnstGraphicsPort::setComponent(QString component)
22 {
23  this->component = component;
24 }
25 
26 QString QnstGraphicsPort::getComponentUid() const
27 {
28  return componentUid;
29 }
30 
31 void QnstGraphicsPort::setComponentUid(QString componentUid)
32 {
33  this->componentUid = componentUid;
34 }
35 
36 QString QnstGraphicsPort::getInterface() const
37 {
38  return interface;
39 }
40 
41 void QnstGraphicsPort::setInterface(QString interface)
42 {
43  this->interface = interface;
44 }
45 
46 QString QnstGraphicsPort::getInterfaceUid() const
47 {
48  return interfaceUid;
49 }
50 
51 void QnstGraphicsPort::setInterfaceUid(QString interfaceUid)
52 {
53  this->interfaceUid = interfaceUid;
54 }
55 
56 void QnstGraphicsPort::draw(QPainter* painter)
57 {
58  painter->setBrush(Qt::black);
59 
60  painter->drawRect(4 + 8/2, 4 + 8/2, getWidth()-8, getHeight()-8);
61 
62  // Draw MouseOver rectangle
63  if (!isSelected() && hasMouseHover())
64  {
65  painter->setBrush(Qt::NoBrush);
66  painter->setPen(QPen(QBrush(QColor("#999999")), 0, Qt::DashLine)); // 0px = cosmetic border
67 
68  painter->drawRect(4, 4, getWidth(), getHeight());
69  }
70 
71  if (isMoving())
72  {
73  painter->setBrush(Qt::NoBrush);
74  painter->setPen(QPen(QBrush(Qt::black), 0)); // 0px = cosmetic border
75 
76  painter->drawRect(getMoveLeft()+4-getLeft(),getMoveTop()+4-getTop(),getWidth()-1,getHeight()-1);
77  }
78 }
79 
80 void QnstGraphicsPort::delineate(QPainterPath* painter) const
81 {
82  painter->addRect(4 + 8/2, 4 + 8/2, getWidth()-8, getHeight()-8);
83 }
84 
85 void QnstGraphicsPort::setProperties(const QMap<QString, QString> &properties)
86 {
87  QnstGraphicsInterface::setProperties(properties);
88 
89  setComponent(properties["component"]);
90 
91  if (properties["componentUid"] != "")
92  setComponentUid(properties["componentUid"]);
93  else
94  setComponentUid("");
95 
96  setInterface(properties["interface"]);
97 
98  if (properties["interfaceUid"] != "")
99  setInterfaceUid(properties["interfaceUid"]);
100  else
101  setInterfaceUid("");
102 }
103 
104 void QnstGraphicsPort::getProperties(QMap<QString, QString> &properties)
105 {
106  QnstGraphicsInterface::getProperties(properties);
107 
108  properties["component"] = getComponent();
109  properties["componentUid"] = getComponentUid();
110 
111  properties["interface"] = getInterface();
112  properties["interfaceUid"] = getInterfaceUid();
113 
114 }