Empty branches are always unscrolled after import, relinking to scrolled branch doesn't open branch release-1-12-maintained
authorinsilmaril
Wed Jul 22 11:47:03 2009 +0000 (2009-07-22)
branchrelease-1-12-maintained
changeset 70e3a85616dbc5
parent 69 053479bc23c6
child 71 0da9dd0b3911
Empty branches are always unscrolled after import, relinking to scrolled branch doesn't open branch
aboutdialog.cpp
branchobj.cpp
mapeditor.cpp
version.h
xml-vym.cpp
     1.1 --- a/aboutdialog.cpp	Wed May 06 11:06:17 2009 +0000
     1.2 +++ b/aboutdialog.cpp	Wed Jul 22 11:47:03 2009 +0000
     1.3 @@ -92,7 +92,7 @@
     1.4      license->setText (
     1.5  	"<center>"
     1.6  	"<h3>VYM - View Your Mind</h3>"
     1.7 -    "<p>Copyright (C) 2004-2007  Uwe Drechsel</p>"  
     1.8 +    "<p>Copyright (C) 2004-2009  Uwe Drechsel</p>"  
     1.9  	"</center>"
    1.10  
    1.11      "<p>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.</p>"
     2.1 --- a/branchobj.cpp	Wed May 06 11:06:17 2009 +0000
     2.2 +++ b/branchobj.cpp	Wed Jul 22 11:47:03 2009 +0000
     2.3 @@ -138,6 +138,8 @@
     2.4  
     2.5  	while (!branch.isEmpty())
     2.6  		delete branch.takeFirst();
     2.7 +
     2.8 +	if (scrolled) unScroll();	
     2.9  }
    2.10  
    2.11  bool isAbove (BranchObj* a, BranchObj *b)
    2.12 @@ -1305,7 +1307,6 @@
    2.13  			bo->setDefAttr(MovedBranch);
    2.14  			updateLink();
    2.15  			return bo;
    2.16 -
    2.17  		} else
    2.18  			return NULL;
    2.19  	}	
     3.1 --- a/mapeditor.cpp	Wed May 06 11:06:17 2009 +0000
     3.2 +++ b/mapeditor.cpp	Wed Jul 22 11:47:03 2009 +0000
     3.3 @@ -4973,6 +4973,10 @@
     3.4  			copyingObj=false;	
     3.5  			if (dst ) 
     3.6  			{
     3.7 +				// Don't unscroll if relinked to a scrolled parent, but
     3.8 +				// select parent instead
     3.9 +				bool selectParent=false;
    3.10 +
    3.11  				// We have a destination, relink to that
    3.12  
    3.13  				BranchObj* bsel=xelection.getBranch();
    3.14 @@ -4994,6 +4998,7 @@
    3.15  					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()+1);
    3.16  				} else	
    3.17  				{	// Append to dst
    3.18 +					if (bdst->isScrolled()) selectParent=true;
    3.19  					preDstParStr=model->getSelectString(dst);
    3.20  					bsel->linkTo (bdst,-1);
    3.21  					if (dst->getDepth()==0) bsel->move (savePos);
    3.22 @@ -5014,6 +5019,8 @@
    3.23  					preSelStr, redoCom,
    3.24  					QString("Relink %1 to %2").arg(getName(bsel)).arg(getName(dst)) );
    3.25  
    3.26 +				if (selectParent) select (bdst);
    3.27 +
    3.28  				model->reposition();	// not necessary if we undo temporary move  below
    3.29  			} else
    3.30  			{
     4.1 --- a/version.h	Wed May 06 11:06:17 2009 +0000
     4.2 +++ b/version.h	Wed Jul 22 11:47:03 2009 +0000
     4.3 @@ -4,10 +4,10 @@
     4.4  #include <QString>
     4.5  
     4.6  #define __VYM_NAME "VYM"
     4.7 -#define __VYM_VERSION "1.12.2h"
     4.8 +#define __VYM_VERSION "1.12.2i"
     4.9  #define __VYM_CODENAME "Maintenance Update "
    4.10  //#define __VYM_CODENAME "Codename: development version"
    4.11 -#define __VYM_BUILD_DATE "2009-05-06"
    4.12 +#define __VYM_BUILD_DATE "2009-07-22"
    4.13  
    4.14  
    4.15  bool checkVersion(const QString &);
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/xml-vym.cpp	Wed Jul 22 11:47:03 2009 +0000
     5.3 @@ -0,0 +1,641 @@
     5.4 +#include "xml-vym.h"
     5.5 +
     5.6 +#include <QMessageBox>
     5.7 +#include <QColor>
     5.8 +#include <QTextStream>
     5.9 +#include <iostream>
    5.10 +#include <typeinfo>
    5.11 +
    5.12 +#include "misc.h"
    5.13 +#include "settings.h"
    5.14 +#include "linkablemapobj.h"
    5.15 +#include "version.h"
    5.16 +
    5.17 +static BranchObj *lastBranch;
    5.18 +static FloatObj *lastFloat;
    5.19 +static OrnamentedObj *lastOO;
    5.20 +
    5.21 +extern Settings settings;
    5.22 +extern QString vymVersion;
    5.23 +
    5.24 +/*
    5.25 +parseVYMHandler::parseVYMHandler() {}
    5.26 +
    5.27 +parseVYMHandler::~parseVYMHandler() {}
    5.28 +
    5.29 +QString parseVYMHandler::errorProtocol() { return errorProt; }
    5.30 +
    5.31 +*/
    5.32 +
    5.33 +bool parseVYMHandler::startDocument()
    5.34 +{
    5.35 +    errorProt = "";
    5.36 +    state = StateInit;
    5.37 +    laststate = StateInit;
    5.38 +	stateStack.clear();
    5.39 +	stateStack.append(StateInit);
    5.40 +	htmldata="";
    5.41 +	isVymPart=false;
    5.42 +    return true;
    5.43 +}
    5.44 +
    5.45 +
    5.46 +/*
    5.47 +QString parseVYMHandler::parseHREF(QString href)
    5.48 +{
    5.49 +	QString type=href.section(":",0,0);
    5.50 +	QString path=href.section(":",1,1);
    5.51 +	if (!tmpDir.endsWith("/"))
    5.52 +		return tmpDir + "/" + path;
    5.53 +	else	
    5.54 +		return tmpDir + path;
    5.55 +}
    5.56 +*/
    5.57 +bool parseVYMHandler::startElement  ( const QString&, const QString&,
    5.58 +                    const QString& eName, const QXmlAttributes& atts ) 
    5.59 +{
    5.60 +    QColor col;
    5.61 +	/* Testing
    5.62 +	cout << "startElement <"<< qPrintable(eName)
    5.63 +		<<">  state="<<state 
    5.64 +		<<"  laststate="<<stateStack.last()
    5.65 +		<<"   loadMode="<<loadMode
    5.66 +		<<"       line="<<QXmlDefaultHandler::lineNumber()
    5.67 +		<<endl;
    5.68 +	*/	
    5.69 +	stateStack.append (state);	
    5.70 +    if ( state == StateInit && (eName == "vymmap")  ) 
    5.71 +	{
    5.72 +        state = StateMap;
    5.73 +
    5.74 +		if (loadMode==NewMap)
    5.75 +			model->clear();	// remove existing mapCenter
    5.76 +
    5.77 +		// Check version
    5.78 +		if (!atts.value( "version").isEmpty() ) 
    5.79 +		{
    5.80 +			if (!checkVersion(atts.value("version")))
    5.81 +				QMessageBox::warning( 0, "Warning: Version Problem" ,
    5.82 +				   "<h3>Map is newer than VYM</h3>"
    5.83 +				   "<p>The map you are just trying to load was "
    5.84 +				   "saved using vym " +atts.value("version")+". "
    5.85 +				   "The version of this vym is " + vymVersion + 
    5.86 +				   ". If you run into problems after pressing "
    5.87 +				   "the ok-button below, updating vym should help.");
    5.88 +			else	   
    5.89 +				model->setVersion(atts.value( "version" ));
    5.90 +
    5.91 +		}
    5.92 +
    5.93 +		if (loadMode==NewMap )
    5.94 +		{
    5.95 +			// Create mapCenter
    5.96 +			model->clear();
    5.97 +			lastBranch=model->first();	// avoid empty pointer
    5.98 +
    5.99 +			if (!atts.value( "author").isEmpty() )
   5.100 +				model->setAuthor(atts.value( "author" ) );
   5.101 +			if (!atts.value( "comment").isEmpty() )
   5.102 +				model->setComment (atts.value( "comment" ) );
   5.103 +			if (!atts.value( "backgroundColor").isEmpty() )
   5.104 +			{
   5.105 +				col.setNamedColor(atts.value("backgroundColor"));
   5.106 +				model->getScene()->setBackgroundBrush(col);
   5.107 +			}	    
   5.108 +			if (!atts.value( "selectionColor").isEmpty() )
   5.109 +			{
   5.110 +				col.setNamedColor(atts.value("selectionColor"));
   5.111 +				model->getMapEditor()->setSelectionColor(col);
   5.112 +			}	    
   5.113 +			if (!atts.value( "linkColorHint").isEmpty() ) 
   5.114 +			{
   5.115 +				if (atts.value("linkColorHint")=="HeadingColor")
   5.116 +					model->getMapEditor()->setMapLinkColorHint(LinkableMapObj::HeadingColor);
   5.117 +				else
   5.118 +					model->getMapEditor()->setMapLinkColorHint(LinkableMapObj::DefaultColor);
   5.119 +			}
   5.120 +			if (!atts.value( "linkStyle").isEmpty() ) 
   5.121 +				model->getMapEditor()->setMapLinkStyle(atts.value("linkStyle"));
   5.122 +			if (!atts.value( "linkColor").isEmpty() ) 
   5.123 +			{
   5.124 +				col.setNamedColor(atts.value("linkColor"));
   5.125 +				model->getMapEditor()->setMapDefLinkColor(col);
   5.126 +			}	
   5.127 +			if (!atts.value( "defXLinkColor").isEmpty() ) 
   5.128 +			{
   5.129 +				col.setNamedColor(atts.value("defXLinkColor"));
   5.130 +				model->getMapEditor()->setMapDefXLinkColor(col);
   5.131 +			}	
   5.132 +			if (!atts.value( "defXLinkWidth").isEmpty() ) 
   5.133 +				model->getMapEditor()->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
   5.134 +		}	
   5.135 +	} else if ( eName == "select" && state == StateMap ) 
   5.136 +	{
   5.137 +		state=StateMapSelect;
   5.138 +	} else if ( eName == "setting" && state == StateMap ) 
   5.139 +	{
   5.140 +		state=StateMapSetting;
   5.141 +		if (loadMode==NewMap)
   5.142 +			readSettingAttr (atts);
   5.143 +	} else if ( eName == "mapcenter" && state == StateMap ) 
   5.144 +	{
   5.145 +		state=StateMapCenter;
   5.146 +		if (loadMode==NewMap)
   5.147 +		{	
   5.148 +			// Really use the found mapcenter as MCO in a new map
   5.149 +
   5.150 +			lastBranch=model->addMapCenter(); 
   5.151 +		} else
   5.152 +		{
   5.153 +			// Treat the found mapcenter as a branch 
   5.154 +			// in an existing map
   5.155 +			LinkableMapObj* lmo=model->getSelection();
   5.156 +			if (lmo && ((typeid(*lmo) == typeid(BranchObj) ) 
   5.157 +			        ||  typeid(*lmo) == typeid(MapCenterObj) ) )
   5.158 +			{
   5.159 +				lastBranch=(BranchObj*)lmo;
   5.160 +				if (loadMode==ImportAdd)
   5.161 +				{
   5.162 +					lastBranch->addBranch();
   5.163 +					lastBranch=lastBranch->getLastBranch();
   5.164 +				} else
   5.165 +					lastBranch->clear();
   5.166 +			} else
   5.167 +				return false;
   5.168 +		}
   5.169 +		readBranchAttr (atts);
   5.170 +	} else if ( 
   5.171 +		(eName == "standardflag" ||eName == "standardFlag") && 
   5.172 +		(state == StateMapCenter || state==StateBranch)) 
   5.173 +	{
   5.174 +		state=StateStandardFlag;
   5.175 +	} else if ( eName == "heading" && (state == StateMapCenter||state==StateBranch)) 
   5.176 +	{
   5.177 +		laststate=state;
   5.178 +		state=StateHeading;
   5.179 +		if (!atts.value( "textColor").isEmpty() ) 
   5.180 +		{
   5.181 +			col.setNamedColor(atts.value("textColor"));
   5.182 +			lastBranch->setColor(col );
   5.183 +		}	    
   5.184 +	} else if ( eName == "note" && 
   5.185 +				(state == StateMapCenter ||state==StateBranch))
   5.186 +	{	// only for backward compatibility (<1.4.6). Use htmlnote now.
   5.187 +		state=StateNote;
   5.188 +		if (!readNoteAttr (atts) ) return false;
   5.189 +	} else if ( eName == "htmlnote" && state == StateMapCenter) 
   5.190 +	{
   5.191 +		laststate=state;
   5.192 +		state=StateHtmlNote;
   5.193 +    } else if ( eName == "floatimage" && 
   5.194 +				(state == StateMapCenter ||state==StateBranch)) 
   5.195 +	{
   5.196 +		state=StateFloatImage;
   5.197 +        lastBranch->addFloatImage();
   5.198 +		lastFloat=lastBranch->getLastFloatImage();
   5.199 +		if (!readFloatImageAttr(atts)) return false;
   5.200 +	} else if ( (eName == "branch"||eName=="floatimage") && state == StateMap) 
   5.201 +	{
   5.202 +		// This is used in vymparts, which have no mapcenter!
   5.203 +		isVymPart=true;
   5.204 +		LinkableMapObj* lmo=model->getSelection();
   5.205 +		if (!lmo)
   5.206 +		{
   5.207 +			// If a vym part is _loaded_ (not imported), 
   5.208 +			// selection==lmo==NULL
   5.209 +			// Treat it like ImportAdd then...
   5.210 +			loadMode=ImportAdd;
   5.211 +			lmo=model->first();		// FIXME this used to be lmo=mc before
   5.212 +		}	
   5.213 +		if (lmo && ((typeid(*lmo) == typeid(BranchObj) ) 
   5.214 +				||  typeid(*lmo) == typeid(MapCenterObj) ) )
   5.215 +		{
   5.216 +			lastBranch=(BranchObj*)(lmo);
   5.217 +			if (eName=="branch")
   5.218 +			{
   5.219 +				state=StateBranch;
   5.220 +				if (loadMode==ImportAdd)
   5.221 +				{
   5.222 +					lastBranch->addBranch();
   5.223 +					lastBranch=lastBranch->getLastBranch();
   5.224 +					
   5.225 +				} else
   5.226 +					lastBranch->clear();
   5.227 +				readBranchAttr (atts);
   5.228 +			} else if (eName=="floatimage")
   5.229 +			{
   5.230 +				state=StateFloatImage;
   5.231 +				lastBranch->addFloatImage();
   5.232 +				lastFloat=lastBranch->getLastFloatImage();
   5.233 +				if (!readFloatImageAttr(atts)) return false;
   5.234 +			} else return false;
   5.235 +		} else return false;
   5.236 +	} else if ( eName == "branch" && state == StateMapCenter) 
   5.237 +	{
   5.238 +		state=StateBranch;
   5.239 +		lastBranch->addBranch();
   5.240 +		lastBranch=lastBranch->getLastBranch();
   5.241 +		readBranchAttr (atts);
   5.242 +	} else if ( eName == "htmlnote" && state == StateBranch) 
   5.243 +	{
   5.244 +		laststate=state;
   5.245 +		state=StateHtmlNote;
   5.246 +		no.clear();
   5.247 +		if (!atts.value( "fonthint").isEmpty() ) 
   5.248 +			no.setFontHint(atts.value ("fonthint") );
   5.249 +	} else if ( eName == "frame" && (state == StateBranch||state==StateMapCenter)) 
   5.250 +	{
   5.251 +		laststate=state;
   5.252 +		state=StateFrame;
   5.253 +		if (!readFrameAttr(atts)) return false;
   5.254 +    } else if ( eName == "xlink" && state == StateBranch ) 
   5.255 +	{
   5.256 +		state=StateBranchXLink;
   5.257 +		if (!readXLinkAttr (atts)) return false;
   5.258 +    } else if ( eName == "branch" && state == StateBranch ) 
   5.259 +	{
   5.260 +        lastBranch->addBranch();
   5.261 +		lastBranch=lastBranch->getLastBranch();		
   5.262 +		readBranchAttr (atts);
   5.263 +    } else if ( eName == "html" && state == StateHtmlNote ) 
   5.264 +	{
   5.265 +		state=StateHtml;
   5.266 +		htmldata="<"+eName;
   5.267 +		readHtmlAttr(atts);
   5.268 +		htmldata+=">";
   5.269 +    } else if ( state == StateHtml ) 
   5.270 +	{
   5.271 +		// accept all while in html mode,
   5.272 +		htmldata+="<"+eName;
   5.273 +		readHtmlAttr(atts);
   5.274 +		htmldata+=">";
   5.275 +    } else
   5.276 +        return false;   // Error
   5.277 +    return true;
   5.278 +}
   5.279 +
   5.280 +bool parseVYMHandler::endElement  ( const QString&, const QString&, const QString &eName)
   5.281 +{
   5.282 +	/* Testing
   5.283 +	cout << "endElement </" <<qPrintable(eName)
   5.284 +		<<">  state=" <<state 
   5.285 +		<<"  laststate=" <<laststate
   5.286 +		<<"  stateStack="<<stateStack.last() 
   5.287 +		<<endl;
   5.288 +	*/
   5.289 +    switch ( state ) 
   5.290 +	{
   5.291 +        case StateBranch: 
   5.292 +			// Empty branches may not be scrolled 
   5.293 +			// (happens if bookmarks are imported)
   5.294 +			if (lastBranch->isScrolled() && lastBranch->countBranches()==0) 
   5.295 +				lastBranch->unScroll();
   5.296 +			lastBranch=(BranchObj*)(lastBranch->getParObj());
   5.297 +            break;
   5.298 +        case StateHtml: 
   5.299 +			htmldata+="</"+eName+">";
   5.300 +			if (eName=="html")
   5.301 +			{
   5.302 +				state=StateHtmlNote;  
   5.303 +				htmldata.replace ("<br></br>","<br />");
   5.304 +				no.setNote (htmldata);
   5.305 +				lastBranch->setNote (no);
   5.306 +			}	
   5.307 +			break;
   5.308 +		default: 
   5.309 +			break;
   5.310 +    }  
   5.311 +	state=stateStack.takeLast();	
   5.312 +	return true;
   5.313 +}
   5.314 +
   5.315 +bool parseVYMHandler::characters   ( const QString& ch)
   5.316 +{
   5.317 +	//cout << "characters \""<<ch<<"\"  state="<<state <<"  laststate="<<laststate<<endl;
   5.318 +
   5.319 +	QString ch_org=quotemeta (ch);
   5.320 +    QString ch_simplified=ch.simplifyWhiteSpace();
   5.321 +    if ( ch_simplified.isEmpty() ) return true;
   5.322 +
   5.323 +    switch ( state ) 
   5.324 +    {
   5.325 +        case StateInit: break;
   5.326 +        case StateMap: break; 
   5.327 +		case StateMapSelect:
   5.328 +			model->select(ch_simplified);
   5.329 +			break;
   5.330 +		case StateMapSetting:break;
   5.331 +        case StateMapCenter: break;
   5.332 +        case StateNote:
   5.333 +			lastBranch->setNote(ch_simplified);
   5.334 +			break;
   5.335 +        case StateBranch: break;
   5.336 +        case StateStandardFlag: 
   5.337 +            lastBranch->activateStandardFlag(ch_simplified); 
   5.338 +            break;
   5.339 +        case StateFloatImage: break;
   5.340 +        case StateHtmlNote: break;
   5.341 +        case StateHtml:
   5.342 +			htmldata+=ch_org;
   5.343 +			break;
   5.344 +        case StateHeading: 
   5.345 +            lastBranch->setHeading(ch_simplified);
   5.346 +            break;
   5.347 +        default: 
   5.348 +			return false;
   5.349 +    }
   5.350 +    return true;
   5.351 +}
   5.352 +
   5.353 +QString parseVYMHandler::errorString() 
   5.354 +{
   5.355 +    return "the document is not in the VYM file format";
   5.356 +}
   5.357 +
   5.358 +bool parseVYMHandler::readBranchAttr (const QXmlAttributes& a)
   5.359 +{
   5.360 +	lastOO=lastBranch;
   5.361 +	if (!readOOAttr(a)) return false;
   5.362 +
   5.363 +	if (!a.value( "scrolled").isEmpty() )
   5.364 +		lastBranch->toggleScroll();
   5.365 +	if (!a.value( "frameType").isEmpty() ) 
   5.366 +		lastOO->setFrameType (a.value("frameType")); //Compatibility 1.8.1
   5.367 +
   5.368 +	if (!a.value( "incImgV").isEmpty() ) 
   5.369 +	{	
   5.370 +		if (a.value("incImgV")=="true")
   5.371 +			lastBranch->setIncludeImagesVer(true);
   5.372 +		else	
   5.373 +			lastBranch->setIncludeImagesVer(false);
   5.374 +	}	
   5.375 +	if (!a.value( "incImgH").isEmpty() ) 
   5.376 +	{	
   5.377 +		if (a.value("incImgH")=="true")
   5.378 +			lastBranch->setIncludeImagesHor(true);
   5.379 +		else	
   5.380 +			lastBranch->setIncludeImagesHor(false);
   5.381 +	}	
   5.382 +	return true;	
   5.383 +}
   5.384 +
   5.385 +bool parseVYMHandler::readFrameAttr (const QXmlAttributes& a)
   5.386 +{
   5.387 +	bool ok;
   5.388 +	int x;
   5.389 +	if (lastOO)
   5.390 +	{
   5.391 +		if (!a.value( "frameType").isEmpty() ) 
   5.392 +			lastOO->setFrameType (a.value("frameType"));
   5.393 +		if (!a.value( "penColor").isEmpty() ) 
   5.394 +			lastOO->setFramePenColor (a.value("penColor"));
   5.395 +		if (!a.value( "brushColor").isEmpty() ) 
   5.396 +			lastOO->setFrameBrushColor (a.value("brushColor"));
   5.397 +		if (!a.value( "padding").isEmpty() ) 
   5.398 +		{
   5.399 +			x=a.value("padding").toInt(&ok);
   5.400 +			if (ok) lastOO->setFramePadding(x);
   5.401 +		}	
   5.402 +		if (!a.value( "borderWidth").isEmpty() ) 
   5.403 +		{
   5.404 +			x=a.value("borderWidth").toInt(&ok);
   5.405 +			if (ok) lastOO->setFrameBorderWidth(x);
   5.406 +		}	
   5.407 +	}		
   5.408 +	return true;
   5.409 +}
   5.410 +
   5.411 +bool parseVYMHandler::readOOAttr (const QXmlAttributes& a)
   5.412 +{
   5.413 +	if (lastOO)
   5.414 +	{
   5.415 +		bool okx,oky;
   5.416 +		float x,y;
   5.417 +		if (!a.value( "relPosX").isEmpty() ) 
   5.418 +		{
   5.419 +			if (!a.value( "relPosY").isEmpty() ) 
   5.420 +			{
   5.421 +				x=a.value("relPosX").toFloat (&okx);
   5.422 +				y=a.value("relPosY").toFloat (&oky);
   5.423 +				if (okx && oky  )
   5.424 +				{
   5.425 +					lastOO->setUseRelPos (true);
   5.426 +					lastOO->move2RelPos (x,y);
   5.427 +				}	
   5.428 +				else
   5.429 +					return false;   // Couldn't read relPos
   5.430 +			}           
   5.431 +		}           
   5.432 +		if (!a.value( "absPosX").isEmpty() && loadMode==NewMap ) 
   5.433 +		{
   5.434 +			if (!a.value( "absPosY").isEmpty() ) 
   5.435 +			{
   5.436 +				x=a.value("absPosX").toFloat (&okx);
   5.437 +				y=a.value("absPosY").toFloat (&oky);
   5.438 +				if (okx && oky  )
   5.439 +					lastOO->move(x,y);
   5.440 +				else
   5.441 +					return false;   // Couldn't read absPos
   5.442 +			}           
   5.443 +		}           
   5.444 +		if (!a.value( "id").isEmpty() ) 
   5.445 +			lastOO->setID (a.value ("id"));
   5.446 +		if (!a.value( "url").isEmpty() ) 
   5.447 +			lastOO->setURL (a.value ("url"));
   5.448 +		if (!a.value( "vymLink").isEmpty() ) 
   5.449 +			lastOO->setVymLink (a.value ("vymLink"));
   5.450 +		if (!a.value( "hideInExport").isEmpty() ) 
   5.451 +			if (a.value("hideInExport")=="true")
   5.452 +				lastOO->setHideInExport(true);
   5.453 +
   5.454 +		if (!a.value( "hideLink").isEmpty()) 
   5.455 +		{
   5.456 +			if (a.value ("hideLink") =="true")
   5.457 +				lastOO->setHideLinkUnselected(true);
   5.458 +			else	
   5.459 +				lastOO->setHideLinkUnselected(false);
   5.460 +		}	
   5.461 +	}
   5.462 +	return true;	
   5.463 +}
   5.464 +
   5.465 +bool parseVYMHandler::readNoteAttr (const QXmlAttributes& a)
   5.466 +{	// only for backward compatibility (<1.4.6). Use htmlnote now.
   5.467 +	no.clear();
   5.468 +	QString fn;
   5.469 +	if (!a.value( "href").isEmpty() ) 
   5.470 +	{
   5.471 +		// Load note
   5.472 +		fn=parseHREF(a.value ("href") );
   5.473 +		QFile file (fn);
   5.474 +		QString s;						// Reading a note
   5.475 +
   5.476 +		if ( !file.open( QIODevice::ReadOnly) )
   5.477 +		{
   5.478 +			qWarning ("parseVYMHandler::readNoteAttr:  Couldn't load "+fn);
   5.479 +			return false;
   5.480 +		}	
   5.481 +		QTextStream stream( &file );
   5.482 +		QString lines;
   5.483 +		while ( !stream.atEnd() ) {
   5.484 +			lines += stream.readLine()+"\n"; 
   5.485 +		}
   5.486 +		file.close();
   5.487 +
   5.488 +		lines ="<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body>"+lines + "</p></body></html>";
   5.489 +		no.setNote (lines);
   5.490 +	}		
   5.491 +	if (!a.value( "fonthint").isEmpty() ) 
   5.492 +		no.setFontHint(a.value ("fonthint") );
   5.493 +	lastBranch->setNote(no);
   5.494 +	return true;
   5.495 +}
   5.496 +
   5.497 +bool parseVYMHandler::readFloatImageAttr (const QXmlAttributes& a)
   5.498 +{
   5.499 +	lastOO=lastFloat;
   5.500 +	
   5.501 +	//if (!readOOAttr(a)) return false;
   5.502 +
   5.503 +	if (!a.value( "useOrientation").isEmpty() ) 
   5.504 +	{
   5.505 +		if (a.value ("useOrientation") =="true")
   5.506 +			lastFloat->setUseOrientation (true);
   5.507 +		else	
   5.508 +			lastFloat->setUseOrientation (false);
   5.509 +	}	
   5.510 +	if (!a.value( "href").isEmpty() )
   5.511 +	{
   5.512 +		// Load FloatImage
   5.513 +		if (!lastFloat->load (parseHREF(a.value ("href") ) ))
   5.514 +		{
   5.515 +			QMessageBox::warning( 0, "Warning: " ,
   5.516 +				"Couldn't load float image\n"+parseHREF(a.value ("href") ));
   5.517 +			lastBranch->removeFloatImage(((FloatImageObj*)(lastFloat)));
   5.518 +			lastFloat=NULL;
   5.519 +			return true;
   5.520 +		}
   5.521 +		
   5.522 +	}	
   5.523 +	if (!a.value( "floatExport").isEmpty() ) 
   5.524 +	{
   5.525 +		// Only for compatibility. THis is not used since 1.7.11 
   5.526 +		if (a.value ("floatExport") =="true")
   5.527 +			lastFloat->setFloatExport(true);
   5.528 +		else	
   5.529 +			lastFloat->setFloatExport (false);
   5.530 +	}	
   5.531 +	if (!a.value( "zPlane").isEmpty() ) 
   5.532 +		lastFloat->setZValue (a.value("zPlane").toInt ());
   5.533 +    float x,y;
   5.534 +    bool okx,oky;
   5.535 +	if (!a.value( "relPosX").isEmpty() ) 
   5.536 +	{
   5.537 +		if (!a.value( "relPosY").isEmpty() ) 
   5.538 +		{
   5.539 +			// read relPos
   5.540 +			x=a.value("relPosX").toFloat (&okx);
   5.541 +			y=a.value("relPosY").toFloat (&oky);
   5.542 +			if (okx && oky) 
   5.543 +				
   5.544 +				{
   5.545 +					lastFloat->setRelPos (QPointF (x,y) );
   5.546 +					// make sure floats in mapcenter are repositioned to relative pos
   5.547 +					if (lastBranch->getDepth()==0) lastBranch->positionContents();
   5.548 +				}
   5.549 +			else
   5.550 +				// Couldn't read relPos
   5.551 +				return false;  
   5.552 +		}           
   5.553 +	}	
   5.554 +	
   5.555 +	if (!readOOAttr(a)) return false;
   5.556 +
   5.557 +	if (!a.value ("orgName").isEmpty() )
   5.558 +	{
   5.559 +		((FloatImageObj*)(lastFloat))->setOriginalFilename (a.value("orgName"));
   5.560 +	}
   5.561 +	return true;
   5.562 +}
   5.563 +
   5.564 +bool parseVYMHandler::readXLinkAttr (const QXmlAttributes& a)
   5.565 +{
   5.566 +	QColor col;
   5.567 +	bool okx;
   5.568 +	bool success=false;
   5.569 +	XLinkObj *xlo=new XLinkObj (model->getScene());
   5.570 +	if (!a.value( "color").isEmpty() ) 
   5.571 +	{
   5.572 +		col.setNamedColor(a.value("color"));
   5.573 +		xlo->setColor (col);
   5.574 +	}
   5.575 +
   5.576 +	if (!a.value( "width").isEmpty() ) 
   5.577 +	{
   5.578 +		xlo->setWidth(a.value ("width").toInt (&okx, 10));
   5.579 +	}
   5.580 +
   5.581 +	// Connecting by select string for compatibility with version < 1.8.76
   5.582 +	if (!a.value( "beginBranch").isEmpty() ) 
   5.583 +	{ 
   5.584 +		if (!a.value( "endBranch").isEmpty() ) 
   5.585 +		{
   5.586 +			LinkableMapObj *lmo=model->findObjBySelect (a.value( "beginBranch"));
   5.587 +			if (lmo && typeid (*lmo)==typeid (BranchObj))
   5.588 +			{
   5.589 +				xlo->setBegin ((BranchObj*)lmo);
   5.590 +				lmo=model->findObjBySelect (a.value( "endBranch"));
   5.591 +				if (lmo && typeid (*lmo)==typeid (BranchObj))
   5.592 +				{
   5.593 +					xlo->setEnd ((BranchObj*)(lmo));
   5.594 +					xlo->activate();
   5.595 +					success=true;
   5.596 +				}
   5.597 +			}
   5.598 +		}           
   5.599 +	}	
   5.600 +
   5.601 +	// object ID is used starting in version 1.8.76
   5.602 +	if (!a.value( "beginID").isEmpty() ) 
   5.603 +	{ 
   5.604 +		if (!a.value( "endID").isEmpty() ) 
   5.605 +		{
   5.606 +			LinkableMapObj *lmo=model->findID (a.value( "beginID"));
   5.607 +			if (lmo && typeid (*lmo)==typeid (BranchObj))
   5.608 +			{
   5.609 +				xlo->setBegin ((BranchObj*)lmo);
   5.610 +				lmo=model->findID (a.value( "endID"));
   5.611 +				if (lmo && typeid (*lmo)==typeid (BranchObj))
   5.612 +				{
   5.613 +					xlo->setEnd ((BranchObj*)(lmo));
   5.614 +					xlo->activate();
   5.615 +					success=true;
   5.616 +				}
   5.617 +			}
   5.618 +		}           
   5.619 +	}	
   5.620 +	if (!success) delete (xlo);
   5.621 +	return true;	// xLinks can only be established at the "end branch", return true
   5.622 +}
   5.623 +
   5.624 +bool parseVYMHandler::readHtmlAttr (const QXmlAttributes& a)
   5.625 +{
   5.626 +	for (int i=1; i<=a.count(); i++)
   5.627 +		htmldata+=" "+a.localName(i-1)+"=\""+a.value(i-1)+"\"";
   5.628 +	return true;
   5.629 +}
   5.630 +
   5.631 +bool parseVYMHandler::readSettingAttr (const QXmlAttributes& a)
   5.632 +{
   5.633 +	if (!a.value( "key").isEmpty() ) 
   5.634 +	{
   5.635 +		if (!a.value( "value").isEmpty() ) 
   5.636 +			settings.setLocalEntry (model->getMapEditor()->getDestPath(), a.value ("key"), a.value ("value"));
   5.637 +		else
   5.638 +			return false;
   5.639 +		
   5.640 +	} else
   5.641 +		return false;
   5.642 +	
   5.643 +	return true;
   5.644 +}