# HG changeset patch # User insilmaril # Date 1253707194 0 # Node ID cf634bbf9e045b6b9aca4953d0ce25e39e10fc80 # Parent 6b0a5f4923d336b5690a39db2f841578f1b821c2 Fixes for moving branches diff -r 6b0a5f4923d3 -r cf634bbf9e04 branchitem.cpp --- a/branchitem.cpp Thu Sep 17 09:41:09 2009 +0000 +++ b/branchitem.cpp Wed Sep 23 11:59:54 2009 +0000 @@ -236,21 +236,22 @@ // find out, if we are scrolled at all. // But ignore myself, just look at parents. - //cout << "BI::hasScrolledParent this="<isBranchLikeType() ) + if (bi && bi!=rootItem ) return bi->hasScrolledParent(start); else return false; } -void BranchItem::tmpUnscroll() +bool BranchItem::tmpUnscroll() { + bool result=false; + // Unscroll parent (recursivly) BranchItem * pi=(BranchItem*)parentItem; - if (pi && pi->isBranchLikeType() ) pi->tmpUnscroll(); + if (pi && pi->isBranchLikeType() ) result=pi->tmpUnscroll(); // Unscroll myself if (scrolled) @@ -259,14 +260,18 @@ systemFlags.activate("system-tmpUnscrolledRight"); toggleScroll(); model->emitDataHasChanged (this); + result=true; } + return result; } -void BranchItem::resetTmpUnscroll() +bool BranchItem::resetTmpUnscroll() { + bool result=false; + // Unscroll parent (recursivly) BranchItem * pi=(BranchItem*)parentItem; - if (pi && pi->isBranchLikeType() ) pi->resetTmpUnscroll(); + if (pi && pi->isBranchLikeType() ) result=pi->resetTmpUnscroll(); // Unscroll myself if (tmpUnscrolled) @@ -275,7 +280,9 @@ systemFlags.deactivate("system-tmpUnscrolledRight"); toggleScroll(); model->emitDataHasChanged (this); + result=true; } + return result; } void BranchItem::sortChildren() diff -r 6b0a5f4923d3 -r cf634bbf9e04 branchitem.h --- a/branchitem.h Thu Sep 17 09:41:09 2009 +0000 +++ b/branchitem.h Wed Sep 23 11:59:54 2009 +0000 @@ -33,8 +33,8 @@ virtual bool toggleScroll(); // scroll or unscroll virtual bool isScrolled(); // returns scroll state virtual bool hasScrolledParent(BranchItem*); // true, if any of the parents is scrolled - virtual void tmpUnscroll(); // unscroll scrolled parents temporary e.g. during "find" process - virtual void resetTmpUnscroll(); // scroll all tmp scrolled parents again e.g. when unselecting + virtual bool tmpUnscroll(); // unscroll scrolled parents temporary e.g. during "find" process + virtual bool resetTmpUnscroll(); // scroll all tmp scrolled parents again e.g. when unselecting virtual void sortChildren(); //! Sort children protected: diff -r 6b0a5f4923d3 -r cf634bbf9e04 branchobj.cpp --- a/branchobj.cpp Thu Sep 17 09:41:09 2009 +0000 +++ b/branchobj.cpp Wed Sep 23 11:59:54 2009 +0000 @@ -115,30 +115,32 @@ return false; } -void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off) +void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off) { - // Temporary link to lmo + // Temporary link to dst // m is position of mouse pointer - // offset 0: default 1: below lmo -1 above lmo (if possible) + // offset 0: default 1: below dst -1 above dst (if possible) - BranchItem *pi=(BranchItem*)(lmo->getTreeItem()->parent()); + BranchItem *dsti=(BranchItem*)(dst->getTreeItem()); + + BranchItem *pi=(BranchItem*)(dsti->parent()); int pi_depth=pi->depth(); - BranchObj* o=(BranchObj*)(lmo); - if (!parObjTmpBuf) - parObjTmpBuf=parObj; + BranchObj* bo=(BranchObj*)(dst); - // ignore mapcenter and mainbranch //FIXME-3 MCO meanwhile also could be relinked + if (!parObjTmpBuf) parObjTmpBuf=parObj; + + // ignore mapcenter and mainbranch //FIXME-1 MCO meanwhile also could be relinked if (pi_depth<2) off=0; if (off==0) link2ParPos=false; else link2ParPos=true; - parObj=o; + parObj=bo; // setLinkStyle calls updateLinkGeometry, only set it once - //LinkableMapObj::Style ls=getDefLinkStyle (lmo->getTreeItem() ); + //LinkableMapObj::Style ls=getDefLinkStyle (dst->getTreeItem() ); //if (style!=ls ) setLinkStyle (ls); - setLinkStyle (lmo->getDefLinkStyle (lmo->getTreeItem())); + setLinkStyle (dst->getDefLinkStyle (dsti)); // Move temporary to new position at destination // Usually the positioning would be done by reposition(), @@ -149,8 +151,7 @@ //FIXME-2 rewrite to us new normalize QPointF p= normalize ( QPointF (m.x() - o->getChildPos().x(), // m.y() - o->getChildPos().y() )); - QPointF p= ( QPointF (m.x() - o->getChildPos().x(), - m.y() - o->getChildPos().y() )); + QPointF p= ( m - bo->getChildPos()); if (p.x()<0) p.setX( p.x()-bbox.width() ); move2RelPos (p); } else @@ -159,8 +160,8 @@ if (off==0) { // new parent is just a branch, link to it - QRectF t=o->getBBoxSizeWithChildren(); - if (o->getTreeItem()->getLastBranch()) + QRectF t=bo->getBBoxSizeWithChildren(); + if (dsti->getLastBranch()) y=t.y() + t.height() ; else y=t.y(); @@ -168,19 +169,19 @@ } else { if (off<0) - // we want to link above lmo - y=o->y() - height() + 5; + // we want to link above dst + y=bo->y() - height() + 5; else - // we want to link below lmo + // we want to link below dst // Bottom of sel should be 5 pixels above // the bottom of the branch _below_ the target: // Don't try to find that branch, guess 12 pixels - y=o->getChildPos().y() -height() + 12; + y=bo->getChildPos().y() -height() + 12; } - if (o->getOrientation()==LinkableMapObj::LeftOfCenter) - move ( o->getChildPos().x() - linkwidth, y ); + if (bo->getOrientation()==LinkableMapObj::LeftOfCenter) + move ( bo->getChildPos().x() - linkwidth, y ); else - move (o->getChildPos().x() + linkwidth, y ); + move (bo->getChildPos().x() + linkwidth, y ); } // updateLinkGeometry is called implicitly in move @@ -264,12 +265,6 @@ void BranchObj::move (double x, double y) { OrnamentedObj::move (x,y); - FloatImageObj *fio; - for (int i=0; iimageCount(); ++i ) - { - fio=treeItem->getImageObjNum(i); - if (fio) fio->reposition(); - } positionBBox(); } @@ -550,6 +545,10 @@ angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ), (int)(y() - parObj->getChildPos().y() ) ) ); } + if (depth==1) + { + move2RelPos (getRelPos() ); + } if (depth>1) { // Align myself depending on orientation and parent, but @@ -647,28 +646,6 @@ } -QPolygonF BranchObj::shape() -{ - QPolygonF p; - - QRectF r=getTotalBBox(); - if (orientation==LinkableMapObj::LeftOfCenter) - p <depth()==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 so far { - // Move MapCenter + // Move MapCenter // FIXME-1 scrolls way too much with shift pressed + lmosel->move (p-movingObj_start); if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) - ((BranchObj*)lmosel)->moveBy( - QPointF(p.x() -movingObj_start.x(), - p.y()-movingObj_start.y()) ); - else - lmosel->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); - model->updateRelPositions(); + { + QPointF v; + v=lmosel->getAbsPos(); + for (int i=0; ibranchCount(); ++i) + { + seli->getBranchObjNum(i)->setRelPos(); + seli->getBranchObjNum(i)->setOrientation(); + } + } } else { if (seli->depth()==1) { // Move mainbranch - lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); + lmosel->move(p-movingObj_start); lmosel->setRelPos(); } else { @@ -1214,7 +1218,7 @@ } // depth>0 // Maybe we can relink temporary? - if (dsti) + if (dsti) // FIXME-1 check if dsti is ancestor of myself! { if (e->modifiers()==Qt::ControlModifier) { @@ -1585,6 +1589,8 @@ QList treeItemsNew; QList treeItemsOld; + bool do_reposition=false; + QModelIndex ix; foreach (ix,newsel.indexes() ) { @@ -1616,7 +1622,8 @@ { // reset tmp scrolled branches BranchItem *bi=(BranchItem*)ti; - bi->resetTmpUnscroll(); + if (bi->resetTmpUnscroll() ) + do_reposition=true; } if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image) // Hide link if not needed @@ -1636,7 +1643,10 @@ { BranchItem *bi=(BranchItem*)ti; if (bi->hasScrolledParent(bi) ) - bi->tmpUnscroll(); + { + if (bi->parentBranch()->tmpUnscroll() ) + do_reposition=true; + } } scrollTo (ix); if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image) @@ -1644,6 +1654,7 @@ ((MapItem*)ti)->getLMO()->updateVisibility(); } } + if (do_reposition) model->reposition(); // Reduce rectangles while (treeItemsNew.count() < selboxList.count() ) @@ -1663,7 +1674,6 @@ } - // Reposition rectangles QRectF bbox; QModelIndex index; diff -r 6b0a5f4923d3 -r cf634bbf9e04 vymmodel.cpp --- a/vymmodel.cpp Thu Sep 17 09:41:09 2009 +0000 +++ b/vymmodel.cpp Wed Sep 23 11:59:54 2009 +0000 @@ -4094,32 +4094,6 @@ } } -void VymModel::updateRelPositions() //FIXME-3 VM should have no need to updateRelPos -{ - /* FIXME-3 ??? - for (int i=0; ibranchCount(); i++) - ((MapCenterObj*)rootItem->getBranchObjNum(i))->updateRelPositions(); - */ - /* - void MapCenterObj::updateRelPositions() - { - if (repositionRequest) unsetAllRepositionRequests(); - - // update relative Positions of branches and floats - for (int i=0; ibranchCount(); ++i) - { - treeItem->getBranchObjNum(i)->setRelPos(); - treeItem->getBranchObjNum(i)->setOrientation(); - } - - for (int i=0; isetRelPos(); - - if (repositionRequest) reposition(); - } - */ -} - void VymModel::reposition() //FIXME-4 VM should have no need to reposition, but the views... { //cout << "VM::reposition blocked="<