selection.cpp
changeset 421 5522d1da7e37
parent 16 41c3d7f9f532
child 424 d886c77ac0fe
     1.1 --- a/selection.cpp	Wed Jan 10 13:26:12 2007 +0000
     1.2 +++ b/selection.cpp	Tue Jan 23 11:50:53 2007 +0000
     1.3 @@ -18,21 +18,23 @@
     1.4  {
     1.5  	mapCenter=other.mapCenter;
     1.6  	selectList=other.selectList;
     1.7 +	lastSelectList=other.lastSelectList;
     1.8  }
     1.9  
    1.10  void Selection::clear()
    1.11  {
    1.12  	selectList.clear();
    1.13 +	lastSelectList.clear();
    1.14  }
    1.15  
    1.16 -bool Selection::select(LinkableMapObj *lmo)
    1.17 +bool Selection::select(LinkableMapObj *lmo)	// TODO no multiselections yet
    1.18  {
    1.19  	clear();
    1.20  	selectList.append (lmo);
    1.21  	return false;
    1.22  }
    1.23  
    1.24 -bool Selection::select (const QString &s)
    1.25 +bool Selection::select (const QString &s)	// TODO no multiselections yet
    1.26  {
    1.27  	LinkableMapObj *lmo=mapCenter->findObjBySelect(s);
    1.28  
    1.29 @@ -47,9 +49,21 @@
    1.30  
    1.31  }
    1.32  
    1.33 +bool Selection::reselect ()	// TODO no multiselections yet
    1.34 +{
    1.35 +	if (!lastSelectList.isEmpty())
    1.36 +	{
    1.37 +		select (lastSelectList.first());
    1.38 +		return true;
    1.39 +	}
    1.40 +	return false;
    1.41 +
    1.42 +}
    1.43 +
    1.44  void Selection::unselect()
    1.45  {
    1.46 -	clear();
    1.47 +	lastSelectList=selectList;
    1.48 +	selectList.clear();
    1.49  }
    1.50  
    1.51  bool Selection::isEmpty()
    1.52 @@ -62,9 +76,20 @@
    1.53  	return selectList.count();
    1.54  }
    1.55  
    1.56 -QString Selection::getSelectString()
    1.57 +SelectionType Selection::type() // TODO no multiselections yet
    1.58  {
    1.59 -	// TODO multiselection (maybe separated by ";")
    1.60 +	if (!selectList.isEmpty())
    1.61 +	{
    1.62 +		LinkableMapObj *sel=selectList.first();
    1.63 +		if (typeid (*sel)==typeid (BranchObj)) return Branch;
    1.64 +		if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
    1.65 +		if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
    1.66 +	}
    1.67 +	return Undefined;
    1.68 +}
    1.69 +
    1.70 +QString Selection::getSelectString()// TODO no multiselections yet
    1.71 +{
    1.72  	if (selectList.count()==1)
    1.73  		return selectList.first()->getSelectString();
    1.74  	else