diff -r 717b20c56358 -r c6a8651e6bbc selection.cpp --- a/selection.cpp Wed Mar 21 11:51:38 2007 +0000 +++ b/selection.cpp Sat Mar 31 09:28:27 2007 +0000 @@ -1,17 +1,26 @@ #include "selection.h" +#include "mainwindow.h" +#include "mapeditor.h" + + + +extern Main *mainWindow; Selection::Selection() { + color= QColor(255,255,0); } Selection::~Selection() { } -void Selection::setMapCenter(MapCenterObj *mco) +void Selection::setMapEditor (MapEditor *me) { - mapCenter=mco; + mapEditor=me; + mapCenter=me->getMapCenter(); + scene=mapCenter->getScene(); } void Selection::copy(const Selection &other) @@ -27,11 +36,44 @@ lastSelectList.clear(); } +void Selection::update() +{ + QRectF bbox; + int w=0; + for (int i=0; i< selectList.count(); ++i) + { + bbox=selectList.at(i)->getBBox(); + selboxList.at(i)->setRect ( + bbox.x()-w,bbox.y()-w, + bbox.width()+2*w, bbox.height()+2*w); + selboxList.at(i)->setPen (color); + selboxList.at(i)->setBrush (color); + } +} + +void Selection::setColor (QColor col) +{ + color=col; + update(); +} + +QColor Selection::getColor () +{ + return color; +} + bool Selection::select(LinkableMapObj *lmo) // TODO no multiselections yet { if (!selectList.isEmpty()) unselect(); selectList.append (lmo); + QGraphicsRectItem *sb = scene->addRect( + QRectF(0,0,0,0), + QPen(color), + color); + sb->setZValue(Z_SELBOX); + selboxList.append (sb); lmo->select(); + mainWindow->updateSatellites (mapEditor); // update branchPropWindow... return true; } @@ -69,6 +111,9 @@ selectList.at(i)->unselect(); lastSelectList=selectList; selectList.clear(); + while (!selboxList.isEmpty() ) + delete selboxList.takeFirst(); + } }