diff -r d85834ad8c54 -r 133e2ed6b9c5 xml-vym.cpp --- a/xml-vym.cpp Mon Aug 24 14:39:07 2009 +0000 +++ b/xml-vym.cpp Thu Sep 03 08:52:00 2009 +0000 @@ -12,6 +12,7 @@ #include "linkablemapobj.h" #include "mainwindow.h" #include "version.h" +#include "xlinkitem.h" static ImageItem *lastImageItem; static MapItem *lastMI; @@ -450,8 +451,8 @@ return false; // Couldn't read absPos } } - //if (!a.value( "id").isEmpty() ) - // lastMI->setID (a.value ("id")); // FIXME-3 + if (!a.value( "id").isEmpty() ) + lastMI->setID (a.value ("id")); if (!a.value( "url").isEmpty() ) lastMI->setURL (a.value ("url")); @@ -550,67 +551,39 @@ return true; } -bool parseVYMHandler::readXLinkAttr (const QXmlAttributes& a) +bool parseVYMHandler::readXLinkAttr (const QXmlAttributes& a) { - QColor col; - bool okx; - bool success=false; - XLinkObj *xlo=new XLinkObj (model->getScene()); - if (!a.value( "color").isEmpty() ) - { - col.setNamedColor(a.value("color")); - xlo->setColor (col); - } - - if (!a.value( "width").isEmpty() ) - { - xlo->setWidth(a.value ("width").toInt (&okx, 10)); - } - - // Connecting by select string for compatibility with version < 1.8.76 - if (!a.value( "beginBranch").isEmpty() ) - { - if (!a.value( "endBranch").isEmpty() ) - { - TreeItem *ti=model->findBySelectString (a.value( "beginBranch")); - if (ti && ti->isBranchLikeType()) - { - /* FIXME-2 xLinks - xlo->setBegin ((BranchObj*)lmo); - lmo=model->findBySelectString (a.value( "endBranch")); - if (lmo && typid (*lmo)==typid (BranchObj)) - { - xlo->setEnd ((BranchObj*)(lmo)); - xlo->activate(); - success=true; - } - */ - } - } - } - // object ID is used starting in version 1.8.76 - /* FIXME-2 xLinks + // (before there was beginBranch and endBranch) if (!a.value( "beginID").isEmpty() ) { if (!a.value( "endID").isEmpty() ) { - LinkableMapObj *lmo=model->findID (a.value( "beginID")); - if (lmo && typid (*lmo)==typid (BranchObj)) + TreeItem *beginBI=model->findID (a.value( "beginID")); + TreeItem *endBI=model->findID (a.value( "endID")); + if (beginBI && endBI && beginBI->isBranchLikeType() && endBI->isBranchLikeType() ) { - xlo->setBegin ((BranchObj*)lmo); - lmo=model->findID (a.value( "endID")); - if (lmo && typid (*lmo)==typid (BranchObj)) + XLinkItem *xli=model->createXLink (lastBranch,true); + xli->setBegin ( (BranchItem*)beginBI ); + xli->setEnd ( (BranchItem*)endBI); + xli->activate(); + + if (!a.value( "color").isEmpty() ) { - xlo->setEnd ((BranchObj*)(lmo)); - xlo->activate(); - success=true; + QColor col; + col.setNamedColor(a.value("color")); + xli->setColor (col); } + + if (!a.value( "width").isEmpty() ) + { + bool okx; + xli->setWidth(a.value ("width").toInt (&okx, 10)); + } + xli->updateXLink(); } } } - */ - if (!success) delete (xlo); return true; // xLinks can only be established at the "end branch", return true }