1.8.69 Some more scripting functionality (for testing)
authorinsilmaril
Mon, 05 Mar 2007 23:22:51 +0000
changeset 432f867269ab8a1
parent 431 c2ffbc9b832d
child 433 310f1d82cf89
1.8.69 Some more scripting functionality (for testing)
api.cpp
api.h
exports.cpp
mainwindow.cpp
mainwindow.h
mapeditor.cpp
mapeditor.h
parser.cpp
parser.h
simplescripteditor.cpp
simplescripteditor.h
simplescripteditor.ui
tex/vym.changelog
version.h
vym.pro
warningdialog.cpp
     1.1 --- a/api.cpp	Sat Feb 24 12:32:53 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,215 +0,0 @@
     1.4 -#include "api.h"
     1.5 -
     1.6 -#include <qregexp.h>
     1.7 -
     1.8 -API::API()
     1.9 -{
    1.10 -	initCommand();
    1.11 -}
    1.12 -
    1.13 -void API::initCommand()
    1.14 -{
    1.15 -	com="";
    1.16 -	paramList.clear();
    1.17 -	resetError();
    1.18 -}
    1.19 -
    1.20 -void API::parseInput (const QString &s)
    1.21 -{
    1.22 -	initCommand();
    1.23 -	input=s;
    1.24 -	QRegExp re;
    1.25 -	int pos;
    1.26 -
    1.27 -	// Get command
    1.28 -	re.setPattern ("(.*)\\s");
    1.29 -	re.setMinimal (true);
    1.30 -	pos=re.search (s);
    1.31 -	if (pos>=0)
    1.32 -		com=re.cap(1);
    1.33 -
    1.34 -	// Get parameters
    1.35 -	paramList.clear();
    1.36 -	re.setPattern ("\\((.*)\\)");
    1.37 -	pos=re.search (s);
    1.38 -	if (pos>=0)
    1.39 -	{
    1.40 -		QString s=re.cap(1);
    1.41 -		QString a;
    1.42 -		bool inquote=false;
    1.43 -		pos=0;
    1.44 -		if (!s.isEmpty())
    1.45 -		{
    1.46 -			while (pos<s.length())
    1.47 -			{
    1.48 -				if (s.at(pos)=='\"') 
    1.49 -				{
    1.50 -					if (inquote)
    1.51 -						inquote=false;
    1.52 -					else	
    1.53 -						inquote=true;
    1.54 -				}
    1.55 -
    1.56 -				if (s.at(pos)==',' && !inquote)
    1.57 -				{
    1.58 -					a=s.left(pos);
    1.59 -					paramList.append(a);
    1.60 -					s=s.right(s.length()-pos-1);
    1.61 -					pos=0;
    1.62 -				} else
    1.63 -					pos++;
    1.64 -				
    1.65 -			}
    1.66 -			paramList.append (s);
    1.67 -		}	
    1.68 -	}	
    1.69 -}
    1.70 -
    1.71 -QString API::command()
    1.72 -{
    1.73 -	return com;
    1.74 -}
    1.75 -
    1.76 -QStringList API::parameters()
    1.77 -{
    1.78 -	return paramList;
    1.79 -}
    1.80 -
    1.81 -int API::paramCount()
    1.82 -{
    1.83 -	return paramList.count();
    1.84 -}
    1.85 -
    1.86 -
    1.87 -QString API::errorMessage()
    1.88 -{
    1.89 -	QString l;
    1.90 -	switch (errLevel)
    1.91 -	{
    1.92 -		case NoError: l="No Error";
    1.93 -		case Warning: l="Warning";
    1.94 -		case Aborted: l="Aborted";
    1.95 -	}
    1.96 -	return QString ("Error Level: %1\n    Command: %2\nDescription: %3")
    1.97 -		.arg(l).arg(com).arg(errDescription);
    1.98 -}
    1.99 -
   1.100 -QString API::errorDescription()
   1.101 -{
   1.102 -	return errDescription;
   1.103 -}
   1.104 -
   1.105 -ErrorLevel API::errorLevel()
   1.106 -{
   1.107 -	return errLevel;
   1.108 -}
   1.109 -
   1.110 -void API::setError(ErrorLevel level, const QString &description)
   1.111 -{
   1.112 -	errDescription=description;
   1.113 -	errLevel=level;
   1.114 -}
   1.115 -
   1.116 -void API::resetError ()
   1.117 -{
   1.118 -	errMessage="";
   1.119 -	errDescription="";
   1.120 -	errLevel=NoError;
   1.121 -}
   1.122 -
   1.123 -
   1.124 -bool API::checkParamCount (QList <int> plist)
   1.125 -{
   1.126 -	QStringList expList;
   1.127 -	QString expected;
   1.128 -	for (int i=0; i<plist.count();i++)
   1.129 -	{
   1.130 -		if (checkParamCount (plist[i])) 
   1.131 -		{
   1.132 -			resetError();
   1.133 -			return true;
   1.134 -		}
   1.135 -		expList.append(QString().setNum(plist[i]));
   1.136 -	}	
   1.137 -	expected=expList.join(",");	
   1.138 -	errDescription=QString("Wrong number of parameters: Expected %1, but found %2").arg(expected).arg(paramList.count());
   1.139 -	return false;
   1.140 -}
   1.141 -
   1.142 -bool API::checkParamCount (const int &expected)
   1.143 -{
   1.144 -	if (paramList.count()!=expected)
   1.145 -	{
   1.146 -		errLevel=Aborted;
   1.147 -		errDescription=QString("Wrong number of parameters: Expected %1, but found %2").arg(expected).arg(paramList.count());
   1.148 -		return false;
   1.149 -	} 
   1.150 -	return true;	
   1.151 -}
   1.152 -
   1.153 -bool API::checkParamIsInt(const int &index)
   1.154 -{
   1.155 -	bool ok;
   1.156 -	if (index > paramList.count())
   1.157 -	{
   1.158 -		errLevel=Aborted;
   1.159 -		errDescription=QString("Parameter index %1 is outside of parameter list").arg(index);
   1.160 -		return false;
   1.161 -	} else
   1.162 -	{
   1.163 -		paramList[index].toInt (&ok, 10);
   1.164 -		if (!ok)
   1.165 -		{
   1.166 -			errLevel=Aborted;
   1.167 -			errDescription=QString("Parameter %1 is not an integer").arg(index);
   1.168 -			return false;
   1.169 -		} 
   1.170 -	}	
   1.171 -	return true;
   1.172 -}
   1.173 -
   1.174 -int API::parInt (bool &ok,const uint &index)
   1.175 -{
   1.176 -	if (checkParamIsInt (index))
   1.177 -		return paramList[index].toInt (&ok, 10);
   1.178 -	ok=false;
   1.179 -	return 0;
   1.180 -}
   1.181 -
   1.182 -QString API::parString (bool &ok,const int &index)
   1.183 -{
   1.184 -	// return the string at index, this could be also stored in
   1.185 -	// a variable later
   1.186 -	QString r;
   1.187 -	QRegExp re("\"(.*)\"");
   1.188 -	int pos=re.search (paramList[index]);
   1.189 -	if (pos>=0)
   1.190 -		r=re.cap (1);
   1.191 -	else	
   1.192 -		r="";
   1.193 -	ok=true;
   1.194 -	return r;
   1.195 -}
   1.196 -
   1.197 -bool API::parBool (bool &ok,const int &index)
   1.198 -{
   1.199 -	// return the bool at index, this could be also stored in
   1.200 -	// a variable later
   1.201 -	QString r;
   1.202 -	ok=true;
   1.203 -	QString p=paramList[index];
   1.204 -	if (p=="true" || p=="1")
   1.205 -		return true;
   1.206 -	else if	(p=="false" || p=="0")
   1.207 -		return false;
   1.208 -	ok=false;
   1.209 -	return ok;
   1.210 -}
   1.211 -
   1.212 -QColor API::parColor(bool &ok,const int &index)
   1.213 -{
   1.214 -	// return the QColor at index
   1.215 -	ok=true;
   1.216 -	return QColor (paramList[index]);
   1.217 -}
   1.218 -
     2.1 --- a/api.h	Sat Feb 24 12:32:53 2007 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,39 +0,0 @@
     2.4 -#ifndef API_H
     2.5 -#define API_H
     2.6 -
     2.7 -#include <QColor>
     2.8 -#include <QStringList>
     2.9 -
    2.10 -enum ErrorLevel {NoError,Warning,Aborted};
    2.11 -
    2.12 -class API
    2.13 -{
    2.14 -public:
    2.15 -	API();
    2.16 -	void initCommand();
    2.17 -	void parseInput (const QString &input);
    2.18 -	QString command();
    2.19 -	QStringList parameters();
    2.20 -	int paramCount();
    2.21 -	QString errorMessage();
    2.22 -	QString errorDescription();
    2.23 -	ErrorLevel errorLevel();
    2.24 -	void setError (ErrorLevel level,const QString &description);
    2.25 -	void resetError();
    2.26 -	bool checkParamCount (QList <int> plist);
    2.27 -	bool checkParamCount (const int &index);
    2.28 -	bool checkParamIsInt (const int &index);
    2.29 -	int parInt (bool &,const uint &index);
    2.30 -	QString parString(bool &ok,const int &index);
    2.31 -	bool parBool (bool &ok, const int &index);
    2.32 -	QColor parColor (bool &ok, const int &index);
    2.33 -private:
    2.34 -	QString input;
    2.35 -	QString com;
    2.36 -	QStringList paramList;
    2.37 -	QString errMessage;
    2.38 -	QString errDescription;
    2.39 -	ErrorLevel errLevel;
    2.40 -};
    2.41 -
    2.42 -#endif
     3.1 --- a/exports.cpp	Sat Feb 24 12:32:53 2007 +0000
     3.2 +++ b/exports.cpp	Mon Mar 05 23:22:51 2007 +0000
     3.3 @@ -166,12 +166,11 @@
     3.4  	if (mapCenter) me=mapCenter->getMapEditor();
     3.5  	if (me)
     3.6  	{
     3.7 -		cout << "starting KDE export\n";
     3.8  		WarningDialog dia;
     3.9  		dia.showCancelButton (true);
    3.10  		dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
    3.11  		dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
    3.12 -		dia.setShowAgainName("/vym/warnings/overwriteKDEBookmarks");
    3.13 +		dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
    3.14  		if (dia.exec()==QDialog::Accepted)
    3.15  		{
    3.16  			me->exportXML(tmpDir.path());
    3.17 @@ -180,11 +179,9 @@
    3.18  			p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
    3.19  			p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
    3.20  			p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
    3.21 -			cout << "Trying to call vym2kde\n";
    3.22  			p.process();
    3.23  
    3.24  			QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
    3.25 -			cout << "Trying to call "<<ub.ascii()<<endl;
    3.26  			QProcess *proc= new QProcess ;
    3.27  			proc->start( ub);
    3.28  			if (!proc->waitForStarted())
     4.1 --- a/mainwindow.cpp	Sat Feb 24 12:32:53 2007 +0000
     4.2 +++ b/mainwindow.cpp	Mon Mar 05 23:22:51 2007 +0000
     4.3 @@ -98,6 +98,13 @@
     4.4  	branchPropertyWindow = new BranchPropertyWindow();
     4.5  	branchPropertyWindow->move (20,20);
     4.6  
     4.7 +	// Initialize script editor
     4.8 +	scriptEditor = new SimpleScriptEditor();
     4.9 +	scriptEditor->move (50,50);
    4.10 +
    4.11 +	connect( scriptEditor, SIGNAL( runScript ( QString ) ), 
    4.12 +		this, SLOT( runScript( QString ) ) );
    4.13 +	
    4.14  	// Initialize some settings, which are platform dependant
    4.15  	QString p,s;
    4.16  
    4.17 @@ -187,6 +194,9 @@
    4.18  	settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
    4.19  	settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
    4.20  
    4.21 +	//FIXME save branchPropWindow settings
    4.22 +	//FIXME save scriptEditor settings
    4.23 +
    4.24  	// call the destructors
    4.25  	delete (textEditor);
    4.26  	delete historyWindow;
    4.27 @@ -3419,6 +3429,14 @@
    4.28  	actionViewToggleNoteEditor->setOn (false);
    4.29  }
    4.30  
    4.31 +void Main::runScript (QString script)
    4.32 +{
    4.33 +	if (currentMapEditor())
    4.34 +		currentMapEditor()->runScript (script);
    4.35 +		
    4.36 +	
    4.37 +}
    4.38 +
    4.39  void Main::showPropertyDialog()
    4.40  {
    4.41  	if(currentMapEditor())
    4.42 @@ -3464,10 +3482,13 @@
    4.43  void Main::testCommand()
    4.44  {
    4.45  	if (!currentMapEditor()) return;
    4.46 +	scriptEditor->show();
    4.47 +	/*
    4.48  	bool ok;
    4.49  	QString com = QInputDialog::getText(
    4.50  			vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
    4.51  	if (ok) currentMapEditor()->parseAtom(com);
    4.52 +	*/
    4.53  }
    4.54  
    4.55  void Main::helpDoc()
     5.1 --- a/mainwindow.h	Sat Feb 24 12:32:53 2007 +0000
     5.2 +++ b/mainwindow.h	Mon Mar 05 23:22:51 2007 +0000
     5.3 @@ -8,6 +8,7 @@
     5.4  #include "findwindow.h"
     5.5  #include "historywindow.h"
     5.6  #include "mapeditor.h"
     5.7 +#include "simplescripteditor.h"
     5.8  #include "texteditor.h"
     5.9  #include "xml.h"
    5.10  
    5.11 @@ -173,6 +174,7 @@
    5.12  	bool useFlagGroups();
    5.13  
    5.14  private slots:
    5.15 +	void runScript(QString);
    5.16  	void showPropertyDialog();
    5.17  	void windowNextEditor();
    5.18  	void windowPreviousEditor();
    5.19 @@ -201,6 +203,7 @@
    5.20  	HistoryWindow *historyWindow;
    5.21  
    5.22  	BranchPropertyWindow *branchPropertyWindow;
    5.23 +	SimpleScriptEditor *scriptEditor;
    5.24  
    5.25  	QList <QAction*> actionListBranches;
    5.26  
     6.1 --- a/mapeditor.cpp	Sat Feb 24 12:32:53 2007 +0000
     6.2 +++ b/mapeditor.cpp	Mon Mar 05 23:22:51 2007 +0000
     6.3 @@ -8,7 +8,7 @@
     6.4  
     6.5  #include "version.h"
     6.6  
     6.7 -#include "api.h"
     6.8 +#include "parser.h"
     6.9  #include "editxlinkdialog.h"
    6.10  #include "exports.h"
    6.11  #include "extrainfodialog.h"
    6.12 @@ -427,35 +427,34 @@
    6.13  void MapEditor::parseAtom(const QString &atom)
    6.14  {
    6.15  	BranchObj *selb=xelection.getBranch();
    6.16 -	API api;
    6.17  	QString s,t;
    6.18  	int x,y;
    6.19  	bool b,ok;
    6.20  
    6.21  	// Split string s into command and parameters
    6.22 -	api.parseInput (atom);
    6.23 -	QString com=api.command();
    6.24 +	parser.parseAtom (atom);
    6.25 +	QString com=parser.command();
    6.26  	
    6.27  	// External commands
    6.28  	if (com=="addBranch")
    6.29  	{
    6.30  		if (xelection.isEmpty())
    6.31  		{
    6.32 -			api.setError (Aborted,"Nothing selected");
    6.33 +			parser.setError (Aborted,"Nothing selected");
    6.34  		} else if (! selb )
    6.35  		{				  
    6.36 -			api.setError (Aborted,"Type of selection is not a branch");
    6.37 +			parser.setError (Aborted,"Type of selection is not a branch");
    6.38  		} else 
    6.39  		{	
    6.40  			QList <int> pl;
    6.41  			pl << 0 <<1;
    6.42 -			if (api.checkParamCount(pl))
    6.43 +			if (parser.checkParamCount(pl))
    6.44  			{
    6.45 -				if (api.paramCount()==0)
    6.46 +				if (parser.paramCount()==0)
    6.47  					addNewBranchInt (-2);
    6.48  				else
    6.49  				{
    6.50 -					y=api.parInt (ok,0);
    6.51 +					y=parser.parInt (ok,0);
    6.52  					if (ok ) addNewBranchInt (y);
    6.53  				}
    6.54  			}
    6.55 @@ -464,13 +463,13 @@
    6.56  	{
    6.57  		if (xelection.isEmpty())
    6.58  		{
    6.59 -			api.setError (Aborted,"Nothing selected");
    6.60 +			parser.setError (Aborted,"Nothing selected");
    6.61  		} else if (! selb )
    6.62  		{				  
    6.63 -			api.setError (Aborted,"Type of selection is not a branch");
    6.64 +			parser.setError (Aborted,"Type of selection is not a branch");
    6.65  		} else 
    6.66  		{	
    6.67 -			if (api.paramCount()==0)
    6.68 +			if (parser.paramCount()==0)
    6.69  			{
    6.70  				addNewBranchBefore ();
    6.71  			}	
    6.72 @@ -479,31 +478,31 @@
    6.73  	{
    6.74  		if (xelection.isEmpty())
    6.75  		{
    6.76 -			api.setError (Aborted,"Nothing selected");
    6.77 +			parser.setError (Aborted,"Nothing selected");
    6.78  		} else if (! selb )
    6.79  		{				  
    6.80 -			api.setError (Aborted,"Type of selection is not a branch");
    6.81 -		} else if (api.checkParamCount(1))
    6.82 +			parser.setError (Aborted,"Type of selection is not a branch");
    6.83 +		} else if (parser.checkParamCount(1))
    6.84  		{
    6.85 -			//s=api.parString (ok,0);	// selection
    6.86 -			t=api.parString (ok,0);	// path to map
    6.87 +			//s=parser.parString (ok,0);	// selection
    6.88 +			t=parser.parString (ok,0);	// path to map
    6.89  			if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
    6.90  			addMapReplaceInt(selb->getSelectString(),t);	
    6.91  		}
    6.92 -	} else if (com==QString("addMapInsert"))
    6.93 +	} else if (com==QString("addMparsernsert"))
    6.94  	{
    6.95  		if (xelection.isEmpty())
    6.96  		{
    6.97 -			api.setError (Aborted,"Nothing selected");
    6.98 +			parser.setError (Aborted,"Nothing selected");
    6.99  		} else if (! selb )
   6.100  		{				  
   6.101 -			api.setError (Aborted,"Type of selection is not a branch");
   6.102 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.103  		} else 
   6.104  		{	
   6.105 -			if (api.checkParamCount(2))
   6.106 +			if (parser.checkParamCount(2))
   6.107  			{
   6.108 -				t=api.parString (ok,0);	// path to map
   6.109 -				y=api.parInt(ok,1);		// position
   6.110 +				t=parser.parString (ok,0);	// path to map
   6.111 +				y=parser.parInt(ok,1);		// position
   6.112  				if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
   6.113  				addMapInsertInt(t,y);	
   6.114  			}
   6.115 @@ -512,39 +511,39 @@
   6.116  	{
   6.117  		if (xelection.isEmpty())
   6.118  		{
   6.119 -			api.setError (Aborted,"Nothing selected");
   6.120 +			parser.setError (Aborted,"Nothing selected");
   6.121  		} else if (! selb )
   6.122  		{				  
   6.123 -			api.setError (Aborted,"Type of selection is not a branch");
   6.124 -		} else if (api.checkParamCount(1))
   6.125 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.126 +		} else if (parser.checkParamCount(1))
   6.127  		{	
   6.128 -			QColor c=api.parColor (ok,0);
   6.129 +			QColor c=parser.parColor (ok,0);
   6.130  			if (ok) colorBranch (c);
   6.131  		}	
   6.132  	} else if (com=="colorSubtree")
   6.133  	{
   6.134  		if (xelection.isEmpty())
   6.135  		{
   6.136 -			api.setError (Aborted,"Nothing selected");
   6.137 +			parser.setError (Aborted,"Nothing selected");
   6.138  		} else if (! selb )
   6.139  		{				  
   6.140 -			api.setError (Aborted,"Type of selection is not a branch");
   6.141 -		} else if (api.checkParamCount(1))
   6.142 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.143 +		} else if (parser.checkParamCount(1))
   6.144  		{	
   6.145 -			QColor c=api.parColor (ok,0);
   6.146 +			QColor c=parser.parColor (ok,0);
   6.147  			if (ok) colorSubtree (c);
   6.148  		}	
   6.149  	} else if (com=="cut")
   6.150  	{
   6.151  		if (xelection.isEmpty())
   6.152  		{
   6.153 -			api.setError (Aborted,"Nothing selected");
   6.154 +			parser.setError (Aborted,"Nothing selected");
   6.155  		} else if ( xelection.type()!=Branch  && 
   6.156  					xelection.type()!=MapCenter  &&
   6.157  					xelection.type()!=FloatImage )
   6.158  		{				  
   6.159 -			api.setError (Aborted,"Type of selection is not a branch or floatimage");
   6.160 -		} else if (api.checkParamCount(0))
   6.161 +			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   6.162 +		} else if (parser.checkParamCount(0))
   6.163  		{	
   6.164  			cut();
   6.165  		}	
   6.166 @@ -552,11 +551,11 @@
   6.167  	{
   6.168  		if (xelection.isEmpty())
   6.169  		{
   6.170 -			api.setError (Aborted,"Nothing selected");
   6.171 +			parser.setError (Aborted,"Nothing selected");
   6.172  		} else if (! selb )
   6.173  		{
   6.174 -			api.setError (Aborted,"Type of selection is not a branch");
   6.175 -		} else if (api.checkParamCount(0))
   6.176 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.177 +		} else if (parser.checkParamCount(0))
   6.178  		{	
   6.179  			deleteSelection();
   6.180  		}	
   6.181 @@ -564,11 +563,11 @@
   6.182  	{
   6.183  		if (xelection.isEmpty())
   6.184  		{
   6.185 -			api.setError (Aborted,"Nothing selected");
   6.186 +			parser.setError (Aborted,"Nothing selected");
   6.187  		} else if (! selb )
   6.188  		{
   6.189 -			api.setError (Aborted,"Type of selection is not a branch");
   6.190 -		} else if (api.checkParamCount(0))
   6.191 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.192 +		} else if (parser.checkParamCount(0))
   6.193  		{	
   6.194  			deleteKeepChilds();
   6.195  		}	
   6.196 @@ -576,11 +575,11 @@
   6.197  	{
   6.198  		if (xelection.isEmpty())
   6.199  		{
   6.200 -			api.setError (Aborted,"Nothing selected");
   6.201 +			parser.setError (Aborted,"Nothing selected");
   6.202  		} else if (! selb)
   6.203  		{
   6.204 -			api.setError (Aborted,"Type of selection is not a branch");
   6.205 -		} else if (api.checkParamCount(0))
   6.206 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.207 +		} else if (parser.checkParamCount(0))
   6.208  		{	
   6.209  			deleteChilds();
   6.210  		}	
   6.211 @@ -588,32 +587,32 @@
   6.212  	{
   6.213  		if (xelection.isEmpty())
   6.214  		{
   6.215 -			api.setError (Aborted,"Nothing selected");
   6.216 +			parser.setError (Aborted,"Nothing selected");
   6.217  		} else if ( selb)
   6.218  		{
   6.219 -			if (api.checkParamCount(4))
   6.220 +			if (parser.checkParamCount(4))
   6.221  			{
   6.222  				// 0	selectstring of parent
   6.223  				// 1	num in parent (for branches)
   6.224  				// 2,3	x,y of mainbranch or mapcenter
   6.225 -				s=api.parString(ok,0);
   6.226 +				s=parser.parString(ok,0);
   6.227  				LinkableMapObj *dst=mapCenter->findObjBySelect (s);
   6.228  				if (dst)
   6.229  				{	
   6.230  					if (typeid(*dst) == typeid(BranchObj) ) 
   6.231  					{
   6.232  						// Get number in parent
   6.233 -						x=api.parInt (ok,1);
   6.234 +						x=parser.parInt (ok,1);
   6.235  						if (ok)
   6.236  							selb->linkTo ((BranchObj*)(dst),x);
   6.237  					} else if (typeid(*dst) == typeid(MapCenterObj) ) 
   6.238  					{
   6.239  						selb->linkTo ((BranchObj*)(dst),-1);
   6.240  						// Get coordinates of mainbranch
   6.241 -						x=api.parInt (ok,2);
   6.242 +						x=parser.parInt (ok,2);
   6.243  						if (ok)
   6.244  						{
   6.245 -							y=api.parInt (ok,3);
   6.246 +							y=parser.parInt (ok,3);
   6.247  							if (ok) selb->move (x,y);
   6.248  						}
   6.249  					}	
   6.250 @@ -621,10 +620,10 @@
   6.251  			}	
   6.252  		} else if ( xelection.type() == FloatImage) 
   6.253  		{
   6.254 -			if (api.checkParamCount(1))
   6.255 +			if (parser.checkParamCount(1))
   6.256  			{
   6.257  				// 0	selectstring of parent
   6.258 -				s=api.parString(ok,0);
   6.259 +				s=parser.parString(ok,0);
   6.260  				LinkableMapObj *dst=mapCenter->findObjBySelect (s);
   6.261  				if (dst)
   6.262  				{	
   6.263 @@ -632,19 +631,32 @@
   6.264  						typeid(*dst) == typeid(MapCenterObj)) 
   6.265  						linkTo (dst->getSelectString());
   6.266  				} else	
   6.267 -					api.setError (Aborted,"Destination is not a branch");
   6.268 +					parser.setError (Aborted,"Destination is not a branch");
   6.269  			}		
   6.270  		} else
   6.271 -			api.setError (Aborted,"Type of selection is not a floatimage or branch");
   6.272 +			parser.setError (Aborted,"Type of selection is not a floatimage or branch");
   6.273 +	} else if (com=="loadImage")
   6.274 +	{
   6.275 +		if (xelection.isEmpty())
   6.276 +		{
   6.277 +			parser.setError (Aborted,"Nothing selected");
   6.278 +		} else if (! selb )
   6.279 +		{				  
   6.280 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.281 +		} else if (parser.checkParamCount(1))
   6.282 +		{
   6.283 +			s=parser.parString(ok,0);
   6.284 +			if (ok) loadFloatImageInt (s);
   6.285 +		}	
   6.286  	} else if (com=="moveBranchUp")
   6.287  	{
   6.288  		if (xelection.isEmpty() )
   6.289  		{
   6.290 -			api.setError (Aborted,"Nothing selected");
   6.291 +			parser.setError (Aborted,"Nothing selected");
   6.292  		} else if (! selb )
   6.293  		{				  
   6.294 -			api.setError (Aborted,"Type of selection is not a branch");
   6.295 -		} else if (api.checkParamCount(0))
   6.296 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.297 +		} else if (parser.checkParamCount(0))
   6.298  		{
   6.299  			moveBranchUp();
   6.300  		}	
   6.301 @@ -652,11 +664,11 @@
   6.302  	{
   6.303  		if (xelection.isEmpty() )
   6.304  		{
   6.305 -			api.setError (Aborted,"Nothing selected");
   6.306 +			parser.setError (Aborted,"Nothing selected");
   6.307  		} else if (! selb )
   6.308  		{				  
   6.309 -			api.setError (Aborted,"Type of selection is not a branch");
   6.310 -		} else if (api.checkParamCount(0))
   6.311 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.312 +		} else if (parser.checkParamCount(0))
   6.313  		{
   6.314  			moveBranchDown();
   6.315  		}	
   6.316 @@ -664,18 +676,18 @@
   6.317  	{
   6.318  		if (xelection.isEmpty() )
   6.319  		{
   6.320 -			api.setError (Aborted,"Nothing selected");
   6.321 +			parser.setError (Aborted,"Nothing selected");
   6.322  		} else if ( xelection.type()!=Branch  && 
   6.323  					xelection.type()!=MapCenter  &&
   6.324  					xelection.type()!=FloatImage )
   6.325  		{				  
   6.326 -			api.setError (Aborted,"Type of selection is not a branch or floatimage");
   6.327 -		} else if (api.checkParamCount(2))
   6.328 +			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   6.329 +		} else if (parser.checkParamCount(2))
   6.330  		{	
   6.331 -			x=api.parInt (ok,0);
   6.332 +			x=parser.parInt (ok,0);
   6.333  			if (ok)
   6.334  			{
   6.335 -				y=api.parInt (ok,1);
   6.336 +				y=parser.parInt (ok,1);
   6.337  				if (ok) move (x,y);
   6.338  			}
   6.339  		}	
   6.340 @@ -683,18 +695,18 @@
   6.341  	{
   6.342  		if (xelection.isEmpty() )
   6.343  		{
   6.344 -			api.setError (Aborted,"Nothing selected");
   6.345 +			parser.setError (Aborted,"Nothing selected");
   6.346  		} else if ( xelection.type()!=Branch  && 
   6.347  					xelection.type()!=MapCenter  &&
   6.348  					xelection.type()!=FloatImage )
   6.349  		{				  
   6.350 -			api.setError (Aborted,"Type of selection is not a branch or floatimage");
   6.351 -		} else if (api.checkParamCount(2))
   6.352 +			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   6.353 +		} else if (parser.checkParamCount(2))
   6.354  		{	
   6.355 -			x=api.parInt (ok,0);
   6.356 +			x=parser.parInt (ok,0);
   6.357  			if (ok)
   6.358  			{
   6.359 -				y=api.parInt (ok,1);
   6.360 +				y=parser.parInt (ok,1);
   6.361  				if (ok) moveRel (x,y);
   6.362  			}
   6.363  		}	
   6.364 @@ -702,11 +714,11 @@
   6.365  	{
   6.366  		if (xelection.isEmpty() )
   6.367  		{
   6.368 -			api.setError (Aborted,"Nothing selected");
   6.369 +			parser.setError (Aborted,"Nothing selected");
   6.370  		} else if (! selb )
   6.371  		{				  
   6.372 -			api.setError (Aborted,"Type of selection is not a branch");
   6.373 -		} else if (api.checkParamCount(0))
   6.374 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.375 +		} else if (parser.checkParamCount(0))
   6.376  		{	
   6.377  			paste();
   6.378  		}	
   6.379 @@ -714,80 +726,96 @@
   6.380  	{
   6.381  		if (xelection.isEmpty() )
   6.382  		{
   6.383 -			api.setError (Aborted,"Nothing selected");
   6.384 +			parser.setError (Aborted,"Nothing selected");
   6.385  		} else if (! selb )
   6.386  		{				  
   6.387 -			api.setError (Aborted,"Type of selection is not a branch");
   6.388 -		} else if (api.checkParamCount(0))
   6.389 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.390 +		} else if (parser.checkParamCount(0))
   6.391  		{	
   6.392  			if (!scrollBranch ())	
   6.393 -				api.setError (Aborted,"Could not scroll branch");
   6.394 +				parser.setError (Aborted,"Could not scroll branch");
   6.395  		}	
   6.396  	} else if (com=="select")
   6.397  	{
   6.398 -		if (api.checkParamCount(1))
   6.399 +		if (parser.checkParamCount(1))
   6.400  		{
   6.401 -			s=api.parString(ok,0);
   6.402 +			s=parser.parString(ok,0);
   6.403  			if (ok) select (s);
   6.404  		}	
   6.405 +	} else if (com=="selectLastBranch")
   6.406 +	{
   6.407 +		if (xelection.isEmpty() )
   6.408 +		{
   6.409 +			parser.setError (Aborted,"Nothing selected");
   6.410 +		} else if (! selb )
   6.411 +		{				  
   6.412 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.413 +		} else if (parser.checkParamCount(0))
   6.414 +		{	
   6.415 +			BranchObj *bo=selb->getLastBranch();
   6.416 +			if (!bo)
   6.417 +				parser.setError (Aborted,"Could not select last branch");
   6.418 +			selectInt (bo);	
   6.419 +				
   6.420 +		}	
   6.421  	} else if (com=="setMapAuthor")
   6.422  	{
   6.423 -		if (api.checkParamCount(1))
   6.424 +		if (parser.checkParamCount(1))
   6.425  		{
   6.426 -			s=api.parString(ok,0);
   6.427 +			s=parser.parString(ok,0);
   6.428  			if (ok) setMapAuthor (s);
   6.429  		}	
   6.430  	} else if (com=="setMapComment")
   6.431  	{
   6.432 -		if (api.checkParamCount(1))
   6.433 +		if (parser.checkParamCount(1))
   6.434  		{
   6.435 -			s=api.parString(ok,0);
   6.436 +			s=parser.parString(ok,0);
   6.437  			if (ok) setMapComment(s);
   6.438  		}	
   6.439  	} else if (com=="setMapBackgroundColor")
   6.440  	{
   6.441  		if (xelection.isEmpty() )
   6.442  		{
   6.443 -			api.setError (Aborted,"Nothing selected");
   6.444 +			parser.setError (Aborted,"Nothing selected");
   6.445  		} else if (! xelection.getBranch() )
   6.446  		{				  
   6.447 -			api.setError (Aborted,"Type of selection is not a branch");
   6.448 -		} else if (api.checkParamCount(1))
   6.449 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.450 +		} else if (parser.checkParamCount(1))
   6.451  		{
   6.452 -			QColor c=api.parColor (ok,0);
   6.453 +			QColor c=parser.parColor (ok,0);
   6.454  			if (ok) setMapBackgroundColor (c);
   6.455  		}	
   6.456  	} else if (com=="setMapDefLinkColor")
   6.457  	{
   6.458  		if (xelection.isEmpty() )
   6.459  		{
   6.460 -			api.setError (Aborted,"Nothing selected");
   6.461 +			parser.setError (Aborted,"Nothing selected");
   6.462  		} else if (! selb )
   6.463  		{				  
   6.464 -			api.setError (Aborted,"Type of selection is not a branch");
   6.465 -		} else if (api.checkParamCount(1))
   6.466 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.467 +		} else if (parser.checkParamCount(1))
   6.468  		{
   6.469 -			QColor c=api.parColor (ok,0);
   6.470 +			QColor c=parser.parColor (ok,0);
   6.471  			if (ok) setMapDefLinkColor (c);
   6.472  		}	
   6.473  	} else if (com=="setMapLinkStyle")
   6.474  	{
   6.475 -		if (api.checkParamCount(1))
   6.476 +		if (parser.checkParamCount(1))
   6.477  		{
   6.478 -			s=api.parString (ok,0);
   6.479 +			s=parser.parString (ok,0);
   6.480  			if (ok) setMapLinkStyle(s);
   6.481  		}	
   6.482  	} else if (com=="setHeading")
   6.483  	{
   6.484  		if (xelection.isEmpty() )
   6.485  		{
   6.486 -			api.setError (Aborted,"Nothing selected");
   6.487 +			parser.setError (Aborted,"Nothing selected");
   6.488  		} else if (! selb )
   6.489  		{				  
   6.490 -			api.setError (Aborted,"Type of selection is not a branch");
   6.491 -		} else if (api.checkParamCount(1))
   6.492 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.493 +		} else if (parser.checkParamCount(1))
   6.494  		{
   6.495 -			s=api.parString (ok,0);
   6.496 +			s=parser.parString (ok,0);
   6.497  			if (ok) 
   6.498  				setHeading (s);
   6.499  		}	
   6.500 @@ -795,39 +823,39 @@
   6.501  	{
   6.502  		if (xelection.isEmpty() )
   6.503  		{
   6.504 -			api.setError (Aborted,"Nothing selected");
   6.505 +			parser.setError (Aborted,"Nothing selected");
   6.506  		} else if (! selb)
   6.507  		{				  
   6.508 -			api.setError (Aborted,"Type of selection is not a branch or floatimage");
   6.509 -		} else if (api.checkParamCount(1))
   6.510 +			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   6.511 +		} else if (parser.checkParamCount(1))
   6.512  		{
   6.513 -			b=api.parBool(ok,0);
   6.514 +			b=parser.parBool(ok,0);
   6.515  			if (ok) setHideExport (b);
   6.516  		}
   6.517  	} else if (com=="setURL")
   6.518  	{
   6.519  		if (xelection.isEmpty() )
   6.520  		{
   6.521 -			api.setError (Aborted,"Nothing selected");
   6.522 +			parser.setError (Aborted,"Nothing selected");
   6.523  		} else if (! selb )
   6.524  		{				  
   6.525 -			api.setError (Aborted,"Type of selection is not a branch");
   6.526 -		} else if (api.checkParamCount(1))
   6.527 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.528 +		} else if (parser.checkParamCount(1))
   6.529  		{
   6.530 -			s=api.parString (ok,0);
   6.531 +			s=parser.parString (ok,0);
   6.532  			if (ok) setURLInt(s);
   6.533  		}	
   6.534  	} else if (com=="setVymLink")
   6.535  	{
   6.536  		if (xelection.isEmpty() )
   6.537  		{
   6.538 -			api.setError (Aborted,"Nothing selected");
   6.539 +			parser.setError (Aborted,"Nothing selected");
   6.540  		} else if (! selb )
   6.541  		{				  
   6.542 -			api.setError (Aborted,"Type of selection is not a branch");
   6.543 -		} else if (api.checkParamCount(1))
   6.544 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.545 +		} else if (parser.checkParamCount(1))
   6.546  		{
   6.547 -			s=api.parString (ok,0);
   6.548 +			s=parser.parString (ok,0);
   6.549  			if (ok) setVymLinkInt(s);
   6.550  		}	
   6.551  	}
   6.552 @@ -835,13 +863,13 @@
   6.553  	{
   6.554  		if (xelection.isEmpty() )
   6.555  		{
   6.556 -			api.setError (Aborted,"Nothing selected");
   6.557 +			parser.setError (Aborted,"Nothing selected");
   6.558  		} else if (! selb )
   6.559  		{				  
   6.560 -			api.setError (Aborted,"Type of selection is not a branch");
   6.561 -		} else if (api.checkParamCount(1))
   6.562 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.563 +		} else if (parser.checkParamCount(1))
   6.564  		{
   6.565 -			s=api.parString(ok,0);
   6.566 +			s=parser.parString(ok,0);
   6.567  			if (ok) 
   6.568  			{
   6.569  				selb->activateStandardFlag(s);
   6.570 @@ -852,26 +880,26 @@
   6.571  	{
   6.572  		if (xelection.isEmpty() )
   6.573  		{
   6.574 -			api.setError (Aborted,"Nothing selected");
   6.575 +			parser.setError (Aborted,"Nothing selected");
   6.576  		} else if (! selb )
   6.577  		{				  
   6.578 -			api.setError (Aborted,"Type of selection is not a branch");
   6.579 -		} else if (api.checkParamCount(0))
   6.580 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.581 +		} else if (parser.checkParamCount(0))
   6.582  		{	
   6.583  			if (!unscrollBranch ())	
   6.584 -				api.setError (Aborted,"Could not unscroll branch");
   6.585 +				parser.setError (Aborted,"Could not unscroll branch");
   6.586  		}	
   6.587  	} else if (com=="unsetFlag")
   6.588  	{
   6.589  		if (xelection.isEmpty() )
   6.590  		{
   6.591 -			api.setError (Aborted,"Nothing selected");
   6.592 +			parser.setError (Aborted,"Nothing selected");
   6.593  		} else if (! selb )
   6.594  		{				  
   6.595 -			api.setError (Aborted,"Type of selection is not a branch");
   6.596 -		} else if (api.checkParamCount(1))
   6.597 +			parser.setError (Aborted,"Type of selection is not a branch");
   6.598 +		} else if (parser.checkParamCount(1))
   6.599  		{
   6.600 -			s=api.parString(ok,0);
   6.601 +			s=parser.parString(ok,0);
   6.602  			if (ok) 
   6.603  			{
   6.604  				selb->deactivateStandardFlag(s);
   6.605 @@ -879,19 +907,43 @@
   6.606  			}	
   6.607  		}
   6.608  	} else
   6.609 -		api.setError (Aborted,"Unknown command");
   6.610 +		parser.setError (Aborted,"Unknown command");
   6.611  
   6.612  	// Any errors?
   6.613 -	if (api.errorLevel()==NoError)
   6.614 +	if (parser.errorLevel()==NoError)
   6.615 +	{
   6.616  		setChanged();
   6.617 +		mapCenter->reposition();
   6.618 +	}	
   6.619  	else	
   6.620  	{
   6.621  		// TODO Error handling
   6.622  		qWarning("MapEditor::parseAtom: Error!");
   6.623 -		qWarning(api.errorMessage());
   6.624 +		qWarning(parser.errorMessage());
   6.625  	} 
   6.626  }
   6.627  
   6.628 +void MapEditor::runScript (QString script)
   6.629 +{
   6.630 +	// TODO "atomize" script, currently each line holds one atom
   6.631 +
   6.632 +	QStringList list=script.split("\n");
   6.633 +	QString l;
   6.634 +	int pos;
   6.635 +	for (int i=0; i<list.size(); i++)
   6.636 +	{
   6.637 +		l=list.at(i);
   6.638 +
   6.639 +		// Ignore comments
   6.640 +		pos=l.indexOf ("#");
   6.641 +		if (pos>=0) l.truncate (pos);
   6.642 +
   6.643 +		// Try to ignore empty lines
   6.644 +		if (l.contains (QRegExp ("\\w")))
   6.645 +			parseAtom (l);
   6.646 +	}
   6.647 +
   6.648 +}
   6.649  
   6.650  bool MapEditor::isDefault()
   6.651  {
   6.652 @@ -3017,6 +3069,21 @@
   6.653  	}	
   6.654  }
   6.655  
   6.656 +FloatImageObj* MapEditor::loadFloatImageInt (QString fn)
   6.657 +{
   6.658 +	BranchObj *bo=xelection.getBranch();
   6.659 +	if (bo)
   6.660 +	{
   6.661 +		FloatImageObj *fio;
   6.662 +		bo->addFloatImage();
   6.663 +		fio=bo->getLastFloatImage();
   6.664 +		fio->load(fn);
   6.665 +		mapCenter->reposition();
   6.666 +		scene()->update();
   6.667 +		return fio;
   6.668 +	}
   6.669 +	return NULL;
   6.670 +}	
   6.671  
   6.672  void MapEditor::loadFloatImage ()
   6.673  {
   6.674 @@ -3035,34 +3102,28 @@
   6.675  		fd->setDir (lastImageDir);
   6.676  		fd->show();
   6.677  
   6.678 -		QString fn;
   6.679  		if ( fd->exec() == QDialog::Accepted )
   6.680  		{
   6.681  			// FIXME loadFIO in QT4 use:	lastImageDir=fd->directory();
   6.682  			lastImageDir=QDir (fd->dirPath());
   6.683 -			QStringList flist = fd->selectedFiles();
   6.684 -			QStringList::Iterator it = flist.begin();
   6.685 +			QString s;
   6.686  			FloatImageObj *fio;
   6.687 -			while( it != flist.end() ) 
   6.688 +			for (int j=0; j<fd->selectedFiles().count(); j++)
   6.689  			{
   6.690 -				fn = *it;
   6.691 -				bo->addFloatImage();
   6.692 -				fio=bo->getLastFloatImage();
   6.693 -				fio->load(*it);
   6.694 -				// FIXME loadFIO check if load of fio was successful
   6.695 -				saveState(
   6.696 -					(LinkableMapObj*)fio,
   6.697 -					"delete ()",
   6.698 -					bo, 
   6.699 -					QString ("loadFloatImage (%1)").arg(*it),
   6.700 -					QString("Add floatimage %1 to %2").arg(*it).arg(getName(bo))
   6.701 -				);
   6.702 -				bo->getLastFloatImage()->setOriginalFilename(fn);
   6.703 -				++it;
   6.704 +				s=fd->selectedFiles().at(j);
   6.705 +				fio=loadFloatImageInt (s);
   6.706 +				if (fio)
   6.707 +					saveState(
   6.708 +						(LinkableMapObj*)fio,
   6.709 +						"delete ()",
   6.710 +						bo, 
   6.711 +						QString ("loadImage (%1)").arg(s ),
   6.712 +						QString("Add image %1 to %2").arg(s).arg(getName(bo))
   6.713 +					);
   6.714 +				else
   6.715 +					// FIXME loadFIO error handling
   6.716 +					qWarning ("Failed to load "+s);
   6.717  			}
   6.718 -
   6.719 -			mapCenter->reposition();
   6.720 -			scene()->update();
   6.721  		}
   6.722  		delete (p);
   6.723  		delete (fd);
   6.724 @@ -3269,16 +3330,19 @@
   6.725  {
   6.726  	// This is the playground
   6.727  
   6.728 +	
   6.729 +/*
   6.730  	WarningDialog dia;
   6.731  	dia.showCancelButton (true);
   6.732  	dia.setText("This is a longer \nWarning");
   6.733  	dia.setCaption("Warning: Flux problem");
   6.734 -	dia.setShowAgainName("/warnings/mapeditor");
   6.735 +	dia.setShowAgainName("mapeditor/testDialog");
   6.736  	if (dia.exec()==QDialog::Accepted)
   6.737  		cout << "accepted!\n";
   6.738  	else	
   6.739  		cout << "canceled!\n";
   6.740  	return;
   6.741 +*/
   6.742  
   6.743  /* TODO Hide hidden stuff temporary, maybe add this as regular function somewhere
   6.744  	if (hidemode==HideNone)
     7.1 --- a/mapeditor.h	Sat Feb 24 12:32:53 2007 +0000
     7.2 +++ b/mapeditor.h	Mon Mar 05 23:22:51 2007 +0000
     7.3 @@ -7,6 +7,7 @@
     7.4  #include "mapcenterobj.h"
     7.5  #include "file.h"
     7.6  #include "misc.h"
     7.7 +#include "parser.h"
     7.8  #include "selection.h"
     7.9  #include "settings.h"
    7.10  
    7.11 @@ -31,7 +32,8 @@
    7.12      void saveState(const QString &, const QString &, const QString &, const QString &, const QString &);
    7.13      void saveState(const SaveMode&, const QString &, const QString &, const QString &, const QString &, const QString &, LinkableMapObj *);
    7.14  public:	
    7.15 -    void parseAtom(const QString &);	
    7.16 +    void parseAtom (const QString &);	
    7.17 +	void runScript (QString);
    7.18  private:
    7.19      void addFloatImageInt(const QPixmap &img);
    7.20  
    7.21 @@ -162,6 +164,9 @@
    7.22  	bool unscrollBranch();
    7.23      void toggleScroll();
    7.24      void unscrollChilds();
    7.25 +private:	
    7.26 +	FloatImageObj* loadFloatImageInt (QString);
    7.27 +public:	
    7.28  	void loadFloatImage ();
    7.29  	void saveFloatImage ();
    7.30  	void setFrame(const FrameType &);
    7.31 @@ -229,6 +234,8 @@
    7.32      bool mapChanged;				// Flag if undo is possible
    7.33  	bool mapUnsaved;				// Flag if map should be saved
    7.34  
    7.35 +	Parser parser;				// Parser stuff for scripting
    7.36 +
    7.37  	bool printFrame;			// Print frame around map
    7.38  	bool printFooter;			// Print footer below map
    7.39  
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/parser.cpp	Mon Mar 05 23:22:51 2007 +0000
     8.3 @@ -0,0 +1,234 @@
     8.4 +#include "parser.h"
     8.5 +
     8.6 +#include <QRegExp>
     8.7 +#include <iostream>
     8.8 +
     8.9 +using namespace std;
    8.10 +
    8.11 +Parser::Parser()
    8.12 +{
    8.13 +	initCommand();
    8.14 +}
    8.15 +
    8.16 +void Parser::initCommand()
    8.17 +{
    8.18 +	com="";
    8.19 +	paramList.clear();
    8.20 +	resetError();
    8.21 +}
    8.22 +
    8.23 +void Parser::parseAtom (const QString &s)
    8.24 +{
    8.25 +	initCommand();
    8.26 +	input=s;
    8.27 +	QRegExp re;
    8.28 +	int pos;
    8.29 +
    8.30 +	// Get command
    8.31 +	re.setPattern ("\\b(.*)(\\s|\\()");
    8.32 +	re.setMinimal (true);
    8.33 +	pos=re.search (s);
    8.34 +	if (pos>=0)
    8.35 +		com=re.cap(1);
    8.36 +
    8.37 +	// Get parameters
    8.38 +	paramList.clear();
    8.39 +	re.setPattern ("\\((.*)\\)");
    8.40 +	pos=re.search (s);
    8.41 +	//cout << "  s="<<s.ascii()<<endl;
    8.42 +	//cout << "com="<<com.ascii()<<"  pos="<<pos<<endl<<endl;
    8.43 +	if (pos>=0)
    8.44 +	{
    8.45 +		QString s=re.cap(1);
    8.46 +		QString a;
    8.47 +		bool inquote=false;
    8.48 +		pos=0;
    8.49 +		if (!s.isEmpty())
    8.50 +		{
    8.51 +			while (pos<s.length())
    8.52 +			{
    8.53 +				if (s.at(pos)=='\"') 
    8.54 +				{
    8.55 +					if (inquote)
    8.56 +						inquote=false;
    8.57 +					else	
    8.58 +						inquote=true;
    8.59 +				}
    8.60 +
    8.61 +				if (s.at(pos)==',' && !inquote)
    8.62 +				{
    8.63 +					a=s.left(pos);
    8.64 +					paramList.append(a);
    8.65 +					s=s.right(s.length()-pos-1);
    8.66 +					pos=0;
    8.67 +				} else
    8.68 +					pos++;
    8.69 +				
    8.70 +			}
    8.71 +			paramList.append (s);
    8.72 +		}	
    8.73 +	}	
    8.74 +}
    8.75 +
    8.76 +QString Parser::command()
    8.77 +{
    8.78 +	return com;
    8.79 +}
    8.80 +
    8.81 +QStringList Parser::parameters()
    8.82 +{
    8.83 +	return paramList;
    8.84 +}
    8.85 +
    8.86 +int Parser::paramCount()
    8.87 +{
    8.88 +	return paramList.count();
    8.89 +}
    8.90 +
    8.91 +
    8.92 +QString Parser::errorMessage()
    8.93 +{
    8.94 +	QString l;
    8.95 +	switch (errLevel)
    8.96 +	{
    8.97 +		case NoError: l="No Error";
    8.98 +		case Warning: l="Warning";
    8.99 +		case Aborted: l="Aborted";
   8.100 +	}
   8.101 +	return QString ("Error Level: %1\n    Command: %2\nDescription: %3")
   8.102 +		.arg(l).arg(com).arg(errDescription);
   8.103 +}
   8.104 +
   8.105 +QString Parser::errorDescription()
   8.106 +{
   8.107 +	return errDescription;
   8.108 +}
   8.109 +
   8.110 +ErrorLevel Parser::errorLevel()
   8.111 +{
   8.112 +	return errLevel;
   8.113 +}
   8.114 +
   8.115 +void Parser::setError(ErrorLevel level, const QString &description)
   8.116 +{
   8.117 +	errDescription=description;
   8.118 +	errLevel=level;
   8.119 +}
   8.120 +
   8.121 +void Parser::resetError ()
   8.122 +{
   8.123 +	errMessage="";
   8.124 +	errDescription="";
   8.125 +	errLevel=NoError;
   8.126 +}
   8.127 +
   8.128 +
   8.129 +bool Parser::checkParamCount (QList <int> plist)
   8.130 +{
   8.131 +	QStringList expList;
   8.132 +	QString expected;
   8.133 +	for (int i=0; i<plist.count();i++)
   8.134 +	{
   8.135 +		if (checkParamCount (plist[i])) 
   8.136 +		{
   8.137 +			resetError();
   8.138 +			return true;
   8.139 +		}
   8.140 +		expList.append(QString().setNum(plist[i]));
   8.141 +	}	
   8.142 +	expected=expList.join(",");	
   8.143 +	errDescription=QString("Wrong number of parameters: Expected %1, but found %2").arg(expected).arg(paramList.count());
   8.144 +	return false;
   8.145 +}
   8.146 +
   8.147 +bool Parser::checkParamCount (const int &expected)
   8.148 +{
   8.149 +	if (paramList.count()!=expected)
   8.150 +	{
   8.151 +		errLevel=Aborted;
   8.152 +		errDescription=QString("Wrong number of parameters: Expected %1, but found %2").arg(expected).arg(paramList.count());
   8.153 +		return false;
   8.154 +	} 
   8.155 +	return true;	
   8.156 +}
   8.157 +
   8.158 +bool Parser::checkParamIsInt(const int &index)
   8.159 +{
   8.160 +	bool ok;
   8.161 +	if (index > paramList.count())
   8.162 +	{
   8.163 +		errLevel=Aborted;
   8.164 +		errDescription=QString("Parameter index %1 is outside of parameter list").arg(index);
   8.165 +		return false;
   8.166 +	} else
   8.167 +	{
   8.168 +		paramList[index].toInt (&ok, 10);
   8.169 +		if (!ok)
   8.170 +		{
   8.171 +			errLevel=Aborted;
   8.172 +			errDescription=QString("Parameter %1 is not an integer").arg(index);
   8.173 +			return false;
   8.174 +		} 
   8.175 +	}	
   8.176 +	return true;
   8.177 +}
   8.178 +
   8.179 +int Parser::parInt (bool &ok,const uint &index)
   8.180 +{
   8.181 +	if (checkParamIsInt (index))
   8.182 +		return paramList[index].toInt (&ok, 10);
   8.183 +	ok=false;
   8.184 +	return 0;
   8.185 +}
   8.186 +
   8.187 +QString Parser::parString (bool &ok,const int &index)
   8.188 +{
   8.189 +	// return the string at index, this could be also stored in
   8.190 +	// a variable later
   8.191 +	QString r;
   8.192 +	QRegExp re("\"(.*)\"");
   8.193 +	int pos=re.search (paramList[index]);
   8.194 +	if (pos>=0)
   8.195 +		r=re.cap (1);
   8.196 +	else	
   8.197 +		r="";
   8.198 +	ok=true;
   8.199 +	return r;
   8.200 +}
   8.201 +
   8.202 +bool Parser::parBool (bool &ok,const int &index)
   8.203 +{
   8.204 +	// return the bool at index, this could be also stored in
   8.205 +	// a variable later
   8.206 +	QString r;
   8.207 +	ok=true;
   8.208 +	QString p=paramList[index];
   8.209 +	if (p=="true" || p=="1")
   8.210 +		return true;
   8.211 +	else if	(p=="false" || p=="0")
   8.212 +		return false;
   8.213 +	ok=false;
   8.214 +	return ok;
   8.215 +}
   8.216 +
   8.217 +QColor Parser::parColor(bool &ok,const int &index)
   8.218 +{
   8.219 +	// return the QColor at index
   8.220 +	ok=true;
   8.221 +	return QColor (paramList[index]);
   8.222 +}
   8.223 +
   8.224 +void Parser::setScript(const QString &s)
   8.225 +{
   8.226 +	script=s;
   8.227 +}	
   8.228 +
   8.229 +QString Parser::getScript()
   8.230 +{
   8.231 +	return script;
   8.232 +}	
   8.233 +
   8.234 +void Parser::startScript()
   8.235 +{
   8.236 +}	
   8.237 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/parser.h	Mon Mar 05 23:22:51 2007 +0000
     9.3 @@ -0,0 +1,49 @@
     9.4 +#ifndef PARSER_H
     9.5 +#define PARSER_H
     9.6 +
     9.7 +#include <QColor>
     9.8 +#include <QStringList>
     9.9 +
    9.10 +enum ErrorLevel {NoError,Warning,Aborted};
    9.11 +
    9.12 +class Parser
    9.13 +{
    9.14 +public:
    9.15 +	Parser();
    9.16 +	void parseAtom (const QString &input);
    9.17 +	QString command();
    9.18 +	QStringList parameters();
    9.19 +	int paramCount();
    9.20 +	QString errorMessage();
    9.21 +	QString errorDescription();
    9.22 +	ErrorLevel errorLevel();
    9.23 +	void setError (ErrorLevel level,const QString &description);
    9.24 +	void resetError();
    9.25 +	bool checkParamCount (QList <int> plist);
    9.26 +	bool checkParamCount (const int &index);
    9.27 +	bool checkParamIsInt (const int &index);
    9.28 +	int parInt (bool &,const uint &index);
    9.29 +	QString parString(bool &ok,const int &index);
    9.30 +	bool parBool (bool &ok, const int &index);
    9.31 +	QColor parColor (bool &ok, const int &index);
    9.32 +
    9.33 +	void setScript (const QString &);
    9.34 +	QString getScript();
    9.35 +	void startScript();
    9.36 +	bool next();
    9.37 +
    9.38 +
    9.39 +private:
    9.40 +	void initCommand();
    9.41 +
    9.42 +	QString input;
    9.43 +	QString com;
    9.44 +	QStringList paramList;
    9.45 +	QString script;
    9.46 +
    9.47 +	QString errMessage;
    9.48 +	QString errDescription;
    9.49 +	ErrorLevel errLevel;
    9.50 +};
    9.51 +
    9.52 +#endif
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/simplescripteditor.cpp	Mon Mar 05 23:22:51 2007 +0000
    10.3 @@ -0,0 +1,109 @@
    10.4 +#include "simplescripteditor.h"
    10.5 +
    10.6 +
    10.7 +#include <QFileDialog>
    10.8 +#include <QMessageBox>
    10.9 +#include <QTextStream>
   10.10 +
   10.11 +
   10.12 +extern QString vymName;
   10.13 +
   10.14 +SimpleScriptEditor::SimpleScriptEditor (QWidget *parent):QDialog(parent)
   10.15 +{
   10.16 +	ui.setupUi (this);
   10.17 +
   10.18 +	connect ( ui.loadButton, SIGNAL (clicked() ), this, SLOT (loadScriptClicked() ));
   10.19 +	connect ( ui.saveButton, SIGNAL (clicked() ), this, SLOT (saveScriptClicked() ));
   10.20 +	connect ( ui.runButton,  SIGNAL (clicked() ), this, SLOT (runScriptClicked() ));
   10.21 +}
   10.22 +
   10.23 +
   10.24 +void SimpleScriptEditor::saveScript()
   10.25 +{
   10.26 +	QFile f( filename );
   10.27 +	if ( !f.open( QIODevice::WriteOnly ) ) 
   10.28 +	{
   10.29 +		return;
   10.30 +	}
   10.31 +
   10.32 +	QTextStream t( &f );
   10.33 +	t << ui.editor->text();
   10.34 +	f.close();
   10.35 +}
   10.36 +
   10.37 +void SimpleScriptEditor::saveScriptClicked()
   10.38 +{
   10.39 +	QString fn = QFileDialog::getSaveFileName( 
   10.40 +		this, 
   10.41 +		QString (vymName + " - " +tr("Save script")),
   10.42 +		QString (),
   10.43 +		"VYM script (HTML) (*.vys);;All files (*)",
   10.44 +		0,
   10.45 +		QFileDialog::DontConfirmOverwrite);
   10.46 +		
   10.47 +    if ( !fn.isEmpty() ) 
   10.48 +	{
   10.49 +		QFile file (fn);
   10.50 +		if (file.exists())
   10.51 +		{
   10.52 +			QMessageBox mb( vymName,
   10.53 +				tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save as'").arg(fn),
   10.54 +			QMessageBox::Warning,
   10.55 +			QMessageBox::Yes | QMessageBox::Default,
   10.56 +			QMessageBox::Cancel | QMessageBox::Escape,
   10.57 +			Qt::NoButton );
   10.58 +			mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
   10.59 +			mb.setButtonText( QMessageBox::No, tr("Cancel"));
   10.60 +			switch( mb.exec() ) 
   10.61 +			{
   10.62 +				case QMessageBox::Yes:
   10.63 +					// save 
   10.64 +					filename = fn;
   10.65 +					saveScript();
   10.66 +					return;
   10.67 +				case QMessageBox::Cancel:
   10.68 +					// do nothing
   10.69 +					return;
   10.70 +			}
   10.71 +		} 
   10.72 +		filename=fn;
   10.73 +		saveScript();
   10.74 +    }
   10.75 +}
   10.76 +
   10.77 +void SimpleScriptEditor::loadScriptClicked()
   10.78 +{
   10.79 +	QFileDialog *fd=new QFileDialog( this);
   10.80 +	QStringList types;
   10.81 +	types<< "VYM scripts (*.vys)" <<
   10.82 +	        "All         (*)" ;
   10.83 +	fd->setFilters (types);
   10.84 +	fd->setDirectory (QDir().current());
   10.85 +	fd->setCaption (vymName + " - " + tr("Load script"));
   10.86 +	fd->show();
   10.87 +	QString fn;
   10.88 +	if ( fd->exec() == QDialog::Accepted )
   10.89 +		fn = fd->selectedFile();
   10.90 +
   10.91 +	if ( !fn.isEmpty() )
   10.92 +	{
   10.93 +		QFile f( fn );
   10.94 +		if ( !f.open( QIODevice::ReadOnly ) )
   10.95 +		{
   10.96 +			QMessageBox::warning(0, 
   10.97 +				tr("Error"),
   10.98 +				tr("Couldn't open %1.\n").arg(fn));
   10.99 +			return;
  10.100 +		}	
  10.101 +
  10.102 +		QTextStream ts( &f );
  10.103 +		ui.editor->setText( ts.read() );
  10.104 +		f.close();
  10.105 +	}
  10.106 +
  10.107 +}
  10.108 +
  10.109 +void SimpleScriptEditor::runScriptClicked()
  10.110 +{
  10.111 +	emit runScript (ui.editor->text() );
  10.112 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/simplescripteditor.h	Mon Mar 05 23:22:51 2007 +0000
    11.3 @@ -0,0 +1,28 @@
    11.4 +#ifndef SIMPLESCRIPTEDITOR_H
    11.5 +#define SIMPLESCRIPTEDITOR_H
    11.6 +
    11.7 +#include "ui_simplescripteditor.h"
    11.8 +
    11.9 +class SimpleScriptEditor:public QDialog
   11.10 +{
   11.11 +    Q_OBJECT
   11.12 +
   11.13 +public:
   11.14 +    SimpleScriptEditor (QWidget* parent = 0);
   11.15 +	void saveScript ();
   11.16 +
   11.17 +public slots:
   11.18 +	void saveScriptClicked();
   11.19 +	void loadScriptClicked();
   11.20 +	void runScriptClicked();
   11.21 +
   11.22 +signals:
   11.23 +	void runScript (QString);
   11.24 +	
   11.25 +private:
   11.26 +    Ui::SimpleScriptEditor ui;
   11.27 +	QString filename;
   11.28 +};
   11.29 +
   11.30 +
   11.31 +#endif 
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/simplescripteditor.ui	Mon Mar 05 23:22:51 2007 +0000
    12.3 @@ -0,0 +1,97 @@
    12.4 +<ui version="4.0" >
    12.5 + <class>SimpleScriptEditor</class>
    12.6 + <widget class="QDialog" name="SimpleScriptEditor" >
    12.7 +  <property name="geometry" >
    12.8 +   <rect>
    12.9 +    <x>0</x>
   12.10 +    <y>0</y>
   12.11 +    <width>551</width>
   12.12 +    <height>407</height>
   12.13 +   </rect>
   12.14 +  </property>
   12.15 +  <property name="windowTitle" >
   12.16 +   <string>Simple Script Editor</string>
   12.17 +  </property>
   12.18 +  <layout class="QHBoxLayout" >
   12.19 +   <property name="margin" >
   12.20 +    <number>9</number>
   12.21 +   </property>
   12.22 +   <property name="spacing" >
   12.23 +    <number>6</number>
   12.24 +   </property>
   12.25 +   <item>
   12.26 +    <widget class="QTextEdit" name="editor" />
   12.27 +   </item>
   12.28 +   <item>
   12.29 +    <layout class="QVBoxLayout" >
   12.30 +     <property name="margin" >
   12.31 +      <number>0</number>
   12.32 +     </property>
   12.33 +     <property name="spacing" >
   12.34 +      <number>6</number>
   12.35 +     </property>
   12.36 +     <item>
   12.37 +      <widget class="QPushButton" name="runButton" >
   12.38 +       <property name="text" >
   12.39 +        <string>Run</string>
   12.40 +       </property>
   12.41 +      </widget>
   12.42 +     </item>
   12.43 +     <item>
   12.44 +      <widget class="QPushButton" name="loadButton" >
   12.45 +       <property name="text" >
   12.46 +        <string>Load</string>
   12.47 +       </property>
   12.48 +      </widget>
   12.49 +     </item>
   12.50 +     <item>
   12.51 +      <widget class="QPushButton" name="saveButton" >
   12.52 +       <property name="text" >
   12.53 +        <string>Save</string>
   12.54 +       </property>
   12.55 +      </widget>
   12.56 +     </item>
   12.57 +     <item>
   12.58 +      <spacer>
   12.59 +       <property name="orientation" >
   12.60 +        <enum>Qt::Vertical</enum>
   12.61 +       </property>
   12.62 +       <property name="sizeHint" >
   12.63 +        <size>
   12.64 +         <width>20</width>
   12.65 +         <height>40</height>
   12.66 +        </size>
   12.67 +       </property>
   12.68 +      </spacer>
   12.69 +     </item>
   12.70 +     <item>
   12.71 +      <widget class="QPushButton" name="closeButton" >
   12.72 +       <property name="text" >
   12.73 +        <string>Close</string>
   12.74 +       </property>
   12.75 +      </widget>
   12.76 +     </item>
   12.77 +    </layout>
   12.78 +   </item>
   12.79 +  </layout>
   12.80 + </widget>
   12.81 + <resources/>
   12.82 + <connections>
   12.83 +  <connection>
   12.84 +   <sender>closeButton</sender>
   12.85 +   <signal>clicked()</signal>
   12.86 +   <receiver>SimpleScriptEditor</receiver>
   12.87 +   <slot>accept()</slot>
   12.88 +   <hints>
   12.89 +    <hint type="sourcelabel" >
   12.90 +     <x>519</x>
   12.91 +     <y>390</y>
   12.92 +    </hint>
   12.93 +    <hint type="destinationlabel" >
   12.94 +     <x>-25</x>
   12.95 +     <y>-275</y>
   12.96 +    </hint>
   12.97 +   </hints>
   12.98 +  </connection>
   12.99 + </connections>
  12.100 +</ui>
    13.1 --- a/tex/vym.changelog	Sat Feb 24 12:32:53 2007 +0000
    13.2 +++ b/tex/vym.changelog	Mon Mar 05 23:22:51 2007 +0000
    13.3 @@ -1,3 +1,9 @@
    13.4 +-------------------------------------------------------------------
    13.5 +Mon Mar  5 22:10:26 CET 2007 - uwe
    13.6 +
    13.7 +- Version: 1.8.69
    13.8 +- Feature: Simple Editor for scripts
    13.9 +
   13.10  -------------------------------------------------------------------
   13.11  Tue Feb 20 22:16:09 CET 2007 - uwe
   13.12  
    14.1 --- a/version.h	Sat Feb 24 12:32:53 2007 +0000
    14.2 +++ b/version.h	Mon Mar 05 23:22:51 2007 +0000
    14.3 @@ -4,8 +4,8 @@
    14.4  #include <QString>
    14.5  
    14.6  #define __VYM_NAME "VYM"
    14.7 -#define __VYM_VERSION "1.8.68"
    14.8 -#define __VYM_BUILD_DATE "February 20, 2007"
    14.9 +#define __VYM_VERSION "1.8.69"
   14.10 +#define __VYM_BUILD_DATE "March 05, 2007"
   14.11  
   14.12  
   14.13  bool checkVersion(const QString &);
    15.1 --- a/vym.pro	Sat Feb 24 12:32:53 2007 +0000
    15.2 +++ b/vym.pro	Mon Mar 05 23:22:51 2007 +0000
    15.3 @@ -1,7 +1,7 @@
    15.4  TEMPLATE	= app
    15.5  LANGUAGE	= C++
    15.6  
    15.7 -CONFIG	+= qt warn_on release
    15.8 +CONFIG	+= qt warn_on release debug
    15.9  CONFIG += x86 ppc
   15.10  ICON =icons/vym.icns
   15.11  
   15.12 @@ -9,7 +9,6 @@
   15.13  
   15.14  HEADERS	+= \	
   15.15  	aboutdialog.h \
   15.16 -	api.h \
   15.17  	branchobj.h \
   15.18  	branchpropwindow.h\
   15.19  	editxlinkdialog.h \
   15.20 @@ -38,9 +37,11 @@
   15.21  	noteobj.h \
   15.22  	options.h \
   15.23  	ornamentedobj.h \
   15.24 +	parser.h \
   15.25  	process.h \
   15.26  	showtextdialog.h\
   15.27  	selection.h \
   15.28 +	simplescripteditor.h\
   15.29  	texteditor.h \
   15.30  	version.h \
   15.31  	xml.h \
   15.32 @@ -50,7 +51,6 @@
   15.33  
   15.34  SOURCES	+= \
   15.35  	aboutdialog.cpp \
   15.36 -	api.cpp \
   15.37  	branchobj.cpp \
   15.38  	branchpropwindow.cpp \
   15.39  	editxlinkdialog.cpp \
   15.40 @@ -80,8 +80,10 @@
   15.41  	noteobj.cpp \
   15.42  	options.cpp \
   15.43  	ornamentedobj.cpp \
   15.44 +	parser.cpp \
   15.45  	process.cpp \
   15.46  	showtextdialog.cpp \
   15.47 +	simplescripteditor.cpp \
   15.48  	selection.cpp \
   15.49  	texteditor.cpp \
   15.50  	version.cpp \
   15.51 @@ -96,6 +98,7 @@
   15.52  	extrainfodialog.ui \
   15.53  	editxlinkdialog.ui \
   15.54  	historywindow.ui \
   15.55 +	simplescripteditor.ui \
   15.56  	showtextdialog.ui \
   15.57  	warningdialog.ui
   15.58  
    16.1 --- a/warningdialog.cpp	Sat Feb 24 12:32:53 2007 +0000
    16.2 +++ b/warningdialog.cpp	Mon Mar 05 23:22:51 2007 +0000
    16.3 @@ -1,6 +1,8 @@
    16.4  #include "warningdialog.h"
    16.5 +#include "settings.h"
    16.6  
    16.7  extern QString iconPath;
    16.8 +extern Settings settings;
    16.9  
   16.10  WarningDialog::WarningDialog(QWidget* parent):QDialog (parent)
   16.11  {
   16.12 @@ -9,12 +11,30 @@
   16.13  	ui.okButton->setText(tr("Proceed"));
   16.14  	/*
   16.15  	ui.warningSign->setPixmap (QPixmap(iconPath + "icons/vym.png"));
   16.16 +	*/
   16.17  	ui.showAgainBox->setText (tr("Show this message again"));
   16.18 -	*/
   16.19  	useShowAgain=false;
   16.20  	ui.showAgainBox->hide();
   16.21  }
   16.22  
   16.23 +int WarningDialog::exec()
   16.24 +{
   16.25 +	int result; 
   16.26 +	if (settings.value ("/warningDialog/"+showAgainName+"/showAgain",true).toBool()  )
   16.27 +	{
   16.28 +		result=QDialog::exec();
   16.29 +		if (result==QDialog::Accepted )
   16.30 +		{
   16.31 +			settings.setValue ("/warningDialog/"+showAgainName+"/value",result);
   16.32 +			settings.setValue ("/warningDialog/"+showAgainName+"/showAgain",ui.showAgainBox->isChecked() );
   16.33 +		}
   16.34 +	} else
   16.35 +	{
   16.36 +		result=settings.value ("/warningDialog/"+showAgainName+"/value",0).toInt();
   16.37 +	}
   16.38 +	return result;
   16.39 +}
   16.40 +
   16.41  void WarningDialog::showCancelButton (bool b)
   16.42  {
   16.43  	if (b)
   16.44 @@ -27,11 +47,9 @@
   16.45  
   16.46  void WarningDialog::setShowAgainName (const QString &s) //FIXME not implemented yet
   16.47  {
   16.48 -/*
   16.49  	showAgainName=s;
   16.50  	useShowAgain=true;
   16.51  	ui.showAgainBox->show();
   16.52 -*/	
   16.53  }
   16.54  
   16.55  void WarningDialog::setText (const QString &s)