xml-vym.cpp
changeset 790 133e2ed6b9c5
parent 788 78ba80b54bc4
child 792 7d67be709091
     1.1 --- a/xml-vym.cpp	Mon Aug 24 14:39:07 2009 +0000
     1.2 +++ b/xml-vym.cpp	Thu Sep 03 08:52:00 2009 +0000
     1.3 @@ -12,6 +12,7 @@
     1.4  #include "linkablemapobj.h"
     1.5  #include "mainwindow.h"
     1.6  #include "version.h"
     1.7 +#include "xlinkitem.h"
     1.8  
     1.9  static ImageItem *lastImageItem;
    1.10  static MapItem *lastMI;
    1.11 @@ -450,8 +451,8 @@
    1.12  					return false;   // Couldn't read absPos
    1.13  			}           
    1.14  		}           
    1.15 -		//if (!a.value( "id").isEmpty() ) 
    1.16 -		//	lastMI->setID (a.value ("id"));		// FIXME-3
    1.17 +		if (!a.value( "id").isEmpty() ) 
    1.18 +			lastMI->setID (a.value ("id"));		
    1.19  			
    1.20  		if (!a.value( "url").isEmpty() ) 
    1.21  			lastMI->setURL (a.value ("url"));
    1.22 @@ -550,67 +551,39 @@
    1.23  	return true;
    1.24  }
    1.25  
    1.26 -bool parseVYMHandler::readXLinkAttr (const QXmlAttributes& a)
    1.27 +bool parseVYMHandler::readXLinkAttr (const QXmlAttributes& a)	
    1.28  {
    1.29 -	QColor col;
    1.30 -	bool okx;
    1.31 -	bool success=false;
    1.32 -	XLinkObj *xlo=new XLinkObj (model->getScene());
    1.33 -	if (!a.value( "color").isEmpty() ) 
    1.34 -	{
    1.35 -		col.setNamedColor(a.value("color"));
    1.36 -		xlo->setColor (col);
    1.37 -	}
    1.38 -
    1.39 -	if (!a.value( "width").isEmpty() ) 
    1.40 -	{
    1.41 -		xlo->setWidth(a.value ("width").toInt (&okx, 10));
    1.42 -	}
    1.43 -
    1.44 -	// Connecting by select string for compatibility with version < 1.8.76
    1.45 -	if (!a.value( "beginBranch").isEmpty() ) 
    1.46 -	{ 
    1.47 -		if (!a.value( "endBranch").isEmpty() ) 
    1.48 -		{
    1.49 -			TreeItem *ti=model->findBySelectString (a.value( "beginBranch"));
    1.50 -			if (ti && ti->isBranchLikeType())
    1.51 -			{
    1.52 -			/* FIXME-2 xLinks
    1.53 -				xlo->setBegin ((BranchObj*)lmo);
    1.54 -				lmo=model->findBySelectString (a.value( "endBranch"));
    1.55 -				if (lmo && typid (*lmo)==typid (BranchObj))
    1.56 -				{
    1.57 -					xlo->setEnd ((BranchObj*)(lmo));
    1.58 -					xlo->activate();
    1.59 -					success=true;
    1.60 -				}
    1.61 -			*/
    1.62 -			}
    1.63 -		}           
    1.64 -	}	
    1.65 -
    1.66  	// object ID is used starting in version 1.8.76
    1.67 -	/* FIXME-2 xLinks
    1.68 +	// (before there was beginBranch and endBranch)
    1.69  	if (!a.value( "beginID").isEmpty() ) 
    1.70  	{ 
    1.71  		if (!a.value( "endID").isEmpty() ) 
    1.72  		{
    1.73 -			LinkableMapObj *lmo=model->findID (a.value( "beginID"));
    1.74 -			if (lmo && typid (*lmo)==typid (BranchObj))
    1.75 +			TreeItem *beginBI=model->findID (a.value( "beginID"));
    1.76 +			TreeItem   *endBI=model->findID (a.value( "endID"));
    1.77 +			if (beginBI && endBI && beginBI->isBranchLikeType() && endBI->isBranchLikeType() )
    1.78  			{
    1.79 -				xlo->setBegin ((BranchObj*)lmo);
    1.80 -				lmo=model->findID (a.value( "endID"));
    1.81 -				if (lmo && typid (*lmo)==typid (BranchObj))
    1.82 +				XLinkItem *xli=model->createXLink (lastBranch,true);
    1.83 +				xli->setBegin ( (BranchItem*)beginBI );
    1.84 +				xli->setEnd ( (BranchItem*)endBI);
    1.85 +				xli->activate();
    1.86 +
    1.87 +				if (!a.value( "color").isEmpty() ) 
    1.88  				{
    1.89 -					xlo->setEnd ((BranchObj*)(lmo));
    1.90 -					xlo->activate();
    1.91 -					success=true;
    1.92 +					QColor col;
    1.93 +					col.setNamedColor(a.value("color"));
    1.94 +					xli->setColor (col);
    1.95  				}
    1.96 +
    1.97 +				if (!a.value( "width").isEmpty() ) 
    1.98 +				{
    1.99 +					bool okx;
   1.100 +					xli->setWidth(a.value ("width").toInt (&okx, 10));
   1.101 +				}
   1.102 +				xli->updateXLink();
   1.103  			}
   1.104  		}           
   1.105  	}	
   1.106 -	*/
   1.107 -	if (!success) delete (xlo);
   1.108  	return true;	// xLinks can only be established at the "end branch", return true
   1.109  }
   1.110