diff -r 914f330b6aa8 -r 25a77484ec72 branchobj.cpp --- a/branchobj.cpp Thu Apr 02 09:57:47 2009 +0000 +++ b/branchobj.cpp Tue Apr 07 16:15:53 2009 +0000 @@ -1,17 +1,16 @@ #include "branchobj.h" -// #include "texteditor.h" #include "branchitem.h" #include "geometry.h" #include "mapeditor.h" #include "mainwindow.h" #include "misc.h" -class TextEditor; +//class TextEditor; //FIXME-3 -extern TextEditor *textEditor; -extern Main *mainWindow; -extern FlagRowObj *standardFlagsDefault; +//extern TextEditor *textEditor; +//extern Main *mainWindow; +//extern FlagRowObj *standardFlagsDefault; ///////////////////////////////////////////////////////////////// @@ -57,7 +56,7 @@ model->stopAnimation (this); } - cout << "Destr BranchObj of "<getHeading().toStdString()<<")"<treeItem->branchCount(); ++i) // Make deep copy of b // Because addBranch again calls copy for the children, // Those will get a deep copy, too addBranch(other->branch.at(i) ); +*/ for (int i=0; ifloatimage.size(); ++i) addFloatImage (other->floatimage.at(i)); @@ -127,9 +127,6 @@ while (!xlink.isEmpty()) delete xlink.takeFirst(); - - while (!branch.isEmpty()) - delete branch.takeFirst(); } bool isAbove (BranchObj* a, BranchObj *b) @@ -243,7 +240,7 @@ { // Now go recursivly through all children for (i=0; ibranchCount(); ++i) - branch.at(i)->setVisibility (v,toDepth); + treeItem->getBranchObjNum(i)->setVisibility (v,toDepth); } } // depth <= toDepth requestReposition(); @@ -273,7 +270,14 @@ { setColor (col); for (int i=0; ibranchCount(); ++i) - branch.at(i)->setColorSubtree(col); + treeItem->getBranchObjNum(i)->setColorSubtree(col); +} + +void BranchObj::updateContentSize() +{ + calcBBoxSize(); + positionBBox(); + requestReposition(); } void BranchObj::positionContents() @@ -300,7 +304,7 @@ { OrnamentedObj::moveBy (x,y); for (int i=0; ibranchCount(); ++i) - branch.at(i)->moveBy (x,y); + treeItem->getBranchObjNum(i)->moveBy (x,y); positionBBox(); } @@ -329,12 +333,12 @@ QSizeF heading_r=heading->getSize(); qreal heading_w=(qreal) heading_r.width() ; qreal heading_h=(qreal) heading_r.height() ; - QSizeF sysflags_r=systemFlags->getSize(); - qreal sysflags_h=sysflags_r.height(); - qreal sysflags_w=sysflags_r.width(); - QSizeF stanflags_r=standardFlags->getSize(); - qreal stanflags_h=stanflags_r.height(); - qreal stanflags_w=stanflags_r.width(); + QSizeF sysflags_r; //FIXME-1 =systemFlags->getSize(); + qreal sysflags_h=0;//sysflags_r.height(); + qreal sysflags_w=0;//sysflags_r.width(); + QSizeF stanflags_r; //FIXME-1 =standardFlags->getSize(); + qreal stanflags_h=0; //stanflags_r.height(); + qreal stanflags_w=0; //stanflags_r.width(); qreal w; qreal h; @@ -426,7 +430,7 @@ LinkableMapObj *lmo; for (int i=0; ibranchCount(); ++i) { - lmo=branch.at(i)->findMapObj(p, excludeLMO); + lmo=treeItem->getBranchObjNum(i)->findMapObj(p, excludeLMO); if (lmo != NULL) return lmo; } @@ -452,7 +456,7 @@ LinkableMapObj *lmo; for (int i=0; ibranchCount(); ++i) { - lmo=branch.at(i)->findID (sid); + lmo=treeItem->getBranchObjNum(i)->findID (sid); if (lmo != NULL) return lmo; } @@ -472,54 +476,22 @@ return NULL; } -void BranchObj::setHeading(QString s) +void BranchObj::updateHeading() { - heading->setText(s); // set new heading - calcBBoxSize(); // recalculate bbox - positionBBox(); // rearrange contents - requestReposition(); -} - -void BranchObj::setHideTmp (HideTmpMode mode) -{ - if (mode==HideExport && (hideExport|| hasHiddenExportParent() ) ) + if (!treeItem) { - // Hide stuff according to hideExport flag and parents - setVisibility (false); - hidden=true; - }else - { - // Do not hide, but still take care of scrolled status - if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem)) - setVisibility (false); - else - setVisibility (true); - hidden=false; - } - - // And take care of my children - for (int i=0; ibranchCount(); ++i) - branch.at(i)->setHideTmp (mode); -} - -bool BranchObj::hasHiddenExportParent() -{ - // Calls parents recursivly to - // find out, if we or parents are temp. hidden - - if (hidden || hideExport) return true; - - BranchObj* bo=(BranchObj*)parObj; - if (bo) - return bo->hasHiddenExportParent(); - else - return false; + qWarning ("BranchObj::udpateHeading treeItem==NULL"); + return; + } + cout << "BO::updateHeading: "<getHeading().toStdString()<setText (treeItem->getHeading() ); + updateContentSize(); } QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) { // Cloudy stuff can be hidden during exports - if (hidden) return ""; + // FIXME-1 if (hidden) return ""; // Update of note is usually done while unselecting a branch // if (isNoteInEditor) getNoteFromTextEditor(); //FIXME-2 moved to TreeItem @@ -560,7 +532,7 @@ incIndent(); // save heading - s+=valueElement("heading", getHeading(), + s+=valueElement("heading", treeItem->getHeading(), attribut ("textColor",QColor(heading->getColor()).name())); // Save frame @@ -580,7 +552,7 @@ // Save branches for (int i=0; ibranchCount(); ++i) - s+=branch.at(i)->saveToDir(tmpdir,prefix,offset); + s+=treeItem->getBranchObjNum(i)->saveToDir(tmpdir,prefix,offset); // Save XLinks QString ol; // old link @@ -594,7 +566,7 @@ ol=cl; } else { - qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading())); + qWarning (QString("Ignoring of duplicate xLink in %1").arg(treeItem->getHeading())); } } @@ -743,7 +715,7 @@ { // Save position in angle for (int i=0; ibranchCount(); ++i) - branch.at(i)->angle=i; + treeItem->getBranchObjNum(i)->angle=i; } void BranchObj::setDefAttr (BranchModification mod) @@ -771,10 +743,9 @@ BranchObj* BranchObj::addBranch() { BranchObj* newbo=new BranchObj(scene,this); - branch.append (newbo); + //FIXME-1 branch.append (newbo); newbo->setParObj(this); newbo->setDefAttr(NewBranch); - newbo->setHeading ("new"); /* FIXME-2 treeItem not set yet!!! if ( ((BranchItem*)treeItem)->isScrolled() ) newbo->setVisibility (false); @@ -789,7 +760,7 @@ BranchObj* BranchObj::addBranch(BranchObj* bo) { BranchObj* newbo=new BranchObj(scene,this); - branch.append (newbo); + //FIXME-1 branch.append (newbo); newbo->copy(bo); newbo->setParObj(this); newbo->setDefAttr(MovedBranch); @@ -804,7 +775,7 @@ BranchObj* BranchObj::addBranchPtr(BranchObj* bo) { - branch.append (bo); + //FIXME-1 branch.append (bo); bo->setParObj (this); bo->depth=depth+1; bo->setDefAttr(MovedBranch); @@ -820,7 +791,7 @@ // Add new bo and resort branches BranchObj *newbo=addBranch (); newbo->angle=pos-0.5; - qSort (branch.begin(),branch.end(), isAbove); + //FIXME-1 qSort (branch.begin(),branch.end(), isAbove); return newbo; } @@ -830,7 +801,7 @@ // Add new bo and resort branches bo->angle=pos-0.5; BranchObj *newbo=addBranch (bo); - qSort (branch.begin(),branch.end(), isAbove); + //FIXME-1 qSort (branch.begin(),branch.end(), isAbove); return newbo; } @@ -839,14 +810,14 @@ savePosInAngle(); // Add new bo and resort branches bo->angle=pos-0.5; - branch.append (bo); + //FIXME-1 branch.append (bo); bo->setParObj (this); bo->depth=depth+1; bo->setDefAttr (MovedBranch); BranchItem *bi=(BranchItem*)treeItem; if ( bi->isScrolled() ) bi->tmpUnscroll(); //setLastSelectedBranch (bo); //FIXME-3 needed? - qSort (branch.begin(),branch.end(), isAbove); + //FIXME-1 qSort (branch.begin(),branch.end(), isAbove); return bo; } @@ -872,8 +843,9 @@ clear(); } -void BranchObj::removeBranch(BranchObj* bo) +void BranchObj::removeBranch(BranchObj* bo) // FIXME-1 not needed here { +/* // if bo is not in branch remove returns false, we // don't care... @@ -885,10 +857,12 @@ } else qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n"); requestReposition(); + */ } -void BranchObj::removeBranchPtr(BranchObj* bo) +void BranchObj::removeBranchPtr(BranchObj* bo) // FIXME-1 not needed here { +/* int i=branch.indexOf(bo); if (i>=0) @@ -896,6 +870,7 @@ else qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n"); requestReposition(); +*/ } bool BranchObj::canMoveBranchUp() @@ -911,17 +886,19 @@ return false; } -BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist +BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // FIXME-1 { +/* savePosInAngle(); int i=branch.indexOf(bo1); if (i>0) { // -1 if bo1 not found - branch.at(i)->angle--; - branch.at(i-1)->angle++; + treeItem->getBranchObjNum(i)->angle--; + treeItem->getBranchObjNum(i-1)->angle++; qSort (branch.begin(),branch.end(), isAbove); - return branch.at(i); + return treeItem->getBranchObjNum(i); } else +*/ return NULL; } @@ -938,19 +915,21 @@ return false; } -BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist +BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// FIXME-1 { +/* savePosInAngle(); int i=branch.indexOf(bo1); int j; if (i branchCount()) { j = i+1; - branch.at(i)->angle++; - branch.at(j)->angle--; + treeItem->getBranchObjNum(i)->angle++; + treeItem->getBranchObjNum(j)->angle--; qSort (branch.begin(),branch.end(), isAbove); - return branch.at(i); + return treeItem->getBranchObjNum(i); } else +*/ return NULL; } @@ -964,8 +943,8 @@ { madeChanges=false; for(curChildIndex=1;curChildIndexgetBranchObjNum(curChildIndex); + BranchObj* prevChild=(BranchObj*)treeItem->getBranchObjNum(curChildIndex-1); if(prevChild->heading->text().compare(curChild->heading->text())>0) { this->moveBranchUp(curChild); @@ -1015,41 +994,45 @@ qreal th = bboxTotal.height(); // TODO testing /* + QString h=QString (treeItem->depth(),' '); + h+=treeItem->getHeading(); + h+=QString (15,' '); + h.truncate (15); QPointF pp; if (parObj) pp=parObj->getChildPos(); - cout << "BO::alignRelTo "<