1.8.58 - More undoCommands, spanish translation of doc
authorinsilmaril
Tue Oct 24 15:36:38 2006 +0000 (2006-10-24)
changeset 39467cfa6e6b863
parent 393 053b8645e3e9
child 395 7ced3733ba60
1.8.58 - More undoCommands, spanish translation of doc
api.cpp
api.h
branchobj.cpp
demos/todo.vym
doc/vym_es.pdf
historywindow.cpp
linkablemapobj.cpp
main.cpp
mainwindow.cpp
mainwindow.h
mapeditor.cpp
mapeditor.h
tex/vym.changelog
version.h
xml.cpp
     1.1 --- a/api.cpp	Wed Oct 18 10:45:00 2006 +0000
     1.2 +++ b/api.cpp	Tue Oct 24 15:36:38 2006 +0000
     1.3 @@ -11,13 +11,13 @@
     1.4  {
     1.5  	com="";
     1.6  	paramList.clear();
     1.7 -	errorString="";
     1.8 -	noErr=true;
     1.9 +	resetError();
    1.10  }
    1.11  
    1.12 -void API::parseCommand (const QString &s)
    1.13 +void API::parseInput (const QString &s)
    1.14  {
    1.15  	initCommand();
    1.16 +	input=s;
    1.17  	QRegExp re;
    1.18  	int pos;
    1.19  
    1.20 @@ -75,32 +75,76 @@
    1.21  	return paramList;
    1.22  }
    1.23  
    1.24 -QString API::errorDesc()
    1.25 +int API::paramCount()
    1.26  {
    1.27 -	return errorString;
    1.28 +	return paramList.count();
    1.29  }
    1.30  
    1.31 -bool API::error()
    1.32 +
    1.33 +QString API::errorMessage()
    1.34  {
    1.35 -	// invert noErr
    1.36 -	return (noErr) ?false:true;
    1.37 +	QString l;
    1.38 +	switch (errLevel)
    1.39 +	{
    1.40 +		case NoError: l="No Error";
    1.41 +		case Warning: l="Warning";
    1.42 +		case Aborted: l="Aborted";
    1.43 +	}
    1.44 +	return QString ("Error Level: %1\n    Command: %2\nDescription: %3")
    1.45 +		.arg(l).arg(com).arg(errDescription);
    1.46  }
    1.47  
    1.48 -void API::setError(const QString &e)
    1.49 +QString API::errorDescription()
    1.50  {
    1.51 -	noErr=false;
    1.52 -	errorString=e;
    1.53 +	return errDescription;
    1.54 +}
    1.55 +
    1.56 +ErrorLevel API::errorLevel()
    1.57 +{
    1.58 +	return errLevel;
    1.59 +}
    1.60 +
    1.61 +void API::setError(ErrorLevel level, const QString &description)
    1.62 +{
    1.63 +	errDescription=description;
    1.64 +	errLevel=level;
    1.65 +}
    1.66 +
    1.67 +void API::resetError ()
    1.68 +{
    1.69 +	errMessage="";
    1.70 +	errDescription="";
    1.71 +	errLevel=NoError;
    1.72 +}
    1.73 +
    1.74 +
    1.75 +bool API::checkParamCount (QList <int> plist)
    1.76 +{
    1.77 +	QStringList expList;
    1.78 +	QString expected;
    1.79 +	for (int i=0; i<plist.count();i++)
    1.80 +	{
    1.81 +		if (checkParamCount (plist[i])) 
    1.82 +		{
    1.83 +			resetError();
    1.84 +			return true;
    1.85 +		}
    1.86 +		expList.append(QString().setNum(plist[i]));
    1.87 +	}	
    1.88 +	expected=expList.join(",");	
    1.89 +	errDescription=QString("Wrong number of parameters: Expected %1, but found %2").arg(expected).arg(paramList.count());
    1.90 +	return false;
    1.91  }
    1.92  
    1.93  bool API::checkParamCount (const int &expected)
    1.94  {
    1.95  	if (paramList.count()!=expected)
    1.96  	{
    1.97 -		errorString=QString("expected %1 parameters, but got %2").arg(expected).arg(paramList.count());
    1.98 -		noErr=false;
    1.99 -	} else 
   1.100 -		noErr=true;
   1.101 -	return noErr;	
   1.102 +		errLevel=Aborted;
   1.103 +		errDescription=QString("Wrong number of parameters: Expected %1, but found %2").arg(expected).arg(paramList.count());
   1.104 +		return false;
   1.105 +	} 
   1.106 +	return true;	
   1.107  }
   1.108  
   1.109  bool API::checkParamIsInt(const int &index)
   1.110 @@ -108,19 +152,20 @@
   1.111  	bool ok;
   1.112  	if (index > paramList.count())
   1.113  	{
   1.114 -		errorString =QString("Parameter index %1 is outside of parameter list").arg(index);
   1.115 -		noErr=false;
   1.116 +		errLevel=Aborted;
   1.117 +		errDescription=QString("Parameter index %1 is outside of parameter list").arg(index);
   1.118 +		return false;
   1.119  	} else
   1.120  	{
   1.121  		paramList[index].toInt (&ok, 10);
   1.122  		if (!ok)
   1.123  		{
   1.124 -			errorString=QString("Parameter %1 is not an integer").arg(index);
   1.125 -			noErr=false;
   1.126 -		} else
   1.127 -			noErr=true;
   1.128 +			errLevel=Aborted;
   1.129 +			errDescription=QString("Parameter %1 is not an integer").arg(index);
   1.130 +			return false;
   1.131 +		} 
   1.132  	}	
   1.133 -	return noErr;
   1.134 +	return true;
   1.135  }
   1.136  
   1.137  int API::parInt (bool &ok,const uint &index)
   1.138 @@ -145,3 +190,26 @@
   1.139  	ok=true;
   1.140  	return r;
   1.141  }
   1.142 +
   1.143 +bool API::parBool (bool &ok,const int &index)
   1.144 +{
   1.145 +	// return the bool at index, this could be also stored in
   1.146 +	// a variable later
   1.147 +	QString r;
   1.148 +	ok=true;
   1.149 +	/*
   1.150 +	QRegExp re("\"(.*)\"");
   1.151 +	int pos=re.search (paramList[index]);
   1.152 +	if (pos>=0)
   1.153 +		r=re.cap (1);
   1.154 +	else	
   1.155 +		r="";
   1.156 +	*/	
   1.157 +	if (paramList[index]=="true")
   1.158 +		return true;
   1.159 +	else if	(paramList[index]=="false")
   1.160 +		return false;
   1.161 +	ok=false;
   1.162 +	return ok;
   1.163 +}
   1.164 +
     2.1 --- a/api.h	Wed Oct 18 10:45:00 2006 +0000
     2.2 +++ b/api.h	Tue Oct 24 15:36:38 2006 +0000
     2.3 @@ -1,28 +1,37 @@
     2.4  #ifndef API_H
     2.5  #define API_H
     2.6  
     2.7 -#include <qstringlist.h>
     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 parseCommand (const QString&);
    2.18 +	void parseInput (const QString &input);
    2.19  	QString command();
    2.20  	QStringList parameters();
    2.21 -	QString errorDesc();
    2.22 -	bool error();
    2.23 -	void setError (const QString &);
    2.24 -	bool checkParamCount (const int &);
    2.25 -	bool checkParamIsInt (const int &);
    2.26 -	int parInt (bool &,const uint&);
    2.27 -	QString parString(bool &,const int &);
    2.28 +	int paramCount();
    2.29 +	QString errorMessage();
    2.30 +	QString errorDescription();
    2.31 +	ErrorLevel errorLevel();
    2.32 +	void setError (ErrorLevel level,const QString &description);
    2.33 +	void resetError();
    2.34 +	bool checkParamCount (QList <int> plist);
    2.35 +	bool checkParamCount (const int &index);
    2.36 +	bool checkParamIsInt (const int &index);
    2.37 +	int parInt (bool &,const uint &index);
    2.38 +	QString parString(bool &ok,const int &index);
    2.39 +	bool parBool (bool &ok, const int &index);
    2.40  private:
    2.41 +	QString input;
    2.42  	QString com;
    2.43  	QStringList paramList;
    2.44 -	QString errorString;
    2.45 -	bool noErr;
    2.46 +	QString errMessage;
    2.47 +	QString errDescription;
    2.48 +	ErrorLevel errLevel;
    2.49  };
    2.50  
    2.51  #endif
     3.1 --- a/branchobj.cpp	Wed Oct 18 10:45:00 2006 +0000
     3.2 +++ b/branchobj.cpp	Tue Oct 24 15:36:38 2006 +0000
     3.3 @@ -1242,7 +1242,6 @@
     3.4  	int th = bboxTotal.height();	
     3.5  // TODO testing
     3.6  /*
     3.7 -*/
     3.8  	cout << "BO::alignRelTo "<<getHeading().ascii()<<endl;
     3.9  	cout << "  d="<<depth<<
    3.10  		"  ref="<<ref<<
    3.11 @@ -1254,6 +1253,7 @@
    3.12  //		"  hidden="<<hidden<<
    3.13  //		"  th="<<th<<
    3.14  		endl;
    3.15 +*/
    3.16  
    3.17  	setOrientation();
    3.18  	//updateLink();
     4.1 Binary file demos/todo.vym has changed
     5.1 Binary file doc/vym_es.pdf has changed
     6.1 --- a/historywindow.cpp	Wed Oct 18 10:45:00 2006 +0000
     6.2 +++ b/historywindow.cpp	Tue Oct 24 15:36:38 2006 +0000
     6.3 @@ -103,6 +103,8 @@
     6.4  	item->setBackgroundColor (c);
     6.5  	ui.historyTable->setItem(undosAvail, 1, item);
     6.6  
     6.7 +	// Show "now" row
     6.8 +	ui.historyTable->scrollToItem (item);
     6.9  
    6.10  	// Update Redos in table
    6.11  	s=curStep;
     7.1 --- a/linkablemapobj.cpp	Wed Oct 18 10:45:00 2006 +0000
     7.2 +++ b/linkablemapobj.cpp	Tue Oct 24 15:36:38 2006 +0000
     7.3 @@ -535,8 +535,6 @@
     7.4  		p2y=QPoint( parObj->getParPos() ).y();
     7.5  	} 
     7.6  
     7.7 -
     7.8 -
     7.9  	setDockPos(); // Call overloaded method
    7.10  	setOrientation();
    7.11  
     8.1 --- a/main.cpp	Wed Oct 18 10:45:00 2006 +0000
     8.2 +++ b/main.cpp	Tue Oct 24 15:36:38 2006 +0000
     8.3 @@ -1,8 +1,8 @@
     8.4  #include <QApplication>
     8.5 -#include <QPixmap>
     8.6 -#include <QTranslator>
     8.7 -#include <QDir>
     8.8 -#include <QTextCodec>
     8.9 +//#include <QPixmap>
    8.10 +//#include <QTranslator>
    8.11 +//#include <QDir>
    8.12 +//#include <QTextCodec>
    8.13  #include <q3network.h>
    8.14  //#include <QActionGroup>
    8.15  
    8.16 @@ -35,9 +35,9 @@
    8.17  
    8.18  int statusbarTime=3500;
    8.19  
    8.20 -int main(int argc, char** argv)
    8.21 +int main(int argc, char* argv[])
    8.22  {
    8.23 -//FIXME	Q_INIT_RESOURCE (application);
    8.24 +	//Q_INIT_RESOURCE (application);
    8.25  
    8.26      QApplication app(argc,argv);
    8.27  
    8.28 @@ -84,7 +84,7 @@
    8.29  	// ok, let's find my way on my own
    8.30  	{
    8.31  		#if defined (Q_OS_MACX)
    8.32 -			vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents");
    8.33 +			vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources");
    8.34  
    8.35  		#else
    8.36  			vymBaseDir.setPath ("/usr/share/vym");
     9.1 --- a/mainwindow.cpp	Wed Oct 18 10:45:00 2006 +0000
     9.2 +++ b/mainwindow.cpp	Tue Oct 24 15:36:38 2006 +0000
     9.3 @@ -70,6 +70,9 @@
     9.4  	move   (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
     9.5  
     9.6  
     9.7 +	// Sometimes we may need to remember old selections
     9.8 +	prevSelection="";
     9.9 +
    9.10  	// Create unique temporary directory
    9.11  	bool ok;
    9.12  	tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
    9.13 @@ -480,16 +483,16 @@
    9.14  	a->setShortcut (Qt::ALT + Qt::Key_Insert );
    9.15  	a->setShortcutContext (Qt::WindowShortcut);
    9.16  	addAction (a);
    9.17 -    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
    9.18 +    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
    9.19  	a->setEnabled (false);
    9.20  	actionListBranches.append(a);
    9.21 -	actionEditAddBranchHere=a;
    9.22 +	actionEditAddBranchBefore=a;
    9.23  	a = new QAction(tr( "Add branch (insert)" ),this);
    9.24  	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
    9.25  	a->setShortcut ( Qt::ALT + Qt::Key_A );
    9.26  	a->setShortcutContext (Qt::WindowShortcut);
    9.27  	addAction (a);
    9.28 -    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
    9.29 +    connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
    9.30  	actionListBranches.append(a);
    9.31  
    9.32  	// Add branch above
    9.33 @@ -1437,7 +1440,7 @@
    9.34  		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
    9.35  		branchAddContextMenu->addAction (actionEditPaste );
    9.36  		branchAddContextMenu->addAction ( actionEditAddBranch );
    9.37 -		branchAddContextMenu->addAction ( actionEditAddBranchHere );
    9.38 +		branchAddContextMenu->addAction ( actionEditAddBranchBefore );
    9.39  		branchAddContextMenu->addAction ( actionEditAddBranchAbove);
    9.40  		branchAddContextMenu->addAction ( actionEditAddBranchBelow );
    9.41  		branchAddContextMenu->addSeparator();	
    9.42 @@ -2607,24 +2610,33 @@
    9.43  	    currentMapEditor()->editFATE2URL();
    9.44  }
    9.45  
    9.46 +void Main::editHeadingFinished()
    9.47 +{
    9.48 +	// only called from editHeading(), so there is a currentME
    9.49 +	MapEditor *me=currentMapEditor();
    9.50 +
    9.51 +#if defined(Q_OS_MACX)
    9.52 +#else
    9.53 +	me->setHeading(lineedit->text());
    9.54 +		
    9.55 +	lineedit->releaseKeyboard();
    9.56 +	lineedit->hide();
    9.57 +	setFocus();
    9.58 +#endif	
    9.59 +	if (!prevSelection.isEmpty()) me->select(prevSelection);
    9.60 +	prevSelection="";
    9.61 +}
    9.62 +
    9.63  void Main::editHeading()
    9.64  {
    9.65 -	if (lineedit->isVisible())
    9.66 +	if (currentMapEditor())
    9.67  	{
    9.68 -		if (currentMapEditor())
    9.69 -		{	
    9.70 -			MapEditor *me=currentMapEditor();
    9.71 -			QString oldSel=me->getSelectString();
    9.72 -			if (me->select (editSel))
    9.73 -				me->setHeading(lineedit->text());
    9.74 -			me->select (oldSel);
    9.75 -		}	
    9.76 -		lineedit->releaseKeyboard();
    9.77 -		lineedit->hide();
    9.78 -		setFocus();
    9.79 -	} else
    9.80 -	{
    9.81 -		if (currentMapEditor())
    9.82 +		MapEditor *me=currentMapEditor();
    9.83 +		QString oldSel=me->getSelectString();
    9.84 +
    9.85 +		if (lineedit->isVisible())
    9.86 +			editHeadingFinished();
    9.87 +		else
    9.88  		{
    9.89  			bool ok;
    9.90  			QPoint p;
    9.91 @@ -2637,30 +2649,30 @@
    9.92  				QDialog *d =new QDialog(NULL);
    9.93  				QLineEdit *le=new QLineEdit (d);
    9.94  				d->setWindowFlags (Qt::FramelessWindowHint);
    9.95 -				d->setGeometry(p.x(),p.y(),200,25);
    9.96 -				le->resize (d->size());
    9.97 +				d->setGeometry(p.x(),p.y(),230,25);
    9.98 +				le->resize (d->width()-10,d->height());
    9.99  				le->setText (s);
   9.100  				le->selectAll();
   9.101  				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
   9.102  				d->activateWindow();
   9.103  				d->exec();
   9.104  				currentMapEditor()->setHeading (le->text());
   9.105 +				delete (le);
   9.106 +				delete (d);
   9.107 +				editHeadingFinished();
   9.108  #else
   9.109  				p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
   9.110 -				lineedit->setGeometry(p.x(),p.y(),200,25);
   9.111 +				lineedit->setGeometry(p.x(),p.y(),230,25);
   9.112  				lineedit->setText(s);
   9.113  				lineedit->setCursorPosition(1);
   9.114  				lineedit->selectAll();
   9.115  				lineedit->show();
   9.116  				lineedit->grabKeyboard();
   9.117  				lineedit->setFocus();
   9.118 -
   9.119 -				editSel=currentMapEditor()->getSelectString();
   9.120  #endif
   9.121 -
   9.122  			}
   9.123  		}
   9.124 -	}
   9.125 +	} // currentMapEditor()	
   9.126  }
   9.127  
   9.128  void Main::openVymLinks(const QStringList &vl)
   9.129 @@ -2764,34 +2776,95 @@
   9.130  void Main::editUnScrollAll()
   9.131  {
   9.132  	if (currentMapEditor())
   9.133 +		currentMapEditor()->unScrollAll();	
   9.134 +}
   9.135 +
   9.136 +void Main::editNewBranch()
   9.137 +{
   9.138 +	MapEditor *me=currentMapEditor();
   9.139 +	if (!lineedit->isVisible() && me)
   9.140  	{
   9.141 -		currentMapEditor()->unScrollAll();	
   9.142 +		BranchObj *bo=(BranchObj*)me->getSelection();
   9.143 +		BranchObj *newbo=me->addNewBranch(0);
   9.144 +
   9.145 +		if (newbo) 
   9.146 +			me->select (newbo->getSelectString());
   9.147 +		else
   9.148 +			return;
   9.149 +
   9.150 +		if (actionSettingsAutoEdit->isOn())
   9.151 +		{
   9.152 +			if (!actionSettingsAutoSelectHeading->isOn())
   9.153 +				prevSelection=bo->getSelectString();
   9.154 +			editHeading();
   9.155 +		}
   9.156  	}	
   9.157  }
   9.158  
   9.159 -void Main::editNewBranch()
   9.160 +void Main::editNewBranchBefore()
   9.161  {
   9.162 -
   9.163 -	if (!lineedit->isVisible() && currentMapEditor())
   9.164 -		currentMapEditor()->addNewBranch(0);
   9.165 -}
   9.166 -
   9.167 -void Main::editNewBranchHere()
   9.168 -{
   9.169 -	if (currentMapEditor())
   9.170 -		currentMapEditor()->addNewBranchHere();
   9.171 +	MapEditor *me=currentMapEditor();
   9.172 +	if (!lineedit->isVisible() && me)
   9.173 +	{
   9.174 +		BranchObj *bo=(BranchObj*)me->getSelection();
   9.175 +		BranchObj *newbo=me->addNewBranchBefore();
   9.176 +
   9.177 +		if (newbo) 
   9.178 +			me->select (newbo->getSelectString());
   9.179 +		else
   9.180 +			return;
   9.181 +
   9.182 +		if (actionSettingsAutoEdit->isOn())
   9.183 +		{
   9.184 +			if (!actionSettingsAutoSelectHeading->isOn())
   9.185 +				prevSelection=bo->getSelectString();
   9.186 +			editHeading();
   9.187 +		}
   9.188 +	}	
   9.189  }
   9.190  
   9.191  void Main::editNewBranchAbove()
   9.192  {
   9.193 -	if (currentMapEditor())
   9.194 -		currentMapEditor()->addNewBranch(-1);
   9.195 +	MapEditor *me=currentMapEditor();
   9.196 +	if (!lineedit->isVisible() && me)
   9.197 +	{
   9.198 +		BranchObj *bo=(BranchObj*)me->getSelection();
   9.199 +		BranchObj *newbo=me->addNewBranch (-1);
   9.200 +
   9.201 +		if (newbo) 
   9.202 +			me->select (newbo->getSelectString());
   9.203 +		else
   9.204 +			return;
   9.205 +
   9.206 +		if (actionSettingsAutoEdit->isOn())
   9.207 +		{
   9.208 +			if (!actionSettingsAutoSelectHeading->isOn())
   9.209 +				prevSelection=bo->getSelectString();
   9.210 +			editHeading();
   9.211 +		}
   9.212 +	}	
   9.213  }
   9.214  
   9.215  void Main::editNewBranchBelow()
   9.216  {
   9.217 -	if (currentMapEditor())
   9.218 -		currentMapEditor()->addNewBranch(1);
   9.219 +	MapEditor *me=currentMapEditor();
   9.220 +	if (!lineedit->isVisible() && me)
   9.221 +	{
   9.222 +		BranchObj *bo=(BranchObj*)me->getSelection();
   9.223 +		BranchObj *newbo=me->addNewBranch (1);
   9.224 +
   9.225 +		if (newbo) 
   9.226 +			me->select (newbo->getSelectString());
   9.227 +		else
   9.228 +			return;
   9.229 +
   9.230 +		if (actionSettingsAutoEdit->isOn())
   9.231 +		{
   9.232 +			if (!actionSettingsAutoSelectHeading->isOn())
   9.233 +				prevSelection=bo->getSelectString();
   9.234 +			editHeading();
   9.235 +		}
   9.236 +	}	
   9.237  }
   9.238  
   9.239  void Main::editImportAdd()
    10.1 --- a/mainwindow.h	Wed Oct 18 10:45:00 2006 +0000
    10.2 +++ b/mainwindow.h	Tue Oct 24 15:36:38 2006 +0000
    10.3 @@ -96,6 +96,7 @@
    10.4  	void openVymLinks(const QStringList &);
    10.5  	void editVymLink();
    10.6  	void editOpenMultipleVymLinks();
    10.7 +    void editHeadingFinished();
    10.8  public slots:
    10.9      void editHeading();
   10.10  	void editOpenVymLink();
   10.11 @@ -108,7 +109,7 @@
   10.12      void editToggleScroll();
   10.13      void editUnScrollAll();
   10.14      void editNewBranch();
   10.15 -    void editNewBranchHere();
   10.16 +    void editNewBranchBefore();
   10.17      void editNewBranchAbove();
   10.18      void editNewBranchBelow();
   10.19      void editImportAdd();
   10.20 @@ -189,7 +190,7 @@
   10.21  	QStringList imageTypes;
   10.22  
   10.23  	QLineEdit *lineedit;	// to enter headings of branches
   10.24 -	QString editSel;
   10.25 +	QString prevSelection;
   10.26  
   10.27  	Q3PtrList <QAction> actionListBranches;
   10.28  
   10.29 @@ -219,7 +220,7 @@
   10.30  	QAction *actionEditHeading;
   10.31  	QAction *actionEditDelete;
   10.32  	QAction *actionEditAddBranch;
   10.33 -	QAction *actionEditAddBranchHere;
   10.34 +	QAction *actionEditAddBranchBefore;
   10.35  	QAction *actionEditAddBranchAbove;
   10.36  	QAction *actionEditAddBranchBelow;
   10.37  	QAction *actionEditRemoveBranchKeepChilds;
    11.1 --- a/mapeditor.cpp	Wed Oct 18 10:45:00 2006 +0000
    11.2 +++ b/mapeditor.cpp	Tue Oct 24 15:36:38 2006 +0000
    11.3 @@ -387,21 +387,33 @@
    11.4  
    11.5  void MapEditor::saveStateRemovingPart(LinkableMapObj *redoSel, const QString &comment)
    11.6  {
    11.7 -	if (!redoSel  ||typeid(*redoSel) != typeid(BranchObj) ) 
    11.8 +	if (!redoSel)
    11.9  	{
   11.10 -		qWarning ("MapEditor::saveStateRemovingPart  no undoSel given!");
   11.11 +		qWarning ("MapEditor::saveStateRemovingPart  no redoSel given!");
   11.12  		return;
   11.13  	}
   11.14 -
   11.15 -	// save the selected part of the map, Undo will insert part of map 
   11.16  	QString undoSelection=redoSel->getParObj()->getSelectString();
   11.17  	QString redoSelection=redoSel->getSelectString();
   11.18 -
   11.19 -	saveState (PartOfMap,
   11.20 -		undoSelection, QString("addMapInsert (\"PATH\",%1)").arg(((BranchObj*)redoSel)->getNum()),
   11.21 -		redoSelection, "delete ()", 
   11.22 -		comment, 
   11.23 -		redoSel);
   11.24 +	if (typeid(*redoSel) == typeid(BranchObj) && redoSel->getDepth()>1 ) 
   11.25 +	{
   11.26 +		// save the selected branch of the map, Undo will insert part of map 
   11.27 +		saveState (PartOfMap,
   11.28 +			undoSelection, QString("addMapInsert (\"PATH\",%1)").arg(((BranchObj*)redoSel)->getNum()),
   11.29 +			redoSelection, "delete ()", 
   11.30 +			comment, 
   11.31 +			redoSel);
   11.32 +	} else if (typeid(*redoSel) == typeid(BranchObj) )
   11.33 +	{
   11.34 +		// save the selected mainbranch of the map, Undo will insert part of map 
   11.35 +		saveState (PartOfMap,
   11.36 +			undoSelection, QString("addMapInsert (\"PATH\",%1)").arg(((BranchObj*)redoSel)->getNum()),
   11.37 +//			undoSelection, QString("addMapInsert (\"PATH\",%1,%2)").arg(((BranchObj*)redoSel)->getNum())
   11.38 +//				.arg(((BranchObj*)redoSel)->x()).arg(((BranchObj*)redoSel)->y()),
   11.39 +			redoSelection, "delete ()", 
   11.40 +			comment, 
   11.41 +			redoSel);
   11.42 +		
   11.43 +	}
   11.44  }
   11.45  
   11.46  void MapEditor::saveStateConstSelection(const QString &uc, const QString &rc, const QString &comment)
   11.47 @@ -545,81 +557,185 @@
   11.48  	bool ok;
   11.49  
   11.50  	// Split string s into command and parameters
   11.51 -	api.parseCommand (atom);
   11.52 +	api.parseInput (atom);
   11.53  	QString com=api.command();
   11.54  	
   11.55  	// External commands
   11.56  	if (com=="addBranch")
   11.57  	{
   11.58 -		if (api.checkParamCount(1) && selection )
   11.59 +		if (!selection)
   11.60 +		{
   11.61 +			api.setError (Aborted,"Nothing selected");
   11.62 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
   11.63 +					 typeid(*selection) != typeid(MapCenterObj)) )
   11.64 +		{				  
   11.65 +			api.setError (Aborted,"Type of selection is not a branch");
   11.66 +		} else 
   11.67  		{	
   11.68 -			y=api.parInt (ok,0);
   11.69 -			if (ok ) addNewBranchInt (y);
   11.70 -		}	
   11.71 +			QList <int> pl;
   11.72 +			pl << 0 <<1;
   11.73 +			if (api.checkParamCount(pl))
   11.74 +			{
   11.75 +				if (api.paramCount()==0)
   11.76 +					addNewBranchInt (-2);
   11.77 +				else
   11.78 +				{
   11.79 +					y=api.parInt (ok,0);
   11.80 +					if (ok ) addNewBranchInt (y);
   11.81 +				}
   11.82 +			}
   11.83 +		}
   11.84 +	} else if (com=="addBranchBefore")
   11.85 +	{
   11.86 +		if (!selection)
   11.87 +		{
   11.88 +			api.setError (Aborted,"Nothing selected");
   11.89 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
   11.90 +					 typeid(*selection) != typeid(MapCenterObj)) )
   11.91 +		{				  
   11.92 +			api.setError (Aborted,"Type of selection is not a branch");
   11.93 +		} else 
   11.94 +		{	
   11.95 +			if (api.paramCount()==0)
   11.96 +			{
   11.97 +				addNewBranchBefore ();
   11.98 +			}	
   11.99 +		}
  11.100  	} else if (com==QString("addMapReplace"))
  11.101  	{
  11.102 -		if (api.checkParamCount(2))
  11.103 +		if (!selection)
  11.104 +		{
  11.105 +			api.setError (Aborted,"Nothing selected");
  11.106 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.107 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.108 +		{				  
  11.109 +			api.setError (Aborted,"Type of selection is not a branch");
  11.110 +		} else if (api.checkParamCount(2))
  11.111  		{
  11.112  			s=api.parString (ok,0);	// selection
  11.113  			t=api.parString (ok,1);	// path to map
  11.114  			if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
  11.115 -			addMapReplace(s,t);	
  11.116 +			addMapReplaceInt(s,t);	
  11.117  		}
  11.118  	} else if (com==QString("addMapInsert"))
  11.119  	{
  11.120 -		if (api.checkParamCount(2))
  11.121 +		if (!selection)
  11.122  		{
  11.123 -			t=api.parString (ok,0);	// path to map
  11.124 -			y=api.parInt(ok,1);		// position
  11.125 -			if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
  11.126 -			addMapInsert(t,y);	
  11.127 +			api.setError (Aborted,"Nothing selected");
  11.128 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.129 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.130 +		{				  
  11.131 +			api.setError (Aborted,"Type of selection is not a branch");
  11.132 +		} else 
  11.133 +		{	
  11.134 +			if (api.checkParamCount(2))
  11.135 +			{
  11.136 +				t=api.parString (ok,0);	// path to map
  11.137 +				y=api.parInt(ok,1);		// position
  11.138 +				if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
  11.139 +				addMapInsertInt(t,y);	
  11.140 +			}
  11.141  		}
  11.142  	} else if (com=="delete")
  11.143  	{
  11.144 -		if (api.checkParamCount(0) && selection )
  11.145 +		if (!selection)
  11.146 +		{
  11.147 +			api.setError (Aborted,"Nothing selected");
  11.148 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.149 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.150 +		{				  
  11.151 +			api.setError (Aborted,"Type of selection is not a branch");
  11.152 +		} else if (api.checkParamCount(0))
  11.153  		{	
  11.154  			deleteSelection();
  11.155  		}	
  11.156 +	} else if (com=="deleteKeepChilds")
  11.157 +	{
  11.158 +		if (!selection)
  11.159 +		{
  11.160 +			api.setError (Aborted,"Nothing selected");
  11.161 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.162 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.163 +		{				  
  11.164 +			api.setError (Aborted,"Type of selection is not a branch");
  11.165 +		} else if (api.checkParamCount(0))
  11.166 +		{	
  11.167 +			removeBranchKeepChilds();
  11.168 +		}	
  11.169  	} else if (com=="linkBranchToPos")
  11.170  	{
  11.171 -		if (selection && typeid(*selection) == typeid(BranchObj) ) 
  11.172 +		if (!selection)
  11.173  		{
  11.174 -			if (api.checkParamCount(4))
  11.175 -			{
  11.176 -				// 0	selectstring of parent
  11.177 -				// 1	num in parent (for branches)
  11.178 -				// 2,3	x,y of mainbranch or mapcenter
  11.179 -				s=api.parString(ok,0);
  11.180 -				LinkableMapObj *dst=mapCenter->findObjBySelect (s);
  11.181 -				if (dst)
  11.182 -				{	
  11.183 -					if (typeid(*dst) == typeid(BranchObj) ) 
  11.184 +			api.setError (Aborted,"Nothing selected");
  11.185 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.186 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.187 +		{				  
  11.188 +			api.setError (Aborted,"Type of selection is not a branch");
  11.189 +		} else if (api.checkParamCount(4))
  11.190 +		{
  11.191 +			// 0	selectstring of parent
  11.192 +			// 1	num in parent (for branches)
  11.193 +			// 2,3	x,y of mainbranch or mapcenter
  11.194 +			s=api.parString(ok,0);
  11.195 +			LinkableMapObj *dst=mapCenter->findObjBySelect (s);
  11.196 +			if (dst)
  11.197 +			{	
  11.198 +				if (typeid(*dst) == typeid(BranchObj) ) 
  11.199 +				{
  11.200 +					// Get number in parent
  11.201 +					x=api.parInt (ok,1);
  11.202 +					if (ok)
  11.203 +						((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),x);
  11.204 +				} else if (typeid(*dst) == typeid(MapCenterObj) ) 
  11.205 +				{
  11.206 +					((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),-1);
  11.207 +					// Get coordinates of mainbranch
  11.208 +					x=api.parInt (ok,2);
  11.209 +					if (ok)
  11.210  					{
  11.211 -						// Get number in parent
  11.212 -						x=api.parInt (ok,1);
  11.213 -						if (ok)
  11.214 -							((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),x);
  11.215 -					} else if (typeid(*dst) == typeid(MapCenterObj) ) 
  11.216 -					{
  11.217 -						((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),-1);
  11.218 -						// Get coordinates of mainbranch
  11.219 -						x=api.parInt (ok,2);
  11.220 -						if (ok)
  11.221 -						{
  11.222 -							y=api.parInt (ok,3);
  11.223 -							if (ok) ((BranchObj*)selection)->move (x,y);
  11.224 -						}
  11.225 -					}	
  11.226 +						y=api.parInt (ok,3);
  11.227 +						if (ok) ((BranchObj*)selection)->move (x,y);
  11.228 +					}
  11.229  				}	
  11.230 -			}
  11.231 +			}	
  11.232  		}
  11.233  	} else if (com=="moveBranchUp")
  11.234 -		moveBranchUp();
  11.235 -	else if (com=="moveBranchDown")
  11.236 -		moveBranchDown();
  11.237 -	else if (com=="move")
  11.238  	{
  11.239 -		if (api.checkParamCount(2) && selection )
  11.240 +		if (!selection)
  11.241 +		{
  11.242 +			api.setError (Aborted,"Nothing selected");
  11.243 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.244 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.245 +		{				  
  11.246 +			api.setError (Aborted,"Type of selection is not a branch");
  11.247 +		} else if (api.checkParamCount(0))
  11.248 +		{
  11.249 +			moveBranchUp();
  11.250 +		}	
  11.251 +	} else if (com=="moveBranchDown")
  11.252 +	{
  11.253 +		if (!selection)
  11.254 +		{
  11.255 +			api.setError (Aborted,"Nothing selected");
  11.256 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.257 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.258 +		{				  
  11.259 +			api.setError (Aborted,"Type of selection is not a branch");
  11.260 +		} else if (api.checkParamCount(0))
  11.261 +		{
  11.262 +			moveBranchDown();
  11.263 +		}	
  11.264 +	} else if (com=="move")
  11.265 +	{
  11.266 +		if (!selection)
  11.267 +		{
  11.268 +			api.setError (Aborted,"Nothing selected");
  11.269 +		} else if ( typeid(*selection) != typeid(BranchObj) && 
  11.270 +					typeid(*selection) != typeid(MapCenterObj) &&
  11.271 +					typeid(*selection) != typeid(FloatImageObj) )
  11.272 +		{				  
  11.273 +			api.setError (Aborted,"Type of selection is not a branch or floatimage");
  11.274 +		} else if (api.checkParamCount(2))
  11.275  		{	
  11.276  			x=api.parInt (ok,0);
  11.277  			if (ok)
  11.278 @@ -631,7 +747,15 @@
  11.279  	}
  11.280  	else if (com=="moveRel")
  11.281  	{
  11.282 -		if (api.checkParamCount(2) && selection )
  11.283 +		if (!selection)
  11.284 +		{
  11.285 +			api.setError (Aborted,"Nothing selected");
  11.286 +		} else if ( typeid(*selection) != typeid(BranchObj) && 
  11.287 +					typeid(*selection) != typeid(MapCenterObj) &&
  11.288 +					typeid(*selection) != typeid(FloatImageObj) )
  11.289 +		{				  
  11.290 +			api.setError (Aborted,"Type of selection is not a branch or floatimage");
  11.291 +		} else if (api.checkParamCount(2))
  11.292  		{	
  11.293  			x=api.parInt (ok,0);
  11.294  			if (ok)
  11.295 @@ -642,7 +766,14 @@
  11.296  		}	
  11.297  	} else if (com=="setHeading")
  11.298  	{
  11.299 -		if (api.checkParamCount(1))
  11.300 +		if (!selection)
  11.301 +		{
  11.302 +			api.setError (Aborted,"Nothing selected");
  11.303 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.304 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.305 +		{				  
  11.306 +			api.setError (Aborted,"Type of selection is not a branch");
  11.307 +		} else if (api.checkParamCount(1))
  11.308  		{
  11.309  			s=api.parString (ok,0);
  11.310  			if (ok) 
  11.311 @@ -650,55 +781,98 @@
  11.312  		}	
  11.313  	} else if (com=="setURL")
  11.314  	{
  11.315 -		if (api.checkParamCount(1))
  11.316 +		if (!selection)
  11.317 +		{
  11.318 +			api.setError (Aborted,"Nothing selected");
  11.319 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.320 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.321 +		{				  
  11.322 +			api.setError (Aborted,"Type of selection is not a branch");
  11.323 +		} else if (api.checkParamCount(1))
  11.324  		{
  11.325  			s=api.parString (ok,0);
  11.326  			if (ok) setURLInt(s);
  11.327  		}	
  11.328  	} else if (com=="setVymLink")
  11.329  	{
  11.330 -		if (api.checkParamCount(1))
  11.331 +		if (!selection)
  11.332 +		{
  11.333 +			api.setError (Aborted,"Nothing selected");
  11.334 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.335 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.336 +		{				  
  11.337 +			api.setError (Aborted,"Type of selection is not a branch");
  11.338 +		} else if (api.checkParamCount(1))
  11.339  		{
  11.340  			s=api.parString (ok,0);
  11.341  			if (ok) setVymLinkInt(s);
  11.342  		}	
  11.343  	}
  11.344 +	else if (com=="setHideExport")
  11.345 +	{
  11.346 +		if (!selection)
  11.347 +		{
  11.348 +			api.setError (Aborted,"Nothing selected");
  11.349 +		} else if ( typeid(*selection) != typeid(BranchObj) && 
  11.350 +					typeid(*selection) != typeid(MapCenterObj) &&
  11.351 +					typeid(*selection) != typeid(FloatImageObj) )
  11.352 +		{				  
  11.353 +			api.setError (Aborted,"Type of selection is not a branch or floatimage");
  11.354 +		} else if (api.checkParamCount(2))
  11.355 +		{
  11.356 +			s=api.parString(ok,0);
  11.357 +			if (ok) 
  11.358 +			{
  11.359 +				BranchObj* bo=(BranchObj*)selection;
  11.360 +				bo->activateStandardFlag(s);
  11.361 +				bo->updateFlagsToolbar();
  11.362 +			}	
  11.363 +		}
  11.364 +	}	
  11.365  	else if (com=="setFlag")
  11.366  	{
  11.367 -		if (selection && typeid(*selection) == typeid(BranchObj) ) 
  11.368 +		if (!selection)
  11.369  		{
  11.370 -			if (api.checkParamCount(1) )
  11.371 -			{	
  11.372 -				s=api.parString(ok,0);
  11.373 -				if (ok) 
  11.374 -				{
  11.375 -					BranchObj* bo=(BranchObj*)selection;
  11.376 -					bo->activateStandardFlag(s);
  11.377 -					bo->updateFlagsToolbar();
  11.378 -				}	
  11.379 +			api.setError (Aborted,"Nothing selected");
  11.380 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.381 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.382 +		{				  
  11.383 +			api.setError (Aborted,"Type of selection is not a branch");
  11.384 +		} else if (api.checkParamCount(1))
  11.385 +		{
  11.386 +			s=api.parString(ok,0);
  11.387 +			if (ok) 
  11.388 +			{
  11.389 +				BranchObj* bo=(BranchObj*)selection;
  11.390 +				bo->activateStandardFlag(s);
  11.391 +				bo->updateFlagsToolbar();
  11.392  			}	
  11.393  		}
  11.394  	}	
  11.395  	else if (com=="unsetFlag")
  11.396  	{
  11.397 -		if (selection && typeid(*selection) == typeid(BranchObj) ) 
  11.398 +		if (!selection)
  11.399  		{
  11.400 -			if (api.checkParamCount(1) )
  11.401 -			{	
  11.402 -				s=api.parString(ok,0);
  11.403 -				if (ok) 
  11.404 -				{
  11.405 -					BranchObj* bo=(BranchObj*)selection;
  11.406 -					bo->deactivateStandardFlag(s);
  11.407 -					bo->updateFlagsToolbar();
  11.408 -				}	
  11.409 +			api.setError (Aborted,"Nothing selected");
  11.410 +		} else if ( (typeid(*selection) != typeid(BranchObj) && 
  11.411 +					 typeid(*selection) != typeid(MapCenterObj)) )
  11.412 +		{				  
  11.413 +			api.setError (Aborted,"Type of selection is not a branch");
  11.414 +		} else if (api.checkParamCount(1))
  11.415 +		{
  11.416 +			s=api.parString(ok,0);
  11.417 +			if (ok) 
  11.418 +			{
  11.419 +				BranchObj* bo=(BranchObj*)selection;
  11.420 +				bo->deactivateStandardFlag(s);
  11.421 +				bo->updateFlagsToolbar();
  11.422  			}	
  11.423  		}
  11.424  	// Internal commands
  11.425  	} else if (com==QString("undoMap"))
  11.426  	{
  11.427  		if (api.checkParamCount(1))
  11.428 -			addMapReplace("",api.parString (ok,0));
  11.429 +			addMapReplaceInt("",api.parString (ok,0));
  11.430  	} else if (com=="select")
  11.431  	{
  11.432  		if (api.checkParamCount(1))
  11.433 @@ -709,16 +883,18 @@
  11.434  	}	
  11.435  	else
  11.436  	{
  11.437 -		api.setError ("Unknown command in: "+atom);
  11.438 +		api.setError (Aborted,"Unknown command");
  11.439  	}
  11.440  
  11.441  	// Any errors?
  11.442 -	if (api.error())
  11.443 +	if (api.errorLevel()==NoError)
  11.444 +		setChanged();
  11.445 +	else	
  11.446  	{
  11.447  		// TODO Error handling
  11.448  		qWarning("MapEditor::parseAtom: Error!");
  11.449 -		qWarning(api.errorDesc());
  11.450 -	}	
  11.451 +		qWarning(api.errorMessage());
  11.452 +	} 
  11.453  }
  11.454  
  11.455  void MapEditor::toggleHistoryWindow()
  11.456 @@ -1388,7 +1564,7 @@
  11.457  	// And ignore clicking the current row ;-)	
  11.458  }
  11.459  
  11.460 -void MapEditor::addMapReplace(const QString &undoSel, const QString &path)
  11.461 +void MapEditor::addMapReplaceInt(const QString &undoSel, const QString &path)
  11.462  {
  11.463  	QString pathDir=path.left(path.findRev("/"));
  11.464  	QDir d(pathDir);
  11.465 @@ -1427,7 +1603,7 @@
  11.466  		QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
  11.467  }
  11.468  
  11.469 -void MapEditor::addMapInsert(const QString &path, int pos)
  11.470 +void MapEditor::addMapInsertInt (const QString &path, int pos)
  11.471  {
  11.472  	if (selection && (typeid(*selection) == typeid(BranchObj) ||
  11.473  				      typeid(*selection) == typeid(MapCenterObj))) 
  11.474 @@ -1436,20 +1612,6 @@
  11.475  		QDir d(pathDir);
  11.476  		QFile file (path);
  11.477  
  11.478 -		BranchObj *bo=addNewBranchInt (pos);
  11.479 -		if (!bo)
  11.480 -		{
  11.481 -			
  11.482 -			QMessageBox::critical( 0, tr( "Critical Error" ), 
  11.483 -				tr("Could insert branch at position %1\n in branch %2").arg(pos)
  11.484 -				.arg(((BranchObj*)selection)->getHeading()));
  11.485 -			return;	
  11.486 -		}
  11.487 -		unselect();
  11.488 -		selection=bo;
  11.489 -		selection->select();
  11.490 -
  11.491 -		
  11.492  		if (d.exists() )
  11.493  		{
  11.494  			// We need to parse saved XML data
  11.495 @@ -1460,7 +1622,7 @@
  11.496  			reader.setErrorHandler( &handler );
  11.497  			handler.setMapEditor( this );
  11.498  			handler.setTmpDir ( pathDir );	// needed to load files with rel. path
  11.499 -			handler.setLoadMode (ImportReplace);
  11.500 +			handler.setLoadMode (ImportAdd);
  11.501  			blockReposition=true;
  11.502  			bool ok = reader.parse( source );
  11.503  			blockReposition=false;
  11.504 @@ -1470,6 +1632,8 @@
  11.505  				QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path),
  11.506  										handler.errorProtocol());
  11.507  			}
  11.508 +			if (selection!=mapCenter)
  11.509 +				((BranchObj*)selection)->getLastBranch()->moveBranchTo ((BranchObj*)(selection),pos);
  11.510  		} else	
  11.511  			QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
  11.512  	}		
  11.513 @@ -1689,18 +1853,19 @@
  11.514  	return newbo;
  11.515  }	
  11.516  
  11.517 -void MapEditor::addNewBranch(int pos)
  11.518 +BranchObj* MapEditor::addNewBranch(int pos)
  11.519  {
  11.520  	// Different meaning than num in addNewBranchInt!
  11.521  	// -1	add above
  11.522  	//  0	add as child
  11.523  	// +1	add below
  11.524 +	BranchObj *bo = (BranchObj*) selection;
  11.525 +	BranchObj *newbo=NULL;
  11.526 +
  11.527  	if (selection  &&  
  11.528  		 (typeid(*selection) == typeid(BranchObj) || 
  11.529  		  typeid(*selection) == typeid(MapCenterObj) ) ) 
  11.530  	{
  11.531 -		BranchObj *bo = (BranchObj*) selection;
  11.532 -		BranchObj *newbo;
  11.533  		newbo=addNewBranchInt (pos-2);
  11.534  
  11.535  		if (newbo)
  11.536 @@ -1711,72 +1876,44 @@
  11.537  				QString ("addBranch (%1)").arg(pos-2),
  11.538  				QString ("Add new branch to %1").arg(getName(bo)));	//TODO undoCommand
  11.539  
  11.540 -			LinkableMapObj *oldselection=selection;
  11.541 -
  11.542  			mapCenter->reposition();
  11.543  			adjustCanvasSize();
  11.544 -
  11.545 -
  11.546 -			if (mainWindow->autoEdit() ||
  11.547 -				mainWindow->autoSelectHeading() )
  11.548 -			{
  11.549 -				selection->unselect();
  11.550 -				selection=newbo;
  11.551 -				selection->select();
  11.552 -				if (mainWindow->autoEdit() )
  11.553 -					mainWindow->editHeading();
  11.554 -				if (!mainWindow->autoSelectHeading()
  11.555 -					)//&& !wasScrolled)  //FIXME wasScrolled was moved to addNewBranchInt
  11.556 -				{
  11.557 -					selection->unselect();
  11.558 -					selection=oldselection;
  11.559 -					selection->select();
  11.560 -				}
  11.561 -			}	
  11.562  		}
  11.563  	}	
  11.564 +	return newbo;
  11.565  }
  11.566  
  11.567  
  11.568 -void MapEditor::addNewBranchHere()
  11.569 +BranchObj* MapEditor::addNewBranchBefore()
  11.570  {
  11.571 +	BranchObj *newbo=NULL;
  11.572  	if (selection  &&  
  11.573  		 (typeid(*selection) == typeid(BranchObj) ) )
  11.574 +		 // We accept no MapCenterObj here, so we _have_ a parent
  11.575  	{
  11.576 -		BranchObj* bo1 = (BranchObj*) selection;
  11.577 -		saveStateChangingPart(selection, QString("Add new branch here").arg(getName(bo1)));
  11.578 -
  11.579 -		bool wasScrolled=false;
  11.580 -		BranchObj *newbo=NULL;
  11.581 +		BranchObj* bo = (BranchObj*) selection;
  11.582 +		QPoint p=bo->getRelPos();
  11.583 +
  11.584 +
  11.585  		BranchObj *parbo=(BranchObj*)(selection->getParObj());
  11.586 -		if (parbo)
  11.587 +
  11.588 +		// add below selection
  11.589 +		newbo=parbo->insertBranch(bo->getNum()+1);
  11.590 +		if (newbo)
  11.591  		{
  11.592 -			// add below selection
  11.593 -			newbo=parbo->insertBranch(bo1->getNum()+1);
  11.594 -		} 
  11.595 -
  11.596 -		LinkableMapObj *oldselection=selection;
  11.597 -		((BranchObj*)selection)->moveBranchTo (newbo,-1);
  11.598 -
  11.599 -		mapCenter->reposition();
  11.600 -		adjustCanvasSize();
  11.601 -		if (mainWindow->autoEdit() ||
  11.602 -			mainWindow->autoSelectHeading() )
  11.603 -		{
  11.604 -			selection->unselect();
  11.605 -			selection=newbo;
  11.606 -			selection->select();
  11.607 -			if (mainWindow->autoEdit() )
  11.608 -				mainWindow->editHeading();
  11.609 -			if (!mainWindow->autoSelectHeading()
  11.610 -				&& !wasScrolled)
  11.611 -			{
  11.612 -				selection->unselect();
  11.613 -				selection=oldselection;
  11.614 -				selection->select();
  11.615 -			}
  11.616 -		}	
  11.617 +			newbo->move2RelPos (p);
  11.618 +
  11.619 +			// Move selection to new branch
  11.620 +			((BranchObj*)selection)->moveBranchTo (newbo,-1);
  11.621 +
  11.622 +			saveState (newbo, "deleteKeepChilds ()", newbo, "addBranchBefore ()", 
  11.623 +				QString ("Add branch before %1").arg(getName(bo)));
  11.624 +
  11.625 +			mapCenter->reposition();
  11.626 +			adjustCanvasSize();
  11.627 +		}
  11.628  	}	
  11.629 +	return newbo;
  11.630  }
  11.631  
  11.632  void MapEditor::deleteSelection()
  11.633 @@ -1786,13 +1923,7 @@
  11.634  		BranchObj* bo=(BranchObj*)selection;
  11.635  		BranchObj* par=(BranchObj*)(bo->getParObj());
  11.636  		bo->unselect();
  11.637 -		if (selection->getDepth()>1)
  11.638 -			// Normal branch, save parent with childs
  11.639 -			saveStateRemovingPart (bo, QString ("Delete %1").arg(getName(bo)));
  11.640 -		else
  11.641 -			// Mainbranch, save whole map
  11.642 -			// TODO Better would be to insert mainbranch again at pos But undoCommand is missing right now
  11.643 -			saveStateComplete(QString("Delete %1").arg(getName(bo)));
  11.644 +		saveStateRemovingPart (bo, QString ("Delete %1").arg(getName(bo)));
  11.645  		selection=NULL;
  11.646  		par->removeBranch(bo);
  11.647  		selection=par;
  11.648 @@ -2584,16 +2715,21 @@
  11.649  	{		
  11.650  		BranchObj* bo=(BranchObj*)selection;
  11.651  		BranchObj* par=(BranchObj*)(bo->getParObj());
  11.652 +		QPoint p=bo->getRelPos();
  11.653  		QString s=QString("Remove %1 and keep its childs").arg(getName(bo));
  11.654  		if (bo->getDepth()==1)
  11.655  			saveStateComplete(s);
  11.656  		else	
  11.657  			saveStateChangingPart(selection->getParObj(),s);	// TODO undoCommand
  11.658 +
  11.659  		QString sel=selection->getSelectString();
  11.660  		unselect();
  11.661  		par->removeBranchHere(bo);
  11.662  		mapCenter->reposition();
  11.663  		select (sel);
  11.664 +		((BranchObj*)selection)->move2RelPos (p);
  11.665 +		mapCenter->reposition();
  11.666 +		adjustCanvasSize();
  11.667  	}	
  11.668  }
  11.669  
  11.670 @@ -2601,6 +2737,7 @@
  11.671  {
  11.672  	if (selection && (typeid(*selection) == typeid(BranchObj) ))
  11.673  	{		
  11.674 +		// TODO undoCommand
  11.675  		saveStateChangingPart(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection)));
  11.676  		((BranchObj*)selection)->removeChilds();
  11.677  		mapCenter->reposition();
  11.678 @@ -3048,6 +3185,15 @@
  11.679  {
  11.680  	cout << "MapEditor::testFunction() called\n";
  11.681  
  11.682 +	if (selection && 
  11.683 +		(typeid(*selection) == typeid(BranchObj)) || 
  11.684 +		(typeid(*selection) == typeid(MapCenterObj))  )
  11.685 +	{
  11.686 +		BranchObj* bo=(BranchObj*)selection;
  11.687 +		cout << bo->getHeading().ascii() <<" is scrolled: "<<bo->isScrolled()<<endl;
  11.688 +	}
  11.689 +	return;
  11.690 +	
  11.691  	WarningDialog dia;
  11.692  	dia.showCancelButton (true);
  11.693  	dia.setText("This is a longer \nWarning");
    12.1 --- a/mapeditor.h	Wed Oct 18 10:45:00 2006 +0000
    12.2 +++ b/mapeditor.h	Tue Oct 24 15:36:38 2006 +0000
    12.3 @@ -84,9 +84,9 @@
    12.4      void undo();		// undo last action
    12.5  	bool isUndoAvailable();
    12.6  	void gotoStep (int);// goto a step in history
    12.7 -    void addMapReplace(const QString & undoSel, const QString & path);
    12.8 -    void addMapInsert (const QString & path, int pos);
    12.9  private:	
   12.10 +    void addMapReplaceInt(const QString & undoSel, const QString & path);
   12.11 +    void addMapInsertInt (const QString & path, int pos);
   12.12      void pasteNoSave();		// paste clipboard to branch
   12.13      void cutNoSave();	// cut to clipboard
   12.14  public:	
   12.15 @@ -104,8 +104,8 @@
   12.16  	void setVymLinkInt(const QString &);	// Set vymLink for selection
   12.17      BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
   12.18  public:	
   12.19 -    void addNewBranch(int);			// pos allows to add above/below selection
   12.20 -    void addNewBranchHere();		// insert and make selection its
   12.21 +    BranchObj* addNewBranch(int);			// pos allows to add above/below selection
   12.22 +    BranchObj* addNewBranchBefore();		// insert and make selection its
   12.23      void deleteSelection();
   12.24  	LinkableMapObj* getSelection();	// returns selection
   12.25  	void unselect();				// before changing current noteedit
    13.1 --- a/tex/vym.changelog	Wed Oct 18 10:45:00 2006 +0000
    13.2 +++ b/tex/vym.changelog	Tue Oct 24 15:36:38 2006 +0000
    13.3 @@ -1,3 +1,9 @@
    13.4 +-------------------------------------------------------------------
    13.5 +Tue Oct 24 17:24:22 CEST 2006 - uwedr
    13.6 +
    13.7 +- Version: 1.8.58
    13.8 +- Feature: More undo commands (and fixes there)
    13.9 +
   13.10  -------------------------------------------------------------------
   13.11  Mon Oct 16 14:41:03 CEST 2006 - uwedr
   13.12  
    14.1 --- a/version.h	Wed Oct 18 10:45:00 2006 +0000
    14.2 +++ b/version.h	Tue Oct 24 15:36:38 2006 +0000
    14.3 @@ -2,7 +2,7 @@
    14.4  #define VERSION_H
    14.5  
    14.6  #define __VYM "VYM"
    14.7 -#define __VYM_VERSION "1.8.57"
    14.8 -#define __BUILD_DATE "October 16, 2006"
    14.9 +#define __VYM_VERSION "1.8.58"
   14.10 +#define __BUILD_DATE "October 24, 2006"
   14.11  
   14.12  #endif
    15.1 --- a/xml.cpp	Wed Oct 18 10:45:00 2006 +0000
    15.2 +++ b/xml.cpp	Tue Oct 24 15:36:38 2006 +0000
    15.3 @@ -463,7 +463,7 @@
    15.4  	{
    15.5  		bool okx,oky;
    15.6  		int x,y;
    15.7 -		if (!a.value( "relPosX").isEmpty() && loadMode==NewMap && branchDepth<2) 
    15.8 +		if (!a.value( "relPosX").isEmpty() ) 
    15.9  		{
   15.10  			if (!a.value( "relPosY").isEmpty() ) 
   15.11  			{