diff -r 7b4e73ac247e -r 1fb50e79661c mapeditor.cpp --- a/mapeditor.cpp Mon Jun 29 10:28:28 2009 +0000 +++ b/mapeditor.cpp Tue Jul 07 09:34:24 2009 +0000 @@ -189,7 +189,7 @@ LinkableMapObj* lmo=NULL; TreeItem *ti= static_cast(index.internalPointer()); if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() ) - lmo=ti->getLMO(); + lmo=((MapItem*)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=ti->getLMO(); + if (ti) lmo=((MapItem*)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=ti->getLMO(); + if (ti) lmo=((MapItem*)ti)->getLMO(); e->accept(); @@ -818,7 +818,7 @@ TreeItem *seli=model->getSelectedItem(); LinkableMapObj* lmosel=NULL; if (seli && (seli->isBranchLikeType() ||seli->getType()==TreeItem::Image)) - lmosel=seli->getLMO(); + lmosel=((MapItem*)seli)->getLMO(); // Move the selected MapObj if ( lmosel && movingObj) @@ -854,7 +854,7 @@ FloatObj *fio=(FloatImageObj*)lmosel; fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); fio->setRelPos(); - fio->updateLink(); //no need for reposition, if we update link here + fio->updateLinkGeometry(); //no need for reposition, if we update link here model->emitSelectionChanged(); // position has changed // Relink float to new mapcenter or branch, if shift is pressed @@ -968,7 +968,7 @@ if (seli) dsti=findMapItem(p, seli); LinkableMapObj* dst=NULL; if (dsti && dsti->isBranchLikeType ()) - dst=dsti->getLMO(); + dst=((MapItem*)dsti)->getLMO(); else dsti=NULL; @@ -1013,7 +1013,7 @@ { if (seli->getType()==TreeItem::Image) { - FloatImageObj *fio=(FloatImageObj*)(seli->getLMO()); + FloatImageObj *fio=(FloatImageObj*)( ((MapItem*)seli)->getLMO()); if(fio) { // Moved FloatObj. Maybe we need to reposition @@ -1051,7 +1051,7 @@ if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch ) { // A branch was moved LinkableMapObj* lmosel=NULL; - lmosel=seli->getLMO(); + lmosel=((MapItem*)seli)->getLMO(); // save the position in case we link to mapcenter QPointF savePos=QPointF (lmosel->getAbsPos() ); @@ -1272,6 +1272,9 @@ void MapEditor::updateSelection(QItemSelection newsel,QItemSelection oldsel) { + // Note: Here we are prepared for multiple selections, though this + // is not yet implemented elsewhere + // Here in MapEditor we can only select Branches and Images QModelIndex ix; foreach (ix,newsel.indexes() ) @@ -1281,6 +1284,7 @@ newsel.indexes().removeOne (ix); } + // Trim list of selection rectangles while (newsel.indexes().count() < selboxList.count() ) delete selboxList.takeFirst(); @@ -1291,10 +1295,17 @@ if (ix.isValid() ) { TreeItem *ti= static_cast(ix.internalPointer()); - if (ti && ti->isBranchLikeType() ) + if (ti) { - BranchItem *bi=(BranchItem*)ti; - bi->resetTmpUnscroll(); + if (ti->isBranchLikeType() ) + { + // reset tmp scrolled branches + BranchItem *bi=(BranchItem*)ti; + bi->resetTmpUnscroll(); + } + if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image) + // Hide link if not needed + ((MapItem*)ti)->getLMO()->updateVisibility(); } } } @@ -1313,6 +1324,9 @@ bi->tmpUnscroll(); } scrollTo (ix); + if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image) + // Show link if needed + ((MapItem*)ti)->getLMO()->updateVisibility(); } } @@ -1344,7 +1358,7 @@ { index=newsel.indexes().at(i); ti= static_cast(index.internalPointer()); - lmo=ti->getLMO(); + lmo=((MapItem*)ti)->getLMO(); bbox=lmo->getBBox(); sb->setRect ( bbox.x(),bbox.y(), @@ -1370,7 +1384,7 @@ if (ti->isBranchLikeType()) { - BranchObj *bo=(BranchObj*) (ti->getLMO()); + BranchObj *bo=(BranchObj*) ( ((MapItem*)ti)->getLMO()); bo->updateData(); }