# HG changeset patch
# User insilmaril
# Date 1118089662 0
# Node ID 67a91e28b30f32a7553ec45151c8ea942712b4bc
# Parent  270593ab83b25c23a1ddf4a8e24b0f43f53f2948
1.6.8 started API to speedup undos

diff -r 270593ab83b2 -r 67a91e28b30f api.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api.cpp	Mon Jun 06 20:27:42 2005 +0000
@@ -0,0 +1,38 @@
+#include "api.h"
+
+#include <qregexp.h>
+
+void API::parseCommand (const QString &s,QString &command,QString
+&param)
+{
+	param="";
+	command="";
+	QRegExp re;
+	int pos;
+
+	// Get command
+	re.setPattern ("(.*)\\s");
+	re.setMinimal (false);
+	pos=re.search (s);
+	if (pos>=0)
+		command=re.cap(1);
+
+	// Get parameters
+	re.setPattern ("\\((.*)\\)");
+	pos=re.search (s);
+	if (pos>=0)
+		param=re.cap (1);
+}
+
+void API::getString (const QString &s, QString &rs)
+{
+	// return the string in s, this could be also stored in
+	// a variable later
+	QRegExp re("\"(.*)\"");
+	int pos=re.search (s);
+	if (pos>=0)
+		rs=re.cap (1);
+	else	
+		rs="";
+
+}
\ No newline at end of file
diff -r 270593ab83b2 -r 67a91e28b30f api.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api.h	Mon Jun 06 20:27:42 2005 +0000
@@ -0,0 +1,13 @@
+#ifndef API_H
+#define API_H
+
+#include <qstring.h>
+
+class API
+{
+public:
+	void parseCommand (const QString&, QString &, QString &);
+	void getString (const QString&, QString &);
+};
+
+#endif
diff -r 270593ab83b2 -r 67a91e28b30f demos/todo.vym
Binary file demos/todo.vym has changed
diff -r 270593ab83b2 -r 67a91e28b30f mainwindow.cpp
--- a/mainwindow.cpp	Mon May 30 05:39:10 2005 +0000
+++ b/mainwindow.cpp	Mon Jun 06 20:27:42 2005 +0000
@@ -927,13 +927,13 @@
 	// This will be populated "on demand" in MapEditor::updateActions
 	branchContextMenu->insertSeparator();	
 	branchLinksContextMenu =new QPopupMenu (this);
-	branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
-	connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
-	
 	branchLinksContextMenuDup =new QPopupMenu (this);
 	branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
 	connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
 
+	branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
+	connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
+	
 	// Context menu for floatimage
 	floatimageContextMenu =new QPopupMenu (this);
 	saveImageFormatMenu=new QPopupMenu (this);
diff -r 270593ab83b2 -r 67a91e28b30f mapeditor.cpp
--- a/mapeditor.cpp	Mon May 30 05:39:10 2005 +0000
+++ b/mapeditor.cpp	Mon Jun 06 20:27:42 2005 +0000
@@ -22,6 +22,7 @@
 
 #include "version.h"
 
+#include "api.h"
 #include "xml.h"
 #include "texteditor.h"
 #include "linkablemapobj.h"
@@ -571,6 +572,11 @@
 
 void MapEditor::saveState(const SaveMode &mode, LinkableMapObj *part)
 {
+	saveState (mode,part,"");
+}
+
+void MapEditor::saveState(const SaveMode &mode, LinkableMapObj *part, const QString &undoCom)
+{
 	// all binary data is saved in bakMapDir (created in Constructor)
 	// the xml data itself is kept in memory in backupXML
 	// 
@@ -580,11 +586,20 @@
 
 	if (mode==PartOfMap && part && (typeid(*part) == typeid (BranchObj) ) ) 
 	{
-		// Writing a vympart only is useful for BranchObj
-		undoSelection=part;
-		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),PartOfMap);
+		// So far we only test undoCommands for BranchObjs
+		undoCommand=undoCom;
+		if (undoCommand!="")
+		{
+			undoSelection=part;
+		} else
+		{
+			// Writing a vympart only is useful for BranchObj
+			undoSelection=part;
+			backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),PartOfMap);
+		}
 	} else	
 	{
+		undoCommand="";
 		undoSelection=NULL;
 		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),CompleteMap);
 	}	
@@ -1105,37 +1120,50 @@
 			selection=NULL;
 		}	
 		
-		mapBuilderHandler handler;
-		QXmlInputSource source;
-		source.setData(backupXML);
-		QXmlSimpleReader reader;
-		reader.setContentHandler( &handler );
-		reader.setErrorHandler( &handler );
-		handler.setMapEditor( this );
-		handler.setTmpDir ( bakMapDir );	// needed to load files with rel. path
-		if (undoSelection)
+		if (undoCommand!="" && undoSelection)
 		{
+			// We don't need to parse XML backup, but
+			// do the undoCommand
 			selection=undoSelection;
 			selection->select();
-			handler.setLoadMode (ImportReplace);
-
-		} else	
+			parseTest (undoCommand);
+
+		} else
 		{
-			mapCenter->clear();
-			handler.setLoadMode (NewMap);
-		}	
-		blockreposition=true;
-		bool ok = reader.parse( source );
-		blockreposition=false;
-		if ( ok ) 
-			mapCenter->reposition();
-			
-		else 
-		{	
-			// This should never ever happen
-			QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ),
-								   tr( handler.errorProtocol() )+" in "+backupXML );
-		}
+			// We need to parse saved XML data
+			mapBuilderHandler handler;
+			QXmlInputSource source;
+			source.setData(backupXML);
+			QXmlSimpleReader reader;
+			reader.setContentHandler( &handler );
+			reader.setErrorHandler( &handler );
+			handler.setMapEditor( this );
+			handler.setTmpDir ( bakMapDir );	// needed to load files with rel. path
+			if (undoSelection)
+			{
+				selection=undoSelection;
+				selection->select();
+				handler.setLoadMode (ImportReplace);
+
+			} else	
+			{
+				mapCenter->clear();
+				handler.setLoadMode (NewMap);
+			}	
+			blockreposition=true;
+			bool ok = reader.parse( source );
+			blockreposition=false;
+			if ( ok ) 
+				mapCenter->reposition();
+				
+			else 
+			{	
+				// This should never ever happen
+				QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ),
+									   tr( handler.errorProtocol() )+" in "+backupXML );
+			}
+		} // restoring saved version	
+
 		// Undo not longer available now
 		actionEditUndo->setEnabled (false);
 		undoSelection=false;
@@ -1307,7 +1335,7 @@
 	if (typeid(*selection) == typeid(BranchObj)  ) 
 	{
 		setChanged();
-		saveState(PartOfMap,selection->getParObj());
+		saveState(PartOfMap,selection,"moveBranchDown ()");
 		bo=(BranchObj*)(selection);
 		par=(BranchObj*)(bo->getParObj());
 		selection->unselect();
@@ -1328,7 +1356,7 @@
 	if (typeid(*selection) == typeid(BranchObj)  ) 
 	{
 		setChanged();
-		saveState(PartOfMap,selection->getParObj());
+		saveState(PartOfMap,selection,"moveBranchUp ()");
 		bo=(BranchObj*)(selection);
 		par=(BranchObj*)(bo->getParObj());
 		selection->unselect(); 
@@ -2779,9 +2807,32 @@
 	}
 }
 
+#include "api.h"
+
 void MapEditor::testFunction()
 {
 	cout << "MapEditor::testFunction() called\n";
+	if (selection && 
+		(typeid(*selection) == typeid(BranchObj)) )
+	{
+		QString s=((BranchObj*)(selection))->getHeading();
+		parseTest (s);
+	}
+}
+
+void MapEditor::parseTest(const QString &s)
+{
+	API api;
+	QString c,p,p0;
+	api.parseCommand (s,c,p);
+	if (c==QString("moveBranchUp"))
+		moveBranchUp();
+	else if (c=="moveBranchDown")
+		moveBranchDown();
+	else if (c=="select")
+		select (p);
+	else
+		cout << "Don't know about command \""<<s<<"\".\n";
 }
 
 void MapEditor::ensureSelectionVisible()
diff -r 270593ab83b2 -r 67a91e28b30f mapeditor.h
--- a/mapeditor.h	Mon May 30 05:39:10 2005 +0000
+++ b/mapeditor.h	Mon Jun 06 20:27:42 2005 +0000
@@ -33,6 +33,7 @@
 	&,SaveMode);
     void saveState();		// save actual state to backup
     void saveState(const SaveMode&, LinkableMapObj *);
+    void saveState(const SaveMode&, LinkableMapObj *, const QString &);
 
 private slots:
     void finishedLineEditNoSave();
@@ -137,6 +138,7 @@
 	void followXLink (int);
 	void editXLink (int);
     void testFunction();				// FIXME just testing
+    void parseTest(const QString &);	// FIXME just testing
 
 protected:
 	void ensureSelectionVisible();		
@@ -184,6 +186,7 @@
 	bool mapUnsaved;				// Flag if map should be saved
     QString backupXML;				// backup (XML) for undo
 	LinkableMapObj* undoSelection;	// replace this LMO with vympart from backup
+	QString undoCommand;			// FIXME testing
 									// if != NULL
 
 	bool printFrame;			// Print frame around map
diff -r 270593ab83b2 -r 67a91e28b30f tex/vym.tex
--- a/tex/vym.tex	Mon May 30 05:39:10 2005 +0000
+++ b/tex/vym.tex	Mon Jun 06 20:27:42 2005 +0000
@@ -33,7 +33,6 @@
 \begin{document}
 \title{VYM \\ -- \\View Your Mind}
 \author{\textcopyright Uwe Drechsel  }
-%\date{September 26, 2002}
 
 \maketitle
 
@@ -582,6 +581,7 @@
 \section{Hello world}
 \vym can export its maps in various formats and can import data from
 outside (though import is still limited at the moment).
+Also parts of a map can be exported.
 
 \subsection{Export}
 The format in which the map will be exported can be chosen with
@@ -671,6 +671,12 @@
 on. This is useful if e.g. for a website several combined maps have to
 be stored in the same directory.
 
+\subsubsection*{Export a part of a map}
+Select a branch you want to export together with its childs, than open
+the context menu and choose {\em Save Selection}. This will create a
+file with the postfix {\tt .vyp}, which is an abbreviation for \lq vym
+part\rq.
+
 \subsection{Import} 
 At the moment \vym can read a directory structure. This is mainly for
 testing \vym e.g. to easily create huge maps used for benchmarks (yes,
@@ -679,6 +685,8 @@
 Many other applications meanwhile can export their data using XML, so
 volunteers to write import filters are welcome.
 
+Also parts of a vym map ({\tt .vyp}) can be imported.
+
 \subsection{File format}
 \vym maps usually have the postfix "{\tt .vym}" and represent a
 compressed archive of data. If you want to have a
@@ -698,12 +706,34 @@
 	zip -r vymfile.vym .
 \end{verbatim}
 
+\subsubsection*{Importa part of a map}
+Select a branch where you want to add a previously save part of a map
+({\tt .vyp}), then open
+the context menu and choose {\em Add \ra Import}. For the import you can
+choose between {\em Import Add} and {\em Import Replace}: The imported
+data will be added after the selection resp. replace the selection.
 
 %TODO
 %\subsubsection{Menus}
 %\subsubsection{Keyboard shortcuts}
 %Where does vym save its settings? -> ~/.qt/vymrc
 
+
+\section{\vym on Mac OS X}
+\subsection{Overview}
+Basically there are two ways to run \vym on Macs:
+\subsubsection{QT Mac Edition:}
+	\vym here provides the well known Mac look and feel.  \vym is
+	available as zipped Mac OS X application. It has been compiled and
+	tested in Mac~OS~10.3, but should also work on Tiger. It is using
+	the Mac version of Trolltechs QT library.  
+\subsubsection{X11}
+	\vym can also be run using the Linux version, but then menus and
+	handling will also be those of the Linux version e.g. The menu bar
+	will look different. 
+
+%TODO  Concept on Mac   context menu, shortcuts...
+
 \section{History of \vym}
 \subsection{Future}
 There are lots of features which might find their way into \vym.
@@ -729,7 +759,7 @@
 1.6.5	& -	&	removing a branch and keeping its childs	& 2005-05-19 \\
         & -	&	removing childs of a branch			& \\
         & -	&	insert branch and make selection its child& \\
-        & -	&	restructured branch context menu	& \\
+        & -	&	restructured branch context menu	
 				in a basic version (straight line)	& 2005-04-15\\
         & -	&	New shortcuts  for use on Mac OS X	& \\
         & -	&	Importing directories generates vymlinks now & \\
diff -r 270593ab83b2 -r 67a91e28b30f version.h
--- a/version.h	Mon May 30 05:39:10 2005 +0000
+++ b/version.h	Mon Jun 06 20:27:42 2005 +0000
@@ -1,7 +1,7 @@
 #ifndef VERSION_H 
 #define VERSION_H
 
-#define __VYM_VERSION__ "1.6.7"
-#define __BUILD_DATE__ "May 27, 2005"
+#define __VYM_VERSION__ "1.6.8"
+#define __BUILD_DATE__ "June 06, 2005"
 
 #endif
diff -r 270593ab83b2 -r 67a91e28b30f vym.pro
--- a/vym.pro	Mon May 30 05:39:10 2005 +0000
+++ b/vym.pro	Mon Jun 06 20:27:42 2005 +0000
@@ -3,7 +3,8 @@
 
 CONFIG	+= qt warn_on release
 
-HEADERS	+= branchobj.h \
+HEADERS	+= api.h \
+	branchobj.h \
 	exports.h \
 	findwindow.h \
 	flagobj.h \
@@ -30,7 +31,8 @@
 	settings.h \
 	options.h
 
-SOURCES	+= branchobj.cpp \
+SOURCES	+= api.cpp \
+	branchobj.cpp \
 	exports.cpp \
 	findwindow.cpp \
 	flagobj.cpp \