vymmodel.cpp
changeset 776 25e634a7e1dc
parent 775 6e4b586aa88a
child 777 8acac4fade1b
     1.1 --- a/vymmodel.cpp	Wed Jun 03 20:37:17 2009 +0000
     1.2 +++ b/vymmodel.cpp	Mon Jun 08 11:36:56 2009 +0000
     1.3 @@ -234,7 +234,7 @@
     1.4  	
     1.5  	// Reset the counters before saving
     1.6  	// TODO constr. of FIO creates lots of objects, better do this in some other way...
     1.7 -	FloatImageObj (mapScene).resetSaveCounter();// FIXME-2 this can be done local to vymmodel maybe...
     1.8 +	ImageItem().resetSaveCounter();// FIXME-2 this can be done local to vymmodel maybe...
     1.9  
    1.10  	// Build xml recursivly
    1.11  	if (!saveSel || saveSel->getType()==TreeItem::MapCenter)
    1.12 @@ -260,6 +260,8 @@
    1.13  	xml.decIndent();
    1.14  	s+=xml.endElement("vymmap");
    1.15  
    1.16 +	//cout << s.toStdString() << endl;
    1.17 +
    1.18  	if (writeflags) standardFlagsMaster->saveToDir (tmpdir+"/flags/","",writeflags);
    1.19  	return s;
    1.20  }
    1.21 @@ -623,7 +625,7 @@
    1.22  	return err;
    1.23  }
    1.24  
    1.25 -void VymModel::addMapReplaceInt(const QString &undoSel, const QString &path)
    1.26 +void VymModel::addMapReplaceInt(const QString &undoSel, const QString &path)	// FIXME-1 test e.g. with undo color subtree
    1.27  {
    1.28  	QString pathDir=path.left(path.findRev("/"));
    1.29  	QDir d(pathDir);
    1.30 @@ -700,15 +702,14 @@
    1.31  */
    1.32  }
    1.33  
    1.34 -FloatImageObj* VymModel::loadFloatImageInt (BranchItem *dst,QString fn)
    1.35 -{
    1.36 -	TreeItem *fi=createImage(dst);
    1.37 -	if (fi)
    1.38 +ImageItem* VymModel::loadFloatImageInt (BranchItem *dst,QString fn)
    1.39 +{
    1.40 +	ImageItem *ii=createImage(dst);
    1.41 +	if (ii)
    1.42  	{
    1.43 -		FloatImageObj *fio= ((FloatImageObj*)fi->getLMO());
    1.44 -		fio->load (fn);
    1.45 +		ii->load (fn);
    1.46  		reposition();
    1.47 -		return fio;
    1.48 +		return ii;
    1.49  	}
    1.50  	return NULL;
    1.51  }	
    1.52 @@ -735,16 +736,15 @@
    1.53  			// TODO loadFIO in QT4 use:	lastImageDir=fd->directory();
    1.54  			lastImageDir=QDir (fd->dirPath());
    1.55  			QString s;
    1.56 -			FloatImageObj *fio;
    1.57 +			ImageItem *ii;
    1.58  			for (int j=0; j<fd->selectedFiles().count(); j++)
    1.59  			{
    1.60  				s=fd->selectedFiles().at(j);
    1.61 -				fio=loadFloatImageInt (selbi,s);
    1.62 -				//FIXME-1 savestate for loadImage missing
    1.63 -				/*
    1.64 -				if (fio)
    1.65 +				ii=loadFloatImageInt (selbi,s);
    1.66 +				//FIXME-3 check savestate for loadImage 
    1.67 +				if (ii)
    1.68  					saveState(
    1.69 -						(LinkableMapObj*)fio,
    1.70 +						(TreeItem*)ii,
    1.71  						"delete ()",
    1.72  						selbi, 
    1.73  						QString ("loadImage (%1)").arg(s ),
    1.74 @@ -753,7 +753,6 @@
    1.75  				else
    1.76  					// TODO loadFIO error handling
    1.77  					qWarning ("Failed to load "+s);
    1.78 -					*/
    1.79  			}
    1.80  		}
    1.81  		delete (p);
    1.82 @@ -761,16 +760,15 @@
    1.83  	}
    1.84  }
    1.85  
    1.86 -void VymModel::saveFloatImageInt  (FloatImageObj *fio, const QString &type, const QString &fn)
    1.87 -{
    1.88 -	fio->save (fn,type);
    1.89 +void VymModel::saveFloatImageInt  (ImageItem *ii, const QString &type, const QString &fn)
    1.90 +{
    1.91 +	ii->save (fn,type);
    1.92  }
    1.93  
    1.94  void VymModel::saveFloatImage ()
    1.95  {
    1.96 -	//FIXME-1 FloatImageObj *fio=selection.getFloatImage();
    1.97 -	FloatImageObj *fio=NULL;
    1.98 -	if (fio)
    1.99 +	ImageItem *ii=getSelectedImageItem();
   1.100 +	if (ii)
   1.101  	{
   1.102  		QFileDialog *fd=new QFileDialog( NULL);
   1.103  		fd->setFilters (imageIO.getFilters());
   1.104 @@ -808,7 +806,7 @@
   1.105  						break;
   1.106  				}
   1.107  			}
   1.108 -			saveFloatImageInt (fio,fd->selectedFilter(),fn );
   1.109 +			saveFloatImageInt (ii,fd->selectedFilter(),fn );
   1.110  		}
   1.111  		delete (fd);
   1.112  	}
   1.113 @@ -992,40 +990,24 @@
   1.114  	findReset();
   1.115  }
   1.116  
   1.117 -QString VymModel::getObjectName (const LinkableMapObj *lmo)	// FIXME-3 should be obsolete
   1.118 -{
   1.119 -	QString s;
   1.120 -	if (!lmo) return QString("Error: NULL has no name!");
   1.121 -
   1.122 -	TreeItem *ti=lmo->getTreeItem();
   1.123 -	if (ti->isBranchLikeType() )
   1.124 -	{
   1.125 -		
   1.126 -		s=lmo->getTreeItem()->getHeading();
   1.127 -		if (s=="") s="unnamed";
   1.128 -		return QString("branch (%1)").arg(s);
   1.129 -	}	
   1.130 -	if (ti->getType()==TreeItem::Image)
   1.131 -		return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename());
   1.132 -	return QString("Unknown type has no name!");
   1.133 +QString VymModel::getObjectName (LinkableMapObj *lmo)	// FIXME-3 should be obsolete
   1.134 +{
   1.135 +	if (!lmo || !lmo->getTreeItem() ) return QString();
   1.136 +	return getObjectName (lmo->getTreeItem() );
   1.137  }
   1.138  
   1.139  
   1.140 -QString VymModel::getObjectName (const TreeItem *ti)
   1.141 +QString VymModel::getObjectName (TreeItem *ti)
   1.142  {
   1.143  	QString s;
   1.144  	if (!ti) return QString("Error: NULL has no name!");
   1.145 -
   1.146 -	if (ti->isBranchLikeType() )
   1.147 -	{
   1.148 -		s=ti->getHeading();
   1.149 -		if (s=="") s="unnamed";
   1.150 +	s=ti->getHeading();
   1.151 +	if (s=="") s="unnamed";
   1.152 +
   1.153 +	if (ti->isBranchLikeType() )	//FIXME-3 shouldnt there also be mapcenter??
   1.154  		return QString("branch (%1)").arg(s);
   1.155 -	}	
   1.156 -	/* FIXME-2 move floatimage to TreeModel first
   1.157 -	if (type==TreeItem::Image)
   1.158 -		return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename());
   1.159 -	*/	
   1.160 +	if (ti->getType()==TreeItem::Image)
   1.161 +		return QString ("image (%1)").arg(ti->getHeading());
   1.162  	return QString("Unknown type has no name!");
   1.163  }
   1.164  
   1.165 @@ -1480,7 +1462,7 @@
   1.166  	return QDate::currentDate().toString ("yyyy-MM-dd");
   1.167  }
   1.168  
   1.169 -int VymModel::branchCount()	// FIXME-2 Optimize this: use internal counter instead of going through whole map each time...
   1.170 +int VymModel::branchCount()	// FIXME-4 Optimize this: use internal counter instead of going through whole map each time...
   1.171  {
   1.172  	int c=0;
   1.173  	BranchItem *cur=NULL;
   1.174 @@ -1627,9 +1609,9 @@
   1.175  	return urls;
   1.176  }
   1.177  
   1.178 -void VymModel::linkFloatImageTo(const QString &dstString)	// FIXME-1
   1.179 -{
   1.180 -	//FIXME-1 FloatImageObj *fio=selection.getFloatImage();
   1.181 +void VymModel::linkFloatImageTo(const QString &dstString)	// FIXME-0
   1.182 +{
   1.183 +	//FIXME-0 FloatImageObj *fio=selection.getFloatImage();
   1.184  	FloatImageObj *fio=NULL;
   1.185  	if (fio)
   1.186  	{
   1.187 @@ -1640,7 +1622,7 @@
   1.188  			QString parString=getSelectString(dstPar);
   1.189  			QString fioPreSelectString=getSelectString(fio);
   1.190  			QString fioPreParentSelectString=getSelectString (fio->getParObj());
   1.191 -			// FIXME-1 ((BranchObj*)dst)->addFloatImage (fio);
   1.192 +			// FIXME-0 ((BranchObj*)dst)->addFloatImage (fio);
   1.193  			unselect();
   1.194  			// ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
   1.195  			fio=((BranchObj*)dst)->getLastFloatImage();
   1.196 @@ -1813,20 +1795,23 @@
   1.197  
   1.198  void VymModel::setHideExport(bool b)
   1.199  {
   1.200 -	BranchItem *bi=getSelectedBranchItem();
   1.201 -	if (bi)
   1.202 +	MapItem *mi=(MapItem*)getSelectedItem();
   1.203 +	if (mi && 
   1.204 +		(mi->getType()==TreeItem::Image ||mi->isBranchLikeType()))
   1.205  	{
   1.206 -		bi->setHideInExport (b);
   1.207 +		mi->setHideInExport (b);
   1.208  		QString u= b ? "false" : "true";
   1.209  		QString r=!b ? "false" : "true";
   1.210  		
   1.211  		saveState(
   1.212 -			bi,
   1.213 +			mi,
   1.214  			QString ("setHideExport (%1)").arg(u),
   1.215 -			bi,
   1.216 +			mi,
   1.217  			QString ("setHideExport (%1)").arg(r),
   1.218 -			QString ("Set HideExport flag of %1 to %2").arg(getObjectName(bi)).arg (r)
   1.219 +			QString ("Set HideExport flag of %1 to %2").arg(getObjectName(mi)).arg (r)
   1.220  		);	
   1.221 +			emitDataHasChanged(mi);
   1.222 +			emitSelectionChanged();
   1.223  		updateActions();
   1.224  		reposition();
   1.225  		// emitSelectionChanged();
   1.226 @@ -1836,9 +1821,9 @@
   1.227  
   1.228  void VymModel::toggleHideExport()
   1.229  {
   1.230 -	BranchItem *selbi=getSelectedBranchItem();
   1.231 -	if (selbi)
   1.232 -		setHideExport ( !selbi->hideInExport() );
   1.233 +	TreeItem *selti=getSelectedItem();
   1.234 +	if (selti)
   1.235 +		setHideExport ( !selti->hideInExport() );
   1.236  }
   1.237  
   1.238  
   1.239 @@ -1971,31 +1956,35 @@
   1.240  		return NULL;
   1.241  }
   1.242  
   1.243 -TreeItem* VymModel::createImage(BranchItem *dst)	//FIXME-1
   1.244 -{
   1.245 -	return NULL;
   1.246 -/*
   1.247 +ImageItem* VymModel::createImage(BranchItem *dst)
   1.248 +{
   1.249  	if (dst)
   1.250  	{
   1.251 -		FloatImageObj *newfio=bo->addFloatImage(); // FIXME-1 VM Old model, merge with below
   1.252 -
   1.253 -		// Create TreeItem
   1.254 +		QModelIndex parix;
   1.255 +		int n;
   1.256  		QList<QVariant> cData;
   1.257 -		cData << "VM:createImage" << "undef"<<"undef";
   1.258 -		TreeItem *parti=bo->getTreeItem();
   1.259 -		TreeItem *ti=new TreeItem (cData,parti);
   1.260 -		ti->setLMO (newfio);
   1.261 -		ti->setType (TreeItem::Image);
   1.262 -		parti->appendChild (ti);
   1.263 -
   1.264 -		if (newfio)
   1.265 -		{
   1.266 -			newfio->setTreeItem (ti);
   1.267 -			select (newfio); // FIXME-2 VM really needed here?
   1.268 -			return ti;
   1.269 -		}
   1.270 -	}
   1.271 -*/
   1.272 +		cData << "VM::createImage" << "undef"<<"undef";
   1.273 +
   1.274 +		ImageItem *newii=new ImageItem (cData);	
   1.275 +		newii->setHeading (QApplication::translate("Heading of new image in map", "new image"));
   1.276 +
   1.277 +		emit (layoutAboutToBeChanged() );
   1.278 +
   1.279 +			parix=index(dst);
   1.280 +			n=dst->getRowNumAppend(newii);
   1.281 +			beginInsertRows (parix,n,n+1);
   1.282 +			dst->appendChild (newii);	
   1.283 +			endInsertRows ();
   1.284 +
   1.285 +		emit (layoutChanged() );
   1.286 +
   1.287 +		// save scroll state. If scrolled, automatically select
   1.288 +		// new branch in order to tmp unscroll parent...
   1.289 +		newii->createMapObj(mapScene);
   1.290 +		reposition();
   1.291 +		return newii;
   1.292 +	} 
   1.293 +	return NULL;
   1.294  }
   1.295  
   1.296  BranchItem* VymModel::addMapCenter ()
   1.297 @@ -2065,7 +2054,7 @@
   1.298  	{
   1.299  		parbi=dst;
   1.300  		parix=index(parbi);
   1.301 -		n=parbi->childCount();
   1.302 +		n=parbi->getRowNumAppend (newbi);
   1.303  		beginInsertRows (parix,n,n+1);	
   1.304  		parbi->appendChild (newbi);	
   1.305  		endInsertRows ();
   1.306 @@ -2073,8 +2062,9 @@
   1.307  	{
   1.308  		// insert below selection
   1.309  		parbi=(BranchItem*)dst->parent();
   1.310 -		parix=index(parbi);
   1.311 -		n=dst->childNumber()+ (3+num)/2;	//-1 |-> 1;-3 |-> 0
   1.312 +		parix=index(parbi);  
   1.313 +		
   1.314 +		n=dst->childNumber() + (3+num)/2;	//-1 |-> 1;-3 |-> 0
   1.315  		beginInsertRows (parix,n,n);	
   1.316  		parbi->insertBranch(n,newbi);	
   1.317  		endInsertRows ();
   1.318 @@ -2201,52 +2191,39 @@
   1.319  {
   1.320  	BranchItem *selbi=getSelectedBranchItem();
   1.321  
   1.322 -	if (!selbi) return;
   1.323 -
   1.324 -	TreeItem *pi=selbi->parent();
   1.325 -	QModelIndex parentIndex=index(pi);
   1.326 -	
   1.327 -	if (selbi->isBranchLikeType() )
   1.328 +	if (selbi && selbi->isBranchLikeType() )
   1.329  	{
   1.330  		unselect();
   1.331  		saveStateRemovingPart (selbi, QString ("Delete %1").arg(getObjectName(selbi)));
   1.332  
   1.333 -		emit (layoutAboutToBeChanged() );
   1.334 -
   1.335 -		int n=selbi->childNum();
   1.336 -		beginRemoveRows (parentIndex,n,n);
   1.337 -		removeRows (n,1,parentIndex);
   1.338 -		endRemoveRows();
   1.339 -		select (pi);
   1.340 -		emitShowSelection();
   1.341 -		reposition();
   1.342 -
   1.343 -		emit (layoutChanged() );
   1.344 +		TreeItem *pi=deleteItem (selbi);
   1.345 +		if (pi)
   1.346 +		{
   1.347 +			select (pi);
   1.348 +			emitShowSelection();
   1.349 +		}
   1.350  		return;
   1.351  	}
   1.352 -	//FloatImageObj *fio=selection.getFloatImage(); 	//FIXME-1 VM still missing
   1.353 -
   1.354 -/*
   1.355 -	if (fio)
   1.356 +	ImageItem *ii=getSelectedImageItem();
   1.357 +	if (ii)
   1.358  	{
   1.359 -		BranchObj* par=(BranchObj*)fio->getParObj();
   1.360 +		BranchItem *pi=(BranchItem*)(ii->parent());
   1.361  		saveStateChangingPart(
   1.362 -			par, 
   1.363 -			fio,
   1.364 +			pi, 
   1.365 +			ii,
   1.366  			"delete ()",
   1.367 -			QString("Delete %1").arg(getObjectName(fio))
   1.368 +			QString("Delete %1").arg(getObjectName(ii))
   1.369  		);
   1.370  		unselect();
   1.371 -		par->removeFloatImage(fio);
   1.372 -		select (par);
   1.373 +		deleteItem (ii);
   1.374 +		select (pi);
   1.375  		reposition();
   1.376  		emitShowSelection();
   1.377  		return;
   1.378  	}
   1.379 -	*/
   1.380  }
   1.381  
   1.382 -void VymModel::deleteKeepChildren()	
   1.383 +void VymModel::deleteKeepChildren()	//FIXME-2 does not work yet for mapcenters
   1.384  
   1.385  {
   1.386  	BranchItem *selbi=getSelectedBranchItem();
   1.387 @@ -2275,7 +2252,15 @@
   1.388  
   1.389  		QString sel=getSelectString(selbi);
   1.390  		unselect();
   1.391 -		//FIXME-0 missing in VM pi->removeBranchHere(selbi);
   1.392 +		int pos=selbi->num();
   1.393 +		BranchItem *bi=selbi->getFirstBranch();
   1.394 +		while (bi)
   1.395 +		{
   1.396 +			relinkBranch (bi,pi,pos);
   1.397 +			bi=selbi->getFirstBranch();
   1.398 +			pos++;
   1.399 +		}
   1.400 +		deleteItem (selbi);
   1.401  		reposition();
   1.402  		select (sel);
   1.403  		BranchObj *bo=getSelectedBranchObj();
   1.404 @@ -2311,6 +2296,27 @@
   1.405  	}	
   1.406  }
   1.407  
   1.408 +TreeItem* VymModel::deleteItem (TreeItem *ti)
   1.409 +{
   1.410 +	if (ti)
   1.411 +	{
   1.412 +		TreeItem *pi=ti->parent();
   1.413 +		QModelIndex parentIndex=index(pi);
   1.414 +
   1.415 +		emit (layoutAboutToBeChanged() );
   1.416 +
   1.417 +		int n=ti->childNum();
   1.418 +		beginRemoveRows (parentIndex,n,n);
   1.419 +		removeRows (n,1,parentIndex);
   1.420 +		endRemoveRows();
   1.421 +		reposition();
   1.422 +
   1.423 +		emit (layoutChanged() );
   1.424 +		if (pi->depth()>0) return pi;
   1.425 +	}	
   1.426 +	return NULL;
   1.427 +}
   1.428 +
   1.429  bool VymModel::scrollBranch(BranchItem *bi)
   1.430  {
   1.431  	if (bi)	
   1.432 @@ -2430,7 +2436,7 @@
   1.433  	}
   1.434  }
   1.435  
   1.436 -void VymModel::addFloatImage (const QPixmap &img) //FIXME-2
   1.437 +void VymModel::addFloatImage (const QPixmap &img) //FIXME-0
   1.438  {
   1.439  /*
   1.440  	BranchObj *bo=getSelectedBranch();
   1.441 @@ -3010,7 +3016,7 @@
   1.442  			if (ok) importDirInt(s);
   1.443  		}	
   1.444  	/////////////////////////////////////////////////////////////////////
   1.445 -	} else /* FIXME-2 if (com=="linkTo")
   1.446 +	} else if (com=="relinkTo")
   1.447  	{
   1.448  		if (!selti)
   1.449  		{
   1.450 @@ -3023,21 +3029,21 @@
   1.451  				// 1	num in parent (for branches)
   1.452  				// 2,3	x,y of mainbranch or mapcenter
   1.453  				s=parser.parString(ok,0);
   1.454 -				LinkableMapObj *dst=findObjBySelect (s);
   1.455 +				TreeItem *dst=findBySelectString (s);
   1.456  				if (dst)
   1.457  				{	
   1.458 -					if (typid(*dst) == typid(BranchObj) ) 
   1.459 +					if (dst->getType()==TreeItem::Branch) 
   1.460  					{
   1.461  						// Get number in parent
   1.462  						n=parser.parInt (ok,1);
   1.463  						if (ok)
   1.464  						{
   1.465 -							selb->linkTo ((BranchObj*)(dst),n);
   1.466 +							relinkBranch (selbi,(BranchItem*)dst,n);
   1.467  							emitSelectionChanged();
   1.468  						}	
   1.469 -					} else if (typid(*dst) == typid(MapCenterObj) ) 
   1.470 +					} else if (dst->getType()==TreeItem::MapCenter) 
   1.471  					{
   1.472 -						selb->linkTo ((BranchObj*)(dst),-1);
   1.473 +						relinkBranch (selbi,(BranchItem*)dst);
   1.474  						// Get coordinates of mainbranch
   1.475  						x=parser.parDouble(ok,2);
   1.476  						if (ok)
   1.477 @@ -3045,32 +3051,33 @@
   1.478  							y=parser.parDouble(ok,3);
   1.479  							if (ok) 
   1.480  							{
   1.481 -								selbi->move (x,y);
   1.482 +								if (selbi->getLMO()) selbi->getLMO()->move (x,y);
   1.483  								emitSelectionChanged();
   1.484  							}
   1.485  						}
   1.486  					}	
   1.487  				}	
   1.488  			}	
   1.489 -		} else if ( selectionType() == TreeItem::Image) 
   1.490 +		} else if ( selti->getType() == TreeItem::Image) 
   1.491  		{
   1.492  			if (parser.checkParCount(1))
   1.493  			{
   1.494  				// 0	selectstring of parent
   1.495  				s=parser.parString(ok,0);
   1.496 -				LinkableMapObj *dst=findObjBySelect (s);
   1.497 +				TreeItem *dst=findBySelectString (s);
   1.498  				if (dst)
   1.499  				{	
   1.500 -					if (typid(*dst) == typid(BranchObj) ||
   1.501 -						typid(*dst) == typid(MapCenterObj)) 
   1.502 +					/* FIXME-0 relink img
   1.503 +					if (dst->isBranchLikeType())
   1.504  						linkFloatImageTo (getSelectString(dst));
   1.505 +					*/	
   1.506  				} else	
   1.507  					parser.setError (Aborted,"Destination is not a branch");
   1.508  			}		
   1.509  		} else
   1.510  			parser.setError (Aborted,"Type of selection is not a floatimage or branch");
   1.511  	/////////////////////////////////////////////////////////////////////
   1.512 -	} else */ if (com=="loadImage")
   1.513 +	} else if (com=="loadImage")
   1.514  	{
   1.515  		if (!selti)
   1.516  		{
   1.517 @@ -3235,18 +3242,17 @@
   1.518  	/////////////////////////////////////////////////////////////////////
   1.519  	} else if (com=="saveImage")
   1.520  	{
   1.521 -		//FIXME-2 FloatImageObj *fio=selection.getFloatImage();
   1.522 -		FloatImageObj* fio=NULL;
   1.523 -		if (!fio)
   1.524 +		ImageItem *ii=getSelectedImageItem();
   1.525 +		if (!ii )
   1.526  		{
   1.527 -			parser.setError (Aborted,"Type of selection is not an image");
   1.528 +			parser.setError (Aborted,"No image selected");
   1.529  		} else if (parser.checkParCount(2))
   1.530  		{
   1.531  			s=parser.parString(ok,0);
   1.532  			if (ok)
   1.533  			{
   1.534  				t=parser.parString(ok,1);
   1.535 -				if (ok) saveFloatImageInt (fio,t,s);
   1.536 +				if (ok) saveFloatImageInt (ii,t,s);
   1.537  			}
   1.538  		}	
   1.539  	/////////////////////////////////////////////////////////////////////
   1.540 @@ -4553,10 +4559,7 @@
   1.541  
   1.542  bool VymModel::select ()
   1.543  {
   1.544 -	QModelIndex index=selModel->selectedIndexes().first();	// TODO no multiselections yet
   1.545 -
   1.546 -	TreeItem *item = getItem (index);
   1.547 -	return select (item->getLMO() );
   1.548 +	return select (selModel->selectedIndexes().first());	// TODO no multiselections yet
   1.549  }
   1.550  
   1.551  bool VymModel::select (const QString &s)
   1.552 @@ -4924,7 +4927,7 @@
   1.553  		TreeItem::Type type=ti->getType();
   1.554  		if (type ==TreeItem::Branch || type==TreeItem::MapCenter || type==TreeItem::Image)
   1.555  		{
   1.556 -			return ti->getLMO();
   1.557 +			return ((MapItem*)ti)->getLMO();
   1.558  		}	
   1.559  	}
   1.560  	return NULL;
   1.561 @@ -4934,7 +4937,7 @@
   1.562  {
   1.563  	TreeItem *ti = getSelectedBranchItem();
   1.564  	if (ti)
   1.565 -		return (BranchObj*)ti->getLMO();
   1.566 +		return (BranchObj*)((MapItem*)ti)->getLMO();
   1.567  	else	
   1.568  		return NULL;
   1.569  }
   1.570 @@ -4970,9 +4973,15 @@
   1.571  		return list.first();
   1.572  }
   1.573  
   1.574 -FloatImageObj* VymModel::getSelectedFloatImage()
   1.575 -{
   1.576 -	//FIXME-2 return selection.getFloatImage();	
   1.577 +ImageItem* VymModel::getSelectedImageItem()
   1.578 +{
   1.579 +	QModelIndexList list=selModel->selectedIndexes();
   1.580 +	if (!list.isEmpty())
   1.581 +	{
   1.582 +		TreeItem *ti=getItem (list.first());
   1.583 +		if (ti && ti->getType()==TreeItem::Image)
   1.584 +			return (ImageItem*)ti;
   1.585 +	}
   1.586  	return NULL;
   1.587  }
   1.588  
   1.589 @@ -4991,8 +5000,7 @@
   1.590  {
   1.591  	QString s;
   1.592  	if (!ti) return s;
   1.593 -	if (ti->getType() == TreeItem::Branch ||
   1.594 -	    ti->getType() == TreeItem::MapCenter)
   1.595 +	if (ti->isBranchLikeType())
   1.596  	{	
   1.597  		TreeItem *par=ti->parent();
   1.598  		if (par)