# HG changeset patch
# User insilmaril
# Date 1115238939 0
# Node ID 58adc2d2ed081036d1cef44c915dc6429f32f63d
# Parent  0b048b6bb6f403f8cda11f56f5114a5c0963b15a
1.6.5 new insert/remove options

diff -r 0b048b6bb6f4 -r 58adc2d2ed08 branchobj.cpp
--- a/branchobj.cpp	Thu Apr 21 19:14:38 2005 +0000
+++ b/branchobj.cpp	Wed May 04 20:35:39 2005 +0000
@@ -985,6 +985,25 @@
 	return bo;
 }
 
+void BranchObj::removeBranchHere(BranchObj* borem)
+{
+	// This removes the branch bo from list, but 
+	// inserts its childs at the place of bo
+	BranchObj *bo;
+	bo=borem->getLastBranch();
+	while (bo)
+	{
+		bo->moveBranchTo (borem,1);
+		bo=borem->getLastBranch();
+	}	
+	removeBranch (borem);
+}
+
+void BranchObj::removeChilds()
+{
+	clear();
+}
+
 void BranchObj::removeBranch(BranchObj* bo)
 {
     // if bo is not in branch remove returns false, we
@@ -1077,9 +1096,9 @@
 	else
 		return NULL;
 
-	if (pos<0  || dst->getDepth()==1)
+	if (pos<0||dst->getDepth()==0)
 	{	
-		// links adds myself as last branch at dst
+		// links myself as last branch at dst
 		dst->addBranchPtr (this);
 		return this;
 	} else
diff -r 0b048b6bb6f4 -r 58adc2d2ed08 branchobj.h
--- a/branchobj.h	Thu Apr 21 19:14:38 2005 +0000
+++ b/branchobj.h	Wed May 04 20:35:39 2005 +0000
@@ -85,6 +85,8 @@
     virtual BranchObj* insertBranch(int);
     virtual BranchObj* insertBranch(BranchObj*,int);
     virtual BranchObj* insertBranchPtr (BranchObj*,int);
+    virtual void removeBranchHere(BranchObj*);  
+    virtual void removeChilds();  
     virtual void removeBranch(BranchObj*);  
     virtual void removeBranchPtr (BranchObj*);  
     virtual void setLastSelectedBranch(BranchObj*);
diff -r 0b048b6bb6f4 -r 58adc2d2ed08 demos/todo.vym
Binary file demos/todo.vym has changed
diff -r 0b048b6bb6f4 -r 58adc2d2ed08 imageobj.cpp
--- a/imageobj.cpp	Thu Apr 21 19:14:38 2005 +0000
+++ b/imageobj.cpp	Wed May 04 20:35:39 2005 +0000
@@ -39,7 +39,7 @@
 {
 	switch (type)
 	{
-		case undef: qWarning("undef");break;
+		case undef: qWarning("Warning: ImageObj::save() type=undef");break;
 		case qimage: image.save (fn,format,-1);break;
 		case qpixmap: pixmap.save (fn,format,-1);break;
 	}
diff -r 0b048b6bb6f4 -r 58adc2d2ed08 main.cpp
--- a/main.cpp	Thu Apr 21 19:14:38 2005 +0000
+++ b/main.cpp	Wed May 04 20:35:39 2005 +0000
@@ -2,6 +2,7 @@
 #include <qpixmap.h>
 #include <qtranslator.h>
 #include <qdir.h>
+#include <qptrlist.h>
 #include <qtextcodec.h>
 
 #include "settings.h"
@@ -22,6 +23,10 @@
 FlagRowObj *systemFlagsDefault;	// used to copy from in LinkableMapObj
 FlagRowObj *standardFlagsDefault;
 
+// Lists of actions
+// (QActionGroup could not be "enabled")
+QPtrList <QAction> actionListBranches;
+
 // Actions which change sometimes
 QAction *actionFileSave;
 QAction *actionFilePrint;
@@ -43,8 +48,11 @@
 QAction *actionEditHeading;
 QAction *actionEditDelete;
 QAction *actionEditAddBranch;
+QAction *actionEditAddBranchHere;
 QAction *actionEditAddBranchAbove;
 QAction *actionEditAddBranchBelow;
+QAction *actionEditRemoveBranchHere;
+QAction *actionEditRemoveChilds;
 QAction *actionEditImportAdd;
 QAction *actionEditImportReplace;
 QAction *actionEditSaveBranch;
@@ -85,6 +93,8 @@
 QAction *actionSettingsUseDelKey;
 
 QPopupMenu *branchContextMenu;
+QPopupMenu *branchAddContextMenu;
+QPopupMenu *branchRemoveContextMenu;
 QPopupMenu *branchLinksContextMenu;
 QPopupMenu *branchLinksContextMenuDup;
 QPopupMenu *floatimageContextMenu;
diff -r 0b048b6bb6f4 -r 58adc2d2ed08 mainwindow.cpp
--- a/mainwindow.cpp	Thu Apr 21 19:14:38 2005 +0000
+++ b/mainwindow.cpp	Wed May 04 20:35:39 2005 +0000
@@ -63,6 +63,8 @@
 extern MapEditor *clipboardME;
 extern FlagRowObj* standardFlagsDefault;
 
+extern QPtrList <QAction> actionListBranches;
+
 extern QAction* actionFileSave;
 extern QAction* actionFilePrint;
 extern QAction* actionEditUndo;
@@ -83,8 +85,11 @@
 extern QAction *actionEditHeading;
 extern QAction *actionEditDelete;
 extern QAction *actionEditAddBranch;
+extern QAction *actionEditAddBranchHere;
 extern QAction *actionEditAddBranchAbove;
 extern QAction *actionEditAddBranchBelow;
+extern QAction *actionEditRemoveBranchHere;
+extern QAction *actionEditRemoveChilds;
 extern QAction *actionEditImportAdd;
 extern QAction *actionEditImportReplace;
 extern QAction *actionEditSaveBranch;
@@ -126,6 +131,8 @@
 extern QAction* actionSettingsUseDelKey;
 
 extern QPopupMenu* branchContextMenu;
+extern QPopupMenu* branchAddContextMenu;
+extern QPopupMenu* branchRemoveContextMenu;
 extern QPopupMenu* branchLinksContextMenu;
 extern QPopupMenu* branchLinksContextMenuDup;
 extern QPopupMenu* floatimageContextMenu;
@@ -396,24 +403,30 @@
     a->addTo( tb );
     a->addTo( menu );
 	actionEditPaste=a;
+
     a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
     connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
+	actionListBranches.append(a);
 	actionEditMoveUp=a;
+
     a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
     connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
+	actionListBranches.append(a);
 	actionEditMoveDown=a;
+	
 
     a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
     connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
+	actionListBranches.append(a);
 	actionEditToggleScroll=a;
 	
     a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
@@ -439,17 +452,20 @@
     connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
     a->addTo( menu );
 	a->setEnabled (false);
+	actionListBranches.append(a);
 	actionEditURL=a;
 	
 	a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
     connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
     a->addTo( menu );
 	a->setEnabled (false);
+	actionListBranches.append(a);
 	actionEditHeading2URL=a;
     
 	a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
     connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
 	a->setEnabled (false);
+	actionListBranches.append(a);
 	actionEditBugzilla2URL=a;
     
 	menu->insertSeparator();
@@ -465,6 +481,7 @@
     connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
     a->addTo( menu );
 	a->setEnabled (false);
+	actionListBranches.append(a);
 	actionEditVymLink=a;
 
     a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
@@ -488,12 +505,15 @@
     connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
 	a->setEnabled (false);
     a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditHeading=a;
     a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
     connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
+	actionListBranches.append(a);
 	actionEditHeading=a;
     a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
     connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
+	actionListBranches.append(a);
     
     // Shortcut to delete selection
     a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
@@ -510,44 +530,65 @@
 	#endif
     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditAddBranch=a;
 
+    // Add branch by inserting it at selection
+	a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
+    connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
+	a->setEnabled (false);
+	actionListBranches.append(a);
+	actionEditAddBranchHere=a;
+
 	// Add branch above
     a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditAddBranchAbove=a;
 
 	// Add branch below 
     a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditAddBranchBelow=a;
 
 	// Import at selection (adding to selection)
     a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
     connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditImportAdd=a;
 
 	// Import at selection (replacing selection)
     a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
     connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditImportReplace=a;
 
 	// Save selection 
-    a = new QAction( tr( "Save selction" ),tr( "Save selection" ), 0, this, "saveSelection" );
+    a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
     connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditSaveBranch=a;
 
+	// Only remove branch, not its childs
+    a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
+    connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
+	a->setEnabled (false);
+	actionListBranches.append(a);
+	actionEditRemoveBranchHere=a;
+
+	// Only remove childs of a branch
+    a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
+    connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
+	a->setEnabled (false);
+	actionListBranches.append(a);
+	actionEditRemoveChilds=a;
+
     // Shortcuts for navigating with cursor:
     a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
     connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
@@ -560,12 +601,14 @@
     a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
 	a->setEnabled (false);
     a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditSelectFirst=a;
     connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
     a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
     connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
 	a->setEnabled (false);
     a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditSelectLast=a;
 
     a = new QAction( tr( "Add Image" ),tr( "Add Image" ), 0, this, "loadImage" );
@@ -593,18 +636,21 @@
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
+	actionListBranches.append(a);
 	actionFormatPickColor=a;
     a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
     connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
+	actionListBranches.append(a);
 	actionFormatColorBranch=a;
     a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
     connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
 	a->setEnabled (false);
     a->addTo( menu );
     a->addTo( tb );
+	actionListBranches.append(a);
 	actionFormatColorSubtree=a;
 
     menu->insertSeparator();
@@ -822,29 +868,44 @@
 
 	// Context Menu for branch or mapcenter
 	branchContextMenu =new QPopupMenu (this);
-	actionEditAddBranch->addTo ( branchContextMenu );
-	actionEditAddBranchAbove->addTo ( branchContextMenu );
-	actionEditAddBranchBelow->addTo ( branchContextMenu );
+
+		// Submenu "Add"
+		branchAddContextMenu =new QPopupMenu (this);
+		actionEditPaste->addTo ( branchAddContextMenu );
+		actionEditAddBranch->addTo ( branchAddContextMenu );
+		actionEditAddBranchHere->addTo ( branchAddContextMenu );
+		actionEditAddBranchAbove->addTo ( branchAddContextMenu );
+		actionEditAddBranchBelow->addTo ( branchAddContextMenu );
+		branchAddContextMenu->insertSeparator();	
+		actionEditLoadImage->addTo( branchAddContextMenu );
+		branchAddContextMenu->insertSeparator();	
+		actionEditImportAdd->addTo ( branchAddContextMenu );
+		actionEditImportReplace->addTo ( branchAddContextMenu );
+
+		// Submenu "Remove"
+		branchRemoveContextMenu =new QPopupMenu (this);
+		actionEditCut->addTo ( branchRemoveContextMenu );
+		actionEditDelete->addTo ( branchRemoveContextMenu );
+		actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
+		actionEditRemoveChilds->addTo( branchRemoveContextMenu );
+		
+	branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);	
+	branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);	
+
 	actionEditSaveBranch->addTo( branchContextMenu );
-	branchContextMenu->insertSeparator();	
-	actionEditImportAdd->addTo ( branchContextMenu );
-	actionEditImportReplace->addTo ( branchContextMenu );
+
 	branchContextMenu->insertSeparator();	
 	actionEditOpenURL->addTo ( branchContextMenu );
 	actionEditURL->addTo ( branchContextMenu );
 	actionEditHeading2URL->addTo ( branchContextMenu );
     if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
 		actionEditBugzilla2URL->addTo( branchContextMenu );
+		
 	branchContextMenu->insertSeparator();	
 	actionEditOpenVymLink->addTo ( branchContextMenu );
 	actionEditVymLink->addTo ( branchContextMenu );
 	actionEditDeleteVymLink->addTo ( branchContextMenu );
-	branchContextMenu->insertSeparator();	
-	actionEditLoadImage->addTo( branchContextMenu );
-	branchContextMenu->insertSeparator();	
-	//actionEditCopy->addTo( branchContextMenu );
-	//actionEditCut->addTo( branchContextMenu );
-	//actionEditPaste->addTo( branchContextMenu );
+	
 	branchContextMenu->insertSeparator();	
 	actionGroupFormatFrameTypes->addTo( branchContextMenu );
 
@@ -1906,6 +1967,12 @@
 		currentMapEditor()->addNewBranch(0);
 }
 
+void Main::editNewBranchHere()
+{
+	if (currentMapEditor())
+		currentMapEditor()->addNewBranchHere();
+}
+
 void Main::editNewBranchAbove()
 {
 	if (currentMapEditor())
@@ -1933,6 +2000,18 @@
 	fileSaveAs (PartOfMap);
 }
 
+void Main::editRemoveBranchHere()
+{
+	if (currentMapEditor())
+		currentMapEditor()->removeBranchHere();
+}
+
+void Main::editRemoveChilds()
+{
+	if (currentMapEditor())
+		currentMapEditor()->removeChilds();
+}
+
 void Main::editDeleteSelection()
 {
 	if (currentMapEditor())
diff -r 0b048b6bb6f4 -r 58adc2d2ed08 mainwindow.h
--- a/mainwindow.h	Thu Apr 21 19:14:38 2005 +0000
+++ b/mainwindow.h	Wed May 04 20:35:39 2005 +0000
@@ -100,11 +100,14 @@
     void editUnScrollAll();
     void editHeading();
     void editNewBranch();
+    void editNewBranchHere();
     void editNewBranchAbove();
     void editNewBranchBelow();
     void editImportAdd();
     void editImportReplace();
     void editSaveBranch();
+    void editRemoveBranchHere();
+    void editRemoveChilds();
     void editDeleteSelection();
     void editUpperBranch();
     void editLowerBranch();
diff -r 0b048b6bb6f4 -r 58adc2d2ed08 mapeditor.cpp
--- a/mapeditor.cpp	Thu Apr 21 19:14:38 2005 +0000
+++ b/mapeditor.cpp	Wed May 04 20:35:39 2005 +0000
@@ -61,6 +61,8 @@
 extern FlagRowObj *standardFlagsDefault;
 extern MapEditor *clipboardME;
 
+extern QPtrList <QAction> actionListBranches;
+
 extern QAction *actionFileSave;
 extern QAction *actionEditUndo;
 extern QAction *actionEditCopy;
@@ -81,6 +83,8 @@
 extern QAction *actionEditAddBranch;
 extern QAction *actionEditAddBranchAbove;
 extern QAction *actionEditAddBranchBelow;
+extern QAction *actionEditRemoveBranchHere;
+extern QAction *actionEditRemoveChilds;
 extern QAction *actionEditImportAdd;
 extern QAction *actionEditImportReplace;
 extern QAction *actionEditSaveBranch;
@@ -1343,7 +1347,6 @@
 	}				
 }
 
-
 void MapEditor::addNewBranch(int pos)
 {
 	// Finish open lineEdits
@@ -1410,6 +1413,57 @@
 	}	
 }
 
+
+void MapEditor::addNewBranchHere()
+{
+	// Finish open lineEdits
+	if (lineedit) finishedLineEditNoSave();
+
+	if (selection  &&  
+		 (typeid(*selection) == typeid(BranchObj) ) )
+	{
+		setChanged();
+		saveState(PartOfMap,selection);
+
+		BranchObj* bo1 = (BranchObj*) (selection);
+		bool wasScrolled=false;
+		BranchObj *newbo=NULL;
+		BranchObj *parbo=(BranchObj*)(selection->getParObj());
+		if (parbo)
+		{
+			// add below selection
+			newbo=parbo->insertBranch(bo1->getNum()+1);
+		} 
+
+		LinkableMapObj *oldselection=selection;
+		((BranchObj*)(selection))->moveBranchTo (newbo,-1);
+
+		mapCenter->reposition();
+		adjustCanvasSize();
+		if (actionSettingsAutoedit->isOn() ||
+			actionSettingsAutoselectHeading->isOn() )
+		{
+			selection->unselect();
+			selection=newbo;
+			selection->select();
+			if (actionSettingsPasteNewHeading->isOn() )
+			{
+				BranchObj *bo2= (BranchObj*)(selection);
+				bo2->setHeading("");
+			}	
+			if (actionSettingsAutoedit->isOn() )
+				editHeading();
+			if (!actionSettingsAutoselectHeading->isOn()
+				&& !wasScrolled)
+			{
+				selection->unselect();
+				selection=oldselection;
+				selection->select();
+			}
+		}	
+	}	
+}
+
 void MapEditor::deleteSelection()
 {
 	// Finish open lineEdits
@@ -1459,7 +1513,7 @@
 	// Finally select the found object
 	if (lmo)
 	{
-		if (selection) selection->unselect();
+		if (selection) unselect();
 		selection=lmo;
 		selection->select();
 		adjustCanvasSize();
@@ -2127,6 +2181,33 @@
 	
 }
 
+void MapEditor::removeBranchHere()
+{
+	if (selection && (typeid(*selection) == typeid(BranchObj) ))
+	{		
+		setChanged();
+		saveState(PartOfMap,selection->getParObj());
+		QString sel=selection->getSelectString();
+		BranchObj* bo=(BranchObj*)(selection);
+		BranchObj* par=(BranchObj*)(bo->getParObj());
+		unselect();
+		par->removeBranchHere(bo);
+		mapCenter->reposition();
+		select (sel);
+	}	
+}
+
+void MapEditor::removeChilds()
+{
+	if (selection && (typeid(*selection) == typeid(BranchObj) ))
+	{		
+		setChanged();
+		saveState(PartOfMap,selection->getParObj());
+		((BranchObj*)(selection))->removeChilds();
+		mapCenter->reposition();
+	}	
+}
+
 void MapEditor::editMapInfo()
 {
 	ExtraInfoDialog dia;
@@ -2170,6 +2251,7 @@
 
 void MapEditor::updateActions()
 {
+	QAction *a;
 	if (getLinkColorHint()==HeadingColor) 
 		actionFormatLinkColorHint->setOn(true);
 	else	
@@ -2242,9 +2324,6 @@
 				actionEditOpenURL->setEnabled (false);
 			else	
 				actionEditOpenURL->setEnabled (true);
-			actionEditURL->setEnabled (true);	
-			actionEditHeading2URL->setEnabled (true);	
-			actionEditBugzilla2URL->setEnabled (true);	
 
 			if ( bo->getVymLink().isEmpty() )
 			{
@@ -2255,28 +2334,14 @@
 				actionEditOpenVymLink->setEnabled (true);
 				actionEditDeleteVymLink->setEnabled (true);
 			}	
-			actionEditVymLink->setEnabled (true);	
 
 			actionEditCopy->setEnabled (true);	
 			actionEditCut->setEnabled (true);	
 			actionEditPaste->setEnabled (true);	
-			actionEditMoveUp->setEnabled (true);	
-			actionEditMoveDown->setEnabled (true);	
-			actionEditToggleScroll->setEnabled (true);	
-			actionEditHeading->setEnabled (true);
+			for (a=actionListBranches.first();a;a=actionListBranches.next())
+				a->setEnabled(true);
 			actionEditDelete->setEnabled (true);
-			actionEditAddBranch->setEnabled (true);
-			actionEditAddBranchAbove->setEnabled (true);
-			actionEditAddBranchBelow->setEnabled (true);
-			actionEditImportAdd->setEnabled (true);
-			actionEditImportReplace->setEnabled (true);
-			actionEditSaveBranch->setEnabled (true);
-			actionEditSelectFirst->setEnabled (true);
-			actionEditSelectLast->setEnabled (true);
 			actionEditToggleFloatExport->setEnabled (false);
-			actionFormatPickColor->setEnabled (true);
-			actionFormatColorBranch->setEnabled (true);
-			actionFormatColorSubtree->setEnabled (true);
 			switch (selection->getFrameType())
 			{
 				case NoFrame: 
@@ -2294,34 +2359,17 @@
 			standardFlagsDefault->setEnabled (false);
 
 			actionEditOpenURL->setEnabled (false);
-			actionEditURL->setEnabled (false);	
-			actionEditHeading2URL->setEnabled (false);	
-			actionEditBugzilla2URL->setEnabled (false);	
 			actionEditOpenVymLink->setEnabled (false);
-			actionEditVymLink->setEnabled (false);	
 			actionEditDeleteVymLink->setEnabled (false);	
 
 			actionEditCopy->setEnabled (true);
 			actionEditCut->setEnabled (true);	
 			actionEditPaste->setEnabled (false);	//FIXME
-			actionEditMoveUp->setEnabled (false);	
-			actionEditMoveDown->setEnabled (false);	
-			actionEditToggleScroll->setEnabled (false);	
-			actionEditHeading->setEnabled (false);
+			for (a=actionListBranches.first();a;a=actionListBranches.next())
+				a->setEnabled(false);
 			actionEditDelete->setEnabled (true);
-			actionEditAddBranch->setEnabled (false);
-			actionEditAddBranchAbove->setEnabled (false);
-			actionEditAddBranchBelow->setEnabled (false);
-			actionEditImportAdd->setEnabled (false);
-			actionEditSaveBranch->setEnabled (false);
-			actionEditImportReplace->setEnabled (false);
-			actionEditSelectFirst->setEnabled (false);
-			actionEditSelectLast->setEnabled (false);
 			actionEditToggleFloatExport->setOn
 				( ((FloatImageObj*)(selection))->getFloatExport() );
-			actionFormatPickColor->setEnabled (false);
-			actionFormatColorBranch->setEnabled (false);
-			actionFormatColorSubtree->setEnabled (false);
 		}
 
 	} else
@@ -2331,29 +2379,15 @@
 		actionEditCopy->setEnabled (false);	
 		actionEditCut->setEnabled (false);	
 		actionEditPaste->setEnabled (false);	
-		actionEditMoveUp->setEnabled (false);	
-		actionEditMoveDown->setEnabled (false);	
-		actionEditToggleScroll->setEnabled (false);	
+		for (a=actionListBranches.first();a;a=actionListBranches.next())
+			a->setEnabled(false);
+
 		actionEditOpenURL->setEnabled (false);
-		actionEditURL->setEnabled (false);	
 		actionEditOpenVymLink->setEnabled (false);
-		actionEditVymLink->setEnabled (false);	
 		actionEditDeleteVymLink->setEnabled (false);	
 		actionEditHeading2URL->setEnabled (false);	
-		actionEditBugzilla2URL->setEnabled (false);	
-		actionEditHeading->setEnabled (false);
 		actionEditDelete->setEnabled (false);
-		actionEditAddBranch->setEnabled (false);
-		actionEditAddBranchAbove->setEnabled (false);
-		actionEditAddBranchBelow->setEnabled (false);
-		actionEditSaveBranch->setEnabled (false);
-		actionEditImportReplace->setEnabled (false);
-		actionEditSelectFirst->setEnabled (false);
-		actionEditSelectLast->setEnabled (false);
 		actionEditToggleFloatExport->setEnabled (false);
-		actionFormatPickColor->setEnabled (false);
-		actionFormatColorBranch->setEnabled (false);
-		actionFormatColorSubtree->setEnabled (false);
 	}	
 }
 
@@ -2716,20 +2750,20 @@
 void MapEditor::testFunction()
 {
 	cout << "MapEditor::testFunction() called\n";
-	//cout <<((BranchObj*)(selection))->getSelectString()<<endl;
-	QString tmpdir,prefix;
-	cout << saveToDir(tmpdir,prefix,true,QPoint(0,0),CompleteMap)<<endl;
 }
 
 void MapEditor::ensureSelectionVisible()
 {
-	LinkableMapObj* lmo= dynamic_cast <LinkableMapObj*> (selection);
-	QPoint p;
-	if (selection->getOrientation() == OrientLeftOfCenter)
-		p= worldMatrix().map(QPoint (lmo->x(),lmo->y()));
-	else	
-		p= worldMatrix().map(QPoint (lmo->x()+lmo->width(),lmo->y()+lmo->height()));
-	ensureVisible (p.x(), p.y() );
+	if (selection)
+	{
+		LinkableMapObj* lmo= dynamic_cast <LinkableMapObj*> (selection);
+		QPoint p;
+		if (selection->getOrientation() == OrientLeftOfCenter)
+			p= worldMatrix().map(QPoint (lmo->x(),lmo->y()));
+		else	
+			p= worldMatrix().map(QPoint (lmo->x()+lmo->width(),lmo->y()+lmo->height()));
+		ensureVisible (p.x(), p.y() );
+	}
 
 }
 
diff -r 0b048b6bb6f4 -r 58adc2d2ed08 mapeditor.h
--- a/mapeditor.h	Thu Apr 21 19:14:38 2005 +0000
+++ b/mapeditor.h	Wed May 04 20:35:39 2005 +0000
@@ -74,6 +74,7 @@
     void moveBranchDown();
     void editHeading();
     void addNewBranch(int);			// pos allows to add above/below selection
+    void addNewBranchHere();		// insert and make selection its
     void deleteSelection();
 	LinkableMapObj* getSelection();	// returns selection
 	bool select(const QString &);	// Select 
@@ -106,6 +107,8 @@
 	void editVymLink();						// edit link to another map
 	void deleteVymLink();					// delete link to another map
 	QString getVymLink();					// return path to map
+	void removeBranchHere();				// remove but keep childs
+	void removeChilds();					// remove childs
 	void editMapInfo();						// dialog to enter author, ...
 	void updateActions();					// update e.g. format buttons
 	void setLinkStyle (LinkStyle);			// Set style of link
diff -r 0b048b6bb6f4 -r 58adc2d2ed08 tex/vym.tex
--- a/tex/vym.tex	Thu Apr 21 19:14:38 2005 +0000
+++ b/tex/vym.tex	Wed May 04 20:35:39 2005 +0000
@@ -713,6 +713,11 @@
 \begin{longtable}{|lcp{8cm}l|} \hline
 Version	&	&	Comment								& Date	\\ \hline \hline \endhead
 	\hline \endfoot
+1.6.5	& -	&	removing a branch and keeping its childs	& 2005-05-03 \\
+        & -	&	removing childs of a branch			& \\
+        & -	&	insert branch and make selection its child& \\
+        & -	&	restructured branch context menu	& \\
+				in a basic version (straight line)	& 2005-04-15\\
 1.6.4	& -	&	xLinks (arbitrary connection between 2 branches) works
 				in a basic version (straight line)	& 2005-04-15\\
 1.6.3	& -	&	Bugfix: Saving of selection to a vym part (.vyp)	&2005-03-30\\
diff -r 0b048b6bb6f4 -r 58adc2d2ed08 version.h
--- a/version.h	Thu Apr 21 19:14:38 2005 +0000
+++ b/version.h	Wed May 04 20:35:39 2005 +0000
@@ -1,7 +1,7 @@
 #ifndef VERSION_H 
 #define VERSION_H
 
-#define __VYM_VERSION__ "1.6.4"
-#define __BUILD_DATE__ "April 21, 2005"
+#define __VYM_VERSION__ "1.6.5"
+#define __BUILD_DATE__ "May 4, 2005"
 
 #endif