# HG changeset patch # User insilmaril # Date 1240488931 0 # Node ID ed5b407975b3dc4046e86ff9b2219f54c3be59ad # Parent db0ec4bcf41629a0fe73a5a0cb6e18142c012dd4 more data in Tree, less in Map diff -r db0ec4bcf416 -r ed5b407975b3 branchitem.cpp --- a/branchitem.cpp Mon Apr 20 10:42:05 2009 +0000 +++ b/branchitem.cpp Thu Apr 23 12:15:31 2009 +0000 @@ -307,3 +307,17 @@ return (BranchObj*)lmo; } +BranchObj* BranchItem::createMapObj(QGraphicsScene *scene) +{ + // Initialize BranchObj, order of things is important... + cout << "BI::createMO scene="<setParObj(parent()->getLMO() ); + newbo->setTreeItem (this); + newbo->setDefAttr(BranchObj::NewBranch); + //newbo->updateLink(); + + lmo=newbo; + return newbo; +} + diff -r db0ec4bcf416 -r ed5b407975b3 branchitem.h --- a/branchitem.h Mon Apr 20 10:42:05 2009 +0000 +++ b/branchitem.h Thu Apr 23 12:15:31 2009 +0000 @@ -3,8 +3,10 @@ #include "treeitem.h" + class QString; class BranchObj; +class QGraphicsScene; class BranchItem:public TreeItem { @@ -38,6 +40,7 @@ virtual TreeItem* findID (QString sid); //! search map for object with ID string BranchObj* getBranchObj(); + BranchObj* createMapObj(QGraphicsScene *scene); //! Create classic object in GraphicsView }; #endif diff -r db0ec4bcf416 -r ed5b407975b3 branchobj.cpp --- a/branchobj.cpp Mon Apr 20 10:42:05 2009 +0000 +++ b/branchobj.cpp Thu Apr 23 12:15:31 2009 +0000 @@ -22,23 +22,22 @@ // cout << "Const BranchObj ()\n"; setParObj (this); init(); - depth=-1; } -BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s) +BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s)// FIXME-3 needed at all? { -// cout << "Const BranchObj (s) called from MapCenterObj (s)\n"; +// cout << "Const BranchObj (s) \n"; parObj=NULL; scene=s; + init(); } -BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s) +BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)// FIXME-3 needed at all? { // cout << "Const BranchObj (s,p)\n"; scene=s; setParObj (p); - depth=p->getDepth()+1; - if (depth==1) + if (treeItem->depth()==1) // Calc angle to mapCenter if I am a mainbranch // needed for reordering the mainbranches clockwise // around mapcenter @@ -120,7 +119,7 @@ void BranchObj::clear() { - setVisibility (true); + //setVisibility (true); //FIXME-4 needed? while (!floatimage.isEmpty()) delete floatimage.takeFirst(); @@ -149,14 +148,14 @@ parObjTmpBuf=parObj; // ignore mapcenter and mainbranch - if (lmo->getDepth()<2) off=0; + if (treeItem->depth()<2) off=0; if (off==0) link2ParPos=false; else link2ParPos=true; parObj=o; - depth=parObj->getDepth()+1; + // FIXME-2 depth=parObj->getDepth()+1; // setLinkStyle calls updateLink, only set it once if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle()); @@ -165,7 +164,7 @@ // Usually the positioning would be done by reposition(), // but then also the destination branch would "Jump" around... // Better just do it approximately - if (depth==1) + if (treeItem->depth()==1) { // new parent is the mapcenter itself QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(), @@ -213,7 +212,7 @@ link2ParPos=false; parObj=parObjTmpBuf; parObjTmpBuf=NULL; - depth=parObj->getDepth()+1; + //FIXME-2 depth=parObj->getDepth()+1; setLinkStyle (getDefLinkStyle() ); updateLink(); } @@ -222,7 +221,7 @@ void BranchObj::setVisibility(bool v, int toDepth) { BranchItem *bi=(BranchItem*)treeItem; - if (depth <= toDepth) + if (bi->depth() <= toDepth) { frame->setVisibility(v); heading->setVisibility(v); @@ -669,7 +668,7 @@ void BranchObj::setDefAttr (BranchModification mod) { int fontsize; - switch (depth) + switch (treeItem->depth()) { case 0: fontsize=16; break; case 1: fontsize=12; break; @@ -688,7 +687,7 @@ calcBBoxSize(); } -BranchObj* BranchObj::addBranch() +BranchObj* BranchObj::addBranch() // FIXME-3 still needed? { BranchObj* newbo=new BranchObj(scene,this); newbo->setParObj(this); @@ -724,7 +723,7 @@ { //FIXME-1 branch.append (bo); bo->setParObj (this); - bo->depth=depth+1; + //FIXME-2 bo->depth=depth+1; bo->setDefAttr(MovedBranch); BranchItem *bi=(BranchItem*)treeItem; if ( bi->isScrolled() ) bi->tmpUnscroll(); @@ -757,14 +756,14 @@ savePosInAngle(); // Add new bo and resort branches bo->angle=pos-0.5; - //FIXME-1 branch.append (bo); + //FIXME-4 branch.append (bo); bo->setParObj (this); - bo->depth=depth+1; + //FIXME-2 bo->depth=depth+1; bo->setDefAttr (MovedBranch); BranchItem *bi=(BranchItem*)treeItem; if ( bi->isScrolled() ) bi->tmpUnscroll(); //setLastSelectedBranch (bo); //FIXME-3 needed? - //FIXME-1 qSort (branch.begin(),branch.end(), isAbove); + //FIXME-2 qSort (branch.begin(),branch.end(), isAbove); return bo; } @@ -785,7 +784,7 @@ */ } -void BranchObj::removeChildren() +void BranchObj::removeChildren() // FIXME-3 not needed here { clear(); } @@ -914,6 +913,7 @@ else return NULL; +/* FIXME-1 // Create new pointer to myself at dst if (pos<0||dst->getDepth()==0) { @@ -934,22 +934,25 @@ } else return NULL; } +*/ } void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf) { qreal th = bboxTotal.height(); + int depth=treeItem->depth(); // TODO testing /* - QString h=QString (treeItem->depth(),' '); + + QString h=QString (depth,' '); h+=treeItem->getHeading(); h+=QString (15,' '); h.truncate (15); QPointF pp; if (parObj) pp=parObj->getChildPos(); cout << "BO::alignRelTo "; cout<getDepth()+1; init(); } diff -r db0ec4bcf416 -r ed5b407975b3 linkablemapobj.cpp --- a/linkablemapobj.cpp Mon Apr 20 10:42:05 2009 +0000 +++ b/linkablemapobj.cpp Thu Apr 23 12:15:31 2009 +0000 @@ -59,7 +59,6 @@ { model=NULL; - depth=-1; childObj=NULL; parObj=NULL; parObjTmpBuf=NULL; @@ -212,6 +211,7 @@ //return UndefinedStyle; } Style ls=model->getMapLinkStyle(); + int depth=treeItem->depth(); if (depth==0) return UndefinedStyle; switch (ls) { @@ -360,7 +360,7 @@ break; default: break; - } // switch (style) + } } QColor LinkableMapObj::getLinkColor() @@ -577,7 +577,7 @@ num=part.right(part.length() - 3); if (typ=="mc:") { - if (depth>0) + if (treeItem->depth()>0) return false; // in a subtree there is no center else break; @@ -621,11 +621,6 @@ return orientation; } -int LinkableMapObj::getDepth() -{ - return depth; -} - QPointF LinkableMapObj::getRandPos() { // Choose a random position with given distance to parent: diff -r db0ec4bcf416 -r ed5b407975b3 linkablemapobj.h --- a/linkablemapobj.h Mon Apr 20 10:42:05 2009 +0000 +++ b/linkablemapobj.h Thu Apr 23 12:15:31 2009 +0000 @@ -19,7 +19,7 @@ */ class LinkableMapObj:public QObject, public MapObj { - Q_OBJECT + Q_OBJECT // FIXME-3 really needed here? public: /*! Orientation of an object depends on the position relative to the parent */ enum Orientation { @@ -101,7 +101,6 @@ QPointF getChildPos(); // returns pos where children dock QPointF getParPos(); // returns pos where parents dock Orientation getOrientation(); // get orientation - virtual int getDepth(); // return depth virtual QPointF getRandPos(); // make randomised position virtual void reposition(); @@ -126,11 +125,10 @@ VymModel* model; Orientation orientation; qreal linkwidth; // width of a link - int depth; // depth: undef=-1 mapCenter=0 branch=1..n QRectF bboxTotal; // bounding box including children LinkableMapObj* childObj; - LinkableMapObj* parObj; + LinkableMapObj* parObj; // FIXME-2 really still needed? Better get from TreeItem LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent qreal bottomlineY; // vertical offset of dockpos to pos diff -r db0ec4bcf416 -r ed5b407975b3 mainwindow.cpp --- a/mainwindow.cpp Mon Apr 20 10:42:05 2009 +0000 +++ b/mainwindow.cpp Thu Apr 23 12:15:31 2009 +0000 @@ -3070,7 +3070,7 @@ void Main::editUpperBranch() { VymModel *m=currentModel(); - if (m) m->selectUpperBranch(); + if (m) m->selectUpperBranch(); // FIXME-0 check also lower... this probably should go into view... } void Main::editLowerBranch() diff -r db0ec4bcf416 -r ed5b407975b3 mapcenterobj.cpp --- a/mapcenterobj.cpp Mon Apr 20 10:42:05 2009 +0000 +++ b/mapcenterobj.cpp Thu Apr 23 12:15:31 2009 +0000 @@ -45,7 +45,6 @@ // TODO this should be done in TextObj later... //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0"); //heading->setFont(font); - depth=0; setDefAttr(MovedBranch); frame->setFrameType (FrameObj::Rectangle); diff -r db0ec4bcf416 -r ed5b407975b3 mapeditor.cpp --- a/mapeditor.cpp Mon Apr 20 10:42:05 2009 +0000 +++ b/mapeditor.cpp Thu Apr 23 12:15:31 2009 +0000 @@ -719,7 +719,7 @@ } } else { // selection != a FloatObj - if (lmosel->getDepth()==0) //FIXME-1 also moved mapcenters could be linked, but not working here... + if (seli->depth()==0) //FIXME-1 also moved mapcenters could be linked, but not working here... { // Move MapCenter if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) @@ -729,7 +729,7 @@ model->updateRelPositions(); } else { - if (lmosel->getDepth()==1) + if (seli->depth()==1) { // Move mainbranch lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); @@ -797,13 +797,12 @@ void MapEditor::mouseReleaseEvent(QMouseEvent* e) { QPointF p = mapToScene(e->pos()); - TreeItem *dsti=findMapItem(p, NULL); - LinkableMapObj* dst=NULL; - if (dsti) dst=dsti->getLMO(); //FIXME-2 get rid of dst... - TreeItem *seli=model->getSelectedItem(); LinkableMapObj *lmosel=seli->getLMO(); // FIXME-2 get rid of lmosel + TreeItem *dsti=findMapItem(p, seli); + LinkableMapObj* dst=NULL; + if (dsti) dst=dsti->getLMO(); //FIXME-2 get rid of dst... // Have we been picking color? @@ -905,37 +904,36 @@ QString preSelStr=model->getSelectString(lmosel); copyingObj=false; - if (dsti ) + if (dsti && dsti->isBranchLikeType() ) { // We have a destination, relink to that BranchObj* bsel=model->getSelectedBranchObj(); - TreeItem * tisel=model->getSelectedItem(); BranchObj* bdst=(BranchObj*)dst; - TreeItem* tidst=dst->getTreeItem(); QString preParStr=model->getSelectString (bsel->getParObj()); - QString preNum=QString::number (tisel->num(),10); + QString preNum=QString::number (seli->num(),10); QString preDstParStr; if (e->state() & Qt::ShiftModifier && dst->getParObj()) { // Link above dst preDstParStr=model->getSelectString (dst->getParObj()); - bsel->linkTo ( (BranchObj*)(bdst->getParObj()), tidst->num()); + bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()); } else if (e->state() & Qt::ControlModifier && dst->getParObj()) { // Link below dst preDstParStr=model->getSelectString (dst->getParObj()); - bsel->linkTo ( (BranchObj*)(bdst->getParObj()), tidst->num()+1); + bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()+1); } else { // Append to dst preDstParStr=model->getSelectString(dst); bsel->linkTo (bdst,-1); - if (dst->getDepth()==0) bsel->move (savePos); + model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti); + if (dsti->depth()==0) bsel->move (savePos); } QString postSelStr=model->getSelectString(lmosel); - QString postNum=QString::number (tisel->num(),10); + QString postNum=QString::number (seli->num(),10); QString undoCom="linkTo (\""+ preParStr+ "\"," + preNum +"," + @@ -955,7 +953,7 @@ { // No destination, undo temporary move - if (lmosel->getDepth()==1) + if (seli->depth()==1) { cout << "ME::releaseMouse d=1\n"; // FIXME_1 better use depth // The select string might be different _after_ moving around. @@ -974,7 +972,7 @@ } // Draw the original link, before selection was moved around - if (settings.value("/animation/use",false).toBool() && lmosel->getDepth()>1) + if (settings.value("/animation/use",false).toBool() && seli->depth()>1) { lmosel->setRelPos(); // calc relPos first for starting point QPointF dst=bi->getBranchObj()->getParObj()->getChildPos(); // FIXME-3 check getBO here... diff -r db0ec4bcf416 -r ed5b407975b3 ornamentedobj.cpp --- a/ornamentedobj.cpp Mon Apr 20 10:42:05 2009 +0000 +++ b/ornamentedobj.cpp Thu Apr 23 12:15:31 2009 +0000 @@ -407,13 +407,13 @@ { QString posAttr; - if (depth==0) + if (treeItem->depth()==0) posAttr= attribut("absPosX",QString().setNum(absPos.x())) + attribut("absPosY",QString().setNum(absPos.y())); else { - if (depth==1 || typeid (*this)==typeid (FloatImageObj)) + if (treeItem->depth()==1 || typeid (*this)==typeid (FloatImageObj)) { if (relPos.x()==0 && relPos.y()==0) setRelPos(); diff -r db0ec4bcf416 -r ed5b407975b3 treeitem.cpp --- a/treeitem.cpp Mon Apr 20 10:42:05 2009 +0000 +++ b/treeitem.cpp Thu Apr 23 12:15:31 2009 +0000 @@ -35,12 +35,14 @@ TreeItem::~TreeItem() { + cout << "Destructor TreeItem\n"; + //if (lmo) delete (lmo); qDeleteAll(childItems); } QString TreeItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) { - qWarning ("TreeItem::saveToDir called directly"); + cout << "TreeItem::saveToDir called directly for ("<getHeading().toStdString()<getTreeItem(); +BranchItem* VymModel::createBranch() +{ + return addNewBranchInt (-2); } TreeItem* VymModel::createImage() //FIXME-2 @@ -2123,7 +2122,7 @@ } -BranchObj* VymModel::addNewBranchInt(int num) +BranchItem* VymModel::addNewBranchInt(int num) { // Depending on pos: // -3 insert in children of parent above selection @@ -2158,6 +2157,8 @@ // save scroll state. If scrolled, automatically select // new branch in order to tmp unscroll parent... + newbo=bi->createMapObj(mapScene); + /* newbo=bo->addBranch(); if (newbo) @@ -2166,63 +2167,70 @@ newbo->setTreeItem (bi); select (bi); } + */ + select (bi); }else if (num==-1) { + /* num=bi->num()+1; bo=(BranchObj*)bo->getParObj(); if (bo) newbo=bo->insertBranch(num); //FIXME-1 VM still missing + */ }else if (num==-3) { + /* num=bi->num(); bo=(BranchObj*)bo->getParObj(); if (bo) newbo=bo->insertBranch(num); //FIXME-1 VM still missing + */ } } - return newbo; + return bi; } -BranchObj* VymModel::addNewBranch(int pos) +BranchItem* VymModel::addNewBranch(int pos) { // Different meaning than num in addNewBranchInt! // -1 add above // 0 add as child // +1 add below - BranchObj *bo = getSelectedBranchObj(); //FIXME-2 - BranchObj *newbo=NULL; - - if (bo) + BranchItem *newbi=NULL; + BranchItem *selbi=getSelectedBranchItem(); + + if (selbi) { // FIXME-2 VM do we still need this in model? setCursor (Qt::ArrowCursor); - newbo=addNewBranchInt (pos-2); - - if (newbo) + newbi=addNewBranchInt (pos-2); + + if (newbi) { saveState( - newbo->getTreeItem(), + newbi, "delete ()", - bo->getTreeItem(), + selbi, QString ("addBranch (%1)").arg(pos), - QString ("Add new branch to %1").arg(getObjectName(bo))); + QString ("Add new branch to %1").arg(getObjectName(selbi))); reposition(); // selection.update(); FIXME-3 - latestSelectionString=getSelectString(newbo); + latestSelectionString=getSelectString(newbi); // In Network mode, the client needs to know where the new branch is, // so we have to pass on this information via saveState. // TODO: Get rid of this positioning workaround - QString ps=qpointfToString (newbo->getAbsPos()); + /* FIXME-4 network problem: QString ps=qpointfToString (newbo->getAbsPos()); sendData ("selectLatestAdded ()"); sendData (QString("move %1").arg(ps)); sendSelection(); + */ } } - return newbo; + return newbi; } -BranchObj* VymModel::addNewBranchBefore() //FIXME-2 +BranchItem* VymModel::addNewBranchBefore() //FIXME-2 { /* BranchObj *newbo=NULL; @@ -2258,6 +2266,22 @@ return NULL; } +BranchItem* VymModel::relinkBranch (BranchItem *branch, BranchItem *dst, int pos) +{ + cout << "VM::relinkBranch "<getHeadingStd()<<" to "<getHeadingStd()<<" at pos="<parent(); + BranchItem *dstpi=(BranchItem*)dst->parent(); + if (pos<0) + { + // Append as last branch to dst + branchpi->removeChild (branch->childNum() ); + dst->appendChild (branch); + } + } +} + void VymModel::deleteSelection() { BranchObj *bo = getSelectedBranchObj(); // FIXME-2 VM should not be necessary @@ -2319,7 +2343,7 @@ beginRemoveRows (parentIndex,n,n); removeRows (n,1,parentIndex); endRemoveRows(); - par->removeBranch(bo); // remove from BranchObj lists... + // delete (selbi->getLMO() ); // FIXME-0 selbi is removed implicetely, destructor is called. from there BO is deleted, but somhow still segfaulting :-( select (par); ensureSelectionVisible(); reposition(); @@ -3964,8 +3988,9 @@ rootItem->getBranchObjNum(i)->reposition(); // for positioning heading } -QPolygonF VymModel::shape(BranchObj *bo) -{ +QPolygonF VymModel::shape(BranchObj *bo) //FIXME-4 +{ +/* // Creating (arbitrary) shapes QPolygonF p; @@ -3995,7 +4020,7 @@ <getDepth()>0) + if (bo && bo->getTreeItem()->depth()>0) { AnimPoint ap; ap.setStart (start); @@ -4710,197 +4735,136 @@ void VymModel::selectNextBranchInt() { - // Increase number of branch - BranchItem *selbi=getSelectedBranchItem(); - if (selbi) + BranchItem *bi=getSelectedBranchItem(); + if (bi) { - QString s=getSelectString(); - QString part; - QString typ; - QString num; - - // Where am I? - part=s.section(",",-1); - typ=part.left (3); - num=part.right(part.length() - 3); - - s=s.left (s.length() -num.length()); - - // Go to next lmo - num=QString ("%1").arg(num.toUInt()+1); - - s=s+num; + TreeItem *pi=bi->parent(); + if (bi!=rootItem) + { + int i=bi->num(); + if (ibranchCount() ) + { + // select previous branch with same parent + i++; + select (pi->getBranchNum(i)); + return; + } + } - // Try to select this one - if (select (s)) return; - - // We have no direct successor, - // try to increase the parental number in order to - // find a successor with same depth - - int d=getSelectedBranchItem()->depth(); - int oldDepth=d; - int i; - bool found=false; - bool b; - while (!found && d>0) - { - s=s.section (",",0,d-1); - // replace substring of current depth in s with "1" - part=s.section(",",-1); - typ=part.left (3); - num=part.right(part.length() - 3); - - if (d>1) - { - // increase number of parent - num=QString ("%1").arg(num.toUInt()+1); - s=s.section (",",0,d-2) + ","+ typ+num; - } else - { - // Special case, look at orientation - if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter) // FIXME-3 check access to LMO - num=QString ("%1").arg(num.toUInt()+1); - else - num=QString ("%1").arg(num.toUInt()-1); - s=typ+num; - } - - if (select (s)) - // pad to oldDepth, select the first branch for each depth - for (i=d;ibranchCount()>0) - s+=",bo:0"; - else - break; - } else - break; - } - - // try to select the freshly built string - found=select(s); - d--; - } - return; - } -} - -void VymModel::selectPrevBranchInt() -{ - // Decrease number of branch - if (selectionType()==TreeItem::Branch) - { - QString s=getSelectString(); - QString part; - QString typ; - QString num; - - // Where am I? - part=s.section(",",-1); - typ=part.left (3); - num=part.right(part.length() - 3); - - s=s.left (s.length() -num.length()); - - int n=num.toInt()-1; - - // Go to next lmo - num=QString ("%1").arg(n); - s=s+num; - - // Try to select this one - if (n>=0 && select (s)) return; - - // We have no direct precessor, - // try to decrease the parental number in order to - // find a precessor with same depth - - int d=getSelectedBranchItem()->depth(); - int oldDepth=d; - int i; - bool found=false; - bool b; - while (!found && d>0) - { - s=s.section (",",0,d-1); - // replace substring of current depth in s with "1" - part=s.section(",",-1); - typ=part.left (3); - num=part.right(part.length() - 3); - - if (d>1) - { - // decrease number of parent - num=QString ("%1").arg(num.toInt()-1); - s=s.section (",",0,d-2) + ","+ typ+num; - } else - { - // Special case, look at orientation - if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter) // FIXME-3 check access to LMO - num=QString ("%1").arg(num.toInt()-1); - else - num=QString ("%1").arg(num.toInt()+1); - s=typ+num; - } - - if (select(s)) - // pad to oldDepth, select the last branch for each depth - for (i=d;ibranchCount()>0) - s+=",bo:"+ QString ("%1").arg( getSelectedItem()->branchCount()-1 ); - else - break; - else - break; - } - - // try to select the freshly built string - found=select(s); - d--; - } - return; - } -} - -void VymModel::selectUpperBranch() -{ - if (selection.isBlocked() ) return; - - BranchItem *bi=getSelectedBranchItem(); - if (bi && bi->getType()==TreeItem::Branch) - { - if (bi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter) //FIXME-3 check getBO - selectPrevBranchInt(); - else - if (bi->depth()==1) - selectNextBranchInt(); - else - selectPrevBranchInt(); } } +void VymModel::selectPrevBranchInt() +{ + + BranchItem *bi=getSelectedBranchItem(); + if (bi) + { + BranchItem *pi=(BranchItem*)bi->parent(); + if (bi!=rootItem) + { + int i=bi->num(); + if (i>0) + { + // select previous branch with same parent + bi=pi->getBranchNum(i-1); + select (bi); + return; + } + bi=pi; + while (bi->branchCount() >0) + bi=bi->getLastBranch(); + select (bi); + + // Try to select last branch in parent pi2 previous to own parent pi + /* + TreeItem *pi2=pi->parent(); + if (pi2) + { + int j=pi->num(); + if (pi2->) + } + */ + } + } +} + +void VymModel::selectAboveBranchInt() +{ + BranchItem *bi=getSelectedBranchItem(); + if (bi) + { + BranchItem *newbi=NULL; + BranchItem *pi=(BranchItem*)bi->parent(); + int i=bi->num(); + if (i>0) + { + // goto previous branch with same parent + newbi=pi->getBranchNum(i-1); + while (newbi->branchCount() >0 ) + newbi=newbi->getLastBranch(); + } + else + newbi=pi; + if (newbi==rootItem) + // already at top branch (resp. mapcenter) + return; + select (newbi); + } +} + +void VymModel::selectBelowBranchInt() +{ + BranchItem *bi=getSelectedBranchItem(); + if (bi) + { + BranchItem *newbi=NULL; + + if (bi->branchCount() >0) + newbi=bi->getFirstBranch(); + else + { + BranchItem *pi; + int i; + while (!newbi) + { + pi=(BranchItem*)bi->parent(); + i=bi->num(); + if (pi->branchCount()-1 > i) + { + newbi=(BranchItem*)pi->getBranchNum(i+1); + //done... + break; + } + else + // look for siblings of myself + // or parent, or parent of parent... + bi=pi; + if (bi==rootItem) + // already at end + return; + } + } + select (newbi); + } +} + +void VymModel::selectUpperBranch() +{ + if (selection.isBlocked() ) return; + + BranchItem *bi=getSelectedBranchItem(); + if (bi && bi->isBranchLikeType()) + selectAboveBranchInt(); +} + void VymModel::selectLowerBranch() { if (selection.isBlocked() ) return; BranchItem *bi=getSelectedBranchItem(); - if (bi && bi->getType()==TreeItem::Branch) - { - if (bi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter) //FIXME-3 check getBO - selectNextBranchInt(); - else - if (bi->depth()==1) - selectPrevBranchInt(); - else - selectNextBranchInt(); - } + if (bi && bi->isBranchLikeType()) + selectBelowBranchInt(); } diff -r db0ec4bcf416 -r ed5b407975b3 vymmodel.h --- a/vymmodel.h Mon Apr 20 10:42:05 2009 +0000 +++ b/vymmodel.h Thu Apr 23 12:15:31 2009 +0000 @@ -309,7 +309,7 @@ MapCenterObj* getLastMapCenter(); //!< get last added MapCenter, used for context menu private: - BranchObj* addNewBranchInt(int); // pos allows to add above/below selection + BranchItem* addNewBranchInt(int); // pos allows to add above/below selection public: /*! \Add new branch @@ -318,8 +318,9 @@ 0 as child of selection 1 below selection */ - BranchObj* addNewBranch(int pos); - BranchObj* addNewBranchBefore(); //!< Insert branch between selection and its parent + BranchItem* addNewBranch(int pos); + BranchItem* addNewBranchBefore(); //!< Insert branch between selection and its parent + BranchItem* relinkBranch (BranchItem* branch, BranchItem* dst, int pos =-1); //! Relink branch to dst at position pos void deleteSelection(); //!< Delete selection void deleteKeepChildren(); //!< remove branch, but keep children void deleteChildren(); //!< keep branch, but remove children @@ -558,7 +559,9 @@ private: void selectNextBranchInt(); // Increment number of branch - void selectPrevBranchInt(); // Decrement number of branch + void selectPrevBranchInt(); //! Select the branch which would be above in vymmap view + void selectAboveBranchInt(); //! Select the branch which would be above current selection in TreeView + void selectBelowBranchInt(); // Increment number of branch public: void selectUpperBranch(); void selectLowerBranch();