deleting works - partially.
5 #include "mainwindow.h"
10 extern Main *mainWindow;
12 Selection::Selection()
17 Selection::~Selection()
21 void Selection::setModel (VymModel *m)
26 void Selection::copy(const Selection &other)
28 selectList=other.selectList;
29 lastSelectList=other.lastSelectList;
32 void Selection::clear()
35 lastSelectList.clear();
39 void Selection::update() // FIXME VM emit signal in VM instead
44 for (int i=0; i< selectList.count(); ++i)
46 bbox=selectList.at(i)->getBBox();
47 selboxList.at(i)->setRect (
48 bbox.x()-w,bbox.y()-w,
49 bbox.width()+2*w, bbox.height()+2*w);
50 selboxList.at(i)->setPen (color);
51 selboxList.at(i)->setBrush (color);
55 bool Selection::select(LinkableMapObj *lmo) // TODO no multiselections yet
57 if (!selectList.isEmpty()) unselect();
58 selectList.append (lmo);
59 /* FIXME VM move to ME
60 QGraphicsRectItem *sb = scene->addRect(
64 sb->setZValue(Z_SELBOX);
66 selboxList.append (sb);
70 mainWindow->updateSatellites (model);
74 bool Selection::select (const QString &s) // TODO no multiselections yet
76 LinkableMapObj *lmo=model->findObjBySelect(s);
78 // Finally select the found object
89 bool Selection::reselect () // TODO no multiselections yet
91 if (!lastSelectList.isEmpty())
93 select (lastSelectList.first());
100 void Selection::unselect()
102 if (!selectList.isEmpty() )
104 for (int i=0; i< selectList.count(); ++i)
105 selectList.at(i)->unselect();
106 lastSelectList=selectList;
108 /* FIXME VM move to ME
109 while (!selboxList.isEmpty() )
110 delete selboxList.takeFirst();
116 bool Selection::isBlocked()
121 void Selection::block()
126 void Selection::unblock()
131 bool Selection::isEmpty()
133 return selectList.isEmpty();
136 uint Selection::count()
138 return selectList.count();
141 Selection::Type Selection::type() // TODO no multiselections yet
143 if (!selectList.isEmpty())
145 LinkableMapObj *sel=selectList.first();
146 if (typeid (*sel)==typeid (BranchObj)) return Branch;
147 if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
148 if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
153 LinkableMapObj* Selection::first()
155 if (!selectList.isEmpty())
156 return selectList.first();
161 LinkableMapObj* Selection::single()
163 if (selectList.count() == 1)
164 return selectList.first();
169 BranchObj* Selection::getBranch()
171 if (!selectList.isEmpty())
173 LinkableMapObj *sel=selectList.first();
174 if (typeid (*sel)==typeid (BranchObj) ||
175 typeid (*sel)==typeid (MapCenterObj))
176 return (BranchObj*)sel;
181 TreeItem* Selection::getBranchItem()
183 BranchObj* bo=getBranch();
184 if (bo) return bo->getTreeItem(); // FIXME VM get directly from treemodl
188 QModelIndex Selection::getBranchIndex()
190 return model->getSelectionModel()->selectedIndexes().first(); // TODO no multiselections yet
194 FloatImageObj* Selection::getFloatImage()
196 if (!selectList.isEmpty())
198 LinkableMapObj *sel=selectList.first();
199 if (typeid (*sel)==typeid (FloatImageObj))
200 return (FloatImageObj*)sel;
205 QString Selection::getSelectString() // FIXME VM this is also in VM ?! clean up here...
206 // TODO no multiselections yet
208 if (selectList.count()==1)
210 return model->getSelectString (selectList.first() );