# HG changeset patch
# User insilmaril
# Date 1241173829 0
# Node ID 8c028a5d90835d21bb6e6b33c0941fe38fbb0fb8
# Parent  ffb95cd03156bfc672bd38a4b32300e978e4d661
add above/below

diff -r ffb95cd03156 -r 8c028a5d9083 branchitem.cpp
--- a/branchitem.cpp	Thu Apr 30 11:52:49 2009 +0000
+++ b/branchitem.cpp	Fri May 01 10:30:29 2009 +0000
@@ -204,29 +204,36 @@
 
 void BranchItem::toggleScroll()
 {
+	BranchItem *bi=getFirstBranch();
+
+	BranchObj *bo=NULL;
 	if (scrolled)
 	{
 		scrolled=false;
 		//FIXME-1 systemFlags->deactivate("scrolledright");
-		/*
-		for (int i=0; i<branch.size(); ++i)
-			branch.at(i)->setVisibility(true);
-		*/	
+		while (bi)
+		{
+			bo=(BranchObj*)(bi->getLMO());
+			if (bo) bo->setVisibility(true);
+			bi=getNextBranch(bi);
+		}
 	} else
 	{
 		scrolled=true;
-		/*
 		//FIXME-1 systemFlags->activate("scrolledright");
-		for (int i=0; i<branch.size(); ++i)
-			branch.at(i)->setVisibility(false);
-		*/	
+		while (bi)
+		{
+			bo=(BranchObj*)(bi->getLMO());
+			if (bo) bo->setVisibility(false);
+			bi=getNextBranch(bi);
+		}
 	}
-	/*	
-	calcBBoxSize();
-	positionBBox();	
-	move (absPos.x(), absPos.y() );
-	forceReposition();
-	*/
+	if (bo)
+	{
+		bo->calcBBoxSize();
+		bo->positionBBox();	
+		bo->forceReposition();
+	}
 }
 
 bool BranchItem::isScrolled()
diff -r ffb95cd03156 -r 8c028a5d9083 flagobj.cpp
--- a/flagobj.cpp	Thu Apr 30 11:52:49 2009 +0000
+++ b/flagobj.cpp	Fri May 01 10:30:29 2009 +0000
@@ -174,8 +174,6 @@
 	if (visible) 
 	{
 		icon->setVisibility (true);
-		//icon->setPos (100,100);
-		//icon->setPos (rand()%100,rand()%130);
 		calcBBoxSize();
 	}	
 }
@@ -216,14 +214,11 @@
 void FlagObj::calcBBoxSize()
 {
 	if (visible && state)
-	{
 		bbox.setSize (	QSizeF(
 			icon->boundingRect().width(), 
 			icon->boundingRect().height() ) );
-	} else
-	{
+	else
 		bbox.setSize (QSizeF(0,0));
-	}
 	clickBox.setSize (bbox.size());
 }
 
diff -r ffb95cd03156 -r 8c028a5d9083 mainwindow.cpp
--- a/mainwindow.cpp	Thu Apr 30 11:52:49 2009 +0000
+++ b/mainwindow.cpp	Fri May 01 10:30:29 2009 +0000
@@ -689,11 +689,6 @@
 	editMenu->addAction (a);
 	actionSortChildren=a;
 
-	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
-	a->setShortcut ( Qt::Key_ScrollLock );
-	a->setStatusTip (tr( "Scroll branch" ) );
-    connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
-
 	alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
 	alt->setShortcut ( Qt::Key_S );					// Scroll branch
 	alt->setStatusTip (tr( "Scroll branch" )); 
@@ -712,6 +707,19 @@
 	addAction (alt);
 	actionListBranches.append(actionToggleScroll);
 	
+	a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
+	a->setShortcut ( Qt::SHIFT + Qt::Key_X );		// Expand all branches 
+	a->setStatusTip (tr( "Expand all branches" )); 
+    connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
+	actionExpandAll=a;
+	actionExpandAll->setEnabled (false);
+	actionExpandAll->setToggleAction(false);
+    //tb->addAction (actionExpandAll);
+    editMenu->addAction ( actionExpandAll);
+	addAction (a);
+	actionListBranches.append(actionExpandAll);
+
+
     a = new QAction( tr( "Unscroll children","Edit menu" ), this);
 	a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
 	editMenu->addAction (a);
@@ -1773,7 +1781,6 @@
 VymView *Main::createView (VymModel *model)
 {
 	VymView *vm=new VymView (model);
-
 	return vm;
 }
 
@@ -1784,8 +1791,7 @@
 	//MapEditor* me = new MapEditor (m);
 	//me->setObjectName ("MapEditor");
 
-	VymView *view=createView (m);
-	tabWidget->addTab (view,tr("unnamed","MainWindow: name for new and empty file"));
+	tabWidget->addTab (createView (m),tr("unnamed","MainWindow: name for new and empty file"));
 	tabWidget->setCurrentIndex (tabModel.count() );
 	
 	// For the very first map we do not have flagrows yet...
@@ -1867,8 +1873,7 @@
 		{
 			vm=new VymModel;
 			tabModel.append (vm);
-			VymView *view=createView (vm);
-			tabWidget->addTab (view,fn);
+			tabWidget->addTab (createView (vm),fn);
 			tabIndex=tabWidget->count()-1;
 			tabWidget->setCurrentPage (tabIndex);
 		}
@@ -2928,6 +2933,12 @@
 	if (m) m->toggleScroll();
 }
 
+void Main::editExpandAll()
+{
+	VymModel *m=currentModel();
+	if (m) m->emitExpandAll();
+}
+
 void Main::editUnscrollChildren()
 {
 	VymModel *m=currentModel();
@@ -2995,7 +3006,7 @@
 	VymModel *m=currentModel();
 	if ( m)
 	{
-		BranchItem *bi=m->createBranch(); //FIXME-1 missing: m->addNewBranch (-1);
+		BranchItem *bi=m->addNewBranch (-1);
 
 
 		if (bi) 
@@ -3017,7 +3028,7 @@
 	VymModel *m=currentModel();
 	if (m)
 	{
-		BranchItem *bi=m->createBranch();//FIXME-1 *newbo=m->addNewBranch (1);
+		BranchItem *bi=m->addNewBranch (1);
 
 		if (bi) 
 			m->select (bi);
@@ -3286,7 +3297,7 @@
 void Main::viewCenter()
 {
 	VymModel *m=currentModel();
-	if (m) m->ensureSelectionVisible();
+	if (m) m->emitShowSelection();
 }
 
 void Main::networkStartServer()
diff -r ffb95cd03156 -r 8c028a5d9083 mainwindow.h
--- a/mainwindow.h	Thu Apr 30 11:52:49 2009 +0000
+++ b/mainwindow.h	Fri May 01 10:30:29 2009 +0000
@@ -147,6 +147,7 @@
     void editMoveDown();	
 	void editSortChildren();
     void editToggleScroll();
+    void editExpandAll();
     void editUnscrollChildren();
     void editAddMapCenter();
     void editNewBranch();
@@ -287,6 +288,7 @@
 	QAction *actionMoveDown;
 	QAction *actionSortChildren;
 	QAction *actionToggleScroll;
+	QAction *actionExpandAll;
 	QAction* actionOpenURL;
 	QAction* actionOpenURLTab;
 	QAction* actionOpenMultipleURLTabs;
diff -r ffb95cd03156 -r 8c028a5d9083 mapeditor.cpp
--- a/mapeditor.cpp	Thu Apr 30 11:52:49 2009 +0000
+++ b/mapeditor.cpp	Fri May 01 10:30:29 2009 +0000
@@ -662,9 +662,9 @@
 			setCursor (Qt::ArrowCursor);
 
 		// To avoid jumping of the sceneView, only 
-		// ensureSelectionVisible, if not tmp linked
+		// show selection, if not tmp linked
 		if (!lmosel->hasParObjTmp())
-			model->ensureSelectionVisible ();
+			model->emitShowSelection();
 		
 		// Now move the selection, but add relative position 
 		// (movingObj_start) where selection was chosen with 
diff -r ffb95cd03156 -r 8c028a5d9083 tex/vym.tex
--- a/tex/vym.tex	Thu Apr 30 11:52:49 2009 +0000
+++ b/tex/vym.tex	Fri May 01 10:30:29 2009 +0000
@@ -368,7 +368,7 @@
 
 To scroll or unscroll a branch and its children,
 \begin{itemize}
-	\item press either the \key{Scroll Lock} key or the \key{S}
+	\item press the \key{S}
 	\item press the middle-mouse button or
 	\item choose the scroll icon from the toolbar.
 \end{itemize}
diff -r ffb95cd03156 -r 8c028a5d9083 treeitem.cpp
--- a/treeitem.cpp	Thu Apr 30 11:52:49 2009 +0000
+++ b/treeitem.cpp	Fri May 01 10:30:29 2009 +0000
@@ -52,6 +52,9 @@
 	branchCounter=0;
 	lastSelectedBranchNum=-1;
 
+	imageOffset=0;
+	imageCounter=0;
+
 	note.setNote(""); 
 	// note.setFontHint (textEditor->getFontHintDefault() );	//FIXME-2
 	// isNoteInEditor=false;
@@ -198,7 +201,7 @@
 		case Undefined: return -1;
 		case MapCenter: return parentItem->childItems.indexOf (this) - branchOffset;
 		case Branch: return parentItem->childItems.indexOf (this) - branchOffset;
-		case Image: return -1; // FIXME-2
+		case Image: return parentItem->childItems.indexOf (this) - imageOffset;
 		default: return -1;
 	}
 }
@@ -209,9 +212,9 @@
 	switch (item->getType())
 	{
 		case Undefined: return -1;
-		case MapCenter: return childItems.indexOf (this) - branchOffset;
-		case Branch: return childItems.indexOf (this) - branchOffset;
-		case Image: return -1; // FIXME-2
+		case MapCenter: return childItems.indexOf (item) - branchOffset;
+		case Branch: return childItems.indexOf (item) - branchOffset;
+		case Image: return parentItem->childItems.indexOf (item) - imageOffset;
 		default: return -1;
 	}
 }
@@ -351,6 +354,16 @@
 		return NULL;
 }
 
+BranchItem* TreeItem::getNextBranch(BranchItem *currentBranch)
+{
+	if (!currentBranch) return NULL;
+	int n=num (currentBranch)+1;
+	if (n<branchCounter)
+		return getBranchNum (branchOffset + n);
+	else
+		return NULL;
+}
+
 
 BranchItem* TreeItem::getBranchNum(const int &n)
 {
diff -r ffb95cd03156 -r 8c028a5d9083 treeitem.h
--- a/treeitem.h	Thu Apr 30 11:52:49 2009 +0000
+++ b/treeitem.h	Fri May 01 10:30:29 2009 +0000
@@ -94,6 +94,11 @@
 	virtual TreeItem* getChildNum(const int &n);
 	virtual BranchItem* getFirstBranch();
 	virtual BranchItem* getLastBranch();
+
+	/*! Get next branch after current branch. Return NULL if there is no
+	    next branch */
+	virtual BranchItem* getNextBranch(BranchItem* currentBranch);
+
 	virtual BranchItem* getBranchNum(const int &n);
 	virtual BranchObj* getBranchObjNum(const int &n);
 	virtual void setLastSelectedBranch();		//! Set myself as last selected in parent
@@ -118,6 +123,9 @@
 	int branchCounter;
 	int lastSelectedBranchNum;
 
+	int imageOffset;
+	int imageCounter;
+
 	bool hideExport;//! Hide this item in export
 	bool hidden;	//! Hidden in export if true
 };
diff -r ffb95cd03156 -r 8c028a5d9083 version.h
--- a/version.h	Thu Apr 30 11:52:49 2009 +0000
+++ b/version.h	Fri May 01 10:30:29 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-04-29"
+#define __VYM_BUILD_DATE "2009-05-01"
 
 
 bool checkVersion(const QString &);
diff -r ffb95cd03156 -r 8c028a5d9083 vymmodel.cpp
--- a/vymmodel.cpp	Thu Apr 30 11:52:49 2009 +0000
+++ b/vymmodel.cpp	Fri May 01 10:30:29 2009 +0000
@@ -1186,7 +1186,7 @@
 	mainWindow->updateHistory (undoSet);
 	updateActions();
 	selection.update();
-	ensureSelectionVisible();
+	emitShowSelection();
 }
 
 bool VymModel::isUndoAvailable()
@@ -1521,7 +1521,7 @@
 
 		reposition();
 //		selection.update();	//FIXME-4
-		ensureSelectionVisible();
+		emitShowSelection();
 	}
 }
 
@@ -1554,7 +1554,7 @@
 				if (getSelectedBranch()!=itFind) 
 				{
 					select(itFind);
-					ensureSelectionVisible();
+					emitShowSelection();
 				}
 				*/
 				if (textEditor->findText(s,flags)) 
@@ -1615,7 +1615,7 @@
 		updateActions();
 		reposition();
 		selection.update();
-		ensureSelectionVisible();
+		emitShowSelection();
 	}
 */
 }	
@@ -1969,7 +1969,7 @@
 		reposition();
 		//FIXME-3 VM needed? scene()->update();
 		selection.update();
-		ensureSelectionVisible();
+		emitShowSelection();
 	}
 	*/
 }
@@ -1988,7 +1988,7 @@
 		reposition();
 		//FIXME-3 VM needed? scene()->update();
 		selection.update();
-		ensureSelectionVisible();
+		emitShowSelection();
 	}	
 */	
 }
@@ -2004,7 +2004,7 @@
 			saveStateChangingPart(bo,bo, "sortChildren ()",QString("Sort children of %1").arg(getObjectName(bo)));
 			bo->sortChildren();
 			reposition();
-			ensureSelectionVisible();
+			emitShowSelection();
 		}
 	}
 */
@@ -2055,7 +2055,7 @@
 	MapCenterItem *mci=addMapCenter (contextPos);
 	//FIXME-3 selection.select (mco);
 	updateActions();
-	ensureSelectionVisible();
+	emitShowSelection();
 	saveState (
 		mci,
 		"delete()",
@@ -2120,52 +2120,59 @@
 	// -2		add branch to selection 
 	// -1		insert in children of parent below selection 
 	// 0..n		insert in children of parent at pos
-	BranchObj *newbo=NULL;
-	BranchObj *bo=getSelectedBranchObj();	//FIXME-2
-	BranchItem *bi=getSelectedBranchItem();
-	if (bo)
+	BranchItem *selbi=getSelectedBranchItem();
+	if (selbi)
 	{
+		// Create TreeItem
+		QList<QVariant> cData;
+		cData << "new" << "undef"<<"undef";
+
+		BranchItem *parbi;
+		QModelIndex parix;
+		int n;
+		BranchItem *newbi=new BranchItem (cData);	
+		newbi->setHeading (QApplication::translate("Heading of new branch in map", "new"));
+
+		emit (layoutAboutToBeChanged() );
+
 		if (num==-2)
 		{
-			// Create TreeItem
-			QList<QVariant> cData;
-			cData << "new" << "undef"<<"undef";
-
-			BranchItem *parbi=bi;
-			QModelIndex parix=index(parbi);
-			int n=parbi->childCount();
-
-			emit (layoutAboutToBeChanged() );
-			beginInsertRows (parix,n,n+1);	//FIXME-1 check if n is correct: should be index below _last_ branch...
-			bi=new BranchItem (cData);	
-			bi->setHeading (QApplication::translate("Heading of new branch in map", "new"));
-
-			parbi->appendChild (bi);	
+			parbi=selbi;
+			parix=index(parbi);
+			n=parbi->childCount();
+			cout <<"n="<<n<<endl;
+			beginInsertRows (parix,n,n+1);	
+			parbi->appendChild (newbi);	
 			endInsertRows ();
-			emit (newChildObject (parix));
-			emit (layoutChanged() );
-
-			// save scroll state. If scrolled, automatically select
-			// new branch in order to tmp unscroll parent...
-			newbo=bi->createMapObj(mapScene);
-			select (bi);
 		}else if (num==-1)
 		{
-		/*
-			num=bi->num()+1;
-			bo=(BranchObj*)bo->getParObj();
-			if (bo) newbo=bo->insertBranch(num);	//FIXME-1 VM still missing 
-		*/	
+			// insert below selection
+			parbi=(BranchItem*)selbi->parent();
+			parix=index(parbi);
+			n=selbi->childNumber()+1;
+			beginInsertRows (parix,n,n);	
+			parbi->insertBranch(n,newbi);	
+			endInsertRows ();
 		}else if (num==-3)
 		{
-		/*
-			num=bi->num();
-			bo=(BranchObj*)bo->getParObj();
-			if (bo) newbo=bo->insertBranch(num);	//FIXME-1 VM still missing
-		*/	
+			// insert above selection
+			parbi=(BranchItem*)selbi->parent();
+			parix=index(parbi);
+			n=selbi->childNumber();
+			beginInsertRows (parix,n,n);	
+			parbi->insertBranch(n,newbi);	
+			endInsertRows ();
 		}
+		emit (newChildObject (parix));
+		emit (layoutChanged() );
+
+		// save scroll state. If scrolled, automatically select
+		// new branch in order to tmp unscroll parent...
+		newbi->createMapObj(mapScene);
+		select (newbi);
+		return newbi;
 	}	
-	return bi;
+	return NULL;
 }	
 
 BranchItem* VymModel::addNewBranch(int pos)
@@ -2179,7 +2186,7 @@
 
 	if (selbi)
 	{
-		// FIXME-2 VM  do we still need this in model? setCursor (Qt::ArrowCursor);
+		// FIXME-3 VM  do we still need this in model? setCursor (Qt::ArrowCursor);
 
 		newbi=addNewBranchInt (pos-2);
 
@@ -2295,7 +2302,7 @@
 		removeRows (n,1,parentIndex);
 		endRemoveRows();
 		select (pi);
-		ensureSelectionVisible();
+		emitShowSelection();
 		reposition();
 
 		emit (layoutChanged() );
@@ -2317,7 +2324,7 @@
 		par->removeFloatImage(fio);
 		select (par);
 		reposition();
-		ensureSelectionVisible();
+		emitShowSelection();
 		return;
 	}
 	*/
@@ -2400,8 +2407,7 @@
 		);
 		*/
 		bi->toggleScroll();
-		//selection.update();
-		// FIXME-3 VM needed? scene()->update();
+		mapScene->update(); //Needed for _quick_ update
 		return true;
 	}	
 	return false;
@@ -2411,7 +2417,7 @@
 {
 	if (bi)
 	{
-		if (bi->isScrolled()) return false;
+		if (!bi->isScrolled()) return false;
 		if (bi->branchCount()==0) return false;
 		if (bi->depth()==0) return false;
 
@@ -2428,8 +2434,7 @@
 		);
 		*/
 		bi->toggleScroll();
-		// selection.update();
-		// FIXME-3 VM needed? scene()->update();
+		mapScene->update();	// Needed for _quick_ update
 		return true;
 	}	
 	return false;
@@ -2447,7 +2452,7 @@
 	}
 }
 
-void VymModel::unscrollChildren() 	// FIXME-1	first, next moved to vymmodel
+void VymModel::unscrollChildren() 	// FIXME-2	first, next moved to vymmodel
 
 {
 /*
@@ -2464,6 +2469,11 @@
 */	
 }
 
+void VymModel::emitExpandAll()
+{
+	emit (expandAll() );
+}
+
 void VymModel::addFloatImage (const QPixmap &img) //FIXME-2
 {
 /*
@@ -2660,7 +2670,7 @@
 		reposition();
 		updateActions();
 		//selection.update();
-		ensureSelectionVisible();
+		emitShowSelection();
 	}
 }
 
@@ -2725,7 +2735,7 @@
 		if (bo) 
 		{
 			selection.select(bo);
-			ensureSelectionVisible();
+			emitShowSelection();
 		}
 	}
 	*/
@@ -4517,7 +4527,7 @@
 void VymModel::updateSelection(const QItemSelection &newsel)
 {
 	emit (selectionChanged(newsel,newsel));	// needed e.g. to update geometry in editor
-	ensureSelectionVisible();
+	emitShowSelection();
 	sendSelection();
 }
 
@@ -4642,10 +4652,10 @@
 	selection.reselect();
 }	
 
-void VymModel::ensureSelectionVisible()		//FIXME-3 needed? in vymmodel.h commented...
-{
-	LinkableMapObj *lmo=getSelectedLMO();
-	if (lmo &&mapEditor) mapEditor->ensureVisible (lmo->getBBox() );
+void VymModel::emitShowSelection()	
+{
+	if (!blockReposition)
+		emit (showSelection() );
 }
 
 void VymModel::emitNoteHasChanged (TreeItem *ti)
@@ -4909,7 +4919,7 @@
 		if (ti2) {
 			select(ti2);
 			selection.update();
-			ensureSelectionVisible();
+			emitShowSelection();
 			sendSelection();
 		}
 	}		
@@ -4926,7 +4936,7 @@
 		if (ti2) {
 			select(ti2);
 			selection.update();
-			ensureSelectionVisible();
+			emitShowSelection();
 			sendSelection();
 		}
 	}		
@@ -4952,7 +4962,7 @@
 		if (!par) return;
 		select(par);
 		selection.update();
-		ensureSelectionVisible();
+		emitShowSelection();
 		sendSelection();
 	}		
 }
diff -r ffb95cd03156 -r 8c028a5d9083 vymmodel.h
--- a/vymmodel.h	Thu Apr 30 11:52:49 2009 +0000
+++ b/vymmodel.h	Fri May 01 10:30:29 2009 +0000
@@ -329,6 +329,11 @@
     void toggleScroll();
     void unscrollChildren();
 
+	void emitExpandAll();
+signals:	
+	void expandAll();
+
+public:	
     void addFloatImage(const QPixmap &img);
 
     void colorBranch(QColor);
@@ -416,8 +421,6 @@
 	QPolygonF shape(BranchObj *bo);		//!< Returns arbitrary shape of subtree
 	void moveAway (LinkableMapObj *lmo);//!< Autolayout: Move all out of the way
 
-	//void ensureSelectionVisible();		//!< Show selection in all views
-
 	void emitNoteHasChanged (TreeItem *ti);
 	void emitDataHasChanged (TreeItem *ti);
 
@@ -545,12 +548,14 @@
 
 	bool select ();							// select by using common QItemSlectionModel
 	bool select (const QString &);			// Select by string
-	bool select (LinkableMapObj *lmo);		// Select by pointer to LMO
+	bool select (LinkableMapObj *lmo);		// Select by pointer tog LMO
 	bool select (TreeItem *ti );			// Select by point to TreeItem
 	void unselect();
 	void reselect();
 
-	void ensureSelectionVisible();			//!< Show selection in all views
+	void emitShowSelection();				//!< Show selection in all views
+signals:
+	void showSelection();
 
 //	void selectInt(LinkableMapObj*);	//FIXME-4
 
diff -r ffb95cd03156 -r 8c028a5d9083 vymview.cpp
--- a/vymview.cpp	Thu Apr 30 11:52:49 2009 +0000
+++ b/vymview.cpp	Fri May 01 10:30:29 2009 +0000
@@ -3,6 +3,7 @@
 #include <iostream>
 using namespace std;
 
+#include "linkablemapobj.h"
 #include "mainwindow.h"
 #include "mapeditor.h"
 
@@ -58,6 +59,14 @@
 		model, SIGNAL (noteHasChanged(QModelIndex) ),
 		mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
 		
+	connect (
+		model, SIGNAL (expandAll() ),
+		this, SLOT (expandAll () ) );
+		
+	connect (
+		model, SIGNAL (showSelection() ),
+		this, SLOT (showSelection() ) );
+		
 
 	//mapEditor->viewport()->setFocus();	//FIXmapEditor-3 needed?
 	mapEditor->setAntiAlias (mainWindow->isAliased());
@@ -105,3 +114,21 @@
 	mainWindow->changeSelection (model,newsel,oldsel);	// FIXME-3 maybe connect VymModel <-> MainWindow directly?
 }
 
+void VymView::expandAll()
+{
+	treeview->expandAll();
+}
+
+void VymView::showSelection()
+{
+	treeview->scrollTo(
+		model->getSelectedIndex(), 
+		//QAbstractItemView::PositionAtCenter   
+		QAbstractItemView::EnsureVisible
+	);
+
+	LinkableMapObj* lmo=model->getSelectedLMO();
+	if (lmo)
+		mapEditor->ensureVisible(lmo->getBBox() );
+}
+
diff -r ffb95cd03156 -r 8c028a5d9083 vymview.h
--- a/vymview.h	Thu Apr 30 11:52:49 2009 +0000
+++ b/vymview.h	Fri May 01 10:30:29 2009 +0000
@@ -19,6 +19,8 @@
 public slots:
 	void updateChilds (QModelIndex ix);
 	void changeSelection (const QItemSelection &newSel, const QItemSelection &delSel);
+	void expandAll ();
+	void showSelection ();
 
 private:
 	VymModel *model;
diff -r ffb95cd03156 -r 8c028a5d9083 xml-freemind.cpp
--- a/xml-freemind.cpp	Thu Apr 30 11:52:49 2009 +0000
+++ b/xml-freemind.cpp	Fri May 01 10:30:29 2009 +0000
@@ -261,12 +261,12 @@
 
 bool parseFreemindHandler::readNodeAttr (const QXmlAttributes& a)	//FIXME-3
 {
-/*
-	lastOO=lastBranch;
-	lastBranchItem=(BranchItem*)(lastBranch->getTreeItem() );
+	//lastOO=lastBranch;
+	//lastBranchItem=(BranchItem*)(lastBranch->getTreeItem() );
 
 	if (a.value( "FOLDED")=="true" )
 		lastBranchItem->toggleScroll();
+/*
 	if (!a.value( "TEXT").isEmpty() )
 		lastBranch->setHeading (a.value ("TEXT"));
 
diff -r ffb95cd03156 -r 8c028a5d9083 xml-vym.cpp
--- a/xml-vym.cpp	Thu Apr 30 11:52:49 2009 +0000
+++ b/xml-vym.cpp	Fri May 01 10:30:29 2009 +0000
@@ -229,8 +229,7 @@
 	} else if ( eName == "branch" && state == StateMapCenter) 
 	{
 		state=StateBranch;
-		model->createBranch();
-		lastBranchItem=model->getSelectedBranchItem();
+		lastBranchItem=model->createBranch();
 		readBranchAttr (atts);
 	} else if ( eName == "htmlnote" && state == StateBranch) 
 	{
@@ -250,8 +249,7 @@
 		if (!readXLinkAttr (atts)) return false;
     } else if ( eName == "branch" && state == StateBranch ) 
 	{
-		model->createBranch();
-		lastBranchItem=model->getSelectedBranchItem();
+		lastBranchItem=model->createBranch();
 		readBranchAttr (atts);
     } else if ( eName == "html" && state == StateHtmlNote ) 
 	{
@@ -353,14 +351,12 @@
 {
 	branchesCurrent++;
 	mainWindow->setProgressValue (branchesCurrent);
-	//lastOO=lastBranch;
-	//lastBranchItem=(BranchItem*)(lastBranch->getTreeItem());
 
 	if (!readOOAttr(a)) return false;
-/*
 
 	if (!a.value( "scrolled").isEmpty() )
 		lastBranchItem->toggleScroll();
+/*
 	if (!a.value( "frameType").isEmpty() ) 
 		lastOO->setFrameType (a.value("frameType")); //Compatibility 1.8.1