subtrees can be deleted now
authorinsilmaril
Wed Oct 29 17:42:34 2008 +0000 (2008-10-29)
changeset 72796402b172173
parent 726 7f43b93242aa
child 728 a8a98a94899a
subtrees can be deleted now
aboutdialog.cpp
demos/vym-projectplan.vym
linkablemapobj.cpp
mainwindow.cpp
mapcenterobj.cpp
mapcenterobj.h
mapeditor.cpp
treeitem.cpp
treeitem.h
treemodel.cpp
treemodel.h
version.h
vymmodel.cpp
vymmodel.h
vymview.cpp
vymview.h
xml-vym.cpp
     1.1 --- a/aboutdialog.cpp	Mon Oct 06 11:10:20 2008 +0000
     1.2 +++ b/aboutdialog.cpp	Wed Oct 29 17:42:34 2008 +0000
     1.3 @@ -54,7 +54,11 @@
     1.4  	"  <ul>"
     1.5  	"    <li>Spanish: <a href=\"http://ieee.udistrital.edu.co/aclibre\">"
     1.6  	"                 ACLibre (Academia y Conocimiento Libre)</a> </li>"
     1.7 -	"    <li>French: Philippe Caillaud, Claude ?</li>"
     1.8 +	"    <li>French: Philippe Caillaud and Claude </li>"
     1.9 +	"    <li>Italian: Seyed Puria Nafisi Azizi </li>"
    1.10 +	"    <li>Brasilian: Amadeu Júnior</li>"
    1.11 +	"    <li>Russion: Anton Olenev</li>"
    1.12 +	"    <li>Simplified Chinese: Moligaloo</li>"
    1.13  	"  </ul>"
    1.14  	"</li>"
    1.15  	"<li> Patches"
     2.1 Binary file demos/vym-projectplan.vym has changed
     3.1 --- a/linkablemapobj.cpp	Mon Oct 06 11:10:20 2008 +0000
     3.2 +++ b/linkablemapobj.cpp	Wed Oct 29 17:42:34 2008 +0000
     3.3 @@ -68,6 +68,7 @@
     3.4      childPos=QPointF(0,0);
     3.5  	link2ParPos=false;
     3.6      l=NULL;
     3.7 +	p=NULL;
     3.8      orientation=UndefinedOrientation;
     3.9      linkwidth=20;		
    3.10  	thickness_start=8;
    3.11 @@ -214,9 +215,10 @@
    3.12  	if (!model)
    3.13  	{
    3.14  		qWarning ("LMO::getDefLinkStyle   model=NULL");
    3.15 -		return UndefinedStyle;
    3.16 +		//return UndefinedStyle;
    3.17  	}
    3.18  	Style ls=model->getMapLinkStyle();
    3.19 +	if (depth==0) return UndefinedStyle;
    3.20  	switch (ls)
    3.21  	{
    3.22  		case Line: 
    3.23 @@ -245,7 +247,7 @@
    3.24  
    3.25  void LinkableMapObj::setLinkStyle(Style newstyle)
    3.26  {
    3.27 -	//if (newstyle=style) return;
    3.28 +	//if (newstyle=style) return; FIXME
    3.29  	delLink();
    3.30  		
    3.31  	style=newstyle;
    3.32 @@ -404,9 +406,11 @@
    3.33  					segment.at(i)->show();
    3.34  				break;	
    3.35  			case PolyLine:
    3.36 +				if (!p) cout << "LMO::setVis p==0 (PolyLine)\n"; //FIXME
    3.37  				if (p) p->show();
    3.38  				break;
    3.39  			case PolyParabel:	
    3.40 +				if (!p) cout << "LMO::setVis p==0 (PolyParabel) "<<((BranchObj*)this)->getHeading().toStdString()<<endl; //FIXME
    3.41  				if (p) p->show();
    3.42  				break;
    3.43  			default:
     4.1 --- a/mainwindow.cpp	Mon Oct 06 11:10:20 2008 +0000
     4.2 +++ b/mainwindow.cpp	Wed Oct 29 17:42:34 2008 +0000
     4.3 @@ -1721,30 +1721,6 @@
     4.4  {
     4.5  	VymView *vm=new VymView (model);
     4.6  
     4.7 -/*
     4.8 -	// Create TreeView
     4.9 -	QTreeView *tv=new QTreeView;
    4.10 -	tv->setModel (model);
    4.11 -	tv->setMinimumWidth (350);
    4.12 -	tv->setColumnWidth (0,350);
    4.13 -
    4.14 -	// Create good old MapEditor
    4.15 -	MapEditor* me=model->getMapEditor();
    4.16 -	if (!me) me=new MapEditor (model);
    4.17 -	//me->viewport()->setFocus();
    4.18 -	me->setAntiAlias (actionViewToggleAntiAlias->isOn());
    4.19 -	me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
    4.20 -
    4.21 -	vm->addWidget (tv);
    4.22 -	vm->addWidget (me);
    4.23 -
    4.24 -	// Set geometry
    4.25 -	QList <int> sizes;
    4.26 -	sizes.append (150);
    4.27 -	sizes.append (600);
    4.28 -	vm->setSizes (sizes);
    4.29 -
    4.30 -*/
    4.31  	return vm;
    4.32  }
    4.33  
    4.34 @@ -1752,8 +1728,8 @@
    4.35  {
    4.36  	VymModel *m=new VymModel;
    4.37  	tabModel.append (m);
    4.38 -	MapEditor* me = new MapEditor (m);
    4.39 -	me->setObjectName ("MapEditor");
    4.40 +	//MapEditor* me = new MapEditor (m);
    4.41 +	//me->setObjectName ("MapEditor");
    4.42  
    4.43  	VymView *view=createView (m);
    4.44  	tabWidget->addTab (view,tr("unnamed","MainWindow: name for new and empty file"));
    4.45 @@ -1787,7 +1763,7 @@
    4.46  	// Make fn absolute (needed for unzip)
    4.47  	fn=QDir (fn).absPath();
    4.48  
    4.49 -	MapEditor *me;
    4.50 +	VymModel *vm;
    4.51  
    4.52  	if (lmode==NewMap)
    4.53  	{
    4.54 @@ -1830,15 +1806,15 @@
    4.55  	// Try to load map
    4.56      if ( !fn.isEmpty() )
    4.57  	{
    4.58 -		me = currentMapEditor();
    4.59 +		vm = currentModel();
    4.60  		// Check first, if mapeditor exists
    4.61  		// If it is not default AND we want a new map, 
    4.62  		// create a new mapeditor in a new tab
    4.63 -		if ( lmode==NewMap && (!me || !me->getModel()->isDefault() )  )
    4.64 +		if ( lmode==NewMap && (!vm || !vm->isDefault() )  )
    4.65  		{
    4.66 -			VymModel *m=new VymModel;
    4.67 -			tabModel.append (m);
    4.68 -			VymView *view=createView (m);
    4.69 +			vm=new VymModel;
    4.70 +			tabModel.append (vm);
    4.71 +			VymView *view=createView (vm);
    4.72  			tabWidget->addTab (view,fn);
    4.73  			tabIndex=tabWidget->count()-1;
    4.74  			tabWidget->setCurrentPage (tabIndex);
    4.75 @@ -1878,20 +1854,20 @@
    4.76  
    4.77  		//tabWidget->currentPage() won't be NULL here, because of above...
    4.78  		tabWidget->setCurrentIndex (tabIndex);
    4.79 -		me->viewport()->setFocus();
    4.80 +		//FIXME no me anymore... me->viewport()->setFocus();
    4.81  
    4.82  		if (err!=aborted)
    4.83  		{
    4.84  			// Save existing filename in case  we import
    4.85 -			QString fn_org=me->getModel()->getFilePath();
    4.86 +			QString fn_org=vm->getFilePath();
    4.87  
    4.88  			// Finally load map into mapEditor
    4.89 -			me->getModel()->setFilePath (fn);
    4.90 -			err=me->getModel()->load(fn,lmode,ftype);
    4.91 +			vm->setFilePath (fn);
    4.92 +			err=vm->load(fn,lmode,ftype);
    4.93  
    4.94  			// Restore old (maybe empty) filepath, if this is an import
    4.95  			if (lmode!=NewMap)
    4.96 -				me->getModel()->setFilePath (fn_org);
    4.97 +				vm->setFilePath (fn_org);
    4.98  		}	
    4.99  
   4.100  		// Finally check for errors and go home
   4.101 @@ -1903,13 +1879,13 @@
   4.102  		{
   4.103  			if (lmode==NewMap)
   4.104  			{
   4.105 -				me->getModel()->setFilePath (fn);
   4.106 -				tabWidget->setTabText (tabIndex, me->getModel()->getFileName());
   4.107 +				vm->setFilePath (fn);
   4.108 +				tabWidget->setTabText (tabIndex, vm->getFileName());
   4.109  				if (!isInTmpDir (fn))
   4.110  				{
   4.111  					// Only append to lastMaps if not loaded from a tmpDir
   4.112  					// e.g. imported bookmarks are in a tmpDir
   4.113 -					addRecentMap(me->getModel()->getFilePath() );
   4.114 +					addRecentMap(vm->getFilePath() );
   4.115  				}
   4.116  				actionFilePrint->setEnabled (true);
   4.117  			}	
     5.1 --- a/mapcenterobj.cpp	Mon Oct 06 11:10:20 2008 +0000
     5.2 +++ b/mapcenterobj.cpp	Wed Oct 29 17:42:34 2008 +0000
     5.3 @@ -21,6 +21,13 @@
     5.4      init();
     5.5  }
     5.6  
     5.7 +MapCenterObj::MapCenterObj(QGraphicsScene* s,VymModel *m) : BranchObj (s)
     5.8 +{
     5.9 +//    cout << "Const MapCenterObj   canvas="<<s<<"\n";
    5.10 +	model=m;
    5.11 +    init();
    5.12 +}
    5.13 +
    5.14  MapCenterObj::~MapCenterObj() 
    5.15  {
    5.16  //    cout << "Destr MapCenterObj\n";
     6.1 --- a/mapcenterobj.h	Mon Oct 06 11:10:20 2008 +0000
     6.2 +++ b/mapcenterobj.h	Wed Oct 29 17:42:34 2008 +0000
     6.3 @@ -6,6 +6,9 @@
     6.4  
     6.5  #include "branchobj.h"
     6.6  
     6.7 +
     6.8 +class VymModel;
     6.9 +
    6.10  /*! \brief The center of the map is a special branch. */
    6.11  
    6.12  /////////////////////////////////////////////////////////////////////////////
    6.13 @@ -13,6 +16,7 @@
    6.14  public:
    6.15      MapCenterObj ();
    6.16      MapCenterObj (QGraphicsScene *);
    6.17 +    MapCenterObj (QGraphicsScene *, VymModel *);
    6.18      ~MapCenterObj ();
    6.19      void clear();
    6.20      void init();
     7.1 --- a/mapeditor.cpp	Mon Oct 06 11:10:20 2008 +0000
     7.2 +++ b/mapeditor.cpp	Wed Oct 29 17:42:34 2008 +0000
     7.3 @@ -44,7 +44,7 @@
     7.4  	model->setScene (mapScene);
     7.5  	model->registerEditor(this);
     7.6  	model->addMapCenter();	//  FIXME create this in MapEditor until BO and MCO are independent of scene
     7.7 -	model->makeDefault();
     7.8 +	model->makeDefault();	// No changes in model so far
     7.9  
    7.10      setScene (mapScene);
    7.11  
     8.1 --- a/treeitem.cpp	Mon Oct 06 11:10:20 2008 +0000
     8.2 +++ b/treeitem.cpp	Wed Oct 29 17:42:34 2008 +0000
     8.3 @@ -19,6 +19,16 @@
     8.4      childItems.append(item);
     8.5  }
     8.6  
     8.7 +void TreeItem::removeChild(int row)
     8.8 +{
     8.9 +    if (row>=0)
    8.10 +	{
    8.11 +		delete (childItems.at(row) );
    8.12 +		childItems.removeAt (row);
    8.13 +	} else
    8.14 +		qWarning ("TreeItem::removeChild tried to remove non existing item?!\n");
    8.15 +}
    8.16 +
    8.17  TreeItem *TreeItem::child(int row)
    8.18  {
    8.19      return childItems.value(row);
    8.20 @@ -33,6 +43,24 @@
    8.21  {
    8.22      return itemData.count();
    8.23  }
    8.24 +int TreeItem::row() const
    8.25 +{
    8.26 +    if (parentItem)
    8.27 +        return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
    8.28 +
    8.29 +    return 0;
    8.30 +}
    8.31 +
    8.32 +int TreeItem::column() const
    8.33 +{
    8.34 +    return 0;
    8.35 +}
    8.36 +
    8.37 +TreeItem *TreeItem::parent()
    8.38 +{
    8.39 +    return parentItem;
    8.40 +}
    8.41 +
    8.42  
    8.43  QVariant TreeItem::data(int column) const
    8.44  {
    8.45 @@ -71,25 +99,7 @@
    8.46  	}
    8.47  }
    8.48  
    8.49 -int TreeItem::row() const
    8.50 -{
    8.51 -    if (parentItem)
    8.52 -        return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
    8.53 -
    8.54 -    return 0;
    8.55 -}
    8.56 -
    8.57 -int TreeItem::column() const
    8.58 -{
    8.59 -    return 0;
    8.60 -}
    8.61 -
    8.62 -TreeItem *TreeItem::parent()
    8.63 -{
    8.64 -    return parentItem;
    8.65 -}
    8.66 -
    8.67 -LinkableMapObj* TreeItem::getLMO()
    8.68 +LinkableMapObj* TreeItem::getLMO()	// FIXME VM should be unnecessary in the end
    8.69  {
    8.70  	return lmo;
    8.71  }
     9.1 --- a/treeitem.h	Mon Oct 06 11:10:20 2008 +0000
     9.2 +++ b/treeitem.h	Wed Oct 29 17:42:34 2008 +0000
     9.3 @@ -13,11 +13,19 @@
     9.4      TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
     9.5      ~TreeItem();
     9.6  
     9.7 -    void appendChild(TreeItem *child);
     9.8 +	// General housekeeping
     9.9 +    void appendChild (TreeItem *child);
    9.10 +	void removeChild (int row);
    9.11  
    9.12      TreeItem *child(int row);
    9.13      int childCount() const;
    9.14      int columnCount() const;
    9.15 +
    9.16 +    int row() const;
    9.17 +	int column() const;
    9.18 +    TreeItem *parent();
    9.19 +
    9.20 +	// Accessing data
    9.21      QVariant data(int column) const;
    9.22  	void setHeading (const QString s);
    9.23  	QString getHeading();
    9.24 @@ -25,10 +33,6 @@
    9.25  	Type getType ();
    9.26  	QString getTypeName ();
    9.27  	
    9.28 -    int row() const;
    9.29 -	int column() const;
    9.30 -    TreeItem *parent();
    9.31 -
    9.32  	// Relation to map objects in graphicsscene
    9.33  	LinkableMapObj* getLMO();
    9.34  	void setLMO (LinkableMapObj*);
    10.1 --- a/treemodel.cpp	Mon Oct 06 11:10:20 2008 +0000
    10.2 +++ b/treemodel.cpp	Wed Oct 29 17:42:34 2008 +0000
    10.3 @@ -12,7 +12,6 @@
    10.4      QList<QVariant> rootData;
    10.5      rootData << "Heading" << "Type" <<"Note";
    10.6      rootItem = new TreeItem(rootData);
    10.7 - //   setupModelData(rootItem);
    10.8  }
    10.9  
   10.10  TreeModel::~TreeModel()
   10.11 @@ -242,41 +241,26 @@
   10.12  	*/
   10.13  }
   10.14  
   10.15 +#include <iostream>
   10.16 +bool TreeModel::removeRows ( int row, int count, const QModelIndex & parent)
   10.17 +{
   10.18 +	int last=row+count-1;
   10.19 +	beginRemoveRows (parent,row,last);
   10.20 +
   10.21 +    TreeItem *pi= static_cast<TreeItem*>(parent.internalPointer());
   10.22 +    TreeItem *ti;
   10.23 +	for (int i=row; i<=last; i++)
   10.24 +	{
   10.25 +		std::cout << "TreeModel::removeRows removing i="<<i<<std::endl;
   10.26 +		pi->removeChild (row);
   10.27 +	}
   10.28 +
   10.29 +	endRemoveRows ();
   10.30 +	
   10.31 +}
   10.32 +
   10.33  QModelIndex TreeModel::index (TreeItem* ti)
   10.34  {
   10.35  	return createIndex (ti->row(),ti->column(),ti);
   10.36  }
   10.37  
   10.38 -TreeItem* TreeModel::LMOToItem (LinkableMapObj *lmo)// FIXME not used so far!!!
   10.39 -{
   10.40 -	TreeItem *ti=rootItem;		
   10.41 -}
   10.42 -
   10.43 -void TreeModel::setupModelData(TreeItem *root)	// FIXME not needed anymore
   10.44 -{
   10.45 -	QList<QVariant> cData;
   10.46 -
   10.47 -	cData << "Center of map" << "MapCenter"<<"Data 1";
   10.48 -	TreeItem *mco=new TreeItem (cData,root);
   10.49 -	root->appendChild (mco);
   10.50 -
   10.51 -	cData.clear();
   10.52 -	cData << "Main A" << "Branch"<<"Data 2";
   10.53 -	TreeItem *bo=new TreeItem (cData,mco);
   10.54 -	mco->appendChild (bo);
   10.55 -	TreeItem *mainA=bo;
   10.56 -
   10.57 -	cData.clear();
   10.58 -	cData << "Sub a" << "Branch"<<"Data";
   10.59 -	bo=new TreeItem (cData,mainA);
   10.60 -	mainA->appendChild (bo);
   10.61 -
   10.62 -	cData.clear();
   10.63 -	cData << "Sub b" << "Branch"<<"Data";
   10.64 -	bo=new TreeItem (cData,mainA);
   10.65 -	mainA->appendChild (bo);
   10.66 -
   10.67 -	cData.clear();
   10.68 -	cData << "Main B"<<"Branch" <<"Data 3";
   10.69 -	mco->appendChild(new TreeItem(cData, mco));
   10.70 -}
    11.1 --- a/treemodel.h	Mon Oct 06 11:10:20 2008 +0000
    11.2 +++ b/treemodel.h	Wed Oct 29 17:42:34 2008 +0000
    11.3 @@ -30,10 +30,11 @@
    11.4  	TreeItem *first();
    11.5  	TreeItem *next();
    11.6  
    11.7 +	bool removeRows ( int row, int count, 
    11.8 +				const QModelIndex & parent = QModelIndex() ); 
    11.9 +
   11.10  protected:
   11.11  	QModelIndex index (TreeItem* ti);
   11.12 -	TreeItem *LMOToItem(LinkableMapObj*);
   11.13 -    void setupModelData(TreeItem *parent);
   11.14  
   11.15      TreeItem *rootItem;
   11.16  	static TreeItem* itFirst;
    12.1 --- a/version.h	Mon Oct 06 11:10:20 2008 +0000
    12.2 +++ b/version.h	Wed Oct 29 17:42:34 2008 +0000
    12.3 @@ -7,7 +7,7 @@
    12.4  #define __VYM_VERSION "1.13.0"
    12.5  //#define __VYM_CODENAME "Codename: RC-1"
    12.6  #define __VYM_CODENAME "Codename: development version"
    12.7 -#define __VYM_BUILD_DATE "2008-09-10"
    12.8 +#define __VYM_BUILD_DATE "2008-10-29"
    12.9  
   12.10  
   12.11  bool checkVersion(const QString &);
    13.1 --- a/vymmodel.cpp	Mon Oct 06 11:10:20 2008 +0000
    13.2 +++ b/vymmodel.cpp	Wed Oct 29 17:42:34 2008 +0000
    13.3 @@ -67,16 +67,24 @@
    13.4  
    13.5  void VymModel::clear() 
    13.6  {
    13.7 +	cout << "VymModel::clear   rows="<<rowCount(index(rootItem))<<endl;	
    13.8  	selection.clear();
    13.9  
   13.10 -	while (!mapCenters.isEmpty())
   13.11 +	// Remove stuff    
   13.12 +	while (!mapCenters.isEmpty())			// FIXME VM needs to be in treemodel only...
   13.13  		delete mapCenters.takeFirst();
   13.14 +
   13.15 +	QModelIndex ri=index(rootItem);
   13.16 +	removeRows (0, rowCount(ri),ri);	
   13.17  }
   13.18  
   13.19  void VymModel::init () 
   13.20  {
   13.21  	// We should have at least one map center to start with
   13.22 -	// addMapCenter();  FIXME create this in MapEditor as long as model is part of that
   13.23 +	// addMapCenter();  FIXME VM create this in MapEditor as long as model is part of that
   13.24 +
   13.25 +	// No MapEditor yet
   13.26 +	mapEditor=NULL;
   13.27  
   13.28  	// History 
   13.29  	mapNum++;
   13.30 @@ -143,7 +151,7 @@
   13.31  	netstate=Offline;
   13.32  
   13.33  	// Create MapCenter
   13.34 -	//  addMapCenter();  FIXME create this in MapEditor until BO and MCO are independent of scene
   13.35 +	//  addMapCenter();  FIXME VM create this in MapEditor until BO and MCO are independent of scene
   13.36  
   13.37  }
   13.38  
   13.39 @@ -157,7 +165,7 @@
   13.40  }
   13.41  
   13.42  
   13.43 -MapEditor* VymModel::getMapEditor()	// FIXME better return favourite editor here
   13.44 +MapEditor* VymModel::getMapEditor()	// FIXME VM better return favourite editor here
   13.45  {
   13.46  	return mapEditor;
   13.47  }
   13.48 @@ -329,7 +337,7 @@
   13.49  	if (lmode==NewMap)
   13.50  	{
   13.51  		selection.clear();
   13.52 -		// FIXME not needed??? model->setMapEditor(this);
   13.53 +		// FIXME VM not needed??? model->setMapEditor(this);
   13.54  		// (map state is set later at end of load...)
   13.55  	} else
   13.56  	{
   13.57 @@ -443,7 +451,7 @@
   13.58  		file.close();
   13.59  		if ( ok ) 
   13.60  		{
   13.61 -			reposition();	// FIXME reposition the view instead...
   13.62 +			reposition();	// FIXME VM reposition the view instead...
   13.63  			selection.update();
   13.64  			if (lmode==NewMap)
   13.65  			{
   13.66 @@ -469,7 +477,6 @@
   13.67  	removeDir (QDir(tmpZipDir));
   13.68  
   13.69  	updateActions();
   13.70 -
   13.71  	return err;
   13.72  }
   13.73  
   13.74 @@ -688,7 +695,7 @@
   13.75  		fio=bo->getLastFloatImage();
   13.76  		fio->load(fn);
   13.77  		reposition();
   13.78 -		// FIXME needed? scene()->update();
   13.79 +		// FIXME VM needed? scene()->update();
   13.80  		return fio;
   13.81  	}
   13.82  	return NULL;
   13.83 @@ -869,7 +876,7 @@
   13.84  		{
   13.85  			importDirInt (fd->selectedFile() );
   13.86  			reposition();
   13.87 -			//FIXME needed? scene()->update();
   13.88 +			//FIXME VM needed? scene()->update();
   13.89  		}
   13.90  	}	
   13.91  }
   13.92 @@ -906,7 +913,7 @@
   13.93  		QDateTime tmod=QFileInfo (filePath).lastModified();
   13.94  		if (tmod>fileChangedTime)
   13.95  		{
   13.96 -			// FIXME switch to current mapeditor and finish lineedits...
   13.97 +			// FIXME VM switch to current mapeditor and finish lineedits...
   13.98  			QMessageBox mb( vymName,
   13.99  				tr("The file of the map  on disk has changed:\n\n"  
  13.100  				   "   %1\n\nDo you want to reload that map with the new file?").arg(filePath),
  13.101 @@ -1485,25 +1492,21 @@
  13.102  			QString("Set heading of %1 to \"%2\"").arg(getObjectName(sel)).arg(s) );
  13.103  		sel->setHeading(s );
  13.104  		TreeItem *ti=selection.getBranchItem();
  13.105 -		if (ti) ti->setHeading (s);
  13.106 -		//FIXME ix is wrong ModelIndex below, ix2 is (hopefully) correct:
  13.107 -		QModelIndex ix=index( ti->row(), ti->column(), index (0,0,QModelIndex()) );
  13.108 -		cout <<"VM::setHeading  s="<<s.toStdString()<<"  ti="<<ti<<"  r,c=("<<ti->row()<<","<<ti->column()<<")"<<endl;
  13.109 -		QModelIndex ix2=index (ti);
  13.110 -		emit (dataChanged ( ix2,ix2));
  13.111 -		cout <<"                (r,c)=("<<ix2.row()<<","<<ix2.column()<<")"<<endl;
  13.112 -
  13.113 -		// FIXME playing around with selections:
  13.114 -		// but somehow not all mco are visible in tree then???
  13.115 -//		if (mapEditor)
  13.116 -		if (NULL)
  13.117 +		if (ti)
  13.118  		{
  13.119 -			
  13.120 -			QItemSelectionModel *selectionModel=mapEditor->selectionModel();
  13.121 -			selectionModel->clear();
  13.122 -			QItemSelection sel (ix2,ix2);
  13.123 -			selectionModel->select (sel, QItemSelectionModel::Select);
  13.124 +			ti->setHeading (s);
  13.125 +			//FIXME VM ix is wrong ModelIndex below, ix2 is (hopefully) correct:
  13.126 +			QModelIndex ix=index( ti->row(), ti->column(), index (0,0,QModelIndex()) );
  13.127 +			//FIXME VM testing only cout <<"VM::setHeading  s="<<s.toStdString()<<"  ti="<<ti<<"  r,c=("<<ti->row()<<","<<ti->column()<<")"<<endl;
  13.128 +			QModelIndex ix2=index (ti);
  13.129 +			emit (dataChanged ( ix2,ix2));
  13.130  		}
  13.131 +		else
  13.132 +		{
  13.133 +			cout << "Warning: VM::setHeading ti==NULL\n";
  13.134 +		}
  13.135 +
  13.136 +		//cout <<"                (r,c)=("<<ix2.row()<<","<<ix2.column()<<")"<<endl;
  13.137  
  13.138  		reposition();
  13.139  		selection.update();
  13.140 @@ -1824,7 +1827,7 @@
  13.141  		updateActions();
  13.142  		reposition();
  13.143  		selection.update();
  13.144 -		// FIXME needed? scene()->update();
  13.145 +		// FIXME VM needed? scene()->update();
  13.146  	}
  13.147  }
  13.148  
  13.149 @@ -1926,7 +1929,7 @@
  13.150  		BranchObj *obo=par->moveBranchUp (bo);	// bo will be the one below selection
  13.151  		saveState (getSelectString(bo),"moveBranchDown ()",getSelectString(obo),"moveBranchUp ()",QString("Move up %1").arg(getObjectName(bo)));
  13.152  		reposition();
  13.153 -		//FIXME needed? scene()->update();
  13.154 +		//FIXME VM needed? scene()->update();
  13.155  		selection.update();
  13.156  		ensureSelectionVisible();
  13.157  	}
  13.158 @@ -1943,7 +1946,7 @@
  13.159  		BranchObj *obo=par->moveBranchDown(bo);	// bo will be the one above selection
  13.160  		saveState(getSelectString(bo),"moveBranchUp ()",getSelectString(obo),"moveBranchDown ()",QString("Move down %1").arg(getObjectName(bo)));
  13.161  		reposition();
  13.162 -		//FIXME needed? scene()->update();
  13.163 +		//FIXME VM needed? scene()->update();
  13.164  		selection.update();
  13.165  		ensureSelectionVisible();
  13.166  	}	
  13.167 @@ -1975,7 +1978,7 @@
  13.168  	BranchObj *bo=selection.getBranch();
  13.169  	if (bo)
  13.170  	{
  13.171 -		BranchObj *newbo=addNewBranchInt (-2); // FIXME Old model, merge with below
  13.172 +		BranchObj *newbo=addNewBranchInt (-2); // FIXME VM Old model, merge with below
  13.173  
  13.174  		// Create TreeItem
  13.175  		QList<QVariant> cData;
  13.176 @@ -1989,7 +1992,7 @@
  13.177  		if (newbo)
  13.178  		{
  13.179  			newbo->setTreeItem (ti);
  13.180 -			selection.select (newbo);
  13.181 +			selection.select (newbo); // FIXME VM really needed here?
  13.182  		}
  13.183  	}
  13.184  }
  13.185 @@ -2012,11 +2015,11 @@
  13.186  
  13.187  MapCenterObj* VymModel::addMapCenter(QPointF absPos)
  13.188  {
  13.189 -	MapCenterObj *mapCenter = new MapCenterObj(mapScene);
  13.190 +	MapCenterObj *mapCenter = new MapCenterObj(mapScene,this);
  13.191 +	mapCenter->setMapEditor(mapEditor);		//FIXME VM needed to get defLinkStyle, mapLinkColorHint ... for later added objects
  13.192  	mapCenter->move (absPos);
  13.193      mapCenter->setVisibility (true);
  13.194  	mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
  13.195 -	mapCenter->setMapEditor(mapEditor);		//FIXME needed to get defLinkStyle, mapLinkColorHint ... for later added objects
  13.196  	mapCenters.append(mapCenter);
  13.197  
  13.198  	// Create TreeItem
  13.199 @@ -2097,7 +2100,7 @@
  13.200  
  13.201  	if (bo)
  13.202  	{
  13.203 -		// FIXME  do we still need this in model? setCursor (Qt::ArrowCursor);
  13.204 +		// FIXME VM  do we still need this in model? setCursor (Qt::ArrowCursor);
  13.205  
  13.206  		newbo=addNewBranchInt (pos-2);
  13.207  
  13.208 @@ -2165,7 +2168,7 @@
  13.209  	{
  13.210  	//	BranchObj* par=(BranchObj*)(bo->getParObj());
  13.211  		selection.unselect();
  13.212 -	/* FIXME Note:  does saveStateRemovingPart work for MCO? (No parent!)
  13.213 +	/* FIXME VM Note:  does saveStateRemovingPart work for MCO? (No parent!)
  13.214  		saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
  13.215  		*/
  13.216  		bo=removeMapCenter ((MapCenterObj*)bo);
  13.217 @@ -2287,7 +2290,7 @@
  13.218  		);
  13.219  		bo->toggleScroll();
  13.220  		selection.update();
  13.221 -		// FIXME needed? scene()->update();
  13.222 +		// FIXME VM needed? scene()->update();
  13.223  		return true;
  13.224  	}	
  13.225  	return false;
  13.226 @@ -2312,7 +2315,7 @@
  13.227  		);
  13.228  		bo->toggleScroll();
  13.229  		selection.update();
  13.230 -		// FIXME needed? scene()->update();
  13.231 +		// FIXME VM needed? scene()->update();
  13.232  		return true;
  13.233  	}	
  13.234  	return false;
  13.235 @@ -2355,7 +2358,7 @@
  13.236  	saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",fio  );
  13.237  	saveState (fio,"delete ()", bo,QString("paste(%1)").arg(curStep),"Pasting dropped image");
  13.238      reposition();
  13.239 -    // FIXME needed? scene()->update();
  13.240 +    // FIXME VM needed? scene()->update();
  13.241    }
  13.242  }
  13.243  
  13.244 @@ -2540,7 +2543,7 @@
  13.245  		bo->setVymLink ("" );
  13.246  		updateActions();
  13.247  		reposition();
  13.248 -		// FIXME needed? scene()->update();
  13.249 +		// FIXME VM needed? scene()->update();
  13.250  	}
  13.251  }
  13.252  
  13.253 @@ -2585,7 +2588,7 @@
  13.254  	}
  13.255  }
  13.256  
  13.257 -void VymModel::editXLink(int i)	// FIXME missing saveState
  13.258 +void VymModel::editXLink(int i)	// FIXME VM missing saveState
  13.259  {
  13.260  	BranchObj *bo=selection.getBranch();
  13.261  	if (bo)
  13.262 @@ -3867,14 +3870,24 @@
  13.263  void VymModel::setMapLinkStyle (const QString & s)
  13.264  {
  13.265  	QString snow;
  13.266 -	if (linkstyle==LinkableMapObj::Line)
  13.267 -		snow="StyleLine";
  13.268 -	else if (linkstyle==LinkableMapObj::Parabel)
  13.269 -		snow="StyleParabel";
  13.270 -	else if (linkstyle==LinkableMapObj::PolyLine)
  13.271 -		snow="StylePolyLine";
  13.272 -	else if (linkstyle==LinkableMapObj::PolyParabel)
  13.273 -		snow="StyleParabel";
  13.274 +	switch (linkstyle)
  13.275 +	{
  13.276 +		case LinkableMapObj::Line :
  13.277 +			snow="StyleLine";
  13.278 +			break;
  13.279 +		case LinkableMapObj::Parabel:
  13.280 +			snow="StyleParabel";
  13.281 +			break;
  13.282 +		case LinkableMapObj::PolyLine:
  13.283 +			snow="StylePolyLine";
  13.284 +			break;
  13.285 +		case LinkableMapObj::PolyParabel:
  13.286 +			snow="StylePolyParabel";
  13.287 +			break;
  13.288 +		default:	
  13.289 +			snow="UndefinedStyle";
  13.290 +			break;
  13.291 +	}
  13.292  
  13.293  	saveState (
  13.294  		QString("setMapLinkStyle (\"%1\")").arg(s),
  13.295 @@ -3888,8 +3901,10 @@
  13.296  		linkstyle=LinkableMapObj::Parabel;
  13.297  	else if (s=="StylePolyLine")
  13.298  		linkstyle=LinkableMapObj::PolyLine;
  13.299 -	else	
  13.300 +	else if (s=="StylePolyParabel")	
  13.301  		linkstyle=LinkableMapObj::PolyParabel;
  13.302 +	else
  13.303 +		linkstyle=LinkableMapObj::UndefinedStyle;
  13.304  
  13.305  	BranchObj *bo;
  13.306  	bo=first();
  13.307 @@ -4341,6 +4356,11 @@
  13.308  // Selection related
  13.309  //////////////////////////////////////////////
  13.310  
  13.311 +void VymModel::setSelectionModel (QItemSelectionModel *sm)
  13.312 +{
  13.313 +	selModel=sm;
  13.314 +}
  13.315 +
  13.316  void VymModel::setSelectionBlocked (bool b)
  13.317  {
  13.318  	if (b)
  13.319 @@ -4354,6 +4374,14 @@
  13.320  	return selection.isBlocked();
  13.321  }
  13.322  
  13.323 +bool VymModel::select ()
  13.324 +{
  13.325 +	QModelIndex index=selModel->selectedIndexes().first();	// TODO no multiselections yet
  13.326 +
  13.327 +	TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
  13.328 +	return select (item->getLMO() );
  13.329 +}
  13.330 +
  13.331  bool VymModel::select (const QString &s)
  13.332  {
  13.333  	if (selection.select(s))
    14.1 --- a/vymmodel.h	Mon Oct 06 11:10:20 2008 +0000
    14.2 +++ b/vymmodel.h	Wed Oct 29 17:42:34 2008 +0000
    14.3 @@ -525,11 +525,14 @@
    14.4  	QString latestSelectionString;	// select string of latest added object
    14.5  
    14.6  public:
    14.7 +	void setSelectionModel(QItemSelectionModel *);		// Set common selectionModel
    14.8 +
    14.9  	void setSelectionBlocked(bool);
   14.10  	bool isSelectionBlocked();
   14.11  
   14.12 -	bool select(const QString &);			// Select by string
   14.13 -	bool select(LinkableMapObj *lmo);		// Select by pointer
   14.14 +	bool select ();							// select by using common QItemSlectionModel
   14.15 +	bool select (const QString &);			// Select by string
   14.16 +	bool select (LinkableMapObj *lmo);		// Select by pointer
   14.17  	void unselect();
   14.18  	void reselect();
   14.19  
   14.20 @@ -562,6 +565,8 @@
   14.21      void selectMapSelectionColor();
   14.22  private:	
   14.23      void setSelectionColorInt(QColor);
   14.24 +	QItemSelectionModel *selModel;
   14.25 +
   14.26  public:	
   14.27      void setSelectionColor(QColor);
   14.28      QColor getSelectionColor();
    15.1 --- a/vymview.cpp	Mon Oct 06 11:10:20 2008 +0000
    15.2 +++ b/vymview.cpp	Wed Oct 29 17:42:34 2008 +0000
    15.3 @@ -1,20 +1,29 @@
    15.4  #include "vymview.h"
    15.5  
    15.6 +#include <iostream>
    15.7 +
    15.8  #include "mapeditor.h"
    15.9  
   15.10  VymView::VymView(VymModel *model)
   15.11  {
   15.12  	// Create TreeView
   15.13 -	QTreeView *treeview=new QTreeView;
   15.14 +	treeview=new QTreeView;
   15.15  	treeview->setModel ((QAbstractItemModel*)model);
   15.16  	treeview->setMinimumWidth (350);
   15.17  	treeview->setColumnWidth (0,350);
   15.18  
   15.19 +	// ItemSelectionModel
   15.20 +	selModel=treeview->selectionModel();
   15.21 +	connect (
   15.22 +		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
   15.23 +		this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
   15.24 +	model->setSelectionModel (selModel);
   15.25 +
   15.26  	// Create good old MapEditor
   15.27  	MapEditor* me=model->getMapEditor();
   15.28  	if (!me) me=new MapEditor (model);
   15.29  
   15.30 -	me->setSelectionModel (treeview->selectionModel() );
   15.31 +	me->setSelectionModel (selModel);
   15.32  
   15.33  	//me->viewport()->setFocus();
   15.34  	//FIXME me->setAntiAlias (actionViewToggleAntiAlias->isOn());
   15.35 @@ -32,8 +41,17 @@
   15.36  
   15.37  QItemSelectionModel* VymView::selectionModel() 
   15.38  {
   15.39 -	if (treeview) return treeview->selectionModel();
   15.40 +	if (treeview) return selModel;
   15.41 +	else std::cout <<"hey, no treeview so far???\n";
   15.42  	return NULL;
   15.43  }
   15.44  
   15.45  
   15.46 +void VymView::changeSelection (const QItemSelection &newSel, const QItemSelection &delSel)
   15.47 +{
   15.48 +	// FIXME Currently this works only from treeview->ME
   15.49 +	treeview->expandAll();	//FIXME only for testing
   15.50 +
   15.51 +	((VymModel*)treeview->model())->select ();
   15.52 +}
   15.53 +
    16.1 --- a/vymview.h	Mon Oct 06 11:10:20 2008 +0000
    16.2 +++ b/vymview.h	Wed Oct 29 17:42:34 2008 +0000
    16.3 @@ -10,11 +10,17 @@
    16.4  
    16.5  class VymView : public QSplitter 
    16.6  {
    16.7 +	Q_OBJECT
    16.8  public:
    16.9  	VymView(VymModel *model);
   16.10  	QItemSelectionModel* selectionModel();
   16.11 +
   16.12 +public slots:
   16.13 +	void changeSelection (const QItemSelection &newSel, const QItemSelection &delSel);
   16.14 +
   16.15  private:
   16.16  	QTreeView *treeview;
   16.17 +	QItemSelectionModel *selModel;
   16.18  };
   16.19  
   16.20  
    17.1 --- a/xml-vym.cpp	Mon Oct 06 11:10:20 2008 +0000
    17.2 +++ b/xml-vym.cpp	Wed Oct 29 17:42:34 2008 +0000
    17.3 @@ -47,25 +47,6 @@
    17.4  	{
    17.5          state = StateMap;
    17.6  
    17.7 -		if (loadMode==NewMap)
    17.8 -			model->clear();	// remove existing mapCenter
    17.9 -
   17.10 -		// Check version
   17.11 -		if (!atts.value( "version").isEmpty() ) 
   17.12 -		{
   17.13 -			if (!checkVersion(atts.value("version")))
   17.14 -				QMessageBox::warning( 0, "Warning: Version Problem" ,
   17.15 -				   "<h3>Map is newer than VYM</h3>"
   17.16 -				   "<p>The map you are just trying to load was "
   17.17 -				   "saved using vym " +atts.value("version")+". "
   17.18 -				   "The version of this vym is " + vymVersion + 
   17.19 -				   ". If you run into problems after pressing "
   17.20 -				   "the ok-button below, updating vym should help.");
   17.21 -			else	   
   17.22 -				model->setVersion(atts.value( "version" ));
   17.23 -
   17.24 -		}
   17.25 -
   17.26  		if (loadMode==NewMap )
   17.27  		{
   17.28  			// Create mapCenter
   17.29 @@ -108,6 +89,22 @@
   17.30  			if (!atts.value( "defXLinkWidth").isEmpty() ) 
   17.31  				model->setMapDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
   17.32  		}	
   17.33 +		// Check version
   17.34 +		if (!atts.value( "version").isEmpty() ) 
   17.35 +		{
   17.36 +			if (!checkVersion(atts.value("version")))
   17.37 +				QMessageBox::warning( 0, "Warning: Version Problem" ,
   17.38 +				   "<h3>Map is newer than VYM</h3>"
   17.39 +				   "<p>The map you are just trying to load was "
   17.40 +				   "saved using vym " +atts.value("version")+". "
   17.41 +				   "The version of this vym is " + vymVersion + 
   17.42 +				   ". If you run into problems after pressing "
   17.43 +				   "the ok-button below, updating vym should help.");
   17.44 +			else	   
   17.45 +				model->setVersion(atts.value( "version" ));
   17.46 +
   17.47 +		}
   17.48 +
   17.49  	} else if ( eName == "select" && state == StateMap ) 
   17.50  	{
   17.51  		state=StateMapSelect;