1.1 --- a/mapeditor.cpp Wed Apr 07 10:45:24 2010 +0000
1.2 +++ b/mapeditor.cpp Wed Jun 09 13:14:08 2010 +0000
1.3 @@ -125,7 +125,7 @@
1.4 selectionColor =QColor (255,255,0);
1.5
1.6
1.7 - // Attributes //FIXME-2 testing only...
1.8 + // Attributes //FIXME-3 testing only...
1.9 QString k;
1.10 AttributeDef *ad;
1.11 attrTable= new AttributeTable();
1.12 @@ -160,8 +160,7 @@
1.13
1.14 MapEditor::~MapEditor()
1.15 {
1.16 - //qDebug() <<"Destructor MapEditor for "<<model->getMapName();
1.17 - //model->unregisterEditor(this);
1.18 + //qDebug ()<<"Destr MapEditor this="<<this;
1.19 }
1.20
1.21 VymModel* MapEditor::getModel()
1.22 @@ -1070,28 +1069,20 @@
1.23 if ((lmo->getOrientation()!=LinkableMapObj::RightOfCenter && p.x() < lmo->getBBox().left()+20) ||
1.24 (lmo->getOrientation()!=LinkableMapObj::LeftOfCenter && p.x() > lmo->getBBox().right()-20) )
1.25 {
1.26 - // FIXME-4 if (ti->xlinkCount()>1)
1.27 - if (true)
1.28 + QMenu menu;
1.29 + QList <QAction*> alist;
1.30 + for (int i=0;i<ti->xlinkCount();i++)
1.31 + alist.append (new QAction(ti->getXLinkNum(i)->getPartnerBranch()->getHeading(),&menu));
1.32 + menu.addActions (alist);
1.33 + QAction *ra=menu.exec (e->globalPos() );
1.34 + if (ra)
1.35 + model->select (ti->getXLinkNum(alist.indexOf(ra))->getPartnerBranch ());
1.36 + while (!alist.isEmpty())
1.37 {
1.38 - QMenu menu;
1.39 - QList <QAction*> alist;
1.40 - for (int i=0;i<ti->xlinkCount();i++)
1.41 - alist.append (new QAction(ti->getXLinkNum(i)->getOtherBranch(ti)->getHeading(),&menu));
1.42 - menu.addActions (alist);
1.43 - QAction *ra=menu.exec (e->globalPos() );
1.44 - if (ra)
1.45 - model->select (ti->getXLinkNum(alist.indexOf(ra))->getOtherBranch (ti));
1.46 - while (!alist.isEmpty())
1.47 - {
1.48 - QAction *a=alist.takeFirst();
1.49 - delete a;
1.50 - }
1.51 - return;
1.52 - } else
1.53 - {
1.54 - model->select (ti->getXLinkNum(0)->getOtherBranch (ti));
1.55 - return;
1.56 - }
1.57 + QAction *a=alist.takeFirst();
1.58 + delete a;
1.59 + }
1.60 + return;
1.61 }
1.62 }
1.63 }
1.64 @@ -1112,11 +1103,13 @@
1.65 if (bi_begin)
1.66 {
1.67 drawingLink=true;
1.68 - tmpXLink=model->createXLink(bi_begin,true);
1.69 - tmpXLink->setColor(model->getMapDefXLinkColor());
1.70 - tmpXLink->setWidth(model->getMapDefXLinkWidth());
1.71 - tmpXLink->setEnd (p);
1.72 - tmpXLink->updateXLink();
1.73 + tmpLink=new Link (model);
1.74 + tmpLink->setBeginBranch (bi_begin);
1.75 + tmpLink->setColor(model->getMapDefXLinkColor());
1.76 + tmpLink->setWidth(model->getMapDefXLinkWidth());
1.77 + tmpLink->setEndPoint (p);
1.78 + tmpLink->createMapObj(mapScene);
1.79 + tmpLink->updateLink();
1.80 return;
1.81 }
1.82 }
1.83 @@ -1141,8 +1134,11 @@
1.84 movingObj_start.setY( p.y() - lmo->y() );
1.85 movingObj_orgPos.setX (lmo->x() );
1.86 movingObj_orgPos.setY (lmo->y() );
1.87 - lmo->setRelPos();
1.88 - movingObj_orgRelPos=lmo->getRelPos();
1.89 + if (ti->depth()>0)
1.90 + {
1.91 + lmo->setRelPos();
1.92 + movingObj_orgRelPos=lmo->getRelPos();
1.93 + }
1.94
1.95 // If modMode==copy, then we want to "move" the _new_ object around
1.96 // then we need the offset from p to the _old_ selection, because of tmp
1.97 @@ -1204,11 +1200,10 @@
1.98 if (mainWindow->getModMode()!=Main::ModModeCopy)
1.99 setCursor (Qt::ArrowCursor);
1.100
1.101 + // Scroll if needed
1.102 // To avoid jumping of the sceneView, only
1.103 // show selection, if not tmp linked
1.104 - /* FIXME-2 if (!lmosel->hasParObjTmp())
1.105 - model->emitShowSelection();
1.106 - */
1.107 + model->emitShowSelection();
1.108
1.109 // Now move the selection, but add relative position
1.110 // (movingObj_start) where selection was chosen with
1.111 @@ -1275,6 +1270,7 @@
1.112 seli->getBranchObjNum(i)->setOrientation();
1.113 }
1.114 }
1.115 + lmosel->move (p-movingObj_start);
1.116 } else
1.117 {
1.118 if (seli->depth()==1)
1.119 @@ -1326,8 +1322,8 @@
1.120 // Draw a link from one branch to another
1.121 if (drawingLink)
1.122 {
1.123 - tmpXLink->setEnd (p);
1.124 - tmpXLink->updateXLink();
1.125 + tmpLink->setEndPoint (p);
1.126 + tmpLink->updateLink();
1.127 }
1.128
1.129 // Move sceneView
1.130 @@ -1380,18 +1376,20 @@
1.131 // Check if we are over another branch
1.132 if (dsti)
1.133 {
1.134 - tmpXLink->setEnd ( ((BranchItem*)dsti) );
1.135 - tmpXLink->updateXLink();
1.136 - tmpXLink->activate();
1.137 + tmpLink->setEndBranch ( ((BranchItem*)dsti) );
1.138 + tmpLink->updateLink();
1.139 + model->createLink (tmpLink);
1.140 + /* FIXME-2 Link savestate missing, segfaulting on undo
1.141 model->saveState(
1.142 tmpXLink,QString("delete ()"),
1.143 dsti,QString("addXLink (\"%1\",\"%2\")").arg(model->getSelectString(tmpXLink->getBegin())).arg(model->getSelectString(dsti)),
1.144 QString("Add xLink from %1 to %2").arg(model->getObjectName(tmpXLink->getBegin())).arg(model->getObjectName(dsti))
1.145 );
1.146 + */
1.147 } else
1.148 {
1.149 - model->deleteItem(tmpXLink);
1.150 - tmpXLink=NULL;
1.151 + delete (tmpLink);
1.152 + tmpLink=NULL;
1.153 }
1.154 return;
1.155 }
1.156 @@ -1576,6 +1574,13 @@
1.157 }
1.158 }
1.159
1.160 +void MapEditor::wheelEvent(QWheelEvent* e)
1.161 +{
1.162 + //qDebug ()<<"ME::wheelEvent"; //FIXME-2 stop all animations in vymModel here
1.163 + //model->stopAllAnimation();
1.164 + QGraphicsView::wheelEvent (e);
1.165 +}
1.166 +
1.167 void MapEditor::resizeEvent (QResizeEvent* e)
1.168 {
1.169 QGraphicsView::resizeEvent( e );