1.1 --- a/selection.cpp Tue Jan 23 11:50:53 2007 +0000
1.2 +++ b/selection.cpp Tue Mar 06 19:37:39 2007 +0000
1.3 @@ -23,15 +23,16 @@
1.4
1.5 void Selection::clear()
1.6 {
1.7 - selectList.clear();
1.8 + unselect();
1.9 lastSelectList.clear();
1.10 }
1.11
1.12 bool Selection::select(LinkableMapObj *lmo) // TODO no multiselections yet
1.13 {
1.14 - clear();
1.15 + if (!selectList.isEmpty()) unselect();
1.16 selectList.append (lmo);
1.17 - return false;
1.18 + lmo->select();
1.19 + return true;
1.20 }
1.21
1.22 bool Selection::select (const QString &s) // TODO no multiselections yet
1.23 @@ -41,7 +42,7 @@
1.24 // Finally select the found object
1.25 if (lmo)
1.26 {
1.27 - clear();
1.28 + unselect();
1.29 select (lmo);
1.30 return true;
1.31 }
1.32 @@ -62,8 +63,13 @@
1.33
1.34 void Selection::unselect()
1.35 {
1.36 - lastSelectList=selectList;
1.37 - selectList.clear();
1.38 + if (!selectList.isEmpty() )
1.39 + {
1.40 + for (int i=0; i< selectList.count(); ++i)
1.41 + selectList.at(i)->unselect();
1.42 + lastSelectList=selectList;
1.43 + selectList.clear();
1.44 + }
1.45 }
1.46
1.47 bool Selection::isEmpty()
1.48 @@ -88,6 +94,45 @@
1.49 return Undefined;
1.50 }
1.51
1.52 +LinkableMapObj* Selection::first()
1.53 +{
1.54 + if (!selectList.isEmpty())
1.55 + return selectList.first();
1.56 + else
1.57 + return NULL;
1.58 +}
1.59 +
1.60 +LinkableMapObj* Selection::single()
1.61 +{
1.62 + if (selectList.count() == 1)
1.63 + return selectList.first();
1.64 + else
1.65 + return NULL;
1.66 +}
1.67 +
1.68 +BranchObj* Selection::getBranch()
1.69 +{
1.70 + if (!selectList.isEmpty())
1.71 + {
1.72 + LinkableMapObj *sel=selectList.first();
1.73 + if (typeid (*sel)==typeid (BranchObj) ||
1.74 + typeid (*sel)==typeid (MapCenterObj))
1.75 + return (BranchObj*)sel;
1.76 + }
1.77 + return NULL;
1.78 +}
1.79 +
1.80 +FloatImageObj* Selection::getFloatImage()
1.81 +{
1.82 + if (!selectList.isEmpty())
1.83 + {
1.84 + LinkableMapObj *sel=selectList.first();
1.85 + if (typeid (*sel)==typeid (FloatImageObj))
1.86 + return (FloatImageObj*)sel;
1.87 + }
1.88 + return NULL;
1.89 +}
1.90 +
1.91 QString Selection::getSelectString()// TODO no multiselections yet
1.92 {
1.93 if (selectList.count()==1)