diff -r 658ad3bc0c8a -r dfbc371b7280 mapeditor.cpp --- a/mapeditor.cpp Sat Mar 31 09:28:27 2007 +0000 +++ b/mapeditor.cpp Sat Mar 31 09:28:27 2007 +0000 @@ -97,7 +97,7 @@ editingBO=NULL; movingObj=NULL; - xelection.setMapCenter (mapCenter); + xelection.setMapEditor (this); xelection.unselect(); defXLinkWidth=1; @@ -222,6 +222,7 @@ attribut("comment",mapCenter->getComment()) + attribut("date",mapCenter->getDate()) + attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) + + attribut("selectionColor", xelection.getColor().name() ) + attribut("linkStyle", ls ) + attribut("linkColor", defLinkColor.name() ) + attribut("defXLinkColor", defXLinkColor.name() ) + @@ -890,6 +891,13 @@ b=parser.parBool(ok,0); if (ok) setIncludeImagesVer(b); } + } else if (com=="setSelectionColor") + { + if (parser.checkParamCount(1)) + { + QColor c=parser.parColor (ok,0); + if (ok) setSelectionColorInt (c); + } } else if (com=="setURL") { if (xelection.isEmpty() ) @@ -1147,6 +1155,7 @@ if ( ok ) { mapCenter->reposition(); + xelection.update(); if (lmode==NewMap) { mapDefault=false; @@ -1221,8 +1230,6 @@ printer->setOutputFileName(settings.value("/mainwindow/printerFileName",printer->outputFileName()).toString()); } - // FIXME testing cout << "ME::print printProgram="<printProgram().ascii()<getTotalBBox(); // Try to set orientation automagically @@ -1319,7 +1326,6 @@ { QRectF mapRect=mapCenter->getTotalBBox(); QPixmap pix((int)mapRect.width(),(int)mapRect.height()); - cout << "w.h="<<(int)mapRect.width()<<","<<(int)mapRect.height()<updateHistory (undoSet); updateActions(); + xelection.update(); ensureSelectionVisible(); } @@ -1777,6 +1784,7 @@ QString("Move %1 to %2").arg(getName(sel)).arg(ps)); sel->move(x,y); // FIXME xelection not moved automagically... mapCenter->reposition(); + xelection.update(); } } @@ -1795,6 +1803,7 @@ ((OrnamentedObj*)sel)->move2RelPos (x,y); mapCenter->reposition(); sel->updateLink(); + xelection.update(); } } @@ -1813,6 +1822,7 @@ saveState (bo,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo))); mapCenter->reposition(); scene()->update(); + xelection.update(); ensureSelectionVisible(); } } @@ -1832,6 +1842,7 @@ saveState(bo,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo))); mapCenter->reposition(); scene()->update(); + xelection.update(); ensureSelectionVisible(); } } @@ -1892,6 +1903,7 @@ QString("Set heading of %1 to \"%2\"").arg(getName(sel)).arg(s) ); sel->setHeading(s ); mapCenter->reposition(); + xelection.update(); ensureSelectionVisible(); } } @@ -1904,6 +1916,7 @@ { bo->setURL(s); mapCenter->reposition(); + xelection.update(); ensureSelectionVisible(); } } @@ -1915,6 +1928,7 @@ { bo->setHeading(s); mapCenter->reposition(); + xelection.update(); ensureSelectionVisible(); } } @@ -1927,6 +1941,7 @@ { bo->setVymLink(s); mapCenter->reposition(); + xelection.update(); ensureSelectionVisible(); } } @@ -1988,6 +2003,7 @@ QString ("Add new branch to %1").arg(getName(bo))); mapCenter->reposition(); + xelection.update(); } } return newbo; @@ -2019,6 +2035,7 @@ QString ("Add branch before %1").arg(getName(bo))); mapCenter->reposition(); + xelection.update(); } } return newbo; @@ -2036,7 +2053,8 @@ xelection.select (par); ensureSelectionVisible(); mapCenter->reposition(); - mapScene->update(); + xelection.update(); + xelection.update(); return; } FloatImageObj *fio=xelection.getFloatImage(); @@ -2052,9 +2070,9 @@ xelection.unselect(); par->removeFloatImage(fio); xelection.select (par); + mapCenter->reposition(); + xelection.update(); ensureSelectionVisible(); - mapCenter->reposition(); - mapScene->update(); return; } } @@ -2064,6 +2082,16 @@ return xelection.single(); } +BranchObj* MapEditor::getSelectedBranch() +{ + return xelection.getBranch(); +} + +FloatImageObj* MapEditor::getSelectedFloatImage() +{ + return xelection.getFloatImage(); +} + void MapEditor::unselect() { xelection.unselect(); @@ -2083,6 +2111,7 @@ { xelection.unselect(); xelection.select(lmo); + xelection.update(); ensureSelectionVisible(); return true; } @@ -2097,7 +2126,10 @@ void MapEditor::selectInt (LinkableMapObj *lmo) { if (lmo && xelection.single()!= lmo) + { xelection.select(lmo); + xelection.update(); + } } void MapEditor::selectNextBranchInt() @@ -2311,6 +2343,7 @@ { bo=par->getLastBranch(); xelection.select(bo); + xelection.update(); ensureSelectionVisible(); } } @@ -2323,6 +2356,7 @@ xelection.type() == FloatImage) { xelection.select(par); + xelection.update(); ensureSelectionVisible(); } } else @@ -2333,6 +2367,7 @@ if (bo) { xelection.select(bo); + xelection.update(); ensureSelectionVisible(); } } @@ -2360,6 +2395,7 @@ if (bo) { xelection.select(bo); + xelection.update(); ensureSelectionVisible(); } } @@ -2372,6 +2408,7 @@ xelection.type() == FloatImage) { xelection.select(par); + xelection.update(); ensureSelectionVisible(); } } else @@ -2382,6 +2419,7 @@ if (bo) { xelection.select(bo); + xelection.update(); ensureSelectionVisible(); } } @@ -2401,6 +2439,7 @@ bo2=par->getFirstBranch(); if (bo2) { xelection.select(bo2); + xelection.update(); ensureSelectionVisible(); } } @@ -2418,6 +2457,7 @@ if (bo2) { xelection.select(bo2); + xelection.update(); ensureSelectionVisible(); } } @@ -2444,7 +2484,7 @@ } } -void MapEditor::setMapBackgroundImage (const QString &fn) +void MapEditor::setMapBackgroundImage (const QString &fn) //FIXME missing savestate { QColor oldcol=mapScene->backgroundBrush().color(); /* @@ -2455,7 +2495,6 @@ QString ("setMapBackgroundImage (%1)").arg(col.name()), QString("Set background color of map to %1").arg(col.name())); */ - cout << "Trying to load "<setBackgroundBrush(brush); @@ -2550,6 +2589,7 @@ QString("%1 (\"%2\")").arg(r).arg(f), QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo))); bo->toggleStandardFlag (f,mainWindow->useFlagGroups()); + xelection.update(); } } @@ -2715,6 +2755,7 @@ QFileDialog *fd=new QFileDialog( this,vymName+" - " +tr("Link to another map")); fd->setFilters (filters); fd->setCaption(vymName+" - " +tr("Link to another map")); + fd->setDirectory (lastFileDir); if (! bo->getVymLink().isEmpty() ) fd->selectFile( bo->getVymLink() ); fd->show(); @@ -2722,6 +2763,7 @@ QString fn; if ( fd->exec() == QDialog::Accepted ) { + lastFileDir=QDir (fd->directory().path()); saveState( bo, "setVymLink (\""+bo->getVymLink()+"\")", @@ -2892,8 +2934,22 @@ } } +void MapEditor::ensureSelectionVisible() +{ + LinkableMapObj *lmo=xelection.single(); + if (lmo) ensureVisible (lmo->getBBox() ); + +} + +void MapEditor::updateSelection() +{ + // Tell selection to update geometries + xelection.update(); +} + void MapEditor::updateActions() { + // Tell mainwindow to update states of actions mainWindow->updateActions(); // TODO maybe don't update if blockReposition is set } @@ -3048,7 +3104,36 @@ QString("Set link color to %1").arg(col.name()) ); setMapDefLinkColor( col ); - +} + +void MapEditor::selectMapSelectionColor() +{ + QColor col = QColorDialog::getColor( defLinkColor, this ); + setSelectionColor (col); +} + +void MapEditor::setSelectionColorInt (QColor col) +{ + if ( !col.isValid() ) return; + xelection.setColor (col); +} + +void MapEditor::setSelectionColor(QColor col) +{ + if ( !col.isValid() ) return; + saveState ( + mapCenter, + QString("setSelectionColor (%1)").arg(xelection.getColor().name()), + mapCenter, + QString("setSelectionColor (%1)").arg(col.name()), + QString("Set color of selection box to %1").arg(col.name()) + ); + setSelectionColorInt (col); +} + +QColor MapEditor::getSelectionColor() +{ + return xelection.getColor(); } bool MapEditor::scrollBranch() @@ -3240,7 +3325,7 @@ } } -void MapEditor::setFrame(const FrameType &t) // FIXME missing saveState +void MapEditor::setFrameType(const FrameType &t) // FIXME missing saveState { BranchObj *bo=xelection.getBranch(); if (bo) @@ -3251,6 +3336,20 @@ } } +void MapEditor::setFramePenColor(const QColor &c) // FIXME missing saveState +{ + BranchObj *bo=xelection.getBranch(); + if (bo) + bo->setFramePenColor (c); +} + +void MapEditor::setFrameBrushColor(const QColor &c) // FIXME missing saveState +{ + BranchObj *bo=xelection.getBranch(); + if (bo) + bo->setFrameBrushColor (c); +} + void MapEditor::setIncludeImagesVer(bool b) { BranchObj *bo=xelection.getBranch(); @@ -3455,12 +3554,6 @@ */ } -void MapEditor::ensureSelectionVisible() -{ - LinkableMapObj *lmo=xelection.single(); - if (lmo) ensureVisible (lmo->getBBox() ); -} - void MapEditor::contextMenuEvent ( QContextMenuEvent * e ) { // Lineedits are already closed by preceding @@ -3542,7 +3635,7 @@ e->accept(); - //Take care of clickdesystem flags _or_ modifier modes + //Take care of system flags _or_ modifier modes // if (lmo && (typeid(*lmo)==typeid(BranchObj) || typeid(*lmo)==typeid(MapCenterObj) )) @@ -3568,12 +3661,12 @@ mainWindow->windowToggleNoteEditor(); else if (foname=="hideInExport") toggleHideExport(); + xelection.update(); return; } } - // No system flag clicked, take care of modmodes - - // Special case: CTRL is pressed + + // No system flag clicked, take care of modmodes (CTRL-Click) if (e->state() & Qt::ControlModifier) { if (mainWindow->getModMode()==ModModeColor) @@ -3604,10 +3697,13 @@ return; } } - } + } // End of modmodes + if (lmo) { + // Select the clicked object selectInt (lmo); + // Left Button Move Branches if (e->button() == Qt::LeftButton ) { @@ -3642,6 +3738,7 @@ if (e->button() == Qt::MidButton ) toggleScroll(); updateActions(); + xelection.update(); } else { // No MapObj found, we are on the scene itself // Left Button move Pos of sceneView @@ -3690,6 +3787,7 @@ fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); fio->setRelPos(); fio->updateLink(); //no need for reposition, if we update link here + xelection.update(); // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent @@ -3716,12 +3814,9 @@ fio->getParObj()->requestReposition(); mapCenter->reposition(); - cout << "current relPos="<getSelectString()); - cout << "setting movingObj\n"; - movingObj=lmosel; - movingObj_orgRelPos=lmosel->getRelPos(); - cout <<"ok 0\n"; + //movingObj=lmosel; + //movingObj_orgRelPos=lmosel->getRelPos(); mapCenter->reposition(); } @@ -3777,6 +3872,7 @@ lmosel->reposition(); } // depth>0 + xelection.update(); } // no FloatImageObj scene()->update(); @@ -3945,6 +4041,7 @@ // Draw the original link, before selection was moved around mapCenter->reposition(); } + xelection.update(); // Finally resize scene, if needed scene()->update(); movingObj=NULL;