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) // 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()
93 bool Selection::isBlocked()
98 void Selection::block()
103 void Selection::unblock()
108 bool Selection::isEmpty()
110 return selectList.isEmpty();
114 uint Selection::count()
116 return selectList.count();
121 Selection::Type Selection::type() // TODO no multiselections yet
123 if (!selectList.isEmpty())
125 LinkableMapObj *sel=selectList.first();
126 if (typeid (*sel)==typeid (BranchObj)) return Branch;
127 if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
128 if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
135 LinkableMapObj* Selection::first()
137 if (!selectList.isEmpty())
138 return selectList.first();
143 LinkableMapObj* Selection::single()
145 if (selectList.count() == 1)
146 return selectList.first();
151 TreeItem* Selection::getBranchItem()
153 BranchObj* bo=getBranch();
154 if (bo) return bo->getTreeItem(); // VM get directly from treemodl
158 QModelIndex Selection::getBranchIndex()
160 return model->getSelectionModel()->selectedIndexes().first(); // TODO no multiselections yet
165 FloatImageObj* Selection::getFloatImage()
167 if (!selectList.isEmpty())
169 LinkableMapObj *sel=selectList.first();
170 if (typeid (*sel)==typeid (FloatImageObj))
171 return (FloatImageObj*)sel;
176 QString Selection::getSelectString() // FIXME-2 VM this is also in VM ?! clean up here...
177 // TODO no multiselections yet
179 if (selectList.count()==1)
181 return model->getSelectString (selectList.first() );