mapeditor.cpp
changeset 89 9db3eaa21237
parent 88 9771028de303
child 90 10f3d35dcbad
     1.1 --- a/mapeditor.cpp	Mon Jan 31 09:47:43 2005 +0000
     1.2 +++ b/mapeditor.cpp	Tue Feb 08 14:07:19 2005 +0000
     1.3 @@ -87,6 +87,7 @@
     1.4  extern QAction *actionEditSelectLast;
     1.5  extern QAction *actionEditLoadImage;
     1.6  extern QAction *actionEditToggleFloatExport;
     1.7 +extern QAction *actionEditNoLink;
     1.8  
     1.9  extern QAction* actionFormatPickColor;
    1.10  extern QAction* actionFormatColorBranch;
    1.11 @@ -95,6 +96,10 @@
    1.12  extern QAction *actionFormatBackColor;
    1.13  extern QAction *actionFormatLinkColor;
    1.14  
    1.15 +extern QActionGroup* actionGroupModModes;
    1.16 +extern QAction* actionModModeColor;
    1.17 +extern QAction* actionModModeLink;
    1.18 +
    1.19  extern QActionGroup *actionGroupFormatFrameTypes;
    1.20  extern QAction *actionFormatFrameNone;
    1.21  extern QAction *actionFormatFrameRectangle;
    1.22 @@ -113,6 +118,7 @@
    1.23  extern QAction *actionSettingsPasteNewHeading;
    1.24  
    1.25  extern QPopupMenu *branchContextMenu;
    1.26 +extern QPopupMenu *branchLinksContextMenu;
    1.27  extern QPopupMenu *floatimageContextMenu;
    1.28  extern QPopupMenu *saveImageFormatMenu;
    1.29  extern QPopupMenu *exportImageFormatMenu;
    1.30 @@ -300,9 +306,6 @@
    1.31  		pickColorCursor=QCursor ( cursorcolorpicker_xpm, 5,27 ); 
    1.32  	#endif
    1.33  
    1.34 -	modifierMode=pickColorMode;
    1.35 -	//modifierMode=linkObjectsMode;	// FIXME testing
    1.36 -
    1.37  	pickingColor=false;
    1.38  
    1.39      editingBO=NULL;
    1.40 @@ -2229,9 +2232,34 @@
    1.41  		if ( (typeid(*selection) == typeid(BranchObj)) || 
    1.42  			(typeid(*selection) == typeid(MapCenterObj))  )
    1.43  		{
    1.44 +			BranchObj *bo=(BranchObj*)(selection);
    1.45 +			// Take care of links
    1.46 +			if (bo->countLinks()==0)
    1.47 +			{
    1.48 +				branchLinksContextMenu->clear();
    1.49 +				branchLinksContextMenu->insertItem ("No link available");
    1.50 +				
    1.51 +			} else
    1.52 +			{
    1.53 +				BranchObj *bot;
    1.54 +				QString s;
    1.55 +				branchLinksContextMenu->clear();
    1.56 +				for (int i=0; i<=bo->countLinks();i++)
    1.57 +				{
    1.58 +					bot=bo->linkTargetAt(i);
    1.59 +					if (bot)
    1.60 +					{
    1.61 +						s=bot->getHeading();
    1.62 +						if (s.length()>25)
    1.63 +							s=s.left(25)+"...";
    1.64 +						branchLinksContextMenu->insertItem (s);
    1.65 +					}	
    1.66 +				}
    1.67 +			}
    1.68 +
    1.69  			standardFlagsDefault->setEnabled (true);
    1.70  
    1.71 -			if ( ((BranchObj*)(selection))->getURL().isEmpty() )
    1.72 +			if ( bo->getURL().isEmpty() )
    1.73  				actionEditOpenURL->setEnabled (false);
    1.74  			else	
    1.75  				actionEditOpenURL->setEnabled (true);
    1.76 @@ -2239,7 +2267,7 @@
    1.77  			actionEditHeading2URL->setEnabled (true);	
    1.78  			actionEditBugzilla2URL->setEnabled (true);	
    1.79  
    1.80 -			if ( ((BranchObj*)(selection))->getVymLink().isEmpty() )
    1.81 +			if ( bo->getVymLink().isEmpty() )
    1.82  			{
    1.83  				actionEditOpenVymLink->setEnabled (false);
    1.84  				actionEditDeleteVymLink->setEnabled (false);
    1.85 @@ -2643,13 +2671,24 @@
    1.86  	}	
    1.87  }
    1.88  
    1.89 +void MapEditor::followLink(int i)
    1.90 +{
    1.91 +	cout << "ME::followLink "<<i<<endl;
    1.92 +	BranchObj *bo=((BranchObj*)(selection))->linkTargetAt(i);
    1.93 +	if (bo) 
    1.94 +	{
    1.95 +		cout << "follow to "<<bo->getHeading()<<endl;
    1.96 +		selection->unselect();
    1.97 +		selection=bo;
    1.98 +		selection->select();
    1.99 +		ensureSelectionVisible();
   1.100 +	}
   1.101 +}
   1.102 +
   1.103  void MapEditor::testFunction()
   1.104  {
   1.105  	cout << "MapEditor::testFunction() called\n";
   1.106 -	if (modifierMode==pickColorMode)
   1.107 -		modifierMode=linkObjectsMode;
   1.108 -	else	
   1.109 -		modifierMode=pickColorMode;
   1.110 +	branchLinksContextMenu->setEnabled (false);
   1.111  }
   1.112  
   1.113  void MapEditor::ensureSelectionVisible()
   1.114 @@ -2728,7 +2767,7 @@
   1.115  	// Special case: CTRL is pressed
   1.116  	if (e->state() & QMouseEvent::ControlButton)
   1.117  	{
   1.118 -		if (modifierMode==pickColorMode)
   1.119 +		if (actionModModeColor->isOn())
   1.120  		{
   1.121  			if (e->state() & QMouseEvent::ControlButton)
   1.122  			{
   1.123 @@ -2737,21 +2776,21 @@
   1.124  				return;
   1.125  			}
   1.126  		} 
   1.127 -		if (modifierMode==linkObjectsMode)
   1.128 +		if (actionModModeLink->isOn())
   1.129  		{	
   1.130 -			if (lmo && 
   1.131 -				(typeid(*lmo) == typeid(BranchObj)) || 
   1.132 -				(typeid(*lmo) == typeid(MapCenterObj))  )
   1.133 +			if (selection && 
   1.134 +				((typeid(*selection) == typeid(BranchObj)) || 
   1.135 +				(typeid(*selection) == typeid(MapCenterObj)))  )
   1.136  			{
   1.137  				drawingLink=true;
   1.138  				linkingObj_src=selection;
   1.139  				tmpLink=new LinkObj (mapCanvas);
   1.140 -				tmpLink->setBegin ( ((BranchObj*)(lmo)) );
   1.141 +				tmpLink->setBegin ( ((BranchObj*)(selection)) );
   1.142  				tmpLink->setEnd   (p);
   1.143  				tmpLink->updateLink();
   1.144  				tmpLink->setVisibility (true);
   1.145  				return;
   1.146 -			}	
   1.147 +			} 
   1.148  		}	
   1.149  	}
   1.150  
   1.151 @@ -2826,6 +2865,7 @@
   1.152      // Move the selected MapObj
   1.153      if ( selection && movingObj) 
   1.154      {	
   1.155 +		ensureVisible (p.x(),p.y());
   1.156  		
   1.157  		// Now move the selection, but add relative position 
   1.158  		// (movingObj_start) where selection was chosen with 
   1.159 @@ -2909,7 +2949,7 @@
   1.160  				} 
   1.161  				// reposition subbranch
   1.162  				lmosel->reposition();	
   1.163 -				ensureSelectionVisible();
   1.164 +				//ensureSelectionVisible();
   1.165  
   1.166  				if (lmo && (lmo!=selection) &&  
   1.167  					(typeid(*lmo) == typeid(BranchObj) ||