1.1 --- a/branchitem.cpp Thu Sep 17 09:41:09 2009 +0000
1.2 +++ b/branchitem.cpp Wed Sep 23 11:59:54 2009 +0000
1.3 @@ -236,21 +236,22 @@
1.4 // find out, if we are scrolled at all.
1.5 // But ignore myself, just look at parents.
1.6
1.7 - //cout << "BI::hasScrolledParent this="<<this<<" "<<getHeadingStd()<<endl;
1.8 if (this !=start && scrolled) return true;
1.9
1.10 BranchItem* bi=(BranchItem*)parentItem;
1.11 - if (bi && bi!=rootItem && bi->isBranchLikeType() )
1.12 + if (bi && bi!=rootItem )
1.13 return bi->hasScrolledParent(start);
1.14 else
1.15 return false;
1.16 }
1.17
1.18 -void BranchItem::tmpUnscroll()
1.19 +bool BranchItem::tmpUnscroll()
1.20 {
1.21 + bool result=false;
1.22 +
1.23 // Unscroll parent (recursivly)
1.24 BranchItem * pi=(BranchItem*)parentItem;
1.25 - if (pi && pi->isBranchLikeType() ) pi->tmpUnscroll();
1.26 + if (pi && pi->isBranchLikeType() ) result=pi->tmpUnscroll();
1.27
1.28 // Unscroll myself
1.29 if (scrolled)
1.30 @@ -259,14 +260,18 @@
1.31 systemFlags.activate("system-tmpUnscrolledRight");
1.32 toggleScroll();
1.33 model->emitDataHasChanged (this);
1.34 + result=true;
1.35 }
1.36 + return result;
1.37 }
1.38
1.39 -void BranchItem::resetTmpUnscroll()
1.40 +bool BranchItem::resetTmpUnscroll()
1.41 {
1.42 + bool result=false;
1.43 +
1.44 // Unscroll parent (recursivly)
1.45 BranchItem * pi=(BranchItem*)parentItem;
1.46 - if (pi && pi->isBranchLikeType() ) pi->resetTmpUnscroll();
1.47 + if (pi && pi->isBranchLikeType() ) result=pi->resetTmpUnscroll();
1.48
1.49 // Unscroll myself
1.50 if (tmpUnscrolled)
1.51 @@ -275,7 +280,9 @@
1.52 systemFlags.deactivate("system-tmpUnscrolledRight");
1.53 toggleScroll();
1.54 model->emitDataHasChanged (this);
1.55 + result=true;
1.56 }
1.57 + return result;
1.58 }
1.59
1.60 void BranchItem::sortChildren()
2.1 --- a/branchitem.h Thu Sep 17 09:41:09 2009 +0000
2.2 +++ b/branchitem.h Wed Sep 23 11:59:54 2009 +0000
2.3 @@ -33,8 +33,8 @@
2.4 virtual bool toggleScroll(); // scroll or unscroll
2.5 virtual bool isScrolled(); // returns scroll state
2.6 virtual bool hasScrolledParent(BranchItem*); // true, if any of the parents is scrolled
2.7 - virtual void tmpUnscroll(); // unscroll scrolled parents temporary e.g. during "find" process
2.8 - virtual void resetTmpUnscroll(); // scroll all tmp scrolled parents again e.g. when unselecting
2.9 + virtual bool tmpUnscroll(); // unscroll scrolled parents temporary e.g. during "find" process
2.10 + virtual bool resetTmpUnscroll(); // scroll all tmp scrolled parents again e.g. when unselecting
2.11 virtual void sortChildren(); //! Sort children
2.12
2.13 protected:
3.1 --- a/branchobj.cpp Thu Sep 17 09:41:09 2009 +0000
3.2 +++ b/branchobj.cpp Wed Sep 23 11:59:54 2009 +0000
3.3 @@ -115,30 +115,32 @@
3.4 return false;
3.5 }
3.6
3.7 -void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off)
3.8 +void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off)
3.9 {
3.10 - // Temporary link to lmo
3.11 + // Temporary link to dst
3.12 // m is position of mouse pointer
3.13 - // offset 0: default 1: below lmo -1 above lmo (if possible)
3.14 + // offset 0: default 1: below dst -1 above dst (if possible)
3.15
3.16 - BranchItem *pi=(BranchItem*)(lmo->getTreeItem()->parent());
3.17 + BranchItem *dsti=(BranchItem*)(dst->getTreeItem());
3.18 +
3.19 + BranchItem *pi=(BranchItem*)(dsti->parent());
3.20 int pi_depth=pi->depth();
3.21 - BranchObj* o=(BranchObj*)(lmo);
3.22 - if (!parObjTmpBuf)
3.23 - parObjTmpBuf=parObj;
3.24 + BranchObj* bo=(BranchObj*)(dst);
3.25
3.26 - // ignore mapcenter and mainbranch //FIXME-3 MCO meanwhile also could be relinked
3.27 + if (!parObjTmpBuf) parObjTmpBuf=parObj;
3.28 +
3.29 + // ignore mapcenter and mainbranch //FIXME-1 MCO meanwhile also could be relinked
3.30 if (pi_depth<2) off=0;
3.31 if (off==0)
3.32 link2ParPos=false;
3.33 else
3.34 link2ParPos=true;
3.35 - parObj=o;
3.36 + parObj=bo;
3.37
3.38 // setLinkStyle calls updateLinkGeometry, only set it once
3.39 - //LinkableMapObj::Style ls=getDefLinkStyle (lmo->getTreeItem() );
3.40 + //LinkableMapObj::Style ls=getDefLinkStyle (dst->getTreeItem() );
3.41 //if (style!=ls ) setLinkStyle (ls);
3.42 - setLinkStyle (lmo->getDefLinkStyle (lmo->getTreeItem()));
3.43 + setLinkStyle (dst->getDefLinkStyle (dsti));
3.44
3.45 // Move temporary to new position at destination
3.46 // Usually the positioning would be done by reposition(),
3.47 @@ -149,8 +151,7 @@
3.48
3.49 //FIXME-2 rewrite to us new normalize QPointF p= normalize ( QPointF (m.x() - o->getChildPos().x(),
3.50 // m.y() - o->getChildPos().y() ));
3.51 - QPointF p= ( QPointF (m.x() - o->getChildPos().x(),
3.52 - m.y() - o->getChildPos().y() ));
3.53 + QPointF p= ( m - bo->getChildPos());
3.54 if (p.x()<0) p.setX( p.x()-bbox.width() );
3.55 move2RelPos (p);
3.56 } else
3.57 @@ -159,8 +160,8 @@
3.58 if (off==0)
3.59 {
3.60 // new parent is just a branch, link to it
3.61 - QRectF t=o->getBBoxSizeWithChildren();
3.62 - if (o->getTreeItem()->getLastBranch())
3.63 + QRectF t=bo->getBBoxSizeWithChildren();
3.64 + if (dsti->getLastBranch())
3.65 y=t.y() + t.height() ;
3.66 else
3.67 y=t.y();
3.68 @@ -168,19 +169,19 @@
3.69 } else
3.70 {
3.71 if (off<0)
3.72 - // we want to link above lmo
3.73 - y=o->y() - height() + 5;
3.74 + // we want to link above dst
3.75 + y=bo->y() - height() + 5;
3.76 else
3.77 - // we want to link below lmo
3.78 + // we want to link below dst
3.79 // Bottom of sel should be 5 pixels above
3.80 // the bottom of the branch _below_ the target:
3.81 // Don't try to find that branch, guess 12 pixels
3.82 - y=o->getChildPos().y() -height() + 12;
3.83 + y=bo->getChildPos().y() -height() + 12;
3.84 }
3.85 - if (o->getOrientation()==LinkableMapObj::LeftOfCenter)
3.86 - move ( o->getChildPos().x() - linkwidth, y );
3.87 + if (bo->getOrientation()==LinkableMapObj::LeftOfCenter)
3.88 + move ( bo->getChildPos().x() - linkwidth, y );
3.89 else
3.90 - move (o->getChildPos().x() + linkwidth, y );
3.91 + move (bo->getChildPos().x() + linkwidth, y );
3.92 }
3.93
3.94 // updateLinkGeometry is called implicitly in move
3.95 @@ -264,12 +265,6 @@
3.96 void BranchObj::move (double x, double y)
3.97 {
3.98 OrnamentedObj::move (x,y);
3.99 - FloatImageObj *fio;
3.100 - for (int i=0; i<treeItem->imageCount(); ++i )
3.101 - {
3.102 - fio=treeItem->getImageObjNum(i);
3.103 - if (fio) fio->reposition();
3.104 - }
3.105 positionBBox();
3.106 }
3.107
3.108 @@ -550,6 +545,10 @@
3.109 angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ),
3.110 (int)(y() - parObj->getChildPos().y() ) ) );
3.111 }
3.112 + if (depth==1)
3.113 + {
3.114 + move2RelPos (getRelPos() );
3.115 + }
3.116 if (depth>1)
3.117 {
3.118 // Align myself depending on orientation and parent, but
3.119 @@ -647,28 +646,6 @@
3.120 }
3.121
3.122
3.123 -QPolygonF BranchObj::shape()
3.124 -{
3.125 - QPolygonF p;
3.126 -
3.127 - QRectF r=getTotalBBox();
3.128 - if (orientation==LinkableMapObj::LeftOfCenter)
3.129 - p <<r.bottomLeft()
3.130 - <<r.topLeft()
3.131 - <<QPointF (bbox.topLeft().x(), r.topLeft().y() )
3.132 - <<bbox.topRight()
3.133 - <<bbox.bottomRight()
3.134 - <<QPointF (bbox.bottomLeft().x(), r.bottomLeft().y() ) ;
3.135 - else
3.136 - p <<r.bottomRight()
3.137 - <<r.topRight()
3.138 - <<QPointF (bbox.topRight().x(), r.topRight().y() )
3.139 - <<bbox.topLeft()
3.140 - <<bbox.bottomLeft()
3.141 - <<QPointF (bbox.bottomRight().x(), r.bottomRight().y() ) ;
3.142 - return p;
3.143 -}
3.144 -
3.145 QRectF BranchObj::getTotalBBox()
3.146 {
3.147 QRectF r=bbox;
4.1 --- a/branchobj.h Thu Sep 17 09:41:09 2009 +0000
4.2 +++ b/branchobj.h Wed Sep 23 11:59:54 2009 +0000
4.3 @@ -52,7 +52,6 @@
4.4 virtual void reposition();
4.5 virtual void unsetAllRepositionRequests();
4.6
4.7 - virtual QPolygonF shape(); //!< Returns arbitrary bounding polygon
4.8 virtual QRectF getTotalBBox(); // return BBox including children
4.9 virtual QRectF getBBoxSizeWithChildren(); // return size of BBox including children
4.10 virtual ConvexPolygon getBoundingPolygon();
5.1 --- a/mapeditor.cpp Thu Sep 17 09:41:09 2009 +0000
5.2 +++ b/mapeditor.cpp Wed Sep 23 11:59:54 2009 +0000
5.3 @@ -1183,22 +1183,26 @@
5.4 }
5.5 } else
5.6 { // selection != a FloatObj
5.7 - if (seli->depth()==0) //FIXME-1 also moved mapcenters could be linked, but not working here...
5.8 + if (seli->depth()==0) //FIXME-1 also moved mapcenters could be linked, but not working so far
5.9 {
5.10 - // Move MapCenter
5.11 + // Move MapCenter // FIXME-1 scrolls way too much with shift pressed
5.12 + lmosel->move (p-movingObj_start);
5.13 if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier)
5.14 - ((BranchObj*)lmosel)->moveBy(
5.15 - QPointF(p.x() -movingObj_start.x(),
5.16 - p.y()-movingObj_start.y()) );
5.17 - else
5.18 - lmosel->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
5.19 - model->updateRelPositions();
5.20 + {
5.21 + QPointF v;
5.22 + v=lmosel->getAbsPos();
5.23 + for (int i=0; i<seli->branchCount(); ++i)
5.24 + {
5.25 + seli->getBranchObjNum(i)->setRelPos();
5.26 + seli->getBranchObjNum(i)->setOrientation();
5.27 + }
5.28 + }
5.29 } else
5.30 {
5.31 if (seli->depth()==1)
5.32 {
5.33 // Move mainbranch
5.34 - lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
5.35 + lmosel->move(p-movingObj_start);
5.36 lmosel->setRelPos();
5.37 } else
5.38 {
5.39 @@ -1214,7 +1218,7 @@
5.40
5.41 } // depth>0
5.42 // Maybe we can relink temporary?
5.43 - if (dsti)
5.44 + if (dsti) // FIXME-1 check if dsti is ancestor of myself!
5.45 {
5.46 if (e->modifiers()==Qt::ControlModifier)
5.47 {
5.48 @@ -1585,6 +1589,8 @@
5.49 QList <TreeItem*> treeItemsNew;
5.50 QList <TreeItem*> treeItemsOld;
5.51
5.52 + bool do_reposition=false;
5.53 +
5.54 QModelIndex ix;
5.55 foreach (ix,newsel.indexes() )
5.56 {
5.57 @@ -1616,7 +1622,8 @@
5.58 {
5.59 // reset tmp scrolled branches
5.60 BranchItem *bi=(BranchItem*)ti;
5.61 - bi->resetTmpUnscroll();
5.62 + if (bi->resetTmpUnscroll() )
5.63 + do_reposition=true;
5.64 }
5.65 if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
5.66 // Hide link if not needed
5.67 @@ -1636,7 +1643,10 @@
5.68 {
5.69 BranchItem *bi=(BranchItem*)ti;
5.70 if (bi->hasScrolledParent(bi) )
5.71 - bi->tmpUnscroll();
5.72 + {
5.73 + if (bi->parentBranch()->tmpUnscroll() )
5.74 + do_reposition=true;
5.75 + }
5.76 }
5.77 scrollTo (ix);
5.78 if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
5.79 @@ -1644,6 +1654,7 @@
5.80 ((MapItem*)ti)->getLMO()->updateVisibility();
5.81 }
5.82 }
5.83 + if (do_reposition) model->reposition();
5.84
5.85 // Reduce rectangles
5.86 while (treeItemsNew.count() < selboxList.count() )
5.87 @@ -1663,7 +1674,6 @@
5.88 }
5.89
5.90
5.91 -
5.92 // Reposition rectangles
5.93 QRectF bbox;
5.94 QModelIndex index;
6.1 --- a/vymmodel.cpp Thu Sep 17 09:41:09 2009 +0000
6.2 +++ b/vymmodel.cpp Wed Sep 23 11:59:54 2009 +0000
6.3 @@ -4094,32 +4094,6 @@
6.4 }
6.5 }
6.6
6.7 -void VymModel::updateRelPositions() //FIXME-3 VM should have no need to updateRelPos
6.8 -{
6.9 - /* FIXME-3 ???
6.10 - for (int i=0; i<rootItem->branchCount(); i++)
6.11 - ((MapCenterObj*)rootItem->getBranchObjNum(i))->updateRelPositions();
6.12 - */
6.13 - /*
6.14 - void MapCenterObj::updateRelPositions()
6.15 - {
6.16 - if (repositionRequest) unsetAllRepositionRequests();
6.17 -
6.18 - // update relative Positions of branches and floats
6.19 - for (int i=0; i<treeItem->branchCount(); ++i)
6.20 - {
6.21 - treeItem->getBranchObjNum(i)->setRelPos();
6.22 - treeItem->getBranchObjNum(i)->setOrientation();
6.23 - }
6.24 -
6.25 - for (int i=0; i<floatimage.size(); ++i)
6.26 - floatimage.at(i)->setRelPos();
6.27 -
6.28 - if (repositionRequest) reposition();
6.29 - }
6.30 - */
6.31 -}
6.32 -
6.33 void VymModel::reposition() //FIXME-4 VM should have no need to reposition, but the views...
6.34 {
6.35 //cout << "VM::reposition blocked="<<blockReposition<<endl;
7.1 --- a/vymmodel.h Thu Sep 17 09:41:09 2009 +0000
7.2 +++ b/vymmodel.h Wed Sep 23 11:59:54 2009 +0000
7.3 @@ -434,8 +434,6 @@
7.4 void unsetContextPos (); //!< forget local position after context menu
7.5
7.6 void updateNoteFlag(); //!< Signal origination in TextEditor
7.7 - void updateRelPositions();
7.8 -
7.9 void reposition(); //!< Call reposition for all MCOs
7.10 void setHideTmpMode (TreeItem::HideTmpMode mode);
7.11