diff -r db0ec4bcf416 -r ed5b407975b3 mapeditor.cpp --- a/mapeditor.cpp Mon Apr 20 10:42:05 2009 +0000 +++ b/mapeditor.cpp Thu Apr 23 12:15:31 2009 +0000 @@ -719,7 +719,7 @@ } } else { // selection != a FloatObj - if (lmosel->getDepth()==0) //FIXME-1 also moved mapcenters could be linked, but not working here... + if (seli->depth()==0) //FIXME-1 also moved mapcenters could be linked, but not working here... { // Move MapCenter if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) @@ -729,7 +729,7 @@ model->updateRelPositions(); } else { - if (lmosel->getDepth()==1) + if (seli->depth()==1) { // Move mainbranch lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); @@ -797,13 +797,12 @@ void MapEditor::mouseReleaseEvent(QMouseEvent* e) { QPointF p = mapToScene(e->pos()); - TreeItem *dsti=findMapItem(p, NULL); - LinkableMapObj* dst=NULL; - if (dsti) dst=dsti->getLMO(); //FIXME-2 get rid of dst... - TreeItem *seli=model->getSelectedItem(); LinkableMapObj *lmosel=seli->getLMO(); // FIXME-2 get rid of lmosel + TreeItem *dsti=findMapItem(p, seli); + LinkableMapObj* dst=NULL; + if (dsti) dst=dsti->getLMO(); //FIXME-2 get rid of dst... // Have we been picking color? @@ -905,37 +904,36 @@ QString preSelStr=model->getSelectString(lmosel); copyingObj=false; - if (dsti ) + if (dsti && dsti->isBranchLikeType() ) { // We have a destination, relink to that BranchObj* bsel=model->getSelectedBranchObj(); - TreeItem * tisel=model->getSelectedItem(); BranchObj* bdst=(BranchObj*)dst; - TreeItem* tidst=dst->getTreeItem(); QString preParStr=model->getSelectString (bsel->getParObj()); - QString preNum=QString::number (tisel->num(),10); + QString preNum=QString::number (seli->num(),10); QString preDstParStr; if (e->state() & Qt::ShiftModifier && dst->getParObj()) { // Link above dst preDstParStr=model->getSelectString (dst->getParObj()); - bsel->linkTo ( (BranchObj*)(bdst->getParObj()), tidst->num()); + bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()); } else if (e->state() & Qt::ControlModifier && dst->getParObj()) { // Link below dst preDstParStr=model->getSelectString (dst->getParObj()); - bsel->linkTo ( (BranchObj*)(bdst->getParObj()), tidst->num()+1); + bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()+1); } else { // Append to dst preDstParStr=model->getSelectString(dst); bsel->linkTo (bdst,-1); - if (dst->getDepth()==0) bsel->move (savePos); + model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti); + if (dsti->depth()==0) bsel->move (savePos); } QString postSelStr=model->getSelectString(lmosel); - QString postNum=QString::number (tisel->num(),10); + QString postNum=QString::number (seli->num(),10); QString undoCom="linkTo (\""+ preParStr+ "\"," + preNum +"," + @@ -955,7 +953,7 @@ { // No destination, undo temporary move - if (lmosel->getDepth()==1) + if (seli->depth()==1) { cout << "ME::releaseMouse d=1\n"; // FIXME_1 better use depth // The select string might be different _after_ moving around. @@ -974,7 +972,7 @@ } // Draw the original link, before selection was moved around - if (settings.value("/animation/use",false).toBool() && lmosel->getDepth()>1) + 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...