diff -r 25e634a7e1dc -r 8acac4fade1b mapeditor.cpp --- a/mapeditor.cpp Mon Jun 08 11:36:56 2009 +0000 +++ b/mapeditor.cpp Mon Jun 29 10:27:42 2009 +0000 @@ -189,7 +189,7 @@ LinkableMapObj* lmo=NULL; TreeItem *ti= static_cast(index.internalPointer()); if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() ) - lmo=((MapItem*)ti)->getLMO(); + lmo=ti->getLMO(); if (lmo) setScrollBarPosTarget (lmo->getBBox() ); } } @@ -599,7 +599,7 @@ QPointF p = mapToScene(e->pos()); TreeItem *ti=findMapItem (p, NULL); LinkableMapObj* lmo=NULL; - if (ti) lmo=((MapItem*)ti)->getLMO(); + if (ti) lmo=ti->getLMO(); if (lmo) { // MapObj was found @@ -683,7 +683,7 @@ QPointF p = mapToScene(e->pos()); TreeItem *ti=findMapItem (p, NULL); LinkableMapObj* lmo=NULL; - if (ti) lmo=((MapItem*)ti)->getLMO(); + if (ti) lmo=ti->getLMO(); e->accept(); @@ -763,8 +763,6 @@ // Left Button Move Branches if (e->button() == Qt::LeftButton ) { - //movingObj_start.setX( p.x() - selection->x() );// TODO replaced selection->lmo here - //movingObj_start.setY( p.y() - selection->y() ); movingObj_start.setX( p.x() - lmo->x() ); movingObj_start.setY( p.y() - lmo->y() ); movingObj_orgPos.setX (lmo->x() ); @@ -818,9 +816,9 @@ { QPointF p = mapToScene(e->pos()); TreeItem *seli=model->getSelectedItem(); - LinkableMapObj* lmosel=NULL; //FIXME-2 get rid of lmosel + LinkableMapObj* lmosel=NULL; if (seli && (seli->isBranchLikeType() ||seli->getType()==TreeItem::Image)) - lmosel=((MapItem*)seli)->getLMO(); + lmosel=seli->getLMO(); // Move the selected MapObj if ( lmosel && movingObj) @@ -840,15 +838,18 @@ // of selection back to absPos) // Check if we could link - TreeItem *dsti=findMapItem (p, seli); + TreeItem *ti=findMapItem (p, seli); + BranchItem *dsti=NULL; LinkableMapObj* dst=NULL; - if (dsti && dsti!=seli && dsti->isBranchLikeType()) - dst=((MapItem*)dsti)->getLMO(); - else + if (ti && ti!=seli && ti->isBranchLikeType()) + { + dsti=(BranchItem*)ti; + dst=dsti->getLMO(); + } else dsti=NULL; - if (lmosel && seli->getType()==TreeItem::Image) + if (lmosel && seli->getType()==TreeItem::Image) { FloatObj *fio=(FloatImageObj*)lmosel; fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); @@ -858,23 +859,23 @@ // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent - if ( (e->modifiers()==Qt::ShiftModifier) && dst && ( dst != fio->getParObj()) - ) + if ( e->modifiers()==Qt::ShiftModifier && dsti && dsti != seli->parent() ) { // Also save the move which was done so far QString pold=qpointfToString(movingObj_orgRelPos); QString pnow=qpointfToString(fio->getRelPos()); model->saveState( - fio->getTreeItem(), // FIXME-3 + seli, "moveRel "+pold, - fio->getTreeItem(), + seli, "moveRel "+pnow, QString("Move %1 to relative position %2").arg(model->getObjectName(fio)).arg(pnow)); fio->getParObj()->requestReposition(); model->reposition(); - model->linkFloatImageTo (model->getSelectString(dst)); - //movingObj=lmosel; + model->relinkImage ((ImageItem*) seli,dsti); + model->select (seli); + //movingObj=lmosel; //FIXME-3 //movingObj_orgRelPos=lmosel->getRelPos(); model->reposition(); @@ -967,7 +968,7 @@ if (seli) dsti=findMapItem(p, seli); LinkableMapObj* dst=NULL; if (dsti && dsti->isBranchLikeType ()) - dst=((MapItem*)dsti)->getLMO(); + dst=dsti->getLMO(); else dsti=NULL; @@ -1012,7 +1013,7 @@ { if (seli->getType()==TreeItem::Image) { - FloatImageObj *fio=(FloatImageObj*)(((MapItem*)seli)->getLMO()); + FloatImageObj *fio=(FloatImageObj*)(seli->getLMO()); if(fio) { // Moved FloatObj. Maybe we need to reposition @@ -1049,8 +1050,8 @@ if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch ) { // A branch was moved - LinkableMapObj* lmosel=NULL; //FIXME-2 get rid of lmosel - lmosel=((MapItem*)seli)->getLMO(); + LinkableMapObj* lmosel=NULL; + lmosel=seli->getLMO(); // save the position in case we link to mapcenter QPointF savePos=QPointF (lmosel->getAbsPos() ); @@ -1343,7 +1344,7 @@ { index=newsel.indexes().at(i); ti= static_cast(index.internalPointer()); - lmo=((MapItem*)ti)->getLMO(); + lmo=ti->getLMO(); bbox=lmo->getBBox(); sb->setRect ( bbox.x(),bbox.y(), @@ -1369,7 +1370,7 @@ if (ti->isBranchLikeType()) { - BranchObj *bo=(BranchObj*) ((MapItem*)ti)->getLMO(); + BranchObj *bo=(BranchObj*) (ti->getLMO()); bo->updateData(); }