mapeditor.cpp
changeset 798 d251c7b2de54
parent 796 cf634bbf9e04
child 800 959bd133cd1a
     1.1 --- a/mapeditor.cpp	Wed Sep 23 12:14:08 2009 +0000
     1.2 +++ b/mapeditor.cpp	Thu Oct 01 11:28:50 2009 +0000
     1.3 @@ -64,6 +64,7 @@
     1.4  	pickingColor=false;
     1.5  	drawingLink=false;
     1.6  	copyingObj=false;
     1.7 +	objectMoved=false;
     1.8  
     1.9      editingBO=NULL;
    1.10      movingObj=NULL;
    1.11 @@ -184,17 +185,20 @@
    1.12      return mapScene;
    1.13  }
    1.14  
    1.15 -void MapEditor::scrollTo (const QModelIndex &index)
    1.16 +void MapEditor::scrollTo (const QModelIndex &index)	//FIXME-1 problems with locating stuff in big maps
    1.17  {
    1.18 -	//cout <<"ME::scrollTo aborted\n";
    1.19 -	//return;
    1.20  	if (index.isValid())
    1.21  	{
    1.22  		LinkableMapObj* lmo=NULL;
    1.23  		TreeItem *ti= static_cast<TreeItem*>(index.internalPointer());
    1.24  		if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() )
    1.25  			lmo=((MapItem*)ti)->getLMO();
    1.26 -		if (lmo) setScrollBarPosTarget (lmo->getBBox() );
    1.27 +		if (lmo) 
    1.28 +		{
    1.29 +			QRectF r=lmo->getBBox();
    1.30 +			cout << "ME::scrollTo "<<ti->getHeadingStd()<<"  tL="<<r.topLeft()<<"  bR="<<r.bottomRight()<<endl;
    1.31 +			setScrollBarPosTarget (lmo->getBBox() );
    1.32 +		}	
    1.33  	}
    1.34  }
    1.35  
    1.36 @@ -457,6 +461,14 @@
    1.37  void MapEditor::testFunction1()
    1.38  {
    1.39  	cout << "ME::test1  selected TI="<<model->getSelectedItem()<<endl;
    1.40 +
    1.41 +	BranchObj *bo=model->getSelectedBranchObj();
    1.42 +	if (bo)
    1.43 +	{
    1.44 +		bo->moveBy (100,100);
    1.45 +		model->reposition();
    1.46 +	}
    1.47 +
    1.48  	/*
    1.49  	// Code copied from Qt sources
    1.50  	QRectF rect=model->getSelectedBranchObj()->getBBox();
    1.51 @@ -657,6 +669,7 @@
    1.52  			Vector v=polys[i].at(0)-orgpos[i];
    1.53  			orients.append (mapobjects[i]->getOrientation());
    1.54  			mapobjects[i]->moveBy(v.x(),v.y() );
    1.55 +			mapobjects[i]->setRelPos();
    1.56  		}	
    1.57  		model->reposition();	
    1.58  		orientationChanged=false;
    1.59 @@ -670,6 +683,8 @@
    1.60  		break;
    1.61  		//orientationChanged=false;
    1.62  	} // loop if orientation has changed
    1.63 +
    1.64 +	model->emitSelectionChanged();
    1.65  }
    1.66  
    1.67  BranchItem* MapEditor::getBranchDirectAbove (BranchItem *bi)
    1.68 @@ -1003,8 +1018,8 @@
    1.69  		if (!foname.isEmpty())
    1.70  		{
    1.71  			// systemFlag clicked
    1.72 -			model->select (lmo);	// FIXME-3 was selectInt
    1.73 -			if (foname=="url") 
    1.74 +			model->select (lmo);	
    1.75 +			if (foname=="system-url") 
    1.76  			{
    1.77  				if (e->state() & Qt::ControlModifier)
    1.78  					mainWindow->editOpenURLTab();
    1.79 @@ -1124,14 +1139,16 @@
    1.80      // Move the selected MapObj
    1.81      if ( lmosel && movingObj) 
    1.82      {	
    1.83 +		objectMoved=true;
    1.84  		// reset cursor if we are moving and don't copy
    1.85  		if (mainWindow->getModMode()!=Main::ModModeCopy)
    1.86  			setCursor (Qt::ArrowCursor);
    1.87  
    1.88  		// To avoid jumping of the sceneView, only 
    1.89  		// show selection, if not tmp linked
    1.90 -		if (!lmosel->hasParObjTmp())
    1.91 +		/* FIXME-2 if (!lmosel->hasParObjTmp())
    1.92  			model->emitShowSelection();
    1.93 +			*/
    1.94  		
    1.95  		// Now move the selection, but add relative position 
    1.96  		// (movingObj_start) where selection was chosen with 
    1.97 @@ -1183,9 +1200,8 @@
    1.98  			}
    1.99  		} else	
   1.100  		{	// selection != a FloatObj
   1.101 -			if (seli->depth()==0)		//FIXME-1 also moved mapcenters could be linked, but not working so far
   1.102 +			if (seli->depth()==0)		
   1.103  			{
   1.104 -				// Move MapCenter // FIXME-1 scrolls way too much with shift pressed
   1.105  				lmosel->move   (p-movingObj_start);		
   1.106  				if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) 
   1.107  				{
   1.108 @@ -1373,7 +1389,7 @@
   1.109  			QString preSelStr=model->getSelectString(seli);
   1.110  
   1.111  			copyingObj=false;	
   1.112 -			if (dsti)
   1.113 +			if (dsti && objectMoved)
   1.114  			{
   1.115  				// We have a destination, relink to that
   1.116  
   1.117 @@ -1444,14 +1460,11 @@
   1.118  				if (settings.value("/animation/use",false).toBool() && seli->depth()>1) 
   1.119  				{
   1.120  					lmosel->setRelPos();	// calc relPos first for starting point
   1.121 -					QPointF dst=bi->getBranchObj()->getParObj()->getChildPos();		// FIXME-3 check getBO here...
   1.122 -			//		if (lmosel->getOrientation()==LinkableMapObj::LeftOfCenter) dst.setX (dst.x()+lmosel->width() );
   1.123  					
   1.124  					model->startAnimation(
   1.125  						(BranchObj*)lmosel,
   1.126  						lmosel->getRelPos(),
   1.127  						movingObj_orgRelPos
   1.128 -//						QPointF (movingObj_orgPos.x() - dst.x(), movingObj_orgPos.y() - dst.y() )
   1.129  					);	
   1.130  				} else	
   1.131  					model->reposition();
   1.132 @@ -1461,9 +1474,8 @@
   1.133  		// Finally resize scene, if needed
   1.134  		scene()->update();
   1.135  		movingObj=NULL;		
   1.136 +		objectMoved=false;
   1.137  
   1.138 -		// Just make sure, that actions are still ok,e.g. the move branch up/down buttons...
   1.139 -		// model->updateActions(); FIXME-3 neeeded? 
   1.140  	} else 
   1.141  		// maybe we moved View: set old cursor
   1.142  		setCursor (Qt::ArrowCursor);
   1.143 @@ -1472,6 +1484,9 @@
   1.144  
   1.145  void MapEditor::mouseDoubleClickEvent(QMouseEvent* e)
   1.146  {
   1.147 +	if (debug) cout << "ME p="<<mapToScene (e->pos())<<endl;
   1.148 +
   1.149 +
   1.150  	if (model->isSelectionBlocked() ) 
   1.151  	{
   1.152  		e->ignore();
   1.153 @@ -1648,12 +1663,12 @@
   1.154  						do_reposition=true;
   1.155  				}	
   1.156  			}
   1.157 -			scrollTo (ix);
   1.158  			if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
   1.159  				// Show link if needed
   1.160  				((MapItem*)ti)->getLMO()->updateVisibility();
   1.161  		}
   1.162  	}
   1.163 +	// FIXME-3 cout << "ME::updateSel  doRepos="<<do_reposition<<endl;
   1.164  	if (do_reposition) model->reposition();
   1.165  
   1.166  	// Reduce rectangles