diff -r 2f002657dada -r 6e4b586aa88a mapeditor.cpp --- a/mapeditor.cpp Tue May 26 11:24:51 2009 +0000 +++ b/mapeditor.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -858,7 +858,7 @@ 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 - model->updateSelection(); // position has changed + model->emitSelectionChanged(); // position has changed // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent @@ -1147,7 +1147,7 @@ model->reposition(); } } - model->updateSelection(); //FIXME-3 needed? at least not after pos of selection has changed... + model->emitSelectionChanged(); //FIXME-3 needed? at least not after pos of selection has changed... // Finally resize scene, if needed scene()->update(); movingObj=NULL; @@ -1236,7 +1236,7 @@ // Workaround to avoid adding empty branches if (!uris.at(i).toString().isEmpty()) { - bi=model->createBranch(); + bi=model->addNewBranch(); if (bi) { /* FIXME-2 @@ -1270,8 +1270,40 @@ event->acceptProposedAction(); } -void MapEditor::updateSelection(const QItemSelection &newsel,const QItemSelection &) +void MapEditor::updateSelection(const QItemSelection &newsel,const QItemSelection &oldsel) { + // Take care to tmp scroll/unscroll + if (!oldsel.isEmpty()) + { + QModelIndex ix=oldsel.indexes().first(); + if (ix.isValid() ) + { + TreeItem *ti= static_cast(ix.internalPointer()); + if (ti && ti->isBranchLikeType() ) + { + BranchItem *bi=(BranchItem*)ti; + bi->resetTmpUnscroll(); + } + } + } + + if (!newsel.isEmpty()) + { + QModelIndex ix=newsel.indexes().first(); + if (ix.isValid() ) + { + // Temporary unscroll if necessary + TreeItem *ti= static_cast(ix.internalPointer()); + if (ti->isBranchLikeType() ) + { + BranchItem *bi=(BranchItem*)ti; + if (bi->hasScrolledParent(bi) ) + bi->tmpUnscroll(); + } + scrollTo (ix); + } + } + // Reduce rectangles while (newsel.indexes().count() < selboxList.count() ) delete selboxList.takeFirst(); @@ -1309,6 +1341,8 @@ sb->setBrush (selectionColor); i++; } + + scene()->update(); } void MapEditor::updateData (const QModelIndex &sel)