Fixed segfault when closing a map
authorinsilmaril
Wed May 20 15:40:14 2009 +0000 (2009-05-20)
changeset 772e3f722759c7e
parent 771 01f2f6d6789d
child 773 340bc29da9a0
Fixed segfault when closing a map
branchitem.cpp
branchobj.cpp
branchobj.h
mainwindow.cpp
mainwindow.h
mapcenteritem.cpp
mapeditor.cpp
mapeditor.h
mapobj.h
treeitem.cpp
treeitem.h
treemodel.cpp
treemodel.h
vymmodel.cpp
vymview.cpp
vymview.h
xml-vym.cpp
     1.1 --- a/branchitem.cpp	Mon May 18 11:22:41 2009 +0000
     1.2 +++ b/branchitem.cpp	Wed May 20 15:40:14 2009 +0000
     1.3 @@ -18,7 +18,7 @@
     1.4  
     1.5  BranchItem::~BranchItem()
     1.6  {
     1.7 -//	cout << "Destr. BranchItem "<<getHeadingStd()<<endl;
     1.8 +	//cout << "Destr. BranchItem "<<getHeadingStd()<<endl;
     1.9  	if (lmo) 
    1.10  	{
    1.11  		delete lmo;
    1.12 @@ -205,8 +205,6 @@
    1.13  
    1.14  bool BranchItem::toggleScroll()	
    1.15  {
    1.16 -
    1.17 -	if (!branchCount()>0) return false;
    1.18  	BranchObj *bo=NULL;
    1.19  	if (scrolled)
    1.20  	{
    1.21 @@ -220,7 +218,6 @@
    1.22  				if (bo) bo->setVisibility(true);
    1.23  			}
    1.24  		}
    1.25 -		model->reposition();
    1.26  	} else
    1.27  	{
    1.28  		scrolled=true;
    1.29 @@ -234,6 +231,7 @@
    1.30  			}
    1.31  		}
    1.32  	}
    1.33 +	model->reposition();	// FIXME-3 we don't really want to update view from here...
    1.34  	return true;
    1.35  }
    1.36  
    1.37 @@ -350,9 +348,12 @@
    1.38  	// Initialize BranchObj, order of things is important...
    1.39      BranchObj* newbo=new BranchObj(scene);
    1.40  	lmo=newbo;
    1.41 -    newbo->setParObj(parent()->getLMO() );
    1.42 +	BranchObj* parbo=(BranchObj*)(parentItem->getLMO());
    1.43 +    newbo->setParObj(parbo);
    1.44  	newbo->setTreeItem (this);
    1.45  	newbo->setDefAttr(BranchObj::NewBranch);
    1.46 +	if (((BranchItem*)parentItem)->scrolled || !parbo->isVisibleObj() )
    1.47 +		newbo->setVisibility (false);
    1.48  	
    1.49  	initLMO();
    1.50  
     2.1 --- a/branchobj.cpp	Mon May 18 11:22:41 2009 +0000
     2.2 +++ b/branchobj.cpp	Wed May 20 15:40:14 2009 +0000
     2.3 @@ -638,58 +638,6 @@
     2.4  	calcBBoxSize();
     2.5  }
     2.6  
     2.7 -void BranchObj::removeBranchHere(BranchObj* borem)	// FIXME-2 getNum no longer available
     2.8 -{
     2.9 -/*
    2.10 -	// This removes the branch bo from list, but 
    2.11 -	// inserts its children at the place of bo
    2.12 -	BranchObj *bo;
    2.13 -	bo=borem->getLastBranch();
    2.14 -	int pos=borem->getNum();
    2.15 -	while (bo)
    2.16 -	{
    2.17 -		bo->linkTo (this,pos+1);
    2.18 -		bo=borem->getLastBranch();
    2.19 -	}	
    2.20 -	removeBranch (borem);
    2.21 -	*/
    2.22 -}
    2.23 -
    2.24 -void BranchObj::removeChildren()	// FIXME-3 not needed here
    2.25 -{
    2.26 -	clear();
    2.27 -}
    2.28 -
    2.29 -void BranchObj::removeBranch(BranchObj* bo)	// FIXME-2 not needed here
    2.30 -{
    2.31 -/*
    2.32 -    // if bo is not in branch remove returns false, we
    2.33 -    // don't care...
    2.34 -	
    2.35 -	int i=branch.indexOf(bo);
    2.36 -    if (i>=0)
    2.37 -	{
    2.38 -		delete (bo);
    2.39 -		branch.removeAt (i);
    2.40 -	} else
    2.41 -		qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
    2.42 -	requestReposition();
    2.43 -	*/
    2.44 -}
    2.45 -
    2.46 -void BranchObj::removeBranchPtr(BranchObj* bo)	// FIXME-3 not needed here
    2.47 -{
    2.48 -/*
    2.49 -	int i=branch.indexOf(bo);
    2.50 -	
    2.51 -	if (i>=0)
    2.52 -		branch.removeAt (i);
    2.53 -	else	
    2.54 -		qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n");
    2.55 -	requestReposition();
    2.56 -*/	
    2.57 -}
    2.58 -
    2.59  void BranchObj::sortChildren() //FIXME-2  
    2.60  {
    2.61  /*
     3.1 --- a/branchobj.h	Mon May 18 11:22:41 2009 +0000
     3.2 +++ b/branchobj.h	Wed May 20 15:40:14 2009 +0000
     3.3 @@ -72,11 +72,6 @@
     3.4  public:	
     3.5  	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
     3.6  
     3.7 -    virtual void removeBranchHere(BranchObj*);  //FIXME-3
     3.8 -    virtual void removeChildren();  
     3.9 -    virtual void removeBranch(BranchObj*);  
    3.10 -    virtual void removeBranchPtr (BranchObj*);  
    3.11 -
    3.12      virtual void sortChildren();
    3.13      virtual void alignRelativeTo(const QPointF, bool alignSelf=false );
    3.14  	virtual void reposition();
     4.1 --- a/mainwindow.cpp	Mon May 18 11:22:41 2009 +0000
     4.2 +++ b/mainwindow.cpp	Wed May 20 15:40:14 2009 +0000
     4.3 @@ -542,34 +542,6 @@
     4.4  	editMenu->addAction (a);
     4.5  	actionPaste=a;
     4.6  
     4.7 -/*	FIXME-5
     4.8 -    // Shortcuts to modify heading:
     4.9 -    a = new QAction(tr( "Edit heading","Edit menu" ),this);
    4.10 -	a->setStatusTip ( tr( "edit Heading" ));
    4.11 -	a->setShortcut ( Qt::Key_Enter);				//Edit heading
    4.12 -//	a->setShortcutContext (Qt::WindowShortcut);
    4.13 -	addAction (a);
    4.14 -    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
    4.15 -	actionListBranches.append(a);
    4.16 -    a = new QAction( tr( "Edit heading","Edit menu" ), this);
    4.17 -	a->setStatusTip (tr( "edit Heading" ));
    4.18 -	a->setShortcut (Qt::Key_Return );				//Edit heading
    4.19 -	//a->setShortcutContext (Qt::WindowShortcut);
    4.20 -	addAction (a);
    4.21 -    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
    4.22 -	actionListBranches.append(a);
    4.23 -	editMenu->addAction (a);
    4.24 -	actionHeading=a;
    4.25 -
    4.26 -    a = new QAction( tr( "Edit heading","Edit menu" ), this);
    4.27 -	a->setStatusTip (tr( "edit Heading" ));
    4.28 -	//a->setShortcut ( Qt::Key_F2 );					//Edit heading
    4.29 -	a->setShortcutContext (Qt::WindowShortcut);
    4.30 -	addAction (a);
    4.31 -    connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
    4.32 -	actionListBranches.append(a);
    4.33 -*/	
    4.34 -    
    4.35      // Shortcut to delete selection
    4.36      a = new QAction( tr( "Delete Selection","Edit menu" ),this);
    4.37  	a->setStatusTip (tr( "Delete Selection" ));
    4.38 @@ -1144,6 +1116,7 @@
    4.39  	QToolBar *tb=NULL;
    4.40  
    4.41  	Flag *flag=new Flag;;
    4.42 +	flag->setVisible(true);
    4.43  
    4.44  	flag->load(QPixmap(flagsPath+"flag-note.png"));
    4.45  	setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
    4.46 @@ -1167,7 +1140,6 @@
    4.47  	tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
    4.48  	tb->setObjectName ("standardFlagTB");
    4.49  	standardFlagsMaster->setToolBar (tb);
    4.50 -
    4.51  	
    4.52  	flag->load(flagsPath+"flag-exclamationmark.png");
    4.53  	flag->setGroup("standard-mark");
    4.54 @@ -1259,7 +1231,7 @@
    4.55  	setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
    4.56  
    4.57  	// Freemind flags
    4.58 -
    4.59 +	flag->setVisible(false);
    4.60  	flag->load(flagsPath+"freemind/warning.png");
    4.61  	setupFlag (flag,tb,  "freemind-warning",tr("Important","Freemind-Flag"));
    4.62  
    4.63 @@ -1343,6 +1315,7 @@
    4.64  		// StandardFlag
    4.65  		tb->addAction (a);
    4.66  		flag->setAction (a);
    4.67 +		a->setVisible (flag->isVisible());
    4.68  		a->setCheckable(true);
    4.69  		a->setObjectName(name);
    4.70  		a->setToolTip(tooltip);
    4.71 @@ -1696,14 +1669,14 @@
    4.72  MapEditor* Main::currentMapEditor() const
    4.73  {
    4.74      if ( tabWidget->currentPage())
    4.75 -		return tabModel.at(tabWidget->currentIndex())->getMapEditor();
    4.76 +		return vymViews.at(tabWidget->currentIndex())->getMapEditor();
    4.77      return NULL;	
    4.78  }
    4.79  
    4.80  VymModel* Main::currentModel() const
    4.81  {
    4.82      if ( tabWidget->currentPage())
    4.83 -		return tabModel.at(tabWidget->currentIndex());
    4.84 +		return vymViews.at(tabWidget->currentIndex())->getModel();
    4.85      return NULL;	
    4.86  }
    4.87  
    4.88 @@ -1712,11 +1685,13 @@
    4.89  {
    4.90  	// Unselect all possibly selected objects
    4.91  	// (Important to update note editor)
    4.92 +	VymModel *m;
    4.93  	for (int i=0;i<=tabWidget->count() -1;i++)
    4.94  	{
    4.95 -		tabModel.at(i)->unselect();
    4.96 -	}	
    4.97 -	VymModel *m=currentModel();
    4.98 +		m= vymViews.at(tabWidget->currentIndex())->getModel();
    4.99 +		if (m) m->unselect();
   4.100 +	}
   4.101 +	m=currentModel();
   4.102  	if (m) m->reselect();
   4.103  
   4.104  	// Update actions to in menus and toolbars according to editor
   4.105 @@ -1726,11 +1701,11 @@
   4.106  void Main::fileNew()
   4.107  {
   4.108  	VymModel *vm=new VymModel;
   4.109 -	tabModel.append (vm);
   4.110  
   4.111  	VymView *vv=new VymView (vm);
   4.112 +	vymViews.append (vv);
   4.113  	tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
   4.114 -	tabWidget->setCurrentIndex (tabModel.count() );
   4.115 +	tabWidget->setCurrentIndex (vymViews.count() );
   4.116  	vv->initFocus();
   4.117  
   4.118  	
   4.119 @@ -1746,7 +1721,7 @@
   4.120  	{
   4.121  		srcModel->copy();
   4.122  		fileNew();
   4.123 -		VymModel *dstModel=tabModel.last ();
   4.124 +		VymModel *dstModel=vymViews.last()->getModel();
   4.125  		dstModel->select("mc:");
   4.126  		dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
   4.127  	}
   4.128 @@ -1770,7 +1745,7 @@
   4.129  		int i=0;
   4.130  		while (i<=tabWidget->count() -1)
   4.131  		{
   4.132 -			if (tabModel.at(i)->getFilePath() == fn)
   4.133 +			if (vymViews.at(i)->getModel()->getFilePath() == fn)
   4.134  			{
   4.135  				// Already there, ask for confirmation
   4.136  				QMessageBox mb( vymName,
   4.137 @@ -1813,7 +1788,7 @@
   4.138  		{
   4.139  			vm=new VymModel;
   4.140  			VymView *vv=new VymView (vm);
   4.141 -			tabModel.append (vm);
   4.142 +			vymViews.append (vv);
   4.143  			tabWidget->addTab (vv,fn);
   4.144  			tabIndex=tabWidget->count()-1;
   4.145  			tabWidget->setCurrentPage (tabIndex);
   4.146 @@ -2310,16 +2285,15 @@
   4.147  	}
   4.148  }
   4.149  
   4.150 -void Main::fileCloseMap()
   4.151 +void Main::fileCloseMap()	
   4.152  {
   4.153 -	MapEditor *me = currentMapEditor();
   4.154  	VymModel *m=currentModel();
   4.155  	if (m)
   4.156  	{
   4.157  		if (m->hasChanged())
   4.158  		{
   4.159  			QMessageBox mb( vymName,
   4.160 -				tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
   4.161 +				tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
   4.162  				QMessageBox::Warning,
   4.163  				QMessageBox::Yes | QMessageBox::Default,
   4.164  				QMessageBox::No,
   4.165 @@ -2340,14 +2314,16 @@
   4.166  				return;
   4.167  			}
   4.168  		} 
   4.169 -		tabModel.removeAt (tabWidget->currentIndex() );
   4.170 +		// And here comes the segfault, because removeTab triggers 
   4.171 +		// currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
   4.172 +		vymViews.removeAt (tabWidget->currentIndex() );
   4.173  		tabWidget->removeTab (tabWidget->currentIndex() );
   4.174  
   4.175 -		// Remove mapEditor;
   4.176 +		// Remove mapEditor/model FIXME-5
   4.177  		// Better would be delete (me), but then we could have a Qt error:
   4.178  		// "QObject: Do not delete object, 'MapEditor', during its event handler!"
   4.179  		// So we only remove data now and call deconstructor when vym closes later
   4.180 -		// FIXME-3  this needs to be moved to vymview...   me->clear();
   4.181 +		// this needs to be moved to vymview...   me->clear();
   4.182  		// some model->clear is needed to free up memory ...
   4.183  
   4.184  		updateActions();
   4.185 @@ -2364,10 +2340,10 @@
   4.186  {
   4.187  	// Check if one or more editors have changed
   4.188  	int i;
   4.189 -	for (i=0;i<=tabModel.count() -1;i++)
   4.190 +	for (i=0;i<=vymViews.count() -1;i++)
   4.191  	{
   4.192  		// If something changed, ask what to do
   4.193 -		if (tabModel.at(i)->hasChanged())
   4.194 +		if (vymViews.at(i)->getModel()->hasChanged())
   4.195  		{
   4.196  			tabWidget->setCurrentPage(i);
   4.197  			QMessageBox mb( vymName,
   4.198 @@ -2641,9 +2617,9 @@
   4.199  		// compare path with already loaded maps
   4.200  		int index=-1;
   4.201  		int i;
   4.202 -		for (i=0;i<=tabModel.count() -1;i++)
   4.203 +		for (i=0;i<=vymViews.count() -1;i++)
   4.204  		{
   4.205 -			if (vl.at(j)==tabModel.at(i)->getFilePath() )
   4.206 +			if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
   4.207  			{
   4.208  				index=i;
   4.209  				break;
   4.210 @@ -2789,11 +2765,7 @@
   4.211  void Main::editAddMapCenter()
   4.212  {
   4.213  	VymModel *m=currentModel();
   4.214 -	if (m)
   4.215 -	{
   4.216 -		cout <<"Main::editAddMapCenter\n";
   4.217 -		m->addMapCenter ();
   4.218 -	}	
   4.219 +	if (m) m->addMapCenter ();
   4.220  }
   4.221  
   4.222  void Main::editNewBranch()
   4.223 @@ -3226,9 +3198,9 @@
   4.224  {
   4.225  	bool b=actionViewToggleAntiAlias->isOn();
   4.226  	MapEditor *me;
   4.227 -	for (int i=0;i<tabModel.count();i++)
   4.228 +	for (int i=0;i<vymViews.count();i++)
   4.229  	{
   4.230 -		me=tabModel.at(i)->getMapEditor();
   4.231 +		me=vymViews.at(i)->getMapEditor();
   4.232  		if (me) me->setAntiAlias(b);
   4.233  	}	
   4.234  
   4.235 @@ -3248,10 +3220,10 @@
   4.236  {
   4.237  	bool b=actionViewToggleSmoothPixmapTransform->isOn();
   4.238  	MapEditor *me;
   4.239 -	for (int i=0;i<tabModel.count();i++)
   4.240 +	for (int i=0;i<vymViews.count();i++)
   4.241  	{
   4.242  		
   4.243 -		me=tabModel.at(i)->getMapEditor();
   4.244 +		me=vymViews.at(i)->getMapEditor();
   4.245  		if (me) me->setSmoothPixmap(b);
   4.246  	}	
   4.247  }
   4.248 @@ -3388,139 +3360,142 @@
   4.249  	else	
   4.250  		actionRedo->setEnabled( false);
   4.251  
   4.252 -	TreeItem *selti=m->getSelectedItem();
   4.253 -	BranchItem *selbi=m->getSelectedBranchItem();
   4.254 -	if (selti)
   4.255 +	if (m)
   4.256  	{
   4.257 -		if (selbi)
   4.258 +		TreeItem *selti=m->getSelectedItem();
   4.259 +		BranchItem *selbi=m->getSelectedBranchItem();
   4.260 +		if (selti)
   4.261  		{
   4.262 -			// Take care of links  // FIXME-1
   4.263 -			/*
   4.264 -			if (bo->countXLinks()==0)
   4.265 +			if (selbi)
   4.266  			{
   4.267 -				branchXLinksContextMenuEdit->clear();
   4.268 -				branchXLinksContextMenuFollow->clear();
   4.269 -			} else
   4.270 +				// Take care of links  // FIXME-1
   4.271 +				/*
   4.272 +				if (bo->countXLinks()==0)
   4.273 +				{
   4.274 +					branchXLinksContextMenuEdit->clear();
   4.275 +					branchXLinksContextMenuFollow->clear();
   4.276 +				} else
   4.277 +				{
   4.278 +					BranchObj *bot;
   4.279 +					QString s;
   4.280 +					branchXLinksContextMenuEdit->clear();
   4.281 +					branchXLinksContextMenuFollow->clear();
   4.282 +					for (int i=0; i<=bo->countXLinks();i++)
   4.283 +					{
   4.284 +						bot=bo->XLinkTargetAt(i);
   4.285 +						if (bot)
   4.286 +						{
   4.287 +							s=bot->getHeading();
   4.288 +							if (s.length()>xLinkMenuWidth)
   4.289 +								s=s.left(xLinkMenuWidth)+"...";
   4.290 +							branchXLinksContextMenuFollow->addAction (s);
   4.291 +							branchXLinksContextMenuEdit->addAction (s);
   4.292 +						}	
   4.293 +					}
   4.294 +				}
   4.295 +				*/
   4.296 +				//Standard Flags
   4.297 +				standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
   4.298 +
   4.299 +				// System Flags
   4.300 +				actionToggleScroll->setEnabled (true);
   4.301 +				if ( selbi->isScrolled() )
   4.302 +					actionToggleScroll->setOn(true);
   4.303 +				else	
   4.304 +					actionToggleScroll->setOn(false);
   4.305 +
   4.306 +				if ( selti->getURL().isEmpty() )
   4.307 +				{
   4.308 +					actionOpenURL->setEnabled (false);
   4.309 +					actionOpenURLTab->setEnabled (false);
   4.310 +				}	
   4.311 +				else	
   4.312 +				{
   4.313 +					actionOpenURL->setEnabled (true);
   4.314 +					actionOpenURLTab->setEnabled (true);
   4.315 +				}
   4.316 +				if ( selti->getVymLink().isEmpty() )
   4.317 +				{
   4.318 +					actionOpenVymLink->setEnabled (false);
   4.319 +					actionDeleteVymLink->setEnabled (false);
   4.320 +				} else	
   4.321 +				{
   4.322 +					actionOpenVymLink->setEnabled (true);
   4.323 +					actionDeleteVymLink->setEnabled (true);
   4.324 +				}	
   4.325 +
   4.326 +				if (selbi->canMoveUp()) 
   4.327 +					actionMoveUp->setEnabled (true);
   4.328 +				else	
   4.329 +					actionMoveUp->setEnabled (false);
   4.330 +				if (selbi->canMoveDown()) 
   4.331 +					actionMoveDown->setEnabled (true);
   4.332 +				else	
   4.333 +					actionMoveDown->setEnabled (false);
   4.334 +
   4.335 +				actionSortChildren->setEnabled (true);
   4.336 +
   4.337 +				actionToggleHideExport->setEnabled (true);	
   4.338 +				actionToggleHideExport->setOn (selbi->hideInExport() );	
   4.339 +
   4.340 +				actionFileSave->setEnabled (true);	
   4.341 +				actionCopy->setEnabled (true);	
   4.342 +				actionCut->setEnabled (true);	
   4.343 +				if (!clipboardEmpty)
   4.344 +					actionPaste->setEnabled (true);	
   4.345 +				else	
   4.346 +					actionPaste->setEnabled (false);	
   4.347 +				for (int i=0; i<actionListBranches.size(); ++i)	
   4.348 +					actionListBranches.at(i)->setEnabled(true);
   4.349 +				actionDelete->setEnabled (true);
   4.350 +				//FIXME-2 actionFormatHideLinkUnselected->setOn (selection->getHideLinkUnselected());
   4.351 +			}
   4.352 +			if ( selti->getType()==TreeItem::Image)
   4.353  			{
   4.354 -				BranchObj *bot;
   4.355 -				QString s;
   4.356 -				branchXLinksContextMenuEdit->clear();
   4.357 -				branchXLinksContextMenuFollow->clear();
   4.358 -				for (int i=0; i<=bo->countXLinks();i++)
   4.359 -				{
   4.360 -					bot=bo->XLinkTargetAt(i);
   4.361 -					if (bot)
   4.362 -					{
   4.363 -						s=bot->getHeading();
   4.364 -						if (s.length()>xLinkMenuWidth)
   4.365 -							s=s.left(xLinkMenuWidth)+"...";
   4.366 -						branchXLinksContextMenuFollow->addAction (s);
   4.367 -						branchXLinksContextMenuEdit->addAction (s);
   4.368 -					}	
   4.369 -				}
   4.370 -			}
   4.371 -			*/
   4.372 -			//Standard Flags
   4.373 -			standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
   4.374 -
   4.375 -			// System Flags
   4.376 -			actionToggleScroll->setEnabled (true);
   4.377 -			if ( selbi->isScrolled() )
   4.378 -				actionToggleScroll->setOn(true);
   4.379 -			else	
   4.380 -				actionToggleScroll->setOn(false);
   4.381 -
   4.382 -			if ( selti->getURL().isEmpty() )
   4.383 -			{
   4.384 +			/* FIXME-2
   4.385 +				FloatObj *fo=(FloatImageObj*)selection;
   4.386 +
   4.387  				actionOpenURL->setEnabled (false);
   4.388 -				actionOpenURLTab->setEnabled (false);
   4.389 -			}	
   4.390 -			else	
   4.391 -			{
   4.392 -				actionOpenURL->setEnabled (true);
   4.393 -				actionOpenURLTab->setEnabled (true);
   4.394 -			}
   4.395 -			if ( selti->getVymLink().isEmpty() )
   4.396 -			{
   4.397  				actionOpenVymLink->setEnabled (false);
   4.398 -				actionDeleteVymLink->setEnabled (false);
   4.399 -			} else	
   4.400 -			{
   4.401 -				actionOpenVymLink->setEnabled (true);
   4.402 -				actionDeleteVymLink->setEnabled (true);
   4.403 -			}	
   4.404 -
   4.405 -            if (selbi->canMoveUp()) 
   4.406 -				actionMoveUp->setEnabled (true);
   4.407 -			else	
   4.408 +				actionDeleteVymLink->setEnabled (false);	
   4.409 +				actionToggleHideExport->setEnabled (true);	
   4.410 +				actionToggleHideExport->setOn (fo->hideInExport() );	
   4.411 +
   4.412 +
   4.413 +				actionCopy->setEnabled (true);
   4.414 +				actionCut->setEnabled (true);	
   4.415 +				actionPaste->setEnabled (false);	//FIXME-4 why not allowing copy of images?
   4.416 +				for (int i=0; i<actionListBranches.size(); ++i)	
   4.417 +					actionListBranches.at(i)->setEnabled(false);
   4.418 +				actionDelete->setEnabled (true);
   4.419 +				actionFormatHideLinkUnselected->setOn
   4.420 +					( selection->getHideLinkUnselected());
   4.421  				actionMoveUp->setEnabled (false);
   4.422 -			if (selbi->canMoveDown()) 
   4.423 -				actionMoveDown->setEnabled (true);
   4.424 -			else	
   4.425  				actionMoveDown->setEnabled (false);
   4.426 -
   4.427 -			actionSortChildren->setEnabled (true);
   4.428 -
   4.429 -			actionToggleHideExport->setEnabled (true);	
   4.430 -			actionToggleHideExport->setOn (selbi->hideInExport() );	
   4.431 -
   4.432 -			actionFileSave->setEnabled (true);	
   4.433 -			actionCopy->setEnabled (true);	
   4.434 -			actionCut->setEnabled (true);	
   4.435 -			if (!clipboardEmpty)
   4.436 -				actionPaste->setEnabled (true);	
   4.437 -			else	
   4.438 -				actionPaste->setEnabled (false);	
   4.439 +				*/
   4.440 +			}	//image
   4.441 +
   4.442 +		} else
   4.443 +		{	// !selti
   4.444 +			actionFileSave->setEnabled (false);	
   4.445 +			actionCopy->setEnabled (false);	
   4.446 +			actionCut->setEnabled (false);	
   4.447 +			actionPaste->setEnabled (false);	
   4.448  			for (int i=0; i<actionListBranches.size(); ++i)	
   4.449 -				actionListBranches.at(i)->setEnabled(true);
   4.450 -			actionDelete->setEnabled (true);
   4.451 -			//FIXME-2 actionFormatHideLinkUnselected->setOn (selection->getHideLinkUnselected());
   4.452 -		}
   4.453 -		if ( selti->getType()==TreeItem::Image)
   4.454 -		{
   4.455 -		/* FIXME-2
   4.456 -			FloatObj *fo=(FloatImageObj*)selection;
   4.457 -
   4.458 +				actionListBranches.at(i)->setEnabled(false);
   4.459 +
   4.460 +			actionToggleScroll->setEnabled (false);
   4.461  			actionOpenURL->setEnabled (false);
   4.462  			actionOpenVymLink->setEnabled (false);
   4.463  			actionDeleteVymLink->setEnabled (false);	
   4.464 -			actionToggleHideExport->setEnabled (true);	
   4.465 -			actionToggleHideExport->setOn (fo->hideInExport() );	
   4.466 -
   4.467 -
   4.468 -			actionCopy->setEnabled (true);
   4.469 -			actionCut->setEnabled (true);	
   4.470 -			actionPaste->setEnabled (false);	//FIXME-4 why not allowing copy of images?
   4.471 -			for (int i=0; i<actionListBranches.size(); ++i)	
   4.472 -				actionListBranches.at(i)->setEnabled(false);
   4.473 -			actionDelete->setEnabled (true);
   4.474 -			actionFormatHideLinkUnselected->setOn
   4.475 -				( selection->getHideLinkUnselected());
   4.476 +			actionHeading2URL->setEnabled (false);	
   4.477 +			actionDelete->setEnabled (false);
   4.478  			actionMoveUp->setEnabled (false);
   4.479  			actionMoveDown->setEnabled (false);
   4.480 -			*/
   4.481 -		}
   4.482 -
   4.483 -	} else
   4.484 -	{
   4.485 -		actionFileSave->setEnabled (false);	
   4.486 -		actionCopy->setEnabled (false);	
   4.487 -		actionCut->setEnabled (false);	
   4.488 -		actionPaste->setEnabled (false);	
   4.489 -		for (int i=0; i<actionListBranches.size(); ++i)	
   4.490 -			actionListBranches.at(i)->setEnabled(false);
   4.491 -
   4.492 -		actionToggleScroll->setEnabled (false);
   4.493 -		actionOpenURL->setEnabled (false);
   4.494 -		actionOpenVymLink->setEnabled (false);
   4.495 -		actionDeleteVymLink->setEnabled (false);	
   4.496 -		actionHeading2URL->setEnabled (false);	
   4.497 -		actionDelete->setEnabled (false);
   4.498 -		actionMoveUp->setEnabled (false);
   4.499 -		actionMoveDown->setEnabled (false);
   4.500 -		actionSortChildren->setEnabled (false);
   4.501 -		actionToggleHideExport->setEnabled (false);	
   4.502 -	}	
   4.503 +			actionSortChildren->setEnabled (false);
   4.504 +			actionToggleHideExport->setEnabled (false);	
   4.505 +		}	
   4.506 +	} // m
   4.507  }
   4.508  
   4.509  Main::ModMode Main::getModMode()
     5.1 --- a/mainwindow.h	Mon May 18 11:22:41 2009 +0000
     5.2 +++ b/mainwindow.h	Wed May 20 15:40:14 2009 +0000
     5.3 @@ -243,8 +243,7 @@
     5.4  
     5.5  	QStringList imageTypes;
     5.6  
     5.7 -	QList <VymModel*> tabModel;		//!< the corresponding model to a tab
     5.8 -
     5.9 +	QList <VymView*> vymViews;		//! Keeps track of models and views related to a tab 
    5.10  	QString prevSelection;
    5.11  
    5.12  	HistoryWindow *historyWindow;
     6.1 --- a/mapcenteritem.cpp	Mon May 18 11:22:41 2009 +0000
     6.2 +++ b/mapcenteritem.cpp	Wed May 20 15:40:14 2009 +0000
     6.3 @@ -12,7 +12,7 @@
     6.4  
     6.5  MapCenterItem::~MapCenterItem()
     6.6  {
     6.7 -	cout << "Destr. MapCenterItem\n";
     6.8 +//	cout << "Destr. MapCenterItem\n";
     6.9      qDeleteAll(childItems);
    6.10  }
    6.11  
     7.1 --- a/mapeditor.cpp	Mon May 18 11:22:41 2009 +0000
     7.2 +++ b/mapeditor.cpp	Wed May 20 15:40:14 2009 +0000
     7.3 @@ -118,7 +118,7 @@
     7.4  	lineEdit=new QLineEdit;
     7.5  	lineEdit->hide();
     7.6  	QGraphicsProxyWidget *pw=scene()->addWidget (lineEdit);
     7.7 -	pw->setZValue (100);
     7.8 +	pw->setZValue (Z_LINEEDIT);
     7.9  
    7.10  	a = new QAction( tr( "Edit heading","MapEditor" ), this);
    7.11  	a->setShortcut ( Qt::Key_Return );					//Edit heading
    7.12 @@ -182,6 +182,15 @@
    7.13      return mapScene;
    7.14  }
    7.15  
    7.16 +void MapEditor::scrollTo (const QModelIndex &index)
    7.17 +{
    7.18 +	if (index.isValid())
    7.19 +	{
    7.20 +		LinkableMapObj* lmo=(static_cast<TreeItem*>(index.internalPointer()))->getLMO();
    7.21 +		if (lmo) setScrollBarPosTarget (lmo->getBBox() );
    7.22 +	}
    7.23 +}
    7.24 +
    7.25  void MapEditor::setScrollBarPosTarget (const QRectF &rect)
    7.26  {
    7.27  	// Code copied from Qt sources
    7.28 @@ -838,7 +847,10 @@
    7.29  		// Check if we could link 
    7.30  		TreeItem *dsti=findMapItem (p, seli);
    7.31  		LinkableMapObj* dst=NULL;
    7.32 -		if (dsti) dst=dsti->getLMO();	//FIXME-2 get rid of lmo...
    7.33 +		if (dsti && dsti!=seli && dsti->isBranchLikeType())
    7.34 +			dst=dsti->getLMO(); //FIXME-2 get rid of lmo...
    7.35 +		else
    7.36 +			dsti=NULL;
    7.37  		
    7.38  
    7.39  		FloatObj *fio=model->getSelectedFloatImage();
    7.40 @@ -851,15 +863,10 @@
    7.41  
    7.42  			// Relink float to new mapcenter or branch, if shift is pressed	
    7.43  			// Only relink, if selection really has a new parent
    7.44 -			if ( (e->modifiers()==Qt::ShiftModifier) && dst &&
    7.45 -				( (typeid(*dst)==typeid(BranchObj)) ||
    7.46 -				  (typeid(*dst)==typeid(MapCenterObj)) ) &&
    7.47 -				( dst != fio->getParObj())  
    7.48 +			if ( (e->modifiers()==Qt::ShiftModifier) && dst && ( dst != fio->getParObj())  
    7.49  				)
    7.50  			{
    7.51 -				if (typeid(*fio) == typeid(FloatImageObj) && 
    7.52 -				( (typeid(*dst)==typeid(BranchObj) ||
    7.53 -				  typeid(*dst)==typeid(MapCenterObj)) ))  
    7.54 +				if (typeid(*fio) == typeid(FloatImageObj) )  
    7.55  				{
    7.56  
    7.57  					// Also save the move which was done so far
    7.58 @@ -911,7 +918,7 @@
    7.59  				} 
    7.60  
    7.61  				// Maybe we can relink temporary?
    7.62 -				if (dsti && (dst!=lmosel) && seli->isBranchLikeType() && dsti->isBranchLikeType() )
    7.63 +				if (dsti)
    7.64  				{
    7.65  					if (e->modifiers()==Qt::ControlModifier)
    7.66  					{
    7.67 @@ -963,9 +970,13 @@
    7.68      QPointF p = mapToScene(e->pos());
    7.69  	TreeItem *seli=model->getSelectedItem();
    7.70  
    7.71 -	TreeItem *dsti=findMapItem(p, seli);
    7.72 +	TreeItem *dsti=NULL;
    7.73 +	if (seli) dsti=findMapItem(p, seli);
    7.74  	LinkableMapObj* dst=NULL;
    7.75 -	if (dsti) dst=dsti->getLMO();	//FIXME-2 get rid of dst...
    7.76 +	if (dsti && dsti->isBranchLikeType ()) 
    7.77 +		dst=dsti->getLMO();	//FIXME-2 get rid of dst...
    7.78 +	else
    7.79 +		dsti=NULL;
    7.80  
    7.81  
    7.82  	// Have we been picking color?
    7.83 @@ -974,7 +985,7 @@
    7.84  		pickingColor=false;
    7.85  		setCursor (Qt::ArrowCursor);
    7.86  		// Check if we are over another branch
    7.87 -		if (dsti && seli) 
    7.88 +		if (dst) 
    7.89  		{	
    7.90  			if (e->state() & Qt::ShiftModifier)
    7.91  				model->colorBranch (((BranchObj*)dst)->getColor());
    7.92 @@ -989,7 +1000,7 @@
    7.93  	{
    7.94  		drawingLink=false;
    7.95  		// Check if we are over another branch
    7.96 -		if (dsti && seli && dsti->isBranchLikeType() ) 
    7.97 +		if (dsti)
    7.98  		{	
    7.99  			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
   7.100  			tmpXLink->updateXLink();
   7.101 @@ -1006,11 +1017,6 @@
   7.102      // Have we been moving something?
   7.103      if ( seli && movingObj ) 
   7.104      {	
   7.105 -		if (dsti==seli) 
   7.106 -		{
   7.107 -			dsti=NULL;
   7.108 -			dst=NULL;
   7.109 -		}
   7.110  		FloatImageObj *fo=model->getSelectedFloatImage();
   7.111  		if(fo)
   7.112  		{
   7.113 @@ -1028,15 +1034,6 @@
   7.114  			model->reposition();
   7.115  		}	
   7.116  
   7.117 -		// Check if we are over another branch, but ignore 
   7.118 -		// any found LMOs, which are FloatObjs
   7.119 -
   7.120 -		if (dsti && (!dsti->isBranchLikeType() )) 
   7.121 -		{
   7.122 -			dst=NULL;
   7.123 -			dsti=NULL;
   7.124 -		}	
   7.125 -		
   7.126  		BranchItem *bi=model->getSelectedBranchItem();
   7.127  		if (bi && bi->depth()==0)
   7.128  		{	
   7.129 @@ -1069,7 +1066,7 @@
   7.130  			QString preSelStr=model->getSelectString(lmosel);
   7.131  
   7.132  			copyingObj=false;	
   7.133 -			if (dsti && dsti->isBranchLikeType() ) 
   7.134 +			if (dsti)
   7.135  			{
   7.136  				// We have a destination, relink to that
   7.137  
     8.1 --- a/mapeditor.h	Mon May 18 11:22:41 2009 +0000
     8.2 +++ b/mapeditor.h	Wed May 20 15:40:14 2009 +0000
     8.3 @@ -31,6 +31,7 @@
     8.4  	QPointF scrollBarPosTarget;
     8.5  	QtPropertyAnimation scrollBarPosAnimation;
     8.6  public:
     8.7 +	void scrollTo (const QModelIndex &index);
     8.8  	void setScrollBarPosTarget (const QRectF &rect);	//!  ensureVisible of rect
     8.9  	QPointF getScrollBarPosTarget ();
    8.10  	void setScrollBarPos (const QPointF &p);
    8.11 @@ -135,7 +136,6 @@
    8.12  public:
    8.13  	void setSelectionColor (QColor c);
    8.14  	QColor getSelectionColor ();
    8.15 -
    8.16  };
    8.17  #endif
    8.18  
     9.1 --- a/mapobj.h	Mon May 18 11:22:41 2009 +0000
     9.2 +++ b/mapobj.h	Wed May 20 15:40:14 2009 +0000
     9.3 @@ -6,14 +6,15 @@
     9.4  
     9.5  #include "xmlobj.h"
     9.6  
     9.7 -#define Z_BBOX      0
     9.8 -#define Z_XLINK    10
     9.9 -#define Z_LINK     20
    9.10 -#define Z_FRAME    50
    9.11 -#define Z_SELBOX   60
    9.12 -#define Z_FLOATIMG 65
    9.13 -#define Z_ICON     80
    9.14 -#define Z_TEXT    100
    9.15 +#define Z_BBOX       0
    9.16 +#define Z_XLINK     10
    9.17 +#define Z_LINK      20
    9.18 +#define Z_FRAME     50
    9.19 +#define Z_SELBOX    60
    9.20 +#define Z_FLOATIMG  65
    9.21 +#define Z_ICON      80
    9.22 +#define Z_TEXT     100
    9.23 +#define Z_LINEEDIT 110
    9.24  
    9.25  /*! \brief Base class for all objects visible on a map
    9.26  */
    10.1 --- a/treeitem.cpp	Mon May 18 11:22:41 2009 +0000
    10.2 +++ b/treeitem.cpp	Wed May 20 15:40:14 2009 +0000
    10.3 @@ -10,6 +10,7 @@
    10.4  
    10.5  using namespace std;
    10.6  
    10.7 +extern FlagRow* standardFlagsMaster;
    10.8  
    10.9  TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent):MapItem()
   10.10  {
   10.11 @@ -64,6 +65,8 @@
   10.12  
   10.13  	// Reset ID
   10.14  	objID="";
   10.15 +
   10.16 +	standardFlags.setMasterRow (standardFlagsMaster);
   10.17  }
   10.18  
   10.19  QString TreeItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
   10.20 @@ -120,6 +123,15 @@
   10.21  	}
   10.22  }
   10.23  
   10.24 +void TreeItem::removeChildBranches()
   10.25 +{
   10.26 +	while ( childItems.size()>0)
   10.27 +	{
   10.28 +		branchCounter--;
   10.29 +		childItems.removeAt (0);
   10.30 +	}
   10.31 +}
   10.32 +
   10.33  TreeItem *TreeItem::child(int row)
   10.34  {
   10.35      return childItems.value(row);
    11.1 --- a/treeitem.h	Mon May 18 11:22:41 2009 +0000
    11.2 +++ b/treeitem.h	Wed May 20 15:40:14 2009 +0000
    11.3 @@ -35,6 +35,7 @@
    11.4  
    11.5      virtual void appendChild (TreeItem *child);
    11.6  	virtual void removeChild (int row);
    11.7 +	virtual void removeChildBranches ();
    11.8  
    11.9      virtual TreeItem *child(int row);
   11.10      virtual int childCount() const;
   11.11 @@ -121,7 +122,6 @@
   11.12  	virtual bool isActiveStandardFlag (const QString &flag);
   11.13  	virtual QStringList activeStandardFlagNames();
   11.14  	virtual FlagRow* getStandardFlagRow ();
   11.15 -	//virtual void updateToolBar();
   11.16  
   11.17  	virtual QStringList activeSystemFlagNames();
   11.18  
    12.1 --- a/treemodel.cpp	Mon May 18 11:22:41 2009 +0000
    12.2 +++ b/treemodel.cpp	Wed May 20 15:40:14 2009 +0000
    12.3 @@ -164,6 +164,7 @@
    12.4  	return current;
    12.5  }
    12.6  
    12.7 +/*
    12.8  bool TreeModel::insertRows ( int row, int count, const QModelIndex & parent)
    12.9  {
   12.10  	std::cout << "TreeModel insertRows()\n";
   12.11 @@ -177,6 +178,7 @@
   12.12  	endInsertRows ();
   12.13  	return true;
   12.14  }
   12.15 +*/
   12.16  
   12.17  bool TreeModel::removeRows ( int row, int count, const QModelIndex & parent)
   12.18  {
    13.1 --- a/treemodel.h	Mon May 18 11:22:41 2009 +0000
    13.2 +++ b/treemodel.h	Wed May 20 15:40:14 2009 +0000
    13.3 @@ -30,8 +30,10 @@
    13.4  
    13.5  	BranchItem* next(BranchItem* &current, BranchItem* &previous, int &d0);
    13.6  
    13.7 +/*
    13.8  	bool insertRows ( int row, int count, 
    13.9  				const QModelIndex & parent = QModelIndex() ); 
   13.10 +*/				
   13.11  	bool removeRows ( int row, int count, 
   13.12  				const QModelIndex & parent = QModelIndex() ); 
   13.13  
    14.1 --- a/vymmodel.cpp	Mon May 18 11:22:41 2009 +0000
    14.2 +++ b/vymmodel.cpp	Wed May 20 15:40:14 2009 +0000
    14.3 @@ -30,6 +30,7 @@
    14.4  extern QString tmpVymDir;
    14.5  
    14.6  extern TextEditor *textEditor;
    14.7 +extern FlagRow *standardFlagsMaster;
    14.8  
    14.9  extern QString clipboardDir;
   14.10  extern QString clipboardFile;
   14.11 @@ -60,7 +61,7 @@
   14.12  
   14.13  VymModel::~VymModel() 
   14.14  {
   14.15 -//    cout << "Destr VymModel\n";
   14.16 +    cout << "Destr VymModel\n";
   14.17  	autosaveTimer->stop();
   14.18  	fileChangedTimer->stop();
   14.19  	clear();
   14.20 @@ -71,7 +72,7 @@
   14.21  	selModel->clearSelection();
   14.22  
   14.23  	//QModelIndex ri=index(rootItem);
   14.24 -	//removeRows (0, rowCount(ri),ri);		// FIXME-2 here should be at least a beginRemoveRows...
   14.25 +	//removeRows (0, rowCount(ri),ri);		// FIXME-3 here should be at least a beginRemoveRows...
   14.26  }
   14.27  
   14.28  void VymModel::init () 
   14.29 @@ -232,7 +233,7 @@
   14.30  	xml.incIndent();
   14.31  
   14.32  	// Find the used flags while traversing the tree	// FIXME-2 this can be done local to vymmodel maybe...
   14.33 -	//FIXME-2 not used any longer: standardFlagsDefault->resetUsedCounter();
   14.34 +	standardFlagsMaster->resetUsedCounter();
   14.35  	
   14.36  	// Reset the counters before saving
   14.37  	// TODO constr. of FIO creates lots of objects, better do this in some other way...
   14.38 @@ -262,7 +263,7 @@
   14.39  	xml.decIndent();
   14.40  	s+=xml.endElement("vymmap");
   14.41  
   14.42 -	// FIXME-2 if (writeflags) standardFlagsDefault->saveToDir (tmpdir+"/flags/","",writeflags);
   14.43 +	if (writeflags) standardFlagsMaster->saveToDir (tmpdir+"/flags/","",writeflags);
   14.44  	return s;
   14.45  }
   14.46  
   14.47 @@ -2008,7 +2009,6 @@
   14.48  MapCenterItem* VymModel::addMapCenter ()
   14.49  {
   14.50  	MapCenterItem *mci=addMapCenter (contextPos);
   14.51 -	//FIXME-3 selection.select (mco);
   14.52  	updateActions();
   14.53  	emitShowSelection();
   14.54  	saveState (
   14.55 @@ -2044,26 +2044,6 @@
   14.56  	// Create MapObj
   14.57  	BranchObj *newbo=mci->createMapObj(mapScene);
   14.58  		
   14.59 -	/*
   14.60 -
   14.61 -	if (!mci->getHeading().isEmpty() ) 
   14.62 -	{
   14.63 -		newbo->updateHeading();
   14.64 -		newbo->setColor (headingColor);
   14.65 -	}	
   14.66 -*/
   14.67 -		
   14.68 -	//newbo->updateLink();	//FIXME-3
   14.69 -
   14.70 -/*
   14.71 -	//mapCenter->setMapEditor(mapEditor);		//FIXME-3 VM needed to get defLinkStyle, mapLinkColorHint ... for later added objects
   14.72 -	mapCenter->setTreeItem (mci);	// TreeItem needs to exist before setVisibility
   14.73 -	mci->setLMO (mapCenter);
   14.74 -	mapCenter->updateHeading();
   14.75 -	mapCenter->move (absPos);
   14.76 -    mapCenter->setVisibility (true);
   14.77 -	//mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
   14.78 -*/
   14.79  	return mci;
   14.80  }
   14.81  
   14.82 @@ -2095,30 +2075,22 @@
   14.83  		beginInsertRows (parix,n,n+1);	
   14.84  		parbi->appendChild (newbi);	
   14.85  		endInsertRows ();
   14.86 -	}else if (num==-1)
   14.87 +	}else if (num==-1 || num==-3)
   14.88  	{
   14.89  		// insert below selection
   14.90  		parbi=(BranchItem*)dst->parent();
   14.91  		parix=index(parbi);
   14.92 -		n=dst->childNumber()+1;
   14.93 +		n=dst->childNumber()+ (3+num)/2;	//-1 |-> 1;-3 |-> 0
   14.94  		beginInsertRows (parix,n,n);	
   14.95  		parbi->insertBranch(n,newbi);	
   14.96  		endInsertRows ();
   14.97 -	}else if (num==-3)
   14.98 -	{
   14.99 -		// insert above selection
  14.100 -		parbi=(BranchItem*)dst->parent();
  14.101 -		parix=index(parbi);
  14.102 -		n=dst->childNumber();
  14.103 -		beginInsertRows (parix,n,n);	
  14.104 -		parbi->insertBranch(n,newbi);	
  14.105 -		endInsertRows ();
  14.106 -	} 
  14.107 +	}
  14.108  	emit (layoutChanged() );
  14.109  
  14.110  	// save scroll state. If scrolled, automatically select
  14.111  	// new branch in order to tmp unscroll parent...
  14.112  	newbi->createMapObj(mapScene);
  14.113 +	reposition();
  14.114  	select (newbi);
  14.115  	return newbi;
  14.116  }	
  14.117 @@ -2165,7 +2137,7 @@
  14.118  }
  14.119  
  14.120  
  14.121 -BranchItem* VymModel::addNewBranchBefore()	//FIXME-0
  14.122 +BranchItem* VymModel::addNewBranchBefore()	
  14.123  {
  14.124  	BranchItem *newbi=NULL;
  14.125  	BranchItem *selbi=getSelectedBranchItem();
  14.126 @@ -2315,24 +2287,29 @@
  14.127  	}	
  14.128  */}
  14.129  
  14.130 -void VymModel::deleteChildren()		//FIXME-2 VM still missing
  14.131 -
  14.132 -{
  14.133 -/*
  14.134 -	BranchObj *bo=getSelectedBranch();
  14.135 -	if (bo)
  14.136 +void VymModel::deleteChildren()		
  14.137 +
  14.138 +{
  14.139 +	BranchItem *selbi=getSelectedBranchItem();
  14.140 +	if (selbi)
  14.141  	{		
  14.142  		saveStateChangingPart(
  14.143 -			bo, 
  14.144 -			bo,
  14.145 +			selbi, 
  14.146 +			selbi,
  14.147  			"deleteChildren ()",
  14.148 -			QString( "Remove children of branch %1").arg(getObjectName(bo))
  14.149 +			QString( "Remove children of branch %1").arg(getObjectName(selbi))
  14.150  		);
  14.151 -		bo->removeChildren();
  14.152 +		emit (layoutAboutToBeChanged() );
  14.153 +
  14.154 +		QModelIndex ix=index (selbi);
  14.155 +		int n=selbi->branchCount()-1;
  14.156 +		beginRemoveRows (ix,0,n);
  14.157 +		removeRows (0,n+1,ix);
  14.158 +		endRemoveRows();
  14.159 +		emit (layoutChanged() );
  14.160  		reposition();
  14.161  	}	
  14.162 -*/}
  14.163 -
  14.164 +}
  14.165  
  14.166  bool VymModel::scrollBranch(BranchItem *bi)
  14.167  {
  14.168 @@ -4972,7 +4949,7 @@
  14.169  	return NULL;
  14.170  }
  14.171  
  14.172 -TreeItem* VymModel::getSelectedItem()
  14.173 +TreeItem* VymModel::getSelectedItem()	
  14.174  {
  14.175  	QModelIndexList list=selModel->selectedIndexes();
  14.176  	if (!list.isEmpty() )
    15.1 --- a/vymview.cpp	Mon May 18 11:22:41 2009 +0000
    15.2 +++ b/vymview.cpp	Wed May 20 15:40:14 2009 +0000
    15.3 @@ -3,7 +3,6 @@
    15.4  #include <iostream>
    15.5  using namespace std;
    15.6  
    15.7 -#include "linkablemapobj.h"
    15.8  #include "mainwindow.h"
    15.9  #include "mapeditor.h"
   15.10  #include "treeeditor.h"
   15.11 @@ -34,13 +33,7 @@
   15.12  	connect (
   15.13  		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
   15.14  		mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
   15.15 -		/*
   15.16 -	connect (
   15.17 -		selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)), 
   15.18 -		me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
   15.19 -		*/
   15.20 -		/*
   15.21 -*/
   15.22 +
   15.23  	connect (
   15.24  		model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)), 
   15.25  		mapEditor,SLOT (updateData(const QModelIndex &) ) );
   15.26 @@ -76,6 +69,21 @@
   15.27  	setSizes(widths);
   15.28  }
   15.29  
   15.30 +VymView::~VymView()
   15.31 +{
   15.32 +	//cout << "Destructor VymView\n";
   15.33 +}
   15.34 +
   15.35 +VymModel* VymView::getModel()
   15.36 +{
   15.37 +	return model;
   15.38 +}
   15.39 +
   15.40 +MapEditor* VymView::getMapEditor()
   15.41 +{
   15.42 +	return mapEditor;
   15.43 +}
   15.44 +
   15.45  void VymView::initFocus()
   15.46  {
   15.47  	mapEditor->setFocus();
   15.48 @@ -92,16 +100,6 @@
   15.49  
   15.50  void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
   15.51  {
   15.52 -	/*
   15.53 -	cout <<"VymView::changeSelection (";
   15.54 -	if (!newsel.indexes().isEmpty() )
   15.55 -		cout << model->getItem(newsel.indexes().first() )->getHeading().toStdString();
   15.56 -	cout << " <- ";
   15.57 -	if (!oldsel.indexes().isEmpty() )
   15.58 -		cout << model->getItem(oldsel.indexes().first() )->getHeading().toStdString();
   15.59 -	cout << ")\n";
   15.60 -	*/
   15.61 -
   15.62  	// Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...)
   15.63  	mainWindow->changeSelection (model,newsel,oldsel);	// FIXME-3 maybe connect VymModel <-> MainWindow directly?
   15.64  	showSelection();
   15.65 @@ -114,14 +112,8 @@
   15.66  
   15.67  void VymView::showSelection()
   15.68  {
   15.69 -	treeEditor->scrollTo(
   15.70 -		model->getSelectedIndex(), 
   15.71 -		//QAbstractItemView::PositionAtCenter   
   15.72 -		QAbstractItemView::EnsureVisible
   15.73 -	);
   15.74 -
   15.75 -	LinkableMapObj* lmo=model->getSelectedLMO();
   15.76 -	if (lmo) 
   15.77 -		mapEditor->setScrollBarPosTarget (lmo->getBBox() );
   15.78 +	QModelIndex ix=model->getSelectedIndex();
   15.79 +	treeEditor->scrollTo( ix, QAbstractItemView::EnsureVisible);
   15.80 +	mapEditor->scrollTo ( ix);
   15.81  }
   15.82  
    16.1 --- a/vymview.h	Mon May 18 11:22:41 2009 +0000
    16.2 +++ b/vymview.h	Wed May 20 15:40:14 2009 +0000
    16.3 @@ -15,6 +15,9 @@
    16.4  	Q_OBJECT
    16.5  public:
    16.6  	VymView(VymModel *model);
    16.7 +	~VymView();
    16.8 +	VymModel* getModel();
    16.9 +	MapEditor* getMapEditor();
   16.10  	void initFocus();
   16.11  	QItemSelectionModel* selectionModel();
   16.12  
    17.1 --- a/xml-vym.cpp	Mon May 18 11:22:41 2009 +0000
    17.2 +++ b/xml-vym.cpp	Wed May 20 15:40:14 2009 +0000
    17.3 @@ -356,8 +356,7 @@
    17.4  
    17.5  bool parseVYMHandler::readBranchAttr (const QXmlAttributes& a)	//FIXME-2
    17.6  {
    17.7 -	branchesCurrent++;
    17.8 -	mainWindow->setProgressValue (branchesCurrent);
    17.9 +	mainWindow->setProgressValue (branchesCurrent++);
   17.10  
   17.11  	if (!readOOAttr(a)) return false;
   17.12