diff -r f0fe7c36ec5c -r 43268373032d mapeditor.cpp --- a/mapeditor.cpp Fri Apr 09 14:24:04 2010 +0000 +++ b/mapeditor.cpp Wed Jun 09 13:14:08 2010 +0000 @@ -125,7 +125,7 @@ selectionColor =QColor (255,255,0); - // Attributes //FIXME-2 testing only... + // Attributes //FIXME-3 testing only... QString k; AttributeDef *ad; attrTable= new AttributeTable(); @@ -160,8 +160,7 @@ MapEditor::~MapEditor() { - //qDebug() <<"Destructor MapEditor for "<getMapName(); - //model->unregisterEditor(this); + //qDebug ()<<"Destr MapEditor this="<getOrientation()!=LinkableMapObj::RightOfCenter && p.x() < lmo->getBBox().left()+20) || (lmo->getOrientation()!=LinkableMapObj::LeftOfCenter && p.x() > lmo->getBBox().right()-20) ) { - // FIXME-4 if (ti->xlinkCount()>1) - if (true) + QMenu menu; + QList alist; + for (int i=0;ixlinkCount();i++) + alist.append (new QAction(ti->getXLinkNum(i)->getPartnerBranch()->getHeading(),&menu)); + menu.addActions (alist); + QAction *ra=menu.exec (e->globalPos() ); + if (ra) + model->select (ti->getXLinkNum(alist.indexOf(ra))->getPartnerBranch ()); + while (!alist.isEmpty()) { - QMenu menu; - QList alist; - for (int i=0;ixlinkCount();i++) - alist.append (new QAction(ti->getXLinkNum(i)->getOtherBranch(ti)->getHeading(),&menu)); - menu.addActions (alist); - QAction *ra=menu.exec (e->globalPos() ); - if (ra) - model->select (ti->getXLinkNum(alist.indexOf(ra))->getOtherBranch (ti)); - while (!alist.isEmpty()) - { - QAction *a=alist.takeFirst(); - delete a; - } - return; - } else - { - model->select (ti->getXLinkNum(0)->getOtherBranch (ti)); - return; - } + QAction *a=alist.takeFirst(); + delete a; + } + return; } } } @@ -1112,11 +1103,13 @@ if (bi_begin) { drawingLink=true; - tmpXLink=model->createXLink(bi_begin,true); - tmpXLink->setColor(model->getMapDefXLinkColor()); - tmpXLink->setWidth(model->getMapDefXLinkWidth()); - tmpXLink->setEnd (p); - tmpXLink->updateXLink(); + tmpLink=new Link (model); + tmpLink->setBeginBranch (bi_begin); + tmpLink->setColor(model->getMapDefXLinkColor()); + tmpLink->setWidth(model->getMapDefXLinkWidth()); + tmpLink->setEndPoint (p); + tmpLink->createMapObj(mapScene); + tmpLink->updateLink(); return; } } @@ -1141,8 +1134,11 @@ movingObj_start.setY( p.y() - lmo->y() ); movingObj_orgPos.setX (lmo->x() ); movingObj_orgPos.setY (lmo->y() ); - lmo->setRelPos(); - movingObj_orgRelPos=lmo->getRelPos(); + if (ti->depth()>0) + { + lmo->setRelPos(); + movingObj_orgRelPos=lmo->getRelPos(); + } // If modMode==copy, then we want to "move" the _new_ object around // then we need the offset from p to the _old_ selection, because of tmp @@ -1204,11 +1200,10 @@ if (mainWindow->getModMode()!=Main::ModModeCopy) setCursor (Qt::ArrowCursor); + // Scroll if needed // To avoid jumping of the sceneView, only // show selection, if not tmp linked - /* FIXME-2 if (!lmosel->hasParObjTmp()) - model->emitShowSelection(); - */ + model->emitShowSelection(); // Now move the selection, but add relative position // (movingObj_start) where selection was chosen with @@ -1275,6 +1270,7 @@ seli->getBranchObjNum(i)->setOrientation(); } } + lmosel->move (p-movingObj_start); } else { if (seli->depth()==1) @@ -1326,8 +1322,8 @@ // Draw a link from one branch to another if (drawingLink) { - tmpXLink->setEnd (p); - tmpXLink->updateXLink(); + tmpLink->setEndPoint (p); + tmpLink->updateLink(); } // Move sceneView @@ -1380,18 +1376,20 @@ // Check if we are over another branch if (dsti) { - tmpXLink->setEnd ( ((BranchItem*)dsti) ); - tmpXLink->updateXLink(); - tmpXLink->activate(); + tmpLink->setEndBranch ( ((BranchItem*)dsti) ); + tmpLink->updateLink(); + model->createLink (tmpLink); + /* FIXME-2 Link savestate missing, segfaulting on undo model->saveState( tmpXLink,QString("delete ()"), dsti,QString("addXLink (\"%1\",\"%2\")").arg(model->getSelectString(tmpXLink->getBegin())).arg(model->getSelectString(dsti)), QString("Add xLink from %1 to %2").arg(model->getObjectName(tmpXLink->getBegin())).arg(model->getObjectName(dsti)) ); + */ } else { - model->deleteItem(tmpXLink); - tmpXLink=NULL; + delete (tmpLink); + tmpLink=NULL; } return; } @@ -1576,6 +1574,13 @@ } } +void MapEditor::wheelEvent(QWheelEvent* e) +{ + //qDebug ()<<"ME::wheelEvent"; //FIXME-2 stop all animations in vymModel here + //model->stopAllAnimation(); + QGraphicsView::wheelEvent (e); +} + void MapEditor::resizeEvent (QResizeEvent* e) { QGraphicsView::resizeEvent( e );