diff -r 96402b172173 -r a8a98a94899a mapeditor.cpp --- a/mapeditor.cpp Wed Oct 29 17:42:34 2008 +0000 +++ b/mapeditor.cpp Tue Nov 04 12:09:10 2008 +0000 @@ -43,7 +43,7 @@ model=vm; model->setScene (mapScene); model->registerEditor(this); - model->addMapCenter(); // FIXME create this in MapEditor until BO and MCO are independent of scene +// model->addMapCenter(); // FIXME create this in MapEditor until BO and MCO are independent of scene model->makeDefault(); // No changes in model so far setScene (mapScene); @@ -82,15 +82,18 @@ QAction *a = new QAction( tr( "Edit heading","MapEditor" ), this); a->setShortcut ( Qt::Key_Return ); //Edit heading - //a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); a = new QAction( tr( "Edit heading","MapEditor" ), this); a->setShortcut ( Qt::Key_Enter); //Edit heading - //a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); + // Selections + selModel=vm->getSelectionModel(); + selectionColor =QColor (255,255,0); + + // Attributes //FIXME testing only... QString k; AttributeDef *ad; @@ -273,12 +276,6 @@ } } -void MapEditor::updateSelection() -{ - // Tell selection to update geometries - model->updateSelection(); -} - AttributeTable* MapEditor::attributeTable() { return attrTable; @@ -1041,26 +1038,71 @@ event->acceptProposedAction(); } +void MapEditor::updateSelection(const QItemSelection &newsel,const QItemSelection &) +{ + cout << "ME::updateSelection\n"; + QGraphicsRectItem *sb; -bool isUnicode16(const QByteArray &d) -{ - // TODO: make more precise check for unicode 16. - // Guess unicode16 if any of second bytes are zero - unsigned int length = max(0,d.size()-2)/2; - for (unsigned int i = 0; iaddRect( + QRectF(0,0,0,0), + QPen(selectionColor), + selectionColor); + sb->setZValue(Z_SELBOX); + sb->show(); + selboxList.append (sb); + } else + sb=selboxList.first(); + + QModelIndex index=newsel.indexes().first(); // TODO no multiselections yet + + TreeItem *item = static_cast(index.internalPointer()); + LinkableMapObj *lmo=item->getLMO(); + + int w=0; // FIXME what for? + if (lmo) + { + QRectF bbox=lmo->getBBox(); + selboxList.first()->setRect ( + bbox.x()-w,bbox.y()-w, + bbox.width()+2*w, bbox.height()+2*w); + selboxList.first()->setPen (selectionColor); + selboxList.first()->setBrush (selectionColor); + } + + + } -QItemSelectionModel* MapEditor::selectionModel () +void MapEditor::updateSelectionGeometry() // FIXME VM only called from VM::animate... { - return selModel; + cout << "ME::updateSelectionGeometry\n"; + + // Tell selection to update geometries + model->updateSelection(); } + +void MapEditor::setSelectionColor (QColor col) +{ + selectionColor=col; + updateSelectionGeometry(); +} + +QColor MapEditor::getSelectionColor () +{ + return selectionColor; +} + +