3 #include "linkablemapobj.h"
4 #include "ornamentedobj.h"
8 extern FlagRowMaster *systemFlagsMaster;
10 MapItem::MapItem(TreeItem *parent)
13 // qDebug() << "Constr. MapItem(" << parent << ")";
21 hideLinkUnselected = false;
24 void MapItem::appendChild(TreeItem *item)
26 TreeItem::appendChild(item);
28 // FIXME-4 maybe access parent in MapObjs directly via treeItem
29 // and remove this here...
31 // If lmo exists, also set parObj there
32 LinkableMapObj *lmo = getLMO();
34 LinkableMapObj *itemLMO = ((MapItem *)item)->getLMO();
36 itemLMO->setParObj(lmo);
40 void MapItem::setRelPos(const QPointF &p)
44 LinkableMapObj *lmo = getLMO();
46 ((OrnamentedObj *)lmo)->setUseRelPos(true);
47 ((OrnamentedObj *)lmo)->move2RelPos(p);
51 void MapItem::setAbsPos(const QPointF &p)
59 void MapItem::setPositionMode(PositionMode mode) { posMode = mode; }
61 MapItem::PositionMode MapItem::getPositionMode() { return posMode; }
63 void MapItem::setHideLinkUnselected(bool b)
65 hideLinkUnselected = b;
66 LinkableMapObj *lmo = getLMO();
68 // lmo->setHideLinkUnselected();
69 lmo->setVisibility(lmo->isVisibleObj());
70 lmo->updateLinkGeometry();
74 bool MapItem::getHideLinkUnselected() { return hideLinkUnselected; }
76 QString MapItem::getMapAttr()
79 LinkableMapObj *lmo = getLMO();
81 if (parentItem == rootItem)
84 if (type == TreeItem::Image || depth() == 1 || lmo->getUseRelPos())
85 posMode = Relative; // FiXME-2 shouldn't this be replaced by relPos?
92 pos = lmo->getRelPos();
93 s = attribut("relPosX", QString().setNum(pos.x())) +
94 attribut("relPosY", QString().setNum(pos.y()));
98 pos = mo->getAbsPos();
99 s = attribut("absPosX", QString().setNum(pos.x())) +
100 attribut("absPosY", QString().setNum(pos.y()));
105 if (hideLinkUnselected)
106 s += attribut("hideLink", "true");
109 MapObj *mo = getMO();
111 angle = mo->getRotation();
113 s += attribut("rotation", QString().setNum(angle));
118 QRectF MapItem::getBBoxURLFlag()
120 QString s = "system-url";
121 QStringList list = systemFlags.activeFlagNames().filter(s);
122 if (list.count() > 1) {
123 qWarning() << "MapItem::getBBoxURLFlag found more than one system-url*";
127 Flag *f = systemFlagsMaster->findFlagByName(s);
129 QUuid u = f->getUuid();
130 LinkableMapObj *lmo = getLMO();
132 return ((OrnamentedObj *)lmo)->getBBoxSystemFlagByUid(u);
137 void MapItem::setRotation(const qreal &a)
140 MapObj *mo = getMO();
145 MapObj *MapItem::getMO() { return mo; }
147 LinkableMapObj *MapItem::getLMO()
149 if (isBranchLikeType() || type == Image)
150 return (LinkableMapObj *)mo;
155 void MapItem::initLMO()
157 LinkableMapObj *lmo = getLMO();