branchobj.cpp
changeset 370 97f5d07bf47d
parent 345 c8b7e4dd9e9e
child 375 06ab6df252fa
     1.1 --- a/branchobj.cpp	Thu Jun 01 14:51:56 2006 +0000
     1.2 +++ b/branchobj.cpp	Tue Sep 05 11:53:54 2006 +0000
     1.3 @@ -14,6 +14,7 @@
     1.4  /////////////////////////////////////////////////////////////////
     1.5  
     1.6  BranchObj* BranchObj::itLast=NULL;
     1.7 +BranchObj* BranchObj::itFirst=NULL;
     1.8  
     1.9  
    1.10  BranchObj::BranchObj () :OrnamentedObj()
    1.11 @@ -24,14 +25,14 @@
    1.12      depth=-1;
    1.13  }
    1.14  
    1.15 -BranchObj::BranchObj (QCanvas* c):OrnamentedObj (c)
    1.16 +BranchObj::BranchObj (Q3Canvas* c):OrnamentedObj (c)
    1.17  {
    1.18  //    cout << "Const BranchObj (c)  called from MapCenterObj (c)\n";
    1.19  	parObj=NULL;
    1.20      canvas=c;
    1.21  }
    1.22  
    1.23 -BranchObj::BranchObj (QCanvas* c, LinkableMapObj* p):OrnamentedObj (c)
    1.24 +BranchObj::BranchObj (Q3Canvas* c, LinkableMapObj* p):OrnamentedObj (c)
    1.25  {
    1.26  //    cout << "Const BranchObj (c,p)\n";
    1.27      canvas=c;
    1.28 @@ -72,7 +73,7 @@
    1.29      return angle == other.angle;
    1.30  }
    1.31  
    1.32 -int BranchObjPtrList::compareItems ( QPtrCollection::Item i, QPtrCollection::Item j)
    1.33 +int BranchObjPtrList::compareItems ( Q3PtrCollection::Item i, Q3PtrCollection::Item j)
    1.34  {
    1.35  	// Make sure PtrList::find works
    1.36  	if (i==j) return 0;
    1.37 @@ -149,7 +150,7 @@
    1.38  int BranchObj::getNum()
    1.39  {
    1.40  	if (parObj)
    1.41 -		return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this));
    1.42 +		return ((BranchObj*)parObj)->getNum (this);
    1.43  	else
    1.44  		return 0;
    1.45  }
    1.46 @@ -158,9 +159,10 @@
    1.47  {
    1.48  	// keep current pointer in branch, 
    1.49  	// otherwise save might fail
    1.50 -	int cur=branch.at();
    1.51 +	// FIXME is this _really_ still true?
    1.52 +//	int cur=branch.at();
    1.53  	int ind=branch.findRef (bo);
    1.54 -	branch.at(cur);
    1.55 +//	branch.at(cur);
    1.56  	return ind;
    1.57  }
    1.58  
    1.59 @@ -406,6 +408,7 @@
    1.60  BranchObj* BranchObj::first()
    1.61  {
    1.62  	itLast=NULL;	
    1.63 +	itFirst=this;
    1.64  	return this; 
    1.65  }
    1.66  	
    1.67 @@ -416,15 +419,17 @@
    1.68  	BranchObj *po=(BranchObj*)(parObj);
    1.69  
    1.70  	if (!itLast)
    1.71 -	{	// We are just beginning at the mapCenter
    1.72 +	{
    1.73  		if (bo) 
    1.74 -		{
    1.75 +		{	// We are just beginning, 
    1.76 +			// return first child  
    1.77  			itLast=this;
    1.78  			return bo;
    1.79  		}	
    1.80  		else
    1.81  		{
    1.82 -			itLast=NULL;
    1.83 +			// No childs
    1.84 +			itLast=this;
    1.85  			return NULL;
    1.86  		}	
    1.87  	}
    1.88 @@ -457,7 +462,7 @@
    1.89  		}
    1.90  	}
    1.91  
    1.92 -	// Try to find last child, we came from, in my own childs
    1.93 +	// Try to find last child, where we came from, in my own childs
    1.94  	bool searching=true;
    1.95  	while (bo && searching)
    1.96  	{
    1.97 @@ -476,6 +481,7 @@
    1.98  		{
    1.99  			if (po)
   1.100  			{
   1.101 +				if (this==itFirst) return NULL;	// Stop at starting point
   1.102  				// go up
   1.103  				itLast=this;
   1.104  				lmo=po->next();
   1.105 @@ -791,6 +797,11 @@
   1.106  	// save names of flags set
   1.107  	s+=standardFlags->saveToDir(tmpdir,prefix,0);
   1.108  	
   1.109 +	// Save FloatImages
   1.110 +	FloatImageObj *fio;
   1.111 +	for (fio=floatimage.first(); fio; fio=floatimage.next() )
   1.112 +		s+=fio->saveToDir (tmpdir,prefix,offset);
   1.113 +
   1.114  	// save note
   1.115  	if (!note.isEmpty() )
   1.116  		s+=note.saveToDir();
   1.117 @@ -800,14 +811,8 @@
   1.118      for (bo=branch.first(); bo; bo=branch.next() )
   1.119  		s+=bo->saveToDir(tmpdir,prefix,offset);
   1.120  
   1.121 -	// Save FloatImages
   1.122 -	FloatImageObj *fio;
   1.123 -	for (fio=floatimage.first(); fio; fio=floatimage.next() )
   1.124 -		s+=fio->saveToDir (tmpdir,prefix,offset);
   1.125 -
   1.126  	// Save XLinks
   1.127  	XLinkObj *xlo;
   1.128 -	//FIXME exponential increase in xlinks...
   1.129  	QString ol;	// old link
   1.130  	QString cl;	// current link
   1.131      for (xlo=xlink.first(); xlo; xlo=xlink.next() )
   1.132 @@ -877,7 +882,6 @@
   1.133  	calcBBoxSize();
   1.134  	positionBBox();
   1.135  	requestReposition();
   1.136 -	//FIXME undo needed
   1.137  }
   1.138  
   1.139  bool BranchObj::getIncludeImagesVer()
   1.140 @@ -891,7 +895,6 @@
   1.141  	calcBBoxSize();
   1.142  	positionBBox();
   1.143  	requestReposition();
   1.144 -	//FIXME undo needed
   1.145  }
   1.146  
   1.147  bool BranchObj::getIncludeImagesHor()
   1.148 @@ -925,7 +928,6 @@
   1.149  	positionBBox();
   1.150  	requestReposition();
   1.151  	return newfi;
   1.152 -	//FIXME undo needed
   1.153  }
   1.154  
   1.155  LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
   1.156 @@ -941,7 +943,6 @@
   1.157  	positionBBox();
   1.158  	requestReposition();
   1.159  	return newfi;
   1.160 -	// FIMXE undo needed
   1.161  }
   1.162  
   1.163  FloatImageObj* BranchObj::getFirstFloatImage ()
   1.164 @@ -1150,7 +1151,7 @@
   1.165  
   1.166  bool BranchObj::canMoveBranchUp() 
   1.167  {
   1.168 -	if (!parObj) return false;
   1.169 +	if (!parObj || depth==1) return false;
   1.170  	BranchObj* par=(BranchObj*)parObj;
   1.171  	if (this==par->getFirstBranch())
   1.172  		return false;
   1.173 @@ -1158,23 +1159,24 @@
   1.174  		return true;
   1.175  }
   1.176  
   1.177 -BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
   1.178 +BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist
   1.179  {
   1.180  	savePosInAngle();
   1.181      int i=branch.find(bo1);
   1.182 +	cout << "BO: i="<<i<<endl;
   1.183      if (i>0) 
   1.184  	{	// -1 if bo1 not found 
   1.185  		branch.at(i)->angle--;
   1.186  		branch.at(i-1)->angle++;
   1.187  		branch.sort();
   1.188 -		return branch.at(i-1);
   1.189 +		return branch.at(i);
   1.190  	} else
   1.191 -		return branch.at(i);
   1.192 +		return NULL;
   1.193  }
   1.194  
   1.195  bool BranchObj::canMoveBranchDown() 
   1.196  {
   1.197 -	if (!parObj) return false;
   1.198 +	if (!parObj|| depth==1) return false;
   1.199  	BranchObj* par=(BranchObj*)parObj;
   1.200  	if (this==par->getLastBranch())
   1.201  		return false;
   1.202 @@ -1182,7 +1184,7 @@
   1.203  		return true;
   1.204  }
   1.205  
   1.206 -BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
   1.207 +BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist
   1.208  {
   1.209  	savePosInAngle();
   1.210      int i=branch.find(bo1);
   1.211 @@ -1193,9 +1195,9 @@
   1.212  		branch.at(i)->angle++;
   1.213  		branch.at(j)->angle--;
   1.214  		branch.sort();
   1.215 -		return branch.at(j);
   1.216 +		return branch.at(i);
   1.217  	} else
   1.218 -		return branch.at(i);
   1.219 +		return NULL;
   1.220  }
   1.221  
   1.222  BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
   1.223 @@ -1203,7 +1205,7 @@
   1.224  	// Find current parent and 
   1.225  	// remove pointer to myself there
   1.226  	if (!dst) return NULL;
   1.227 -	BranchObj *par=(BranchObj*)(parObj);
   1.228 +	BranchObj *par=(BranchObj*)parObj;
   1.229  	if (par)
   1.230  		par->removeBranchPtr (this);
   1.231  	else
   1.232 @@ -1248,7 +1250,7 @@
   1.233  
   1.234  	// If I am the mapcenter or a mainbranch, reposition heading
   1.235  	if (depth<2)
   1.236 -	{	//FIXME ugly! optimize this   move for MCO needed to initially position text in box...
   1.237 +	{
   1.238  		if (depth==1)
   1.239  			// Calc angle to mapCenter if I am a mainbranch
   1.240  			// needed for reordering the mainbranches clockwise 
   1.241 @@ -1447,7 +1449,7 @@
   1.242  	if (!status.isEmpty()) mainWindow->statusMessage (status);
   1.243  
   1.244  	// Update Toolbar
   1.245 -	standardFlags->updateToolbar();
   1.246 +	updateFlagsToolbar();
   1.247  
   1.248  	// Update actions in mapeditor
   1.249  	mapEditor->updateActions();