diff -r 7b4e73ac247e -r 1fb50e79661c mapitem.cpp --- a/mapitem.cpp Mon Jun 29 10:28:28 2009 +0000 +++ b/mapitem.cpp Tue Jul 07 09:34:24 2009 +0000 @@ -8,10 +8,32 @@ init(); } +MapItem::MapItem(const QList &data, TreeItem *parent):TreeItem (data,parent) +{ + init(); +} + void MapItem::init() { lmo=NULL; posMode=Unused; + hideLinkUnselected=false; +} + +void MapItem::appendChild (TreeItem *item) +{ + TreeItem::appendChild (item); + + // FIXME-4 maybe access parent in MapObjs directly via treeItem + // and remove this here... + + // If lmo exists, also set parObj there + if (lmo && (item->isBranchLikeType() || item->getType()==TreeItem::Image) ) + { + LinkableMapObj *itemLMO=((MapItem*)item)->lmo; + if (itemLMO) + itemLMO->setParObj (lmo); + } } void MapItem::setRelPos (const QPointF &p) @@ -37,6 +59,51 @@ posMode=mode; } +void MapItem::setHideLinkUnselected (bool b) +{ + hideLinkUnselected=b; + if (lmo) lmo->setHideLinkUnselected(); +} + +bool MapItem::getHideLinkUnselected() +{ + return hideLinkUnselected; +} + +QString MapItem::getMapAttr () +{ + QString s; + + if (parentItem==rootItem) + posMode=Absolute; + else + { + if (type==TreeItem::Image ||depth()==1) + posMode=Relative; + else + posMode=Unused; + } + switch (posMode) + { + case Relative: + if (lmo) pos=lmo->getRelPos(); + s= attribut("relPosX",QString().setNum(pos.x())) + + attribut("relPosY",QString().setNum(pos.y())); + break; + case Absolute: + if (lmo) pos=lmo->getAbsPos(); + s=attribut("absPosX",QString().setNum(pos.x())) + + attribut("absPosY",QString().setNum(pos.y())); + break; + default: break; + } + if (hideLinkUnselected) + s+=attribut ("hideLink","true"); + else + s+=attribut ("hideLink","false"); + return s; +} + LinkableMapObj* MapItem::getLMO() { return lmo;