mapcenterobj.cpp
branchqt4-port
changeset 2 608f976aa7bb
parent 0 7a96bd401351
     1.1 --- a/mapcenterobj.cpp	Sun Jan 30 12:58:47 2005 +0000
     1.2 +++ b/mapcenterobj.cpp	Tue Jun 06 14:58:11 2006 +0000
     1.3 @@ -13,7 +13,7 @@
     1.4      init();
     1.5  }
     1.6  
     1.7 -MapCenterObj::MapCenterObj(QCanvas* c) : BranchObj (c)
     1.8 +MapCenterObj::MapCenterObj(Q3Canvas* c) : BranchObj (c)
     1.9  {
    1.10  //    cout << "Const MapCenterObj   canvas="<<c<<"\n";
    1.11      init();
    1.12 @@ -27,26 +27,18 @@
    1.13  void MapCenterObj::clear() 
    1.14  {
    1.15  	BranchObj::clear();
    1.16 -    init();
    1.17  }
    1.18  
    1.19  void MapCenterObj::init () 
    1.20  {
    1.21 +	BranchObj::init();
    1.22      orientation=OrientUndef;
    1.23 -    absPos=QPoint (canvas->width()/2, canvas->height()/2);
    1.24  
    1.25  	// FIXME this should be done in TextObj later...
    1.26 -	QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
    1.27 -	heading->setFont(font);
    1.28 -
    1.29 -	branch.setAutoDelete (TRUE);
    1.30 -	floatimage.setAutoDelete (TRUE);
    1.31 -
    1.32 -	move (absPos.x(), absPos.y() );
    1.33 +	//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
    1.34 +	//heading->setFont(font);
    1.35  	depth=0;
    1.36 -
    1.37 -	scrolled=false;
    1.38 -	tmpUnscrolled=false;
    1.39 +	setDefAttr(MovedBranch);
    1.40  
    1.41  	frame->setFrameType (Rectangle);
    1.42  }
    1.43 @@ -54,13 +46,11 @@
    1.44  void MapCenterObj::move (double x, double y)
    1.45  {
    1.46  	BranchObj::move(x,y);
    1.47 -	positionBBox();
    1.48  }
    1.49  
    1.50  void MapCenterObj::moveBy (double x, double y)
    1.51  {
    1.52  	BranchObj::moveBy(x,y);
    1.53 -	positionBBox();
    1.54  }
    1.55  
    1.56  void MapCenterObj::moveAll (double x, double y)
    1.57 @@ -77,16 +67,13 @@
    1.58  {
    1.59  	// Move myself
    1.60  	moveBy(dx,dy);
    1.61 -
    1.62 -	positionBBox();
    1.63  }
    1.64  
    1.65  void MapCenterObj::updateLink()
    1.66  {
    1.67  	// set childPos to middle of MapCenterObj
    1.68 -	childPos=QPoint(
    1.69 -		absPos.x() + QSize(getSize() ).width()/2, 
    1.70 -		absPos.y() + QSize(getSize() ).height()/2);
    1.71 +	childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
    1.72 +	childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
    1.73  	parPos=childPos;		
    1.74  	BranchObj *b;
    1.75  	for (b=branch.first(); b; b=branch.next() )
    1.76 @@ -102,19 +89,15 @@
    1.77  	for (bo=branch.first(); bo; bo=branch.next() )
    1.78  	{	
    1.79  		lmo = bo->findMapObj(p, excludeLMO);
    1.80 -		
    1.81 -		if (lmo!= NULL) 
    1.82 -		{
    1.83 -			return lmo;
    1.84 -		}	
    1.85 +		if (lmo!= NULL) return lmo;
    1.86  	}
    1.87  	// is p in MapCenter?
    1.88 -	if (inBBox (p) && (this != excludeLMO) ) return this;
    1.89 +	if (inBox (p) && (this != excludeLMO) ) return this;
    1.90  
    1.91  	// Search float images
    1.92  	FloatImageObj *foi;
    1.93  	for (foi=floatimage.first(); foi; foi=floatimage.next() )
    1.94 -		if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
    1.95 +		if (foi->inBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
    1.96  
    1.97  	// nothing found
    1.98  	return NULL;
    1.99 @@ -131,13 +114,21 @@
   1.100  		attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
   1.101  		attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
   1.102  	
   1.103 +	// Providing an ID for a branch makes export to XHTML easier
   1.104 +	QString idAttr;
   1.105 +	if (countXLinks()>0)
   1.106 +		idAttr=attribut ("id",getSelectString());
   1.107 +	else
   1.108 +		idAttr="";
   1.109 +
   1.110 +	QString linkAttr=getLinkAttr();
   1.111 +
   1.112      s=beginElement ("mapcenter" 
   1.113 -		+attribut("absPosX",QString().setNum(absPos.x(),10))
   1.114 -		+attribut("absPosY",QString().setNum(absPos.y(),10))
   1.115 +		+getOrnAttr() 
   1.116  		+attribut("frameType",frame->getFrameTypeName()) 
   1.117  		+areaAttr 
   1.118 -		);
   1.119 -		
   1.120 +		+idAttr 
   1.121 +		+getIncludeImageAttr() );
   1.122      incIndent();
   1.123      if (heading->getColor()!=QColor("black"))
   1.124  		a=attribut ("textColor",QColor(heading->getColor()).name() );
   1.125 @@ -149,23 +140,25 @@
   1.126  	s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
   1.127      s=s+valueElement("heading", getHeading(),a);
   1.128  
   1.129 -	// Reset the counters before saving
   1.130 -	FloatImageObj (canvas).resetSaveCounter();
   1.131 -
   1.132  	// add link to file in s
   1.133  	if (!note.isEmpty() )
   1.134  		s+=note.saveToDir();
   1.135  	
   1.136 -	// Save FloatImages
   1.137 -	FloatImageObj *fio;
   1.138 -	for (fio=floatimage.first(); fio; fio=floatimage.next() )
   1.139 -		s+=fio->saveToDir (tmpdir,prefix);
   1.140 -
   1.141  	// Save branches
   1.142      BranchObj *bo;
   1.143      for (bo=branch.first(); bo; bo=branch.next() )
   1.144  		s+=bo->saveToDir(tmpdir,prefix, offset);
   1.145  
   1.146 +	// Save FloatImages
   1.147 +	FloatImageObj *fio;
   1.148 +	for (fio=floatimage.first(); fio; fio=floatimage.next() )
   1.149 +		s+=fio->saveToDir (tmpdir,prefix,offset);
   1.150 +
   1.151 +	// Save XLinks
   1.152 +	XLinkObj *xlo;
   1.153 +    for (xlo=xlink.first(); xlo; xlo=xlink.next() )
   1.154 +		s+=xlo->saveToDir();
   1.155 +
   1.156      decIndent();
   1.157      s+=endElement   ("mapcenter");
   1.158      return s;
   1.159 @@ -184,9 +177,9 @@
   1.160  	QString s2=version.section (".",1,1);
   1.161  	QString s3=version.section (".",2,2);
   1.162  	bool ok;
   1.163 -	int vv1 =QString(__VYM_VERSION__).section (".",0,0).toInt(&ok,10);
   1.164 -	int vv2 =QString(__VYM_VERSION__).section (".",1,1).toInt(&ok,10);
   1.165 -	int vv3 =QString(__VYM_VERSION__).section (".",2,2).toInt(&ok,10);
   1.166 +	int vv1 =QString(__VYM_VERSION).section (".",0,0).toInt(&ok,10);
   1.167 +	int vv2 =QString(__VYM_VERSION).section (".",1,1).toInt(&ok,10);
   1.168 +	int vv3 =QString(__VYM_VERSION).section (".",2,2).toInt(&ok,10);
   1.169  	int mv1=0;
   1.170  	int mv2=0;
   1.171  	int mv3=0;
   1.172 @@ -233,3 +226,4 @@
   1.173  {
   1.174  	return QDate::currentDate().toString ("yyyy-MM-dd");
   1.175  }
   1.176 +