00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "node.h"
00023 #include <QGraphicsScene>
00024
00025
00026 Node::Node(QGraphicsItem * parent, QGraphicsScene * scene): QGraphicsItem(parent, scene), name(), type() { }
00027
00028 void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
00029 {
00030
00031 QGraphicsItem *ancestor = parentItem();
00032 while (ancestor) {
00033 ancestor->update();
00034 ancestor = ancestor->parentItem();
00035 }
00036
00037 QGraphicsItem::mouseMoveEvent(event);
00038
00039 }
00040
00041 void Node::addInLink(Link *link)
00042 {
00043 myInLinks.append(link);
00044 }
00045
00046 void Node::addOutLink(Link *link)
00047 {
00048 myOutLinks.append(link);
00049 }
00050
00051 void Node::removeLink(Link *link)
00052 {
00053 myInLinks.removeAll(link);
00054 myOutLinks.removeAll(link);
00055 }
00056
00057 QList<Link *> Node::getLinks() const
00058 {
00059 return (myInLinks + myOutLinks);
00060 }
00061
00062 QList<Link *> Node::getInLinks() const
00063 {
00064 return myInLinks;
00065 }
00066
00067 QList<Link *> Node::getOutLinks() const
00068 {
00069 return myOutLinks;
00070 }
00071
00072
00073
00074 void Node::setText(const QString &text)
00075 {
00076 prepareGeometryChange();
00077 myText = text;
00078 update();
00079 }
00080
00081 QString Node::text() const
00082 {
00083 return myText;
00084 }
00085
00086 void Node::setTextColor(const QColor &color)
00087 {
00088 myTextColor = color;
00089 update();
00090 }
00091
00092 QColor Node::textColor() const
00093 {
00094 return myTextColor;
00095 }
00096
00097 void Node::setOutlineColor(const QColor &color)
00098 {
00099 myOutlineColor = color;
00100 update();
00101 }
00102
00103 QColor Node::outlineColor() const
00104 {
00105 return myOutlineColor;
00106 }
00107
00108 void Node::setBackgroundColor(const QColor &color)
00109 {
00110 myBackgroundColor = color;
00111 update();
00112 }
00113
00114 QColor Node::backgroundColor() const
00115 {
00116 return myBackgroundColor;
00117 }
00118
00119 QRectF Node::boundingRect() const
00120 {
00121 const int Margin = 1;
00122 return outlineRect().adjusted(-Margin, -Margin, +Margin, +Margin);
00123 }
00124
00125 QPainterPath Node::shape() const
00126 {
00127 QRectF rect = outlineRect();
00128
00129 QPainterPath path;
00130 path.addRoundRect(rect, roundness(rect.width()),
00131 roundness(rect.height()));
00132 return path;
00133 }
00134