mapeditor.cpp
changeset 731 c8b1a3564c74
parent 730 0594d7b7099d
child 732 b77b56f707f1
     1.1 --- a/mapeditor.cpp	Tue Dec 09 16:44:54 2008 +0000
     1.2 +++ b/mapeditor.cpp	Wed Dec 10 13:10:35 2008 +0000
     1.3 @@ -736,7 +736,9 @@
     1.4  				lmosel->reposition();	
     1.5  			} // depth>0
     1.6  
     1.7 -			model->updateSelection();// FIXME needed? 
     1.8 +			//model->updateSelection();// FIXME needed? 
     1.9 +			//updateSelectionGeometry();
    1.10 +			updateSelection(selModel->selection(), selModel->selection() );
    1.11  		} // no FloatImageObj
    1.12  
    1.13  		scene()->update();
    1.14 @@ -1066,31 +1068,7 @@
    1.15  {
    1.16  	cout << "ME::updateSelection\n";
    1.17  
    1.18 -	QGraphicsRectItem *sb;
    1.19  
    1.20 -/*
    1.21 -	// Check if selection is empty
    1.22 -	if (newsel.indexes().isEmpty() )
    1.23 -	{
    1.24 -		if (!selboxList.isEmpty())
    1.25 -			while (!selboxList.isEmpty() )
    1.26 -				delete selboxList.takeFirst();
    1.27 -		return;		
    1.28 -	}
    1.29 -
    1.30 -	if (selboxList.isEmpty())
    1.31 -	{
    1.32 -
    1.33 -		sb = mapScene->addRect(
    1.34 -			QRectF(0,0,0,0), 
    1.35 -			QPen(selectionColor),
    1.36 -			selectionColor);
    1.37 -		sb->setZValue(Z_SELBOX);
    1.38 -		sb->show();
    1.39 -		selboxList.append (sb);
    1.40 -	} else
    1.41 -		sb=selboxList.first();
    1.42 -*/		
    1.43  	if (newsel.isEmpty() )
    1.44  	{
    1.45  		cout << "   newsel=empty!\n";
    1.46 @@ -1104,18 +1082,40 @@
    1.47  	cout << "   h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
    1.48  	cout << "   ti ("<<ti->row()<<","<<ti->column()<<") = "<<ti<<endl;
    1.49  
    1.50 -/*
    1.51 -	int w=0;	// FIXME what for?
    1.52 -	if (lmo)
    1.53 +
    1.54 +	// Reduce rectangles
    1.55 +	while (newsel.indexes().count() < selboxList.count() )
    1.56 +		delete selboxList.takeFirst();
    1.57 +
    1.58 +	// Add additonal rectangles
    1.59 +	QGraphicsRectItem *sb;
    1.60 +	while (newsel.indexes().count() > selboxList.count() )
    1.61  	{
    1.62 -		QRectF bbox=lmo->getBBox();
    1.63 -		selboxList.first()->setRect (
    1.64 -			bbox.x()-w,bbox.y()-w, 
    1.65 -			bbox.width()+2*w, bbox.height()+2*w);
    1.66 -		selboxList.first()->setPen (selectionColor);	
    1.67 -		selboxList.first()->setBrush (selectionColor);	
    1.68 +		sb = mapScene->addRect(
    1.69 +			QRectF(0,0,0,0), 
    1.70 +			QPen(selectionColor),
    1.71 +			selectionColor);
    1.72 +		sb->setZValue(Z_SELBOX);
    1.73 +		sb->show();
    1.74 +		selboxList.append (sb);
    1.75  	}
    1.76 -*/	
    1.77 +
    1.78 +	// Reposition rectangles
    1.79 +	int i=0;
    1.80 +	QRectF bbox;
    1.81 +	foreach (sb,selboxList)
    1.82 +	{
    1.83 +		index=newsel.indexes().at(i);
    1.84 +		ti= static_cast<TreeItem*>(index.internalPointer());
    1.85 +		lmo=ti->getLMO();
    1.86 +		bbox=lmo->getBBox();
    1.87 +		sb->setRect (
    1.88 +			bbox.x(),bbox.y(), 
    1.89 +			bbox.width(), bbox.height());
    1.90 +		sb->setPen (selectionColor);	
    1.91 +		sb->setBrush (selectionColor);	
    1.92 +		i++;
    1.93 +	}
    1.94  }
    1.95  
    1.96  void MapEditor::updateCurrent (const QModelIndex &newsel,const QModelIndex &)
    1.97 @@ -1137,7 +1137,8 @@
    1.98  	cout << "ME::updateSelectionGeometry\n";
    1.99  
   1.100  	// Tell selection to update geometries
   1.101 -	model->updateSelection();
   1.102 +	updateSelection(selModel->selection(), selModel->selection() );
   1.103 +	//model->updateSelection();
   1.104  }
   1.105  
   1.106