diff -r edb78a44240b -r 9ff332964015 branchobj.cpp --- a/branchobj.cpp Tue Mar 31 15:36:10 2009 +0000 +++ b/branchobj.cpp Wed Apr 01 15:06:57 2009 +0000 @@ -1,6 +1,7 @@ #include "branchobj.h" // #include "texteditor.h" +#include "branchitem.h" #include "geometry.h" #include "mapeditor.h" #include "mainwindow.h" @@ -58,8 +59,9 @@ cout << "Destr BranchObj of "<getLastBranch(); if (bo) po->unScroll(); } + */ clear(); } @@ -90,9 +93,6 @@ setChildObj(this); - scrolled=false; - tmpUnscrolled=false; - includeImagesVer=false; includeImagesHor=false; } @@ -110,8 +110,7 @@ for (int i=0; ifloatimage.size(); ++i) addFloatImage (other->floatimage.at(i)); - scrolled=other->scrolled; - tmpUnscrolled=other->tmpUnscrolled; + setVisibility (other->visible); angle=other->angle; @@ -141,39 +140,6 @@ return false; } -int BranchObj::getNum() -{ - if (parObj) - return ((BranchObj*)parObj)->getNum (this); - else - return 0; -} - -int BranchObj::getNum(BranchObj *bo) -{ - return branch.indexOf (bo); -} - -int BranchObj::getFloatImageNum(FloatImageObj *fio) -{ - return floatimage.indexOf(fio); -} - -int BranchObj::countBranches() -{ - return branch.count(); -} - -int BranchObj::countFloatImages() -{ - return floatimage.count(); -} - -int BranchObj::countXLinks() -{ - return xlink.count(); -} - void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off) { // Temporary link to lmo @@ -256,86 +222,9 @@ } } -void BranchObj::unScroll() -{ - if (tmpUnscrolled) resetTmpUnscroll(); - if (scrolled) toggleScroll(); -} - -void BranchObj::toggleScroll() -{ - if (scrolled) - { - scrolled=false; - systemFlags->deactivate("scrolledright"); - for (int i=0; isetVisibility(true); - } else - { - scrolled=true; - systemFlags->activate("scrolledright"); - for (int i=0; isetVisibility(false); - } - calcBBoxSize(); - positionBBox(); - move (absPos.x(), absPos.y() ); - forceReposition(); -} - -bool BranchObj::isScrolled() -{ - return scrolled; -} - -bool BranchObj::hasScrolledParent(BranchObj *start) -{ - // Calls parents recursivly to - // find out, if we are scrolled at all. - // But ignore myself, just look at parents. - - if (this !=start && scrolled) return true; - - BranchObj* bo=(BranchObj*)(parObj); - if (bo) - return bo->hasScrolledParent(start); - else - return false; -} - -void BranchObj::tmpUnscroll() -{ - // Unscroll parent (recursivly) - BranchObj* bo=(BranchObj*)(parObj); - if (bo) bo->tmpUnscroll(); - - // Unscroll myself - if (scrolled) - { - tmpUnscrolled=true; - systemFlags->activate("tmpUnscrolledright"); - toggleScroll(); - } -} - -void BranchObj::resetTmpUnscroll() -{ - // Unscroll parent (recursivly) - BranchObj* bo=(BranchObj*)(parObj); - if (bo) - bo->resetTmpUnscroll(); - - // Unscroll myself - if (tmpUnscrolled) - { - tmpUnscrolled=false; - systemFlags->deactivate("tmpUnscrolledright"); - toggleScroll(); - } -} - void BranchObj::setVisibility(bool v, int toDepth) { + BranchItem *bi=(BranchItem*)treeItem; if (depth <= toDepth) { frame->setVisibility(v); @@ -343,7 +232,6 @@ systemFlags->setVisibility(v); standardFlags->setVisibility(v); LinkableMapObj::setVisibility (v); - int i; for (i=0; isetVisibility (v); @@ -351,7 +239,7 @@ xlink.at(i)->setVisibility (); // Only change children, if I am not scrolled - if (!scrolled && (depth < toDepth)) + if (! bi->isScrolled() && (bi->depth() < toDepth)) { // Now go recursivly through all children for (i=0; i0) + if (treeItem->imageCount()>0) { for (int i=0; ihasScrolledParent((BranchItem*)treeItem)) setVisibility (false); else setVisibility (true); @@ -638,14 +526,14 @@ QString s,a; QString scrolledAttr; - if (scrolled) + if ( ((BranchItem*)treeItem)->isScrolled() ) scrolledAttr=attribut ("scrolled","yes"); else scrolledAttr=""; // save area, if not scrolled QString areaAttr; - if (!((BranchObj*)(parObj))->isScrolled() ) + if (!((BranchItem*) (treeItem->parent()) )->isScrolled() ) { areaAttr= attribut("x1",QString().setNum(absPos.x()-offset.x())) + @@ -658,7 +546,7 @@ // Providing an ID for a branch makes export to XHTML easier QString idAttr; - if (countXLinks()>0) + if (treeItem->xlinkCount()>0) idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model else idAttr=""; @@ -744,12 +632,6 @@ return xlink.at(i); } -int BranchObj::countXLink() -{ - return xlink.count(); -} - - BranchObj* BranchObj::XLinkTargetAt (int i) { if (i>=0 && ihasScrolledParent((BranchItem*)treeItem) ) newfi->setVisibility (false); else newfi->setVisibility(visible); @@ -821,7 +703,7 @@ FloatImageObj *newfi=new FloatImageObj (scene,this); floatimage.append (newfi); newfi->copy (fio); - if (hasScrolledParent(this) ) + if (((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) ) newfi->setVisibility (false); else newfi->setVisibility(visible); @@ -893,10 +775,12 @@ newbo->setParObj(this); newbo->setDefAttr(NewBranch); newbo->setHeading ("new"); - if (scrolled) + /* FIXME-2 treeItem not set yet!!! + if ( ((BranchItem*)treeItem)->isScrolled() ) newbo->setVisibility (false); else newbo->setVisibility(visible); + */ newbo->updateLink(); requestReposition(); return newbo; @@ -909,7 +793,7 @@ newbo->copy(bo); newbo->setParObj(this); newbo->setDefAttr(MovedBranch); - if (scrolled) + if ( ((BranchItem*)treeItem)->isScrolled() ) newbo->setVisibility (false); else newbo->setVisibility(bo->visible); @@ -924,7 +808,8 @@ bo->setParObj (this); bo->depth=depth+1; bo->setDefAttr(MovedBranch); - if (scrolled) tmpUnscroll(); + BranchItem *bi=(BranchItem*)treeItem; + if ( bi->isScrolled() ) bi->tmpUnscroll(); //setLastSelectedBranch (bo); //FIXME-3 needed? return bo; } @@ -958,14 +843,16 @@ bo->setParObj (this); bo->depth=depth+1; bo->setDefAttr (MovedBranch); - if (scrolled) tmpUnscroll(); + BranchItem *bi=(BranchItem*)treeItem; + if ( bi->isScrolled() ) bi->tmpUnscroll(); //setLastSelectedBranch (bo); //FIXME-3 needed? qSort (branch.begin(),branch.end(), isAbove); return bo; } -void BranchObj::removeBranchHere(BranchObj* borem) +void BranchObj::removeBranchHere(BranchObj* borem) // FIXME-1 getNum no longer available { +/* // This removes the branch bo from list, but // inserts its children at the place of bo BranchObj *bo; @@ -977,6 +864,7 @@ bo=borem->getLastBranch(); } removeBranch (borem); + */ } void BranchObj::removeChildren() @@ -1084,9 +972,10 @@ return NULL; } -void BranchObj::sortChildren() +void BranchObj::sortChildren() //FIXME-1 { - int childCount=branch.count(); +/* + int childCount=branch.count(); int curChildIndex; bool madeChanges=false; do @@ -1102,6 +991,7 @@ } } }while(madeChanges); +*/ } @@ -1206,7 +1096,7 @@ } } - if (scrolled) return; + if ( ((BranchItem*)treeItem)->isScrolled() ) return; // Set reference point for alignment of children QPointF ref2; @@ -1301,7 +1191,7 @@ { QRectF r=bbox; - if (scrolled) return r; + if ( ((BranchItem*)treeItem)->isScrolled() ) return r; for (int i=0; iisHidden()) @@ -1332,7 +1222,7 @@ bboxTotal.setY(bbox.y() ); // if branch is scrolled, ignore children, but still consider floatimages - if (scrolled) + if ( ((BranchItem*)treeItem)->isScrolled() ) { bboxTotal.setWidth (bbox.width()); bboxTotal.setHeight(bbox.height());