diff -r 3dc98c8843bc -r 7b74fa3772bf branchobj.cpp --- a/branchobj.cpp Tue Aug 01 09:30:57 2006 +0000 +++ b/branchobj.cpp Tue Sep 05 09:47:13 2006 +0000 @@ -14,6 +14,7 @@ ///////////////////////////////////////////////////////////////// BranchObj* BranchObj::itLast=NULL; +BranchObj* BranchObj::itFirst=NULL; BranchObj::BranchObj () :OrnamentedObj() @@ -24,14 +25,14 @@ depth=-1; } -BranchObj::BranchObj (QCanvas* c):OrnamentedObj (c) +BranchObj::BranchObj (Q3Canvas* c):OrnamentedObj (c) { // cout << "Const BranchObj (c) called from MapCenterObj (c)\n"; parObj=NULL; canvas=c; } -BranchObj::BranchObj (QCanvas* c, LinkableMapObj* p):OrnamentedObj (c) +BranchObj::BranchObj (Q3Canvas* c, LinkableMapObj* p):OrnamentedObj (c) { // cout << "Const BranchObj (c,p)\n"; canvas=c; @@ -72,7 +73,7 @@ return angle == other.angle; } -int BranchObjPtrList::compareItems ( QPtrCollection::Item i, QPtrCollection::Item j) +int BranchObjPtrList::compareItems ( Q3PtrCollection::Item i, Q3PtrCollection::Item j) { // Make sure PtrList::find works if (i==j) return 0; @@ -149,7 +150,7 @@ int BranchObj::getNum() { if (parObj) - return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this)); + return ((BranchObj*)parObj)->getNum (this); else return 0; } @@ -158,9 +159,10 @@ { // keep current pointer in branch, // otherwise save might fail - int cur=branch.at(); + // FIXME is this _really_ still true? +// int cur=branch.at(); int ind=branch.findRef (bo); - branch.at(cur); +// branch.at(cur); return ind; } @@ -406,6 +408,7 @@ BranchObj* BranchObj::first() { itLast=NULL; + itFirst=this; return this; } @@ -416,15 +419,17 @@ BranchObj *po=(BranchObj*)(parObj); if (!itLast) - { // We are just beginning at the mapCenter + { if (bo) - { + { // We are just beginning, + // return first child itLast=this; return bo; } else { - itLast=NULL; + // No childs + itLast=this; return NULL; } } @@ -457,7 +462,7 @@ } } - // Try to find last child, we came from, in my own childs + // Try to find last child, where we came from, in my own childs bool searching=true; while (bo && searching) { @@ -476,6 +481,7 @@ { if (po) { + if (this==itFirst) return NULL; // Stop at starting point // go up itLast=this; lmo=po->next(); @@ -791,6 +797,11 @@ // save names of flags set s+=standardFlags->saveToDir(tmpdir,prefix,0); + // Save FloatImages + FloatImageObj *fio; + for (fio=floatimage.first(); fio; fio=floatimage.next() ) + s+=fio->saveToDir (tmpdir,prefix,offset); + // save note if (!note.isEmpty() ) s+=note.saveToDir(); @@ -800,14 +811,8 @@ for (bo=branch.first(); bo; bo=branch.next() ) s+=bo->saveToDir(tmpdir,prefix,offset); - // Save FloatImages - FloatImageObj *fio; - for (fio=floatimage.first(); fio; fio=floatimage.next() ) - s+=fio->saveToDir (tmpdir,prefix,offset); - // Save XLinks XLinkObj *xlo; - //FIXME exponential increase in xlinks... QString ol; // old link QString cl; // current link for (xlo=xlink.first(); xlo; xlo=xlink.next() ) @@ -877,7 +882,6 @@ calcBBoxSize(); positionBBox(); requestReposition(); - //FIXME undo needed } bool BranchObj::getIncludeImagesVer() @@ -891,7 +895,6 @@ calcBBoxSize(); positionBBox(); requestReposition(); - //FIXME undo needed } bool BranchObj::getIncludeImagesHor() @@ -925,7 +928,6 @@ positionBBox(); requestReposition(); return newfi; - //FIXME undo needed } LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio) @@ -941,7 +943,6 @@ positionBBox(); requestReposition(); return newfi; - // FIMXE undo needed } FloatImageObj* BranchObj::getFirstFloatImage () @@ -1150,7 +1151,7 @@ bool BranchObj::canMoveBranchUp() { - if (!parObj) return false; + if (!parObj || depth==1) return false; BranchObj* par=(BranchObj*)parObj; if (this==par->getFirstBranch()) return false; @@ -1158,23 +1159,24 @@ return true; } -BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself) +BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist { savePosInAngle(); int i=branch.find(bo1); + cout << "BO: i="<0) { // -1 if bo1 not found branch.at(i)->angle--; branch.at(i-1)->angle++; branch.sort(); - return branch.at(i-1); + return branch.at(i); } else - return branch.at(i); + return NULL; } bool BranchObj::canMoveBranchDown() { - if (!parObj) return false; + if (!parObj|| depth==1) return false; BranchObj* par=(BranchObj*)parObj; if (this==par->getLastBranch()) return false; @@ -1182,7 +1184,7 @@ return true; } -BranchObj* BranchObj::moveBranchDown(BranchObj* bo1) +BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist { savePosInAngle(); int i=branch.find(bo1); @@ -1193,9 +1195,9 @@ branch.at(i)->angle++; branch.at(j)->angle--; branch.sort(); - return branch.at(j); + return branch.at(i); } else - return branch.at(i); + return NULL; } BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos) @@ -1203,7 +1205,7 @@ // Find current parent and // remove pointer to myself there if (!dst) return NULL; - BranchObj *par=(BranchObj*)(parObj); + BranchObj *par=(BranchObj*)parObj; if (par) par->removeBranchPtr (this); else @@ -1248,7 +1250,7 @@ // If I am the mapcenter or a mainbranch, reposition heading if (depth<2) - { //FIXME ugly! optimize this move for MCO needed to initially position text in box... + { if (depth==1) // Calc angle to mapCenter if I am a mainbranch // needed for reordering the mainbranches clockwise @@ -1447,7 +1449,7 @@ if (!status.isEmpty()) mainWindow->statusMessage (status); // Update Toolbar - standardFlags->updateToolbar(); + updateFlagsToolbar(); // Update actions in mapeditor mapEditor->updateActions();