1.1 --- a/mapeditor.cpp Tue Sep 06 15:04:50 2005 +0000
1.2 +++ b/mapeditor.cpp Mon Sep 12 19:52:51 2005 +0000
1.3 @@ -355,6 +355,11 @@
1.4 fileName="unnamed";
1.5 mapName="";
1.6
1.7 +
1.8 + undosTotal=15;
1.9 + undosAvail=0;
1.10 + undoNum=0;
1.11 +
1.12 // Initialize find routine
1.13 itFind=NULL;
1.14 EOFind=false;
1.15 @@ -480,21 +485,26 @@
1.16 {
1.17 // Create unique temporary directories
1.18 char tmpdir[]="/tmp/vym-XXXXXX";
1.19 - bakMapDir=mkdtemp(tmpdir);
1.20 - makeSubDirs(bakMapDir);
1.21 - // FIXME set permissions and maybe use QT method for portability
1.22 + // TODO set permissions and maybe use QT method for portability
1.23 + tmpMapDir=mkdtemp(tmpdir);
1.24 + QString bakMapDir;
1.25 + for (int i=undosTotal;i>0;i--)
1.26 + {
1.27 + bakMapDir=tmpMapDir+QString("/undo-%1").arg(i);
1.28 + makeSubDirs(bakMapDir);
1.29 + }
1.30 }
1.31
1.32 void MapEditor::delTmpDirs()
1.33 {
1.34 - //FIXME delete tmp directory, better use QT methods here:
1.35 - system ( "rm -rf "+ bakMapDir );
1.36 + removeDir (QDir(tmpMapDir));
1.37 }
1.38
1.39
1.40 void MapEditor::makeSubDirs(const QString &s)
1.41 {
1.42 QDir d(s);
1.43 + d.mkdir(s);
1.44 d.mkdir ("images");
1.45 d.mkdir ("flags");
1.46 }
1.47 @@ -502,7 +512,7 @@
1.48
1.49 QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSelection)
1.50 {
1.51 - // tmpdir temporary directory to which data will be writte
1.52 + // tmpdir temporary directory to which data will be written
1.53 // prefix mapname, which will be appended to images etc.
1.54 // writeflags Only write flags for "real" save of map, not undo
1.55 // offset offset of bbox of whole map in canvas.
1.56 @@ -560,7 +570,7 @@
1.57 else
1.58 if (selection && typeid(*selection)==typeid(BranchObj))
1.59 // This is used if selected branch is saved from mainwindow
1.60 - s+=((BranchObj*)(selection))->saveToDir(tmpdir,prefix,offset);
1.61 + s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset);
1.62 }
1.63
1.64 // Save local settings
1.65 @@ -580,44 +590,70 @@
1.66
1.67 void MapEditor::saveState()
1.68 {
1.69 - saveState (CompleteMap,NULL,"","");
1.70 + // Save complete map
1.71 + saveState (CompleteMap,"",NULL,"",NULL);
1.72 }
1.73
1.74 void MapEditor::saveState(LinkableMapObj *undoSel)
1.75 {
1.76 - saveState (PartOfMap,undoSel,"","");
1.77 + // save the given part of the map
1.78 + saveState (PartOfMap,"",undoSel,"",NULL);
1.79 }
1.80
1.81 -void MapEditor::saveState(const QString & uc, const QString &rc)
1.82 +void MapEditor::saveState(const QString &uc, const QString &rc)
1.83 {
1.84 - LinkableMapObj *undoSel;
1.85 + // selection does not change during action,
1.86 + // so just save commands for undo and redo
1.87 + LinkableMapObj *unsel;
1.88 if (selection)
1.89 - undoSel=selection;
1.90 + unsel=selection;
1.91 else
1.92 - undoSel=NULL;
1.93 - saveState (UndoCommand,undoSel,uc,rc);
1.94 + unsel=NULL;
1.95 + saveState (UndoCommand,uc,unsel,rc,unsel);
1.96 }
1.97
1.98 -void MapEditor::saveState(const SaveMode &savemode, LinkableMapObj *undoSel, const QString &undoCom, const QString &redoCom)
1.99 +void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel)
1.100 {
1.101 + saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL);
1.102 +}
1.103 +
1.104 +void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel)
1.105 +{
1.106 + // Main saveState
1.107 +
1.108 if (blockSaveState) return;
1.109
1.110 + /* TODO remove after testing
1.111 + cout << "ME::saveState() begin\n"<<endl;
1.112 + cout << " undosTotal="<<undosTotal<<endl;
1.113 + cout << " undosAvail="<<undosAvail<<endl;
1.114 + cout << " undoNum="<<undoNum<<endl;
1.115 + cout << " ---------------------------"<<endl;
1.116 + */
1.117 setChanged();
1.118
1.119 + // Find out current undo directory
1.120 + if (undosAvail<undosTotal) undosAvail++;
1.121 + undoNum++;
1.122 + if (undoNum>undosTotal) undoNum=1;
1.123 +
1.124 + QString backupXML;
1.125 + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
1.126 + QString bakMapPath=bakMapDir+"/map.xml";
1.127 +
1.128 +
1.129 // Save current selection
1.130 - redoCommand=redoCom;
1.131 - if (selection)
1.132 - redoSelection=selection->getSelectString();
1.133 - else
1.134 - redoSelection="";
1.135 + QString redoSelection="";
1.136 + if (redoSel)
1.137 + redoSelection=redoSel->getSelectString();
1.138
1.139 // Save the object, which should be undone
1.140 + QString undoSelection="";
1.141 if (undoSel)
1.142 undoSelection=undoSel->getSelectString();
1.143 - else
1.144 - undoSelection="";
1.145
1.146 // Save depending on how much needs to be saved
1.147 + QString undoCommand="";
1.148 if (savemode==UndoCommand)
1.149 {
1.150 undoCommand=undoCom;
1.151 @@ -625,28 +661,43 @@
1.152 }
1.153 else if (savemode==PartOfMap && undoSel)
1.154 {
1.155 - undoCommand="undoPart (\""+undoSelection+"\")";
1.156 + undoCommand="undoPart (\""+ undoSelection+"\",\""+bakMapPath+"\")";
1.157 backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel);
1.158 } else
1.159 {
1.160 - undoCommand="undoMap ()";
1.161 + undoCommand="undoMap (\""+bakMapPath+"\")";
1.162 backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),NULL);
1.163 undoSelection="";
1.164 }
1.165 - /* FIXME testing
1.166 - cout << "ME::saveState()\n";
1.167 - cout << " undoCom="<<undoCommand<<endl;
1.168 - cout << " undoSel="<<undoSelection<<endl;
1.169 - cout << " ---------------------------"<<endl;
1.170 - cout << " redoCom="<<redoCommand<<endl;
1.171 - cout << " redoSel="<<redoSelection<<endl<<endl;
1.172 + if (!backupXML.isEmpty())
1.173 + // Write XML Data to disk
1.174 + saveStringToDisk (QString(bakMapPath),backupXML);
1.175 +
1.176 + SimpleSettings set;
1.177 + set.setEntry (QString("undoCommand"),undoCommand);
1.178 + set.setEntry (QString("undoSelection"),undoSelection);
1.179 + set.setEntry (QString("redoCommand"),redoCom);
1.180 + set.setEntry (QString("redoSelection"),redoSelection);
1.181 + set.writeSettings(QString(bakMapDir+"/commands"));
1.182 +
1.183 + /* TODO remove after testing
1.184 + cout << " into="<< bakMapDir<<endl;
1.185 + cout << " undosAvail="<<undosAvail<<endl;
1.186 + cout << " undoNum="<<undoNum<<endl;
1.187 + cout << " ---------------------------"<<endl;
1.188 + cout << " undoCom="<<undoCommand<<endl;
1.189 + cout << " undoSel="<<undoSelection<<endl;
1.190 + cout << " ---------------------------"<<endl;
1.191 + cout << " redoCom="<<redoCom<<endl;
1.192 + cout << " redoSel="<<redoSelection<<endl;
1.193 + cout << " ---------------------------"<<endl<<endl;
1.194 */
1.195 }
1.196
1.197 void MapEditor::parseAtom(const QString &atom)
1.198 {
1.199 API api;
1.200 - QString s;
1.201 + QString s,t;
1.202 int x,y;
1.203 bool ok;
1.204
1.205 @@ -655,7 +706,7 @@
1.206 QString com=api.command();
1.207
1.208 // External commands
1.209 - if (com==QString("moveBranchUp"))
1.210 + if (com=="moveBranchUp")
1.211 moveBranchUp();
1.212 else if (com=="moveBranchDown")
1.213 moveBranchDown();
1.214 @@ -686,16 +737,16 @@
1.215 // Get number in parent
1.216 x=api.parInt (ok,1);
1.217 if (ok)
1.218 - ((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),x);
1.219 + ((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),x);
1.220 } else if (typeid(*dst) == typeid(MapCenterObj) )
1.221 {
1.222 - ((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1);
1.223 + ((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),-1);
1.224 // Get coordinates of mainbranch
1.225 x=api.parInt (ok,2);
1.226 if (ok)
1.227 {
1.228 y=api.parInt (ok,3);
1.229 - if (ok) ((BranchObj*)(selection))->move (x,y);
1.230 + if (ok) ((BranchObj*)selection)->move (x,y);
1.231 }
1.232 }
1.233 }
1.234 @@ -723,18 +774,18 @@
1.235 if (ok) setVymLink(s);
1.236 }
1.237 }
1.238 -
1.239 // Internal commands, used for undo etc.
1.240 else if (com==QString("undoMap"))
1.241 {
1.242 - if (api.checkParamCount(0))
1.243 - undoXML("");
1.244 + if (api.checkParamCount(1))
1.245 + undoXML("",api.parString (ok,0));
1.246 } else if (com==QString("undoPart"))
1.247 {
1.248 - if (api.checkParamCount(1))
1.249 + if (api.checkParamCount(2))
1.250 {
1.251 s=api.parString (ok,0);
1.252 - undoXML(s);
1.253 + t=api.parString (ok,1);
1.254 + undoXML(s,t);
1.255 }
1.256 } else if (com=="select")
1.257 if (api.checkParamCount(1))
1.258 @@ -743,7 +794,10 @@
1.259 if (ok) select (s);
1.260 }
1.261 else
1.262 + {
1.263 api.setError ("Unknown command in: "+atom);
1.264 + cout << "ME::parse api should have error now...\n";
1.265 + }
1.266
1.267 // Any errors?
1.268 if (api.error())
1.269 @@ -908,8 +962,10 @@
1.270 handler.setMapEditor( this );
1.271 handler.setTmpDir (filePath.left(filePath.findRev("/",-1))); // needed to load files with rel. path
1.272 handler.setLoadMode (lmode);
1.273 + blockSaveState=true;
1.274 bool ok = reader.parse( source );
1.275 blockReposition=false;
1.276 + blockSaveState=false;
1.277 file.close();
1.278 if ( ok )
1.279 {
1.280 @@ -955,35 +1011,14 @@
1.281 fname=fileName;
1.282
1.283
1.284 - // Check if fname is writeable
1.285 - QFile file( fileDir+fname);
1.286 - if (!file.open( IO_WriteOnly ) )
1.287 - {
1.288 - QMessageBox::critical( 0, tr( "Critical Save Error" ),
1.289 - tr("Couldn't write to ") +fileDir+fname);
1.290 - return 1;
1.291 - }
1.292 - file.close();
1.293 -
1.294 QString saveFile;
1.295 if (savemode==CompleteMap || selection==NULL)
1.296 saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),NULL);
1.297 else
1.298 saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),selection);
1.299
1.300 - file.setName ( fileDir + fname);
1.301 - if ( !file.open( IO_WriteOnly ) )
1.302 - {
1.303 - // This should neverever happen
1.304 - QMessageBox::critical(0, tr("Critcal Save error"),"MapEditor::save() Couldn't open "+file.name());
1.305 + if (!saveStringToDisk(fileDir+fname,saveFile))
1.306 return 1;
1.307 - }
1.308 -
1.309 - // Write it finally, and write in UTF8, no matter what
1.310 - QTextStream ts( &file );
1.311 - ts.setEncoding (QTextStream::UnicodeUTF8);
1.312 - ts << saveFile;
1.313 - file.close();
1.314
1.315 if (returnCode==0)
1.316 {
1.317 @@ -1074,7 +1109,7 @@
1.318 frame->setZ(0);
1.319 frame->show();
1.320 }
1.321 - /* FIXME testing
1.322 + /* TODO remove after testing
1.323 QCanvasLine *l=new QCanvasLine (mapCanvas);
1.324 l->setPoints (0,0,mapRect.width(),mapRect.height());
1.325 l->setPen (QPen(QColor(black), 1));
1.326 @@ -1227,6 +1262,93 @@
1.327 }
1.328 }
1.329
1.330 +void MapEditor::exportLaTeX()
1.331 +{
1.332 + // FIXME still experimental
1.333 + QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (LaTex)"));
1.334 + fd->addFilter ("TEX (*.tex)");
1.335 + fd->setCaption("VYM - Export (LaTex) (still experimental)");
1.336 + fd->setMode( QFileDialog::AnyFile );
1.337 + fd->show();
1.338 +
1.339 + if ( fd->exec() == QDialog::Accepted )
1.340 + {
1.341 + if (QFile (fd->selectedFile()).exists() )
1.342 + {
1.343 + QMessageBox mb( "VYM",
1.344 + tr("The file ") + fd->selectedFile() +
1.345 + tr(" exists already. Do you want to overwrite it?"),
1.346 + QMessageBox::Warning,
1.347 + QMessageBox::Yes | QMessageBox::Default,
1.348 + QMessageBox::Cancel | QMessageBox::Escape,
1.349 + QMessageBox::NoButton );
1.350 +
1.351 + mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1.352 + mb.setButtonText( QMessageBox::No, tr("Cancel"));
1.353 + Export ex;
1.354 + switch( mb.exec() )
1.355 + {
1.356 + case QMessageBox::Yes:
1.357 + // save
1.358 + break;;
1.359 + case QMessageBox::Cancel:
1.360 + // do nothing
1.361 + return;
1.362 + break;
1.363 + }
1.364 + }
1.365 + Export ex;
1.366 + ex.setPath (fd->selectedFile() );
1.367 + ex.setMapCenter(mapCenter);
1.368 + ex.exportLaTeX();
1.369 + }
1.370 +}
1.371 +
1.372 +void MapEditor::exportOOPresentation()
1.373 +{
1.374 + // FIXME still experimental
1.375 + /*
1.376 + QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (Open Office 1.3.x Presentation)"));
1.377 + fd->addFilter ("Open Office 1.3.x presentation (*.sxi)");
1.378 + fd->setCaption("VYM - Export (Open Office 1.3.x presentation) (still experimental)");
1.379 + fd->setMode( QFileDialog::AnyFile );
1.380 + fd->show();
1.381 +
1.382 + if ( fd->exec() == QDialog::Accepted )
1.383 + {
1.384 + if (QFile (fd->selectedFile()).exists() )
1.385 + {
1.386 + QMessageBox mb( "VYM",
1.387 + tr("The file ") + fd->selectedFile() +
1.388 + tr(" exists already. Do you want to overwrite it?"),
1.389 + QMessageBox::Warning,
1.390 + QMessageBox::Yes | QMessageBox::Default,
1.391 + QMessageBox::Cancel | QMessageBox::Escape,
1.392 + QMessageBox::NoButton );
1.393 +
1.394 + mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1.395 + mb.setButtonText( QMessageBox::No, tr("Cancel"));
1.396 + Export ex;
1.397 + switch( mb.exec() )
1.398 + {
1.399 + case QMessageBox::Yes:
1.400 + // save
1.401 + break;;
1.402 + case QMessageBox::Cancel:
1.403 + // do nothing
1.404 + return;
1.405 + break;
1.406 + }
1.407 + }
1.408 + */
1.409 + Export ex;
1.410 + //ex.setPath (fd->selectedFile() );
1.411 + ex.setMapCenter(mapCenter);
1.412 + ex.exportOOPresentation();
1.413 +// }
1.414 +}
1.415 +
1.416 +
1.417
1.418 void MapEditor::exportXML(const QString &dir)
1.419 {
1.420 @@ -1282,7 +1404,7 @@
1.421 to=clipboardME->getMapCenter()->getLastBranch();
1.422 if (to)
1.423 {
1.424 - from=(BranchObj*)(selection);
1.425 + from=(BranchObj*)selection;
1.426 to->copy(from);
1.427
1.428 // keep position relative to parent
1.429 @@ -1310,7 +1432,7 @@
1.430 to=clipboardME->getMapCenter()->getLastFloatImage();
1.431 if (to)
1.432 {
1.433 - from=(FloatImageObj*)(selection);
1.434 + from=(FloatImageObj*)selection;
1.435 to->copy(from);
1.436
1.437 // select data in clipboard
1.438 @@ -1319,9 +1441,7 @@
1.439 // repositioning makes testing nicer,
1.440 // but is not needed usually:
1.441 if (clipboardME->isVisible())
1.442 - {
1.443 clipboardME->getMapCenter()->reposition();
1.444 - }
1.445 else
1.446 clipboardME->hide();
1.447 }
1.448 @@ -1329,36 +1449,143 @@
1.449 }
1.450 }
1.451
1.452 +void MapEditor::redo()
1.453 +{
1.454 + // Finish open lineEdits
1.455 + if (lineedit) finishedLineEditNoSave();
1.456 +
1.457 + blockSaveState=true;
1.458 +
1.459 + // Find out current undo directory
1.460 + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
1.461 +
1.462 + // Restore variables
1.463 + QString undoCommand;
1.464 + QString undoSelection;
1.465 + QString redoCommand;
1.466 + QString redoSelection;
1.467 + SimpleSettings set;
1.468 + set.readSettings(QString(bakMapDir+"/commands"));
1.469 + undoCommand=set.readEntry ("undoCommand");
1.470 + undoSelection=set.readEntry ("undoSelection");
1.471 + redoCommand=set.readEntry ("redoCommand");
1.472 + redoSelection=set.readEntry ("redoSelection");
1.473 +
1.474 + // select object before redo
1.475 + if (!redoSelection.isEmpty())
1.476 + select (redoSelection);
1.477 +
1.478 +/* TODO remove testing
1.479 + cout << "ME::redo() begin\n";
1.480 + cout << " undosTotal="<<undosTotal<<endl;
1.481 + cout << " undosAvail="<<undosAvail<<endl;
1.482 + cout << " undoNum="<<undoNum<<endl;
1.483 + cout << " ---------------------------"<<endl;
1.484 + cout << " undoCom="<<undoCommand<<endl;
1.485 + cout << " undoSel="<<undoSelection<<endl;
1.486 + cout << " ---------------------------"<<endl;
1.487 + cout << " redoCom="<<redoCommand<<endl;
1.488 + cout << " redoSel="<<redoSelection<<endl;
1.489 + cout << " ---------------------------"<<endl;
1.490 +*/
1.491 + parseAtom (undoCommand);
1.492 + mapCenter->reposition();
1.493 +
1.494 + //mapChanged=false; FIXME still needed???
1.495 +
1.496 + //if (!redoSelection.isEmpty())
1.497 + // select (redoSelection);
1.498 +
1.499 + undosAvail--;
1.500 + if (undosAvail<1)
1.501 + // Undo not longer available now
1.502 + actionEditUndo->setEnabled (false);
1.503 + else
1.504 + undoNum--; if (undoNum<1) undoNum=undosTotal;
1.505 +
1.506 + blockSaveState=false;
1.507 +/* TODO remove testing
1.508 + cout << "ME::redo() end\n";
1.509 + cout << " undosAvail="<<undosAvail<<endl;
1.510 + cout << " undoNum="<<undoNum<<endl;
1.511 + cout << " ---------------------------"<<endl<<endl;
1.512 +*/
1.513 +}
1.514 +
1.515 void MapEditor::undo()
1.516 {
1.517 // Finish open lineEdits
1.518 if (lineedit) finishedLineEditNoSave();
1.519
1.520 + blockSaveState=true;
1.521 +
1.522 + // Find out current undo directory
1.523 + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
1.524 +
1.525 + // Restore variables
1.526 + QString undoCommand;
1.527 + QString undoSelection;
1.528 + QString redoCommand;
1.529 + QString redoSelection;
1.530 + SimpleSettings set;
1.531 + set.readSettings(QString(bakMapDir+"/commands"));
1.532 + undoCommand= set.readEntry ("undoCommand");
1.533 + undoSelection=set.readEntry ("undoSelection");
1.534 + redoCommand= set.readEntry ("redoCommand");
1.535 + redoSelection=set.readEntry ("redoSelection");
1.536 +
1.537 // select object before undo
1.538 if (!undoSelection.isEmpty())
1.539 select (undoSelection);
1.540
1.541 +/* TODO remove testing
1.542 + cout << "ME::undo() begin\n";
1.543 + cout << " undosTotal="<<undosTotal<<endl;
1.544 + cout << " undosAvail="<<undosAvail<<endl;
1.545 + cout << " undoNum="<<undoNum<<endl;
1.546 + cout << " ---------------------------"<<endl;
1.547 + cout << " undoCom="<<undoCommand<<endl;
1.548 + cout << " undoSel="<<undoSelection<<endl;
1.549 + cout << " ---------------------------"<<endl;
1.550 + cout << " redoCom="<<redoCommand<<endl;
1.551 + cout << " redoSel="<<redoSelection<<endl;
1.552 + cout << " ---------------------------"<<endl;
1.553 +*/
1.554 parseAtom (undoCommand);
1.555 mapCenter->reposition();
1.556
1.557 - // Undo not longer available now
1.558 - actionEditUndo->setEnabled (false);
1.559 - mapChanged=false;
1.560 -
1.561 - if (!redoSelection.isEmpty())
1.562 - select (redoSelection);
1.563 + //mapChanged=false; FIXME still needed???
1.564 +
1.565 + //if (!redoSelection.isEmpty())
1.566 + // select (redoSelection);
1.567 +
1.568 + undosAvail--;
1.569 + if (undosAvail<1)
1.570 + // Undo not longer available now
1.571 + actionEditUndo->setEnabled (false);
1.572 + else
1.573 + undoNum--; if (undoNum<1) undoNum=undosTotal;
1.574 +
1.575 + blockSaveState=false;
1.576 +/* TODO remove testing
1.577 + cout << "ME::undo() end\n";
1.578 + cout << " undosAvail="<<undosAvail<<endl;
1.579 + cout << " undoNum="<<undoNum<<endl;
1.580 + cout << " ---------------------------"<<endl<<endl;
1.581 +*/
1.582 }
1.583
1.584 -void MapEditor::undoXML(const QString &undoSel)
1.585 +void MapEditor::undoXML(const QString &undoSel, const QString &bakMapPath)
1.586 {
1.587 - QDir d;
1.588 - d.setPath(bakMapDir);
1.589 + QString bakMapDir=bakMapPath.left(bakMapPath.findRev("/"));
1.590 + QDir d(bakMapDir);
1.591 + QFile file (bakMapPath);
1.592 +
1.593 if (d.exists() )
1.594 {
1.595 // We need to parse saved XML data
1.596 mapBuilderHandler handler;
1.597 - QXmlInputSource source;
1.598 - source.setData(backupXML);
1.599 + QXmlInputSource source( file);
1.600 QXmlSimpleReader reader;
1.601 reader.setContentHandler( &handler );
1.602 reader.setErrorHandler( &handler );
1.603 @@ -1375,15 +1602,13 @@
1.604 handler.setLoadMode (ImportReplace);
1.605 }
1.606 blockReposition=true;
1.607 - blockSaveState=true;
1.608 bool ok = reader.parse( source );
1.609 blockReposition=false;
1.610 - blockSaveState=false;
1.611 if (! ok )
1.612 {
1.613 // This should never ever happen
1.614 QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ),
1.615 - tr( handler.errorProtocol() )+" in "+backupXML );
1.616 + tr( handler.errorProtocol() )+" in "+bakMapDir );
1.617 }
1.618 } else
1.619 {
1.620 @@ -1414,13 +1639,13 @@
1.621 ((BranchObj*)(returnLMO))->move2RelPos(normalise(fromLMO->getRelPos() ) );
1.622 }
1.623 if (typeid(*selection) == typeid(BranchObj))
1.624 - returnLMO=((BranchObj*)(selection))->addBranch((BranchObj*)(fromLMO) );
1.625 + returnLMO=((BranchObj*)selection)->addBranch((BranchObj*)(fromLMO) );
1.626 }
1.627
1.628 if (typeid(*fromLMO) == typeid(FloatImageObj) &&
1.629 (typeid(*selection) == typeid (BranchObj) ||
1.630 typeid(*selection)==typeid(MapCenterObj)) )
1.631 - returnLMO=((BranchObj*) (selection))->addFloatImage ((FloatImageObj*)(fromLMO));
1.632 + returnLMO=((BranchObj*) selection)->addFloatImage ((FloatImageObj*)(fromLMO));
1.633
1.634 }
1.635 return returnLMO;
1.636 @@ -1436,7 +1661,7 @@
1.637 if (selection != NULL) {
1.638 if (typeid(*selection) == typeid(BranchObj) )
1.639 {
1.640 - bo=(BranchObj*)(selection);
1.641 + bo=(BranchObj*)selection;
1.642 par=(BranchObj*)(bo->getParObj());
1.643 bo->unselect();
1.644 selection=NULL;
1.645 @@ -1446,7 +1671,7 @@
1.646 }
1.647 if (typeid(*selection) == typeid(FloatImageObj) )
1.648 {
1.649 - FloatImageObj* fio=(FloatImageObj*)(selection);
1.650 + FloatImageObj* fio=(FloatImageObj*)selection;
1.651 par=(BranchObj*)(fio->getParObj());
1.652 fio->unselect();
1.653 selection=NULL;
1.654 @@ -1479,7 +1704,7 @@
1.655 // FIXME no saveState, because this is only internal at undo so far
1.656 if (selection) selection->move(x,y);
1.657 if (typeid(*selection) == typeid(FloatImageObj))
1.658 - ((FloatImageObj*)(selection))->setRelPos();
1.659 + ((FloatImageObj*)selection)->setRelPos();
1.660 }
1.661
1.662 void MapEditor::moveBranchUp()
1.663 @@ -1491,12 +1716,12 @@
1.664 BranchObj* par;
1.665 if (typeid(*selection) == typeid(BranchObj) )
1.666 {
1.667 - bo=(BranchObj*)(selection);
1.668 + bo=(BranchObj*)selection;
1.669 par=(BranchObj*)(bo->getParObj());
1.670 selection->unselect();
1.671 selection=par->moveBranchUp (bo);
1.672 selection->select();
1.673 - saveState("moveBranchDown ()",bo->getSelectString());
1.674 + saveState("moveBranchDown ()",bo);
1.675 mapCenter->reposition();
1.676 ensureSelectionVisible();
1.677 }
1.678 @@ -1511,12 +1736,12 @@
1.679 BranchObj* par;
1.680 if (typeid(*selection) == typeid(BranchObj) )
1.681 {
1.682 - bo=(BranchObj*)(selection);
1.683 + bo=(BranchObj*)selection;
1.684 par=(BranchObj*)(bo->getParObj());
1.685 selection->unselect();
1.686 selection=par->moveBranchDown(bo);
1.687 selection->select();
1.688 - saveState("moveBranchUp ()",bo->getSelectString());
1.689 + saveState("moveBranchUp ()",bo);
1.690 mapCenter->reposition();
1.691 ensureSelectionVisible();
1.692 }
1.693 @@ -1531,8 +1756,8 @@
1.694 (typeid(*selection) == typeid(BranchObj) ||
1.695 typeid(*selection) == typeid(MapCenterObj) ) )
1.696 {
1.697 - editingBO=(BranchObj*)(selection);
1.698 - saveState("setHeading (\""+((BranchObj*)(selection))->getHeading()+"\")",editingBO->getSelectString() );
1.699 + editingBO=(BranchObj*)selection;
1.700 + saveState("setHeading (\""+((BranchObj*)selection)->getHeading()+"\")",editingBO );
1.701
1.702 ensureSelectionVisible();
1.703 QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y()));
1.704 @@ -1543,7 +1768,6 @@
1.705 if (actionSettingsAutoselectText->isOn() && !s.isEmpty() && actionSettingsPasteNewHeading->isOn() )
1.706 lineedit->selectAll();
1.707 lineedit->show();
1.708 -
1.709 lineedit->grabKeyboard();
1.710 lineedit->setFocus();
1.711 }
1.712 @@ -1556,7 +1780,7 @@
1.713 (typeid(*selection) == typeid(BranchObj) ||
1.714 typeid(*selection) == typeid(MapCenterObj) ) )
1.715 {
1.716 - ((BranchObj*)(selection))->setHeading(s);
1.717 + ((BranchObj*)selection)->setHeading(s);
1.718 mapCenter->reposition();
1.719 adjustCanvasSize();
1.720 ensureSelectionVisible();
1.721 @@ -1570,7 +1794,7 @@
1.722 (typeid(*selection) == typeid(BranchObj) ||
1.723 typeid(*selection) == typeid(MapCenterObj) ) )
1.724 {
1.725 - ((BranchObj*)(selection))->setURL(s);
1.726 + ((BranchObj*)selection)->setURL(s);
1.727 mapCenter->reposition();
1.728 adjustCanvasSize();
1.729 ensureSelectionVisible();
1.730 @@ -1584,7 +1808,7 @@
1.731 (typeid(*selection) == typeid(BranchObj) ||
1.732 typeid(*selection) == typeid(MapCenterObj) ) )
1.733 {
1.734 - ((BranchObj*)(selection))->setVymLink(s);
1.735 + ((BranchObj*)selection)->setVymLink(s);
1.736 mapCenter->reposition();
1.737 adjustCanvasSize();
1.738 ensureSelectionVisible();
1.739 @@ -1602,7 +1826,7 @@
1.740 {
1.741 saveState(selection); //FIXME undoCommand
1.742
1.743 - BranchObj* bo1 = (BranchObj*) (selection);
1.744 + BranchObj* bo1 = (BranchObj*) selection;
1.745 bool wasScrolled=false;
1.746 BranchObj *newbo=NULL;
1.747 if (pos==0)
1.748 @@ -1640,7 +1864,7 @@
1.749 selection->select();
1.750 if (actionSettingsPasteNewHeading->isOn() )
1.751 {
1.752 - BranchObj *bo2= (BranchObj*)(selection);
1.753 + BranchObj *bo2= (BranchObj*)selection;
1.754 bo2->setHeading("");
1.755 }
1.756 if (actionSettingsAutoedit->isOn() )
1.757 @@ -1667,7 +1891,7 @@
1.758 {
1.759 saveState(selection);
1.760
1.761 - BranchObj* bo1 = (BranchObj*) (selection);
1.762 + BranchObj* bo1 = (BranchObj*) selection;
1.763 bool wasScrolled=false;
1.764 BranchObj *newbo=NULL;
1.765 BranchObj *parbo=(BranchObj*)(selection->getParObj());
1.766 @@ -1678,7 +1902,7 @@
1.767 }
1.768
1.769 LinkableMapObj *oldselection=selection;
1.770 - ((BranchObj*)(selection))->moveBranchTo (newbo,-1);
1.771 + ((BranchObj*)selection)->moveBranchTo (newbo,-1);
1.772
1.773 mapCenter->reposition();
1.774 adjustCanvasSize();
1.775 @@ -1690,7 +1914,7 @@
1.776 selection->select();
1.777 if (actionSettingsPasteNewHeading->isOn() )
1.778 {
1.779 - BranchObj *bo2= (BranchObj*)(selection);
1.780 + BranchObj *bo2= (BranchObj*)selection;
1.781 bo2->setHeading("");
1.782 }
1.783 if (actionSettingsAutoedit->isOn() )
1.784 @@ -1854,7 +2078,7 @@
1.785 b=select (s);
1.786 if (b)
1.787 {
1.788 - if ( ((BranchObj*)(selection))->countBranches()>0)
1.789 + if ( ((BranchObj*)selection)->countBranches()>0)
1.790 s+=",bo:0";
1.791 else
1.792 break;
1.793 @@ -1933,8 +2157,8 @@
1.794 {
1.795 b=select (s);
1.796 if (b)
1.797 - if ( ((BranchObj*)(selection))->countBranches()>0)
1.798 - s+=",bo:"+ QString ("%1").arg( ((BranchObj*)(selection))->countBranches()-1 );
1.799 + if ( ((BranchObj*)selection)->countBranches()>0)
1.800 + s+=",bo:"+ QString ("%1").arg( ((BranchObj*)selection)->countBranches()-1 );
1.801 else
1.802 break;
1.803 else
1.804 @@ -2001,7 +2225,7 @@
1.805 {
1.806 if (typeid(*selection) == typeid(MapCenterObj))
1.807 {
1.808 - par= (BranchObj*) (selection);
1.809 + par= (BranchObj*) selection;
1.810 bo=par->getLastSelectedBranch();
1.811 if (bo)
1.812 {
1.813 @@ -2037,7 +2261,7 @@
1.814 {
1.815 if (typeid(*selection) == typeid(BranchObj) )
1.816 {
1.817 - bo=((BranchObj*)(selection))->getLastSelectedBranch();
1.818 + bo=((BranchObj*)selection)->getLastSelectedBranch();
1.819 if (bo)
1.820 {
1.821 selection->unselect();
1.822 @@ -2064,7 +2288,7 @@
1.823 {
1.824 if (typeid(*selection) == typeid(MapCenterObj))
1.825 {
1.826 - par= (BranchObj*) (selection);
1.827 + par= (BranchObj*) selection;
1.828 bo=par->getLastSelectedBranch();
1.829 if (bo)
1.830 {
1.831 @@ -2097,7 +2321,7 @@
1.832 {
1.833 if (typeid(*selection) == typeid(BranchObj) )
1.834 {
1.835 - bo=((BranchObj*)(selection))->getLastSelectedBranch();
1.836 + bo=((BranchObj*)selection)->getLastSelectedBranch();
1.837 if (bo)
1.838 {
1.839 selection->unselect();
1.840 @@ -2123,7 +2347,7 @@
1.841 if (selection) {
1.842 if (typeid(*selection) == typeid(BranchObj))
1.843 {
1.844 - bo1= (BranchObj*) (selection);
1.845 + bo1= (BranchObj*) selection;
1.846 par=(BranchObj*)(bo1->getParObj());
1.847 bo2=par->getFirstBranch();
1.848 if (bo2) {
1.849 @@ -2148,7 +2372,7 @@
1.850 if (selection) {
1.851 if (typeid(*selection) == typeid(BranchObj))
1.852 {
1.853 - bo1= (BranchObj*) (selection);
1.854 + bo1= (BranchObj*) selection;
1.855 par=(BranchObj*)(bo1->getParObj());
1.856 bo2=par->getLastBranch();
1.857 if (bo2) {
1.858 @@ -2190,7 +2414,7 @@
1.859 if (typeid(*selection) == typeid(BranchObj) ||
1.860 typeid(*selection) == typeid(MapCenterObj))
1.861 {
1.862 - BranchObj *bo=(BranchObj*)(selection);
1.863 + BranchObj *bo=(BranchObj*)selection;
1.864 actColor=bo->getColor();
1.865 }
1.866 }
1.867 @@ -2205,7 +2429,7 @@
1.868 typeid(*selection) == typeid(MapCenterObj))
1.869 {
1.870 saveState(selection); //FIXME undoCommand
1.871 - BranchObj *bo=(BranchObj*)(selection);
1.872 + BranchObj *bo=(BranchObj*)selection;
1.873 bo->setColor(actColor, false); // color links, color childs
1.874 }
1.875 }
1.876 @@ -2219,7 +2443,7 @@
1.877 typeid(*selection) == typeid(MapCenterObj))
1.878 {
1.879 saveState(selection);
1.880 - BranchObj *bo=(BranchObj*)(selection);
1.881 + BranchObj *bo=(BranchObj*)selection;
1.882 bo->setColor(actColor, true); // color links, color childs
1.883 }
1.884 }
1.885 @@ -2231,7 +2455,7 @@
1.886 if (selection)
1.887 {
1.888 saveState(selection);// FIXME undoCommand
1.889 - ((BranchObj*)(selection))->toggleStandardFlag (f,actionSettingsUseFlagGroups);
1.890 + ((BranchObj*)selection)->toggleStandardFlag (f,actionSettingsUseFlagGroups);
1.891 }
1.892 }
1.893
1.894 @@ -2263,7 +2487,7 @@
1.895 {
1.896 if (selection!=itFind)
1.897 {
1.898 - if (selection) ((BranchObj*)(selection))->unselect();
1.899 + if (selection) ((BranchObj*)selection)->unselect();
1.900 selection=itFind;
1.901 selection->select();
1.902 adjustCanvasSize();
1.903 @@ -2278,7 +2502,7 @@
1.904 // Searching in Heading
1.905 if (searching && itFind->getHeading().contains (s,cs) )
1.906 {
1.907 - if (selection) ((BranchObj*)(selection))->unselect();
1.908 + if (selection) ((BranchObj*)selection)->unselect();
1.909 selection=itFind;
1.910 selection->select();
1.911 adjustCanvasSize();
1.912 @@ -2295,7 +2519,7 @@
1.913 if (!searching)
1.914 {
1.915 adjustCanvasSize();
1.916 - return (BranchObj*)(selection);
1.917 + return (BranchObj*)selection;
1.918 } else
1.919 return NULL;
1.920 }
1.921 @@ -2313,7 +2537,7 @@
1.922 if (typeid(*selection) == typeid(BranchObj) ||
1.923 typeid(*selection) == typeid(MapCenterObj))
1.924 {
1.925 - QString url=((BranchObj*)(selection))->getURL();
1.926 + QString url=((BranchObj*)selection)->getURL();
1.927
1.928 QProcess *proc = new QProcess( this );
1.929
1.930 @@ -2334,7 +2558,7 @@
1.931 typeid(*selection) == typeid(MapCenterObj)) )
1.932 {
1.933 bool ok;
1.934 - BranchObj *bo=(BranchObj*)(selection);
1.935 + BranchObj *bo=(BranchObj*)selection;
1.936 QString text = QInputDialog::getText(
1.937 "VYM", tr("Enter URL:"), QLineEdit::Normal,
1.938 bo->getURL(), &ok, this );
1.939 @@ -2353,7 +2577,7 @@
1.940 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.941 typeid(*selection) == typeid(MapCenterObj)) )
1.942 {
1.943 - BranchObj *bo=(BranchObj*)(selection);
1.944 + BranchObj *bo=(BranchObj*)selection;
1.945 saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")");
1.946 bo->setURL (bo->getHeading());
1.947 updateActions();
1.948 @@ -2365,7 +2589,7 @@
1.949 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.950 typeid(*selection) == typeid(MapCenterObj)) )
1.951 {
1.952 - BranchObj *bo=(BranchObj*)(selection);
1.953 + BranchObj *bo=(BranchObj*)selection;
1.954 QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
1.955 saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")");
1.956 bo->setURL (url);
1.957 @@ -2378,7 +2602,7 @@
1.958 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.959 typeid(*selection) == typeid(MapCenterObj)) )
1.960 {
1.961 - BranchObj *bo=(BranchObj*)(selection);
1.962 + BranchObj *bo=(BranchObj*)selection;
1.963 QFileDialog *fd=new QFileDialog( this,tr("VYM - Link to another map"));
1.964 fd->addFilter (QString (tr("vym map") + " (*.vym)"));
1.965 fd->setCaption(tr("VYM - Link to another map"));
1.966 @@ -2404,7 +2628,7 @@
1.967 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.968 typeid(*selection) == typeid(MapCenterObj)) )
1.969 {
1.970 - BranchObj *bo=(BranchObj*)(selection);
1.971 + BranchObj *bo=(BranchObj*)selection;
1.972 saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")");
1.973 bo->setVymLink ("" );
1.974 updateActions();
1.975 @@ -2419,7 +2643,7 @@
1.976 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.977 typeid(*selection) == typeid(MapCenterObj)) )
1.978 {
1.979 - return ((BranchObj*)(selection))->getVymLink();
1.980 + return ((BranchObj*)selection)->getVymLink();
1.981 }
1.982 return "";
1.983
1.984 @@ -2429,7 +2653,7 @@
1.985 {
1.986 if (selection && (typeid(*selection) == typeid(BranchObj) ))
1.987 {
1.988 - BranchObj* bo=(BranchObj*)(selection);
1.989 + BranchObj* bo=(BranchObj*)selection;
1.990 BranchObj* par=(BranchObj*)(bo->getParObj());
1.991 if (bo->getDepth()==1)
1.992 saveState();
1.993 @@ -2448,7 +2672,7 @@
1.994 if (selection && (typeid(*selection) == typeid(BranchObj) ))
1.995 {
1.996 saveState(selection->getParObj());
1.997 - ((BranchObj*)(selection))->removeChilds();
1.998 + ((BranchObj*)selection)->removeChilds();
1.999 mapCenter->reposition();
1.1000 }
1.1001 }
1.1002 @@ -2537,7 +2761,7 @@
1.1003 if ( (typeid(*selection) == typeid(BranchObj)) ||
1.1004 (typeid(*selection) == typeid(MapCenterObj)) )
1.1005 {
1.1006 - BranchObj *bo=(BranchObj*)(selection);
1.1007 + BranchObj *bo=(BranchObj*)selection;
1.1008 // Take care of links
1.1009 if (bo->countXLinks()==0)
1.1010 {
1.1011 @@ -2622,7 +2846,7 @@
1.1012 a->setEnabled(false);
1.1013 actionEditDelete->setEnabled (true);
1.1014 actionEditToggleFloatExport->setOn
1.1015 - ( ((FloatImageObj*)(selection))->getFloatExport() );
1.1016 + ( ((FloatImageObj*)selection)->getFloatExport() );
1.1017 actionFormatHideLinkUnselected->setOn
1.1018 ( selection->getHideLinkUnselected());
1.1019 }
1.1020 @@ -2649,11 +2873,9 @@
1.1021 void MapEditor::updateNoteFlag()
1.1022 {
1.1023 if (selection)
1.1024 - {
1.1025 if ( (typeid(*selection) == typeid(BranchObj)) ||
1.1026 (typeid(*selection) == typeid(MapCenterObj)) )
1.1027 ((BranchObj*)selection)->updateNoteFlag();
1.1028 - }
1.1029 }
1.1030
1.1031 void MapEditor::setLinkStyle (LinkStyle ls)
1.1032 @@ -2762,7 +2984,7 @@
1.1033 {
1.1034 if (selection && (typeid(*selection) == typeid(BranchObj)) )
1.1035 {
1.1036 - BranchObj *bo=((BranchObj*)(selection));
1.1037 + BranchObj *bo=((BranchObj*)selection);
1.1038 if (bo->countBranches()==0) return;
1.1039 if (bo->getDepth()==0) return;
1.1040 saveState(selection);
1.1041 @@ -2789,7 +3011,7 @@
1.1042 (typeid(*selection) == typeid(BranchObj)) ||
1.1043 (typeid(*selection) == typeid(MapCenterObj)) )
1.1044 {
1.1045 - BranchObj *bo=((BranchObj*)(selection));
1.1046 + BranchObj *bo=((BranchObj*)selection);
1.1047
1.1048 QFileDialog *fd=new QFileDialog( this,tr("vym - load image"));
1.1049 fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
1.1050 @@ -2823,7 +3045,7 @@
1.1051 if (selection &&
1.1052 (typeid(*selection) == typeid(FloatImageObj)) )
1.1053 {
1.1054 - FloatImageObj *fio=((FloatImageObj*)(selection));
1.1055 + FloatImageObj *fio=((FloatImageObj*)selection);
1.1056 const char* fmt = saveImageFormatMenu->text(item);
1.1057
1.1058 QFileDialog *fd=new QFileDialog( this, tr("vym - save image as") + fmt);
1.1059 @@ -2877,7 +3099,7 @@
1.1060 (typeid(*selection) == typeid(FloatImageObj))||
1.1061 (typeid(*selection) == typeid(FloatObj)) )
1.1062 {
1.1063 - FloatImageObj *fio=((FloatImageObj*)(selection));
1.1064 + FloatImageObj *fio=((FloatImageObj*)selection);
1.1065 fio->setFloatExport (actionEditToggleFloatExport->isOn() );
1.1066 }
1.1067 }
1.1068 @@ -2971,7 +3193,7 @@
1.1069 QString fn;
1.1070 if ( fd->exec() == QDialog::Accepted )
1.1071 {
1.1072 - BranchObj *bo=((BranchObj*)(selection));
1.1073 + BranchObj *bo=((BranchObj*)selection);
1.1074 importDir (bo,QDir(fd->selectedFile()) );
1.1075 mapCenter->reposition();
1.1076 adjustCanvasSize();
1.1077 @@ -2986,7 +3208,7 @@
1.1078 (typeid(*selection) == typeid(BranchObj)) ||
1.1079 (typeid(*selection) == typeid(MapCenterObj)) )
1.1080 {
1.1081 - BranchObj *bo=((BranchObj*)(selection))->XLinkTargetAt(i);
1.1082 + BranchObj *bo=((BranchObj*)selection)->XLinkTargetAt(i);
1.1083 if (bo)
1.1084 {
1.1085 selection->unselect();
1.1086 @@ -3003,7 +3225,7 @@
1.1087 (typeid(*selection) == typeid(BranchObj)) ||
1.1088 (typeid(*selection) == typeid(MapCenterObj)) )
1.1089 {
1.1090 - XLinkObj *xlo=((BranchObj*)(selection))->XLinkAt(i);
1.1091 + XLinkObj *xlo=((BranchObj*)selection)->XLinkAt(i);
1.1092 if (xlo)
1.1093 {
1.1094 EditXLinkDialog dia;
1.1095 @@ -3017,7 +3239,7 @@
1.1096 setDefXLinkWidth (xlo->getWidth() );
1.1097 }
1.1098 if (dia.deleteXLink())
1.1099 - ((BranchObj*)(selection))->deleteXLinkAt(i);
1.1100 + ((BranchObj*)selection)->deleteXLinkAt(i);
1.1101 saveState(); //FIXME undoCommand
1.1102 }
1.1103 }
1.1104 @@ -3030,7 +3252,7 @@
1.1105 if (selection &&
1.1106 (typeid(*selection) == typeid(BranchObj)) )
1.1107 {
1.1108 - QString s=((BranchObj*)(selection))->getHeading();
1.1109 + QString s=((BranchObj*)selection)->getHeading();
1.1110 parseAtom(s);
1.1111 }
1.1112 }
1.1113 @@ -3132,7 +3354,7 @@
1.1114 if (selection &&
1.1115 ((typeid(*selection) == typeid(BranchObj)) ||
1.1116 (typeid(*selection) == typeid(MapCenterObj))) )
1.1117 - bo_begin=(BranchObj*)(selection);
1.1118 + bo_begin=(BranchObj*)selection;
1.1119 if (bo_begin)
1.1120 {
1.1121 drawingLink=true;
1.1122 @@ -3165,7 +3387,7 @@
1.1123 if (typeid(*selection)==typeid(BranchObj) ||
1.1124 typeid(*selection)==typeid(MapCenterObj) )
1.1125 {
1.1126 - QString foname=((BranchObj*)(selection))->getSystemFlagName(p);
1.1127 + QString foname=((BranchObj*)selection)->getSystemFlagName(p);
1.1128 if (!foname.isEmpty())
1.1129 {
1.1130 // Do not move, if systemFlag clicked
1.1131 @@ -3200,7 +3422,7 @@
1.1132 if (typeid(*selection)==typeid(BranchObj) )
1.1133 {
1.1134 copyingObj=true;
1.1135 - mapCenter->addBranch ((BranchObj*)(selection));
1.1136 + mapCenter->addBranch ((BranchObj*)selection);
1.1137 unselect();
1.1138 selection=mapCenter->getLastBranch();
1.1139 selection->select();
1.1140 @@ -3252,7 +3474,7 @@
1.1141
1.1142 if (typeid(*selection) == typeid(FloatImageObj))
1.1143 {
1.1144 - FloatObj *fo=(FloatObj*)(selection);
1.1145 + FloatObj *fo=(FloatObj*)selection;
1.1146 saveState("move "+qpointToString(movingObj_orgPos),fo->getSelectString() );
1.1147 if (fo->getLinkStyle()==StyleUndef)
1.1148 {
1.1149 @@ -3304,7 +3526,6 @@
1.1150 if (lmosel->getDepth()==1)
1.1151 {
1.1152 // depth==1, mainbranch
1.1153 - saveState("move "+qpointToString(movingObj_orgPos), lmosel->getSelectString() );
1.1154 lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.1155 } else
1.1156 {
1.1157 @@ -3389,13 +3610,13 @@
1.1158 {
1.1159 if (e->state() & QMouseEvent::ShiftButton)
1.1160 {
1.1161 - ((BranchObj*)(selection))->setColor (((BranchObj*)(dst))->getColor(),false);
1.1162 - ((BranchObj*)(selection))->setLinkColor ();
1.1163 + ((BranchObj*)selection)->setColor (((BranchObj*)(dst))->getColor(),false);
1.1164 + ((BranchObj*)selection)->setLinkColor ();
1.1165 }
1.1166 else
1.1167 {
1.1168 - ((BranchObj*)(selection))->setColor (((BranchObj*)(dst))->getColor(),true);
1.1169 - ((BranchObj*)(selection))->setLinkColor ();
1.1170 + ((BranchObj*)selection)->setColor (((BranchObj*)(dst))->getColor(),true);
1.1171 + ((BranchObj*)selection)->setLinkColor ();
1.1172 }
1.1173 }
1.1174 return;
1.1175 @@ -3427,13 +3648,11 @@
1.1176 // Check if we are over another branch, but ignore
1.1177 // any found LMOs, which are FloatObjs
1.1178 dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ),
1.1179 - ((LinkableMapObj*)(selection)) );
1.1180 + ((LinkableMapObj*)selection) );
1.1181
1.1182 if (dst &&
1.1183 (typeid(*dst)!=typeid(BranchObj)&&typeid(*dst)!=typeid(MapCenterObj)))
1.1184 - {
1.1185 dst=NULL;
1.1186 - }
1.1187
1.1188 // Now check, if we have been moving a branch
1.1189 if (typeid(*selection) == typeid(BranchObj) )
1.1190 @@ -3442,13 +3661,13 @@
1.1191 QPoint savePos=QPoint (selection->x(),selection->y() );
1.1192
1.1193 // Reset the temporary drawn link to the original one
1.1194 - ((LinkableMapObj*)(selection))->unsetParObjTmp();
1.1195 + ((LinkableMapObj*)selection)->unsetParObjTmp();
1.1196
1.1197
1.1198 copyingObj=false;
1.1199 if (dst )
1.1200 {
1.1201 - BranchObj* bs=((BranchObj*)(selection));
1.1202 + BranchObj* bs=((BranchObj*)selection);
1.1203 QString undoCom="linkBranchToPos (\""+
1.1204 (bs->getParObj())->getSelectString()+
1.1205 "\","+
1.1206 @@ -3474,7 +3693,11 @@
1.1207 bs->move (savePos);
1.1208 }
1.1209 saveState (undoCom,bs->getSelectString() );
1.1210 - }
1.1211 + } else
1.1212 + if (selection->getDepth()==1)
1.1213 + // If we have moved mainbranch only save endposition
1.1214 + saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString() );
1.1215 +
1.1216 // Draw the original link, before selection was moved around
1.1217 mapCenter->reposition();
1.1218 }
1.1219 @@ -3646,7 +3869,7 @@
1.1220 BranchObj *bo;
1.1221 for (const char* u=uris.first(); u; u=uris.next())
1.1222 {
1.1223 - bo=((BranchObj*)(selection))->addBranch();
1.1224 + bo=((BranchObj*)selection)->addBranch();
1.1225 if (bo)
1.1226 {
1.1227 s=QUriDrag::uriToLocalFile(u);
1.1228 @@ -3688,7 +3911,7 @@
1.1229 (typeid(*selection) == typeid(BranchObj)) ||
1.1230 (typeid(*selection) == typeid(MapCenterObj)) )
1.1231 {
1.1232 - BranchObj *bo=((BranchObj*)(selection));
1.1233 + BranchObj *bo=((BranchObj*)selection);
1.1234 saveState(selection);
1.1235 //QString fn=fd->selectedFile();
1.1236 //lastImageDir=fn.left(fn.findRev ("/"));