# 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; i<treeItem->branchCount(); ++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<<bboxTotal.topRight(); p<<bboxTotal.bottomRight(); p<<bboxTotal.bottomLeft(); - if (pi) pi->setPolygon (p ); + //cout << "BO::getBP (total) "<<treeItem->getHeadingStd()<<" tL="<<bboxTotal.topLeft()<<" bR="<<bboxTotal.bottomRight()<<endl; + //cout << " "<<" tL="<<bbox.topLeft()<<" bR="<<bbox.bottomRight()<<endl; + if (pi) pi->setPolygon (p ); return p; } @@ -751,6 +767,7 @@ r.setWidth( max (br.width(), r.width() )); r.setHeight(br.height() + r.height() ); if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y()); + if (br.x()<bboxTotal.x()) bboxTotal.setX(br.x()); } } // Add myself and also diff -r 2876353ea150 -r d251c7b2de54 floatobj.cpp --- a/floatobj.cpp Wed Sep 23 12:14:08 2009 +0000 +++ b/floatobj.cpp Thu Oct 01 11:28:50 2009 +0000 @@ -9,7 +9,7 @@ FloatObj::FloatObj (QGraphicsScene* s, TreeItem *ti):OrnamentedObj(s,ti) { - cout << "Const FloatObj s="<<s<<" ti="<<ti<<" treeItem="<<treeItem<<endl; + //cout << "Const FloatObj s="<<s<<" ti="<<ti<<" treeItem="<<treeItem<<endl; setParObj (this); init(); } diff -r 2876353ea150 -r d251c7b2de54 geometry.cpp --- a/geometry.cpp Wed Sep 23 12:14:08 2009 +0000 +++ b/geometry.cpp Thu Oct 01 11:28:50 2009 +0000 @@ -88,6 +88,11 @@ setY (-y()); } +QPointF Vector::toQPointF () +{ + return QPointF (x(),y()); +} + /*! Calculate the projection of a polygon on an axis and returns it as a [min, max] interval */ ConvexPolygon::ConvexPolygon () diff -r 2876353ea150 -r d251c7b2de54 geometry.h --- a/geometry.h Wed Sep 23 12:14:08 2009 +0000 +++ b/geometry.h Thu Oct 01 11:28:50 2009 +0000 @@ -21,6 +21,7 @@ virtual qreal dotProduct (const QPointF &b); virtual void scale (const qreal &f); virtual void invert (); + virtual QPointF toQPointF(); }; class ConvexPolygon:public QPolygonF diff -r 2876353ea150 -r d251c7b2de54 imageitem.cpp --- a/imageitem.cpp Wed Sep 23 12:14:08 2009 +0000 +++ b/imageitem.cpp Thu Oct 01 11:28:50 2009 +0000 @@ -66,7 +66,7 @@ initLMO(); fio->setZValue(zValue); fio->setRelPos (pos); - cout << "II::createMO fio="<<fio<<" tI="<<fio->getTreeItem()<<endl; + //cout << "II::createMO fio="<<fio<<" tI="<<fio->getTreeItem()<<endl; return fio; } diff -r 2876353ea150 -r d251c7b2de54 linkablemapobj.cpp --- a/linkablemapobj.cpp Wed Sep 23 12:14:08 2009 +0000 +++ b/linkablemapobj.cpp Thu Oct 01 11:28:50 2009 +0000 @@ -39,6 +39,7 @@ void LinkableMapObj::delLink() { + //bottomline->hide(); switch (style) { case Line: @@ -62,6 +63,7 @@ { parObj=NULL; parObjTmpBuf=NULL; + tmpParent=false; parPos=QPointF(0,0); childPos=QPointF(0,0); link2ParPos=false; @@ -78,6 +80,8 @@ pen.setWidth (1); pen.setColor (linkcolor); pen.setCapStyle ( Qt::RoundCap ); + + useBottomline=true; bottomline=scene->addLine(QLineF(1,1,1,1),pen); bottomline->setZValue(Z_LINK); bottomline->show(); @@ -116,8 +120,7 @@ bool LinkableMapObj::hasParObjTmp() { - if (parObjTmpBuf) return true; - return false; + return tmpParent; } void LinkableMapObj::setUseRelPos (const bool &b) @@ -205,7 +208,6 @@ void LinkableMapObj::setLinkStyle(Style newstyle) { - //if (newstyle==style) return; FIXME-3 delLink(); style=newstyle; @@ -368,7 +370,11 @@ if (visnow) { - bottomline->show(); + if (useBottomline) + bottomline->show(); + else + bottomline->hide(); + switch (style) { case Line: @@ -477,7 +483,6 @@ double vy=p2y - p1y; // Draw the horizontal line below heading (from ChildPos to ParPos) - //bottomline->prepareGeometryChange(); bottomline->setLine (QLine (qRound(childPos.x()), qRound(childPos.y()), qRound(p1x), diff -r 2876353ea150 -r d251c7b2de54 linkablemapobj.h --- a/linkablemapobj.h Wed Sep 23 12:14:08 2009 +0000 +++ b/linkablemapobj.h Thu Oct 01 11:28:50 2009 +0000 @@ -40,6 +40,7 @@ Bottom //!< Link is drawn at bottom of object }; + /*! Hint if link should use the default link color or the color of heading */ enum ColorHint { DefaultColor, //!< Link uses the default color @@ -117,7 +118,7 @@ LinkableMapObj* parObj; LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent - qreal bottomlineY; // vertical offset of dockpos to pos + bool tmpParent; int thickness_start; // for StylePoly* Style style; // Current style @@ -131,7 +132,11 @@ QPolygonF pa0; // For drawing of PolyParabel and PolyLine QPolygonF pa1; // For drawing of PolyParabel QPolygonF pa2; // For drawing of PolyParabel + QGraphicsLineItem* bottomline; // on bottom of BBox + bool useBottomline; //! Hint if bottomline should be used + qreal bottomlineY; // vertical offset of dockpos to pos + bool repositionRequest; // qreal topPad, botPad, diff -r 2876353ea150 -r d251c7b2de54 mapeditor.cpp --- a/mapeditor.cpp Wed Sep 23 12:14:08 2009 +0000 +++ b/mapeditor.cpp Thu Oct 01 11:28:50 2009 +0000 @@ -64,6 +64,7 @@ pickingColor=false; drawingLink=false; copyingObj=false; + objectMoved=false; editingBO=NULL; movingObj=NULL; @@ -184,17 +185,20 @@ return mapScene; } -void MapEditor::scrollTo (const QModelIndex &index) +void MapEditor::scrollTo (const QModelIndex &index) //FIXME-1 problems with locating stuff in big maps { - //cout <<"ME::scrollTo aborted\n"; - //return; if (index.isValid()) { LinkableMapObj* lmo=NULL; TreeItem *ti= static_cast<TreeItem*>(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 "<<ti->getHeadingStd()<<" tL="<<r.topLeft()<<" bR="<<r.bottomRight()<<endl; + setScrollBarPosTarget (lmo->getBBox() ); + } } } @@ -457,6 +461,14 @@ void MapEditor::testFunction1() { cout << "ME::test1 selected TI="<<model->getSelectedItem()<<endl; + + BranchObj *bo=model->getSelectedBranchObj(); + if (bo) + { + bo->moveBy (100,100); + model->reposition(); + } + /* // Code copied from Qt sources QRectF rect=model->getSelectedBranchObj()->getBBox(); @@ -657,6 +669,7 @@ Vector v=polys[i].at(0)-orgpos[i]; orients.append (mapobjects[i]->getOrientation()); mapobjects[i]->moveBy(v.x(),v.y() ); + mapobjects[i]->setRelPos(); } model->reposition(); orientationChanged=false; @@ -670,6 +683,8 @@ break; //orientationChanged=false; } // loop if orientation has changed + + model->emitSelectionChanged(); } BranchItem* MapEditor::getBranchDirectAbove (BranchItem *bi) @@ -1003,8 +1018,8 @@ if (!foname.isEmpty()) { // systemFlag clicked - model->select (lmo); // FIXME-3 was selectInt - if (foname=="url") + model->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="<<mapToScene (e->pos())<<endl; + + if (model->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="<<do_reposition<<endl; if (do_reposition) model->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; i<selbi->branchCount();++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 "<<branch->getHeadingStd()<<endl; - } emit (layoutAboutToBeChanged() ); BranchItem *branchpi=(BranchItem*)branch->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()