diff -r 01f2f6d6789d -r e3f722759c7e mapeditor.cpp --- a/mapeditor.cpp Mon May 18 11:22:41 2009 +0000 +++ b/mapeditor.cpp Wed May 20 15:40:14 2009 +0000 @@ -118,7 +118,7 @@ lineEdit=new QLineEdit; lineEdit->hide(); QGraphicsProxyWidget *pw=scene()->addWidget (lineEdit); - pw->setZValue (100); + pw->setZValue (Z_LINEEDIT); a = new QAction( tr( "Edit heading","MapEditor" ), this); a->setShortcut ( Qt::Key_Return ); //Edit heading @@ -182,6 +182,15 @@ return mapScene; } +void MapEditor::scrollTo (const QModelIndex &index) +{ + if (index.isValid()) + { + LinkableMapObj* lmo=(static_cast(index.internalPointer()))->getLMO(); + if (lmo) setScrollBarPosTarget (lmo->getBBox() ); + } +} + void MapEditor::setScrollBarPosTarget (const QRectF &rect) { // Code copied from Qt sources @@ -838,7 +847,10 @@ // Check if we could link TreeItem *dsti=findMapItem (p, seli); LinkableMapObj* dst=NULL; - if (dsti) dst=dsti->getLMO(); //FIXME-2 get rid of lmo... + if (dsti && dsti!=seli && dsti->isBranchLikeType()) + dst=dsti->getLMO(); //FIXME-2 get rid of lmo... + else + dsti=NULL; FloatObj *fio=model->getSelectedFloatImage(); @@ -851,15 +863,10 @@ // 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 && - ( (typeid(*dst)==typeid(BranchObj)) || - (typeid(*dst)==typeid(MapCenterObj)) ) && - ( dst != fio->getParObj()) + if ( (e->modifiers()==Qt::ShiftModifier) && dst && ( dst != fio->getParObj()) ) { - if (typeid(*fio) == typeid(FloatImageObj) && - ( (typeid(*dst)==typeid(BranchObj) || - typeid(*dst)==typeid(MapCenterObj)) )) + if (typeid(*fio) == typeid(FloatImageObj) ) { // Also save the move which was done so far @@ -911,7 +918,7 @@ } // Maybe we can relink temporary? - if (dsti && (dst!=lmosel) && seli->isBranchLikeType() && dsti->isBranchLikeType() ) + if (dsti) { if (e->modifiers()==Qt::ControlModifier) { @@ -963,9 +970,13 @@ QPointF p = mapToScene(e->pos()); TreeItem *seli=model->getSelectedItem(); - TreeItem *dsti=findMapItem(p, seli); + TreeItem *dsti=NULL; + if (seli) dsti=findMapItem(p, seli); LinkableMapObj* dst=NULL; - if (dsti) dst=dsti->getLMO(); //FIXME-2 get rid of dst... + if (dsti && dsti->isBranchLikeType ()) + dst=dsti->getLMO(); //FIXME-2 get rid of dst... + else + dsti=NULL; // Have we been picking color? @@ -974,7 +985,7 @@ pickingColor=false; setCursor (Qt::ArrowCursor); // Check if we are over another branch - if (dsti && seli) + if (dst) { if (e->state() & Qt::ShiftModifier) model->colorBranch (((BranchObj*)dst)->getColor()); @@ -989,7 +1000,7 @@ { drawingLink=false; // Check if we are over another branch - if (dsti && seli && dsti->isBranchLikeType() ) + if (dsti) { tmpXLink->setEnd ( ((BranchObj*)(dst)) ); tmpXLink->updateXLink(); @@ -1006,11 +1017,6 @@ // Have we been moving something? if ( seli && movingObj ) { - if (dsti==seli) - { - dsti=NULL; - dst=NULL; - } FloatImageObj *fo=model->getSelectedFloatImage(); if(fo) { @@ -1028,15 +1034,6 @@ model->reposition(); } - // Check if we are over another branch, but ignore - // any found LMOs, which are FloatObjs - - if (dsti && (!dsti->isBranchLikeType() )) - { - dst=NULL; - dsti=NULL; - } - BranchItem *bi=model->getSelectedBranchItem(); if (bi && bi->depth()==0) { @@ -1069,7 +1066,7 @@ QString preSelStr=model->getSelectString(lmosel); copyingObj=false; - if (dsti && dsti->isBranchLikeType() ) + if (dsti) { // We have a destination, relink to that