5 #include "mainwindow.h"
11 extern Main *mainWindow;
13 Selection::Selection()
15 color= QColor(255,255,0);
19 Selection::~Selection()
23 void Selection::setModel (VymModel *m)
26 scene=model->getScene();
29 void Selection::copy(const Selection &other)
31 selectList=other.selectList;
32 lastSelectList=other.lastSelectList;
35 void Selection::clear()
38 lastSelectList.clear();
41 void Selection::update() // FIXME this needs to be adapted to several views
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 void Selection::setColor (QColor col)
62 QColor Selection::getColor ()
67 bool Selection::select(LinkableMapObj *lmo) // TODO no multiselections yet
69 if (!selectList.isEmpty()) unselect();
70 selectList.append (lmo);
71 QGraphicsRectItem *sb = scene->addRect(
75 sb->setZValue(Z_SELBOX);
77 selboxList.append (sb);
80 mainWindow->updateSatellites (model);
84 bool Selection::select (const QString &s) // TODO no multiselections yet
86 LinkableMapObj *lmo=model->findObjBySelect(s);
88 // Finally select the found object
99 bool Selection::reselect () // TODO no multiselections yet
101 if (!lastSelectList.isEmpty())
103 select (lastSelectList.first());
110 void Selection::unselect()
112 if (!selectList.isEmpty() )
114 for (int i=0; i< selectList.count(); ++i)
115 selectList.at(i)->unselect();
116 lastSelectList=selectList;
118 while (!selboxList.isEmpty() )
119 delete selboxList.takeFirst();
124 bool Selection::isBlocked()
129 void Selection::block()
134 void Selection::unblock()
139 bool Selection::isEmpty()
141 return selectList.isEmpty();
144 uint Selection::count()
146 return selectList.count();
149 Selection::Type Selection::type() // TODO no multiselections yet
151 if (!selectList.isEmpty())
153 LinkableMapObj *sel=selectList.first();
154 if (typeid (*sel)==typeid (BranchObj)) return Branch;
155 if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
156 if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
161 LinkableMapObj* Selection::first()
163 if (!selectList.isEmpty())
164 return selectList.first();
169 LinkableMapObj* Selection::single()
171 if (selectList.count() == 1)
172 return selectList.first();
177 BranchObj* Selection::getBranch()
179 if (!selectList.isEmpty())
181 LinkableMapObj *sel=selectList.first();
182 if (typeid (*sel)==typeid (BranchObj) ||
183 typeid (*sel)==typeid (MapCenterObj))
184 return (BranchObj*)sel;
189 FloatImageObj* Selection::getFloatImage()
191 if (!selectList.isEmpty())
193 LinkableMapObj *sel=selectList.first();
194 if (typeid (*sel)==typeid (FloatImageObj))
195 return (FloatImageObj*)sel;
200 QString Selection::getSelectString()// TODO no multiselections yet
202 if (selectList.count()==1)
204 return model->getSelectString (selectList.first() );