1.1 --- a/mapeditor.cpp Tue Jan 23 11:50:56 2007 +0000
1.2 +++ b/mapeditor.cpp Mon Jan 29 12:29:13 2007 +0000
1.3 @@ -95,12 +95,10 @@
1.4 copyingObj=false;
1.5
1.6 editingBO=NULL;
1.7 - selection=NULL;
1.8 - selectionLast=NULL;
1.9 movingObj=NULL;
1.10
1.11 xelection.setMapCenter (mapCenter);
1.12 - xelection.clear();
1.13 + xelection.unselect();
1.14
1.15 defXLinkWidth=1;
1.16 defXLinkColor=QColor (230,230,230);
1.17 @@ -257,8 +255,8 @@
1.18 s+=settings.getXMLData (destPath);
1.19
1.20 // Save selection
1.21 - if (selection && !saveSel )
1.22 - s+=valueElement("select",selection->getSelectString());
1.23 + if (!xelection.isEmpty() && !saveSel )
1.24 + s+=valueElement("select",xelection.getSelectString());
1.25
1.26 decIndent();
1.27 s+=endElement("vymmap");
1.28 @@ -428,6 +426,7 @@
1.29
1.30 void MapEditor::parseAtom(const QString &atom)
1.31 {
1.32 + BranchObj *selb=xelection.getBranch();
1.33 API api;
1.34 QString s,t;
1.35 int x,y;
1.36 @@ -440,11 +439,10 @@
1.37 // External commands
1.38 if (com=="addBranch")
1.39 {
1.40 - if (!selection)
1.41 + if (xelection.isEmpty())
1.42 {
1.43 api.setError (Aborted,"Nothing selected");
1.44 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.45 - typeid(*selection) != typeid(MapCenterObj)) )
1.46 + } else if (! selb )
1.47 {
1.48 api.setError (Aborted,"Type of selection is not a branch");
1.49 } else
1.50 @@ -464,11 +462,10 @@
1.51 }
1.52 } else if (com=="addBranchBefore")
1.53 {
1.54 - if (!selection)
1.55 + if (xelection.isEmpty())
1.56 {
1.57 api.setError (Aborted,"Nothing selected");
1.58 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.59 - typeid(*selection) != typeid(MapCenterObj)) )
1.60 + } else if (! selb )
1.61 {
1.62 api.setError (Aborted,"Type of selection is not a branch");
1.63 } else
1.64 @@ -480,11 +477,10 @@
1.65 }
1.66 } else if (com==QString("addMapReplace"))
1.67 {
1.68 - if (!selection)
1.69 + if (xelection.isEmpty())
1.70 {
1.71 api.setError (Aborted,"Nothing selected");
1.72 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.73 - typeid(*selection) != typeid(MapCenterObj)) )
1.74 + } else if (! selb )
1.75 {
1.76 api.setError (Aborted,"Type of selection is not a branch");
1.77 } else if (api.checkParamCount(1))
1.78 @@ -492,15 +488,14 @@
1.79 //s=api.parString (ok,0); // selection
1.80 t=api.parString (ok,0); // path to map
1.81 if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
1.82 - addMapReplaceInt(selection->getSelectString(),t);
1.83 + addMapReplaceInt(selb->getSelectString(),t);
1.84 }
1.85 } else if (com==QString("addMapInsert"))
1.86 {
1.87 - if (!selection)
1.88 + if (xelection.isEmpty())
1.89 {
1.90 api.setError (Aborted,"Nothing selected");
1.91 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.92 - typeid(*selection) != typeid(MapCenterObj)) )
1.93 + } else if (! selb )
1.94 {
1.95 api.setError (Aborted,"Type of selection is not a branch");
1.96 } else
1.97 @@ -515,11 +510,10 @@
1.98 }
1.99 } else if (com=="colorBranch")
1.100 {
1.101 - if (!selection)
1.102 + if (xelection.isEmpty())
1.103 {
1.104 api.setError (Aborted,"Nothing selected");
1.105 - } else if ( typeid(*selection) != typeid(BranchObj) &&
1.106 - typeid(*selection) != typeid(MapCenterObj))
1.107 + } else if (! selb )
1.108 {
1.109 api.setError (Aborted,"Type of selection is not a branch");
1.110 } else if (api.checkParamCount(1))
1.111 @@ -529,11 +523,10 @@
1.112 }
1.113 } else if (com=="colorSubtree")
1.114 {
1.115 - if (!selection)
1.116 + if (xelection.isEmpty())
1.117 {
1.118 api.setError (Aborted,"Nothing selected");
1.119 - } else if ( typeid(*selection) != typeid(BranchObj) &&
1.120 - typeid(*selection) != typeid(MapCenterObj))
1.121 + } else if (! selb )
1.122 {
1.123 api.setError (Aborted,"Type of selection is not a branch");
1.124 } else if (api.checkParamCount(1))
1.125 @@ -543,12 +536,12 @@
1.126 }
1.127 } else if (com=="cut")
1.128 {
1.129 - if (!selection)
1.130 + if (xelection.isEmpty())
1.131 {
1.132 api.setError (Aborted,"Nothing selected");
1.133 - } else if ( typeid(*selection) != typeid(BranchObj) &&
1.134 - typeid(*selection) != typeid(MapCenterObj) &&
1.135 - typeid(*selection) != typeid(FloatImageObj) )
1.136 + } else if ( xelection.type()!=Branch &&
1.137 + xelection.type()!=MapCenter &&
1.138 + xelection.type()!=FloatImage )
1.139 {
1.140 api.setError (Aborted,"Type of selection is not a branch or floatimage");
1.141 } else if (api.checkParamCount(0))
1.142 @@ -557,12 +550,11 @@
1.143 }
1.144 } else if (com=="delete")
1.145 {
1.146 - if (!selection)
1.147 + if (xelection.isEmpty())
1.148 {
1.149 api.setError (Aborted,"Nothing selected");
1.150 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.151 - typeid(*selection) != typeid(MapCenterObj)) )
1.152 - {
1.153 + } else if (! selb )
1.154 + {
1.155 api.setError (Aborted,"Type of selection is not a branch");
1.156 } else if (api.checkParamCount(0))
1.157 {
1.158 @@ -570,12 +562,11 @@
1.159 }
1.160 } else if (com=="deleteKeepChilds")
1.161 {
1.162 - if (!selection)
1.163 + if (xelection.isEmpty())
1.164 {
1.165 api.setError (Aborted,"Nothing selected");
1.166 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.167 - typeid(*selection) != typeid(MapCenterObj)) )
1.168 - {
1.169 + } else if (! selb )
1.170 + {
1.171 api.setError (Aborted,"Type of selection is not a branch");
1.172 } else if (api.checkParamCount(0))
1.173 {
1.174 @@ -583,12 +574,11 @@
1.175 }
1.176 } else if (com=="deleteChilds")
1.177 {
1.178 - if (!selection)
1.179 + if (xelection.isEmpty())
1.180 {
1.181 api.setError (Aborted,"Nothing selected");
1.182 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.183 - typeid(*selection) != typeid(MapCenterObj)) )
1.184 - {
1.185 + } else if (! selb)
1.186 + {
1.187 api.setError (Aborted,"Type of selection is not a branch");
1.188 } else if (api.checkParamCount(0))
1.189 {
1.190 @@ -596,11 +586,10 @@
1.191 }
1.192 } else if (com=="linkTo")
1.193 {
1.194 - if (!selection)
1.195 + if (xelection.isEmpty())
1.196 {
1.197 api.setError (Aborted,"Nothing selected");
1.198 - } else if ( (typeid(*selection) == typeid(BranchObj) ||
1.199 - typeid(*selection) == typeid(MapCenterObj)) )
1.200 + } else if ( selb)
1.201 {
1.202 if (api.checkParamCount(4))
1.203 {
1.204 @@ -616,21 +605,21 @@
1.205 // Get number in parent
1.206 x=api.parInt (ok,1);
1.207 if (ok)
1.208 - ((BranchObj*)selection)->linkTo ((BranchObj*)(dst),x);
1.209 + selb->linkTo ((BranchObj*)(dst),x);
1.210 } else if (typeid(*dst) == typeid(MapCenterObj) )
1.211 {
1.212 - ((BranchObj*)selection)->linkTo ((BranchObj*)(dst),-1);
1.213 + selb->linkTo ((BranchObj*)(dst),-1);
1.214 // Get coordinates of mainbranch
1.215 x=api.parInt (ok,2);
1.216 if (ok)
1.217 {
1.218 y=api.parInt (ok,3);
1.219 - if (ok) ((BranchObj*)selection)->move (x,y);
1.220 + if (ok) selb->move (x,y);
1.221 }
1.222 }
1.223 }
1.224 }
1.225 - } else if ( typeid(*selection) != typeid(FloatImageObj))
1.226 + } else if ( xelection.type() == FloatImage)
1.227 {
1.228 if (api.checkParamCount(1))
1.229 {
1.230 @@ -649,11 +638,10 @@
1.231 api.setError (Aborted,"Type of selection is not a floatimage or branch");
1.232 } else if (com=="moveBranchUp")
1.233 {
1.234 - if (!selection)
1.235 + if (xelection.isEmpty() )
1.236 {
1.237 api.setError (Aborted,"Nothing selected");
1.238 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.239 - typeid(*selection) != typeid(MapCenterObj)) )
1.240 + } else if (! selb )
1.241 {
1.242 api.setError (Aborted,"Type of selection is not a branch");
1.243 } else if (api.checkParamCount(0))
1.244 @@ -662,11 +650,10 @@
1.245 }
1.246 } else if (com=="moveBranchDown")
1.247 {
1.248 - if (!selection)
1.249 + if (xelection.isEmpty() )
1.250 {
1.251 api.setError (Aborted,"Nothing selected");
1.252 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.253 - typeid(*selection) != typeid(MapCenterObj)) )
1.254 + } else if (! selb )
1.255 {
1.256 api.setError (Aborted,"Type of selection is not a branch");
1.257 } else if (api.checkParamCount(0))
1.258 @@ -675,12 +662,12 @@
1.259 }
1.260 } else if (com=="move")
1.261 {
1.262 - if (!selection)
1.263 + if (xelection.isEmpty() )
1.264 {
1.265 api.setError (Aborted,"Nothing selected");
1.266 - } else if ( typeid(*selection) != typeid(BranchObj) &&
1.267 - typeid(*selection) != typeid(MapCenterObj) &&
1.268 - typeid(*selection) != typeid(FloatImageObj) )
1.269 + } else if ( xelection.type()!=Branch &&
1.270 + xelection.type()!=MapCenter &&
1.271 + xelection.type()!=FloatImage )
1.272 {
1.273 api.setError (Aborted,"Type of selection is not a branch or floatimage");
1.274 } else if (api.checkParamCount(2))
1.275 @@ -694,12 +681,12 @@
1.276 }
1.277 } else if (com=="moveRel")
1.278 {
1.279 - if (!selection)
1.280 + if (xelection.isEmpty() )
1.281 {
1.282 api.setError (Aborted,"Nothing selected");
1.283 - } else if ( typeid(*selection) != typeid(BranchObj) &&
1.284 - typeid(*selection) != typeid(MapCenterObj) &&
1.285 - typeid(*selection) != typeid(FloatImageObj) )
1.286 + } else if ( xelection.type()!=Branch &&
1.287 + xelection.type()!=MapCenter &&
1.288 + xelection.type()!=FloatImage )
1.289 {
1.290 api.setError (Aborted,"Type of selection is not a branch or floatimage");
1.291 } else if (api.checkParamCount(2))
1.292 @@ -713,11 +700,10 @@
1.293 }
1.294 } else if (com=="paste")
1.295 {
1.296 - if (!selection)
1.297 + if (xelection.isEmpty() )
1.298 {
1.299 api.setError (Aborted,"Nothing selected");
1.300 - } else if ( typeid(*selection) != typeid(BranchObj) &&
1.301 - typeid(*selection) != typeid(MapCenterObj) )
1.302 + } else if (! selb )
1.303 {
1.304 api.setError (Aborted,"Type of selection is not a branch");
1.305 } else if (api.checkParamCount(0))
1.306 @@ -747,11 +733,10 @@
1.307 }
1.308 } else if (com=="setMapBackgroundColor")
1.309 {
1.310 - if (!selection)
1.311 + if (xelection.isEmpty() )
1.312 {
1.313 api.setError (Aborted,"Nothing selected");
1.314 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.315 - typeid(*selection) != typeid(MapCenterObj)) )
1.316 + } else if (! xelection.getBranch() )
1.317 {
1.318 api.setError (Aborted,"Type of selection is not a branch");
1.319 } else if (api.checkParamCount(1))
1.320 @@ -761,11 +746,10 @@
1.321 }
1.322 } else if (com=="setMapDefLinkColor")
1.323 {
1.324 - if (!selection)
1.325 + if (xelection.isEmpty() )
1.326 {
1.327 api.setError (Aborted,"Nothing selected");
1.328 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.329 - typeid(*selection) != typeid(MapCenterObj)) )
1.330 + } else if (! selb )
1.331 {
1.332 api.setError (Aborted,"Type of selection is not a branch");
1.333 } else if (api.checkParamCount(1))
1.334 @@ -782,11 +766,10 @@
1.335 }
1.336 } else if (com=="setHeading")
1.337 {
1.338 - if (!selection)
1.339 + if (xelection.isEmpty() )
1.340 {
1.341 api.setError (Aborted,"Nothing selected");
1.342 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.343 - typeid(*selection) != typeid(MapCenterObj)) )
1.344 + } else if (! selb )
1.345 {
1.346 api.setError (Aborted,"Type of selection is not a branch");
1.347 } else if (api.checkParamCount(1))
1.348 @@ -797,11 +780,10 @@
1.349 }
1.350 } else if (com=="setHideExport")
1.351 {
1.352 - if (!selection)
1.353 + if (xelection.isEmpty() )
1.354 {
1.355 api.setError (Aborted,"Nothing selected");
1.356 - } else if ( typeid(*selection) != typeid(BranchObj) &&
1.357 - typeid(*selection) != typeid(FloatImageObj) )
1.358 + } else if (! selb)
1.359 {
1.360 api.setError (Aborted,"Type of selection is not a branch or floatimage");
1.361 } else if (api.checkParamCount(1))
1.362 @@ -811,11 +793,10 @@
1.363 }
1.364 } else if (com=="setURL")
1.365 {
1.366 - if (!selection)
1.367 + if (xelection.isEmpty() )
1.368 {
1.369 api.setError (Aborted,"Nothing selected");
1.370 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.371 - typeid(*selection) != typeid(MapCenterObj)) )
1.372 + } else if (! selb )
1.373 {
1.374 api.setError (Aborted,"Type of selection is not a branch");
1.375 } else if (api.checkParamCount(1))
1.376 @@ -825,11 +806,10 @@
1.377 }
1.378 } else if (com=="setVymLink")
1.379 {
1.380 - if (!selection)
1.381 + if (xelection.isEmpty() )
1.382 {
1.383 api.setError (Aborted,"Nothing selected");
1.384 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.385 - typeid(*selection) != typeid(MapCenterObj)) )
1.386 + } else if (! selb )
1.387 {
1.388 api.setError (Aborted,"Type of selection is not a branch");
1.389 } else if (api.checkParamCount(1))
1.390 @@ -840,11 +820,10 @@
1.391 }
1.392 else if (com=="setFlag")
1.393 {
1.394 - if (!selection)
1.395 + if (xelection.isEmpty() )
1.396 {
1.397 api.setError (Aborted,"Nothing selected");
1.398 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.399 - typeid(*selection) != typeid(MapCenterObj)) )
1.400 + } else if (! selb )
1.401 {
1.402 api.setError (Aborted,"Type of selection is not a branch");
1.403 } else if (api.checkParamCount(1))
1.404 @@ -852,19 +831,17 @@
1.405 s=api.parString(ok,0);
1.406 if (ok)
1.407 {
1.408 - BranchObj* bo=(BranchObj*)selection;
1.409 - bo->activateStandardFlag(s);
1.410 - bo->updateFlagsToolbar();
1.411 + selb->activateStandardFlag(s);
1.412 + selb->updateFlagsToolbar();
1.413 }
1.414 }
1.415 }
1.416 else if (com=="unsetFlag")
1.417 {
1.418 - if (!selection)
1.419 + if (xelection.isEmpty() )
1.420 {
1.421 api.setError (Aborted,"Nothing selected");
1.422 - } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.423 - typeid(*selection) != typeid(MapCenterObj)) )
1.424 + } else if (! selb )
1.425 {
1.426 api.setError (Aborted,"Type of selection is not a branch");
1.427 } else if (api.checkParamCount(1))
1.428 @@ -872,9 +849,8 @@
1.429 s=api.parString(ok,0);
1.430 if (ok)
1.431 {
1.432 - BranchObj* bo=(BranchObj*)selection;
1.433 - bo->deactivateStandardFlag(s);
1.434 - bo->updateFlagsToolbar();
1.435 + selb->deactivateStandardFlag(s);
1.436 + selb->updateFlagsToolbar();
1.437 }
1.438 }
1.439 } else
1.440 @@ -918,8 +894,8 @@
1.441 void MapEditor::closeMap()
1.442 {
1.443 // Unselect before disabling the toolbar actions
1.444 - if (selection) selection->unselect();
1.445 - selection=NULL;
1.446 + if (!xelection.isEmpty() ) xelection.unselect();
1.447 + xelection.clear();
1.448 updateActions();
1.449
1.450 clear();
1.451 @@ -983,27 +959,25 @@
1.452
1.453 if (lmode==NewMap)
1.454 {
1.455 - if (selection) selection->unselect();
1.456 - selection=NULL;
1.457 + if (xelection.isEmpty() ) xelection.unselect();
1.458 + xelection.clear();
1.459 mapCenter->clear();
1.460 mapCenter->setMapEditor(this);
1.461 // (map state is set later at end of load...)
1.462 } else
1.463 {
1.464 - if (!selection || (typeid(*selection) != typeid(BranchObj) &&
1.465 - typeid(*selection) != typeid (MapCenterObj)))
1.466 - return aborted;
1.467 - BranchObj *bo=(BranchObj*)selection;
1.468 + BranchObj *bo=xelection.getBranch();
1.469 + if (!bo) return aborted;
1.470 if (lmode==ImportAdd)
1.471 saveStateChangingPart(
1.472 - selection,
1.473 - selection,
1.474 + bo,
1.475 + bo,
1.476 QString("addMapInsert (%1)").arg(fname),
1.477 QString("Add map %1 to %2").arg(fname).arg(getName(bo)));
1.478 else
1.479 saveStateChangingPart(
1.480 - selection,
1.481 - selection,
1.482 + bo,
1.483 + bo,
1.484 QString("addMapReplace(%1)").arg(fname),
1.485 QString("Add map %1 to %2").arg(fname).arg(getName(bo)));
1.486 }
1.487 @@ -1073,10 +1047,10 @@
1.488
1.489
1.490 QString saveFile;
1.491 - if (savemode==CompleteMap || selection==NULL)
1.492 + if (savemode==CompleteMap || xelection.isEmpty())
1.493 saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL);
1.494 else
1.495 - saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),selection);
1.496 + saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),xelection.getBranch()); //FIXME check selected FIO
1.497
1.498 if (!saveStringToDisk(fileDir+fname,saveFile))
1.499 return 1;
1.500 @@ -1136,12 +1110,7 @@
1.501 pp.setRenderHint(QPainter::Antialiasing,true);
1.502
1.503 // Don't print the visualisation of selection
1.504 - LinkableMapObj *oldselection=NULL;
1.505 - if (selection)
1.506 - {
1.507 - oldselection=selection;
1.508 - selection->unselect();
1.509 - }
1.510 + xelection.unselect();
1.511
1.512 QRectF mapRect=totalBBox;
1.513 QGraphicsRectItem *frame=NULL;
1.514 @@ -1192,11 +1161,7 @@
1.515 if (frame) delete (frame);
1.516
1.517 // Restore selection
1.518 - if (oldselection)
1.519 - {
1.520 - selection=oldselection;
1.521 - selection->select();
1.522 - }
1.523 + xelection.reselect();
1.524
1.525 // Save settings in vymrc
1.526 settings.writeEntry("/mainwindow/printerName",printer->printerName());
1.527 @@ -1225,12 +1190,7 @@
1.528 pp.setRenderHints(renderHints());
1.529
1.530 // Don't print the visualisation of selection
1.531 - LinkableMapObj *oldselection=NULL;
1.532 - if (selection)
1.533 - {
1.534 - oldselection=selection;
1.535 - selection->unselect();
1.536 - }
1.537 + xelection.unselect();
1.538
1.539 mapScene->render ( &pp,
1.540 QRectF(0,0,mapRect.width(),mapRect.height()),
1.541 @@ -1241,11 +1201,7 @@
1.542
1.543
1.544 // Restore selection
1.545 - if (oldselection)
1.546 - {
1.547 - selection=oldselection;
1.548 - selection->select();
1.549 - }
1.550 + xelection.reselect();
1.551
1.552 return pix;
1.553 }
1.554 @@ -1338,22 +1294,18 @@
1.555
1.556 void MapEditor::clear()
1.557 {
1.558 - if (selection)
1.559 - {
1.560 - selection->unselect();
1.561 - selection=NULL;
1.562 - }
1.563 -
1.564 + xelection.unselect();
1.565 mapCenter->clear();
1.566 }
1.567
1.568 void MapEditor::copy()
1.569 {
1.570 - if (selection)
1.571 + LinkableMapObj *sel=xelection.single();
1.572 + if (sel)
1.573 {
1.574 // write to directory
1.575 QString clipfile="part";
1.576 - QString saveFile=saveToDir (fileDir,clipfile+"-",true,QPointF(),selection);
1.577 + QString saveFile=saveToDir (fileDir,clipfile+"-",true,QPointF(),sel ); // FIXME check FIO
1.578 QFile file;
1.579
1.580 file.setName ( clipboardDir + "/"+clipfile+".xml");
1.581 @@ -1597,8 +1549,8 @@
1.582
1.583 void MapEditor::addMapInsertInt (const QString &path, int pos)
1.584 {
1.585 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.586 - typeid(*selection) == typeid(MapCenterObj)))
1.587 + BranchObj *sel=xelection.getBranch();
1.588 + if (sel);
1.589 {
1.590 QString pathDir=path.left(path.findRev("/"));
1.591 QDir d(pathDir);
1.592 @@ -1624,8 +1576,8 @@
1.593 QMessageBox::critical( 0, tr( "Critical Parse Error while reading %1").arg(path),
1.594 handler.errorProtocol());
1.595 }
1.596 - if (selection!=mapCenter)
1.597 - ((BranchObj*)selection)->getLastBranch()->linkTo ((BranchObj*)(selection),pos);
1.598 + if (sel!=mapCenter)
1.599 + sel->getLastBranch()->linkTo (sel,pos);
1.600 } else
1.601 QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
1.602 }
1.603 @@ -1642,17 +1594,17 @@
1.604 deleteSelection();
1.605 }
1.606
1.607 -void MapEditor::paste()
1.608 +void MapEditor::paste() // FIXME no pasting of FIO ???
1.609 {
1.610 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.611 - typeid(*selection) == typeid(MapCenterObj)))
1.612 + BranchObj *sel=xelection.getBranch();
1.613 + if (sel)
1.614 {
1.615 pasteNoSave();
1.616 saveStateChangingPart(
1.617 - selection,
1.618 - selection,
1.619 + sel,
1.620 + sel,
1.621 "paste ()",
1.622 - QString("Paste to %1").arg( getName(selection))
1.623 + QString("Paste to %1").arg( getName(sel))
1.624 );
1.625 mapCenter->reposition();
1.626 }
1.627 @@ -1660,28 +1612,35 @@
1.628
1.629 void MapEditor::cut()
1.630 {
1.631 - saveStateChangingPart(
1.632 - selection->getParObj(),
1.633 - selection,
1.634 - "cut ()",
1.635 - QString("Cut %1").arg(getName(selection))
1.636 - );
1.637 - copy();
1.638 - cutNoSave();
1.639 - mapCenter->reposition();
1.640 + LinkableMapObj *sel=xelection.single();
1.641 + if ( sel && (xelection.type() == Branch ||
1.642 + xelection.type()==MapCenter ||
1.643 + xelection.type()==FloatImage))
1.644 + {
1.645 + saveStateChangingPart(
1.646 + sel->getParObj(),
1.647 + sel,
1.648 + "cut ()",
1.649 + QString("Cut %1").arg(getName(sel ))
1.650 + );
1.651 + copy();
1.652 + cutNoSave();
1.653 + mapCenter->reposition();
1.654 + }
1.655 }
1.656
1.657 void MapEditor::move(const int &x, const int &y)
1.658 {
1.659 - if (selection)
1.660 + LinkableMapObj *sel=xelection.single();
1.661 + if (sel)
1.662 {
1.663 - QString ps=qpointfToString (selection->getAbsPos());
1.664 - QString s=selection->getSelectString();
1.665 + QString ps=qpointfToString (sel->getAbsPos());
1.666 + QString s=xelection.single()->getSelectString();
1.667 saveState(
1.668 s, "move "+ps,
1.669 s, "move "+qpointfToString (QPointF (x,y)),
1.670 - QString("Move %1 to %2").arg(getName(selection)).arg(ps));
1.671 - selection->move(x,y);
1.672 + QString("Move %1 to %2").arg(getName(sel)).arg(ps));
1.673 + sel->move(x,y); // FIXME xelection not moved automagically...
1.674 mapCenter->reposition();
1.675 }
1.676
1.677 @@ -1689,35 +1648,34 @@
1.678
1.679 void MapEditor::moveRel (const int &x, const int &y)
1.680 {
1.681 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.682 - typeid(*selection) == typeid(MapCenterObj) ||
1.683 - typeid(*selection) == typeid (FloatImageObj)))
1.684 + LinkableMapObj *sel=xelection.single();
1.685 + if (sel)
1.686 {
1.687 - QString ps=qpointfToString (selection->getRelPos());
1.688 - QString s=selection->getSelectString();
1.689 + QString ps=qpointfToString (sel->getRelPos());
1.690 + QString s=sel->getSelectString();
1.691 saveState(
1.692 s, "moveRel "+ps,
1.693 s, "moveRel "+qpointfToString (QPointF (x,y)),
1.694 - QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps));
1.695 - ((OrnamentedObj*)selection)->move2RelPos (x,y);
1.696 + QString("Move %1 to relativ position %2").arg(getName(sel)).arg(ps));
1.697 + ((OrnamentedObj*)sel)->move2RelPos (x,y);
1.698 mapCenter->reposition();
1.699 - selection->updateLink();
1.700 + sel->updateLink();
1.701 }
1.702 }
1.703
1.704 void MapEditor::moveBranchUp()
1.705 {
1.706 - BranchObj* bo;
1.707 + BranchObj* bo=xelection.getBranch();
1.708 BranchObj* par;
1.709 - if (typeid(*selection) == typeid(BranchObj) )
1.710 + if (bo)
1.711 {
1.712 - bo=(BranchObj*)selection;
1.713 if (!bo->canMoveBranchUp()) return;
1.714 par=(BranchObj*)(bo->getParObj());
1.715 - selection->unselect();
1.716 + xelection.unselect(); // FIXME needed?
1.717 bo=par->moveBranchUp (bo); // bo will be the one below selection
1.718 - selection->select();
1.719 - saveState (selection,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
1.720 + xelection.reselect();
1.721 + //saveState (selection,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
1.722 + saveState (bo,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
1.723 mapCenter->reposition();
1.724 scene()->update();
1.725 ensureSelectionVisible();
1.726 @@ -1726,63 +1684,61 @@
1.727
1.728 void MapEditor::moveBranchDown()
1.729 {
1.730 - BranchObj* bo;
1.731 + BranchObj* bo=xelection.getBranch();
1.732 BranchObj* par;
1.733 - if (typeid(*selection) == typeid(BranchObj) )
1.734 + if (bo)
1.735 {
1.736 - bo=(BranchObj*)selection;
1.737 if (!bo->canMoveBranchDown()) return;
1.738 par=(BranchObj*)(bo->getParObj());
1.739 - selection->unselect();
1.740 + xelection.unselect(); // FIXME needed?
1.741 bo=par->moveBranchDown(bo); // bo will be the one above selection
1.742 - selection->select();
1.743 - saveState(selection,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
1.744 + xelection.reselect();
1.745 + //saveState(selection,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
1.746 + saveState(bo,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
1.747 mapCenter->reposition();
1.748 scene()->update();
1.749 ensureSelectionVisible();
1.750 }
1.751 }
1.752
1.753 -void MapEditor::linkTo(const QString &dstString)
1.754 +void MapEditor::linkTo(const QString &dstString) // FIXME needed? only for FIO ??
1.755 {
1.756 - BranchObj *dst=(BranchObj*)(mapCenter->findObjBySelect(dstString));
1.757 - if (dst && (typeid(*dst)==typeid (BranchObj) ||
1.758 - typeid(*dst)==typeid (MapCenterObj)))
1.759 - {
1.760 - LinkableMapObj *dstPar=dst->getParObj();
1.761 - QString parString=dstPar->getSelectString();
1.762 - if (typeid(*selection)==typeid(FloatImageObj))
1.763 - {
1.764 - FloatImageObj *fio=(FloatImageObj*)selection;
1.765 + FloatImageObj *fio=xelection.getFloatImage();
1.766 + if (fio)
1.767 + {
1.768 + BranchObj *dst=(BranchObj*)(mapCenter->findObjBySelect(dstString));
1.769 + if (dst && (typeid(*dst)==typeid (BranchObj) ||
1.770 + typeid(*dst)==typeid (MapCenterObj)))
1.771 + {
1.772 + LinkableMapObj *dstPar=dst->getParObj();
1.773 + QString parString=dstPar->getSelectString();
1.774 QString fioPreSelectString=fio->getSelectString();
1.775 QString fioPreParentSelectString=fio->getParObj()->getSelectString();
1.776 ((BranchObj*)(dst))->addFloatImage (fio);
1.777 - fio->unselect();
1.778 + xelection.unselect();
1.779 ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
1.780 fio=((BranchObj*)(dst))->getLastFloatImage();
1.781 fio->setRelPos();
1.782 fio->reposition();
1.783 - selection=(LinkableMapObj*)fio;
1.784 - selection->select();
1.785 + xelection.select(fio);
1.786 saveState(
1.787 fio->getSelectString(),
1.788 QString("linkTo (\"%1\")").arg(fioPreParentSelectString),
1.789 fioPreSelectString,
1.790 QString ("linkTo (\"%1\")").arg(dstString),
1.791 QString ("Link floatimage to %1").arg(getName(dst)));
1.792 - }
1.793 + }
1.794 }
1.795 }
1.796
1.797 QString MapEditor::getHeading(bool &ok, QPoint &p)
1.798 {
1.799 - if (selection &&
1.800 - (typeid(*selection) == typeid(BranchObj) ||
1.801 - typeid(*selection) == typeid(MapCenterObj) ) )
1.802 + BranchObj *bo=xelection.getBranch();
1.803 + if (bo)
1.804 {
1.805 ok=true;
1.806 - p=mapFromScene(selection->getAbsPos());
1.807 - return ((BranchObj*)selection)->getHeading();
1.808 + p=mapFromScene(bo->getAbsPos());
1.809 + return bo->getHeading();
1.810 }
1.811 ok=false;
1.812 return QString();
1.813 @@ -1790,19 +1746,16 @@
1.814
1.815 void MapEditor::setHeading(const QString &s)
1.816 {
1.817 - if (selection &&
1.818 - (typeid(*selection) == typeid(BranchObj) ||
1.819 - typeid(*selection) == typeid(MapCenterObj) ) )
1.820 + BranchObj *sel=xelection.getBranch();
1.821 + if (sel)
1.822 {
1.823 - editingBO=(BranchObj*)selection;
1.824 saveState(
1.825 - selection,
1.826 - "setHeading (\""+editingBO->getHeading()+"\")",
1.827 - selection,
1.828 + sel,
1.829 + "setHeading (\""+sel->getHeading()+"\")",
1.830 + sel,
1.831 "setHeading (\""+s+"\")",
1.832 - QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(s) );
1.833 - editingBO->setHeading(s );
1.834 - editingBO=NULL;
1.835 + QString("Set heading of %1 to \"%2\"").arg(getName(sel)).arg(s) );
1.836 + sel->setHeading(s );
1.837 mapCenter->reposition();
1.838 ensureSelectionVisible();
1.839 }
1.840 @@ -1811,11 +1764,10 @@
1.841 void MapEditor::setURLInt (const QString &s)
1.842 {
1.843 // Internal function, no saveState needed
1.844 - if (selection &&
1.845 - (typeid(*selection) == typeid(BranchObj) ||
1.846 - typeid(*selection) == typeid(MapCenterObj) ) )
1.847 + BranchObj *bo=xelection.getBranch();
1.848 + if (bo)
1.849 {
1.850 - ((BranchObj*)selection)->setURL(s);
1.851 + bo->setURL(s);
1.852 mapCenter->reposition();
1.853 ensureSelectionVisible();
1.854 }
1.855 @@ -1823,11 +1775,10 @@
1.856
1.857 void MapEditor::setHeadingInt(const QString &s)
1.858 {
1.859 - if (selection &&
1.860 - (typeid(*selection) == typeid(BranchObj) ||
1.861 - typeid(*selection) == typeid(MapCenterObj) ) )
1.862 + BranchObj *bo=xelection.getBranch();
1.863 + if (bo)
1.864 {
1.865 - ((BranchObj*)selection)->setHeading(s);
1.866 + bo->setHeading(s);
1.867 mapCenter->reposition();
1.868 ensureSelectionVisible();
1.869 }
1.870 @@ -1836,11 +1787,10 @@
1.871 void MapEditor::setVymLinkInt (const QString &s)
1.872 {
1.873 // Internal function, no saveState needed
1.874 - if (selection &&
1.875 - (typeid(*selection) == typeid(BranchObj) ||
1.876 - typeid(*selection) == typeid(MapCenterObj) ) )
1.877 + BranchObj *bo=xelection.getBranch();
1.878 + if (bo)
1.879 {
1.880 - ((BranchObj*)selection)->setVymLink(s);
1.881 + bo->setVymLink(s);
1.882 mapCenter->reposition();
1.883 ensureSelectionVisible();
1.884 }
1.885 @@ -1854,11 +1804,9 @@
1.886 // -1 insert in childs of parent below selection
1.887 // 0..n insert in childs of parent at pos
1.888 BranchObj *newbo=NULL;
1.889 - if (selection &&
1.890 - (typeid(*selection) == typeid(BranchObj) ||
1.891 - typeid(*selection) == typeid(MapCenterObj) ) )
1.892 + BranchObj *bo=xelection.getBranch();
1.893 + if (bo)
1.894 {
1.895 - BranchObj* bo = (BranchObj*) selection;
1.896 if (num==-2)
1.897 {
1.898 // save scroll state. If scrolled, automatically select
1.899 @@ -1886,12 +1834,10 @@
1.900 // -1 add above
1.901 // 0 add as child
1.902 // +1 add below
1.903 - BranchObj *bo = (BranchObj*) selection;
1.904 + BranchObj *bo = xelection.getBranch();
1.905 BranchObj *newbo=NULL;
1.906
1.907 - if (selection &&
1.908 - (typeid(*selection) == typeid(BranchObj) ||
1.909 - typeid(*selection) == typeid(MapCenterObj) ) )
1.910 + if (bo)
1.911 {
1.912 setCursor (Qt::ArrowCursor);
1.913
1.914 @@ -1902,7 +1848,7 @@
1.915 saveState(
1.916 newbo,
1.917 "delete ()",
1.918 - selection,
1.919 + bo,
1.920 QString ("addBranch (%1)").arg(pos-2),
1.921 QString ("Add new branch to %1").arg(getName(bo)));
1.922
1.923 @@ -1916,15 +1862,14 @@
1.924 BranchObj* MapEditor::addNewBranchBefore()
1.925 {
1.926 BranchObj *newbo=NULL;
1.927 - if (selection &&
1.928 - (typeid(*selection) == typeid(BranchObj) ) )
1.929 + BranchObj *bo = xelection.getBranch();
1.930 + if (bo && xelection.type()==Branch)
1.931 // We accept no MapCenterObj here, so we _have_ a parent
1.932 {
1.933 - BranchObj* bo = (BranchObj*) selection;
1.934 QPointF p=bo->getRelPos();
1.935
1.936
1.937 - BranchObj *parbo=(BranchObj*)(selection->getParObj());
1.938 + BranchObj *parbo=(BranchObj*)(bo->getParObj());
1.939
1.940 // add below selection
1.941 newbo=parbo->insertBranch(bo->getNum()+1);
1.942 @@ -1933,7 +1878,7 @@
1.943 newbo->move2RelPos (p);
1.944
1.945 // Move selection to new branch
1.946 - ((BranchObj*)selection)->linkTo (newbo,-1);
1.947 + bo->linkTo (newbo,-1);
1.948
1.949 saveState (newbo, "deleteKeepChilds ()", newbo, "addBranchBefore ()",
1.950 QString ("Add branch before %1").arg(getName(bo)));
1.951 @@ -1946,22 +1891,22 @@
1.952
1.953 void MapEditor::deleteSelection()
1.954 {
1.955 - if (selection && typeid(*selection) ==typeid(BranchObj) )
1.956 + BranchObj *bo = xelection.getBranch();
1.957 + if (bo && xelection.type()==Branch)
1.958 {
1.959 - BranchObj* bo=(BranchObj*)selection;
1.960 BranchObj* par=(BranchObj*)(bo->getParObj());
1.961 - bo->unselect();
1.962 + xelection.unselect();
1.963 saveStateRemovingPart (bo, QString ("Delete %1").arg(getName(bo)));
1.964 - selection=NULL;
1.965 par->removeBranch(bo);
1.966 - selection=par;
1.967 - selection->select();
1.968 + xelection.select (par);
1.969 ensureSelectionVisible();
1.970 mapCenter->reposition();
1.971 + mapScene->update();
1.972 + return;
1.973 }
1.974 - if (selection && typeid(*selection) ==typeid(FloatImageObj) )
1.975 + FloatImageObj *fio=xelection.getFloatImage();
1.976 + if (fio)
1.977 {
1.978 - FloatImageObj* fio=(FloatImageObj*)selection;
1.979 BranchObj* par=(BranchObj*)(fio->getParObj());
1.980 saveStateChangingPart(
1.981 par,
1.982 @@ -1969,40 +1914,29 @@
1.983 "delete ()",
1.984 QString("Delete %1").arg(getName(fio))
1.985 );
1.986 - fio->unselect();
1.987 - selection=NULL;
1.988 + xelection.unselect();
1.989 par->removeFloatImage(fio);
1.990 - selection=par;
1.991 - selection->select();
1.992 + xelection.select (par);
1.993 ensureSelectionVisible();
1.994 mapCenter->reposition();
1.995 + mapScene->update();
1.996 + return;
1.997 }
1.998 - mapScene->update();
1.999 }
1.1000
1.1001 LinkableMapObj* MapEditor::getSelection()
1.1002 {
1.1003 - return selection;
1.1004 + return xelection.single();
1.1005 }
1.1006
1.1007 void MapEditor::unselect()
1.1008 {
1.1009 - if (selection)
1.1010 - {
1.1011 - selectionLast=selection;
1.1012 - selection->unselect();
1.1013 - selection=NULL;
1.1014 - }
1.1015 + xelection.unselect();
1.1016 }
1.1017
1.1018 void MapEditor::reselect()
1.1019 {
1.1020 - if (selectionLast)
1.1021 - {
1.1022 - selection=selectionLast;
1.1023 - selection->select();
1.1024 - selectionLast=NULL;
1.1025 - }
1.1026 + xelection.reselect();
1.1027 }
1.1028
1.1029 bool MapEditor::select (const QString &s)
1.1030 @@ -2012,9 +1946,8 @@
1.1031 // Finally select the found object
1.1032 if (lmo)
1.1033 {
1.1034 - if (selection) unselect();
1.1035 - selection=lmo;
1.1036 - selection->select();
1.1037 + xelection.unselect();
1.1038 + xelection.select(lmo);
1.1039 ensureSelectionVisible();
1.1040 return true;
1.1041 }
1.1042 @@ -2023,27 +1956,22 @@
1.1043
1.1044 QString MapEditor::getSelectString()
1.1045 {
1.1046 - if (selection) return selection->getSelectString();
1.1047 - return QString();
1.1048 + return xelection.getSelectString();
1.1049 }
1.1050
1.1051 void MapEditor::selectInt (LinkableMapObj *lmo)
1.1052 {
1.1053 - if (lmo && selection != lmo)
1.1054 - {
1.1055 - // select the MapObj
1.1056 - if (selection) selection->unselect();
1.1057 - selection=lmo;
1.1058 - selection->select();
1.1059 - }
1.1060 + if (lmo && xelection.single()!= lmo)
1.1061 + xelection.select(lmo);
1.1062 }
1.1063
1.1064 void MapEditor::selectNextBranchInt()
1.1065 {
1.1066 // Increase number of branch
1.1067 - if (selection)
1.1068 + LinkableMapObj *sel=xelection.single();
1.1069 + if (sel)
1.1070 {
1.1071 - QString s=selection->getSelectString();
1.1072 + QString s=sel->getSelectString();
1.1073 QString part;
1.1074 QString typ;
1.1075 QString num;
1.1076 @@ -2067,7 +1995,7 @@
1.1077 // try to increase the parental number in order to
1.1078 // find a successor with same depth
1.1079
1.1080 - int d=selection->getDepth();
1.1081 + int d=xelection.single()->getDepth();
1.1082 int oldDepth=d;
1.1083 int i;
1.1084 bool found=false;
1.1085 @@ -2088,7 +2016,7 @@
1.1086 } else
1.1087 {
1.1088 // Special case, look at orientation
1.1089 - if (selection->getOrientation()==OrientRightOfCenter)
1.1090 + if (xelection.single()->getOrientation()==OrientRightOfCenter)
1.1091 num=QString ("%1").arg(num.toUInt()+1);
1.1092 else
1.1093 num=QString ("%1").arg(num.toUInt()-1);
1.1094 @@ -2102,7 +2030,7 @@
1.1095 b=select (s);
1.1096 if (b)
1.1097 {
1.1098 - if ( ((BranchObj*)selection)->countBranches()>0)
1.1099 + if ( xelection.getBranch()->countBranches()>0)
1.1100 s+=",bo:0";
1.1101 else
1.1102 break;
1.1103 @@ -2121,9 +2049,10 @@
1.1104 void MapEditor::selectPrevBranchInt()
1.1105 {
1.1106 // Decrease number of branch
1.1107 - if (selection)
1.1108 + BranchObj *bo=xelection.getBranch();
1.1109 + if (bo)
1.1110 {
1.1111 - QString s=selection->getSelectString();
1.1112 + QString s=bo->getSelectString();
1.1113 QString part;
1.1114 QString typ;
1.1115 QString num;
1.1116 @@ -2148,7 +2077,7 @@
1.1117 // try to decrease the parental number in order to
1.1118 // find a precessor with same depth
1.1119
1.1120 - int d=selection->getDepth();
1.1121 + int d=xelection.single()->getDepth();
1.1122 int oldDepth=d;
1.1123 int i;
1.1124 bool found=false;
1.1125 @@ -2169,7 +2098,7 @@
1.1126 } else
1.1127 {
1.1128 // Special case, look at orientation
1.1129 - if (selection->getOrientation()==OrientRightOfCenter)
1.1130 + if (xelection.single()->getOrientation()==OrientRightOfCenter)
1.1131 num=QString ("%1").arg(num.toInt()-1);
1.1132 else
1.1133 num=QString ("%1").arg(num.toInt()+1);
1.1134 @@ -2182,8 +2111,8 @@
1.1135 {
1.1136 b=select (s);
1.1137 if (b)
1.1138 - if ( ((BranchObj*)selection)->countBranches()>0)
1.1139 - s+=",bo:"+ QString ("%1").arg( ((BranchObj*)selection)->countBranches()-1 );
1.1140 + if ( xelection.getBranch()->countBranches()>0)
1.1141 + s+=",bo:"+ QString ("%1").arg( xelection.getBranch()->countBranches()-1 );
1.1142 else
1.1143 break;
1.1144 else
1.1145 @@ -2200,36 +2129,30 @@
1.1146
1.1147 void MapEditor::selectUpperBranch()
1.1148 {
1.1149 - if (selection)
1.1150 + BranchObj *bo=xelection.getBranch();
1.1151 + if (bo && xelection.type()==Branch)
1.1152 {
1.1153 - if (typeid(*selection) == typeid(BranchObj))
1.1154 - {
1.1155 - if (selection->getOrientation()==OrientRightOfCenter)
1.1156 + if (bo->getOrientation()==OrientRightOfCenter)
1.1157 + selectPrevBranchInt();
1.1158 + else
1.1159 + if (bo->getDepth()==1)
1.1160 + selectNextBranchInt();
1.1161 + else
1.1162 + selectPrevBranchInt();
1.1163 + }
1.1164 +}
1.1165 +
1.1166 +void MapEditor::selectLowerBranch()
1.1167 +{
1.1168 + BranchObj *bo=xelection.getBranch();
1.1169 + if (bo && xelection.type()==Branch)
1.1170 + if (bo->getOrientation()==OrientRightOfCenter)
1.1171 + selectNextBranchInt();
1.1172 + else
1.1173 + if (bo->getDepth()==1)
1.1174 selectPrevBranchInt();
1.1175 else
1.1176 - if (selection->getDepth()==1)
1.1177 - selectNextBranchInt();
1.1178 - else
1.1179 - selectPrevBranchInt();
1.1180 - }
1.1181 - }
1.1182 -}
1.1183 -
1.1184 -void MapEditor::selectLowerBranch()
1.1185 -{
1.1186 - if (selection)
1.1187 - {
1.1188 - if (typeid(*selection) == typeid(BranchObj))
1.1189 - {
1.1190 - if (selection->getOrientation()==OrientRightOfCenter)
1.1191 selectNextBranchInt();
1.1192 - else
1.1193 - if (selection->getDepth()==1)
1.1194 - selectPrevBranchInt();
1.1195 - else
1.1196 - selectNextBranchInt();
1.1197 - }
1.1198 - }
1.1199 }
1.1200
1.1201
1.1202 @@ -2237,50 +2160,44 @@
1.1203 {
1.1204 BranchObj* bo;
1.1205 BranchObj* par;
1.1206 - if (selection)
1.1207 + LinkableMapObj *sel=xelection.single();
1.1208 + if (sel)
1.1209 {
1.1210 - if (typeid(*selection) == typeid(MapCenterObj))
1.1211 + if (xelection.type()== MapCenter)
1.1212 {
1.1213 - par= (BranchObj*) selection;
1.1214 + par=xelection.getBranch();
1.1215 bo=par->getLastSelectedBranch();
1.1216 if (bo)
1.1217 {
1.1218 // Workaround for reselecting on left and right side
1.1219 if (bo->getOrientation()==OrientRightOfCenter)
1.1220 + bo=par->getLastBranch();
1.1221 + if (bo)
1.1222 {
1.1223 bo=par->getLastBranch();
1.1224 - }
1.1225 - if (bo)
1.1226 - {
1.1227 - par->unselect();
1.1228 - selection=bo;
1.1229 - selection->select();
1.1230 + xelection.select(bo);
1.1231 ensureSelectionVisible();
1.1232 }
1.1233 }
1.1234 } else
1.1235 {
1.1236 - par=(BranchObj*)(selection->getParObj());
1.1237 - if (selection->getOrientation()==OrientRightOfCenter)
1.1238 + par=(BranchObj*)(sel->getParObj());
1.1239 + if (sel->getOrientation()==OrientRightOfCenter)
1.1240 {
1.1241 - if (typeid(*selection) == typeid(BranchObj) ||
1.1242 - typeid(*selection) == typeid(FloatImageObj))
1.1243 + if (xelection.type() == Branch ||
1.1244 + xelection.type() == FloatImage)
1.1245 {
1.1246 - selection->unselect();
1.1247 - selection=par;
1.1248 - selection->select();
1.1249 + xelection.select(par);
1.1250 ensureSelectionVisible();
1.1251 }
1.1252 } else
1.1253 {
1.1254 - if (typeid(*selection) == typeid(BranchObj) )
1.1255 + if (xelection.type() == Branch )
1.1256 {
1.1257 - bo=((BranchObj*)selection)->getLastSelectedBranch();
1.1258 + bo=xelection.getBranch()->getLastSelectedBranch();
1.1259 if (bo)
1.1260 {
1.1261 - selection->unselect();
1.1262 - selection=bo;
1.1263 - selection->select();
1.1264 + xelection.select(bo);
1.1265 ensureSelectionVisible();
1.1266 }
1.1267 }
1.1268 @@ -2293,12 +2210,12 @@
1.1269 {
1.1270 BranchObj* bo;
1.1271 BranchObj* par;
1.1272 -
1.1273 - if (selection)
1.1274 + LinkableMapObj *sel=xelection.single();
1.1275 + if (sel)
1.1276 {
1.1277 - if (typeid(*selection) == typeid(MapCenterObj))
1.1278 + if (xelection.type()==MapCenter)
1.1279 {
1.1280 - par= (BranchObj*) selection;
1.1281 + par=xelection.getBranch();
1.1282 bo=par->getLastSelectedBranch();
1.1283 if (bo)
1.1284 {
1.1285 @@ -2307,35 +2224,29 @@
1.1286 bo=par->getFirstBranch();
1.1287 if (bo)
1.1288 {
1.1289 - par->unselect();
1.1290 - selection=bo;
1.1291 - selection->select();
1.1292 + xelection.select(bo);
1.1293 ensureSelectionVisible();
1.1294 }
1.1295 }
1.1296 } else
1.1297 {
1.1298 - par=(BranchObj*)(selection->getParObj());
1.1299 - if (selection->getOrientation()==OrientLeftOfCenter)
1.1300 + par=(BranchObj*)(xelection.single()->getParObj());
1.1301 + if (xelection.single()->getOrientation()==OrientLeftOfCenter)
1.1302 {
1.1303 - if (typeid(*selection) == typeid(BranchObj) ||
1.1304 - typeid(*selection) == typeid(FloatImageObj))
1.1305 + if (xelection.type() == Branch ||
1.1306 + xelection.type() == FloatImage)
1.1307 {
1.1308 - selection->unselect();
1.1309 - selection=par;
1.1310 - selection->select();
1.1311 + xelection.select(par);
1.1312 ensureSelectionVisible();
1.1313 }
1.1314 } else
1.1315 {
1.1316 - if (typeid(*selection) == typeid(BranchObj) )
1.1317 + if (xelection.type() == Branch)
1.1318 {
1.1319 - bo=((BranchObj*)selection)->getLastSelectedBranch();
1.1320 + bo=xelection.getBranch()->getLastSelectedBranch();
1.1321 if (bo)
1.1322 {
1.1323 - selection->unselect();
1.1324 - selection=bo;
1.1325 - selection->select();
1.1326 + xelection.select(bo);
1.1327 ensureSelectionVisible();
1.1328 }
1.1329 }
1.1330 @@ -2346,44 +2257,35 @@
1.1331
1.1332 void MapEditor::selectFirstBranch()
1.1333 {
1.1334 - BranchObj *bo1;
1.1335 + BranchObj *bo1=xelection.getBranch();
1.1336 BranchObj *bo2;
1.1337 BranchObj* par;
1.1338 - if (selection) {
1.1339 - if (typeid(*selection) == typeid(BranchObj))
1.1340 - {
1.1341 - bo1= (BranchObj*) selection;
1.1342 - par=(BranchObj*)(bo1->getParObj());
1.1343 - bo2=par->getFirstBranch();
1.1344 - if (bo2) {
1.1345 - bo1->unselect();
1.1346 - selection=bo2;
1.1347 - selection->select();
1.1348 - ensureSelectionVisible();
1.1349 - }
1.1350 - }
1.1351 - }
1.1352 + if (bo1)
1.1353 + {
1.1354 + par=(BranchObj*)(bo1->getParObj());
1.1355 + bo2=par->getFirstBranch();
1.1356 + if (bo2) {
1.1357 + xelection.select(bo2);
1.1358 + ensureSelectionVisible();
1.1359 + }
1.1360 + }
1.1361 }
1.1362
1.1363 void MapEditor::selectLastBranch()
1.1364 {
1.1365 - BranchObj *bo1;
1.1366 + BranchObj *bo1=xelection.getBranch();
1.1367 BranchObj *bo2;
1.1368 BranchObj* par;
1.1369 - if (selection) {
1.1370 - if (typeid(*selection) == typeid(BranchObj))
1.1371 + if (bo1)
1.1372 + {
1.1373 + par=(BranchObj*)(bo1->getParObj());
1.1374 + bo2=par->getLastBranch();
1.1375 + if (bo2)
1.1376 {
1.1377 - bo1= (BranchObj*) selection;
1.1378 - par=(BranchObj*)(bo1->getParObj());
1.1379 - bo2=par->getLastBranch();
1.1380 - if (bo2) {
1.1381 - bo1->unselect();
1.1382 - selection=bo2;
1.1383 - selection->select();
1.1384 - ensureSelectionVisible();
1.1385 - }
1.1386 - }
1.1387 - }
1.1388 + xelection.select(bo2);
1.1389 + ensureSelectionVisible();
1.1390 + }
1.1391 + }
1.1392 }
1.1393
1.1394 void MapEditor::selectMapBackgroundImage ()
1.1395 @@ -2418,7 +2320,7 @@
1.1396 QString ("setMapBackgroundImage (%1)").arg(col.name()),
1.1397 QString("Set background color of map to %1").arg(col.name()));
1.1398 */
1.1399 - cout << "Trying to load "<<fn.ascii()<<endl;
1.1400 + cout << "Trying to load "<<fn.ascii()<<endl;//FIXME
1.1401 QBrush brush;
1.1402 brush.setTextureImage (QPixmap (fn));
1.1403 mapScene->setBackgroundBrush(brush);
1.1404 @@ -2436,9 +2338,9 @@
1.1405 {
1.1406 QColor oldcol=mapScene->backgroundBrush().color();
1.1407 saveState(
1.1408 - selection,
1.1409 + mapCenter,
1.1410 QString ("setMapBackgroundColor (%1)").arg(oldcol.name()),
1.1411 - selection,
1.1412 + mapCenter,
1.1413 QString ("setMapBackgroundColor (%1)").arg(col.name()),
1.1414 QString("Set background color of map to %1").arg(col.name()));
1.1415 mapScene->setBackgroundBrush(col);
1.1416 @@ -2451,15 +2353,8 @@
1.1417
1.1418 QColor MapEditor::getCurrentHeadingColor()
1.1419 {
1.1420 - if (selection)
1.1421 - {
1.1422 - if (typeid(*selection) == typeid(BranchObj) ||
1.1423 - typeid(*selection) == typeid(MapCenterObj))
1.1424 - {
1.1425 - BranchObj *bo=(BranchObj*)selection;
1.1426 - return bo->getColor();
1.1427 - }
1.1428 - }
1.1429 + BranchObj *bo=xelection.getBranch();
1.1430 + if (bo) return bo->getColor();
1.1431
1.1432 QMessageBox::warning(0,tr("Warning"),tr("Can't get color of heading,\nthere's no branch selected"));
1.1433 return Qt::black;
1.1434 @@ -2467,72 +2362,60 @@
1.1435
1.1436 void MapEditor::colorBranch (QColor c)
1.1437 {
1.1438 - if (selection)
1.1439 + BranchObj *bo=xelection.getBranch();
1.1440 + if (bo)
1.1441 {
1.1442 - if (typeid(*selection) == typeid(BranchObj) ||
1.1443 - typeid(*selection) == typeid(MapCenterObj))
1.1444 - {
1.1445 - BranchObj *bo=(BranchObj*)selection;
1.1446 - saveState(
1.1447 - selection,
1.1448 - QString ("colorBranch (%1)").arg(bo->getColor().name()),
1.1449 - selection,
1.1450 - QString ("colorBranch (%1)").arg(c.name()),
1.1451 - QString("Set color of %1 to %2").arg(getName(bo)).arg(c.name())
1.1452 - );
1.1453 - bo->setColor(c); // color branch
1.1454 - }
1.1455 + saveState(
1.1456 + bo,
1.1457 + QString ("colorBranch (%1)").arg(bo->getColor().name()),
1.1458 + bo,
1.1459 + QString ("colorBranch (%1)").arg(c.name()),
1.1460 + QString("Set color of %1 to %2").arg(getName(bo)).arg(c.name())
1.1461 + );
1.1462 + bo->setColor(c); // color branch
1.1463 }
1.1464 }
1.1465
1.1466 void MapEditor::colorSubtree (QColor c)
1.1467 {
1.1468 - if (selection)
1.1469 + BranchObj *bo=xelection.getBranch();
1.1470 + if (bo)
1.1471 {
1.1472 - if (typeid(*selection) == typeid(BranchObj) ||
1.1473 - typeid(*selection) == typeid(MapCenterObj))
1.1474 - {
1.1475 - BranchObj *bo=(BranchObj*)selection;
1.1476 - saveStateChangingPart(
1.1477 - selection,
1.1478 - selection,
1.1479 - QString ("colorSubtree (%1)").arg(c.name()),
1.1480 - QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(c.name())
1.1481 - );
1.1482 - bo->setColorSubtree (c); // color links, color childs
1.1483 - }
1.1484 + saveStateChangingPart(
1.1485 + bo,
1.1486 + bo,
1.1487 + QString ("colorSubtree (%1)").arg(c.name()),
1.1488 + QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(c.name())
1.1489 + );
1.1490 + bo->setColorSubtree (c); // color links, color childs
1.1491 }
1.1492 }
1.1493
1.1494
1.1495 void MapEditor::toggleStandardFlag(QString f)
1.1496 {
1.1497 - if (selection)
1.1498 + BranchObj *bo=xelection.getBranch();
1.1499 + if (bo)
1.1500 {
1.1501 - if (typeid(*selection) == typeid(BranchObj) ||
1.1502 - typeid(*selection) == typeid(MapCenterObj))
1.1503 + QString u,r;
1.1504 + if (bo->isSetStandardFlag(f))
1.1505 {
1.1506 - BranchObj *bo=(BranchObj*)selection;
1.1507 - QString u,r;
1.1508 - if (bo->isSetStandardFlag(f))
1.1509 - {
1.1510 - r="unsetFlag";
1.1511 - u="setFlag";
1.1512 - }
1.1513 - else
1.1514 - {
1.1515 - u="unsetFlag";
1.1516 - r="setFlag";
1.1517 - }
1.1518 - saveState(
1.1519 - selection,
1.1520 - QString("%1 (\"%2\")").arg(u).arg(f),
1.1521 - selection,
1.1522 - QString("%1 (\"%2\")").arg(r).arg(f),
1.1523 - QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo)));
1.1524 - bo->toggleStandardFlag (f,mainWindow->useFlagGroups());
1.1525 - }
1.1526 - }
1.1527 + r="unsetFlag";
1.1528 + u="setFlag";
1.1529 + }
1.1530 + else
1.1531 + {
1.1532 + u="unsetFlag";
1.1533 + r="setFlag";
1.1534 + }
1.1535 + saveState(
1.1536 + bo,
1.1537 + QString("%1 (\"%2\")").arg(u).arg(f),
1.1538 + bo,
1.1539 + QString("%1 (\"%2\")").arg(r).arg(f),
1.1540 + QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo)));
1.1541 + bo->toggleStandardFlag (f,mainWindow->useFlagGroups());
1.1542 + }
1.1543 }
1.1544
1.1545
1.1546 @@ -2557,11 +2440,9 @@
1.1547 // Searching in Note
1.1548 if (itFind->getNote().contains(s,cs))
1.1549 {
1.1550 - if (selection!=itFind)
1.1551 + if (xelection.single()!=itFind)
1.1552 {
1.1553 - if (selection) ((BranchObj*)selection)->unselect();
1.1554 - selection=itFind;
1.1555 - selection->select();
1.1556 + xelection.select(itFind);
1.1557 ensureSelectionVisible();
1.1558 }
1.1559 if (textEditor->findText(s,flags))
1.1560 @@ -2573,9 +2454,7 @@
1.1561 // Searching in Heading
1.1562 if (searching && itFind->getHeading().contains (s,cs) )
1.1563 {
1.1564 - if (selection) ((BranchObj*)selection)->unselect();
1.1565 - selection=itFind;
1.1566 - selection->select();
1.1567 + xelection.select(itFind);
1.1568 ensureSelectionVisible();
1.1569 searching=false;
1.1570 }
1.1571 @@ -2587,9 +2466,8 @@
1.1572 }
1.1573 }
1.1574 if (!searching)
1.1575 - {
1.1576 - return (BranchObj*)selection;
1.1577 - } else
1.1578 + return xelection.getBranch();
1.1579 + else
1.1580 return NULL;
1.1581 }
1.1582
1.1583 @@ -2600,16 +2478,15 @@
1.1584 }
1.1585 void MapEditor::setURL(const QString &url)
1.1586 {
1.1587 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1588 - typeid(*selection) == typeid(MapCenterObj)) )
1.1589 - {
1.1590 - BranchObj *bo=(BranchObj*)selection;
1.1591 + BranchObj *bo=xelection.getBranch();
1.1592 + if (bo)
1.1593 + {
1.1594 QString oldurl=bo->getURL();
1.1595 bo->setURL (url);
1.1596 saveState (
1.1597 - selection,
1.1598 + bo,
1.1599 QString ("setURL (\"%1\")").arg(oldurl),
1.1600 - selection,
1.1601 + bo,
1.1602 QString ("setURL (\"%1\")").arg(url),
1.1603 QString ("set URL of %1 to %2").arg(getName(bo)).arg(url)
1.1604 );
1.1605 @@ -2619,11 +2496,10 @@
1.1606
1.1607 void MapEditor::editURL()
1.1608 {
1.1609 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1610 - typeid(*selection) == typeid(MapCenterObj)) )
1.1611 + BranchObj *bo=xelection.getBranch();
1.1612 + if (bo)
1.1613 {
1.1614 bool ok;
1.1615 - BranchObj *bo=(BranchObj*)selection;
1.1616 QString text = QInputDialog::getText(
1.1617 "VYM", tr("Enter URL:"), QLineEdit::Normal,
1.1618 bo->getURL(), &ok, this );
1.1619 @@ -2635,9 +2511,9 @@
1.1620
1.1621 QString MapEditor::getURL()
1.1622 {
1.1623 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1624 - typeid(*selection) == typeid(MapCenterObj)) )
1.1625 - return ((BranchObj*)selection)->getURL();
1.1626 + BranchObj *bo=xelection.getBranch();
1.1627 + if (bo)
1.1628 + return bo->getURL();
1.1629 else
1.1630 return "";
1.1631 }
1.1632 @@ -2645,10 +2521,9 @@
1.1633 QStringList MapEditor::getURLs()
1.1634 {
1.1635 QStringList urls;
1.1636 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1637 - typeid(*selection) == typeid(MapCenterObj)) )
1.1638 + BranchObj *bo=xelection.getBranch();
1.1639 + if (bo)
1.1640 {
1.1641 - BranchObj *bo=(BranchObj*)selection;
1.1642 bo=bo->first();
1.1643 while (bo)
1.1644 {
1.1645 @@ -2662,17 +2537,16 @@
1.1646
1.1647 void MapEditor::editHeading2URL()
1.1648 {
1.1649 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1650 - typeid(*selection) == typeid(MapCenterObj)) )
1.1651 - setURL (((BranchObj*)selection)->getHeading());
1.1652 + BranchObj *bo=xelection.getBranch();
1.1653 + if (bo)
1.1654 + setURL (bo->getHeading());
1.1655 }
1.1656
1.1657 void MapEditor::editBugzilla2URL()
1.1658 {
1.1659 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1660 - typeid(*selection) == typeid(MapCenterObj)) )
1.1661 + BranchObj *bo=xelection.getBranch();
1.1662 + if (bo)
1.1663 {
1.1664 - BranchObj *bo=(BranchObj*)selection;
1.1665 QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
1.1666 setURL (url);
1.1667 }
1.1668 @@ -2680,15 +2554,14 @@
1.1669
1.1670 void MapEditor::editFATE2URL()
1.1671 {
1.1672 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1673 - typeid(*selection) == typeid(MapCenterObj)) )
1.1674 + BranchObj *bo=xelection.getBranch();
1.1675 + if (bo)
1.1676 {
1.1677 - BranchObj *bo=(BranchObj*)selection;
1.1678 QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
1.1679 saveState(
1.1680 - selection,
1.1681 + bo,
1.1682 "setURL (\""+bo->getURL()+"\")",
1.1683 - selection,
1.1684 + bo,
1.1685 "setURL (\""+url+"\")",
1.1686 QString("Use heading of %1 as link to FATE").arg(getName(bo))
1.1687 );
1.1688 @@ -2699,10 +2572,9 @@
1.1689
1.1690 void MapEditor::editVymLink()
1.1691 {
1.1692 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1693 - typeid(*selection) == typeid(MapCenterObj)) )
1.1694 + BranchObj *bo=xelection.getBranch();
1.1695 + if (bo)
1.1696 {
1.1697 - BranchObj *bo=(BranchObj*)selection;
1.1698 QStringList filters;
1.1699 filters <<"VYM map (*.vym)";
1.1700 QFileDialog *fd=new QFileDialog( this,vymName+" - " +tr("Link to another map"));
1.1701 @@ -2716,9 +2588,9 @@
1.1702 if ( fd->exec() == QDialog::Accepted )
1.1703 {
1.1704 saveState(
1.1705 - selection,
1.1706 + bo,
1.1707 "setVymLink (\""+bo->getVymLink()+"\")",
1.1708 - selection,
1.1709 + bo,
1.1710 "setVymLink (\""+fd->selectedFile()+"\")",
1.1711 QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile())
1.1712 );
1.1713 @@ -2732,14 +2604,13 @@
1.1714
1.1715 void MapEditor::deleteVymLink()
1.1716 {
1.1717 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1718 - typeid(*selection) == typeid(MapCenterObj)) )
1.1719 + BranchObj *bo=xelection.getBranch();
1.1720 + if (bo)
1.1721 {
1.1722 - BranchObj *bo=(BranchObj*)selection;
1.1723 saveState(
1.1724 - selection,
1.1725 + bo,
1.1726 "setVymLink (\""+bo->getVymLink()+"\")",
1.1727 - selection,
1.1728 + bo,
1.1729 "setVymLink (\"\")",
1.1730 QString("Unset vymlink of %1").arg(getName(bo))
1.1731 );
1.1732 @@ -2752,20 +2623,19 @@
1.1733
1.1734 void MapEditor::setHideExport(bool b)
1.1735 {
1.1736 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1737 - typeid(*selection)==typeid(FloatImageObj)))
1.1738 + BranchObj *bo=xelection.getBranch();
1.1739 + if (bo)
1.1740 {
1.1741 - OrnamentedObj *oo=(OrnamentedObj*)selection;
1.1742 - oo->setHideInExport (b);
1.1743 + bo->setHideInExport (b);
1.1744 QString u= b ? "false" : "true";
1.1745 QString r=!b ? "false" : "true";
1.1746
1.1747 saveState(
1.1748 - selection,
1.1749 + bo,
1.1750 QString ("setHideExport (%1)").arg(u),
1.1751 - selection,
1.1752 + bo,
1.1753 QString ("setHideExport (%1)").arg(r),
1.1754 - QString ("Set HideExport flag of %1 to %2").arg(getName(oo)).arg (r)
1.1755 + QString ("Set HideExport flag of %1 to %2").arg(getName(bo)).arg (r)
1.1756 );
1.1757 updateActions();
1.1758 mapCenter->reposition();
1.1759 @@ -2775,29 +2645,27 @@
1.1760
1.1761 void MapEditor::toggleHideExport()
1.1762 {
1.1763 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1764 - typeid(*selection)==typeid(FloatImageObj)))
1.1765 - setHideExport ( !((OrnamentedObj*)selection)->hideInExport() );
1.1766 + BranchObj *bo=xelection.getBranch();
1.1767 + if (bo)
1.1768 + setHideExport ( !bo->hideInExport() );
1.1769 }
1.1770
1.1771 QString MapEditor::getVymLink()
1.1772 {
1.1773 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1774 - typeid(*selection) == typeid(MapCenterObj)) )
1.1775 - {
1.1776 - return ((BranchObj*)selection)->getVymLink();
1.1777 - }
1.1778 - return "";
1.1779 + BranchObj *bo=xelection.getBranch();
1.1780 + if (bo)
1.1781 + return bo->getVymLink();
1.1782 + else
1.1783 + return "";
1.1784
1.1785 }
1.1786
1.1787 QStringList MapEditor::getVymLinks()
1.1788 {
1.1789 QStringList links;
1.1790 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1791 - typeid(*selection) == typeid(MapCenterObj)) )
1.1792 + BranchObj *bo=xelection.getBranch();
1.1793 + if (bo)
1.1794 {
1.1795 - BranchObj *bo=(BranchObj*)selection;
1.1796 bo=bo->first();
1.1797 while (bo)
1.1798 {
1.1799 @@ -2811,40 +2679,41 @@
1.1800
1.1801 void MapEditor::deleteKeepChilds()
1.1802 {
1.1803 - if (selection && (typeid(*selection) == typeid(BranchObj) ))
1.1804 - {
1.1805 - BranchObj* bo=(BranchObj*)selection;
1.1806 - BranchObj* par=(BranchObj*)(bo->getParObj());
1.1807 + BranchObj *bo=xelection.getBranch();
1.1808 + BranchObj *par;
1.1809 + if (bo)
1.1810 + {
1.1811 + par=(BranchObj*)(bo->getParObj());
1.1812 QPointF p=bo->getRelPos();
1.1813 saveStateChangingPart(
1.1814 - selection->getParObj(),
1.1815 - selection,
1.1816 + bo->getParObj(),
1.1817 + bo,
1.1818 "deleteKeepChilds ()",
1.1819 QString("Remove %1 and keep its childs").arg(getName(bo))
1.1820 );
1.1821
1.1822 - QString sel=selection->getSelectString();
1.1823 + QString sel=bo->getSelectString();
1.1824 unselect();
1.1825 par->removeBranchHere(bo);
1.1826 mapCenter->reposition();
1.1827 select (sel);
1.1828 - ((BranchObj*)selection)->move2RelPos (p);
1.1829 + xelection.getBranch()->move2RelPos (p);
1.1830 mapCenter->reposition();
1.1831 }
1.1832 }
1.1833
1.1834 void MapEditor::deleteChilds()
1.1835 {
1.1836 - if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1837 - typeid(*selection)==typeid(MapCenterObj)))
1.1838 + BranchObj *bo=xelection.getBranch();
1.1839 + if (bo)
1.1840 {
1.1841 saveStateChangingPart(
1.1842 - selection->getParObj(),
1.1843 - selection,
1.1844 + bo->getParObj(),
1.1845 + bo,
1.1846 "deleteChilds ()",
1.1847 - QString( "Remove childs of branch %1").arg(getName(selection))
1.1848 + QString( "Remove childs of branch %1").arg(getName(bo))
1.1849 );
1.1850 - ((BranchObj*)selection)->removeChilds();
1.1851 + bo->removeChilds();
1.1852 mapCenter->reposition();
1.1853 }
1.1854 }
1.1855 @@ -2896,18 +2765,16 @@
1.1856
1.1857 void MapEditor::updateNoteFlag()
1.1858 {
1.1859 - if (selection)
1.1860 - if ( (typeid(*selection) == typeid(BranchObj)) ||
1.1861 - (typeid(*selection) == typeid(MapCenterObj)) )
1.1862 - ((BranchObj*)selection)->updateNoteFlag();
1.1863 + BranchObj *bo=xelection.getBranch();
1.1864 + if (bo) bo->updateNoteFlag();
1.1865 }
1.1866
1.1867 void MapEditor::setMapAuthor (const QString &s)
1.1868 {
1.1869 saveState (
1.1870 - selection,
1.1871 + mapCenter,
1.1872 QString ("setMapAuthor (\"%1\")").arg(mapCenter->getAuthor()),
1.1873 - selection,
1.1874 + mapCenter,
1.1875 QString ("setMapAuthor (\"%1\")").arg(s),
1.1876 QString ("Set author of map to \"%1\"").arg(s)
1.1877 );
1.1878 @@ -2917,9 +2784,9 @@
1.1879 void MapEditor::setMapComment (const QString &s)
1.1880 {
1.1881 saveState (
1.1882 - selection,
1.1883 + mapCenter,
1.1884 QString ("setMapComment (\"%1\")").arg(mapCenter->getComment()),
1.1885 - selection,
1.1886 + mapCenter,
1.1887 QString ("setMapComment (\"%1\")").arg(s),
1.1888 QString ("Set comment of map")
1.1889 );
1.1890 @@ -3034,9 +2901,9 @@
1.1891 QColor col = QColorDialog::getColor( defLinkColor, this );
1.1892 if ( !col.isValid() ) return;
1.1893 saveState (
1.1894 - selection,
1.1895 + mapCenter,
1.1896 QString("setMapDefLinkColor (\"%1\")").arg(getMapDefLinkColor().name()),
1.1897 - selection,
1.1898 + mapCenter,
1.1899 QString("setMapDefLinkColor (\"%1\")").arg(col.name()),
1.1900 QString("Set link color to %1").arg(col.name())
1.1901 );
1.1902 @@ -3046,9 +2913,9 @@
1.1903
1.1904 void MapEditor::toggleScroll()
1.1905 {
1.1906 - if (selection && (typeid(*selection) == typeid(BranchObj)) )
1.1907 + BranchObj *bo=xelection.getBranch();
1.1908 + if (xelection.type()==Branch )
1.1909 {
1.1910 - BranchObj *bo=((BranchObj*)selection);
1.1911 if (bo->countBranches()==0) return;
1.1912 if (bo->getDepth()==0) return;
1.1913 QString u,r;
1.1914 @@ -3063,9 +2930,9 @@
1.1915 r="unscroll";
1.1916 }
1.1917 saveState(
1.1918 - selection,
1.1919 + bo,
1.1920 QString ("%1 ()").arg(u),
1.1921 - selection,
1.1922 + bo,
1.1923 QString ("%1 ()").arg(r),
1.1924 QString ("%1 %2").arg(r).arg(getName(bo))
1.1925 );
1.1926 @@ -3087,11 +2954,9 @@
1.1927
1.1928 void MapEditor::loadFloatImage ()
1.1929 {
1.1930 - if (selection &&
1.1931 - (typeid(*selection) == typeid(BranchObj)) ||
1.1932 - (typeid(*selection) == typeid(MapCenterObj)) )
1.1933 + BranchObj *bo=xelection.getBranch();
1.1934 + if (bo)
1.1935 {
1.1936 - BranchObj *bo=((BranchObj*)selection);
1.1937
1.1938 Q3FileDialog *fd=new Q3FileDialog( this);
1.1939 fd->setMode (Q3FileDialog::ExistingFiles);
1.1940 @@ -3122,9 +2987,9 @@
1.1941 saveState(
1.1942 (LinkableMapObj*)fio,
1.1943 "delete ()",
1.1944 - selection,
1.1945 + bo,
1.1946 QString ("loadFloatImage (%1)").arg(*it),
1.1947 - QString("Add floatimage %1 to %2").arg(*it).arg(getName(selection))
1.1948 + QString("Add floatimage %1 to %2").arg(*it).arg(getName(bo))
1.1949 );
1.1950 bo->getLastFloatImage()->setOriginalFilename(fn);
1.1951 ++it;
1.1952 @@ -3140,10 +3005,9 @@
1.1953
1.1954 void MapEditor::saveFloatImage ()
1.1955 {
1.1956 - if (selection &&
1.1957 - (typeid(*selection) == typeid(FloatImageObj)) )
1.1958 + FloatImageObj *fio=xelection.getFloatImage();
1.1959 + if (fio)
1.1960 {
1.1961 - FloatImageObj *fio=((FloatImageObj*)selection);
1.1962 QFileDialog *fd=new QFileDialog( this);
1.1963 fd->setFilters (imageIO.getFilters());
1.1964 fd->setCaption(vymName+" - " +tr("Save image"));
1.1965 @@ -3187,51 +3051,50 @@
1.1966
1.1967 void MapEditor::setFrame(const FrameType &t) // FIXME missing saveState
1.1968 {
1.1969 - if (selection &&
1.1970 - (typeid(*selection) == typeid(BranchObj)) ||
1.1971 - (typeid(*selection) == typeid(MapCenterObj)) )
1.1972 + BranchObj *bo=xelection.getBranch();
1.1973 + if (bo)
1.1974 {
1.1975 - selection->setFrameType (t);
1.1976 + bo->setFrameType (t);
1.1977 mapCenter->reposition();
1.1978 - selection->updateLink();
1.1979 + bo->updateLink();
1.1980 }
1.1981 }
1.1982
1.1983 void MapEditor::setIncludeImagesVer(bool b) // FIXME missing saveState
1.1984 {
1.1985 - if (selection &&
1.1986 - (typeid(*selection) == typeid(BranchObj)) ||
1.1987 - (typeid(*selection) == typeid(MapCenterObj)) )
1.1988 - ((BranchObj*)selection)->setIncludeImagesVer(b);
1.1989 + BranchObj *bo=xelection.getBranch();
1.1990 + if (bo)
1.1991 + {
1.1992 + bo->setIncludeImagesVer(b);
1.1993 mapCenter->reposition();
1.1994 + }
1.1995 }
1.1996
1.1997 void MapEditor::setIncludeImagesHor(bool b) // FIXME missing saveState
1.1998 {
1.1999 - if (selection &&
1.2000 - (typeid(*selection) == typeid(BranchObj)) ||
1.2001 - (typeid(*selection) == typeid(MapCenterObj)) )
1.2002 - ((BranchObj*)selection)->setIncludeImagesHor(b);
1.2003 + BranchObj *bo=xelection.getBranch();
1.2004 + if (bo)
1.2005 + {
1.2006 + bo->setIncludeImagesHor(b);
1.2007 mapCenter->reposition();
1.2008 + }
1.2009 }
1.2010
1.2011 void MapEditor::setHideLinkUnselected (bool b) // FIXME missing saveState
1.2012 {
1.2013 - if (selection &&
1.2014 - (typeid(*selection) == typeid(BranchObj)) ||
1.2015 - (typeid(*selection) == typeid(MapCenterObj)) ||
1.2016 - (typeid(*selection) == typeid(FloatImageObj)) )
1.2017 - selection->setHideLinkUnselected(b);
1.2018 + LinkableMapObj *sel=xelection.single();
1.2019 + if (sel &&
1.2020 + (xelection.type() == Branch ||
1.2021 + xelection.type() == MapCenter ||
1.2022 + xelection.type() == FloatImage ))
1.2023 + sel->setHideLinkUnselected(b);
1.2024 }
1.2025
1.2026 void MapEditor::importDirInt(BranchObj *dst, QDir d) // FIXME missing saveState
1.2027 {
1.2028 - if (selection &&
1.2029 - (typeid(*selection) == typeid(BranchObj)) ||
1.2030 - (typeid(*selection) == typeid(MapCenterObj)) )
1.2031 + BranchObj *bo=xelection.getBranch();
1.2032 + if (bo)
1.2033 {
1.2034 - BranchObj *bo;
1.2035 -
1.2036 // Traverse directories
1.2037 d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
1.2038 QFileInfoList list = d.entryInfoList();
1.2039 @@ -3276,9 +3139,8 @@
1.2040
1.2041 void MapEditor::importDir()
1.2042 {
1.2043 - if (selection &&
1.2044 - (typeid(*selection) == typeid(BranchObj)) ||
1.2045 - (typeid(*selection) == typeid(MapCenterObj)) )
1.2046 + BranchObj *bo=xelection.getBranch();
1.2047 + if (bo)
1.2048 {
1.2049 QStringList filters;
1.2050 filters <<"VYM map (*.vym)";
1.2051 @@ -3291,7 +3153,6 @@
1.2052 QString fn;
1.2053 if ( fd->exec() == QDialog::Accepted )
1.2054 {
1.2055 - BranchObj *bo=((BranchObj*)selection);
1.2056 importDirInt (bo,QDir(fd->selectedFile()) );
1.2057 mapCenter->reposition();
1.2058 scene()->update();
1.2059 @@ -3301,16 +3162,13 @@
1.2060
1.2061 void MapEditor::followXLink(int i)
1.2062 {
1.2063 - if (selection &&
1.2064 - (typeid(*selection) == typeid(BranchObj)) ||
1.2065 - (typeid(*selection) == typeid(MapCenterObj)) )
1.2066 + BranchObj *bo=xelection.getBranch();
1.2067 + if (bo)
1.2068 {
1.2069 - BranchObj *bo=((BranchObj*)selection)->XLinkTargetAt(i);
1.2070 + bo=bo->XLinkTargetAt(i);
1.2071 if (bo)
1.2072 {
1.2073 - selection->unselect();
1.2074 - selection=bo;
1.2075 - selection->select();
1.2076 + xelection.select(bo);
1.2077 ensureSelectionVisible();
1.2078 }
1.2079 }
1.2080 @@ -3318,16 +3176,15 @@
1.2081
1.2082 void MapEditor::editXLink(int i) // FIXME missing saveState
1.2083 {
1.2084 - if (selection &&
1.2085 - (typeid(*selection) == typeid(BranchObj)) ||
1.2086 - (typeid(*selection) == typeid(MapCenterObj)) )
1.2087 + BranchObj *bo=xelection.getBranch();
1.2088 + if (bo)
1.2089 {
1.2090 - XLinkObj *xlo=((BranchObj*)selection)->XLinkAt(i);
1.2091 + XLinkObj *xlo=bo->XLinkAt(i);
1.2092 if (xlo)
1.2093 {
1.2094 EditXLinkDialog dia;
1.2095 dia.setXLink (xlo);
1.2096 - dia.setSelection(selection);
1.2097 + dia.setSelection(bo);
1.2098 if (dia.exec() == QDialog::Accepted)
1.2099 {
1.2100 if (dia.useSettingsGlobal() )
1.2101 @@ -3336,7 +3193,7 @@
1.2102 setMapDefXLinkWidth (xlo->getWidth() );
1.2103 }
1.2104 if (dia.deleteXLink())
1.2105 - ((BranchObj*)selection)->deleteXLinkAt(i);
1.2106 + bo->deleteXLinkAt(i);
1.2107 }
1.2108 }
1.2109 }
1.2110 @@ -3388,12 +3245,8 @@
1.2111
1.2112 void MapEditor::ensureSelectionVisible()
1.2113 {
1.2114 - if (selection)
1.2115 - {
1.2116 - LinkableMapObj* lmo= dynamic_cast <LinkableMapObj*> (selection);
1.2117 - ensureVisible (lmo->getBBox());
1.2118 - }
1.2119 -
1.2120 + LinkableMapObj *lmo=xelection.single();
1.2121 + if (lmo) ensureVisible (lmo->getBBox() );
1.2122 }
1.2123
1.2124 void MapEditor::contextMenuEvent ( QContextMenuEvent * e )
1.2125 @@ -3406,24 +3259,20 @@
1.2126
1.2127 if (lmo)
1.2128 { // MapObj was found
1.2129 - if (selection != lmo)
1.2130 + if (xelection.single() != lmo)
1.2131 {
1.2132 // select the MapObj
1.2133 - if (selection) selection->unselect();
1.2134 - selection=lmo;
1.2135 - selection->select();
1.2136 + xelection.select(lmo);
1.2137 }
1.2138 // Context Menu
1.2139 - if (selection)
1.2140 + if (xelection.getBranch() )
1.2141 {
1.2142 - if (typeid(*selection)==typeid(BranchObj) ||
1.2143 - typeid(*selection)==typeid(MapCenterObj) )
1.2144 - {
1.2145 - // Context Menu on branch or mapcenter
1.2146 - updateActions();
1.2147 - branchContextMenu->popup(e->globalPos() );
1.2148 - }
1.2149 - if (typeid(*selection)==typeid(FloatImageObj))
1.2150 + // Context Menu on branch or mapcenter
1.2151 + updateActions();
1.2152 + branchContextMenu->popup(e->globalPos() );
1.2153 + } else
1.2154 + {
1.2155 + if (xelection.getFloatImage() )
1.2156 {
1.2157 // Context Menu on floatimage
1.2158 updateActions();
1.2159 @@ -3527,10 +3376,8 @@
1.2160 if (lmo)
1.2161 bo_begin=(BranchObj*)(lmo);
1.2162 else
1.2163 - if (selection &&
1.2164 - ((typeid(*selection) == typeid(BranchObj)) ||
1.2165 - (typeid(*selection) == typeid(MapCenterObj))) )
1.2166 - bo_begin=(BranchObj*)selection;
1.2167 + if (xelection.getBranch() )
1.2168 + bo_begin=xelection.getBranch();
1.2169 if (bo_begin)
1.2170 {
1.2171 drawingLink=true;
1.2172 @@ -3552,8 +3399,10 @@
1.2173 // Left Button Move Branches
1.2174 if (e->button() == Qt::LeftButton )
1.2175 {
1.2176 - movingObj_start.setX( p.x() - selection->x() );
1.2177 - movingObj_start.setY( p.y() - selection->y() );
1.2178 + //movingObj_start.setX( p.x() - selection->x() );// TODO replaced selection->lmo here
1.2179 + //movingObj_start.setY( p.y() - selection->y() );
1.2180 + movingObj_start.setX( p.x() - lmo->x() );
1.2181 + movingObj_start.setY( p.y() - lmo->y() );
1.2182 movingObj_orgPos.setX (lmo->x() );
1.2183 movingObj_orgPos.setY (lmo->y() );
1.2184 movingObj_orgRelPos=lmo->getRelPos();
1.2185 @@ -3563,18 +3412,17 @@
1.2186 if (mainWindow->getModMode()==ModModeCopy &&
1.2187 e->state() & Qt::ControlModifier)
1.2188 {
1.2189 - if (typeid(*selection)==typeid(BranchObj) )
1.2190 + if (xelection.type()==Branch)
1.2191 {
1.2192 copyingObj=true;
1.2193 - mapCenter->addBranch ((BranchObj*)selection);
1.2194 + mapCenter->addBranch ((BranchObj*)xelection.single());
1.2195 unselect();
1.2196 - selection=mapCenter->getLastBranch();
1.2197 - selection->select();
1.2198 + xelection.select(mapCenter->getLastBranch());
1.2199 mapCenter->reposition();
1.2200 }
1.2201 }
1.2202
1.2203 - movingObj=selection;
1.2204 + movingObj=xelection.single();
1.2205 } else
1.2206 // Middle Button Toggle Scroll
1.2207 // (On Mac OS X this won't work, but we still have
1.2208 @@ -3601,9 +3449,10 @@
1.2209 void MapEditor::mouseMoveEvent(QMouseEvent* e)
1.2210 {
1.2211 QPointF p = mapToScene(e->pos());
1.2212 + LinkableMapObj *lmosel=xelection.single();
1.2213
1.2214 // Move the selected MapObj
1.2215 - if ( selection && movingObj)
1.2216 + if ( lmosel && movingObj)
1.2217 {
1.2218 // reset cursor if we are moving and don't copy
1.2219 if (mainWindow->getModMode()!=ModModeCopy)
1.2220 @@ -3611,7 +3460,7 @@
1.2221
1.2222 // To avoid jumping of the sceneView, only
1.2223 // ensureSelectionVisible, if not tmp linked
1.2224 - if (!selection->hasParObjTmp())
1.2225 + if (!lmosel->hasParObjTmp())
1.2226 ensureSelectionVisible ();
1.2227
1.2228 // Now move the selection, but add relative position
1.2229 @@ -3619,51 +3468,47 @@
1.2230 // mousepointer. (This avoids flickering resp. jumping
1.2231 // of selection back to absPos)
1.2232
1.2233 - LinkableMapObj *lmosel;
1.2234 - lmosel = dynamic_cast <LinkableMapObj*> (selection);
1.2235 -
1.2236 // Check if we could link
1.2237 LinkableMapObj* lmo=mapCenter->findMapObj(p, lmosel);
1.2238
1.2239
1.2240 - if (typeid(*selection) == typeid(FloatImageObj))
1.2241 + FloatObj *fio=xelection.getFloatImage();
1.2242 + if (fio)
1.2243 {
1.2244 - FloatObj *fo=(FloatObj*)selection;
1.2245 - fo->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.2246 - fo->setRelPos();
1.2247 - fo->updateLink(); //no need for reposition, if we update link here
1.2248 + fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.2249 + fio->setRelPos();
1.2250 + fio->updateLink(); //no need for reposition, if we update link here
1.2251
1.2252 // Relink float to new mapcenter or branch, if shift is pressed
1.2253 // Only relink, if selection really has a new parent
1.2254 if ( (e->modifiers()==Qt::ShiftModifier) && lmo &&
1.2255 ( (typeid(*lmo)==typeid(BranchObj)) ||
1.2256 (typeid(*lmo)==typeid(MapCenterObj)) ) &&
1.2257 - ( lmo != fo->getParObj())
1.2258 + ( lmo != fio->getParObj())
1.2259 )
1.2260 {
1.2261 - if (typeid(*fo) == typeid(FloatImageObj) &&
1.2262 + if (typeid(*fio) == typeid(FloatImageObj) &&
1.2263 ( (typeid(*lmo)==typeid(BranchObj) ||
1.2264 typeid(*lmo)==typeid(MapCenterObj)) ))
1.2265 {
1.2266
1.2267 // Also save the move which was done so far
1.2268 - FloatImageObj *fio=(FloatImageObj*)selection;
1.2269 QString pold=qpointfToString(movingObj_orgRelPos);
1.2270 QString pnow=qpointfToString(fio->getRelPos());
1.2271 saveState(
1.2272 - selection,
1.2273 + fio,
1.2274 "moveRel "+pold,
1.2275 - selection,
1.2276 + fio,
1.2277 "moveRel "+pnow,
1.2278 - QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow));
1.2279 + QString("Move %1 to relativ position %2").arg(getName(fio)).arg(pnow));
1.2280 fio->getParObj()->requestReposition();
1.2281 mapCenter->reposition();
1.2282
1.2283 - cout << "current relPos="<<movingObj_orgRelPos<<endl;
1.2284 + cout << "current relPos="<<movingObj_orgRelPos<<endl; // FIXME testing
1.2285 linkTo (lmo->getSelectString());
1.2286 cout << "setting movingObj\n";
1.2287 - movingObj=(MapObj*)selection;
1.2288 - movingObj_orgRelPos=selection->getRelPos();
1.2289 + movingObj=lmosel;
1.2290 + movingObj_orgRelPos=lmosel->getRelPos();
1.2291 cout <<"ok 0\n";
1.2292
1.2293 mapCenter->reposition();
1.2294 @@ -3699,10 +3544,7 @@
1.2295 // reposition subbranch
1.2296 lmosel->reposition();
1.2297
1.2298 - if (lmo && (lmo!=selection) &&
1.2299 - (typeid(*lmo) == typeid(BranchObj) ||
1.2300 - (typeid(*lmo) == typeid(MapCenterObj) )
1.2301 - ) )
1.2302 + if (lmo && (lmo!=lmosel) && xelection.getBranch() )
1.2303 {
1.2304 if (e->modifiers()==Qt::ControlModifier)
1.2305 {
1.2306 @@ -3748,6 +3590,7 @@
1.2307 {
1.2308 QPointF p = mapToScene(e->pos());
1.2309 LinkableMapObj *dst;
1.2310 + LinkableMapObj *lmosel=xelection.single();
1.2311 // Have we been picking color?
1.2312 if (pickingColor)
1.2313 {
1.2314 @@ -3755,7 +3598,7 @@
1.2315 setCursor (Qt::ArrowCursor);
1.2316 // Check if we are over another branch
1.2317 dst=mapCenter->findMapObj(p, NULL);
1.2318 - if (dst && selection)
1.2319 + if (dst && lmosel)
1.2320 {
1.2321 if (e->state() & Qt::ShiftModifier)
1.2322 colorBranch (((BranchObj*)(dst))->getColor());
1.2323 @@ -3771,7 +3614,7 @@
1.2324 drawingLink=false;
1.2325 // Check if we are over another branch
1.2326 dst=mapCenter->findMapObj(p, NULL);
1.2327 - if (dst && selection)
1.2328 + if (dst && lmosel)
1.2329 {
1.2330 tmpXLink->setEnd ( ((BranchObj*)(dst)) );
1.2331 tmpXLink->updateXLink();
1.2332 @@ -3786,53 +3629,52 @@
1.2333 }
1.2334
1.2335 // Have we been moving something?
1.2336 - if ( selection && movingObj )
1.2337 + if ( lmosel && movingObj )
1.2338 {
1.2339 - if(typeid(*selection)==typeid (FloatImageObj))
1.2340 + FloatImageObj *fo=xelection.getFloatImage();
1.2341 + if(fo)
1.2342 {
1.2343 // Moved FloatObj. Maybe we need to reposition
1.2344 - FloatImageObj *fo=(FloatImageObj*)selection;
1.2345 QString pold=qpointfToString(movingObj_orgRelPos);
1.2346 QString pnow=qpointfToString(fo->getRelPos());
1.2347 saveState(
1.2348 - selection,
1.2349 + fo,
1.2350 "moveRel "+pold,
1.2351 - selection,
1.2352 + fo,
1.2353 "moveRel "+pnow,
1.2354 - QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow));
1.2355 -
1.2356 - selection->getParObj()->requestReposition();
1.2357 + QString("Move %1 to relativ position %2").arg(getName(fo)).arg(pnow));
1.2358 +
1.2359 + fo->getParObj()->requestReposition();
1.2360 mapCenter->reposition();
1.2361 }
1.2362
1.2363 // Check if we are over another branch, but ignore
1.2364 // any found LMOs, which are FloatObjs
1.2365 - dst=mapCenter->findMapObj(mapToScene(e->pos() ),
1.2366 - ((LinkableMapObj*)selection) );
1.2367 + dst=mapCenter->findMapObj(mapToScene(e->pos() ), lmosel);
1.2368
1.2369 if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj)))
1.2370 dst=NULL;
1.2371
1.2372 - if (typeid(*selection) == typeid(MapCenterObj) )
1.2373 + if (xelection.type() == MapCenter )
1.2374 { // FIXME The MapCenter was moved, no savestate yet
1.2375 }
1.2376
1.2377 - if (typeid(*selection) == typeid(BranchObj) )
1.2378 + if (xelection.type() == Branch )
1.2379 { // A branch was moved
1.2380
1.2381 // save the position in case we link to mapcenter
1.2382 - QPointF savePos=QPointF (selection->x(),selection->y() );
1.2383 + QPointF savePos=QPointF (lmosel->getAbsPos() );
1.2384
1.2385 // Reset the temporary drawn link to the original one
1.2386 - ((LinkableMapObj*)selection)->unsetParObjTmp();
1.2387 + lmosel->unsetParObjTmp();
1.2388
1.2389 // For Redo we may need to save original selection
1.2390 - QString preSelStr=selection->getSelectString();
1.2391 + QString preSelStr=lmosel->getSelectString();
1.2392
1.2393 copyingObj=false;
1.2394 if (dst )
1.2395 {
1.2396 - BranchObj* bsel=(BranchObj*)selection;
1.2397 + BranchObj* bsel=xelection.getBranch();
1.2398 BranchObj* bdst=(BranchObj*)dst;
1.2399
1.2400 QString preParStr=(bsel->getParObj())->getSelectString();
1.2401 @@ -3855,7 +3697,7 @@
1.2402 bsel->linkTo (bdst,-1);
1.2403 if (dst->getDepth()==0) bsel->move (savePos);
1.2404 }
1.2405 - QString postSelStr=selection->getSelectString();
1.2406 + QString postSelStr=lmosel->getSelectString();
1.2407 QString postNum=QString::number (bsel->getNum(),10);
1.2408
1.2409 QString undoCom="linkTo (\""+
1.2410 @@ -3871,17 +3713,17 @@
1.2411 preSelStr, redoCom,
1.2412 QString("Relink %1 to %2").arg(getName(bsel)).arg(getName(dst)) );
1.2413 } else
1.2414 - if (selection->getDepth()==1)
1.2415 + if (lmosel->getDepth()==1)
1.2416 {
1.2417 // The select string might be different _after_ moving around.
1.2418 // Therefor reposition and then use string of old selection, too
1.2419 mapCenter->reposition();
1.2420
1.2421 - QString ps=qpointfToString ( ((BranchObj*)selection)->getRelPos() );
1.2422 + QString ps=qpointfToString ( lmosel->getRelPos() );
1.2423 saveState(
1.2424 - selection->getSelectString(), "moveRel "+qpointfToString(movingObj_orgRelPos),
1.2425 + lmosel->getSelectString(), "moveRel "+qpointfToString(movingObj_orgRelPos),
1.2426 preSelStr, "moveRel "+ps,
1.2427 - QString("Move %1 to relative position %2").arg(getName(selection)).arg(ps));
1.2428 + QString("Move %1 to relative position %2").arg(getName(lmosel)).arg(ps));
1.2429
1.2430 }
1.2431 // Draw the original link, before selection was moved around
1.2432 @@ -3907,9 +3749,7 @@
1.2433 LinkableMapObj *lmo=mapCenter->findMapObj(p, NULL);
1.2434 if (lmo) { // MapObj was found
1.2435 // First select the MapObj than edit heading
1.2436 - if (selection) selection->unselect();
1.2437 - selection=lmo;
1.2438 - selection->select();
1.2439 + xelection.select(lmo);
1.2440 mainWindow->editHeading();
1.2441 }
1.2442 }
1.2443 @@ -3943,9 +3783,8 @@
1.2444
1.2445 void MapEditor::dropEvent(QDropEvent *event)
1.2446 {
1.2447 - if (selection &&
1.2448 - (typeid(*selection) == typeid(BranchObj)) ||
1.2449 - (typeid(*selection) == typeid(MapCenterObj)))
1.2450 + BranchObj *sel=xelection.getBranch();
1.2451 + if (sel)
1.2452 {
1.2453 QList <QUrl> uris;
1.2454 if (event->mimeData()->hasImage())
1.2455 @@ -3964,7 +3803,7 @@
1.2456 BranchObj *bo;
1.2457 for (int i=0; i<uris.count();++i)
1.2458 {
1.2459 - bo=((BranchObj*)selection)->addBranch();
1.2460 + bo=sel->addBranch();
1.2461 if (bo)
1.2462 {
1.2463 s=uris.at(i).toLocalFile();
1.2464 @@ -4060,11 +3899,9 @@
1.2465
1.2466 void MapEditor::addFloatImageInt (const QPixmap &img)
1.2467 {
1.2468 - if (selection &&
1.2469 - (typeid(*selection) == typeid(BranchObj)) ||
1.2470 - (typeid(*selection) == typeid(MapCenterObj)) )
1.2471 + BranchObj *bo=xelection.getBranch();
1.2472 + if (bo)
1.2473 {
1.2474 - BranchObj *bo=((BranchObj*)selection);
1.2475 //FIXME XXX saveStateChangingPart(selection,QString("Add floatimage to %1").arg(getName(bo)));
1.2476 //QString fn=fd->selectedFile();
1.2477 //lastImageDir=fn.left(fn.findRev ("/"));