mapeditor.cpp
changeset 143 56c57552f1d2
parent 139 087e60400acc
child 148 401f76b830d1
     1.1 --- a/mapeditor.cpp	Sun Jul 31 12:24:53 2005 +0000
     1.2 +++ b/mapeditor.cpp	Mon Aug 01 19:32:45 2005 +0000
     1.3 @@ -706,7 +706,22 @@
     1.4  			s=api.parString (ok,0);
     1.5  			if (ok) setHeading (s);
     1.6  		}	
     1.7 -	}	
     1.8 +	} else if (com=="setURL")
     1.9 +	{
    1.10 +		if (api.checkParamCount(1))
    1.11 +		{
    1.12 +			s=api.parString (ok,0);
    1.13 +			if (ok) setURL(s);
    1.14 +		}	
    1.15 +	} else if (com=="setVymLink")
    1.16 +	{
    1.17 +		if (api.checkParamCount(1))
    1.18 +		{
    1.19 +			s=api.parString (ok,0);
    1.20 +			if (ok) setVymLink(s);
    1.21 +		}	
    1.22 +	}
    1.23 +
    1.24  	// Internal commands, used for undo etc.	
    1.25  	else if (com==QString("undoMap"))
    1.26  	{
    1.27 @@ -1548,6 +1563,34 @@
    1.28  	}
    1.29  }
    1.30  
    1.31 +void MapEditor::setURL (const QString &s)
    1.32 +{
    1.33 +	// Internal function, no saveState needed
    1.34 +	if (selection  &&  
    1.35 +		 (typeid(*selection) == typeid(BranchObj) || 
    1.36 +		  typeid(*selection) == typeid(MapCenterObj) ) ) 
    1.37 +	{
    1.38 +		((BranchObj*)(selection))->setURL(s);
    1.39 +		mapCenter->reposition();
    1.40 +		adjustCanvasSize();
    1.41 +		ensureSelectionVisible();
    1.42 +	}
    1.43 +}
    1.44 +
    1.45 +void MapEditor::setVymLink (const QString &s)
    1.46 +{
    1.47 +	// Internal function, no saveState needed
    1.48 +	if (selection  &&  
    1.49 +		 (typeid(*selection) == typeid(BranchObj) || 
    1.50 +		  typeid(*selection) == typeid(MapCenterObj) ) ) 
    1.51 +	{
    1.52 +		((BranchObj*)(selection))->setVymLink(s);
    1.53 +		mapCenter->reposition();
    1.54 +		adjustCanvasSize();
    1.55 +		ensureSelectionVisible();
    1.56 +	}
    1.57 +}
    1.58 +
    1.59  void MapEditor::addNewBranch(int pos)
    1.60  {
    1.61  	// Finish open lineEdits
    1.62 @@ -1557,7 +1600,7 @@
    1.63  		 (typeid(*selection) == typeid(BranchObj) || 
    1.64  		  typeid(*selection) == typeid(MapCenterObj) ) ) 
    1.65  	{
    1.66 -		saveState(selection);
    1.67 +		saveState(selection);	//FIXME undoCommand
    1.68  
    1.69  		BranchObj* bo1 = (BranchObj*) (selection);
    1.70  		bool wasScrolled=false;
    1.71 @@ -2161,7 +2204,7 @@
    1.72  		if (typeid(*selection) == typeid(BranchObj) ||
    1.73  			typeid(*selection) == typeid(MapCenterObj))
    1.74  		{
    1.75 -			saveState(selection);
    1.76 +			saveState(selection);	//FIXME undoCommand
    1.77  			BranchObj *bo=(BranchObj*)(selection);
    1.78  			bo->setColor(actColor, false); // color links, color childs
    1.79  		}    
    1.80 @@ -2187,7 +2230,7 @@
    1.81  {
    1.82  	if (selection)
    1.83  	{
    1.84 -		saveState(selection);	
    1.85 +		saveState(selection);// FIXME undoCommand	
    1.86  		((BranchObj*)(selection))->toggleStandardFlag (f,actionSettingsUseFlagGroups);
    1.87  	}	
    1.88  }
    1.89 @@ -2297,15 +2340,16 @@
    1.90  			typeid(*selection) == typeid(MapCenterObj)) )
    1.91  	{		
    1.92  		bool ok;
    1.93 +		BranchObj *bo=(BranchObj*)(selection);
    1.94  		QString text = QInputDialog::getText(
    1.95  				"VYM", tr("Enter URL:"), QLineEdit::Normal,
    1.96 -				((BranchObj*)(selection))->getURL(), &ok, this );
    1.97 +				bo->getURL(), &ok, this );
    1.98  		if ( ok) 
    1.99  		{
   1.100  			// user entered something and pressed OK
   1.101 -			((BranchObj*)(selection))->setURL (text);
   1.102 +			saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")");	
   1.103 +			bo->setURL (text);
   1.104  			updateActions();
   1.105 -			saveState();	//FIXME undoCommand
   1.106  		}	
   1.107  	}
   1.108  }
   1.109 @@ -2315,10 +2359,10 @@
   1.110  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   1.111  			typeid(*selection) == typeid(MapCenterObj)) )
   1.112  	{		
   1.113 -		BranchObj *b=(BranchObj*)(selection);
   1.114 -		b->setURL (b->getHeading());
   1.115 +		BranchObj *bo=(BranchObj*)(selection);
   1.116 +		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")");	
   1.117 +		bo->setURL (bo->getHeading());
   1.118  		updateActions();
   1.119 -		saveState();	//FIXME undoCommand
   1.120  	}
   1.121  }	
   1.122  
   1.123 @@ -2327,10 +2371,11 @@
   1.124  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   1.125  			typeid(*selection) == typeid(MapCenterObj)) )
   1.126  	{		
   1.127 -		BranchObj *b=(BranchObj*)(selection);
   1.128 -		b->setURL ("https://bugzilla.novell.com/show_bug.cgi?id="+b->getHeading());
   1.129 +		BranchObj *bo=(BranchObj*)(selection);
   1.130 +		QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
   1.131 +		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")");	
   1.132 +		bo->setURL (url);
   1.133  		updateActions();
   1.134 -		saveState();	//FIXME undoCommand
   1.135  	}
   1.136  }	
   1.137  
   1.138 @@ -2339,21 +2384,24 @@
   1.139  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   1.140  			typeid(*selection) == typeid(MapCenterObj)) )
   1.141  	{		
   1.142 +		BranchObj *bo=(BranchObj*)(selection);
   1.143  		QFileDialog *fd=new QFileDialog( this,tr("VYM - Link to another map"));
   1.144  		fd->addFilter (QString (tr("vym map") + " (*.vym)"));
   1.145  		fd->setCaption(tr("VYM - Link to another map"));
   1.146 -		if (! ((BranchObj*)(selection))->getVymLink().isEmpty() )
   1.147 -			fd->setSelection( ((BranchObj*)(selection))->getVymLink() );
   1.148 +		if (! bo->getVymLink().isEmpty() )
   1.149 +			fd->setSelection( bo->getVymLink() );
   1.150  		fd->show();
   1.151  
   1.152  		QString fn;
   1.153  		if ( fd->exec() == QDialog::Accepted )
   1.154 -			((BranchObj*)(selection))->setVymLink (fd->selectedFile() );
   1.155 -		updateActions();
   1.156 -		mapCenter->reposition();
   1.157 -		adjustCanvasSize();
   1.158 -		canvas()->update();
   1.159 -		saveState();	//FIXME undoCommand
   1.160 +		{
   1.161 +			saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")");	
   1.162 +			bo->setVymLink (fd->selectedFile() );
   1.163 +			updateActions();
   1.164 +			mapCenter->reposition();
   1.165 +			adjustCanvasSize();
   1.166 +			canvas()->update();
   1.167 +		}
   1.168  	}
   1.169  }
   1.170  
   1.171 @@ -2362,12 +2410,13 @@
   1.172  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
   1.173  			typeid(*selection) == typeid(MapCenterObj)) )
   1.174  	{		
   1.175 -		((BranchObj*)(selection))->setVymLink ("" );
   1.176 +		BranchObj *bo=(BranchObj*)(selection);
   1.177 +		saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")");	
   1.178 +		bo->setVymLink ("" );
   1.179  		updateActions();
   1.180  		mapCenter->reposition();
   1.181  		adjustCanvasSize();
   1.182  		canvas()->update();
   1.183 -		saveState();	//FIXME undoCommand
   1.184  	}
   1.185  }
   1.186