# HG changeset patch # User insilmaril # Date 1254396530 0 # Node ID d251c7b2de54cb6dc832e6557a90ce98023b2020 # Parent 2876353ea15003dea58b2ee49552709d120ffe78 Various fixes for relinking and selecting diff -r 2876353ea150 -r d251c7b2de54 branchitem.cpp --- a/branchitem.cpp Wed Sep 23 12:14:08 2009 +0000 +++ b/branchitem.cpp Thu Oct 01 11:28:50 2009 +0000 @@ -438,9 +438,13 @@ { // FIXME-5 compare also MapItem::initLMO... - if (lmo && parentItem != rootItem) - { - lmo->setParObj ( ((MapItem*)parentItem)->getLMO() ); + if (lmo) + { + if ( parentItem != rootItem) + lmo->setParObj ( ((MapItem*)parentItem)->getLMO() ); + else + lmo->setParObj (NULL); + ((BranchObj*)lmo)->setDefAttr(BranchObj::MovedBranch); } } @@ -458,7 +462,7 @@ if (parentItem==rootItem) { newbo->setParObj(NULL); - newbo->setFrameType (FrameObj::Rectangle); + //newbo->setFrameType (FrameObj::Rectangle); //FIXME-4 maybe call updateStyles? } else { newbo->setParObj( ((MapItem*)parentItem)->getLMO() ); diff -r 2876353ea150 -r d251c7b2de54 branchobj.cpp --- a/branchobj.cpp Wed Sep 23 12:14:08 2009 +0000 +++ b/branchobj.cpp Thu Oct 01 11:28:50 2009 +0000 @@ -115,7 +115,7 @@ return false; } -void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off) +void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off) //FIXME-1 after moving a mainbranch to a branch and away again mainbranch is no longer connected to mapcenter... { // Temporary link to dst // m is position of mouse pointer @@ -127,9 +127,12 @@ int pi_depth=pi->depth(); BranchObj* bo=(BranchObj*)(dst); - if (!parObjTmpBuf) parObjTmpBuf=parObj; + if (!tmpParent) + { + tmpParent=true; + 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; @@ -137,9 +140,6 @@ link2ParPos=true; parObj=bo; - // setLinkStyle calls updateLinkGeometry, only set it once - //LinkableMapObj::Style ls=getDefLinkStyle (dst->getTreeItem() ); - //if (style!=ls ) setLinkStyle (ls); setLinkStyle (dst->getDefLinkStyle (dsti)); // Move temporary to new position at destination @@ -148,12 +148,11 @@ // Better just do it approximately if (parObj->getTreeItem()->depth()==0) { // new parent is a mapcenter - - //FIXME-2 rewrite to us new normalize QPointF p= normalize ( 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); + Vector v= ( m - bo->getChildPos()); + if (v.x()<0) v.setX( v.x()-bbox.width() ); + v.normalize(); + v.scale (100); + move2RelPos (v.toQPointF()); } else { qreal y; @@ -190,8 +189,9 @@ void BranchObj::unsetParObjTmp() { - if (parObjTmpBuf) + if (tmpParent) { + tmpParent=false; link2ParPos=false; parObj=parObjTmpBuf; parObjTmpBuf=NULL; @@ -485,9 +485,18 @@ int fontsize; switch (treeItem->depth()) { - case 0: fontsize=16; break; - case 1: fontsize=12; break; - default: fontsize=10; break; + case 0: + fontsize=16; + setFrameType (FrameObj::Rectangle); + break; + case 1: + fontsize=12; + setFrameType (FrameObj::NoFrame); + break; + default: + fontsize=10; + setFrameType (FrameObj::NoFrame); + break; } setLinkStyle(getDefLinkStyle(treeItem->parent() )); setLinkColor (); @@ -497,6 +506,10 @@ if (mod==NewBranch) setColor (treeItem->getHeadingColor() ); + else + // Also set styles for children + for (int i=0; ibranchCount(); ++i) + treeItem->getBranchObjNum(i)->setDefAttr(MovedBranch); calcBBoxSize(); } @@ -672,7 +685,7 @@ return bboxTotal; } -ConvexPolygon BranchObj::getBoundingPolygon() +ConvexPolygon BranchObj::getBoundingPolygon() { /* if (!pi) //FIXME-3 Testing only @@ -683,6 +696,7 @@ pi->setZValue(Z_BBOX); } */ + if (treeItem->branchCount()==0 || treeItem->depth()==0) { if (pi) pi->setPolygon (MapObj::getBoundingPolygon() ); @@ -695,7 +709,9 @@ p<setPolygon (p ); + //cout << "BO::getBP (total) "<getHeadingStd()<<" tL="<(index.internalPointer()); if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() ) lmo=((MapItem*)ti)->getLMO(); - if (lmo) setScrollBarPosTarget (lmo->getBBox() ); + if (lmo) + { + QRectF r=lmo->getBBox(); + cout << "ME::scrollTo "<getHeadingStd()<<" tL="<select (lmo); + if (foname=="system-url") { if (e->state() & Qt::ControlModifier) mainWindow->editOpenURLTab(); @@ -1124,14 +1139,16 @@ // Move the selected MapObj if ( lmosel && movingObj) { + objectMoved=true; // reset cursor if we are moving and don't copy if (mainWindow->getModMode()!=Main::ModModeCopy) setCursor (Qt::ArrowCursor); // To avoid jumping of the sceneView, only // show selection, if not tmp linked - if (!lmosel->hasParObjTmp()) + /* FIXME-2 if (!lmosel->hasParObjTmp()) model->emitShowSelection(); + */ // Now move the selection, but add relative position // (movingObj_start) where selection was chosen with @@ -1183,9 +1200,8 @@ } } else { // selection != a FloatObj - if (seli->depth()==0) //FIXME-1 also moved mapcenters could be linked, but not working so far + if (seli->depth()==0) { - // 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) { @@ -1373,7 +1389,7 @@ QString preSelStr=model->getSelectString(seli); copyingObj=false; - if (dsti) + if (dsti && objectMoved) { // We have a destination, relink to that @@ -1444,14 +1460,11 @@ 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... - // if (lmosel->getOrientation()==LinkableMapObj::LeftOfCenter) dst.setX (dst.x()+lmosel->width() ); model->startAnimation( (BranchObj*)lmosel, lmosel->getRelPos(), movingObj_orgRelPos -// QPointF (movingObj_orgPos.x() - dst.x(), movingObj_orgPos.y() - dst.y() ) ); } else model->reposition(); @@ -1461,9 +1474,8 @@ // Finally resize scene, if needed scene()->update(); movingObj=NULL; + objectMoved=false; - // Just make sure, that actions are still ok,e.g. the move branch up/down buttons... - // model->updateActions(); FIXME-3 neeeded? } else // maybe we moved View: set old cursor setCursor (Qt::ArrowCursor); @@ -1472,6 +1484,9 @@ void MapEditor::mouseDoubleClickEvent(QMouseEvent* e) { + if (debug) cout << "ME p="<pos())<isSelectionBlocked() ) { e->ignore(); @@ -1648,12 +1663,12 @@ do_reposition=true; } } - scrollTo (ix); if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image) // Show link if needed ((MapItem*)ti)->getLMO()->updateVisibility(); } } + // FIXME-3 cout << "ME::updateSel doRepos="<reposition(); // Reduce rectangles diff -r 2876353ea150 -r d251c7b2de54 mapeditor.h --- a/mapeditor.h Wed Sep 23 12:14:08 2009 +0000 +++ b/mapeditor.h Thu Oct 01 11:28:50 2009 +0000 @@ -112,7 +112,8 @@ QCursor XLinkCursor; // cursor while picking color bool pickingColor; bool drawingLink; // true while creating a link - bool copyingObj; // true while creating a link + bool copyingObj; // true while modModeCopy + bool objectMoved; // true if object was not clicked, but moved with mouse XLinkItem* tmpXLink; MapObj* movingObj; // moving a MapObj diff -r 2876353ea150 -r d251c7b2de54 ornamentedobj.cpp --- a/ornamentedobj.cpp Wed Sep 23 12:14:08 2009 +0000 +++ b/ornamentedobj.cpp Thu Oct 01 11:28:50 2009 +0000 @@ -90,9 +90,14 @@ { frame->setFrameType(t); if (t == FrameObj::NoFrame) + { linkpos=LinkableMapObj::Bottom; - else + useBottomline=true; + } else + { linkpos=LinkableMapObj::Middle; + useBottomline=false; + } calcBBoxSize(); positionBBox(); diff -r 2876353ea150 -r d251c7b2de54 version.h --- a/version.h Wed Sep 23 12:14:08 2009 +0000 +++ b/version.h Thu Oct 01 11:28:50 2009 +0000 @@ -7,7 +7,7 @@ #define __VYM_VERSION "1.13.0" //#define __VYM_CODENAME "Codename: RC-1" #define __VYM_CODENAME "Codename: development version, not for production!" -#define __VYM_BUILD_DATE "2009-09-23" +#define __VYM_BUILD_DATE "2009-10-01" bool checkVersion(const QString &); diff -r 2876353ea150 -r d251c7b2de54 vymmodel.cpp --- a/vymmodel.cpp Wed Sep 23 12:14:08 2009 +0000 +++ b/vymmodel.cpp Thu Oct 01 11:28:50 2009 +0000 @@ -1963,10 +1963,15 @@ BranchItem *selbi=getSelectedBranch(); if (selbi && selbi->depth()>0) { + // if no relPos have been set before, try to use current rel positions + if (selbi->getLMO()) + for (int i=0; ibranchCount();++i) + selbi->getBranchNum(i)->getBranchObj()->setRelPos(); + //QString oldsel=getSelectString(); if ( relinkBranch (selbi,rootItem,-1) ) saveState ( - selbi,QString("relink()"), //FIXME-1 add paramters + selbi,QString("relink()"), //FIXME-1 add paramters when detaching selbi,"detach ()", QString("Detach %1").arg(getObjectName(selbi)) ); @@ -2264,10 +2269,6 @@ { if (branch && dst) { - if (branch->depth()==0) - { - cout <<"VM::relinkBranch d=0 for "<getHeadingStd()<parent(); // Remove at current position @@ -2517,6 +2518,7 @@ if (bi->depth()==0) return false; if (bi->toggleScroll()) { + reposition(); QString u,r; r="scroll"; u="unscroll"; @@ -2546,21 +2548,21 @@ if (bi->toggleScroll()) { reposition(); - QString u,r; - u="scroll"; - r="unscroll"; - saveState( - bi, - QString ("%1 ()").arg(u), - bi, - QString ("%1 ()").arg(r), - QString ("%1 %2").arg(r).arg(getObjectName(bi)) - ); - emitDataHasChanged(bi); - emitSelectionChanged(); + QString u,r; + u="scroll"; + r="unscroll"; + saveState( + bi, + QString ("%1 ()").arg(u), + bi, + QString ("%1 ()").arg(r), + QString ("%1 %2").arg(r).arg(getObjectName(bi)) + ); + emitDataHasChanged(bi); + emitSelectionChanged(); mapScene->update(); //Needed for _quick_ update, even in 1.13.x - return true; - } + return true; + } } return false; } @@ -2657,6 +2659,7 @@ void VymModel::colorBranch (QColor c) { +cout << "VM::colBranch\n"; BranchItem *selbi=getSelectedBranch(); if (selbi) { @@ -4225,6 +4228,7 @@ } void VymModel::selectMapBackgroundImage () // FIXME-2 move to ME +// FIXME-4 for using background image: view.setCacheMode(QGraphicsView::CacheBackground); { Q3FileDialog *fd=new Q3FileDialog( NULL); fd->setMode (Q3FileDialog::ExistingFile); @@ -4400,6 +4404,7 @@ void VymModel::startAnimation(BranchObj *bo, const QPointF &start, const QPointF &dest) { + if (start==dest) return; if (bo && bo->getTreeItem()->depth()>0) { AnimPoint ap; @@ -4590,7 +4595,7 @@ void VymModel::emitSelectionChanged(const QItemSelection &newsel) { emit (selectionChanged(newsel,newsel)); // needed e.g. to update geometry in editor - emitShowSelection(); + //FIXME-3 emitShowSelection(); sendSelection(); } diff -r 2876353ea150 -r d251c7b2de54 vymview.cpp --- a/vymview.cpp Wed Sep 23 12:14:08 2009 +0000 +++ b/vymview.cpp Thu Oct 01 11:28:50 2009 +0000 @@ -118,7 +118,7 @@ mainWindow->changeSelection (model,newsel,oldsel); // FIXME-5 maybe connect VymModel <-> MainWindow directly? // would require to also get current model in mainWindow - //showSelection(); + //showSelection(); // if called here, no tmpParObj can be set... } void VymView::expandAll()