1.1 --- a/mapeditor.cpp Sat Mar 31 09:28:27 2007 +0000
1.2 +++ b/mapeditor.cpp Sat Mar 31 09:28:27 2007 +0000
1.3 @@ -97,7 +97,7 @@
1.4 editingBO=NULL;
1.5 movingObj=NULL;
1.6
1.7 - xelection.setMapCenter (mapCenter);
1.8 + xelection.setMapEditor (this);
1.9 xelection.unselect();
1.10
1.11 defXLinkWidth=1;
1.12 @@ -222,6 +222,7 @@
1.13 attribut("comment",mapCenter->getComment()) +
1.14 attribut("date",mapCenter->getDate()) +
1.15 attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) +
1.16 + attribut("selectionColor", xelection.getColor().name() ) +
1.17 attribut("linkStyle", ls ) +
1.18 attribut("linkColor", defLinkColor.name() ) +
1.19 attribut("defXLinkColor", defXLinkColor.name() ) +
1.20 @@ -890,6 +891,13 @@
1.21 b=parser.parBool(ok,0);
1.22 if (ok) setIncludeImagesVer(b);
1.23 }
1.24 + } else if (com=="setSelectionColor")
1.25 + {
1.26 + if (parser.checkParamCount(1))
1.27 + {
1.28 + QColor c=parser.parColor (ok,0);
1.29 + if (ok) setSelectionColorInt (c);
1.30 + }
1.31 } else if (com=="setURL")
1.32 {
1.33 if (xelection.isEmpty() )
1.34 @@ -1147,6 +1155,7 @@
1.35 if ( ok )
1.36 {
1.37 mapCenter->reposition();
1.38 + xelection.update();
1.39 if (lmode==NewMap)
1.40 {
1.41 mapDefault=false;
1.42 @@ -1221,8 +1230,6 @@
1.43 printer->setOutputFileName(settings.value("/mainwindow/printerFileName",printer->outputFileName()).toString());
1.44 }
1.45
1.46 - // FIXME testing cout << "ME::print printProgram="<<printer->printProgram().ascii()<<endl;
1.47 -
1.48 QRectF totalBBox=mapCenter->getTotalBBox();
1.49
1.50 // Try to set orientation automagically
1.51 @@ -1319,7 +1326,6 @@
1.52 {
1.53 QRectF mapRect=mapCenter->getTotalBBox();
1.54 QPixmap pix((int)mapRect.width(),(int)mapRect.height());
1.55 - cout << "w.h="<<(int)mapRect.width()<<","<<(int)mapRect.height()<<endl;
1.56 QPainter pp (&pix);
1.57
1.58 pp.setRenderHints(renderHints());
1.59 @@ -1611,6 +1617,7 @@
1.60
1.61 mainWindow->updateHistory (undoSet);
1.62 updateActions();
1.63 + xelection.update();
1.64 ensureSelectionVisible();
1.65 }
1.66
1.67 @@ -1777,6 +1784,7 @@
1.68 QString("Move %1 to %2").arg(getName(sel)).arg(ps));
1.69 sel->move(x,y); // FIXME xelection not moved automagically...
1.70 mapCenter->reposition();
1.71 + xelection.update();
1.72 }
1.73
1.74 }
1.75 @@ -1795,6 +1803,7 @@
1.76 ((OrnamentedObj*)sel)->move2RelPos (x,y);
1.77 mapCenter->reposition();
1.78 sel->updateLink();
1.79 + xelection.update();
1.80 }
1.81 }
1.82
1.83 @@ -1813,6 +1822,7 @@
1.84 saveState (bo,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
1.85 mapCenter->reposition();
1.86 scene()->update();
1.87 + xelection.update();
1.88 ensureSelectionVisible();
1.89 }
1.90 }
1.91 @@ -1832,6 +1842,7 @@
1.92 saveState(bo,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
1.93 mapCenter->reposition();
1.94 scene()->update();
1.95 + xelection.update();
1.96 ensureSelectionVisible();
1.97 }
1.98 }
1.99 @@ -1892,6 +1903,7 @@
1.100 QString("Set heading of %1 to \"%2\"").arg(getName(sel)).arg(s) );
1.101 sel->setHeading(s );
1.102 mapCenter->reposition();
1.103 + xelection.update();
1.104 ensureSelectionVisible();
1.105 }
1.106 }
1.107 @@ -1904,6 +1916,7 @@
1.108 {
1.109 bo->setURL(s);
1.110 mapCenter->reposition();
1.111 + xelection.update();
1.112 ensureSelectionVisible();
1.113 }
1.114 }
1.115 @@ -1915,6 +1928,7 @@
1.116 {
1.117 bo->setHeading(s);
1.118 mapCenter->reposition();
1.119 + xelection.update();
1.120 ensureSelectionVisible();
1.121 }
1.122 }
1.123 @@ -1927,6 +1941,7 @@
1.124 {
1.125 bo->setVymLink(s);
1.126 mapCenter->reposition();
1.127 + xelection.update();
1.128 ensureSelectionVisible();
1.129 }
1.130 }
1.131 @@ -1988,6 +2003,7 @@
1.132 QString ("Add new branch to %1").arg(getName(bo)));
1.133
1.134 mapCenter->reposition();
1.135 + xelection.update();
1.136 }
1.137 }
1.138 return newbo;
1.139 @@ -2019,6 +2035,7 @@
1.140 QString ("Add branch before %1").arg(getName(bo)));
1.141
1.142 mapCenter->reposition();
1.143 + xelection.update();
1.144 }
1.145 }
1.146 return newbo;
1.147 @@ -2036,7 +2053,8 @@
1.148 xelection.select (par);
1.149 ensureSelectionVisible();
1.150 mapCenter->reposition();
1.151 - mapScene->update();
1.152 + xelection.update();
1.153 + xelection.update();
1.154 return;
1.155 }
1.156 FloatImageObj *fio=xelection.getFloatImage();
1.157 @@ -2052,9 +2070,9 @@
1.158 xelection.unselect();
1.159 par->removeFloatImage(fio);
1.160 xelection.select (par);
1.161 + mapCenter->reposition();
1.162 + xelection.update();
1.163 ensureSelectionVisible();
1.164 - mapCenter->reposition();
1.165 - mapScene->update();
1.166 return;
1.167 }
1.168 }
1.169 @@ -2064,6 +2082,16 @@
1.170 return xelection.single();
1.171 }
1.172
1.173 +BranchObj* MapEditor::getSelectedBranch()
1.174 +{
1.175 + return xelection.getBranch();
1.176 +}
1.177 +
1.178 +FloatImageObj* MapEditor::getSelectedFloatImage()
1.179 +{
1.180 + return xelection.getFloatImage();
1.181 +}
1.182 +
1.183 void MapEditor::unselect()
1.184 {
1.185 xelection.unselect();
1.186 @@ -2083,6 +2111,7 @@
1.187 {
1.188 xelection.unselect();
1.189 xelection.select(lmo);
1.190 + xelection.update();
1.191 ensureSelectionVisible();
1.192 return true;
1.193 }
1.194 @@ -2097,7 +2126,10 @@
1.195 void MapEditor::selectInt (LinkableMapObj *lmo)
1.196 {
1.197 if (lmo && xelection.single()!= lmo)
1.198 + {
1.199 xelection.select(lmo);
1.200 + xelection.update();
1.201 + }
1.202 }
1.203
1.204 void MapEditor::selectNextBranchInt()
1.205 @@ -2311,6 +2343,7 @@
1.206 {
1.207 bo=par->getLastBranch();
1.208 xelection.select(bo);
1.209 + xelection.update();
1.210 ensureSelectionVisible();
1.211 }
1.212 }
1.213 @@ -2323,6 +2356,7 @@
1.214 xelection.type() == FloatImage)
1.215 {
1.216 xelection.select(par);
1.217 + xelection.update();
1.218 ensureSelectionVisible();
1.219 }
1.220 } else
1.221 @@ -2333,6 +2367,7 @@
1.222 if (bo)
1.223 {
1.224 xelection.select(bo);
1.225 + xelection.update();
1.226 ensureSelectionVisible();
1.227 }
1.228 }
1.229 @@ -2360,6 +2395,7 @@
1.230 if (bo)
1.231 {
1.232 xelection.select(bo);
1.233 + xelection.update();
1.234 ensureSelectionVisible();
1.235 }
1.236 }
1.237 @@ -2372,6 +2408,7 @@
1.238 xelection.type() == FloatImage)
1.239 {
1.240 xelection.select(par);
1.241 + xelection.update();
1.242 ensureSelectionVisible();
1.243 }
1.244 } else
1.245 @@ -2382,6 +2419,7 @@
1.246 if (bo)
1.247 {
1.248 xelection.select(bo);
1.249 + xelection.update();
1.250 ensureSelectionVisible();
1.251 }
1.252 }
1.253 @@ -2401,6 +2439,7 @@
1.254 bo2=par->getFirstBranch();
1.255 if (bo2) {
1.256 xelection.select(bo2);
1.257 + xelection.update();
1.258 ensureSelectionVisible();
1.259 }
1.260 }
1.261 @@ -2418,6 +2457,7 @@
1.262 if (bo2)
1.263 {
1.264 xelection.select(bo2);
1.265 + xelection.update();
1.266 ensureSelectionVisible();
1.267 }
1.268 }
1.269 @@ -2444,7 +2484,7 @@
1.270 }
1.271 }
1.272
1.273 -void MapEditor::setMapBackgroundImage (const QString &fn)
1.274 +void MapEditor::setMapBackgroundImage (const QString &fn) //FIXME missing savestate
1.275 {
1.276 QColor oldcol=mapScene->backgroundBrush().color();
1.277 /*
1.278 @@ -2455,7 +2495,6 @@
1.279 QString ("setMapBackgroundImage (%1)").arg(col.name()),
1.280 QString("Set background color of map to %1").arg(col.name()));
1.281 */
1.282 - cout << "Trying to load "<<fn.ascii()<<endl;//FIXME
1.283 QBrush brush;
1.284 brush.setTextureImage (QPixmap (fn));
1.285 mapScene->setBackgroundBrush(brush);
1.286 @@ -2550,6 +2589,7 @@
1.287 QString("%1 (\"%2\")").arg(r).arg(f),
1.288 QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo)));
1.289 bo->toggleStandardFlag (f,mainWindow->useFlagGroups());
1.290 + xelection.update();
1.291 }
1.292 }
1.293
1.294 @@ -2715,6 +2755,7 @@
1.295 QFileDialog *fd=new QFileDialog( this,vymName+" - " +tr("Link to another map"));
1.296 fd->setFilters (filters);
1.297 fd->setCaption(vymName+" - " +tr("Link to another map"));
1.298 + fd->setDirectory (lastFileDir);
1.299 if (! bo->getVymLink().isEmpty() )
1.300 fd->selectFile( bo->getVymLink() );
1.301 fd->show();
1.302 @@ -2722,6 +2763,7 @@
1.303 QString fn;
1.304 if ( fd->exec() == QDialog::Accepted )
1.305 {
1.306 + lastFileDir=QDir (fd->directory().path());
1.307 saveState(
1.308 bo,
1.309 "setVymLink (\""+bo->getVymLink()+"\")",
1.310 @@ -2892,8 +2934,22 @@
1.311 }
1.312 }
1.313
1.314 +void MapEditor::ensureSelectionVisible()
1.315 +{
1.316 + LinkableMapObj *lmo=xelection.single();
1.317 + if (lmo) ensureVisible (lmo->getBBox() );
1.318 +
1.319 +}
1.320 +
1.321 +void MapEditor::updateSelection()
1.322 +{
1.323 + // Tell selection to update geometries
1.324 + xelection.update();
1.325 +}
1.326 +
1.327 void MapEditor::updateActions()
1.328 {
1.329 + // Tell mainwindow to update states of actions
1.330 mainWindow->updateActions();
1.331 // TODO maybe don't update if blockReposition is set
1.332 }
1.333 @@ -3048,7 +3104,36 @@
1.334 QString("Set link color to %1").arg(col.name())
1.335 );
1.336 setMapDefLinkColor( col );
1.337 -
1.338 +}
1.339 +
1.340 +void MapEditor::selectMapSelectionColor()
1.341 +{
1.342 + QColor col = QColorDialog::getColor( defLinkColor, this );
1.343 + setSelectionColor (col);
1.344 +}
1.345 +
1.346 +void MapEditor::setSelectionColorInt (QColor col)
1.347 +{
1.348 + if ( !col.isValid() ) return;
1.349 + xelection.setColor (col);
1.350 +}
1.351 +
1.352 +void MapEditor::setSelectionColor(QColor col)
1.353 +{
1.354 + if ( !col.isValid() ) return;
1.355 + saveState (
1.356 + mapCenter,
1.357 + QString("setSelectionColor (%1)").arg(xelection.getColor().name()),
1.358 + mapCenter,
1.359 + QString("setSelectionColor (%1)").arg(col.name()),
1.360 + QString("Set color of selection box to %1").arg(col.name())
1.361 + );
1.362 + setSelectionColorInt (col);
1.363 +}
1.364 +
1.365 +QColor MapEditor::getSelectionColor()
1.366 +{
1.367 + return xelection.getColor();
1.368 }
1.369
1.370 bool MapEditor::scrollBranch()
1.371 @@ -3240,7 +3325,7 @@
1.372 }
1.373 }
1.374
1.375 -void MapEditor::setFrame(const FrameType &t) // FIXME missing saveState
1.376 +void MapEditor::setFrameType(const FrameType &t) // FIXME missing saveState
1.377 {
1.378 BranchObj *bo=xelection.getBranch();
1.379 if (bo)
1.380 @@ -3251,6 +3336,20 @@
1.381 }
1.382 }
1.383
1.384 +void MapEditor::setFramePenColor(const QColor &c) // FIXME missing saveState
1.385 +{
1.386 + BranchObj *bo=xelection.getBranch();
1.387 + if (bo)
1.388 + bo->setFramePenColor (c);
1.389 +}
1.390 +
1.391 +void MapEditor::setFrameBrushColor(const QColor &c) // FIXME missing saveState
1.392 +{
1.393 + BranchObj *bo=xelection.getBranch();
1.394 + if (bo)
1.395 + bo->setFrameBrushColor (c);
1.396 +}
1.397 +
1.398 void MapEditor::setIncludeImagesVer(bool b)
1.399 {
1.400 BranchObj *bo=xelection.getBranch();
1.401 @@ -3455,12 +3554,6 @@
1.402 */
1.403 }
1.404
1.405 -void MapEditor::ensureSelectionVisible()
1.406 -{
1.407 - LinkableMapObj *lmo=xelection.single();
1.408 - if (lmo) ensureVisible (lmo->getBBox() );
1.409 -}
1.410 -
1.411 void MapEditor::contextMenuEvent ( QContextMenuEvent * e )
1.412 {
1.413 // Lineedits are already closed by preceding
1.414 @@ -3542,7 +3635,7 @@
1.415
1.416 e->accept();
1.417
1.418 - //Take care of clickdesystem flags _or_ modifier modes
1.419 + //Take care of system flags _or_ modifier modes
1.420 //
1.421 if (lmo && (typeid(*lmo)==typeid(BranchObj) ||
1.422 typeid(*lmo)==typeid(MapCenterObj) ))
1.423 @@ -3568,12 +3661,12 @@
1.424 mainWindow->windowToggleNoteEditor();
1.425 else if (foname=="hideInExport")
1.426 toggleHideExport();
1.427 + xelection.update();
1.428 return;
1.429 }
1.430 }
1.431 - // No system flag clicked, take care of modmodes
1.432 -
1.433 - // Special case: CTRL is pressed
1.434 +
1.435 + // No system flag clicked, take care of modmodes (CTRL-Click)
1.436 if (e->state() & Qt::ControlModifier)
1.437 {
1.438 if (mainWindow->getModMode()==ModModeColor)
1.439 @@ -3604,10 +3697,13 @@
1.440 return;
1.441 }
1.442 }
1.443 - }
1.444 + } // End of modmodes
1.445 +
1.446 if (lmo)
1.447 {
1.448 + // Select the clicked object
1.449 selectInt (lmo);
1.450 +
1.451 // Left Button Move Branches
1.452 if (e->button() == Qt::LeftButton )
1.453 {
1.454 @@ -3642,6 +3738,7 @@
1.455 if (e->button() == Qt::MidButton )
1.456 toggleScroll();
1.457 updateActions();
1.458 + xelection.update();
1.459 } else
1.460 { // No MapObj found, we are on the scene itself
1.461 // Left Button move Pos of sceneView
1.462 @@ -3690,6 +3787,7 @@
1.463 fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.464 fio->setRelPos();
1.465 fio->updateLink(); //no need for reposition, if we update link here
1.466 + xelection.update();
1.467
1.468 // Relink float to new mapcenter or branch, if shift is pressed
1.469 // Only relink, if selection really has a new parent
1.470 @@ -3716,12 +3814,9 @@
1.471 fio->getParObj()->requestReposition();
1.472 mapCenter->reposition();
1.473
1.474 - cout << "current relPos="<<movingObj_orgRelPos<<endl; // FIXME testing
1.475 linkTo (lmo->getSelectString());
1.476 - cout << "setting movingObj\n";
1.477 - movingObj=lmosel;
1.478 - movingObj_orgRelPos=lmosel->getRelPos();
1.479 - cout <<"ok 0\n";
1.480 + //movingObj=lmosel;
1.481 + //movingObj_orgRelPos=lmosel->getRelPos();
1.482
1.483 mapCenter->reposition();
1.484 }
1.485 @@ -3777,6 +3872,7 @@
1.486 lmosel->reposition();
1.487 } // depth>0
1.488
1.489 + xelection.update();
1.490 } // no FloatImageObj
1.491
1.492 scene()->update();
1.493 @@ -3945,6 +4041,7 @@
1.494 // Draw the original link, before selection was moved around
1.495 mapCenter->reposition();
1.496 }
1.497 + xelection.update();
1.498 // Finally resize scene, if needed
1.499 scene()->update();
1.500 movingObj=NULL;