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 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) // TODO no multiselections yet
47 return model->select (lmo);
49 if (!selectList.isEmpty()) unselect();
50 selectList.append (lmo);
53 mainWindow->updateSatellites (model);
54 cout << "Sel::select lmo e\n";
59 bool Selection::select (const QString &s) // TODO no multiselections yet
61 return model->select (s);
63 cout << "Sel::select s=\n";
64 LinkableMapObj *lmo=model->findObjBySelect(s);
66 // Finally select the found object
77 bool Selection::reselect () // TODO no multiselections yet
79 if (!lastSelectList.isEmpty())
81 select (lastSelectList.first());
88 void Selection::unselect()
92 cout << "Sel::unselect\n";
93 if (!selectList.isEmpty() )
95 for (int i=0; i< selectList.count(); ++i)
96 selectList.at(i)->unselect();
97 lastSelectList=selectList;
99 // FIXME VM move to ME
100 //while (!selboxList.isEmpty() )
101 // delete selboxList.takeFirst();
106 bool Selection::isBlocked()
111 void Selection::block()
116 void Selection::unblock()
121 bool Selection::isEmpty()
123 return selectList.isEmpty();
127 uint Selection::count()
129 return selectList.count();
134 Selection::Type Selection::type() // TODO no multiselections yet
136 if (!selectList.isEmpty())
138 LinkableMapObj *sel=selectList.first();
139 if (typeid (*sel)==typeid (BranchObj)) return Branch;
140 if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
141 if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
148 LinkableMapObj* Selection::first()
150 if (!selectList.isEmpty())
151 return selectList.first();
156 LinkableMapObj* Selection::single()
158 if (selectList.count() == 1)
159 return selectList.first();
164 TreeItem* Selection::getBranchItem()
166 BranchObj* bo=getBranch();
167 if (bo) return bo->getTreeItem(); // FIXME VM get directly from treemodl
171 QModelIndex Selection::getBranchIndex()
173 return model->getSelectionModel()->selectedIndexes().first(); // TODO no multiselections yet
178 FloatImageObj* Selection::getFloatImage()
180 if (!selectList.isEmpty())
182 LinkableMapObj *sel=selectList.first();
183 if (typeid (*sel)==typeid (FloatImageObj))
184 return (FloatImageObj*)sel;
189 QString Selection::getSelectString() // FIXME VM this is also in VM ?! clean up here...
190 // TODO no multiselections yet
192 if (selectList.count()==1)
194 return model->getSelectString (selectList.first() );