# HG changeset patch
# User insilmaril
# Date 1207643317 0
# Node ID 5f9a2771680db4b44da81534bbc706eee9f93ecc
# Parent  7df0b7986274c4f72fd79d2008418332dbadcf66
1.11.7: Fixed hanging find function

diff -r 7df0b7986274 -r 5f9a2771680d mainwindow.cpp
--- a/mainwindow.cpp	Tue Apr 08 08:28:37 2008 +0000
+++ b/mainwindow.cpp	Tue Apr 08 08:28:37 2008 +0000
@@ -527,6 +527,12 @@
     connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
 	actionEditDelete=a;
     
+    // Shortcut to add mapcenter
+	a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
+    connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
+	actionEditAddMapCenter = a;
+
+
     // Shortcut to add branch
 	alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
 	alt->setStatusTip ( tr( "Add a branch as child of selection" ));
@@ -1592,6 +1598,8 @@
 	// Context menu for canvas
 	canvasContextMenu =new QMenu (this);
 	actionEditMapInfo->addTo( canvasContextMenu );
+	if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) 
+		actionEditAddMapCenter->addTo( canvasContextMenu );
 	canvasContextMenu->insertSeparator();	
 	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
 	canvasContextMenu->insertSeparator();	
@@ -2855,6 +2863,15 @@
 		currentMapEditor()->unscrollChilds();	
 }
 
+void Main::editAddMapCenter()
+{
+	MapEditor *me=currentMapEditor();
+	if (!lineedit->isVisible() && me)
+	{
+		me->addMapCenter ();
+	}	
+}
+
 void Main::editNewBranch()
 {
 	MapEditor *me=currentMapEditor();
@@ -2863,9 +2880,9 @@
 		BranchObj *bo=(BranchObj*)me->getSelection();
 		BranchObj *newbo=me->addNewBranch(0);
 
-		prevSelection=bo->getSelectString();
+		prevSelection=me->getModel()->getSelectString(bo);
 		if (newbo) 
-			me->select (newbo->getSelectString());
+			me->select (newbo);
 		else
 			return;
 
@@ -2892,14 +2909,14 @@
 		BranchObj *newbo=me->addNewBranchBefore();
 
 		if (newbo) 
-			me->select (newbo->getSelectString());
+			me->select (newbo);
 		else
 			return;
 
 		if (actionSettingsAutoEditNewBranch->isOn())
 		{
 			if (!actionSettingsAutoSelectNewBranch->isOn())
-				prevSelection=bo->getSelectString();
+				prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
 			editHeading();
 		}
 	}	
@@ -2914,14 +2931,14 @@
 		BranchObj *newbo=me->addNewBranch (-1);
 
 		if (newbo) 
-			me->select (newbo->getSelectString());
+			me->select (newbo);
 		else
 			return;
 
 		if (actionSettingsAutoEditNewBranch->isOn())
 		{
 			if (!actionSettingsAutoSelectNewBranch->isOn())
-				prevSelection=bo->getSelectString();
+				prevSelection=me->getModel()->getSelectString (bo);	// TODO access directly
 			editHeading();
 		}
 	}	
@@ -2936,14 +2953,14 @@
 		BranchObj *newbo=me->addNewBranch (1);
 
 		if (newbo) 
-			me->select (newbo->getSelectString());
+			me->select (newbo);
 		else
 			return;
 
 		if (actionSettingsAutoEditNewBranch->isOn())
 		{
 			if (!actionSettingsAutoSelectNewBranch->isOn())
-				prevSelection=bo->getSelectString();
+				prevSelection=me->getModel()->getSelectString(bo);	//TODO access directly
 			editHeading();
 		}
 	}	
diff -r 7df0b7986274 -r 5f9a2771680d mainwindow.h
--- a/mainwindow.h	Tue Apr 08 08:28:37 2008 +0000
+++ b/mainwindow.h	Tue Apr 08 08:28:37 2008 +0000
@@ -131,6 +131,7 @@
 	void editSortChildren();
     void editToggleScroll();
     void editUnscrollChilds();
+    void editAddMapCenter();
     void editNewBranch();
     void editNewBranchBefore();
     void editNewBranchAbove();
@@ -276,6 +277,7 @@
 	QAction *actionEditMapInfo;
 	QAction *actionEditHeading;
 	QAction *actionEditDelete;
+	QAction *actionEditAddMapCenter;
 	QAction *actionEditAddBranch;
 	QAction *actionEditAddBranchBefore;
 	QAction *actionEditAddBranchAbove;
diff -r 7df0b7986274 -r 5f9a2771680d mapeditor.cpp
--- a/mapeditor.cpp	Tue Apr 08 08:28:37 2008 +0000
+++ b/mapeditor.cpp	Tue Apr 08 08:28:37 2008 +0000
@@ -429,7 +429,7 @@
 		cout << "    undoSel="<<undoSelection.toStdString()<<endl;
 		cout << "    redoCom="<<redoCom.toStdString()<<endl;
 		cout << "    redoSel="<<redoSelection.toStdString()<<endl;
-		if (saveSel) cout << "    saveSel="<<qPrintable (saveSel->getSelectString())<<endl;
+		if (saveSel) cout << "    saveSel="<<qPrintable (model->getSelectString(saveSel))<<endl;
 		cout << "    ---------------------------"<<endl;
 	}
 
@@ -444,12 +444,12 @@
 	// save the selected part of the map, Undo will replace part of map 
 	QString undoSelection="";
 	if (undoSel)
-		undoSelection=undoSel->getSelectString();
+		undoSelection=model->getSelectString(undoSel);
 	else
 		qWarning ("MapEditor::saveStateChangingPart  no undoSel given!");
 	QString redoSelection="";
 	if (redoSel)
-		redoSelection=undoSel->getSelectString();
+		redoSelection=model->getSelectString(undoSel);
 	else
 		qWarning ("MapEditor::saveStateChangingPart  no redoSel given!");
 		
@@ -468,8 +468,8 @@
 		qWarning ("MapEditor::saveStateRemovingPart  no redoSel given!");
 		return;
 	}
-	QString undoSelection=redoSel->getParObj()->getSelectString();
-	QString redoSelection=redoSel->getSelectString();
+	QString undoSelection=model->getSelectString (redoSel->getParObj());
+	QString redoSelection=model->getSelectString(redoSel);
 	if (typeid(*redoSel) == typeid(BranchObj)  ) 
 	{
 		// save the selected branch of the map, Undo will insert part of map 
@@ -489,9 +489,9 @@
 	// and use current selection
 
 	QString redoSelection="";
-	if (redoSel) redoSelection=redoSel->getSelectString();
+	if (redoSel) redoSelection=model->getSelectString(redoSel);
 	QString undoSelection="";
-	if (undoSel) undoSelection=undoSel->getSelectString();
+	if (undoSel) undoSelection=model->getSelectString(undoSel);
 
 	saveState (UndoCommand,
 		undoSelection, uc,
@@ -578,6 +578,18 @@
 			}	
 		}
 	/////////////////////////////////////////////////////////////////////
+	} else if (com==QString("addMapCenter"))
+	{
+		if (parser.checkParCount(2))
+		{
+			x=parser.parDouble (ok,0);
+			if (ok)
+			{
+				y=parser.parDouble (ok,1);
+				if (ok) model->addMapCenter (QPointF(x,y));
+			}
+		}	
+	/////////////////////////////////////////////////////////////////////
 	} else if (com==QString("addMapReplace"))
 	{
 		if (xelection.isEmpty())
@@ -591,7 +603,7 @@
 			//s=parser.parString (ok,0);	// selection
 			t=parser.parString (ok,0);	// path to map
 			if (QDir::isRelativePath(t)) t=(tmpMapDir + "/"+t);
-			addMapReplaceInt(selb->getSelectString(),t);	
+			addMapReplaceInt(model->getSelectString(selb),t);	
 		}
 	/////////////////////////////////////////////////////////////////////
 	} else if (com==QString("addMapInsert"))
@@ -688,10 +700,13 @@
 		if (xelection.isEmpty())
 		{
 			parser.setError (Aborted,"Nothing selected");
-		} else if (xelection.type() != Selection::Branch && xelection.type() != Selection::FloatImage )
+		} 
+		/*else if (xelection.type() != Selection::Branch && xelection.type() != Selection::FloatImage )
 		{
 			parser.setError (Aborted,"Type of selection is wrong.");
-		} else if (parser.checkParCount(0))
+		} 
+		*/
+		else if (parser.checkParCount(0))
 		{	
 			deleteSelection();
 		}	
@@ -854,7 +869,7 @@
 				{	
 					if (typeid(*dst) == typeid(BranchObj) ||
 						typeid(*dst) == typeid(MapCenterObj)) 
-						linkTo (dst->getSelectString());
+						linkTo (model->getSelectString(dst));
 				} else	
 					parser.setError (Aborted,"Destination is not a branch");
 			}		
@@ -2145,7 +2160,7 @@
 		if (redosAvail == 0)
 		{
 			// Copy to history
-			QString s=sel->getSelectString();
+			QString s=model->getSelectString(sel);
 			saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy selection to clipboard",sel  );
 			curClipboard=curStep;
 		}
@@ -2487,7 +2502,7 @@
         if (ap != to)
         {
             QString ps=qpointfToString(ap);
-            QString s=xelection.single()->getSelectString();
+            QString s=xelection.getSelectString();
             saveState(
                 s, "move "+ps, 
                 s, "move "+qpointfToString(to), 
@@ -2509,7 +2524,7 @@
         if (rp != to)
         {
             QString ps=qpointfToString (sel->getRelPos());
-            QString s=sel->getSelectString();
+            QString s=model->getSelectString(sel);
             saveState(
                 s, "moveRel "+ps, 
                 s, "moveRel "+qpointfToString(to), 
@@ -2531,7 +2546,7 @@
 		if (!bo->canMoveBranchUp()) return;
 		par=(BranchObj*)(bo->getParObj());
 		BranchObj *obo=par->moveBranchUp (bo);	// bo will be the one below selection
-		saveState (bo->getSelectString(),"moveBranchDown ()",obo->getSelectString(),"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
+		saveState (model->getSelectString(bo),"moveBranchDown ()",model->getSelectString(obo),"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
 		model->reposition();
 		scene()->update();
 		xelection.update();
@@ -2548,7 +2563,7 @@
 		if (!bo->canMoveBranchDown()) return;
 		par=(BranchObj*)(bo->getParObj());
 		BranchObj *obo=par->moveBranchDown(bo);	// bo will be the one above selection
-		saveState(bo->getSelectString(),"moveBranchUp ()",obo->getSelectString(),"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
+		saveState(model->getSelectString(bo),"moveBranchUp ()",model->getSelectString(obo),"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
 		model->reposition();
 		scene()->update();
 		xelection.update();
@@ -2581,9 +2596,9 @@
 					typeid(*dst)==typeid (MapCenterObj)))
 		{			
 			LinkableMapObj *dstPar=dst->getParObj();
-			QString parString=dstPar->getSelectString();
-			QString fioPreSelectString=fio->getSelectString();
-			QString fioPreParentSelectString=fio->getParObj()->getSelectString();
+			QString parString=model->getSelectString(dstPar);
+			QString fioPreSelectString=model->getSelectString(fio);
+			QString fioPreParentSelectString=model->getSelectString (fio->getParObj());
 			((BranchObj*)(dst))->addFloatImage (fio);
 			xelection.unselect();
 			((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
@@ -2592,7 +2607,7 @@
 			fio->reposition();
 			xelection.select(fio);
 			saveState(
-				fio->getSelectString(),
+				model->getSelectString(fio),
 				QString("linkTo (\"%1\")").arg(fioPreParentSelectString), 
 				fioPreSelectString, 
 				QString ("linkTo (\"%1\")").arg(dstString),
@@ -2658,6 +2673,22 @@
 	}
 }
 
+BranchObj* MapEditor::addMapCenter ()
+{
+	MapCenterObj *mco= model->addMapCenter(contextMenuPos);
+	xelection.select (mco);
+	updateActions();
+	ensureSelectionVisible();
+	saveState (
+		mco,
+		"delete()",
+		NULL,
+		QString ("addMapCenter (%1,%2)").arg (contextMenuPos.x()).arg(contextMenuPos.y()),
+		QString ("Adding MapCenter to (%1,%2").arg (contextMenuPos.x()).arg(contextMenuPos.y())
+	);	
+	return mco;	
+}
+
 BranchObj* MapEditor::addNewBranchInt(int num)
 {
 	// Depending on pos:
@@ -2717,7 +2748,7 @@
 
 			model->reposition();
 			xelection.update();
-			latestSelection=newbo->getSelectString();
+			latestSelection=model->getSelectString(newbo);
 			// 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
@@ -2853,6 +2884,18 @@
 	return false;
 }
 
+bool MapEditor::select (LinkableMapObj *lmo)
+{
+	if (xelection.select(lmo))
+	{
+		xelection.update();
+		ensureSelectionVisible();
+		sendSelection ();
+		return true;
+	}
+	return false;
+}
+
 QString MapEditor::getSelectString()
 {
 	return xelection.getSelectString();
@@ -2874,7 +2917,7 @@
 	LinkableMapObj *sel=xelection.single();
 	if (sel)
 	{
-		QString s=sel->getSelectString();
+		QString s=xelection.getSelectString();
 		QString part;
 		QString typ;
 		QString num;
@@ -2955,7 +2998,7 @@
 	BranchObj *bo=xelection.getBranch();
 	if (bo)
 	{
-		QString s=bo->getSelectString();
+		QString s=xelection.getSelectString();
 		QString part;
 		QString typ;
 		QString num;
@@ -3391,6 +3434,7 @@
 			itFind=model->next(itFind);
 			if (!itFind) EOFind=true;
 		}
+	//cout <<"still searching...  "<<qPrintable( itFind->getHeading())<<endl;
 	}	
 	if (!searching)
 		return xelection.getBranch();
@@ -3649,7 +3693,7 @@
 			QString("Remove %1 and keep its childs").arg(getName(bo))
 		);
 
-		QString sel=bo->getSelectString();
+		QString sel=model->getSelectString(bo);
 		unselect();
 		par->removeBranchHere(bo);
 		model->reposition();
@@ -4417,16 +4461,11 @@
 void MapEditor::testFunction2()
 {
 
-	xelection.select (model->addMapCenter());
-	ensureSelectionVisible();
-
-/*
 	// Toggle hidemode
 	if (hidemode==HideExport)
 		setHideTmpMode (HideNone);
 	else	
 		setHideTmpMode (HideExport);
-*/		
 }
 
 void MapEditor::contextMenuEvent ( QContextMenuEvent * e )
@@ -4463,6 +4502,7 @@
 	{ // No MapObj found, we are on the Canvas itself
 		// Context Menu on scene
 		updateActions();
+		contextMenuPos=p;
 		canvasContextMenu->popup(e->globalPos() );
     } 
 	e->accept();
@@ -4697,7 +4737,7 @@
 					fio->getParObj()->requestReposition();
 					model->reposition();
 
-					linkTo (lmo->getSelectString());
+					linkTo (model->getSelectString(lmo));
 					//movingObj=lmosel;
 					//movingObj_orgRelPos=lmosel->getRelPos();	
 
@@ -4876,7 +4916,7 @@
 			lmosel->unsetParObjTmp();
 
 			// For Redo we may need to save original selection
-			QString preSelStr=lmosel->getSelectString();
+			QString preSelStr=model->getSelectString(lmosel);
 
 			copyingObj=false;	
 			if (dst ) 
@@ -4884,27 +4924,27 @@
 				BranchObj* bsel=xelection.getBranch();
 				BranchObj* bdst=(BranchObj*)dst;
 
-				QString preParStr=(bsel->getParObj())->getSelectString();
+				QString preParStr=model->getSelectString (bsel->getParObj());
 				QString preNum=QString::number (bsel->getNum(),10);
 				QString preDstParStr;
 
 				if (e->state() & Qt::ShiftModifier && dst->getParObj())
 				{	// Link above dst
-					preDstParStr=dst->getParObj()->getSelectString();
+					preDstParStr=model->getSelectString (dst->getParObj());
 					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum());
 				} else 
 				if (e->state() & Qt::ControlModifier && dst->getParObj())
 				{
 					// Link below dst
-					preDstParStr=dst->getParObj()->getSelectString();
+					preDstParStr=model->getSelectString (dst->getParObj());
 					bsel->linkTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()+1);
 				} else	
 				{	// Append to dst
-					preDstParStr=dst->getSelectString();
+					preDstParStr=model->getSelectString(dst);
 					bsel->linkTo (bdst,-1);
 					if (dst->getDepth()==0) bsel->move (savePos);
 				} 
-				QString postSelStr=lmosel->getSelectString();
+				QString postSelStr=model->getSelectString(lmosel);
 				QString postNum=QString::number (bsel->getNum(),10);
 
 				QString undoCom="linkTo (\""+ 
@@ -4931,7 +4971,7 @@
                     {
                         QString ps=qpointfToString(rp);
                         saveState(
-                            lmosel->getSelectString(), "moveRel "+qpointfToString(movingObj_orgRelPos), 
+                            model->getSelectString(lmosel), "moveRel "+qpointfToString(movingObj_orgRelPos), 
                             preSelStr, "moveRel "+ps, 
                             QString("Move %1 to relative position %2").arg(getName(lmosel)).arg(ps));
                     }
@@ -5342,7 +5382,7 @@
 	FloatImageObj *fio=bo->addFloatImage();
     fio->load(img);
     fio->setOriginalFilename("No original filename (image added by dropevent)");	
-	QString s=bo->getSelectString();
+	QString s=model->getSelectString(bo);
 	saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",fio  );
 	saveState (fio,"delete ()", bo,QString("paste(%1)").arg(curStep),"Pasting dropped image");
     model->reposition();
diff -r 7df0b7986274 -r 5f9a2771680d mapeditor.h
--- a/mapeditor.h	Tue Apr 08 08:28:37 2008 +0000
+++ b/mapeditor.h	Tue Apr 08 08:28:37 2008 +0000
@@ -230,6 +230,13 @@
 private:
 	void setHeadingInt(const QString &);
 	void setVymLinkInt(const QString &);	// Set vymLink for selection
+	/*! \brief Add new mapcenter
+
+	    Disclaimer: Still experimental, not fully supported.
+	*/	
+public:	
+    BranchObj* addMapCenter();		
+
 	/*! \brief Add new branch
 
 		Depending on num the new branch is created
@@ -240,6 +247,7 @@
 		0..n	insert at a specific position in selections parent
 		(needed for free relinking)
 	*/	
+private:	
     BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
 public:	
 	/*! \Add new branch
@@ -258,6 +266,7 @@
 	void unselect();						// before changing current noteedit
 	void reselect();						// after  changing current noteedit
 	bool select(const QString &);			// Select by string
+	bool select(LinkableMapObj *lmo);		// Select by pointer
 	QString getSelectString();
 private:	
 	void selectInt(LinkableMapObj*);	
@@ -427,6 +436,9 @@
     QPointF movingObj_start;		// rel. pos of mouse to absPos 
     QPointF movingCont_start;		// inital pos of moving Content or
     QPointF movingVec;				// how far has Content moved
+
+	QPointF contextMenuPos;					// position where context event was triggered
+
     QPrinter* printer;				// Printing
 
     bool mapDefault;				// Flag if map is untouched
diff -r 7df0b7986274 -r 5f9a2771680d tex/vym.changelog
--- a/tex/vym.changelog	Tue Apr 08 08:28:37 2008 +0000
+++ b/tex/vym.changelog	Tue Apr 08 08:28:37 2008 +0000
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Tue Apr  8 09:59:11 CEST 2008 - uwedr@suse.de
+
+- Version: 1.11.7
+- Bugfix: Hangup when find function did not find anything 
+
 -------------------------------------------------------------------
 Thu Mar 13 02:06:59 CET 2008 - uwedr@suse.de
 
diff -r 7df0b7986274 -r 5f9a2771680d version.h
--- a/version.h	Tue Apr 08 08:28:37 2008 +0000
+++ b/version.h	Tue Apr 08 08:28:37 2008 +0000
@@ -4,10 +4,10 @@
 #include <QString>
 
 #define __VYM_NAME "VYM"
-#define __VYM_VERSION "1.11.6"
+#define __VYM_VERSION "1.11.7"
 //#define __VYM_CODENAME "Codename: 1.10.0-RC-3"
 #define __VYM_CODENAME "Codename: development version"
-#define __VYM_BUILD_DATE "2008-03-13"
+#define __VYM_BUILD_DATE "2008-04-08"
 
 
 bool checkVersion(const QString &);
diff -r 7df0b7986274 -r 5f9a2771680d vymmodel.cpp
--- a/vymmodel.cpp	Tue Apr 08 08:28:37 2008 +0000
+++ b/vymmodel.cpp	Tue Apr 08 08:28:37 2008 +0000
@@ -81,7 +81,13 @@
 
 MapCenterObj* VymModel::addMapCenter()
 {
+	return addMapCenter (QPointF(0,0));
+}
+
+MapCenterObj* VymModel::addMapCenter(QPointF absPos)
+{
 	MapCenterObj *mapCenter = new MapCenterObj(mapScene);
+	mapCenter->move (absPos);
     mapCenter->setVisibility (true);
 	mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
 	mapCenter->setMapEditor(mapEditor);		//FIXME needed to get defLinkStyle, mapLinkColorHint ... for later added objects
@@ -122,12 +128,11 @@
 		// Try to find MapCenter of bo
 		while (bo->getDepth()>0) bo=(BranchObj*)bo->getParObj();
 
-
 		// Try to find next MapCenter
 		int i=mapCenters.indexOf ((MapCenterObj*)bo);
-		if (i+1 > mapCenters.count() || i<0) return NULL;
-		if (mapCenters.at(i)!=bo_start)
-			return mapCenters.at(i);
+		if (i+2 > mapCenters.count() || i<0) return NULL;
+		if (mapCenters.at(i+1)!=bo_start)
+			return mapCenters.at(i+1);
 	} 
 	return NULL;
 }
diff -r 7df0b7986274 -r 5f9a2771680d vymmodel.h
--- a/vymmodel.h	Tue Apr 08 08:28:37 2008 +0000
+++ b/vymmodel.h	Tue Apr 08 08:28:37 2008 +0000
@@ -27,6 +27,7 @@
 	void setScene(QGraphicsScene *s);
 	QGraphicsScene *getScene();
 	MapCenterObj* addMapCenter();
+	MapCenterObj* addMapCenter(QPointF absPos);
 	MapCenterObj* removeMapCenter(MapCenterObj *mco);
 
 	BranchObj* first();					// FIXME replaced by ModelIndex later