# HG changeset patch
# User insilmaril
# Date 1183547115 0
# Node ID 16d3598f611fb111550c565f543de2320024a5f9
# Parent  322402d9f9f911da90f710d4bdcf405db789b561
Version 1.9.0

diff -r 322402d9f9f9 -r 16d3598f611f mainwindow.cpp
--- a/mainwindow.cpp	Wed Jul 04 11:05:11 2007 +0000
+++ b/mainwindow.cpp	Wed Jul 04 11:05:15 2007 +0000
@@ -202,9 +202,9 @@
 	settings.setValue( "/version/builddate", vymBuildDate );
 
 	settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
-	settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
+	settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
 	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
-	settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
+	settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
 	settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
 	settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
 	settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
@@ -1451,16 +1451,16 @@
     a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
     a->setStatusTip( tr( "Edit branch after adding it" ));
 	a->setToggleAction(true);
-	a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
+	a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
 	settingsMenu->addAction (a);
-	actionSettingsAutoEdit=a;
+	actionSettingsAutoEditNewBranch=a;
 
     a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
     a->setStatusTip( tr( "Select branch after adding it" ));
 	a->setToggleAction(true);
-	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
+	a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
 	settingsMenu->addAction (a);
-	actionSettingsAutoSelectHeading=a;
+	actionSettingsAutoSelectNewBranch=a;
 	
     a= new QAction(tr( "Select existing heading","Settings action" ), this);
     a->setStatusTip( tr( "Select heading before editing" ));
@@ -2726,7 +2726,9 @@
 		lineedit->hide();
 		setFocus();
 #endif	
-		if (!prevSelection.isEmpty()) me->select(prevSelection);
+		if (!actionSettingsAutoSelectNewBranch->isOn() && 
+			!prevSelection.isEmpty()) 
+			me->select(prevSelection);
 		prevSelection="";
 	}
 }
@@ -2898,15 +2900,11 @@
 		else
 			return;
 
-		if (actionSettingsAutoEdit->isOn())
+		if (actionSettingsAutoEditNewBranch->isOn())
 		{
 			editHeading();
 			return;
 		}	
-			/*
-		if (!actionSettingsAutoSelectHeading->isOn())
-			me->select(bo->getSelectString());
-			*/	
 		if (!prevSelection.isEmpty()) 
 		{
 			me->select(prevSelection);
@@ -2929,9 +2927,9 @@
 		else
 			return;
 
-		if (actionSettingsAutoEdit->isOn())
+		if (actionSettingsAutoEditNewBranch->isOn())
 		{
-			if (!actionSettingsAutoSelectHeading->isOn())
+			if (!actionSettingsAutoSelectNewBranch->isOn())
 				prevSelection=bo->getSelectString();
 			editHeading();
 		}
@@ -2951,9 +2949,9 @@
 		else
 			return;
 
-		if (actionSettingsAutoEdit->isOn())
+		if (actionSettingsAutoEditNewBranch->isOn())
 		{
-			if (!actionSettingsAutoSelectHeading->isOn())
+			if (!actionSettingsAutoSelectNewBranch->isOn())
 				prevSelection=bo->getSelectString();
 			editHeading();
 		}
@@ -2973,9 +2971,9 @@
 		else
 			return;
 
-		if (actionSettingsAutoEdit->isOn())
+		if (actionSettingsAutoEditNewBranch->isOn())
 		{
-			if (!actionSettingsAutoSelectHeading->isOn())
+			if (!actionSettingsAutoSelectNewBranch->isOn())
 				prevSelection=bo->getSelectString();
 			editHeading();
 		}
@@ -3580,14 +3578,14 @@
 	return ModModeNone;
 }
 
-bool Main::autoEdit()
+bool Main::autoEditNewBranch()
 {
-	return actionSettingsAutoEdit->isOn();
+	return actionSettingsAutoEditNewBranch->isOn();
 }
 
-bool Main::autoSelectHeading()
+bool Main::autoSelectNewBranch()
 {
-	return actionSettingsAutoSelectHeading->isOn();
+	return actionSettingsAutoSelectNewBranch->isOn();
 }
 
 bool Main::useFlagGroups()
@@ -3684,7 +3682,7 @@
 	QStringList searchList;
 	QDir docdir;
 	#if defined(Q_OS_MACX)
-		searchList << "./vym.app/Contents";
+		searchList << "./vym.app/Contents/Resources/doc";
 	#else
 		// default path in SUSE LINUX
 		searchList <<"/usr/share/doc/packages/vym/doc";
diff -r 322402d9f9f9 -r 16d3598f611f mainwindow.h
--- a/mainwindow.h	Wed Jul 04 11:05:11 2007 +0000
+++ b/mainwindow.h	Wed Jul 04 11:05:15 2007 +0000
@@ -189,8 +189,8 @@
 	void updateSatellites(MapEditor *);
 	void updateActions();
 	ModMode getModMode();
-	bool autoEdit();
-	bool autoSelectHeading();
+	bool autoEditNewBranch();
+	bool autoSelectNewBranch();
 	bool useFlagGroups();
 	void setScript(const QString &);
 	void runScript(const QString &);
@@ -312,8 +312,8 @@
 	QAction *actionViewToggleSmoothPixmapTransform;
 	QAction* actionViewCenter;
 
-	QAction* actionSettingsAutoEdit;
-	QAction* actionSettingsAutoSelectHeading;
+	QAction* actionSettingsAutoEditNewBranch;
+	QAction* actionSettingsAutoSelectNewBranch;
 	QAction* actionSettingsAutoSelectText;
 	QAction* actionSettingsUseDelKey;
 	QAction* actionSettingsUseFlagGroups;
diff -r 322402d9f9f9 -r 16d3598f611f mapeditor.cpp
--- a/mapeditor.cpp	Wed Jul 04 11:05:11 2007 +0000
+++ b/mapeditor.cpp	Wed Jul 04 11:05:15 2007 +0000
@@ -482,7 +482,8 @@
 {
 	BranchObj *selb=xelection.getBranch();
 	QString s,t;
-	int x,y;
+	double x,y;
+	int n;
 	bool b,ok;
 
 	// Split string s into command and parameters
@@ -506,11 +507,11 @@
 			if (parser.checkParCount(pl))
 			{
 				if (parser.parCount()==0)
-					addNewBranchInt (-2);
+					addNewBranch (0);
 				else
 				{
-					y=parser.parInt (ok,0);
-					if (ok ) addNewBranchInt (y);
+					n=parser.parInt (ok,0);
+					if (ok ) addNewBranch (n);
 				}
 			}
 		}
@@ -560,9 +561,9 @@
 			if (parser.checkParCount(2))
 			{
 				t=parser.parString (ok,0);	// path to map
-				y=parser.parInt(ok,1);		// position
+				n=parser.parInt(ok,1);		// position
 				if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
-				addMapInsertInt(t,y);	
+				addMapInsertInt(t,n);	
 			}
 		}
 	/////////////////////////////////////////////////////////////////////
@@ -773,20 +774,20 @@
 					if (typeid(*dst) == typeid(BranchObj) ) 
 					{
 						// Get number in parent
-						x=parser.parInt (ok,1);
+						n=parser.parInt (ok,1);
 						if (ok)
 						{
-							selb->linkTo ((BranchObj*)(dst),x);
+							selb->linkTo ((BranchObj*)(dst),n);
 							xelection.update();
 						}	
 					} else if (typeid(*dst) == typeid(MapCenterObj) ) 
 					{
 						selb->linkTo ((BranchObj*)(dst),-1);
 						// Get coordinates of mainbranch
-						x=parser.parInt (ok,2);
+						x=parser.parDouble(ok,2);
 						if (ok)
 						{
-							y=parser.parInt (ok,3);
+							y=parser.parDouble(ok,3);
 							if (ok) 
 							{
 								selb->move (x,y);
@@ -866,10 +867,10 @@
 			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
 		} else if (parser.checkParCount(2))
 		{	
-			x=parser.parInt (ok,0);
+			x=parser.parDouble (ok,0);
 			if (ok)
 			{
-				y=parser.parInt (ok,1);
+				y=parser.parDouble (ok,1);
 				if (ok) move (x,y);
 			}
 		}	
@@ -886,10 +887,10 @@
 			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
 		} else if (parser.checkParCount(2))
 		{	
-			x=parser.parInt (ok,0);
+			x=parser.parDouble (ok,0);
 			if (ok)
 			{
-				y=parser.parInt (ok,1);
+				y=parser.parDouble (ok,1);
 				if (ok) moveRel (x,y);
 			}
 		}	
@@ -907,8 +908,8 @@
 			parser.setError (Aborted,"Type of selection is not a branch");
 		} else if (parser.checkParCount(1))
 		{	
-			x=parser.parInt (ok,0);
-			if (ok) pasteNoSave(x);
+			n=parser.parInt (ok,0);
+			if (ok) pasteNoSave(n);
 		}	
 	/////////////////////////////////////////////////////////////////////
 	} else if (com=="qa")
@@ -1049,6 +1050,17 @@
 				
 		}	
 	/////////////////////////////////////////////////////////////////////
+	} else if (com=="selectLatestAdded")
+	{
+		if (latestSelection.isEmpty() )
+		{
+			parser.setError (Aborted,"No latest added object");
+		} else
+		{	
+			if (!select (latestSelection))
+				parser.setError (Aborted,"Could not select latest added object "+latestSelection);
+		}	
+	/////////////////////////////////////////////////////////////////////
 	} else if (com=="setFrameType")
 	{
 		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
@@ -1093,8 +1105,8 @@
 		}
 		else if (parser.checkParCount(1))
 		{
-			x=parser.parInt(ok,0);
-			if (ok) setFramePadding(x);
+			n=parser.parInt(ok,0);
+			if (ok) setFramePadding(n);
 		}	
 	/////////////////////////////////////////////////////////////////////
 	} else if (com=="setFrameBorderWidth")
@@ -1105,8 +1117,8 @@
 		}
 		else if (parser.checkParCount(1))
 		{
-			x=parser.parInt(ok,0);
-			if (ok) setFrameBorderWidth (x);
+			n=parser.parInt(ok,0);
+			if (ok) setFrameBorderWidth (n);
 		}	
 	/////////////////////////////////////////////////////////////////////
 	} else if (com=="setMapAuthor")
@@ -2239,7 +2251,7 @@
 	}
 }
 
-void MapEditor::move(const int &x, const int &y)
+void MapEditor::move(const double &x, const double &y)
 {
 	LinkableMapObj *sel=xelection.single();
 	if (sel)
@@ -2257,7 +2269,7 @@
 
 }
 
-void MapEditor::moveRel (const int &x, const int &y)
+void MapEditor::moveRel (const double &x, const double &y)
 {
 	LinkableMapObj *sel=xelection.single();
 	if (sel)
@@ -2411,19 +2423,20 @@
 		{
 			// save scroll state. If scrolled, automatically select
 			// new branch in order to tmp unscroll parent...
-			return bo->addBranch();
+			newbo=bo->addBranch();
 			
 		}else if (num==-1)
 		{
 			num=bo->getNum()+1;
 			bo=(BranchObj*)bo->getParObj();
+			if (bo) newbo=bo->insertBranch(num);
 		}else if (num==-3)
 		{
 			num=bo->getNum();
 			bo=(BranchObj*)bo->getParObj();
+			if (bo) newbo=bo->insertBranch(num);
 		}
-		if (!bo) return bo;
-		newbo=bo->insertBranch(num);
+		if (!newbo) return NULL;
 	}	
 	return newbo;
 }	
@@ -2449,18 +2462,19 @@
 				newbo,		
 				"delete ()",
 				bo,
-				QString ("addBranch (%1)").arg(pos-2),
+				QString ("addBranch (%1)").arg(pos),
 				QString ("Add new branch to %1").arg(getName(bo)));	
 
 			mapCenter->reposition();
+			xelection.update();
+			latestSelection=newbo->getSelectString();
 			// In Network mode, the client needs to know where the new branch is,
 			// so we have to pass on this information via saveState.
 			// TODO: Get rid of this positioning workaround
 			QString ps=qpointfToString (newbo->getAbsPos());
-			sendData ("selectLastBranch ()");
+			sendData ("selectLatestAdded ()");
 			sendData (QString("move %1").arg(ps));
 			sendSelection();
-			xelection.update();
 		}
 	}	
 	return newbo;
@@ -2495,6 +2509,7 @@
 			xelection.update();
 		}
 	}	
+	latestSelection=xelection.getSelectString();
 	return newbo;
 }
 
@@ -4837,6 +4852,8 @@
 
 void MapEditor::sendData(const QString &s)
 {
+	if (clientList.size()==0) return;
+
 	// Create bytearray to send
 	QByteArray block;
     QDataStream out(&block, QIODevice::WriteOnly);
@@ -4856,7 +4873,8 @@
     quint16 bs=(quint16)(block.size() - 2*sizeof(quint16));
 	out << bs;
 
-	cout << "ME::sendData  bs="<<bs<<"  counter="<<sendCounter<<"  s="<<s.ascii()<<endl;
+	if (debug)
+		cout << "ME::sendData  bs="<<bs<<"  counter="<<sendCounter<<"  s="<<s.ascii()<<endl;
 
 	for (int i=0; i<clientList.size(); ++i)
 	{
@@ -4869,7 +4887,8 @@
 {
 	while (clientSocket->bytesAvailable() >=(int)sizeof(quint16) )
 	{
-		cout <<"readData  bytesAvail="<<clientSocket->bytesAvailable();
+		if (debug)
+			cout <<"readData  bytesAvail="<<clientSocket->bytesAvailable();
 		quint16 recCounter;
 		quint16 blockSize;
 
@@ -4881,7 +4900,8 @@
 		
 		QString t;
 		in >>t;
-		cout << "  t="<<t.ascii()<<endl;
+		if (debug)
+			cout << "  t="<<t.ascii()<<endl;
 		parseAtom (t);
 	}
 	return;
diff -r 322402d9f9f9 -r 16d3598f611f mapeditor.h
--- a/mapeditor.h	Wed Jul 04 11:05:11 2007 +0000
+++ b/mapeditor.h	Wed Jul 04 11:05:15 2007 +0000
@@ -181,12 +181,12 @@
 
 		Move absolutly to (x,y).
 	*/	
-    void move    (const int &x, const int &y);
+    void move    (const double &x, const double &y);
 	/*! \brief Move relativly
 
 		Move relativly to (x,y).
 	*/	
-    void moveRel (const int &x, const int &y);
+    void moveRel (const double &x, const double &y);
     void moveBranchUp();	//!< Move branch up
     void moveBranchDown();	//!< Move branch down
 private:	
@@ -380,6 +380,9 @@
 	XLinkObj* tmpXLink;
 
 	Selection xelection;	
+
+	QString latestSelection;		// select string of latest added object
+
     MapObj* movingObj;				// moving a MapObj
 	MapObj* linkingObj_src;			// part of a link
     QPointF movingObj_orgPos;		// org. pos of mouse before move