xml.cpp
changeset 95 f688a9913724
parent 83 e90f5bef70c8
child 97 0b048b6bb6f4
     1.1 --- a/xml.cpp	Sat Apr 09 22:50:08 2005 +0000
     1.2 +++ b/xml.cpp	Mon Apr 18 06:17:00 2005 +0000
     1.3 @@ -7,6 +7,7 @@
     1.4  
     1.5  #include "misc.h"
     1.6  #include "settings.h"
     1.7 +#include "linkablemapobj.h"
     1.8  
     1.9  #include "version.h"
    1.10  
    1.11 @@ -228,6 +229,10 @@
    1.12          lastBranch->addFloatImage();
    1.13  		lastFloat=lastBranch->getLastFloatImage();
    1.14  		if (!readFloatImageAttr(atts)) return false;
    1.15 +    } else if ( eName == "xlink" && state == StateBranch ) 
    1.16 +	{
    1.17 +		state=StateBranchXLink;
    1.18 +		if (!readXLinkAttr (atts)) return false;
    1.19      } else if ( eName == "branch" && state == StateBranch ) 
    1.20  	{
    1.21          lastBranch->addBranch();
    1.22 @@ -282,6 +287,7 @@
    1.23          case StateBranchHeading: state=StateBranch;  return true;
    1.24          case StateBranchNote: state=StateBranch; return true;
    1.25          case StateBranchFloatImage: state=StateBranch;  return true;
    1.26 +        case StateBranchXLink: state=StateBranch;  return true;
    1.27          case StateHtmlNote: state=laststate; return true;
    1.28          case StateHtml: 
    1.29  			htmldata+="</"+eName+">";
    1.30 @@ -504,6 +510,38 @@
    1.31  	return true;
    1.32  }
    1.33  
    1.34 +bool mapBuilderHandler::readXLinkAttr (const QXmlAttributes& a)
    1.35 +{
    1.36 +	QColor col;
    1.37 +	XLinkObj *xlo=new XLinkObj (mc->getCanvas());
    1.38 +	if (!a.value( "xLinkColor").isEmpty() ) 
    1.39 +	{
    1.40 +		col.setNamedColor(a.value("xLinkColor"));
    1.41 +		xlo->setColor (col);
    1.42 +	}
    1.43 +
    1.44 +	if (!a.value( "beginBranch").isEmpty() ) 
    1.45 +	{
    1.46 +		if (!a.value( "endBranch").isEmpty() ) 
    1.47 +		{
    1.48 +			LinkableMapObj *lmo=mc->findObj (a.value( "beginBranch"));
    1.49 +			if (lmo && typeid (*lmo)==typeid (BranchObj))
    1.50 +			{
    1.51 +				xlo->setBegin ((BranchObj*)(lmo));
    1.52 +				lmo=mc->findObj (a.value( "endBranch"));
    1.53 +				if (lmo && typeid (*lmo)==typeid (BranchObj))
    1.54 +				{
    1.55 +					xlo->setEnd ((BranchObj*)(lmo));
    1.56 +					xlo->activate();
    1.57 +					return true;
    1.58 +				}
    1.59 +			}
    1.60 +			return true;	// Not all branches there yet, no error
    1.61 +		}           
    1.62 +	}	
    1.63 +	return false; 
    1.64 +}
    1.65 +
    1.66  bool mapBuilderHandler::readHtmlAttr (const QXmlAttributes& a)
    1.67  {
    1.68  	for (int i=1; i<=a.count(); i++)