5 #include "branchitem.h"
13 /////////////////////////////////////////////////////////////////
15 /////////////////////////////////////////////////////////////////
17 Link::Link(VymModel *m)
19 // qDebug() << "Const Link () this="<<this;
26 // qDebug()<<"* Destr Link begin this="<<this<<" bLI="<<beginLinkItem<<"
27 // eLI="<<endLinkItem;
29 // qDebug()<<"* Destr Link end this="<<this;
39 xLinkState = Link::undefinedXLink;
42 pen = model->getMapDefXLinkPen();
45 VymModel *Link::getModel() { return model; }
47 void Link::setBeginBranch(BranchItem *bi)
50 xLinkState = initXLink;
55 BranchItem *Link::getBeginBranch() { return beginBranch; }
57 void Link::setEndBranch(BranchItem *bi)
66 BranchItem *Link::getEndBranch() { return endBranch; }
68 void Link::setEndPoint(QPointF p)
70 // Used only while creating the link, without endBranch
75 void Link::setBeginLinkItem(XLinkItem *li)
78 xLinkState = initXLink;
83 XLinkItem *Link::getBeginLinkItem() { return beginLinkItem; }
85 void Link::setEndLinkItem(XLinkItem *li)
88 xLinkState = initXLink;
93 XLinkItem *Link::getEndLinkItem() { return endLinkItem; }
95 XLinkItem *Link::getOtherEnd(XLinkItem *xli)
97 if (xli == beginLinkItem)
99 if (xli == endLinkItem)
100 return beginLinkItem;
104 void Link::setPen(const QPen &p)
111 QPen Link::getPen() { return pen; }
113 void Link::setLinkType(const QString &s)
117 else if (s == "Bezier")
120 qWarning() << "Link::setLinkType Unknown type: " << s;
123 void Link::setStyleBegin(const QString &s)
126 xlo->setStyleBegin(s);
131 QString Link::getStyleBeginString()
134 return ArrowObj::styleToString(xlo->getStyleBegin());
139 void Link::setStyleEnd(const QString &s)
147 QString Link::getStyleEndString()
150 return ArrowObj::styleToString(xlo->getStyleEnd());
155 bool Link::activate()
157 if (beginBranch && endBranch) {
158 if (beginBranch == endBranch)
160 xLinkState = activeXLink;
161 model->updateActions();
168 void Link::deactivate()
170 // Remove pointers from XLinkItem to Link and
173 // qDebug()<<"Link::deactivate ******************************";
174 xLinkState = deleteXLink;
176 beginLinkItem->setLink(NULL);
178 endLinkItem->setLink(NULL);
185 Link::XLinkState Link::getState() { return xLinkState; }
187 void Link::removeXLinkItem(XLinkItem *xli)
189 // Only mark _one_ end for removal here!
190 if (xli == beginLinkItem)
191 beginLinkItem = NULL;
192 if (xli == endLinkItem)
194 xLinkState = deleteXLink;
197 void Link::updateLink()
203 QString Link::saveToDir()
205 // qDebug()<<"Link::saveToDir this="<<this<<"
206 // beginBranch="<<beginBranch<<" endBranch="<<endBranch<<"
207 // state="<<xLinkState;
209 if (beginBranch && endBranch && xLinkState == activeXLink) {
210 if (beginBranch == endBranch)
212 "Link::saveToDir ignored, because beginBranch==endBranch, ");
214 QString colAttr = attribut("color", pen.color().name());
216 attribut("width", QString().setNum(pen.width(), 10));
218 attribut("penstyle", penStyleToString(pen.style()));
223 typeAttr = attribut("type", "Linear");
226 typeAttr = attribut("type", "Bezier");
228 ctrlAttr += attribut("c0", pointToString(xlo->getC0()));
229 ctrlAttr += attribut("c1", pointToString(xlo->getC1()));
234 attribut("beginID", model->getSelectString(beginBranch));
236 attribut("endID", model->getSelectString(endBranch));
240 QString(" styleBegin=\"%1\"")
241 .arg(ArrowObj::styleToString(xlo->getStyleBegin()));
243 QString(" styleEnd=\"%1\"")
244 .arg(ArrowObj::styleToString(xlo->getStyleEnd()));
246 s = singleElement("xlink", colAttr + widAttr + styAttr + typeAttr +
247 ctrlAttr + begSelAttr + endSelAttr +
254 XLinkObj *Link::getXLinkObj() { return xlo; }
256 XLinkObj *Link::createMapObj()
259 xlo = new XLinkObj(beginBranch->getLMO(), this);
260 xlo->setVisibility();
264 MapObj *Link::getMO() { return xlo; }