# HG changeset patch
# User insilmaril
# Date 1225302154 0
# Node ID 96402b17217318a10b15ed6c9dc21dd7c94c498d
# Parent  7f43b93242aa53aad31c9ce2db3dc48a1c9f450d
subtrees can be deleted now

diff -r 7f43b93242aa -r 96402b172173 aboutdialog.cpp
--- a/aboutdialog.cpp	Mon Oct 06 11:10:20 2008 +0000
+++ b/aboutdialog.cpp	Wed Oct 29 17:42:34 2008 +0000
@@ -54,7 +54,11 @@
 	"  <ul>"
 	"    <li>Spanish: <a href=\"http://ieee.udistrital.edu.co/aclibre\">"
 	"                 ACLibre (Academia y Conocimiento Libre)</a> </li>"
-	"    <li>French: Philippe Caillaud, Claude ?</li>"
+	"    <li>French: Philippe Caillaud and Claude </li>"
+	"    <li>Italian: Seyed Puria Nafisi Azizi </li>"
+	"    <li>Brasilian: Amadeu JĂșnior</li>"
+	"    <li>Russion: Anton Olenev</li>"
+	"    <li>Simplified Chinese: Moligaloo</li>"
 	"  </ul>"
 	"</li>"
 	"<li> Patches"
diff -r 7f43b93242aa -r 96402b172173 demos/vym-projectplan.vym
Binary file demos/vym-projectplan.vym has changed
diff -r 7f43b93242aa -r 96402b172173 linkablemapobj.cpp
--- a/linkablemapobj.cpp	Mon Oct 06 11:10:20 2008 +0000
+++ b/linkablemapobj.cpp	Wed Oct 29 17:42:34 2008 +0000
@@ -68,6 +68,7 @@
     childPos=QPointF(0,0);
 	link2ParPos=false;
     l=NULL;
+	p=NULL;
     orientation=UndefinedOrientation;
     linkwidth=20;		
 	thickness_start=8;
@@ -214,9 +215,10 @@
 	if (!model)
 	{
 		qWarning ("LMO::getDefLinkStyle   model=NULL");
-		return UndefinedStyle;
+		//return UndefinedStyle;
 	}
 	Style ls=model->getMapLinkStyle();
+	if (depth==0) return UndefinedStyle;
 	switch (ls)
 	{
 		case Line: 
@@ -245,7 +247,7 @@
 
 void LinkableMapObj::setLinkStyle(Style newstyle)
 {
-	//if (newstyle=style) return;
+	//if (newstyle=style) return; FIXME
 	delLink();
 		
 	style=newstyle;
@@ -404,9 +406,11 @@
 					segment.at(i)->show();
 				break;	
 			case PolyLine:
+				if (!p) cout << "LMO::setVis p==0 (PolyLine)\n"; //FIXME
 				if (p) p->show();
 				break;
 			case PolyParabel:	
+				if (!p) cout << "LMO::setVis p==0 (PolyParabel) "<<((BranchObj*)this)->getHeading().toStdString()<<endl; //FIXME
 				if (p) p->show();
 				break;
 			default:
diff -r 7f43b93242aa -r 96402b172173 mainwindow.cpp
--- a/mainwindow.cpp	Mon Oct 06 11:10:20 2008 +0000
+++ b/mainwindow.cpp	Wed Oct 29 17:42:34 2008 +0000
@@ -1721,30 +1721,6 @@
 {
 	VymView *vm=new VymView (model);
 
-/*
-	// Create TreeView
-	QTreeView *tv=new QTreeView;
-	tv->setModel (model);
-	tv->setMinimumWidth (350);
-	tv->setColumnWidth (0,350);
-
-	// Create good old MapEditor
-	MapEditor* me=model->getMapEditor();
-	if (!me) me=new MapEditor (model);
-	//me->viewport()->setFocus();
-	me->setAntiAlias (actionViewToggleAntiAlias->isOn());
-	me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
-
-	vm->addWidget (tv);
-	vm->addWidget (me);
-
-	// Set geometry
-	QList <int> sizes;
-	sizes.append (150);
-	sizes.append (600);
-	vm->setSizes (sizes);
-
-*/
 	return vm;
 }
 
@@ -1752,8 +1728,8 @@
 {
 	VymModel *m=new VymModel;
 	tabModel.append (m);
-	MapEditor* me = new MapEditor (m);
-	me->setObjectName ("MapEditor");
+	//MapEditor* me = new MapEditor (m);
+	//me->setObjectName ("MapEditor");
 
 	VymView *view=createView (m);
 	tabWidget->addTab (view,tr("unnamed","MainWindow: name for new and empty file"));
@@ -1787,7 +1763,7 @@
 	// Make fn absolute (needed for unzip)
 	fn=QDir (fn).absPath();
 
-	MapEditor *me;
+	VymModel *vm;
 
 	if (lmode==NewMap)
 	{
@@ -1830,15 +1806,15 @@
 	// Try to load map
     if ( !fn.isEmpty() )
 	{
-		me = currentMapEditor();
+		vm = currentModel();
 		// Check first, if mapeditor exists
 		// If it is not default AND we want a new map, 
 		// create a new mapeditor in a new tab
-		if ( lmode==NewMap && (!me || !me->getModel()->isDefault() )  )
+		if ( lmode==NewMap && (!vm || !vm->isDefault() )  )
 		{
-			VymModel *m=new VymModel;
-			tabModel.append (m);
-			VymView *view=createView (m);
+			vm=new VymModel;
+			tabModel.append (vm);
+			VymView *view=createView (vm);
 			tabWidget->addTab (view,fn);
 			tabIndex=tabWidget->count()-1;
 			tabWidget->setCurrentPage (tabIndex);
@@ -1878,20 +1854,20 @@
 
 		//tabWidget->currentPage() won't be NULL here, because of above...
 		tabWidget->setCurrentIndex (tabIndex);
-		me->viewport()->setFocus();
+		//FIXME no me anymore... me->viewport()->setFocus();
 
 		if (err!=aborted)
 		{
 			// Save existing filename in case  we import
-			QString fn_org=me->getModel()->getFilePath();
+			QString fn_org=vm->getFilePath();
 
 			// Finally load map into mapEditor
-			me->getModel()->setFilePath (fn);
-			err=me->getModel()->load(fn,lmode,ftype);
+			vm->setFilePath (fn);
+			err=vm->load(fn,lmode,ftype);
 
 			// Restore old (maybe empty) filepath, if this is an import
 			if (lmode!=NewMap)
-				me->getModel()->setFilePath (fn_org);
+				vm->setFilePath (fn_org);
 		}	
 
 		// Finally check for errors and go home
@@ -1903,13 +1879,13 @@
 		{
 			if (lmode==NewMap)
 			{
-				me->getModel()->setFilePath (fn);
-				tabWidget->setTabText (tabIndex, me->getModel()->getFileName());
+				vm->setFilePath (fn);
+				tabWidget->setTabText (tabIndex, vm->getFileName());
 				if (!isInTmpDir (fn))
 				{
 					// Only append to lastMaps if not loaded from a tmpDir
 					// e.g. imported bookmarks are in a tmpDir
-					addRecentMap(me->getModel()->getFilePath() );
+					addRecentMap(vm->getFilePath() );
 				}
 				actionFilePrint->setEnabled (true);
 			}	
diff -r 7f43b93242aa -r 96402b172173 mapcenterobj.cpp
--- a/mapcenterobj.cpp	Mon Oct 06 11:10:20 2008 +0000
+++ b/mapcenterobj.cpp	Wed Oct 29 17:42:34 2008 +0000
@@ -21,6 +21,13 @@
     init();
 }
 
+MapCenterObj::MapCenterObj(QGraphicsScene* s,VymModel *m) : BranchObj (s)
+{
+//    cout << "Const MapCenterObj   canvas="<<s<<"\n";
+	model=m;
+    init();
+}
+
 MapCenterObj::~MapCenterObj() 
 {
 //    cout << "Destr MapCenterObj\n";
diff -r 7f43b93242aa -r 96402b172173 mapcenterobj.h
--- a/mapcenterobj.h	Mon Oct 06 11:10:20 2008 +0000
+++ b/mapcenterobj.h	Wed Oct 29 17:42:34 2008 +0000
@@ -6,6 +6,9 @@
 
 #include "branchobj.h"
 
+
+class VymModel;
+
 /*! \brief The center of the map is a special branch. */
 
 /////////////////////////////////////////////////////////////////////////////
@@ -13,6 +16,7 @@
 public:
     MapCenterObj ();
     MapCenterObj (QGraphicsScene *);
+    MapCenterObj (QGraphicsScene *, VymModel *);
     ~MapCenterObj ();
     void clear();
     void init();
diff -r 7f43b93242aa -r 96402b172173 mapeditor.cpp
--- a/mapeditor.cpp	Mon Oct 06 11:10:20 2008 +0000
+++ b/mapeditor.cpp	Wed Oct 29 17:42:34 2008 +0000
@@ -44,7 +44,7 @@
 	model->setScene (mapScene);
 	model->registerEditor(this);
 	model->addMapCenter();	//  FIXME create this in MapEditor until BO and MCO are independent of scene
-	model->makeDefault();
+	model->makeDefault();	// No changes in model so far
 
     setScene (mapScene);
 
diff -r 7f43b93242aa -r 96402b172173 treeitem.cpp
--- a/treeitem.cpp	Mon Oct 06 11:10:20 2008 +0000
+++ b/treeitem.cpp	Wed Oct 29 17:42:34 2008 +0000
@@ -19,6 +19,16 @@
     childItems.append(item);
 }
 
+void TreeItem::removeChild(int row)
+{
+    if (row>=0)
+	{
+		delete (childItems.at(row) );
+		childItems.removeAt (row);
+	} else
+		qWarning ("TreeItem::removeChild tried to remove non existing item?!\n");
+}
+
 TreeItem *TreeItem::child(int row)
 {
     return childItems.value(row);
@@ -33,6 +43,24 @@
 {
     return itemData.count();
 }
+int TreeItem::row() const
+{
+    if (parentItem)
+        return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
+
+    return 0;
+}
+
+int TreeItem::column() const
+{
+    return 0;
+}
+
+TreeItem *TreeItem::parent()
+{
+    return parentItem;
+}
+
 
 QVariant TreeItem::data(int column) const
 {
@@ -71,25 +99,7 @@
 	}
 }
 
-int TreeItem::row() const
-{
-    if (parentItem)
-        return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
-
-    return 0;
-}
-
-int TreeItem::column() const
-{
-    return 0;
-}
-
-TreeItem *TreeItem::parent()
-{
-    return parentItem;
-}
-
-LinkableMapObj* TreeItem::getLMO()
+LinkableMapObj* TreeItem::getLMO()	// FIXME VM should be unnecessary in the end
 {
 	return lmo;
 }
diff -r 7f43b93242aa -r 96402b172173 treeitem.h
--- a/treeitem.h	Mon Oct 06 11:10:20 2008 +0000
+++ b/treeitem.h	Wed Oct 29 17:42:34 2008 +0000
@@ -13,11 +13,19 @@
     TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
     ~TreeItem();
 
-    void appendChild(TreeItem *child);
+	// General housekeeping
+    void appendChild (TreeItem *child);
+	void removeChild (int row);
 
     TreeItem *child(int row);
     int childCount() const;
     int columnCount() const;
+
+    int row() const;
+	int column() const;
+    TreeItem *parent();
+
+	// Accessing data
     QVariant data(int column) const;
 	void setHeading (const QString s);
 	QString getHeading();
@@ -25,10 +33,6 @@
 	Type getType ();
 	QString getTypeName ();
 	
-    int row() const;
-	int column() const;
-    TreeItem *parent();
-
 	// Relation to map objects in graphicsscene
 	LinkableMapObj* getLMO();
 	void setLMO (LinkableMapObj*);
diff -r 7f43b93242aa -r 96402b172173 treemodel.cpp
--- a/treemodel.cpp	Mon Oct 06 11:10:20 2008 +0000
+++ b/treemodel.cpp	Wed Oct 29 17:42:34 2008 +0000
@@ -12,7 +12,6 @@
     QList<QVariant> rootData;
     rootData << "Heading" << "Type" <<"Note";
     rootItem = new TreeItem(rootData);
- //   setupModelData(rootItem);
 }
 
 TreeModel::~TreeModel()
@@ -242,41 +241,26 @@
 	*/
 }
 
+#include <iostream>
+bool TreeModel::removeRows ( int row, int count, const QModelIndex & parent)
+{
+	int last=row+count-1;
+	beginRemoveRows (parent,row,last);
+
+    TreeItem *pi= static_cast<TreeItem*>(parent.internalPointer());
+    TreeItem *ti;
+	for (int i=row; i<=last; i++)
+	{
+		std::cout << "TreeModel::removeRows removing i="<<i<<std::endl;
+		pi->removeChild (row);
+	}
+
+	endRemoveRows ();
+	
+}
+
 QModelIndex TreeModel::index (TreeItem* ti)
 {
 	return createIndex (ti->row(),ti->column(),ti);
 }
 
-TreeItem* TreeModel::LMOToItem (LinkableMapObj *lmo)// FIXME not used so far!!!
-{
-	TreeItem *ti=rootItem;		
-}
-
-void TreeModel::setupModelData(TreeItem *root)	// FIXME not needed anymore
-{
-	QList<QVariant> cData;
-
-	cData << "Center of map" << "MapCenter"<<"Data 1";
-	TreeItem *mco=new TreeItem (cData,root);
-	root->appendChild (mco);
-
-	cData.clear();
-	cData << "Main A" << "Branch"<<"Data 2";
-	TreeItem *bo=new TreeItem (cData,mco);
-	mco->appendChild (bo);
-	TreeItem *mainA=bo;
-
-	cData.clear();
-	cData << "Sub a" << "Branch"<<"Data";
-	bo=new TreeItem (cData,mainA);
-	mainA->appendChild (bo);
-
-	cData.clear();
-	cData << "Sub b" << "Branch"<<"Data";
-	bo=new TreeItem (cData,mainA);
-	mainA->appendChild (bo);
-
-	cData.clear();
-	cData << "Main B"<<"Branch" <<"Data 3";
-	mco->appendChild(new TreeItem(cData, mco));
-}
diff -r 7f43b93242aa -r 96402b172173 treemodel.h
--- a/treemodel.h	Mon Oct 06 11:10:20 2008 +0000
+++ b/treemodel.h	Wed Oct 29 17:42:34 2008 +0000
@@ -30,10 +30,11 @@
 	TreeItem *first();
 	TreeItem *next();
 
+	bool removeRows ( int row, int count, 
+				const QModelIndex & parent = QModelIndex() ); 
+
 protected:
 	QModelIndex index (TreeItem* ti);
-	TreeItem *LMOToItem(LinkableMapObj*);
-    void setupModelData(TreeItem *parent);
 
     TreeItem *rootItem;
 	static TreeItem* itFirst;
diff -r 7f43b93242aa -r 96402b172173 version.h
--- a/version.h	Mon Oct 06 11:10:20 2008 +0000
+++ b/version.h	Wed Oct 29 17:42:34 2008 +0000
@@ -7,7 +7,7 @@
 #define __VYM_VERSION "1.13.0"
 //#define __VYM_CODENAME "Codename: RC-1"
 #define __VYM_CODENAME "Codename: development version"
-#define __VYM_BUILD_DATE "2008-09-10"
+#define __VYM_BUILD_DATE "2008-10-29"
 
 
 bool checkVersion(const QString &);
diff -r 7f43b93242aa -r 96402b172173 vymmodel.cpp
--- a/vymmodel.cpp	Mon Oct 06 11:10:20 2008 +0000
+++ b/vymmodel.cpp	Wed Oct 29 17:42:34 2008 +0000
@@ -67,16 +67,24 @@
 
 void VymModel::clear() 
 {
+	cout << "VymModel::clear   rows="<<rowCount(index(rootItem))<<endl;	
 	selection.clear();
 
-	while (!mapCenters.isEmpty())
+	// Remove stuff    
+	while (!mapCenters.isEmpty())			// FIXME VM needs to be in treemodel only...
 		delete mapCenters.takeFirst();
+
+	QModelIndex ri=index(rootItem);
+	removeRows (0, rowCount(ri),ri);	
 }
 
 void VymModel::init () 
 {
 	// We should have at least one map center to start with
-	// addMapCenter();  FIXME create this in MapEditor as long as model is part of that
+	// addMapCenter();  FIXME VM create this in MapEditor as long as model is part of that
+
+	// No MapEditor yet
+	mapEditor=NULL;
 
 	// History 
 	mapNum++;
@@ -143,7 +151,7 @@
 	netstate=Offline;
 
 	// Create MapCenter
-	//  addMapCenter();  FIXME create this in MapEditor until BO and MCO are independent of scene
+	//  addMapCenter();  FIXME VM create this in MapEditor until BO and MCO are independent of scene
 
 }
 
@@ -157,7 +165,7 @@
 }
 
 
-MapEditor* VymModel::getMapEditor()	// FIXME better return favourite editor here
+MapEditor* VymModel::getMapEditor()	// FIXME VM better return favourite editor here
 {
 	return mapEditor;
 }
@@ -329,7 +337,7 @@
 	if (lmode==NewMap)
 	{
 		selection.clear();
-		// FIXME not needed??? model->setMapEditor(this);
+		// FIXME VM not needed??? model->setMapEditor(this);
 		// (map state is set later at end of load...)
 	} else
 	{
@@ -443,7 +451,7 @@
 		file.close();
 		if ( ok ) 
 		{
-			reposition();	// FIXME reposition the view instead...
+			reposition();	// FIXME VM reposition the view instead...
 			selection.update();
 			if (lmode==NewMap)
 			{
@@ -469,7 +477,6 @@
 	removeDir (QDir(tmpZipDir));
 
 	updateActions();
-
 	return err;
 }
 
@@ -688,7 +695,7 @@
 		fio=bo->getLastFloatImage();
 		fio->load(fn);
 		reposition();
-		// FIXME needed? scene()->update();
+		// FIXME VM needed? scene()->update();
 		return fio;
 	}
 	return NULL;
@@ -869,7 +876,7 @@
 		{
 			importDirInt (fd->selectedFile() );
 			reposition();
-			//FIXME needed? scene()->update();
+			//FIXME VM needed? scene()->update();
 		}
 	}	
 }
@@ -906,7 +913,7 @@
 		QDateTime tmod=QFileInfo (filePath).lastModified();
 		if (tmod>fileChangedTime)
 		{
-			// FIXME switch to current mapeditor and finish lineedits...
+			// FIXME VM switch to current mapeditor and finish lineedits...
 			QMessageBox mb( vymName,
 				tr("The file of the map  on disk has changed:\n\n"  
 				   "   %1\n\nDo you want to reload that map with the new file?").arg(filePath),
@@ -1485,25 +1492,21 @@
 			QString("Set heading of %1 to \"%2\"").arg(getObjectName(sel)).arg(s) );
 		sel->setHeading(s );
 		TreeItem *ti=selection.getBranchItem();
-		if (ti) ti->setHeading (s);
-		//FIXME ix is wrong ModelIndex below, ix2 is (hopefully) correct:
-		QModelIndex ix=index( ti->row(), ti->column(), index (0,0,QModelIndex()) );
-		cout <<"VM::setHeading  s="<<s.toStdString()<<"  ti="<<ti<<"  r,c=("<<ti->row()<<","<<ti->column()<<")"<<endl;
-		QModelIndex ix2=index (ti);
-		emit (dataChanged ( ix2,ix2));
-		cout <<"                (r,c)=("<<ix2.row()<<","<<ix2.column()<<")"<<endl;
-
-		// FIXME playing around with selections:
-		// but somehow not all mco are visible in tree then???
-//		if (mapEditor)
-		if (NULL)
+		if (ti)
 		{
-			
-			QItemSelectionModel *selectionModel=mapEditor->selectionModel();
-			selectionModel->clear();
-			QItemSelection sel (ix2,ix2);
-			selectionModel->select (sel, QItemSelectionModel::Select);
+			ti->setHeading (s);
+			//FIXME VM ix is wrong ModelIndex below, ix2 is (hopefully) correct:
+			QModelIndex ix=index( ti->row(), ti->column(), index (0,0,QModelIndex()) );
+			//FIXME VM testing only cout <<"VM::setHeading  s="<<s.toStdString()<<"  ti="<<ti<<"  r,c=("<<ti->row()<<","<<ti->column()<<")"<<endl;
+			QModelIndex ix2=index (ti);
+			emit (dataChanged ( ix2,ix2));
 		}
+		else
+		{
+			cout << "Warning: VM::setHeading ti==NULL\n";
+		}
+
+		//cout <<"                (r,c)=("<<ix2.row()<<","<<ix2.column()<<")"<<endl;
 
 		reposition();
 		selection.update();
@@ -1824,7 +1827,7 @@
 		updateActions();
 		reposition();
 		selection.update();
-		// FIXME needed? scene()->update();
+		// FIXME VM needed? scene()->update();
 	}
 }
 
@@ -1926,7 +1929,7 @@
 		BranchObj *obo=par->moveBranchUp (bo);	// bo will be the one below selection
 		saveState (getSelectString(bo),"moveBranchDown ()",getSelectString(obo),"moveBranchUp ()",QString("Move up %1").arg(getObjectName(bo)));
 		reposition();
-		//FIXME needed? scene()->update();
+		//FIXME VM needed? scene()->update();
 		selection.update();
 		ensureSelectionVisible();
 	}
@@ -1943,7 +1946,7 @@
 		BranchObj *obo=par->moveBranchDown(bo);	// bo will be the one above selection
 		saveState(getSelectString(bo),"moveBranchUp ()",getSelectString(obo),"moveBranchDown ()",QString("Move down %1").arg(getObjectName(bo)));
 		reposition();
-		//FIXME needed? scene()->update();
+		//FIXME VM needed? scene()->update();
 		selection.update();
 		ensureSelectionVisible();
 	}	
@@ -1975,7 +1978,7 @@
 	BranchObj *bo=selection.getBranch();
 	if (bo)
 	{
-		BranchObj *newbo=addNewBranchInt (-2); // FIXME Old model, merge with below
+		BranchObj *newbo=addNewBranchInt (-2); // FIXME VM Old model, merge with below
 
 		// Create TreeItem
 		QList<QVariant> cData;
@@ -1989,7 +1992,7 @@
 		if (newbo)
 		{
 			newbo->setTreeItem (ti);
-			selection.select (newbo);
+			selection.select (newbo); // FIXME VM really needed here?
 		}
 	}
 }
@@ -2012,11 +2015,11 @@
 
 MapCenterObj* VymModel::addMapCenter(QPointF absPos)
 {
-	MapCenterObj *mapCenter = new MapCenterObj(mapScene);
+	MapCenterObj *mapCenter = new MapCenterObj(mapScene,this);
+	mapCenter->setMapEditor(mapEditor);		//FIXME VM needed to get defLinkStyle, mapLinkColorHint ... for later added objects
 	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
 	mapCenters.append(mapCenter);
 
 	// Create TreeItem
@@ -2097,7 +2100,7 @@
 
 	if (bo)
 	{
-		// FIXME  do we still need this in model? setCursor (Qt::ArrowCursor);
+		// FIXME VM  do we still need this in model? setCursor (Qt::ArrowCursor);
 
 		newbo=addNewBranchInt (pos-2);
 
@@ -2165,7 +2168,7 @@
 	{
 	//	BranchObj* par=(BranchObj*)(bo->getParObj());
 		selection.unselect();
-	/* FIXME Note:  does saveStateRemovingPart work for MCO? (No parent!)
+	/* FIXME VM Note:  does saveStateRemovingPart work for MCO? (No parent!)
 		saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
 		*/
 		bo=removeMapCenter ((MapCenterObj*)bo);
@@ -2287,7 +2290,7 @@
 		);
 		bo->toggleScroll();
 		selection.update();
-		// FIXME needed? scene()->update();
+		// FIXME VM needed? scene()->update();
 		return true;
 	}	
 	return false;
@@ -2312,7 +2315,7 @@
 		);
 		bo->toggleScroll();
 		selection.update();
-		// FIXME needed? scene()->update();
+		// FIXME VM needed? scene()->update();
 		return true;
 	}	
 	return false;
@@ -2355,7 +2358,7 @@
 	saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",fio  );
 	saveState (fio,"delete ()", bo,QString("paste(%1)").arg(curStep),"Pasting dropped image");
     reposition();
-    // FIXME needed? scene()->update();
+    // FIXME VM needed? scene()->update();
   }
 }
 
@@ -2540,7 +2543,7 @@
 		bo->setVymLink ("" );
 		updateActions();
 		reposition();
-		// FIXME needed? scene()->update();
+		// FIXME VM needed? scene()->update();
 	}
 }
 
@@ -2585,7 +2588,7 @@
 	}
 }
 
-void VymModel::editXLink(int i)	// FIXME missing saveState
+void VymModel::editXLink(int i)	// FIXME VM missing saveState
 {
 	BranchObj *bo=selection.getBranch();
 	if (bo)
@@ -3867,14 +3870,24 @@
 void VymModel::setMapLinkStyle (const QString & s)
 {
 	QString snow;
-	if (linkstyle==LinkableMapObj::Line)
-		snow="StyleLine";
-	else if (linkstyle==LinkableMapObj::Parabel)
-		snow="StyleParabel";
-	else if (linkstyle==LinkableMapObj::PolyLine)
-		snow="StylePolyLine";
-	else if (linkstyle==LinkableMapObj::PolyParabel)
-		snow="StyleParabel";
+	switch (linkstyle)
+	{
+		case LinkableMapObj::Line :
+			snow="StyleLine";
+			break;
+		case LinkableMapObj::Parabel:
+			snow="StyleParabel";
+			break;
+		case LinkableMapObj::PolyLine:
+			snow="StylePolyLine";
+			break;
+		case LinkableMapObj::PolyParabel:
+			snow="StylePolyParabel";
+			break;
+		default:	
+			snow="UndefinedStyle";
+			break;
+	}
 
 	saveState (
 		QString("setMapLinkStyle (\"%1\")").arg(s),
@@ -3888,8 +3901,10 @@
 		linkstyle=LinkableMapObj::Parabel;
 	else if (s=="StylePolyLine")
 		linkstyle=LinkableMapObj::PolyLine;
-	else	
+	else if (s=="StylePolyParabel")	
 		linkstyle=LinkableMapObj::PolyParabel;
+	else
+		linkstyle=LinkableMapObj::UndefinedStyle;
 
 	BranchObj *bo;
 	bo=first();
@@ -4341,6 +4356,11 @@
 // Selection related
 //////////////////////////////////////////////
 
+void VymModel::setSelectionModel (QItemSelectionModel *sm)
+{
+	selModel=sm;
+}
+
 void VymModel::setSelectionBlocked (bool b)
 {
 	if (b)
@@ -4354,6 +4374,14 @@
 	return selection.isBlocked();
 }
 
+bool VymModel::select ()
+{
+	QModelIndex index=selModel->selectedIndexes().first();	// TODO no multiselections yet
+
+	TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
+	return select (item->getLMO() );
+}
+
 bool VymModel::select (const QString &s)
 {
 	if (selection.select(s))
diff -r 7f43b93242aa -r 96402b172173 vymmodel.h
--- a/vymmodel.h	Mon Oct 06 11:10:20 2008 +0000
+++ b/vymmodel.h	Wed Oct 29 17:42:34 2008 +0000
@@ -525,11 +525,14 @@
 	QString latestSelectionString;	// select string of latest added object
 
 public:
+	void setSelectionModel(QItemSelectionModel *);		// Set common selectionModel
+
 	void setSelectionBlocked(bool);
 	bool isSelectionBlocked();
 
-	bool select(const QString &);			// Select by string
-	bool select(LinkableMapObj *lmo);		// Select by pointer
+	bool select ();							// select by using common QItemSlectionModel
+	bool select (const QString &);			// Select by string
+	bool select (LinkableMapObj *lmo);		// Select by pointer
 	void unselect();
 	void reselect();
 
@@ -562,6 +565,8 @@
     void selectMapSelectionColor();
 private:	
     void setSelectionColorInt(QColor);
+	QItemSelectionModel *selModel;
+
 public:	
     void setSelectionColor(QColor);
     QColor getSelectionColor();
diff -r 7f43b93242aa -r 96402b172173 vymview.cpp
--- a/vymview.cpp	Mon Oct 06 11:10:20 2008 +0000
+++ b/vymview.cpp	Wed Oct 29 17:42:34 2008 +0000
@@ -1,20 +1,29 @@
 #include "vymview.h"
 
+#include <iostream>
+
 #include "mapeditor.h"
 
 VymView::VymView(VymModel *model)
 {
 	// Create TreeView
-	QTreeView *treeview=new QTreeView;
+	treeview=new QTreeView;
 	treeview->setModel ((QAbstractItemModel*)model);
 	treeview->setMinimumWidth (350);
 	treeview->setColumnWidth (0,350);
 
+	// ItemSelectionModel
+	selModel=treeview->selectionModel();
+	connect (
+		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
+		this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
+	model->setSelectionModel (selModel);
+
 	// Create good old MapEditor
 	MapEditor* me=model->getMapEditor();
 	if (!me) me=new MapEditor (model);
 
-	me->setSelectionModel (treeview->selectionModel() );
+	me->setSelectionModel (selModel);
 
 	//me->viewport()->setFocus();
 	//FIXME me->setAntiAlias (actionViewToggleAntiAlias->isOn());
@@ -32,8 +41,17 @@
 
 QItemSelectionModel* VymView::selectionModel() 
 {
-	if (treeview) return treeview->selectionModel();
+	if (treeview) return selModel;
+	else std::cout <<"hey, no treeview so far???\n";
 	return NULL;
 }
 
 
+void VymView::changeSelection (const QItemSelection &newSel, const QItemSelection &delSel)
+{
+	// FIXME Currently this works only from treeview->ME
+	treeview->expandAll();	//FIXME only for testing
+
+	((VymModel*)treeview->model())->select ();
+}
+
diff -r 7f43b93242aa -r 96402b172173 vymview.h
--- a/vymview.h	Mon Oct 06 11:10:20 2008 +0000
+++ b/vymview.h	Wed Oct 29 17:42:34 2008 +0000
@@ -10,11 +10,17 @@
 
 class VymView : public QSplitter 
 {
+	Q_OBJECT
 public:
 	VymView(VymModel *model);
 	QItemSelectionModel* selectionModel();
+
+public slots:
+	void changeSelection (const QItemSelection &newSel, const QItemSelection &delSel);
+
 private:
 	QTreeView *treeview;
+	QItemSelectionModel *selModel;
 };
 
 
diff -r 7f43b93242aa -r 96402b172173 xml-vym.cpp
--- a/xml-vym.cpp	Mon Oct 06 11:10:20 2008 +0000
+++ b/xml-vym.cpp	Wed Oct 29 17:42:34 2008 +0000
@@ -47,25 +47,6 @@
 	{
         state = StateMap;
 
-		if (loadMode==NewMap)
-			model->clear();	// remove existing mapCenter
-
-		// Check version
-		if (!atts.value( "version").isEmpty() ) 
-		{
-			if (!checkVersion(atts.value("version")))
-				QMessageBox::warning( 0, "Warning: Version Problem" ,
-				   "<h3>Map is newer than VYM</h3>"
-				   "<p>The map you are just trying to load was "
-				   "saved using vym " +atts.value("version")+". "
-				   "The version of this vym is " + vymVersion + 
-				   ". If you run into problems after pressing "
-				   "the ok-button below, updating vym should help.");
-			else	   
-				model->setVersion(atts.value( "version" ));
-
-		}
-
 		if (loadMode==NewMap )
 		{
 			// Create mapCenter
@@ -108,6 +89,22 @@
 			if (!atts.value( "defXLinkWidth").isEmpty() ) 
 				model->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
 		}	
+		// Check version
+		if (!atts.value( "version").isEmpty() ) 
+		{
+			if (!checkVersion(atts.value("version")))
+				QMessageBox::warning( 0, "Warning: Version Problem" ,
+				   "<h3>Map is newer than VYM</h3>"
+				   "<p>The map you are just trying to load was "
+				   "saved using vym " +atts.value("version")+". "
+				   "The version of this vym is " + vymVersion + 
+				   ". If you run into problems after pressing "
+				   "the ok-button below, updating vym should help.");
+			else	   
+				model->setVersion(atts.value( "version" ));
+
+		}
+
 	} else if ( eName == "select" && state == StateMap ) 
 	{
 		state=StateMapSelect;