5 #include "mainwindow.h"
10 extern Main *mainWindow;
12 Selection::Selection()
17 Selection::~Selection()
21 void Selection::setModel (VymModel *m)
24 selModel=model->getSelectionModel();
27 void Selection::copy(const Selection &other)
29 selectList=other.selectList;
30 lastSelectList=other.lastSelectList;
33 void Selection::clear()
36 lastSelectList.clear();
40 void Selection::update() // FIXME VM emit signal in VM instead
45 for (int i=0; i< selectList.count(); ++i)
47 bbox=selectList.at(i)->getBBox();
48 selboxList.at(i)->setRect (
49 bbox.x()-w,bbox.y()-w,
50 bbox.width()+2*w, bbox.height()+2*w);
51 selboxList.at(i)->setPen (color);
52 selboxList.at(i)->setBrush (color);
56 bool Selection::select(LinkableMapObj *lmo) // TODO no multiselections yet
58 if (!selectList.isEmpty()) unselect();
59 selectList.append (lmo);
60 /* FIXME VM move to ME
61 QGraphicsRectItem *sb = scene->addRect(
65 sb->setZValue(Z_SELBOX);
67 selboxList.append (sb);
71 mainWindow->updateSatellites (model);
75 bool Selection::select (const QString &s) // TODO no multiselections yet
77 LinkableMapObj *lmo=model->findObjBySelect(s);
79 // Finally select the found object
90 bool Selection::reselect () // TODO no multiselections yet
92 if (!lastSelectList.isEmpty())
94 select (lastSelectList.first());
101 void Selection::unselect()
103 if (!selectList.isEmpty() )
105 for (int i=0; i< selectList.count(); ++i)
106 selectList.at(i)->unselect();
107 lastSelectList=selectList;
109 /* FIXME VM move to ME
110 while (!selboxList.isEmpty() )
111 delete selboxList.takeFirst();
117 bool Selection::isBlocked()
122 void Selection::block()
127 void Selection::unblock()
132 bool Selection::isEmpty()
134 return selectList.isEmpty();
137 uint Selection::count()
139 return selectList.count();
142 Selection::Type Selection::type() // TODO no multiselections yet
144 if (!selectList.isEmpty())
146 LinkableMapObj *sel=selectList.first();
147 if (typeid (*sel)==typeid (BranchObj)) return Branch;
148 if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
149 if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
154 LinkableMapObj* Selection::first()
156 if (!selectList.isEmpty())
157 return selectList.first();
162 LinkableMapObj* Selection::single()
164 if (selectList.count() == 1)
165 return selectList.first();
170 BranchObj* Selection::getBranch()
172 if (!selectList.isEmpty())
174 LinkableMapObj *sel=selectList.first();
175 if (typeid (*sel)==typeid (BranchObj) ||
176 typeid (*sel)==typeid (MapCenterObj))
177 return (BranchObj*)sel;
182 TreeItem* Selection::getBranchItem()
184 BranchObj* bo=getBranch();
185 if (bo) return bo->getTreeItem(); // FIXME VM get directly from treemodl
189 QModelIndex Selection::getBranchIndex()
191 return selModel->selectedIndexes().first(); // TODO no multiselections yet
195 FloatImageObj* Selection::getFloatImage()
197 if (!selectList.isEmpty())
199 LinkableMapObj *sel=selectList.first();
200 if (typeid (*sel)==typeid (FloatImageObj))
201 return (FloatImageObj*)sel;
206 QString Selection::getSelectString() // FIXME VM this is also in VM ?! clean up here...
207 // TODO no multiselections yet
209 if (selectList.count()==1)
211 return model->getSelectString (selectList.first() );