mapeditor.cpp
changeset 775 6e4b586aa88a
parent 773 340bc29da9a0
child 776 25e634a7e1dc
     1.1 --- a/mapeditor.cpp	Tue May 26 11:24:51 2009 +0000
     1.2 +++ b/mapeditor.cpp	Wed Jun 03 20:37:17 2009 +0000
     1.3 @@ -858,7 +858,7 @@
     1.4  			fio->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
     1.5  			fio->setRelPos();
     1.6  			fio->updateLink(); //no need for reposition, if we update link here
     1.7 -			model->updateSelection();	// position has changed
     1.8 +			model->emitSelectionChanged();	// position has changed
     1.9  
    1.10  			// Relink float to new mapcenter or branch, if shift is pressed	
    1.11  			// Only relink, if selection really has a new parent
    1.12 @@ -1147,7 +1147,7 @@
    1.13  					model->reposition();
    1.14  			}
    1.15  		}
    1.16 -		model->updateSelection();  //FIXME-3 needed? at least not after pos of selection has changed...
    1.17 +		model->emitSelectionChanged();  //FIXME-3 needed? at least not after pos of selection has changed...
    1.18  		// Finally resize scene, if needed
    1.19  		scene()->update();
    1.20  		movingObj=NULL;		
    1.21 @@ -1236,7 +1236,7 @@
    1.22  				// Workaround to avoid adding empty branches
    1.23  				if (!uris.at(i).toString().isEmpty())
    1.24  				{
    1.25 -					bi=model->createBranch();
    1.26 +					bi=model->addNewBranch();
    1.27  					if (bi)
    1.28  					{
    1.29  						   /* FIXME-2 
    1.30 @@ -1270,8 +1270,40 @@
    1.31  	event->acceptProposedAction();
    1.32  }
    1.33  
    1.34 -void MapEditor::updateSelection(const QItemSelection &newsel,const QItemSelection &)
    1.35 +void MapEditor::updateSelection(const QItemSelection &newsel,const QItemSelection &oldsel)
    1.36  {
    1.37 +	// Take care to tmp scroll/unscroll
    1.38 +	if (!oldsel.isEmpty())
    1.39 +	{
    1.40 +		QModelIndex ix=oldsel.indexes().first(); 
    1.41 +		if (ix.isValid() )
    1.42 +		{
    1.43 +			TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
    1.44 +			if (ti && ti->isBranchLikeType() )
    1.45 +			{
    1.46 +				BranchItem *bi=(BranchItem*)ti;
    1.47 +				bi->resetTmpUnscroll();
    1.48 +			}
    1.49 +		}
    1.50 +	}
    1.51 +
    1.52 +	if (!newsel.isEmpty())
    1.53 +	{
    1.54 +		QModelIndex ix=newsel.indexes().first(); 
    1.55 +		if (ix.isValid() )
    1.56 +		{
    1.57 +			// Temporary unscroll if necessary
    1.58 +			TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
    1.59 +			if (ti->isBranchLikeType() )
    1.60 +			{
    1.61 +				BranchItem *bi=(BranchItem*)ti;
    1.62 +				if (bi->hasScrolledParent(bi) )
    1.63 +					bi->tmpUnscroll();
    1.64 +			}
    1.65 +			scrollTo (ix);
    1.66 +		}
    1.67 +	}
    1.68 +
    1.69  	// Reduce rectangles
    1.70  	while (newsel.indexes().count() < selboxList.count() )
    1.71  		delete selboxList.takeFirst();
    1.72 @@ -1309,6 +1341,8 @@
    1.73  		sb->setBrush (selectionColor);	
    1.74  		i++;
    1.75  	}
    1.76 +
    1.77 +	scene()->update();
    1.78  }
    1.79  
    1.80  void MapEditor::updateData (const QModelIndex &sel)