diff -r a4532e5c2ce3 -r 1c8ff1928b97 branchobj.cpp --- a/branchobj.cpp Mon Nov 20 12:12:05 2006 +0000 +++ b/branchobj.cpp Thu Nov 23 13:53:08 2006 +0000 @@ -8,6 +8,19 @@ extern FlagRowObj *standardFlagsDefault; +/* FIXME not needed any longer in QT4 +int BranchObjPointrList::compareItems ( Q3PtrCollection::Item i, Q3PtrCollection::Item j) +{ + // Make sure PtrList::find works + if (i==j) return 0; + + if ( ((BranchObj*)(i))->angle > ((BranchObj*)(j))->angle ) + return 1; + else + return -1; +} +*/ + ///////////////////////////////////////////////////////////////// // BranchObj ///////////////////////////////////////////////////////////////// @@ -72,22 +85,8 @@ return angle == other.angle; } -int BranchObjPtrList::compareItems ( Q3PtrCollection::Item i, Q3PtrCollection::Item j) -{ - // Make sure PtrList::find works - if (i==j) return 0; - - if ( ((BranchObj*)(i))->angle > ((BranchObj*)(j))->angle ) - return 1; - else - return -1; -} - void BranchObj::init () { - branch.setAutoDelete (false); - xlink.setAutoDelete (false); - if (parObj) { absPos=getRandPos(); @@ -110,12 +109,11 @@ OrnamentedObj::copy(other); branch.clear(); - BranchObj* b; - for (b=other->branch.first(); b;b=other->branch.next() ) + for (int i=0; ibranch.size(); ++i) // Make deep copy of b // Because addBranch again calls copy for the childs, // Those will get a deep copy, too - addBranch(b); + addBranch(other->branch.at(i) ); for (int i=0; ifloatimage.size(); ++i) addFloatImage (other->floatimage.at(i)); @@ -134,15 +132,10 @@ delete floatimage.takeFirst(); while (!xlink.isEmpty()) - deleteXLink (xlink.first() ); + delete xlink.takeFirst(); - BranchObj *bo; while (!branch.isEmpty()) - { - bo=branch.first(); - branch.removeFirst(); - delete (bo); - } + delete branch.takeFirst(); } int BranchObj::getNum() @@ -155,12 +148,7 @@ int BranchObj::getNum(BranchObj *bo) { - // keep current pointer in branch, - // otherwise saveToDir will fail - int cur=branch.at(); - int ind=branch.findRef (bo); - branch.at(cur); - return ind; + return branch.indexOf (bo); } int BranchObj::getFloatImageNum(FloatImageObj *fio) @@ -273,23 +261,18 @@ void BranchObj::toggleScroll() { - BranchObj *bo; if (scrolled) { scrolled=false; systemFlags->deactivate("scrolledright"); - for (bo=branch.first(); bo; bo=branch.next() ) - { - bo->setVisibility(true); - } + for (int i=0; isetVisibility(true); } else { scrolled=true; systemFlags->activate("scrolledright"); - for (bo=branch.first(); bo; bo=branch.next() ) - { - bo->setVisibility(false); - } + for (int i=0; isetVisibility(false); } calcBBoxSize(); positionBBox(); @@ -362,14 +345,13 @@ if (!scrolled && (depth < toDepth)) { // Now go recursivly through all childs - BranchObj* b; - for (b=branch.first(); b;b=branch.next() ) - b->setVisibility (v,toDepth); - for (int i=0; isetVisibility (v,toDepth); + for (i=0; isetVisibility (v); - XLinkObj* xlo; - for (xlo=xlink.first(); xlo;xlo=xlink.next() ) - xlo->setVisibility (); + for (i=0; isetVisibility (); } } // depth <= toDepth requestReposition(); @@ -396,9 +378,8 @@ void BranchObj::setColorChilds (QColor col) { OrnamentedObj::setColor (col); - BranchObj *bo; - for (bo=branch.first(); bo; bo=branch.next() ) - bo->setColorChilds(col); + for (int i=0; isetColorChilds(col); } BranchObj* BranchObj::first() @@ -410,28 +391,35 @@ BranchObj* BranchObj::next() { + BranchObj *bo; BranchObj *lmo; - BranchObj *bo=branch.first(); - BranchObj *po=(BranchObj*)(parObj); + BranchObj *po=(BranchObj*)parObj; + + if (branch.isEmpty()) + bo=NULL; + else + bo=branch.first(); if (!itLast) { + // no itLast, we are just beginning if (bo) - { // We are just beginning, - // return first child + { + // we have childs, return first one itLast=this; return bo; } else { - // No childs + // No childs, so there is no next itLast=this; return NULL; } } - if (itLast==parObj) - { // We come from above + // We have an itLast + if (itLast==po) + { // We come from parent if (bo) { // there are childs, go there @@ -442,7 +430,7 @@ { // no childs, try to go up again if (po) { - // go up + // go back to parent and try to find next there itLast=this; lmo=po->next(); itLast=this; @@ -451,22 +439,36 @@ } else { - // can't go up, I am mapCenter + // can't go up, I am mapCenter, no next itLast=NULL; return NULL; } } } + // We don't come from parent, but from brother or childs + // Try to find last child, where we came from, in my own childs bool searching=true; - while (bo && searching) + int i=0; + while (i0) { // proceed with my first child itLast=this; - return bo; + return branch.first(); } else { @@ -554,9 +555,8 @@ void BranchObj::moveBy (double x, double y) { OrnamentedObj::moveBy (x,y); - BranchObj* b; - for (b=branch.first(); b;b=branch.next() ) - b->moveBy (x,y); + for (int i=0; imoveBy (x,y); positionBBox(); } @@ -577,9 +577,8 @@ frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); // Update links to other branches - XLinkObj *xlo; - for (xlo=xlink.first(); xlo; xlo=xlink.next() ) - xlo->updateXLink(); + for (int i=0; iupdateXLink(); } void BranchObj::calcBBoxSize() @@ -673,11 +672,10 @@ LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO) { // Search branches - BranchObj *b; LinkableMapObj *lmo; - for (b=branch.first(); b; b=branch.next() ) + for (int i=0; ifindMapObj(p, excludeLMO); + lmo=branch.at(i)->findMapObj(p, excludeLMO); if (lmo != NULL) return lmo; } @@ -719,9 +717,8 @@ hidden=false; } - BranchObj *bo; - for (bo=branch.first(); bo; bo=branch.next() ) - bo->setHideTmp (mode); + for (int i=0; isetHideTmp (mode); } bool BranchObj::hasHiddenExportParent(BranchObj *start) @@ -805,17 +802,15 @@ s+=note.saveToDir(); // Save branches - BranchObj *bo; - for (bo=branch.first(); bo; bo=branch.next() ) - s+=bo->saveToDir(tmpdir,prefix,offset); + for (int i=0; isaveToDir(tmpdir,prefix,offset); // Save XLinks - XLinkObj *xlo; QString ol; // old link QString cl; // current link - for (xlo=xlink.first(); xlo; xlo=xlink.next() ) + for (int i=0; isaveToDir(); + cl=xlink.at(i)->saveToDir(); if (cl!=ol) { s+=cl; @@ -839,7 +834,7 @@ void BranchObj::removeXLinkRef (XLinkObj *xlo) { - xlink.remove (xlo); + xlink.removeAt (xlink.indexOf(xlo)); } void BranchObj::deleteXLink(XLinkObj *xlo) @@ -868,10 +863,12 @@ BranchObj* BranchObj::XLinkTargetAt (int i) { - if (xlink.at(i)) - return xlink.at(i)->otherBranch (this); - else - return NULL; + if (i>=0 && iotherBranch (this); + } + return NULL; } void BranchObj::setIncludeImagesVer(bool b) @@ -975,13 +972,8 @@ void BranchObj::savePosInAngle () { // Save position in angle - BranchObj *b; - int i=0; - for (b=branch.first(); b; b=branch.next() ) - { - b->angle=i; - i++; - } + for (int i=0; iangle=i; } void BranchObj::setDefAttr (BranchModification mod) @@ -1055,7 +1047,7 @@ // Add new bo and resort branches BranchObj *newbo=addBranch (); newbo->angle=pos-0.5; - branch.sort(); + //FIXME branch.sort(); return newbo; } @@ -1065,7 +1057,7 @@ // Add new bo and resort branches bo->angle=pos-0.5; BranchObj *newbo=addBranch (bo); - branch.sort(); + //FIXME branch.sort(); return newbo; } @@ -1080,7 +1072,7 @@ bo->setDefAttr (MovedBranch); if (scrolled) tmpUnscroll(); setLastSelectedBranch (bo); - branch.sort(); + //FIXME branch.sort(); return bo; } @@ -1109,22 +1101,30 @@ // if bo is not in branch remove returns false, we // don't care... - if (branch.remove (bo)) + int i=branch.indexOf(bo); + if (i>=0) + { delete (bo); - else + branch.removeAt (i); + } else qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n"); requestReposition(); } void BranchObj::removeBranchPtr(BranchObj* bo) { - branch.remove (bo); + int i=branch.indexOf(bo); + + if (i>=0) + branch.removeAt (i); + else + qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n"); requestReposition(); } void BranchObj::setLastSelectedBranch (BranchObj* bo) { - lastSelectedBranch=branch.find(bo); + lastSelectedBranch=branch.indexOf(bo); } BranchObj* BranchObj::getLastSelectedBranch () @@ -1147,9 +1147,12 @@ return branch.last(); } -BranchObj* BranchObj::getBranchNum (const uint &i) +BranchObj* BranchObj::getBranchNum (int i) { - return branch.at(i); + if (i>=0 && i0) { // -1 if bo1 not found branch.at(i)->angle--; branch.at(i-1)->angle++; - branch.sort(); + //FIXME branch.sort(); return branch.at(i); } else return NULL; @@ -1189,14 +1192,14 @@ BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist { savePosInAngle(); - int i=branch.find(bo1); + int i=branch.indexOf(bo1); int j; - if (branch.next()) + if (i angle++; branch.at(j)->angle--; - branch.sort(); + //FIXME branch.sort(); return branch.at(i); } else return NULL; @@ -1305,13 +1308,12 @@ ref2.setY(ref.y() ); // Align the childs depending on reference point - BranchObj *b; - for (b=branch.first(); b; b=branch.next() ) + for (int i=0; iisHidden()) + if (!branch.at(i)->isHidden()) { - b->alignRelativeTo (ref2); - ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() ); + branch.at(i)->alignRelativeTo (ref2); + ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChilds().height() ); } } } @@ -1340,7 +1342,7 @@ alignRelativeTo ( QPoint (absPos.x(), absPos.y()-(bboxTotal.height()-bbox.height())/2) ); - branch.sort(); + //FIXME branch.sort(); positionBBox(); // Reposition bbox and contents } else { @@ -1354,11 +1356,8 @@ void BranchObj::unsetAllRepositionRequests() { repositionRequest=false; - BranchObj *b; - for (b=branch.first(); b; b=branch.next() ) - { - b->unsetAllRepositionRequests(); - } + for (int i=0; iunsetAllRepositionRequests(); } @@ -1368,10 +1367,9 @@ if (scrolled) return r; - BranchObj* b; - for (b=branch.first();b ;b=branch.next() ) - if (!b->isHidden()) - r=addBBox(b->getTotalBBox(),r); + for (int i=0; iisHidden()) + r=addBBox(branch.at(i)->getTotalBBox(),r); for (int i=0; iisHidden()) @@ -1427,13 +1425,12 @@ // sum of heights // maximum of widths // minimum of y - BranchObj* b; - for (b=branch.first();b ;b=branch.next() ) + for (int i=0; iisHidden()) + if (!branch.at(i)->isHidden()) { - b->calcBBoxSizeWithChilds(); - br=b->getBBoxSizeWithChilds(); + branch.at(i)->calcBBoxSizeWithChilds(); + br=branch.at(i)->getBBoxSizeWithChilds(); r.setWidth( max (br.width(), r.width() )); r.setHeight(br.height() + r.height() ); if (br.y()updateActions(); }