Fix: Save note of MapCenter release-1-12-maintained
authorinsilmaril
Wed Nov 12 11:15:37 2008 +0000 (2008-11-12)
branchrelease-1-12-maintained
changeset 526cd53d63956f
parent 51 b2224ebf331f
child 53 1532402be6c2
Fix: Save note of MapCenter
mapcenterobj.cpp
version.h
     1.1 --- a/mapcenterobj.cpp	Mon Oct 06 12:28:25 2008 +0000
     1.2 +++ b/mapcenterobj.cpp	Wed Nov 12 11:15:37 2008 +0000
     1.3 @@ -1,9 +1,11 @@
     1.4 -#include <qdatetime.h>
     1.5 +#include <QDateTime>
     1.6  
     1.7 +#include "floatimageobj.h"
     1.8 +#include "geometry.h"
     1.9  #include "mapcenterobj.h"
    1.10 -#include "floatimageobj.h"
    1.11  #include "mapeditor.h"
    1.12  
    1.13 +
    1.14  /////////////////////////////////////////////////////////////////
    1.15  // MapCenterObj
    1.16  /////////////////////////////////////////////////////////////////
    1.17 @@ -13,54 +15,50 @@
    1.18      init();
    1.19  }
    1.20  
    1.21 -MapCenterObj::MapCenterObj(QCanvas* c) : BranchObj (c)
    1.22 +MapCenterObj::MapCenterObj(QGraphicsScene* s) : BranchObj (s)
    1.23  {
    1.24 -//    cout << "Const MapCenterObj   canvas="<<c<<"\n";
    1.25 +//    cout << "Const MapCenterObj   canvas="<<s<<"\n";
    1.26      init();
    1.27  }
    1.28  
    1.29  MapCenterObj::~MapCenterObj() 
    1.30  {
    1.31  //    cout << "Destr MapCenterObj\n";
    1.32 +	clear();
    1.33  }	
    1.34  
    1.35  void MapCenterObj::clear() 
    1.36  {
    1.37  	BranchObj::clear();
    1.38 -    init();
    1.39  }
    1.40  
    1.41  void MapCenterObj::init () 
    1.42  {
    1.43 -    orientation=OrientUndef;
    1.44 -    absPos=QPoint (canvas->width()/2, canvas->height()/2);
    1.45 +	BranchObj::init();
    1.46 +    orientation=LinkableMapObj::UndefinedOrientation;
    1.47  
    1.48 -	// FIXME this should be done in TextObj later...
    1.49 -	QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
    1.50 -	heading->setFont(font);
    1.51 +	// TODO this should be done in TextObj later...
    1.52 +	//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
    1.53 +	//heading->setFont(font);
    1.54 +	depth=0;
    1.55 +	setDefAttr(MovedBranch);
    1.56  
    1.57 -	branch.setAutoDelete (TRUE);
    1.58 -	floatimage.setAutoDelete (TRUE);
    1.59 -
    1.60 -	move (absPos.x(), absPos.y() );
    1.61 -	depth=0;
    1.62 -
    1.63 -	scrolled=false;
    1.64 -	tmpUnscrolled=false;
    1.65 -
    1.66 -	frame->setFrameType (Rectangle);
    1.67 +	frame->setFrameType (FrameObj::Rectangle);
    1.68  }
    1.69  
    1.70  void MapCenterObj::move (double x, double y)
    1.71  {
    1.72  	BranchObj::move(x,y);
    1.73 -	positionBBox();
    1.74 +}
    1.75 +
    1.76 +void MapCenterObj::move (QPointF absPos)
    1.77 +{
    1.78 +	BranchObj::move(absPos);
    1.79  }
    1.80  
    1.81  void MapCenterObj::moveBy (double x, double y)
    1.82  {
    1.83  	BranchObj::moveBy(x,y);
    1.84 -	positionBBox();
    1.85  }
    1.86  
    1.87  void MapCenterObj::moveAll (double x, double y)
    1.88 @@ -75,69 +73,84 @@
    1.89  
    1.90  void MapCenterObj::moveAllBy (double dx, double dy)
    1.91  {
    1.92 -	// Move myself
    1.93 -	moveBy(dx,dy);
    1.94 -
    1.95 -	positionBBox();
    1.96 +	// Move myself and childs
    1.97 +	BranchObj::moveBy(dx,dy);
    1.98  }
    1.99  
   1.100  void MapCenterObj::updateLink()
   1.101  {
   1.102  	// set childPos to middle of MapCenterObj
   1.103 -	childPos=QPoint(
   1.104 -		absPos.x() + QSize(getSize() ).width()/2, 
   1.105 -		absPos.y() + QSize(getSize() ).height()/2);
   1.106 +	childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
   1.107 +	childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
   1.108  	parPos=childPos;		
   1.109 -	BranchObj *b;
   1.110 -	for (b=branch.first(); b; b=branch.next() )
   1.111 -		b->updateLink();
   1.112 +	for (int i=0; i<branch.size(); ++i)
   1.113 +		branch.at(i)->updateLink();
   1.114  }
   1.115  
   1.116 -LinkableMapObj* MapCenterObj::findMapObj(QPoint p, LinkableMapObj *excludeLMO)
   1.117 +void MapCenterObj::updateRelPositions()
   1.118 +{
   1.119 +	if (repositionRequest) unsetAllRepositionRequests();
   1.120 +
   1.121 +	// update relative Positions of branches and floats
   1.122 +	for (int i=0; i<branch.size(); ++i)
   1.123  	{
   1.124 -	BranchObj *bo;
   1.125 +		branch.at(i)->setRelPos();
   1.126 +		branch.at(i)->setOrientation();
   1.127 +	}
   1.128 +	
   1.129 +	for (int i=0; i<floatimage.size(); ++i)
   1.130 +		floatimage.at(i)->setRelPos();
   1.131 +
   1.132 +	if (repositionRequest) reposition();
   1.133 +}
   1.134 +
   1.135 +LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
   1.136 +	{
   1.137  	LinkableMapObj *lmo;
   1.138  
   1.139  	// Search through child branches
   1.140 -	for (bo=branch.first(); bo; bo=branch.next() )
   1.141 +	for (int i=0; i<branch.size(); ++i)
   1.142  	{	
   1.143 -		lmo = bo->findMapObj(p, excludeLMO);
   1.144 -		
   1.145 -		if (lmo!= NULL) 
   1.146 -		{
   1.147 -			return lmo;
   1.148 -		}	
   1.149 +		lmo = branch.at(i)->findMapObj(p, excludeLMO);
   1.150 +		if (lmo!= NULL) return lmo;
   1.151  	}
   1.152  	// is p in MapCenter?
   1.153 -	if (inBBox (p) && (this != excludeLMO) ) return this;
   1.154 +	if (inBox (p,clickBox) && (this != excludeLMO) ) return this;
   1.155  
   1.156  	// Search float images
   1.157 -	FloatImageObj *foi;
   1.158 -	for (foi=floatimage.first(); foi; foi=floatimage.next() )
   1.159 -		if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
   1.160 +	for (int i=0; i<floatimage.size(); ++i)
   1.161 +		if (inBox(p,floatimage.at(i)->getClickBox()) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i);
   1.162  
   1.163  	// nothing found
   1.164  	return NULL;
   1.165  }
   1.166  
   1.167 -QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPoint &offset)
   1.168 +QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
   1.169  {
   1.170      QString s,a;
   1.171  
   1.172  	// save area, if not scrolled
   1.173  	QString areaAttr=
   1.174 -		attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
   1.175 -		attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
   1.176 -		attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
   1.177 -		attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
   1.178 +		attribut("x1",QString().setNum(absPos.x()-offset.x())) +
   1.179 +		attribut("y1",QString().setNum(absPos.y()-offset.y())) +
   1.180 +		attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
   1.181 +		attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
   1.182  	
   1.183 +	// Providing an ID for a branch makes export to XHTML easier
   1.184 +	QString idAttr;
   1.185 +	if (countXLinks()>0)
   1.186 +		idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model
   1.187 +
   1.188 +	else
   1.189 +		idAttr="";
   1.190 +
   1.191 +	QString linkAttr=getLinkAttr();
   1.192 +
   1.193      s=beginElement ("mapcenter" 
   1.194 -		+attribut("absPosX",QString().setNum(absPos.x(),10))
   1.195 -		+attribut("absPosY",QString().setNum(absPos.y(),10))
   1.196 -		+attribut("frameType",frame->getFrameTypeName()) 
   1.197 +		+getOrnXMLAttr() 
   1.198  		+areaAttr 
   1.199 -		);
   1.200 -		
   1.201 +		+idAttr 
   1.202 +		+getIncludeImageAttr() );
   1.203      incIndent();
   1.204      if (heading->getColor()!=QColor("black"))
   1.205  		a=attribut ("textColor",QColor(heading->getColor()).name() );
   1.206 @@ -147,24 +160,31 @@
   1.207  	// Save flags. If verbose is set (export to xml dir), also write
   1.208  	// the flags as picture
   1.209  	s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
   1.210 -    s=s+valueElement("heading", getHeading(),a);
   1.211  
   1.212 -	// Reset the counters before saving
   1.213 -	FloatImageObj (canvas).resetSaveCounter();
   1.214 +	// Save heading
   1.215 +    s+=valueElement("heading", getHeading(),a);
   1.216  
   1.217 -	// add link to file in s
   1.218 +	// Save frame
   1.219 +	s+=frame->saveToDir ();
   1.220 +
   1.221 +	// Update of note is usually done while unselecting a branch
   1.222 +	if (isNoteInEditor) getNoteFromTextEditor();
   1.223 +
   1.224 +	// save note
   1.225  	if (!note.isEmpty() )
   1.226  		s+=note.saveToDir();
   1.227  	
   1.228 +	// Save branches
   1.229 +	for (int i=0; i<branch.size(); ++i)
   1.230 +		s+=branch.at(i)->saveToDir(tmpdir,prefix, offset);
   1.231 +
   1.232  	// Save FloatImages
   1.233 -	FloatImageObj *fio;
   1.234 -	for (fio=floatimage.first(); fio; fio=floatimage.next() )
   1.235 -		s+=fio->saveToDir (tmpdir,prefix);
   1.236 +	for (int i=0; i<floatimage.size(); ++i)
   1.237 +		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
   1.238  
   1.239 -	// Save branches
   1.240 -    BranchObj *bo;
   1.241 -    for (bo=branch.first(); bo; bo=branch.next() )
   1.242 -		s+=bo->saveToDir(tmpdir,prefix, offset);
   1.243 +	// Save XLinks
   1.244 +	for (int i=0;i<xlink.size(); ++i)
   1.245 +		s+=xlink.at(i)->saveToDir();
   1.246  
   1.247      decIndent();
   1.248      s+=endElement   ("mapcenter");
   1.249 @@ -176,39 +196,6 @@
   1.250  	version=s;
   1.251  }
   1.252  
   1.253 -bool MapCenterObj::checkVersion ()
   1.254 -{
   1.255 -	// returns true, if vym is able to read file regarding 
   1.256 -	// the version set with setVersion
   1.257 -	QString s1=version.section (".",0,0);
   1.258 -	QString s2=version.section (".",1,1);
   1.259 -	QString s3=version.section (".",2,2);
   1.260 -	bool ok;
   1.261 -	int vv1 =QString(__VYM_VERSION__).section (".",0,0).toInt(&ok,10);
   1.262 -	int vv2 =QString(__VYM_VERSION__).section (".",1,1).toInt(&ok,10);
   1.263 -	int vv3 =QString(__VYM_VERSION__).section (".",2,2).toInt(&ok,10);
   1.264 -	int mv1=0;
   1.265 -	int mv2=0;
   1.266 -	int mv3=0;
   1.267 -	if (!s1.isEmpty() ) mv1=s1.toInt(&ok,10);
   1.268 -	if (!s2.isEmpty() ) mv2=s2.toInt(&ok,10);
   1.269 -	if (!s3.isEmpty() ) mv3=s3.toInt(&ok,10);
   1.270 -	
   1.271 -	if (vv1 > mv1)
   1.272 -		return true;
   1.273 -	if (vv1 < mv1)
   1.274 -		return false;
   1.275 -	if (vv2 > mv2)
   1.276 -		return true;
   1.277 -	if (vv2 < mv2)
   1.278 -		return false;
   1.279 -	if (vv3 > mv3)
   1.280 -		return true;
   1.281 -	if (vv3 < mv3)
   1.282 -		return false;
   1.283 -	return true;	
   1.284 -}
   1.285 -
   1.286  void MapCenterObj::setAuthor (const QString &s)
   1.287  {
   1.288  	author=s;
   1.289 @@ -233,3 +220,4 @@
   1.290  {
   1.291  	return QDate::currentDate().toString ("yyyy-MM-dd");
   1.292  }
   1.293 +
     2.1 --- a/version.h	Mon Oct 06 12:28:25 2008 +0000
     2.2 +++ b/version.h	Wed Nov 12 11:15:37 2008 +0000
     2.3 @@ -5,9 +5,9 @@
     2.4  
     2.5  #define __VYM_NAME "VYM"
     2.6  #define __VYM_VERSION "1.12.2"
     2.7 -#define __VYM_CODENAME "Maintenance Update"
     2.8 +#define __VYM_CODENAME "Maintenance Update a"
     2.9  //#define __VYM_CODENAME "Codename: development version"
    2.10 -#define __VYM_BUILD_DATE "2008-10-05"
    2.11 +#define __VYM_BUILD_DATE "2008-11-12"
    2.12  
    2.13  
    2.14  bool checkVersion(const QString &);