# HG changeset patch
# User insilmaril
# Date 1258101123 0
# Node ID 14f2b1b15242092db9ef3fc7e2eeac8edce0e478
# Parent  338ebdc9b94706301c9835b318f8b590c6bde9bb
Several fixes, see tex/vym.changelog for details

diff -r 338ebdc9b947 -r 14f2b1b15242 adaptormodel.cpp
--- a/adaptormodel.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/adaptormodel.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -55,3 +55,8 @@
 }
 
 
+void AdaptorModel::setHeading (const QString &s)
+{
+	model->setHeading(s);
+}
+
diff -r 338ebdc9b947 -r 14f2b1b15242 adaptormodel.h
--- a/adaptormodel.h	Fri Oct 02 14:31:03 2009 +0000
+++ b/adaptormodel.h	Fri Nov 13 08:32:03 2009 +0000
@@ -11,7 +11,9 @@
 {
     Q_OBJECT
     Q_CLASSINFO("D-Bus Interface", "org.insilmaril.Adaptor")
-	Q_PROPERTY(QString caption READ caption WRITE setCaption)
+//    Q_CLASSINFO("D-Bus Interface", "org.insilmaril.Adaptor.test")
+//	Q_PROPERTY(QString caption READ caption WRITE setCaption)
+//	Q_PROPERTY(QString heading READ getHeading WRITE setHeading)
 private:
 	VymModel *model;
 
@@ -27,6 +29,7 @@
 public slots: // METHODS
    QDBusVariant query(const QString &query);
    QDBusVariant getHeading();
+   void setHeading (const QString &s);
 
 Q_SIGNALS: // SIGNALS
     void crashed();
diff -r 338ebdc9b947 -r 14f2b1b15242 branchitem.cpp
--- a/branchitem.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/branchitem.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -368,7 +368,10 @@
 
 BranchItem* BranchItem::getLastSelectedBranch()
 {
-	return getBranchNum (lastSelectedBranchNum);
+	if (lastSelectedBranchNum>=branchCounter)
+		return getBranchNum (branchCounter-1);
+	else	
+		return getBranchNum (lastSelectedBranchNum);
 }
 
 BranchItem* BranchItem::getLastSelectedBranchAlt()
diff -r 338ebdc9b947 -r 14f2b1b15242 branchobj.cpp
--- a/branchobj.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/branchobj.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -115,7 +115,7 @@
 		return false;
 }
 
-void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off)	//FIXME-1 after moving a mainbranch to a branch and away again mainbranch is no longer connected to mapcenter...
+void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off)	//FIXME-1 when moving a mainbranch to a branch it still has relPos, not moved as child
 {
 	// Temporary link to dst
 	// m is position of mouse pointer 
@@ -125,7 +125,7 @@
 
 	BranchItem *pi=(BranchItem*)(dsti->parent());
 	int pi_depth=pi->depth();
-	BranchObj* bo=(BranchObj*)(dst);
+	BranchObj* bo=(BranchObj*)dst;
 
 	if (!tmpParent) 
 	{
@@ -490,6 +490,10 @@
 			setFrameType (FrameObj::Rectangle);
 			break;
 		case 1: 
+			fontsize=14; 
+			setFrameType (FrameObj::NoFrame);
+			break;
+		case 2: 
 			fontsize=12; 
 			setFrameType (FrameObj::NoFrame);
 			break;
diff -r 338ebdc9b947 -r 14f2b1b15242 branchpropwindow.cpp
--- a/branchpropwindow.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/branchpropwindow.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -169,7 +169,6 @@
 
 void BranchPropertyWindow::setModel (VymModel *m)
 {
-return;
 	model=m;
 	if (model) 
 		setItem (model->getSelectedItem() );
diff -r 338ebdc9b947 -r 14f2b1b15242 exports.cpp
--- a/exports.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/exports.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -148,7 +148,7 @@
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
 
-	cur=model->next (cur,prev);
+	cur=model->nextBranch (cur,prev);
 	while (cur) 
 	{
 		if (cur->getType()==TreeItem::Branch || cur->getType()==TreeItem::MapCenter)
@@ -195,7 +195,7 @@
 				}
 			}
 		}
-		cur=model->next(cur,prev);
+		cur=model->nextBranch(cur,prev);
 	}
 	file.close();
 }
@@ -229,7 +229,7 @@
 	BranchObj *bo;  //FIXME-3 still needed?
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	cur=model->next (cur,prev);
+	cur=model->nextBranch (cur,prev);
 	while (cur) 
 	{
 		bo=(BranchObj*)(cur->getLMO());
@@ -252,7 +252,7 @@
 			ts << curIndent << "\"" << cur->getHeading()<<"\""<<endl;
 		}
 		
-		cur=model->next(cur,prev);
+		cur=model->nextBranch(cur,prev);
 		curIndent="";
 	}
 	file.close();
@@ -388,7 +388,7 @@
   BranchObj *bo;
   BranchItem *cur=NULL;
   BranchItem *prev=NULL;
-  model->next(cur,prev);
+  model->nextBranch(cur,prev);
   while (cur) 
   {
 	bo=(BranchObj*)(cur->getLMO());
@@ -420,7 +420,7 @@
 		  ts << ("\n");
 		}
 	}
-    cur=model->next(cur,prev);
+    cur=model->nextBranch(cur,prev);
    }
   file.close();
 }
@@ -443,7 +443,7 @@
 	BranchItem *bi=current->getFirstBranch();
 	if (bi)
     {
-		if (true) //if (!bo->hasHiddenExportParent() )	// FIXME-2 use BranchItem...
+		if (!bi->hasHiddenExportParent() )	// FIXME-3 use BranchItem...
 		{
 			// Start list
 			r+="<text:list text:style-name=\"vym-list\">\n";
@@ -471,51 +471,73 @@
 {
 	QString allPages;
 
-/* FIXME-2 not adapted to multiple mapCenters yet, see patch already done in 1.12.2...
+	BranchItem *firstMCO=(BranchItem*)(model->getRootItem()->getFirstBranch());
+	if (!firstMCO) 
+	{
+		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("No objects in map!"));
+		return;
+	}
+
 	// Insert new content
-	content.replace ("<!-- INSERT TITLE -->",quotemeta(mapCenter->getHeading()));
-	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(mapCenter->getAuthor()));
+	// FIXME add extra title in mapinfo for vym 1.13.x
+	content.replace ("<!-- INSERT TITLE -->",quotemeta(firstMCO->getHeading()));
+	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(model->getAuthor()));
 
 	QString	onePage;
 	QString list;
 	
-	BranchObj *sectionBO=mapCenter->getFirstBranch();
+	BranchItem *sectionBI;	
     int i=0;
-	BranchObj *pagesBO;
+	BranchItem *pagesBI;
     int j=0;
 
+	int mapcenters=model->getRootItem()->branchCount();
+
+	// useSections already has been set in setConfigFile 
+	if (mapcenters>1)	
+		sectionBI=firstMCO;
+	else
+		sectionBI=firstMCO->getFirstBranch();
+
 	// Walk sections
-	while (sectionBO && !sectionBO->hasHiddenExportParent() )
+	while (sectionBI && !sectionBI->hasHiddenExportParent() )
 	{
 		if (useSections)
 		{
 			// Add page with section title
 			onePage=sectionTemplate;
-			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBO->getHeading() ) );
+			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBI->getHeading() ) );
 			allPages+=onePage;
+			pagesBI=sectionBI->getFirstBranch();
 		} else
 		{
-			i=-2;	// only use inner loop to 
+			//i=-2;	// only use inner loop to 
 			        // turn mainbranches into pages
-			sectionBO=mapCenter;
+			//sectionBI=firstMCO;
+			pagesBI=sectionBI;
 		}
 
-		// Walk mainpages
-		pagesBO=sectionBO->getFirstBranch();
 		j=0;
-		while (pagesBO && !pagesBO->hasHiddenExportParent() )
+		while (pagesBI && !pagesBI->hasHiddenExportParent() )
 		{
 			// Add page with list of items
 			onePage=pageTemplate;
-			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
-			list=buildList (pagesBO->getTreeItem() );  
+			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBI->getHeading() ) );
+			list=buildList (pagesBI);
 			onePage.replace ("<!-- INSERT LIST -->", list);
 			allPages+=onePage;
-			j++;
-			pagesBO=sectionBO->getBranchNum(j);
+			if (pagesBI!=sectionBI)
+			{
+				j++;
+				pagesBI=((BranchItem*)pagesBI->parent())->getBranchNum(j);
+			} else
+				pagesBI=NULL;	// We are already iterating over the sectionBIs
 		}
 		i++;
-		sectionBO=mapCenter->getBranchNum(i);
+		if (mapcenters>1 )
+			sectionBI=model->getRootItem()->getBranchNum (i);
+		else
+			sectionBI=firstMCO->getBranchNum (i);
 	}
 	
 	content.replace ("<!-- INSERT PAGES -->",allPages);
@@ -535,7 +557,6 @@
 
 	// zip tmpdir to destination
 	zipDir (tmpDir,outputFile);	
-*/
 }
 
 bool ExportOO::setConfigFile (const QString &cf)
diff -r 338ebdc9b947 -r 14f2b1b15242 highlighter.cpp
--- a/highlighter.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/highlighter.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -79,6 +79,7 @@
 					<< "\\bsetMapBackgroundColor\\b" 
 					<< "\\bsetMapDefLinkColor\\b" 
 					<< "\\bsetMapDefLinkStyle\\b" 
+					<< "\\bsetNote\\b" 
 					<< "\\bsetHeading\\b" 
 					<< "\\bsetHideExport\\b" 
 					<< "\\bsetIncludeImagesHorizontally\\b" 
diff -r 338ebdc9b947 -r 14f2b1b15242 main.cpp
--- a/main.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/main.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -16,6 +16,9 @@
 #include <windows.h>
 #endif
 
+#include <sys/types.h>			// To retrieve PID for use in DBUS
+#include <unistd.h>
+
 // Global variables
 TextEditor *textEditor;			// used in Constr. of LinkableMapObj
 								// initialized in mainwindow
@@ -25,8 +28,10 @@
 QString vymCodeName;
 
 Main *mainWindow;				// used in BranchObj::select()								
+
 QDBusConnection dbusConnection= QDBusConnection::sessionBus();
 
+
 QString tmpVymDir;				// All temp files go there, created in mainwindow
 QString clipboardDir;			// Clipboard used in all mapEditors
 QString clipboardFile;			// Clipboard used in all mapEditors
@@ -61,7 +66,6 @@
 	vymBuildDate=__VYM_BUILD_DATE;
 	vymCodeName=__VYM_CODENAME;
 
-
 	// Reading and initializing options commandline options
 	options.add ("debug", Option::Switch, "d", "debug");
 	options.add ("version", Option::Switch, "v","version");
@@ -87,7 +91,7 @@
 
 	if (options.isOn ("version"))
 	{
-		cout << "VYM - View Your Mind (c) 2004-2007 Uwe Drechsel "  << endl
+		cout << "VYM - View Your Mind (c) 2004-2009 Uwe Drechsel "  << endl
 			<<"   Version: "<<__VYM_VERSION <<endl
 			<<"Build date: "<<__VYM_BUILD_DATE << endl
 			<<"  "<<__VYM_CODENAME<<endl;
@@ -95,6 +99,10 @@
 		return 0;	
 	}		
 	
+	// Register for DBUS
+	if (debug) cout << "PID="<<getpid()<<endl;
+	dbusConnection.registerService (QString ("org.insilmaril.vym-%1").arg(getpid()));
+
 	// Use /usr/share/vym or /usr/local/share/vym or . ?
 	// First try options
 	if (options.isOn ("local"))
@@ -186,14 +194,6 @@
 	// Paint Mainwindow first time
 	qApp->processEvents();
 
-	// FIXME-3 playing around with dbus
-	/*
-	new Adaptor (&app);
-	dbusConnection.registerService("org.insilmaril.MainWindow");
-	QDBusConnection::sessionBus().registerObject("/MainApplication", &app);
-	*/
-
-
 	m.loadCmdLine();
 
 	// Run script
diff -r 338ebdc9b947 -r 14f2b1b15242 mainwindow.cpp
--- a/mainwindow.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/mainwindow.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -19,11 +19,12 @@
 #include "options.h"
 #include "process.h"
 #include "settings.h"
+#include "shortcuts.h"
 #include "texteditor.h"
 #include "warningdialog.h"
 #include "xlinkitem.h"
 
-//#include <modeltest.h>	// FIXME-3
+#include <modeltest.h>	// FIXME-3
 
 #if defined(Q_OS_WIN32)
 // Define only this structure as opposed to
@@ -123,7 +124,8 @@
 	makeSubDirs (clipboardDir);
 	clipboardEmpty=true;
 
-	procBrowser=NULL;
+	browserPID=new qint64;
+	*browserPID=0;
 
 	// Satellite windows //////////////////////////////////////////
 	// history window
@@ -705,6 +707,29 @@
 	addAction (a);
 	actionListBranches.append(actionExpandAll);
 
+	a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
+	a->setShortcut ( Qt::Key_Greater );		// Expand one level in tree editor
+	a->setStatusTip (tr( "Expand one level in tree editor" )); 
+    connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
+	a->setEnabled (false);
+	a->setToggleAction(false);
+	actionExpandOneLevel=a;
+    //tb->addAction (a);
+    editMenu->addAction ( a);
+	addAction (a);
+	actionListBranches.append(a);
+
+	a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
+	a->setShortcut ( Qt::Key_Less);			// Collapse one level in tree editor
+	a->setStatusTip (tr( "Collapse one level in tree editor" )); 
+    connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
+	a->setEnabled (false);
+	a->setToggleAction(false);
+	actionCollapseOneLevel=a;
+    //tb->addAction (a);
+    editMenu->addAction ( a);
+	addAction (a);
+	actionListBranches.append(a);
 
     a = new QAction( tr( "Unscroll children","Edit menu" ), this);
 	a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
@@ -722,7 +747,7 @@
 	editMenu->addSeparator();
 
 	a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
-	a->setShortcut (Qt::CTRL + Qt::Key_U );
+	a->setShortcut (Qt::SHIFT + Qt::Key_U );
 	a->setShortcut (tr( "Open URL" ));
     tb->addAction (a);
 	addAction(a);
@@ -738,6 +763,7 @@
 
 	a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
 	a->setStatusTip (tr( "Open all URLs in subtree" ));
+	a->setShortcut ( Qt::CTRL + Qt::Key_U );
 	addAction(a);
 	actionListBranches.append(a);
     connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
@@ -754,7 +780,7 @@
 	
 	a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
 	a->setStatusTip ( tr( "Edit local URL" ) );
-	a->setShortcut (Qt::SHIFT +  Qt::Key_U );
+	//a->setShortcut (Qt::SHIFT +  Qt::Key_U );
 	a->setShortcutContext (Qt::WindowShortcut);
 	actionListBranches.append(a);
 	addAction(a);
@@ -775,7 +801,6 @@
 	a->setShortcut ( Qt::Key_B );
 	a->setShortcutContext (Qt::WindowShortcut);
 	addAction(a);
-
     connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
 	actionBugzilla2URL=a;
     
@@ -823,6 +848,16 @@
     connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
 	actionToggleHideExport=a;
 
+	a = new QAction(tr( "Add timestamp","Edit menu" ), this);
+	a->setStatusTip ( tr( "Add timestamp" ));
+	a->setEnabled (false);
+	actionListBranches.append(a);
+	a->setShortcut ( Qt::Key_T );	// Add timestamp
+	a->setShortcutContext (Qt::WindowShortcut);
+	addAction(a);
+    connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
+	actionAddTimestamp=a;
+    
     a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
 	a->setStatusTip ( tr( "Edit Map Info" ));
 	a->setEnabled (true);
@@ -925,7 +960,7 @@
 
     a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
 	a->setStatusTip ( tr( "Color Subtree" ));
-	a->setShortcut (Qt::CTRL + Qt::Key_T);
+	//FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T);	// Color subtree
     connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
 	a->setEnabled (false);
 	formatMenu->addAction (a);
@@ -1010,31 +1045,34 @@
 	tb->setObjectName ("viewTB");
     QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
 
+	Switchboard switchboard;	//FIXME-1 testing...
+
     QAction *a;
     a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
 	a->setStatusTip ( tr( "Zoom reset" ) );
-	a->setShortcut (Qt::CTRL + Qt::Key_0 );
+	a->setShortcut (Qt::CTRL + Qt::Key_0);	// Reset zoom
+	switchboard.addConnection(a,"CTRL+0");
     a->addTo( tb );
 	viewMenu->addAction (a);
     connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
 	
     a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
 	a->setStatusTip (tr( "Zoom in" ));
-	a->setShortcut (Qt::CTRL + Qt::Key_Plus);
+	switchboard.addConnection(a,"CTRL++");
     a->addTo( tb );
 	viewMenu->addAction (a);
     connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
 	
     a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
 	a->setStatusTip (tr( "Zoom out" ));
-	a->setShortcut (Qt::CTRL + Qt::Key_Minus );
+	switchboard.addConnection(a,"CTRL+-");
     a->addTo( tb );
 	viewMenu->addAction (a);
     connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
 
     a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
 	a->setStatusTip (tr( "Show selection" ));
-	a->setShortcut (Qt::Key_Period);
+	switchboard.addConnection(a,".");
     a->addTo( tb );
 	viewMenu->addAction (a);
     connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
@@ -1043,7 +1081,7 @@
 
     a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
 	a->setStatusTip ( tr( "Show Note Editor" ));
-	a->setShortcut ( Qt::CTRL + Qt::Key_E );
+	a->setShortcut ( Qt::CTRL + Qt::Key_E );	// Toggle Note Editor
 	a->setToggleAction(true);
     a->addTo( tb );
 	viewMenu->addAction (a);
@@ -1052,7 +1090,7 @@
 
     a = new QAction(QPixmap(iconPath+"history.png"),  tr( "History Window","View action" ),this );
 	a->setStatusTip ( tr( "Show History Window" ));
-	a->setShortcut ( Qt::CTRL + Qt::Key_H  );
+	a->setShortcut ( Qt::CTRL + Qt::Key_H  );	// Toggle history window
 	a->setToggleAction(true);
     a->addTo( tb );
 	viewMenu->addAction (a);
@@ -1090,6 +1128,8 @@
 	a->setShortcut (Qt::ALT + Qt::Key_P );
 	viewMenu->addAction (a);
     connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
+
+	switchboard.print();
 }
 
 // Mode Actions
@@ -1356,13 +1396,13 @@
 
     a = new QAction(  "Start TCPserver for MapEditor",this);
     //a->setStatusTip ( "Set application to open pdf files"));
-	a->setShortcut ( Qt::Key_T );		//New TCP server
+	//a->setShortcut ( Qt::ALT + Qt::Key_T );		//New TCP server
     connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
 	netMenu->addAction (a);
 
     a = new QAction(  "Connect MapEditor to server",this);
     //a->setStatusTip ( "Set application to open pdf files"));
-	a->setShortcut ( Qt::Key_C );		// Connect to server
+	a->setShortcut ( Qt::ALT + Qt::Key_C );		// Connect to server
     connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
 	netMenu->addAction (a);
 }
@@ -1480,12 +1520,13 @@
     QAction *a;
     a = new QAction( "Test function 1" , this);
     a->setStatusTip( "Call test function 1" );
+	a->setShortcut (Qt::CTRL + Qt::Key_T);	// Test function 1  //FIXME-2 originally: color subtree
 	testMenu->addAction (a);
     connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
 
     a = new QAction( "Test function 2" , this);
     a->setStatusTip( "Call test function 2" );
-	a->setShortcut (Qt::SHIFT + Qt::Key_T);
+	a->setShortcut (Qt::SHIFT + Qt::Key_T);		// Test function 2
 	testMenu->addAction (a);
     connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
 
@@ -1704,7 +1745,7 @@
 	VymModel *m;
 	for (int i=0;i<=tabWidget->count() -1;i++)
 	{
-		m= vymViews.at(tabWidget->currentIndex())->getModel();
+		m= vymViews.at(i)->getModel();
 		if (m) m->unselect();
 	}
 	m=currentModel();
@@ -1718,7 +1759,7 @@
 {
 	VymModel *vm=new VymModel;
 
-//new ModelTest(vm, this);	//FIXME-3
+new ModelTest(vm, this);	//FIXME-3
 
 
 	VymView *vv=new VymView (vm);
@@ -1728,7 +1769,8 @@
 	vv->initFocus();
 
 	// Create MapCenter for empty map
-	//vm->createMapCenter();
+	vm->addMapCenter();
+	vm->makeDefault();
 
 	// For the very first map we do not have flagrows yet...
 	vm->select("mc:");
@@ -2336,7 +2378,7 @@
 			}
 		} 
 		// And here comes the segfault, because removeTab triggers 
-		// currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
+		// FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
 		vymViews.removeAt (tabWidget->currentIndex() );
 		tabWidget->removeTab (tabWidget->currentIndex() );
 
@@ -2469,14 +2511,12 @@
 		bool success=true;
 		QStringList args;
 		QString browser=settings.value("/mainwindow/readerURL" ).toString();
-		QProcess *p;
-		if (!procBrowser ||  procBrowser->state()!=QProcess::Running)
+		if (*browserPID==0)	//FIXME-2 need to check if browser is really still there instead of this
 		{
 			QString u=urls.takeFirst();
-			procBrowser = new QProcess( this );
 			args<<u;
-			procBrowser->start(browser,args);
-			if ( !procBrowser->waitForStarted())
+			QString workDir=QDir::currentDirPath();
+			if (!QProcess::startDetached(browser,args,workDir,browserPID))
 			{
 				// try to set path to browser
 				QMessageBox::warning(0, 
@@ -2485,37 +2525,37 @@
 					tr("Please use Settings->")+tr("Set application to open an URL"));
 				return;
 			}
+			if (debug) cout << "Main::openTabs  Started konqueror-"<<*browserPID<<endl;
 #if defined(Q_OS_WIN32)
             // There's no sleep in VCEE, replace it with Qt's QThread::wait().
             this->thread()->wait(3000);
 #else
-			sleep (3);
+			sleep (3);	//FIXME-3 needed?
 #endif
 		}
+
 		if (browser.contains("konqueror"))
 		{
 			for (int i=0; i<urls.size(); i++)
 			{
 				// Open new browser
 				// Try to open new tab in existing konqueror started previously by vym
-				p=new QProcess (this);
 				args.clear();
-#if defined(Q_OS_WIN32)
-                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
-                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
-				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
-					"konqueror-mainwindow#1"<<
-					"newTab" <<
-					urls.at(i);
-#else
+
+/*	On KDE3 use DCOP
 				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
 					"konqueror-mainwindow#1"<<
 					"newTab" <<
 					urls.at(i);
-#endif
-				p->start ("dcop",args);
-				if (debug) cout << "MainWindo::openURLs  args="<<args.join(" ").toStdString()<<endl;
-				if ( !p->waitForStarted() ) success=false;
+*/					
+				args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
+					"/konqueror/MainWindow_1"<<
+					"newTab" <<
+					urls.at(i)<<
+					"false";
+				if (debug) cout << "MainWindow::openURLs  args="<<args.join(" ").toStdString()<<endl;
+				if (!QProcess::startDetached ("qdbus",args))
+					success=false;
 			}
 			if (!success)
 				QMessageBox::warning(0, 
@@ -2527,10 +2567,9 @@
 			for (int i=0; i<urls.size(); i++)
 			{
 				// Try to open new tab in firefox
-				p=new QProcess (this);
 				args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
-				p->start (browser,args);
-				if ( !p->waitForStarted() ) success=false;
+				if (!QProcess::startDetached (browser,args))
+					success=false;
 			}			
 			if (!success)
 				QMessageBox::warning(0, 
@@ -2554,10 +2593,9 @@
 		QStringList args;
 		if (url=="") return;
 		QString browser=settings.value("/mainwindow/readerURL" ).toString();
-		procBrowser = new QProcess( this );
 		args<<url;
-		procBrowser->start(browser,args);
-		if ( !procBrowser->waitForStarted())
+		QString workDir=QDir::currentDirPath();
+		if (!procBrowser->startDetached(browser,args))
 		{
 			// try to set path to browser
 			QMessageBox::warning(0, 
@@ -2704,6 +2742,12 @@
 	if (m) m->toggleHideExport();	
 }
 
+void Main::editAddTimestamp()
+{
+	VymModel *m=currentModel();
+	if (m) m->addTimestamp();	
+}
+
 void Main::editMapInfo()
 {
 	VymModel *m=currentModel();
@@ -2724,14 +2768,14 @@
 	uint xl=0;
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	m->next(cur,prev);
+	m->nextBranch(cur,prev);
 	while (cur) 
 	{
 		if (!cur->getNote().isEmpty() ) n++;
 		f+= cur->imageCount();
 		b++;
 		xl+=cur->xlinkCount();
-		m->next(cur,prev);
+		m->nextBranch(cur,prev);
 	}
 
     stats+=QString ("%1 xLinks \n").arg (xl,6);
@@ -2784,6 +2828,18 @@
 	if (m) m->emitExpandAll();
 }
 
+void Main::editExpandOneLevel()
+{
+	VymModel *m=currentModel();
+	if (m) m->emitExpandOneLevel();
+}
+
+void Main::editCollapseOneLevel()
+{
+	VymModel *m=currentModel();
+	if (m) m->emitCollapseOneLevel();
+}
+
 void Main::editUnscrollChildren()
 {
 	VymModel *m=currentModel();
@@ -2847,7 +2903,7 @@
 	}	
 }
 
-void Main::editNewBranchAbove()
+void Main::editNewBranchAbove()	// FIXME-1 can crash
 {
 	VymModel *m=currentModel();
 	if ( m)
@@ -3368,10 +3424,20 @@
 		// History window
 		historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
 
+
+		// Expanding/collapsing
+		actionExpandAll->setEnabled (true);
+		actionExpandOneLevel->setEnabled (true);
+		actionCollapseOneLevel->setEnabled (true);
 	} else
 	{
 		// Printing
 		actionFilePrint->setEnabled (false);
+
+		// Expanding/collapsing
+		actionExpandAll->setEnabled (false);
+		actionExpandOneLevel->setEnabled (false);
+		actionCollapseOneLevel->setEnabled (false);
 	}
 
 	if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) 
@@ -3603,10 +3669,11 @@
 
 void Main::testFunction1()
 {
+/*
 	if (!currentMapEditor()) return;
 	//currentMapEditor()->testFunction1();
-	/*
-	*/
+*/
+
 	VymModel *m=currentModel();
 	if (!m) return;
 
@@ -3689,8 +3756,7 @@
 	Process *pdfProc = new Process();
     args << QDir::toNativeSeparators(docfile.fileName());
 
-	pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
-	if ( !pdfProc->waitForStarted() ) 
+	if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
 	{
 		// error handling
 		QMessageBox::warning(0, 
diff -r 338ebdc9b947 -r 14f2b1b15242 mainwindow.h
--- a/mainwindow.h	Fri Oct 02 14:31:03 2009 +0000
+++ b/mainwindow.h	Fri Nov 13 08:32:03 2009 +0000
@@ -141,6 +141,7 @@
 private slots:
 	void editDeleteVymLink();
 	void editToggleHideExport();
+	void editAddTimestamp();
 	void editMapInfo();
     void editMoveUp();	
     void editMoveDown();	
@@ -148,6 +149,8 @@
 	void editSortChildren();
     void editToggleScroll();
     void editExpandAll();
+    void editExpandOneLevel();
+    void editCollapseOneLevel();
     void editUnscrollChildren();
     void editAddAttribute();
     void editAddMapCenter();
@@ -182,6 +185,7 @@
     void formatToggleLinkColorHint();
 	void formatHideLinkUnselected();
 
+public slots:
     void viewZoomReset();
     void viewZoomIn();
     void viewZoomOut();
@@ -244,7 +248,8 @@
 private:
 	QTabWidget *tabWidget;
 	FindWindow *findWindow;
-	QProcess *procBrowser;
+	QProcess *procBrowser;		//FIXME-2 remove this...
+	qint64 *browserPID;
 
 	QStringList imageTypes;
 
@@ -283,6 +288,8 @@
 	QAction *actionSortChildren;
 	QAction *actionToggleScroll;
 	QAction *actionExpandAll;
+	QAction *actionExpandOneLevel;
+	QAction *actionCollapseOneLevel;
 	QAction* actionOpenURL;
 	QAction* actionOpenURLTab;
 	QAction* actionOpenMultipleURLTabs;
@@ -295,6 +302,7 @@
 	QAction *actionOpenMultipleVymLinks;
 	QAction *actionVymLink;
 	QAction *actionDeleteVymLink;
+	QAction *actionAddTimestamp;
 	QAction *actionToggleHideExport;
 	QAction *actionMapInfo;
 	QAction *actionHeading;
diff -r 338ebdc9b947 -r 14f2b1b15242 mapeditor.cpp
--- a/mapeditor.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/mapeditor.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -1,4 +1,4 @@
-#include "mapeditor.h"
+														  #include "mapeditor.h"
 
 #include <iostream>
 #include <cstdlib>
@@ -196,7 +196,6 @@
 		if (lmo) 
 		{
 			QRectF r=lmo->getBBox();
-			if (debug) cout << "ME::scrollTo "<<ti->getHeadingStd()<<" bbox="<<r<<endl;
 			setScrollBarPosTarget (r);
 		}	
 	}
@@ -909,7 +908,8 @@
 		lineEdit->setText (bi->getHeading());
 		QPoint p = mapTo (this,bo->getAbsPos().toPoint() );
 		lineEdit->setGeometry(p.x(),p.y(),230,25);
-		lineEdit->selectAll();
+		//lineEdit->selectAll();
+		//lineEdit->setCursorPosition (1);
 		lineEdit->show();
 		lineEdit->setFocus();
 		lineEdit->grabKeyboard();
@@ -1002,9 +1002,11 @@
 
 void MapEditor::mousePressEvent(QMouseEvent* e)
 {
+cout << "ME::mousePressed\n";
 	// Ignore right clicks, these will go to context menus
 	if (e->button() == Qt::RightButton )
 	{
+		cout << "  ME::ignoring right mouse event...\n";
 		e->ignore();
 		return;
 	}
@@ -1012,6 +1014,7 @@
 	//Ignore clicks while editing heading
 	if (model->isSelectionBlocked() ) 
 	{
+		cout << "  ME::ignoring other mouse event...\n";
 		e->ignore();
 		return;
 	}
@@ -1707,7 +1710,6 @@
 		selboxList.append (sb);
 	}
 
-
 	// Reposition rectangles
 	QRectF bbox;
 	QModelIndex index;
@@ -1726,7 +1728,7 @@
 		i++;
 	}
 
-	scene()->update();
+	scene()->update();  
 }
 
 void MapEditor::updateData (const QModelIndex &sel)
diff -r 338ebdc9b947 -r 14f2b1b15242 mysortfilterproxymodel.cpp
--- a/mysortfilterproxymodel.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/mysortfilterproxymodel.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -1,55 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial Usage
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui>
+//#include <QtGui>
 
 #include "mysortfilterproxymodel.h"
 
-//! [0]
 MySortFilterProxyModel::MySortFilterProxyModel(QObject *parent)
     : QSortFilterProxyModel(parent)
 {
 }
 //! [0]
 
+/*
 //! [1]
 void MySortFilterProxyModel::setFilterMinimumDate(const QDate &date)
 {
@@ -64,10 +23,9 @@
     maxDate = date;
     invalidateFilter();
 }
-//! [2]
+*/
 
-//! [3]
-bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow,
+bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow,	// FIXME-1 find a way to show _all_ rows which match, independent of parent
         const QModelIndex &sourceParent) const
 {
     QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
@@ -75,12 +33,11 @@
     QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent);
 
     return (sourceModel()->data(index0).toString().contains(filterRegExp())
-            || sourceModel()->data(index1).toString().contains(filterRegExp()))
-           && dateInRange(sourceModel()->data(index2).toDate());
+            || sourceModel()->data(index1).toString().contains(filterRegExp()));
+//           && dateInRange(sourceModel()->data(index2).toDate());
 }
-//! [3]
 
-//! [4] //! [5]
+/*
 bool MySortFilterProxyModel::lessThan(const QModelIndex &left,
                                       const QModelIndex &right) const
 {
@@ -114,3 +71,4 @@
            && (!maxDate.isValid() || date < maxDate);
 }
 //! [7]
+*/
diff -r 338ebdc9b947 -r 14f2b1b15242 mysortfilterproxymodel.h
--- a/mysortfilterproxymodel.h	Fri Oct 02 14:31:03 2009 +0000
+++ b/mysortfilterproxymodel.h	Fri Nov 13 08:32:03 2009 +0000
@@ -1,48 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial Usage
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
 #ifndef MYSORTFILTERPROXYMODEL_H
 #define MYSORTFILTERPROXYMODEL_H
 
-#include <QDate>
+//#include <QDate>
 #include <QSortFilterProxyModel>
 
 //! [0]
@@ -52,15 +11,17 @@
 
 public:
     MySortFilterProxyModel(QObject *parent = 0);
+/*
 
     QDate filterMinimumDate() const { return minDate; }
     void setFilterMinimumDate(const QDate &date);
 
     QDate filterMaximumDate() const { return maxDate; }
     void setFilterMaximumDate(const QDate &date);
-
 protected:
+*/
     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
+	/*
     bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
 
 private:
@@ -68,7 +29,7 @@
 
     QDate minDate;
     QDate maxDate;
+*/
 };
-//! [0]
 
 #endif
diff -r 338ebdc9b947 -r 14f2b1b15242 tex/vc
--- a/tex/vc	Fri Oct 02 14:31:03 2009 +0000
+++ b/tex/vc	Fri Nov 13 08:32:03 2009 +0000
@@ -1,6 +1,8 @@
 #! /bin/bash
 #
 
+user=vym@insilmaril.de
+
 set -e  # abort on errors
 shopt -s nullglob  # file globs that don't match expand
 		   # to nothing
@@ -69,10 +71,10 @@
 #
 # Add domain to username (if it's me ;-)
 #
-user=`whoami`
-if [ $user = "uwedr" ]; then
-	user="$user@suse.de"
-fi
+#user=`whoami`
+#if [ $user = "uwedr" ]; then
+#	user="$user@suse.de"
+#fi
 
 COMMENT_FILE=$2
 
diff -r 338ebdc9b947 -r 14f2b1b15242 tex/vym.changelog
--- a/tex/vym.changelog	Fri Oct 02 14:31:03 2009 +0000
+++ b/tex/vym.changelog	Fri Nov 13 08:32:03 2009 +0000
@@ -1,3 +1,36 @@
+-------------------------------------------------------------------
+Wed Nov 11 10:32:29 CET 2009 - vym@insilmaril.de
+
+- Bugfix: New map has mapcenter again
+
+-------------------------------------------------------------------
+Tue Nov 10 13:53:37 CET 2009 - vym@insilmaril.de
+
+- Bugfix: Autodetection of textformat (ASCII vs. HTML)
+- Bugfix: nextBranch failed with xLinks
+
+-------------------------------------------------------------------
+Fri Oct 30 18:58:22 CET 2009 - uwedr@suse.de
+
+- Bugfix: Selection doesn't get lost when switching maps
+
+-------------------------------------------------------------------
+Wed Oct 28 08:43:34 CET 2009 - uwedr@suse.de
+
+- Feature: Adding timestamp to branch
+
+-------------------------------------------------------------------
+Wed Oct 21 17:23:13 CEST 2009 - uwedr@suse.de
+
+- Feature: expand/collapse by one level in TreeEditor 
+- Bugfix: Process like webbrowser started by vym survive vym now
+
+-------------------------------------------------------------------
+Tue Oct  6 16:29:07 CEST 2009 - uwedr@suse.de
+
+- Bugfix: Export to OpenOffice.org
+- Bugfix: BranchProp window
+
 -------------------------------------------------------------------
 Sat Aug  8 23:54:38 CEST 2009 - uwedr@suse.de
 
diff -r 338ebdc9b947 -r 14f2b1b15242 texteditor.cpp
--- a/texteditor.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/texteditor.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -15,6 +15,8 @@
 extern QString iconPath;
 extern QString vymName;
 
+extern bool debug;
+
 using namespace std;
 
 
@@ -110,6 +112,30 @@
 
 }
 
+void TextEditor::reset()
+{
+	e->clear();
+	actionFormatUseFixedFont->setOn (false);
+    actionTextBold->setOn (false);
+	e->setBold (false);
+
+	actionTextUnderline->setOn (false);
+	e->setUnderline (false);
+
+	actionTextItalic->setOn (false);
+	e->setItalic (false);
+
+    QPixmap pix( 16, 16 );
+    pix.fill( Qt::black );
+    actionTextColor->setIconSet( pix );
+	e->setColor (Qt::black);
+
+	actionAlignSubScript->setOn (false);
+	actionAlignSuperScript->setOn (false);
+	actionAlignLeft->setOn (true);
+	e->setAlignment( Qt::AlignLeft );
+}
+
 bool TextEditor::isEmpty()
 {
 	if (e->toPlainText().length()>0)
@@ -547,7 +573,14 @@
 {
 	blockChangedSignal=true;
 	e->setReadOnly(false);
-	e->setText(t);
+	reset();
+	if (Qt::mightBeRichText (t))
+		e->setHtml(t);
+	else
+	{
+		actionFormatUseFixedFont->setChecked (true);
+		e->setPlainText(t);
+	}	
 	enableActions();
 	blockChangedSignal=false;
 }
diff -r 338ebdc9b947 -r 14f2b1b15242 texteditor.h
--- a/texteditor.h	Fri Oct 02 14:31:03 2009 +0000
+++ b/texteditor.h	Fri Nov 13 08:32:03 2009 +0000
@@ -5,7 +5,6 @@
 
 enum EditorState {inactiveEditor,emptyEditor,filledEditor};
 
-class MyTextEdit;
 class NoteObj;
 
 class TextEditor : public QMainWindow {
@@ -14,6 +13,7 @@
     TextEditor();
     ~TextEditor();
 
+	void reset();
 	bool isEmpty();
 	void setShowWithMain (bool);
 	bool showWithMain ();
diff -r 338ebdc9b947 -r 14f2b1b15242 treeeditor.cpp
--- a/treeeditor.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/treeeditor.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -8,19 +8,17 @@
 
 #include "vymmodel.h"
 
-#include "mysortfilterproxymodel.h"
-
 ///////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////
 TreeEditor::TreeEditor(VymModel *m)
 {
 	model=m;
 
-//	MySortFilterProxyModel *proxyModel = new MySortFilterProxyModel(this);	// FIXME-1 trying to use proxy...
-	proxyModel = new QSortFilterProxyModel (this);
-
-	setModel(proxyModel);
-	proxyModel->setSourceModel(model);
+	// FIXME-2 use proxmodel
+	//proxyModel = new MySortFilterProxyModel(this);	
+	//setModel(proxyModel);
+	setModel(m);
+	//proxyModel->setSourceModel(model);
 
 	QAction *a;
 	// Shortcuts for navigating with cursor:
@@ -44,14 +42,23 @@
 	//cout <<"Destructor TreeEditor for "<<model->getMapName().toStdString()<<endl;
 }
 
-QSortFilterProxyModel* TreeEditor::getProxyModel()
+MySortFilterProxyModel* TreeEditor::getProxyModel()
 {
 	return proxyModel;
 }
 
+QModelIndex TreeEditor::getSelectedIndex()
+{
+	QModelIndexList list=selectionModel()->selectedIndexes();
+	if (list.isEmpty() )
+		return QModelIndex();
+	else
+		return list.first();
+}
+
+
 void TreeEditor::setSortFilter(QString s)
 {
-	cout << "TE::setting sortFilter to "<<s.toStdString()<<endl;
 	proxyModel->setFilterRegExp(QRegExp(s, Qt::CaseInsensitive));
 	proxyModel->setFilterKeyColumn(0);
 	proxyModel->setDynamicSortFilter (true);
@@ -59,11 +66,19 @@
 
 void TreeEditor::cursorUp()
 {
-	model->select (indexAbove (model->getSelectedIndex() ));
+	QModelIndex ix=getSelectedIndex();
+	// FIXME-2 useproxymodel ix=proxyModel->mapToSource (indexAbove(ix));
+	ix=indexAbove (ix);
+	if (ix.isValid())
+		model->select (ix );
 }
 
 void TreeEditor::cursorDown()
 {
-	model->select (indexBelow (model->getSelectedIndex() ));
+	QModelIndex ix=getSelectedIndex();
+	//FIXME-2 useProxymodel ix=proxyModel->mapToSource (indexBelow(ix));
+	ix=indexBelow (ix);
+	if (ix.isValid())
+		model->select (ix );
 }
 
diff -r 338ebdc9b947 -r 14f2b1b15242 treeeditor.h
--- a/treeeditor.h	Fri Oct 02 14:31:03 2009 +0000
+++ b/treeeditor.h	Fri Nov 13 08:32:03 2009 +0000
@@ -2,7 +2,7 @@
 #define TREEEDITOR_H
 
 #include <QTreeView>
-#include <QSortFilterProxyModel>
+#include "mysortfilterproxymodel.h"
 
 class VymModel;
 
@@ -16,7 +16,8 @@
 public:
     TreeEditor(VymModel *m);
 	~TreeEditor();
-	QSortFilterProxyModel *getProxyModel();
+	MySortFilterProxyModel *getProxyModel();
+	QModelIndex getSelectedIndex();
 
 public slots:
 	void setSortFilter (QString f);
@@ -27,7 +28,7 @@
 
 private:
 	VymModel *model;
-	QSortFilterProxyModel *proxyModel;
+	MySortFilterProxyModel *proxyModel;
 };
 
 #endif
diff -r 338ebdc9b947 -r 14f2b1b15242 treeitem.cpp
--- a/treeitem.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/treeitem.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -532,7 +532,7 @@
 BranchItem* TreeItem::getFirstBranch()
 {
 	if (branchCounter>0)
-		return getBranchNum (branchOffset);
+		return getBranchNum (0);
 	else
 		return NULL;
 }
@@ -540,7 +540,7 @@
 BranchItem* TreeItem::getLastBranch()
 {
 	if (branchCounter>0)
-		return getBranchNum (branchOffset + branchCounter-1);
+		return getBranchNum (branchCounter-1);
 	else
 		return NULL;
 }
@@ -707,7 +707,7 @@
 	return hidden;
 }	
 
-QString TreeItem::getGeneralAttr()
+QString TreeItem::getGeneralAttr()	
 {
 	QString s;
 	if (hideExport)
@@ -715,7 +715,7 @@
 	if (!url.isEmpty())
 		s+=attribut ("url",url);
 	if (!vymLink.isEmpty())
-		s+=attribut ("vymLink",vymLink);
+		s+=attribut ("vymLink",convertToRel (model->getDestPath(),vymLink));
 	return s;	
 }
 
diff -r 338ebdc9b947 -r 14f2b1b15242 treemodel.cpp
--- a/treemodel.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/treemodel.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -146,14 +146,8 @@
 	return c;
 }
 
-BranchItem* TreeModel::next(BranchItem* &current, BranchItem* &previous, BranchItem* start)	// FIXME-3 change this to nextBranch and use "next" for all TIs
+BranchItem* TreeModel::nextBranch (BranchItem* &current, BranchItem* &previous, bool deepLevelsFirst, BranchItem *start)	
 {
-/*FIXME-3	cout << "TM::next \n"; 
-	std::string ch="()"; if (current) ch=current->getHeadingStd();
-	std::string ph="()"; if (previous) ph=previous->getHeadingStd();
-	cout << "  cur="<<ch << " prev="<<ph<<endl;
-*/
-
 	// Walk through map beginning at current with previous==0
 	// Start at root, if current==NULL
 	if (!current) current=(BranchItem*)rootItem;
@@ -166,63 +160,98 @@
 		current=current->getFirstBranch();
 		return current;
 	}
+	if (deepLevelsFirst)
+	{
+		// Going up or down (deeper)?
+		if (current->depth() > previous->depth() )
+		{	
+			// Coming from above
+			// Trying  to go down deeper
+			if (current->branchCount() >0 )
+			{
+				previous=current;
+				current=current->getFirstBranch();
+				return current;
+			}	
+			// turn around and go up again
+			BranchItem *bi=current;
+			current=previous;
+			previous=bi;
+		}	
 
-	// Going up or down (deeper)?
-	if (current->depth() > previous->depth() )
-	{	
-		// Coming from above
-		// Trying  to go down deeper
-//		cout << "  trying to go deeper\n";
-		if (current->branchCount() >0 )
-		{
-//			cout << "  yes, going deeper\n";
+		// Coming from below
+		// Trying to go down again to siblings
+
+		BranchItem *sibling=current->getBranchNum (previous->num()+1);
+
+		if (sibling)
+		{	
+			// Found sibling of previous, go there
 			previous=current;
-			current=current->getFirstBranch();
+			current=sibling;
 			return current;
-		}	
-		// turn around and go up again
-//		cout << "  sorry, turn around\n";
-		BranchItem *bi=current;
-		current=previous;
-		previous=bi;
-	}	
+		} 
 
-/*
-	cout << "  coming from below\n";
-	ch="()"; if (current) ch=current->getHeadingStd();
-	ph="()"; if (previous) ph=previous->getHeadingStd();
-	cout << "  cur="<<ch << " prev="<<ph<<endl;
-*/	
-	// Coming from below
-	// Trying to go down again to siblings
+		// If we only needed to go through subtree, we are done now
+		if (start==current) return NULL;
 
-	BranchItem *sibling=current->getBranchNum (previous->num()+1);
-//	cout <<"    prev->num()="<<previous->num()<<endl;
+		// Go up and try to find siblings of current
+		previous=current;
+		current=(BranchItem*)current->parent();
 
-	if (sibling)
-	{	
-		// Found sibling of previous, go there
-//		cout << "  sib=cur="<<sibling->getHeadingStd()<<endl;
-		previous=current;
-		current=sibling;
+		// Check if we still can go somewhere
+		if (!current) return current;
+		
+		while (current && current->depth() < previous->depth() )
+			current=nextBranch (current,previous,true,start);
+			
 		return current;
-	} 
 
-	// If we only needed to go through subtree, we are done now
-	if (start==current) return NULL;
+	} else
+	{
+/*FIXME-3
+		cout << "TM::nextBranch shallow\n"; 
+		std::string ch="()"; if (current) ch=current->getHeadingStd();
+		std::string ph="()"; if (previous) ph=previous->getHeadingStd();
+		cout << "  cur="<<ch << " prev="<<ph<<endl;
+*/
 
-	// Go up and try to find siblings of current
-//	cout <<"  going up again...\n";
-	previous=current;
-	current=(BranchItem*)current->parent();
+		// Try to find sibling with same depth
+		BranchItem *sibling=current->parent()->getBranchNum (current->num()+1);
+		if (sibling)
+		{	
+			// Found sibling of previous, go there
+			previous=current;
+			current=sibling;
+			return current;
+		}  else
+		{	
+			// Try to find next branch with same depth or greater
+			
 
-	// Check if we still can go somewhere
-	if (!current) return current;
-	
-	while (current && current->depth() < previous->depth() )
-		current=next (current,previous,start);
-		
-	return current;
+			current=NULL;
+			return current;
+		}
+
+
+		/*
+	while (ix.isValid())
+	{
+		TreeItem *ti=model->getItem (ix);
+		cout << "  level="<<level<<"  ix=";
+		if (ti) cout << ti->getHeadingStd();
+		row=ix.row();
+		col=ix.column();
+		if (! treeEditor->isExpanded(ix))
+			cout <<"  expand!";
+		else	
+			cout <<"  is expanded.";
+		cout <<endl;
+		ix=ix.sibling(row+1,col);
+	}
+	*/
+
+	}
 }
 
 bool TreeModel::removeRows ( int row, int count, const QModelIndex & parent)
diff -r 338ebdc9b947 -r 14f2b1b15242 treemodel.h
--- a/treemodel.h	Fri Oct 02 14:31:03 2009 +0000
+++ b/treemodel.h	Fri Nov 13 08:32:03 2009 +0000
@@ -29,7 +29,7 @@
     int rowCount(const QModelIndex &parent = QModelIndex()) const;
     int columnCount(const QModelIndex &parent = QModelIndex()) const;
 
-	BranchItem* next(BranchItem* &current, BranchItem* &previous, BranchItem* start=NULL);
+	BranchItem* nextBranch (BranchItem* &current, BranchItem* &previous, bool deepLevelsFirst=true, BranchItem* start=NULL);
 
 	bool removeRows ( int row, int count, 
 				const QModelIndex & parent = QModelIndex() ); 
diff -r 338ebdc9b947 -r 14f2b1b15242 version.h
--- a/version.h	Fri Oct 02 14:31:03 2009 +0000
+++ b/version.h	Fri Nov 13 08:32:03 2009 +0000
@@ -7,7 +7,7 @@
 #define __VYM_VERSION "1.13.0"
 //#define __VYM_CODENAME "Codename: RC-1"
 #define __VYM_CODENAME "Codename: development version, not for production!"
-#define __VYM_BUILD_DATE "2009-10-02"
+#define __VYM_BUILD_DATE "2009-11-12"
 
 
 bool checkVersion(const QString &);
diff -r 338ebdc9b947 -r 14f2b1b15242 vym.pro
--- a/vym.pro	Fri Oct 02 14:31:03 2009 +0000
+++ b/vym.pro	Fri Nov 13 08:32:03 2009 +0000
@@ -75,6 +75,7 @@
 	ornamentedobj.h \
 	parser.h \
 	process.h \
+	shortcuts.h\
 	showtextdialog.h\
 	simplescripteditor.h\
 	texteditor.h \
@@ -140,6 +141,7 @@
 	ornamentedobj.cpp \
 	parser.cpp \
 	process.cpp \
+	shortcuts.cpp\
 	showtextdialog.cpp \
 	simplescripteditor.cpp \
 	texteditor.cpp \
diff -r 338ebdc9b947 -r 14f2b1b15242 vymmodel.cpp
--- a/vymmodel.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/vymmodel.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -70,9 +70,8 @@
 void VymModel::clear() 
 {
 	selModel->clearSelection();
-
-	//QModelIndex ri=index(rootItem);
-	//removeRows (0, rowCount(ri),ri);		// FIXME-3 here should be at least a beginRemoveRows...
+	while (rootItem->childCount() >0)
+		deleteItem (rootItem->getChildNum(0) );
 }
 
 void VymModel::init () 
@@ -149,12 +148,10 @@
 	// Create MapCenter
 	//  addMapCenter();  FIXME-2 VM create this in MapEditor until BO and MCO are independent of scene
 
-	//Initialize DBUS
+	//Initialize DBUS object
 	adaptorModel=new AdaptorModel(this);	// Created and not deleted as documented in Qt
-	//adaptor->setModel (this);
-    //connection.registerObject("/Car", car);
-    dbusConnection.registerService("org.insilmaril.VymModel");
-    dbusConnection.sessionBus().registerObject ("/Object1",this);
+    if (!dbusConnection.registerObject (QString("/vymmodel_%1").arg(mapNum),this))
+		qWarning ("VymModel: Couldn't register DBUS object!");
 }
 
 void VymModel::makeTmpDirectories()
@@ -1076,7 +1073,9 @@
 		select (redoSelection);
 
 
-	parseAtom (redoCommand);
+	bool noErr;
+	QString errMsg;
+	parseAtom (redoCommand,noErr,errMsg);
 
 	blockSaveState=blockSaveStateOrg;
 
@@ -1154,7 +1153,10 @@
 		cout << "    redoSel="<<redoSelection.toStdString()<<endl;
 		cout << "    ---------------------------"<<endl<<endl;
 	}	
-	parseAtom (undoCommand);
+
+	bool noErr;
+	QString errMsg;
+	parseAtom (redoCommand,noErr,errMsg);
 
 	undosAvail--;
 	curStep--; 
@@ -1441,11 +1443,11 @@
 {
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	next(cur,prev);
+	nextBranch(cur,prev);
 	while (cur) 
 	{
 		if (s==cur->getID() ) return cur;
-		next(cur,prev);
+		nextBranch(cur,prev);
 	}
 	return NULL;
 }
@@ -1498,11 +1500,11 @@
 	int c=0;
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
-	next(cur,prev);
+	nextBranch(cur,prev);
 	while (cur) 
 	{
 		c++;
-		next(cur,prev);
+		nextBranch(cur,prev);
 	}
 	return c;
 }
@@ -1545,6 +1547,25 @@
 		return QString();
 }
 
+void VymModel::setNote(const QString &s)	//FIXME-2 savestate missing	// FIXME-2 call to VM::updateNoteFlag missing (fix signal handling here)
+{
+	TreeItem *selti=getSelectedItem();
+	if (selti) 
+	{
+		selti->setNote(s);
+		emitNoteHasChanged(selti);
+	}
+}
+
+QString VymModel::getNote()
+{
+	TreeItem *selti=getSelectedItem();
+	if (selti)
+		return selti->getNote();
+	else	
+		return QString();
+}
+
 BranchItem* VymModel::findText (QString s, bool cs)   
 {
 	QTextDocument::FindFlags flags=0;
@@ -1557,7 +1578,7 @@
 			EOFind=false;
 		findCurrent=NULL;	
 		findPrevious=NULL;	
-		next (findCurrent,findPrevious);
+		nextBranch (findCurrent,findPrevious);
 	}	
 	bool searching=true;
 	bool foundNote=false;
@@ -1591,7 +1612,7 @@
 		}	
 		if (!foundNote)
 		{
-			if (!next(findCurrent,findPrevious) )
+			if (!nextBranch(findCurrent,findPrevious) )
 				EOFind=true;
 		}
 	//cout <<"still searching...  "<<qPrintable( itFind->getHeading())<<endl;
@@ -1652,7 +1673,7 @@
 	while (cur) 
 	{
 		if (!cur->getURL().isEmpty()) urls.append( cur->getURL());
-		cur=next (cur,prev,selbi);
+		cur=nextBranch (cur,prev,true,selbi);
 	}	
 	return urls;
 }
@@ -1852,6 +1873,23 @@
 		setHideExport ( !selti->hideInExport() );
 }
 
+void VymModel::addTimestamp()	//FIXME-3 new function, localize
+{
+	BranchItem *selbi=addNewBranch();
+	if (selbi)
+	{
+		QDate today=QDate::currentDate();
+		QChar c='0';
+		selbi->setHeading (QString ("%1-%2-%3")
+			.arg(today.year(),4,10,c)
+			.arg(today.month(),2,10,c)
+			.arg(today.day(),2,10,c));
+		emitDataHasChanged ( selbi);	//FIXME-3 maybe emit signal from TreeItem? 
+		reposition();
+		select (selbi);
+	}
+}
+
 
 void VymModel::copy()	
 {
@@ -2283,6 +2321,8 @@
 {
 	if (branch && dst)
 	{
+		unselect();
+
 		emit (layoutAboutToBeChanged() );
 		BranchItem *branchpi=(BranchItem*)branch->parent();
 		// Remove at current position
@@ -2365,7 +2405,7 @@
 	BranchItem *selbi=getSelectedBranch();
 
 	if (selbi)
-	{
+	{	// Delete branch
 		unselect();
 		saveStateRemovingPart (selbi, QString ("Delete %1").arg(getObjectName(selbi)));
 
@@ -2379,7 +2419,7 @@
 	}
 	TreeItem *ti=getSelectedItem();
 	if (ti)
-	{
+	{	// Delete other item
 		TreeItem *pi=ti->parent();
 		if (!pi) return;
 		if (ti->getType()==TreeItem::Image || ti->getType()==TreeItem::Attribute)
@@ -2614,18 +2654,28 @@
 				cur->toggleScroll(); 
 				emitDataHasChanged (cur);
 		}
-			cur=next (cur,prev,selbi);
+			cur=nextBranch (cur,prev,true,selbi);
 		}	
 		updateActions();
 		reposition();
 	}	
 }
 
-void VymModel::emitExpandAll()
+void VymModel::emitExpandAll()	
 {
 	emit (expandAll() );
 }
 
+void VymModel::emitExpandOneLevel()	
+{
+	emit (expandOneLevel () );
+}
+
+void VymModel::emitCollapseOneLevel()	
+{
+	emit (collapseOneLevel () );
+}
+
 void VymModel::toggleStandardFlag (const QString &name, FlagRow *master)
 {
 	BranchItem *bi=getSelectedBranch();
@@ -2673,7 +2723,6 @@
 
 void VymModel::colorBranch (QColor c)	
 {
-cout << "VM::colBranch\n";
 	BranchItem *selbi=getSelectedBranch();
 	if (selbi)
 	{
@@ -2705,7 +2754,7 @@
 		while (cur) 
 		{
 			cur->setHeadingColor(c); // color links, color children
-			cur=next (cur,prev,selbi);
+			cur=nextBranch (cur,prev,true,selbi);
 		}	
 	mapScene->update();
 	}
@@ -2883,7 +2932,7 @@
 	while (cur) 
 	{
 		if (!cur->getVymLink().isEmpty()) links.append( cur->getVymLink());
-		cur=next (cur,prev,selbi);
+		cur=nextBranch (cur,prev,true,selbi);
 	}	
 	return links;
 }
@@ -2933,7 +2982,7 @@
 // Scripting
 //////////////////////////////////////////////
 
-void VymModel::parseAtom(const QString &atom)
+QVariant VymModel::parseAtom(const QString &atom, bool &noErr, QString &errorMsg)
 {
 	TreeItem* selti=getSelectedItem();
 	BranchItem *selbi=getSelectedBranch();
@@ -2941,6 +2990,7 @@
 	double x,y;
 	int n;
 	bool b,ok;
+	QVariant returnValue;
 
 	// Split string s into command and parameters
 	parser.parseAtom (atom);
@@ -3248,6 +3298,14 @@
 			exportXML (fname,false);
 		}
 	/////////////////////////////////////////////////////////////////////
+	} else if (com=="getHeading")
+	{ 
+		if (!selti)
+		{
+			parser.setError (Aborted,"Nothing selected");
+		} else if (parser.checkParCount(0))
+			returnValue=selti->getHeading();
+	/////////////////////////////////////////////////////////////////////
 	} else if (com=="importDir")
 	{
 		if (!selti)
@@ -3567,6 +3625,21 @@
 				parser.setError (Aborted,"Could not select latest added object ");
 		}	
 	/////////////////////////////////////////////////////////////////////
+	} else if (com=="setFlag")
+	{
+		if (!selti )
+		{
+			parser.setError (Aborted,"Nothing selected");
+		} else if (! selbi )
+		{				  
+			parser.setError (Aborted,"Type of selection is not a branch");
+		} else if (parser.checkParCount(1))
+		{
+			s=parser.parString(ok,0);
+			if (ok) 
+				selbi->activateStandardFlag(s);
+		}
+	/////////////////////////////////////////////////////////////////////
 	} else if (com=="setFrameType")
 	{
 		if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
@@ -3627,57 +3700,22 @@
 			if (ok) setFrameBorderWidth (n);
 		}	
 	/////////////////////////////////////////////////////////////////////
-	} else if (com=="setMapAuthor")
-	{
-		if (parser.checkParCount(1))
-		{
-			s=parser.parString(ok,0);
-			if (ok) setAuthor (s);
-		}	
-	/////////////////////////////////////////////////////////////////////
-	} else if (com=="setMapComment")
-	{
-		if (parser.checkParCount(1))
-		{
-			s=parser.parString(ok,0);
-			if (ok) setComment(s);
-		}	
-	/////////////////////////////////////////////////////////////////////
-	} else if (com=="setMapBackgroundColor")
+	/* FIXME-2  else if (com=="setFrameType")
 	{
 		if (!selti )
 		{
 			parser.setError (Aborted,"Nothing selected");
-		} else if (! selbi )
+		} else if (! selb )
 		{				  
 			parser.setError (Aborted,"Type of selection is not a branch");
 		} else if (parser.checkParCount(1))
 		{
-			QColor c=parser.parColor (ok,0);
-			if (ok) setMapBackgroundColor (c);
-		}	
+			s=parser.parString(ok,0);
+			if (ok) 
+				setFrameType (s);
+		}
 	/////////////////////////////////////////////////////////////////////
-	} else if (com=="setMapDefLinkColor")
-	{
-		if (!selti )
-		{
-			parser.setError (Aborted,"Nothing selected");
-		} else if (! selbi )
-		{				  
-			parser.setError (Aborted,"Type of selection is not a branch");
-		} else if (parser.checkParCount(1))
-		{
-			QColor c=parser.parColor (ok,0);
-			if (ok) setMapDefLinkColor (c);
-		}	
-	/////////////////////////////////////////////////////////////////////
-	} else if (com=="setMapLinkStyle")
-	{
-		if (parser.checkParCount(1))
-		{
-			s=parser.parString (ok,0);
-			if (ok) setMapLinkStyle(s);
-		}	
+	} else*/ 
 	/////////////////////////////////////////////////////////////////////
 	} else if (com=="setHeading")
 	{
@@ -3750,6 +3788,73 @@
 			if (ok) setHideLinkUnselected(b);
 		}
 	/////////////////////////////////////////////////////////////////////
+	} else if (com=="setMapAuthor")
+	{
+		if (parser.checkParCount(1))
+		{
+			s=parser.parString(ok,0);
+			if (ok) setAuthor (s);
+		}	
+	/////////////////////////////////////////////////////////////////////
+	} else if (com=="setMapComment")
+	{
+		if (parser.checkParCount(1))
+		{
+			s=parser.parString(ok,0);
+			if (ok) setComment(s);
+		}	
+	/////////////////////////////////////////////////////////////////////
+	} else if (com=="setMapBackgroundColor")
+	{
+		if (!selti )
+		{
+			parser.setError (Aborted,"Nothing selected");
+		} else if (! selbi )
+		{				  
+			parser.setError (Aborted,"Type of selection is not a branch");
+		} else if (parser.checkParCount(1))
+		{
+			QColor c=parser.parColor (ok,0);
+			if (ok) setMapBackgroundColor (c);
+		}	
+	/////////////////////////////////////////////////////////////////////
+	} else if (com=="setMapDefLinkColor")
+	{
+		if (!selti )
+		{
+			parser.setError (Aborted,"Nothing selected");
+		} else if (! selbi )
+		{				  
+			parser.setError (Aborted,"Type of selection is not a branch");
+		} else if (parser.checkParCount(1))
+		{
+			QColor c=parser.parColor (ok,0);
+			if (ok) setMapDefLinkColor (c);
+		}	
+	/////////////////////////////////////////////////////////////////////
+	} else if (com=="setMapLinkStyle")
+	{
+		if (parser.checkParCount(1))
+		{
+			s=parser.parString (ok,0);
+			if (ok) setMapLinkStyle(s);
+		}	
+	/////////////////////////////////////////////////////////////////////
+	} else if (com=="setNote")
+	{
+		if (!selti )
+		{
+			parser.setError (Aborted,"Nothing selected");
+		} else if (! selbi )
+		{				  
+			parser.setError (Aborted,"Type of selection is not a branch");
+		} else if (parser.checkParCount(1))
+		{
+			s=parser.parString (ok,0);
+			if (ok) 
+				setNote (s);
+		}	
+	/////////////////////////////////////////////////////////////////////
 	} else if (com=="setSelectionColor")
 	{
 		if (parser.checkParCount(1))
@@ -3785,39 +3890,7 @@
 			s=parser.parString (ok,0);
 			if (ok) setVymLink(s);
 		}	
-	}
-	/////////////////////////////////////////////////////////////////////
-	else if (com=="setFlag")
-	{
-		if (!selti )
-		{
-			parser.setError (Aborted,"Nothing selected");
-		} else if (! selbi )
-		{				  
-			parser.setError (Aborted,"Type of selection is not a branch");
-		} else if (parser.checkParCount(1))
-		{
-			s=parser.parString(ok,0);
-			if (ok) 
-				selbi->activateStandardFlag(s);
-		}
-	/////////////////////////////////////////////////////////////////////
-	} else /* FIXME-2 if (com=="setFrameType")
-	{
-		if (!selti )
-		{
-			parser.setError (Aborted,"Nothing selected");
-		} else if (! selb )
-		{				  
-			parser.setError (Aborted,"Type of selection is not a branch");
-		} else if (parser.checkParCount(1))
-		{
-			s=parser.parString(ok,0);
-			if (ok) 
-				setFrameType (s);
-		}
-	/////////////////////////////////////////////////////////////////////
-	} else*/ if (com=="sortChildren")
+	} else if (com=="sortChildren")
 	{
 		if (!selti )
 		{
@@ -3894,21 +3967,34 @@
 	{
 		// setChanged();  FIXME-2 should not be called e.g. for export?!
 		reposition();
+		errorMsg.clear();
+		noErr=true;
 	}	
 	else	
 	{
 		// TODO Error handling
 		qWarning("VymModel::parseAtom: Error!");
+
 		qWarning(parser.errorMessage());
+		noErr=false;
+		errorMsg=parser.errorMessage();
 	} 
+	return returnValue;
 }
 
 void VymModel::runScript (QString script)
 {
 	parser.setScript (script);
 	parser.runScript();
-	while (parser.next() ) 
-		parseAtom(parser.getAtom());
+	QVariant r;
+	bool noErr=true;
+	QString errMsg;
+	while (parser.next() && noErr) 
+	{
+		r=parseAtom(parser.getAtom(),noErr,errMsg);
+		if (!noErr)	//FIXME-3 need dialog box here
+			cout << "VM::runScript aborted:\n"<<errMsg.toStdString()<<endl;
+	}	
 }
 
 void VymModel::setExportMode (bool b)
@@ -4166,12 +4252,12 @@
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
 	BranchObj *bo;
-	next (cur,prev);
+	nextBranch (cur,prev);
 	while (cur) 
 	{
 		bo=(BranchObj*)(cur->getLMO() );
 		bo->setLinkStyle(bo->getDefLinkStyle(cur->parent() ));	//FIXME-3 better emit dataCHanged and leave the changes to View
-		cur=next(cur,prev);
+		cur=nextBranch(cur,prev);
 	}
 	reposition();
 }
@@ -4194,12 +4280,12 @@
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
 	BranchObj *bo;
-	cur=next(cur,prev);
+	cur=nextBranch(cur,prev);
 	while (cur) 
 	{
 		bo=(BranchObj*)(cur->getLMO() );
 		bo->setLinkColor();
-		next(cur,prev);
+		nextBranch(cur,prev);
 	}
 	updateActions();
 }
@@ -4210,12 +4296,12 @@
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
 	BranchObj *bo;
-	cur=next(cur,prev);
+	cur=nextBranch(cur,prev);
 	while (cur) 
 	{
 		bo=(BranchObj*)(cur->getLMO() );
 		bo->setLinkColor();
-		cur=next(cur,prev);
+		cur=nextBranch(cur,prev);
 	}
 }
 
@@ -4234,12 +4320,12 @@
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
 	BranchObj *bo;
-	cur=next(cur,prev);
+	cur=nextBranch(cur,prev);
 	while (cur) 
 	{
 		bo=(BranchObj*)(cur->getLMO() );
 		bo->setLinkColor();
-		next(cur,prev);
+		nextBranch(cur,prev);
 	}
 }
 
@@ -4544,8 +4630,11 @@
 		QString t;
 		in >>t;
 		if (debug)
-			cout << "  t="<<qPrintable (t)<<endl;
-		parseAtom (t);
+			cout << "VymModel::readData  command="<<qPrintable (t)<<endl;
+		bool noErr;
+		QString errMsg;
+		parseAtom (t,noErr,errMsg);
+
 	}
 	return;
 }
@@ -4717,8 +4806,11 @@
 
 void VymModel::unselect()
 {
-	lastSelectString=getSelectString();
-	selModel->clearSelection();
+	if (!selModel->selectedIndexes().isEmpty())
+	{
+		lastSelectString=getSelectString();
+		selModel->clearSelection();
+	}
 }	
 
 bool VymModel::reselect()
diff -r 338ebdc9b947 -r 14f2b1b15242 vymmodel.h
--- a/vymmodel.h	Fri Oct 02 14:31:03 2009 +0000
+++ b/vymmodel.h	Fri Nov 13 08:32:03 2009 +0000
@@ -254,11 +254,14 @@
 public:
 	void setHeading(const QString &);		//!< Set heading of item	
 	QString getHeading ();					//!< Get heading of item
+	void setNote(const QString &s);			//!< Set note text
+	QString getNote();						//!< Get note text
 
 private:
 	BranchItem* findCurrent;				// next object in find process
 	BranchItem* findPrevious;				// next object in find process
 	bool EOFind;							// true, if search failed
+
 public:
     BranchItem* findText(QString,bool);		// Find object
     void findReset();						// Reset Search
@@ -284,6 +287,8 @@
 	/*! Should object be hidden in exports (clouded)? */
 	void toggleHideExport();		
 
+	void addTimestamp();		
+
     void copy();						//!< Copy to clipboard
 private:	
     void pasteNoSave(const int &n);		//!< paste clipboard to branch
@@ -358,8 +363,12 @@
     void toggleScroll();
     void unscrollChildren();
 	void emitExpandAll();
+	void emitExpandOneLevel();
+	void emitCollapseOneLevel();
 signals:	
 	void expandAll();
+	void expandOneLevel();
+	void collapseOneLevel();
 
 public:	
 	void toggleStandardFlag (const QString &name, FlagRow *master=NULL);
@@ -392,7 +401,7 @@
 public:	
 
 	/* \brief Process one command and its parameters */
-    void parseAtom (const QString &atom);	
+    QVariant parseAtom (const QString &atom, bool &noError, QString &errorMsg);	
 
 	/* \brief Runs the script */
 	void runScript (QString script);
diff -r 338ebdc9b947 -r 14f2b1b15242 vymview.cpp
--- a/vymview.cpp	Fri Oct 02 14:31:03 2009 +0000
+++ b/vymview.cpp	Fri Nov 13 08:32:03 2009 +0000
@@ -3,6 +3,7 @@
 #include <iostream>
 using namespace std;
 
+#include "branchitem.h"
 #include "mainwindow.h"
 #include "mapeditor.h"
 #include "treeeditor.h"
@@ -22,11 +23,12 @@
 	treeEditor->setColumnWidth (0,150);
 	treeEditor->setAnimated (true);
 
-	proxySelModel=treeEditor->selectionModel();
+	// FIXME-2 use proxySelModel=treeEditor->selectionModel();
 	selModel=new QItemSelectionModel (model);
 
 	//model->setSelectionModel (proxySelModel);
 	model->setSelectionModel (selModel);
+	treeEditor->setSelectionModel (selModel);
 
 	// Create good old MapEditor
 	mapEditor=model->getMapEditor();
@@ -35,23 +37,27 @@
 	// Connect selections
 
 		// Proxymodel changed
+		/*
 		connect (
 			proxySelModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
 			this,SLOT (changeProxySelection(const QItemSelection &,const QItemSelection &)));
+*/
 
-		// Model changed	
+		// Selection in Model changed	
 		connect (
 			selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
 			this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
 
-		connect (
-			model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
-			mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
-			//FIXME-3 above and below necessary???
+		// Tell MapEditor to update selection
 		connect (
 			selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
 			mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
 
+		// FIXME-2 testing, if that reenables updating selbox during animation
+		connect (
+			model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
+			mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
+
 	// Connect data changed signals	
 	connect (
 		model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)), 
@@ -70,6 +76,14 @@
 		this, SLOT (expandAll () ) );
 		
 	connect (
+		model, SIGNAL (expandOneLevel() ),
+		this, SLOT (expandOneLevel() ) );
+		
+	connect (
+		model, SIGNAL (collapseOneLevel() ),
+		this, SLOT (collapseOneLevel() ) );
+		
+	connect (
 		model, SIGNAL (showSelection() ),
 		this, SLOT (showSelection() ) );
 		
@@ -112,10 +126,22 @@
 	// Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
 	mainWindow->changeSelection (model,newsel,oldsel);	// FIXME-5 maybe connect VymModel <-> MainWindow directly?
 	// would require to also get current model in mainWindow
-	proxySelModel->select (
-		treeEditor->getProxyModel()->mapSelectionFromSource (newsel),
-		QItemSelectionModel::ClearAndSelect );
-	showSelection();
+
+	cout << "VV::changeSelection   newsel.count="<<newsel.indexes().count()<<endl;
+
+	if (newsel.indexes().count()>0)
+	{
+
+	/* FIXME-2 use proxymodel
+		proxySelModel->select (
+			treeEditor->getProxyModel()->mapSelectionFromSource (newsel),
+			QItemSelectionModel::ClearAndSelect );
+		*/
+		QModelIndex ix=newsel.indexes().first();
+		selModel->setCurrentIndex (ix,QItemSelectionModel::ClearAndSelect  );
+		treeEditor->setCurrentIndex (ix);
+		showSelection();
+	}
 }
 
 void VymView::changeProxySelection (const QItemSelection &newsel, const QItemSelection &oldsel)
@@ -123,9 +149,22 @@
 	// Notify mainwindow to update satellites, but map selection to 
 	// original model first
 
+	cout << "VV::changeProxySelection   newsel.count="<<newsel.indexes().count()<<endl;
+	if (!newsel.indexes().isEmpty())
+	{
+	/* FIXME-2 need to set current, too
+	*/
+		proxySelModel->setCurrentIndex (
+			newsel.indexes().first(),
+			QItemSelectionModel::ClearAndSelect );
+	treeEditor->setCurrentIndex (newsel.indexes().first() );
+	}
+
 	// Re-emit but map selection first
-	selModel->select (treeEditor->getProxyModel()->mapSelectionToSource (newsel),
+	selModel->select (
+		treeEditor->getProxyModel()->mapSelectionToSource (newsel),
 		QItemSelectionModel::ClearAndSelect );
+
 	showSelection();
 }
 
@@ -134,6 +173,85 @@
 	treeEditor->expandAll();
 }
 
+void VymView::expandOneLevel()
+{
+	int level=999999;
+	int d;
+	BranchItem *cur=NULL;
+	BranchItem *prev=NULL;
+	QModelIndex pix;
+
+	// Find level to expand
+	model->nextBranch(cur,prev);
+	while (cur) 
+	{
+		// FIXME-2 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
+		pix=model->index (cur);
+		d=cur->depth();
+		if (!treeEditor->isExpanded(pix) && d < level)
+			level=d;
+		model->nextBranch(cur,prev);	
+	}
+
+	// Expand all to level
+	cur=NULL;
+	prev=NULL;
+	model->nextBranch(cur,prev);
+	while (cur) 
+	{
+		// FIXME-2 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
+		pix=model->index (cur);
+		d=cur->depth();
+		if (!treeEditor->isExpanded(pix) && d <= level && cur->branchCount()>0)
+			treeEditor->setExpanded(pix,true);
+		model->nextBranch(cur,prev);	
+	}
+	/* FIXME-3 optimize expanding by using flat version of next
+	model->nextBranch(cur,prev,false);
+	while (cur) 
+	{
+		cout << "ok: "<<cur->getHeadingStd()<<endl./re/videochristinaprison1_wmvl.wmv
+;
+		model->nextBranch(cur,prev,false);	
+	}
+	*/
+}
+
+void VymView::collapseOneLevel()
+{
+	int level=-1;
+	int d;
+	BranchItem *cur=NULL;
+	BranchItem *prev=NULL;
+	QModelIndex pix;
+
+	// Find level to collapse
+	model->nextBranch(cur,prev);
+	while (cur) 
+	{
+		// FIXME-2 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
+		pix=model->index (cur);
+		d=cur->depth();
+		if (treeEditor->isExpanded(pix) && d > level)
+			level=d;
+		model->nextBranch(cur,prev);	
+	}
+
+	// collapse all to level
+	cur=NULL;
+	prev=NULL;
+	model->nextBranch(cur,prev);
+	while (cur) 
+	{
+		// FIXME-2 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
+		pix=model->index (cur);
+		d=cur->depth();
+		if (treeEditor->isExpanded(pix) && d >= level)
+			treeEditor->setExpanded(pix,false);
+		model->nextBranch(cur,prev);	
+	}
+}
+
 void VymView::showSelection()
 {
 	QModelIndex ix=model->getSelectedIndex();
diff -r 338ebdc9b947 -r 14f2b1b15242 vymview.h
--- a/vymview.h	Fri Oct 02 14:31:03 2009 +0000
+++ b/vymview.h	Fri Nov 13 08:32:03 2009 +0000
@@ -25,6 +25,8 @@
 	void changeSelection (const QItemSelection &newSel, const QItemSelection &delSel);
 	void changeProxySelection (const QItemSelection &newSel, const QItemSelection &delSel);
 	void expandAll ();
+	void expandOneLevel ();
+	void collapseOneLevel ();
 	void showSelection ();
 
 private: