mapeditor.cpp
changeset 729 7ddbe3fa34a1
parent 728 a8a98a94899a
child 730 0594d7b7099d
     1.1 --- a/mapeditor.cpp	Tue Nov 04 12:09:10 2008 +0000
     1.2 +++ b/mapeditor.cpp	Mon Dec 08 16:57:33 2008 +0000
     1.3 @@ -538,8 +538,34 @@
     1.4  
     1.5      if (lmo) 
     1.6  	{	
     1.7 +		cout << "ME::mouse pressed\n";
     1.8 +		cout << "  lmo="<<lmo<<endl;
     1.9 +		cout << "  h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
    1.10  		// Select the clicked object
    1.11 -		model->selectInt (lmo);
    1.12 +		// FIXME VM use index & signal below instead of lmo   
    1.13 +		// model->selectInt (lmo);
    1.14 +
    1.15 +		// FIXME VM better let "find" return an index instead of lmo...
    1.16 +		// Get index of clicked LMO
    1.17 +		TreeItem *ti=lmo->getTreeItem();
    1.18 +		cout << "  lmo="<<lmo<<"    lmo(ti)="<<ti->getLMO()<<endl;
    1.19 +		cout << "  ti ("<<ti->row()<<","<<ti->column()<<") = "<<ti<<endl;
    1.20 +		//QModelIndex ix=model->index( ti->row(), ti->column(), model->index (0,0,QModelIndex()) );
    1.21 +		QModelIndex ix=model->index(ti);
    1.22 +		selModel->select (ix,QItemSelectionModel::ClearAndSelect  );
    1.23 +		/*
    1.24 +		if (selModel->hasSelection() ) 
    1.25 +		{
    1.26 +			QModelIndex ixsel=selModel->selectedIndexes().first();
    1.27 +			TreeItem *tisel= static_cast<TreeItem*>(ixsel.internalPointer());
    1.28 +	;
    1.29 +			cout << "  ti="<<ti<<"  tisel="<<tisel<<endl;
    1.30 +			if (ti!=tisel) int i=1/0;
    1.31 +		}
    1.32 +		else
    1.33 +			cout <<"MapEditor::mousePressed  No selection!!!\n";
    1.34 +		*/
    1.35 +
    1.36  
    1.37  		// Left Button	    Move Branches
    1.38  		if (e->button() == Qt::LeftButton )
    1.39 @@ -1044,6 +1070,7 @@
    1.40  
    1.41  	QGraphicsRectItem *sb;
    1.42  
    1.43 +/*
    1.44  	// Check if selection is empty
    1.45  	if (newsel.indexes().isEmpty() )
    1.46  	{
    1.47 @@ -1055,6 +1082,7 @@
    1.48  
    1.49  	if (selboxList.isEmpty())
    1.50  	{
    1.51 +
    1.52  		sb = mapScene->addRect(
    1.53  			QRectF(0,0,0,0), 
    1.54  			QPen(selectionColor),
    1.55 @@ -1064,12 +1092,21 @@
    1.56  		selboxList.append (sb);
    1.57  	} else
    1.58  		sb=selboxList.first();
    1.59 -		
    1.60 +*/		
    1.61 +	if (newsel.isEmpty() )
    1.62 +	{
    1.63 +		cout << "   newsel=empty!\n";
    1.64 +		return;
    1.65 +	}	
    1.66  	QModelIndex index=newsel.indexes().first();	// TODO no multiselections yet
    1.67  
    1.68 -	TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
    1.69 -	LinkableMapObj *lmo=item->getLMO();
    1.70 +	TreeItem *ti= static_cast<TreeItem*>(index.internalPointer());
    1.71 +	LinkableMapObj *lmo=ti->getLMO();
    1.72 +	cout << "   newsel.count="<<newsel.indexes().count()<<"  lmo="<<lmo<<endl;
    1.73 +	cout << "   h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
    1.74 +	cout << "   ti ("<<ti->row()<<","<<ti->column()<<") = "<<ti<<endl;
    1.75  
    1.76 +/*
    1.77  	int w=0;	// FIXME what for?
    1.78  	if (lmo)
    1.79  	{
    1.80 @@ -1080,8 +1117,20 @@
    1.81  		selboxList.first()->setPen (selectionColor);	
    1.82  		selboxList.first()->setBrush (selectionColor);	
    1.83  	}
    1.84 -	
    1.85 +*/	
    1.86 +}
    1.87  
    1.88 +void MapEditor::updateCurrent (const QModelIndex &newsel,const QModelIndex &)
    1.89 +{
    1.90 +	cout << "ME::updateCurrent\n";
    1.91 +
    1.92 +/*
    1.93 +
    1.94 +	TreeItem *item = static_cast<TreeItem*>(newsel.internalPointer());
    1.95 +	LinkableMapObj *lmo=item->getLMO();
    1.96 +	cout << "  lmo="<<lmo<<endl;
    1.97 +	cout << "  h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
    1.98 +	*/
    1.99  
   1.100  }
   1.101