7 #include "mainwindow.h"
12 extern Main *mainWindow;
14 Selection::Selection()
20 Selection::~Selection()
24 void Selection::setModel (VymModel *m)
29 void Selection::update() // FIXME-2 VM emit signal in VM instead and get rid of this
34 for (int i=0; i< selectList.count(); ++i)
36 bbox=selectList.at(i)->getBBox();
37 selboxList.at(i)->setRect (
38 bbox.x()-w,bbox.y()-w,
39 bbox.width()+2*w, bbox.height()+2*w);
40 selboxList.at(i)->setPen (color);
41 selboxList.at(i)->setBrush (color);
45 bool Selection::select(LinkableMapObj *lmo)// FIXME-2 VM emit signal in VM instead and get rid of this
48 return model->select (lmo);
50 if (!selectList.isEmpty()) unselect();
51 selectList.append (lmo);
54 mainWindow->updateSatellites (model);
55 cout << "Sel::select lmo e\n";
60 bool Selection::select (const QString &s)// FIXME-2 VM emit signal in VM instead and get rid of this
63 return model->select (s);
65 cout << "Sel::select s=\n";
66 LinkableMapObj *lmo=model->findObjBySelect(s);
68 // Finally select the found object
79 bool Selection::reselect () // TODO no multiselections yet
81 if (!lastSelectList.isEmpty())
83 select (lastSelectList.first());
90 void Selection::unselect()
95 bool Selection::isBlocked()
100 void Selection::block()
105 void Selection::unblock()
110 bool Selection::isEmpty()
112 return selectList.isEmpty();
116 uint Selection::count()
118 return selectList.count();
123 Selection::Type Selection::type() // TODO no multiselections yet
125 if (!selectList.isEmpty())
127 LinkableMapObj *sel=selectList.first();
128 if (typeid (*sel)==typeid (BranchObj)) return Branch;
129 if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
130 if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
137 LinkableMapObj* Selection::first()
139 if (!selectList.isEmpty())
140 return selectList.first();
145 LinkableMapObj* Selection::single()
147 if (selectList.count() == 1)
148 return selectList.first();
153 TreeItem* Selection::getBranchItem()
155 BranchObj* bo=getBranch();
156 if (bo) return bo->getTreeItem(); // VM get directly from treemodl
160 QModelIndex Selection::getBranchIndex()
162 return model->getSelectionModel()->selectedIndexes().first(); // TODO no multiselections yet
167 FloatImageObj* Selection::getFloatImage()
169 if (!selectList.isEmpty())
171 LinkableMapObj *sel=selectList.first();
172 if (typeid (*sel)==typeid (FloatImageObj))
173 return (FloatImageObj*)sel;
178 QString Selection::getSelectString() // FIXME-2 VM this is also in VM ?! clean up here...
179 // TODO no multiselections yet
181 if (selectList.count()==1)
183 return model->getSelectString (selectList.first() );