1.1 --- a/mapeditor.cpp Tue Aug 15 12:01:14 2006 +0000
1.2 +++ b/mapeditor.cpp Tue Aug 29 08:31:42 2006 +0000
1.3 @@ -44,7 +44,6 @@
1.4 #include "linkablemapobj.h"
1.5 #include "mainwindow.h"
1.6 #include "misc.h"
1.7 -#include "settings.h"
1.8 #include "texteditor.h"
1.9 #include "warningdialog.h"
1.10 #include "xml.h"
1.11 @@ -63,6 +62,7 @@
1.12
1.13 extern QAction *actionFileSave;
1.14 extern QAction *actionEditUndo;
1.15 +extern QAction *actionEditRedo;
1.16 extern QAction *actionEditCopy;
1.17 extern QAction *actionEditCut;
1.18 extern QAction *actionEditPaste;
1.19 @@ -177,10 +177,6 @@
1.20
1.21 printer=NULL;
1.22
1.23 - lineedit = new QLineEdit(this, "lineedit" );
1.24 - connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEdit() ) );
1.25 - lineedit->hide();
1.26 -
1.27 actColor=Qt::black; setColor (actColor);
1.28 defLinkColor=QColor (0,0,255);
1.29 defXLinkColor=QColor (180,180,180);
1.30 @@ -207,6 +203,8 @@
1.31 selectionLast=NULL;
1.32 movingObj=NULL;
1.33
1.34 + xelection.setMapCenter (mapCenter);
1.35 +
1.36 defXLinkWidth=1;
1.37 defXLinkColor=QColor (230,230,230);
1.38
1.39 @@ -220,8 +218,6 @@
1.40 mapName="";
1.41
1.42 undosTotal=settings.readNumEntry("/mapeditor/undoLevels",50);
1.43 - undosAvail=0;
1.44 - undoNum=0;
1.45
1.46 // Initialize find routine
1.47 itFind=NULL;
1.48 @@ -248,6 +244,8 @@
1.49 historyWindow->setCaption (fileName);
1.50
1.51 mapCenter->reposition(); // for positioning heading
1.52 +
1.53 +
1.54 }
1.55
1.56 MapEditor::~MapEditor()
1.57 @@ -372,7 +370,8 @@
1.58 void MapEditor::makeTmpDirs()
1.59 {
1.60 // Create unique temporary directories
1.61 - tmpMapDir=tmpVymDir+QString("/mapeditor-%1").arg(mapNum);
1.62 + tmpMapDir=QDir::convertSeparators (tmpVymDir+QString("/mapeditor-%1").arg(mapNum));
1.63 + histPath=QDir::convertSeparators (tmpMapDir+"/history");
1.64 QDir d;
1.65 d.mkdir (tmpMapDir,true);
1.66 }
1.67 @@ -458,32 +457,29 @@
1.68 return s;
1.69 }
1.70
1.71 -void MapEditor::saveState(const QString &comment)
1.72 +void MapEditor::saveStateComplete(const QString &comment)
1.73 {
1.74 // Save complete map
1.75 saveState (CompleteMap,"",NULL,"",NULL, comment);
1.76 }
1.77
1.78 -void MapEditor::saveState(LinkableMapObj *undoSel, const QString &comment)
1.79 +void MapEditor::saveStatePart(LinkableMapObj *undoSel, const QString &comment)
1.80 {
1.81 - // save the given part of the map
1.82 + // save the selected part of the map
1.83 saveState (PartOfMap,"",undoSel,"",NULL, comment);
1.84 }
1.85
1.86 -void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment)
1.87 +void MapEditor::saveStateConstSelection(const QString &uc, const QString &rc, const QString &comment)
1.88 {
1.89 // selection does not change during action,
1.90 // so just save commands for undo and redo
1.91 - LinkableMapObj *unsel;
1.92 - if (selection)
1.93 - unsel=selection;
1.94 - else
1.95 - unsel=NULL;
1.96 - saveState (UndoCommand,uc,unsel,rc,unsel, comment);
1.97 + // and use current selection
1.98 + saveState (UndoCommand,uc,selection,rc,selection, comment);
1.99 }
1.100
1.101 -void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel, const QString &comment)
1.102 +void MapEditor::saveStateX(LinkableMapObj *unsel, const QString &uncom, const QString &comment)
1.103 {
1.104 + //
1.105 saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL, comment);
1.106 }
1.107
1.108 @@ -494,24 +490,24 @@
1.109 if (blockSaveState) return;
1.110
1.111 /* TODO remove after testing
1.112 + */
1.113 cout << "ME::saveState() begin\n"<<endl;
1.114 cout << " undosTotal="<<undosTotal<<endl;
1.115 - cout << " undosAvail="<<undosAvail<<endl;
1.116 - cout << " undoNum="<<undoNum<<endl;
1.117 cout << " ---------------------------"<<endl;
1.118 - */
1.119
1.120 historyWindow->append (comment);
1.121
1.122 setChanged();
1.123
1.124 + int undosAvail=undoSet.readNumEntry ("/history/undosAvail",0);
1.125 + int curStep=undoSet.readNumEntry ("/history/curStep",0);
1.126 // Find out current undo directory
1.127 if (undosAvail<undosTotal) undosAvail++;
1.128 - undoNum++;
1.129 - if (undoNum>undosTotal) undoNum=1;
1.130 + curStep++;
1.131 + if (curStep>undosTotal) curStep=1;
1.132
1.133 QString backupXML;
1.134 - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
1.135 + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
1.136 QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml");
1.137
1.138 // Create bakMapDir if not available
1.139 @@ -550,28 +546,27 @@
1.140 // Write XML Data to disk
1.141 saveStringToDisk (QString(bakMapPath),backupXML);
1.142
1.143 - SimpleSettings set;
1.144 - set.setEntry (QString("undoCommand"),undoCommand);
1.145 - set.setEntry (QString("undoSelection"),undoSelection);
1.146 - set.setEntry (QString("redoCommand"),redoCom);
1.147 - set.setEntry (QString("redoSelection"),redoSelection);
1.148 - set.setEntry (QString("comment"),comment);
1.149 - set.writeSettings(QString(bakMapDir+"/commands"));
1.150 + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
1.151 + undoSet.setEntry ("/history/curStep",QString::number(curStep));
1.152 + undoSet.setEntry (QString("/history/step-%1/undoCommand").arg(curStep),undoCommand);
1.153 + undoSet.setEntry (QString("/history/step-%1/undoSelection").arg(curStep),undoSelection);
1.154 + undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom);
1.155 + undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection);
1.156 + undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment);
1.157 + undoSet.writeSettings(histPath);
1.158
1.159 /* TODO remove after testing
1.160 - cout << " into="<< bakMapDir<<endl;
1.161 + */
1.162 + cout << " into="<< histPath.toStdString()<<endl;
1.163 cout << " undosAvail="<<undosAvail<<endl;
1.164 - cout << " undoNum="<<undoNum<<endl;
1.165 + cout << " curStep="<<curStep<<endl;
1.166 cout << " ---------------------------"<<endl;
1.167 - cout << " comment="<<comment<<endl;
1.168 - cout << " ---------------------------"<<endl;
1.169 - cout << " undoCom="<<undoCommand<<endl;
1.170 - cout << " undoSel="<<undoSelection<<endl;
1.171 - cout << " ---------------------------"<<endl;
1.172 - cout << " redoCom="<<redoCom<<endl;
1.173 - cout << " redoSel="<<redoSelection<<endl;
1.174 + cout << " comment="<<comment.toStdString()<<endl;
1.175 + cout << " undoCom="<<undoCommand.toStdString()<<endl;
1.176 + cout << " undoSel="<<undoSelection.toStdString()<<endl;
1.177 + cout << " redoCom="<<redoCom.toStdString()<<endl;
1.178 + cout << " redoSel="<<redoSelection.toStdString()<<endl;
1.179 cout << " ---------------------------"<<endl<<endl;
1.180 - */
1.181 }
1.182
1.183 void MapEditor::parseAtom(const QString &atom)
1.184 @@ -602,6 +597,17 @@
1.185 }
1.186 }
1.187 }
1.188 + else if (com=="delete")
1.189 + {
1.190 + if (api.checkParamCount(1) && selection )
1.191 + {
1.192 + s=api.parString(ok,0);
1.193 + if (ok)
1.194 + {
1.195 + if (select (s)) deleteSelection();
1.196 + }
1.197 + }
1.198 + }
1.199 else if (com=="linkBranchToPos")
1.200 {
1.201 if (selection && typeid(*selection) == typeid(BranchObj) )
1.202 @@ -637,23 +643,46 @@
1.203 if (api.checkParamCount(1))
1.204 {
1.205 s=api.parString (ok,0);
1.206 - if (ok) setHeading (s);
1.207 + if (ok)
1.208 + setHeading (s);
1.209 }
1.210 } else if (com=="setURL")
1.211 {
1.212 if (api.checkParamCount(1))
1.213 {
1.214 s=api.parString (ok,0);
1.215 - if (ok) setURL(s);
1.216 + if (ok) setURLInt(s);
1.217 }
1.218 } else if (com=="setVymLink")
1.219 {
1.220 if (api.checkParamCount(1))
1.221 {
1.222 s=api.parString (ok,0);
1.223 - if (ok) setVymLink(s);
1.224 + if (ok) setVymLinkInt(s);
1.225 }
1.226 }
1.227 + else if (com=="setFlag")
1.228 + {
1.229 + if (selection && typeid(*selection) == typeid(BranchObj) )
1.230 + {
1.231 + if (api.checkParamCount(1) )
1.232 + {
1.233 + s=api.parString(ok,0);
1.234 + if (ok) ((BranchObj*)selection)->activateStandardFlag(s);
1.235 + }
1.236 + }
1.237 + }
1.238 + else if (com=="unsetFlag")
1.239 + {
1.240 + if (selection && typeid(*selection) == typeid(BranchObj) )
1.241 + {
1.242 + if (api.checkParamCount(1) )
1.243 + {
1.244 + s=api.parString(ok,0);
1.245 + if (ok) ((BranchObj*)selection)->deactivateStandardFlag(s);
1.246 + }
1.247 + }
1.248 + }
1.249 // Internal commands, used for undo etc.
1.250 else if (com==QString("undoMap"))
1.251 {
1.252 @@ -687,31 +716,6 @@
1.253 }
1.254 }
1.255
1.256 -
1.257 -void MapEditor::finishedLineEdit()
1.258 -{
1.259 - // This is called by finishedLineEdit or any MapEditor method,
1.260 - // which wants to assure, that lineedits finish, before e.g. a branch is
1.261 - // deleted
1.262 -
1.263 - // After calling LineEdit and using the clipboard, the
1.264 - // focus is not any longer on the main widget, we
1.265 - // have to restore it using parentWidget()->setFocus()
1.266 -
1.267 - if (editingBO!=NULL)
1.268 - {
1.269 - saveState("setHeading (\""+editingBO->getHeading()+"\")",editingBO, QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(lineedit->text()) );
1.270 - editingBO->setHeading(lineedit->text() );
1.271 - editingBO=NULL;
1.272 - lineedit->releaseKeyboard();
1.273 - lineedit->hide();
1.274 - parentWidget()->setFocus();
1.275 - mapCenter->reposition();
1.276 - adjustCanvasSize();
1.277 - ensureSelectionVisible();
1.278 - }
1.279 -}
1.280 -
1.281 void MapEditor::toggleHistoryWindow()
1.282 {
1.283 if (historyWindow->isVisible())
1.284 @@ -748,9 +752,6 @@
1.285
1.286 void MapEditor::closeMap()
1.287 {
1.288 - // Finish open lineEdits
1.289 - if (lineedit) finishedLineEdit();
1.290 -
1.291 // Unselect before disabling the toolbar actions
1.292 if (selection) selection->unselect();
1.293 selection=NULL;
1.294 @@ -816,9 +817,6 @@
1.295
1.296 ErrorCode MapEditor::load (QString fname, LoadMode lmode)
1.297 {
1.298 - // Finish open lineEdits
1.299 - if (lineedit) finishedLineEdit();
1.300 -
1.301 ErrorCode err=success;
1.302
1.303 if (lmode==NewMap)
1.304 @@ -830,7 +828,7 @@
1.305 // (map state is set later at end of load...)
1.306 } else
1.307 {
1.308 - saveState(selection,"Load map");
1.309 + saveStatePart(selection,"Load map");
1.310 }
1.311
1.312
1.313 @@ -885,9 +883,6 @@
1.314
1.315 int MapEditor::save (const SaveMode &savemode)
1.316 {
1.317 - // Finish open lineEdits
1.318 - if (lineedit) finishedLineEdit();
1.319 -
1.320 int returnCode=0;
1.321
1.322 // The SaveMode UndoCommand is not supported here
1.323 @@ -935,9 +930,6 @@
1.324
1.325 void MapEditor::print()
1.326 {
1.327 - // Finish open lineEdits
1.328 - if (lineedit) finishedLineEdit();
1.329 -
1.330 if ( !printer )
1.331 {
1.332 printer = new QPrinter;
1.333 @@ -1111,9 +1103,6 @@
1.334
1.335 void MapEditor::exportImage(QString fn)
1.336 {
1.337 - // Finish open lineEdits
1.338 - if (lineedit) finishedLineEdit();
1.339 -
1.340 setExportMode (true);
1.341 QPixmap pix (getPixmap());
1.342 pix.save(fn, "PNG");
1.343 @@ -1132,9 +1121,6 @@
1.344
1.345 void MapEditor::exportImage(QString fn, QString format)
1.346 {
1.347 - // Finish open lineEdits
1.348 - if (lineedit) finishedLineEdit();
1.349 -
1.350 setExportMode (true);
1.351 QPixmap pix (getPixmap());
1.352 pix.save(fn, format);
1.353 @@ -1201,9 +1187,6 @@
1.354
1.355 void MapEditor::copy()
1.356 {
1.357 - // Finish open lineEdits
1.358 - if (lineedit) finishedLineEdit();
1.359 -
1.360 if (selection)
1.361 {
1.362 // write to directory
1.363 @@ -1232,124 +1215,134 @@
1.364
1.365 void MapEditor::redo()
1.366 {
1.367 - // Finish open lineEdits
1.368 - if (lineedit) finishedLineEdit();
1.369 -
1.370 blockSaveState=true;
1.371
1.372 + // Restore variables
1.373 + int curStep=undoSet.readNumEntry (QString("/history/curStep"));
1.374 + int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
1.375 + int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
1.376 + if (redosAvail>0) redosAvail--;
1.377 + if (undosAvail<undosTotal) undosAvail++;
1.378 + curStep++;
1.379 + if (curStep>undosTotal) curStep=1;
1.380 + QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
1.381 + QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
1.382 + QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
1.383 + QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
1.384 + QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
1.385 +
1.386 // Find out current undo directory
1.387 - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
1.388 -
1.389 - // Restore variables
1.390 - QString undoCommand;
1.391 - QString undoSelection;
1.392 - QString redoCommand;
1.393 - QString redoSelection;
1.394 - SimpleSettings set;
1.395 - set.readSettings(QString(bakMapDir+"/commands"));
1.396 - undoCommand=set.readEntry ("undoCommand");
1.397 - undoSelection=set.readEntry ("undoSelection");
1.398 - redoCommand=set.readEntry ("redoCommand");
1.399 - redoSelection=set.readEntry ("redoSelection");
1.400 + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
1.401 +
1.402 +/* TODO remove testing
1.403 +*/
1.404 + cout << "ME::redo() begin\n";
1.405 + cout << " undosAvail="<<undosAvail<<endl;
1.406 + cout << " redosAvail="<<redosAvail<<endl;
1.407 + cout << " curStep="<<curStep<<endl;
1.408 + cout << " ---------------------------"<<endl;
1.409 + cout << " comment="<<comment.toStdString()<<endl;
1.410 + cout << " undoCom="<<undoCommand.toStdString()<<endl;
1.411 + cout << " undoSel="<<undoSelection.toStdString()<<endl;
1.412 + cout << " redoCom="<<redoCommand.toStdString()<<endl;
1.413 + cout << " redoSel="<<redoSelection.toStdString()<<endl;
1.414 + cout << " ---------------------------"<<endl<<endl;
1.415
1.416 // select object before redo
1.417 + // FIXME better give up if no selection there...
1.418 if (!redoSelection.isEmpty())
1.419 select (redoSelection);
1.420
1.421 +
1.422 + parseAtom (redoCommand);
1.423 + mapCenter->reposition();
1.424 +
1.425 + //if (!redoSelection.isEmpty())
1.426 + // select (redoSelection);
1.427 +
1.428 + blockSaveState=false;
1.429 /* TODO remove testing
1.430 - cout << "ME::redo() begin\n";
1.431 - cout << " undosTotal="<<undosTotal<<endl;
1.432 +*/
1.433 + cout << "ME::redo() end\n";
1.434 cout << " undosAvail="<<undosAvail<<endl;
1.435 - cout << " undoNum="<<undoNum<<endl;
1.436 + cout << " redosAvail="<<redosAvail<<endl;
1.437 + cout << " curStep="<<curStep<<endl;
1.438 + cout << " ---------------------------"<<endl<<endl;
1.439 +
1.440 +
1.441 + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
1.442 + undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
1.443 + undoSet.setEntry ("/history/curStep",QString::number(curStep));
1.444 + undoSet.writeSettings(histPath);
1.445 +
1.446 + updateActions();
1.447 +}
1.448 +
1.449 +void MapEditor::undo()
1.450 +{
1.451 + blockSaveState=true;
1.452 +
1.453 + // Restore variables
1.454 + int curStep=undoSet.readNumEntry (QString("/history/curStep"));
1.455 + int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
1.456 + int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
1.457 + QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
1.458 + QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
1.459 + QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
1.460 + QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
1.461 + QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
1.462 +
1.463 + // Find out current undo directory
1.464 + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
1.465 +
1.466 + // select object before undo
1.467 + if (!undoSelection.isEmpty())
1.468 + select (undoSelection);
1.469 +
1.470 +/* TODO testing
1.471 +*/
1.472 + cout << "ME::undo() begin\n";
1.473 + cout << " undosAvail="<<undosAvail<<endl;
1.474 + cout << " redosAvail="<<redosAvail<<endl;
1.475 + cout << " curStep="<<curStep<<endl;
1.476 cout << " ---------------------------"<<endl;
1.477 - cout << " undoCom="<<undoCommand<<endl;
1.478 - cout << " undoSel="<<undoSelection<<endl;
1.479 - cout << " ---------------------------"<<endl;
1.480 - cout << " redoCom="<<redoCommand<<endl;
1.481 - cout << " redoSel="<<redoSelection<<endl;
1.482 - cout << " ---------------------------"<<endl;
1.483 -*/
1.484 + cout << " comment="<<comment.toStdString()<<endl;
1.485 + cout << " undoCom="<<undoCommand.toStdString()<<endl;
1.486 + cout << " undoSel="<<undoSelection.toStdString()<<endl;
1.487 + cout << " redoCom="<<redoCommand.toStdString()<<endl;
1.488 + cout << " redoSel="<<redoSelection.toStdString()<<endl;
1.489 + cout << " ---------------------------"<<endl<<endl;
1.490 parseAtom (undoCommand);
1.491 mapCenter->reposition();
1.492
1.493 //if (!redoSelection.isEmpty())
1.494 // select (redoSelection);
1.495
1.496 +
1.497 undosAvail--;
1.498 if (undosAvail<1)
1.499 // Undo not longer available now
1.500 actionEditUndo->setEnabled (false);
1.501 else
1.502 - undoNum--; if (undoNum<1) undoNum=undosTotal;
1.503 + curStep--; if (curStep<1) curStep=undosTotal;
1.504 +
1.505 + redosAvail++;
1.506
1.507 blockSaveState=false;
1.508 /* TODO remove testing
1.509 - cout << "ME::redo() end\n";
1.510 - cout << " undosAvail="<<undosAvail<<endl;
1.511 - cout << " undoNum="<<undoNum<<endl;
1.512 - cout << " ---------------------------"<<endl<<endl;
1.513 -*/
1.514 -}
1.515 -
1.516 -void MapEditor::undo()
1.517 -{
1.518 - // Finish open lineEdits
1.519 - if (lineedit) finishedLineEdit();
1.520 -
1.521 - blockSaveState=true;
1.522 -
1.523 - // Find out current undo directory
1.524 - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
1.525 -
1.526 - // Restore variables
1.527 - QString undoCommand;
1.528 - QString undoSelection;
1.529 - QString redoCommand;
1.530 - QString redoSelection;
1.531 - SimpleSettings set;
1.532 - set.readSettings(QString(bakMapDir+"/commands"));
1.533 - undoCommand= set.readEntry ("undoCommand");
1.534 - undoSelection=set.readEntry ("undoSelection");
1.535 - redoCommand= set.readEntry ("redoCommand");
1.536 - redoSelection=set.readEntry ("redoSelection");
1.537 -
1.538 - // select object before undo
1.539 - if (!undoSelection.isEmpty())
1.540 - select (undoSelection);
1.541 -
1.542 -/* TODO testing
1.543 - cout << "ME::undo() begin\n";
1.544 - cout << " undosTotal="<<undosTotal<<endl;
1.545 - cout << " undosAvail="<<undosAvail<<endl;
1.546 - cout << " undoNum="<<undoNum<<endl;
1.547 - cout << " ---------------------------"<<endl;
1.548 - cout << " undoCom="<<undoCommand<<endl;
1.549 - cout << " undoSel="<<undoSelection<<endl;
1.550 - cout << " ---------------------------"<<endl;
1.551 - cout << " redoCom="<<redoCommand<<endl;
1.552 - cout << " redoSel="<<redoSelection<<endl;
1.553 - cout << " ---------------------------"<<endl;
1.554 -*/
1.555 - parseAtom (undoCommand);
1.556 - mapCenter->reposition();
1.557 -
1.558 - //if (!redoSelection.isEmpty())
1.559 - // select (redoSelection);
1.560 -
1.561 - undosAvail--;
1.562 - if (undosAvail<1)
1.563 - // Undo not longer available now
1.564 - actionEditUndo->setEnabled (false);
1.565 - else
1.566 - undoNum--; if (undoNum<1) undoNum=undosTotal;
1.567 -
1.568 - blockSaveState=false;
1.569 -/* TODO remove testing
1.570 +*/
1.571 cout << "ME::undo() end\n";
1.572 cout << " undosAvail="<<undosAvail<<endl;
1.573 - cout << " undoNum="<<undoNum<<endl;
1.574 + cout << " redosAvail="<<redosAvail<<endl;
1.575 + cout << " curStep="<<curStep<<endl;
1.576 cout << " ---------------------------"<<endl<<endl;
1.577 -*/
1.578 +
1.579 + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
1.580 + undoSet.setEntry ("/history/redosAvail",QString::number(undosAvail));
1.581 + undoSet.setEntry ("/history/curStep",QString::number(curStep));
1.582 + undoSet.writeSettings(histPath);
1.583 +
1.584 + updateActions();
1.585 }
1.586
1.587 void MapEditor::undoXML(const QString &undoSel, const QString &bakMapPath)
1.588 @@ -1400,9 +1393,6 @@
1.589
1.590 void MapEditor::pasteNoSave()
1.591 {
1.592 - // Finish open lineEdits
1.593 - if (lineedit) finishedLineEdit();
1.594 -
1.595 load (clipboardDir+"/part.xml",ImportAdd);
1.596 }
1.597
1.598 @@ -1417,7 +1407,7 @@
1.599 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.600 typeid(*selection) == typeid(MapCenterObj)))
1.601 {
1.602 - saveState(selection,QString("Paste to %1").arg( getName(selection)));
1.603 + saveStatePart(selection,QString("Paste to %1").arg( getName(selection)));
1.604 pasteNoSave();
1.605 mapCenter->reposition();
1.606 adjustCanvasSize();
1.607 @@ -1426,7 +1416,7 @@
1.608
1.609 void MapEditor::cut()
1.610 {
1.611 - saveState(selection->getParObj(),QString("Cut %1").arg(getName(selection)));
1.612 + saveStatePart(selection->getParObj(),QString("Cut %1").arg(getName(selection)));
1.613 copy();
1.614 cutNoSave();
1.615 mapCenter->reposition();
1.616 @@ -1443,9 +1433,6 @@
1.617
1.618 void MapEditor::moveBranchUp()
1.619 {
1.620 - // Finish open lineEdits
1.621 - if (lineedit) finishedLineEdit();
1.622 -
1.623 BranchObj* bo;
1.624 BranchObj* par;
1.625 if (typeid(*selection) == typeid(BranchObj) )
1.626 @@ -1456,7 +1443,7 @@
1.627 selection->unselect();
1.628 selection=par->moveBranchUp (bo);
1.629 selection->select();
1.630 - saveState("moveBranchDown ()",bo,QString("Move up %1").arg(getName(bo)));
1.631 + saveStateX(bo,"moveBranchDown ()",QString("Move up %1").arg(getName(bo)));
1.632 mapCenter->reposition();
1.633 ensureSelectionVisible();
1.634 }
1.635 @@ -1464,9 +1451,6 @@
1.636
1.637 void MapEditor::moveBranchDown()
1.638 {
1.639 - // Finish open lineEdits
1.640 - if (lineedit) finishedLineEdit();
1.641 -
1.642 BranchObj* bo;
1.643 BranchObj* par;
1.644 if (typeid(*selection) == typeid(BranchObj) )
1.645 @@ -1477,7 +1461,7 @@
1.646 selection->unselect();
1.647 selection=par->moveBranchDown(bo);
1.648 selection->select();
1.649 - saveState("moveBranchUp ()",bo,QString("Move down %1").arg(getName(bo)));
1.650 + saveStateX(bo,"moveBranchUp ()",QString("Move down %1").arg(getName(bo)));
1.651 mapCenter->reposition();
1.652 ensureSelectionVisible();
1.653 }
1.654 @@ -1485,32 +1469,56 @@
1.655
1.656 void MapEditor::editHeading()
1.657 {
1.658 - // Finish open lineEdits
1.659 - if (lineedit->isVisible())
1.660 - {
1.661 - finishedLineEdit();
1.662 - return;
1.663 - }
1.664 -
1.665 +/* FIXME not needed any longer
1.666 if (selection &&
1.667 (typeid(*selection) == typeid(BranchObj) ||
1.668 typeid(*selection) == typeid(MapCenterObj) ) )
1.669 {
1.670 editingBO=(BranchObj*)selection;
1.671 -
1.672 ensureSelectionVisible();
1.673 QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y()));
1.674 - lineedit->setGeometry(p.x()-contentsX(),p.y()-contentsY(),200,25);
1.675 - QString s=editingBO->getHeading();
1.676 - lineedit->setText(s);
1.677 - lineedit->setCursorPosition(1);
1.678 - if (actionSettingsAutoselectText->isOn() && !s.isEmpty() && actionSettingsPasteNewHeading->isOn() )
1.679 - lineedit->selectAll();
1.680 - lineedit->show();
1.681 - lineedit->setFocus();
1.682 - lineedit->grabKeyboard();
1.683 - cout << "le="<<lineedit<<" kgrabber="<<keyboardGrabber()<<endl;
1.684 - }
1.685 +
1.686 + QDialog *d =new QDialog(NULL);
1.687 + QLineEdit *le=new QLineEdit (d);
1.688 + d->setWindowFlags (Qt::FramelessWindowHint);
1.689 + QPoint q=mapToGlobal (QPoint(0,0));
1.690 + d->setGeometry(p.x()+q.x(),p.y()+q.y(),200,25);
1.691 + le->resize (d->size());
1.692 + le->setText (editingBO->getHeading());
1.693 + le->selectAll();
1.694 + connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
1.695 + d->activateWindow();
1.696 + d->exec();
1.697 +
1.698 + saveStateConstSelection(
1.699 + "setHeading (\""+editingBO->getHeading()+"\")",
1.700 + "setHeading (\""+le->text()+"\")",
1.701 + QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(le->text()) );
1.702 + editingBO->setHeading(le->text() );
1.703 + editingBO=NULL;
1.704 + mapCenter->reposition();
1.705 + adjustCanvasSize();
1.706 + ensureSelectionVisible();
1.707 + activateWindow();
1.708 + }
1.709 +*/
1.710 +}
1.711 +
1.712 +QString MapEditor::getHeading(bool &ok, QPoint &p)
1.713 +{
1.714 + if (selection &&
1.715 + (typeid(*selection) == typeid(BranchObj) ||
1.716 + typeid(*selection) == typeid(MapCenterObj) ) )
1.717 + {
1.718 + ok=true;
1.719 + ensureSelectionVisible();
1.720 + p = ((BranchObj*)selection)->getAbsPos();
1.721 + p.setY(p.y()+((BranchObj*)selection)->height()/2);
1.722 +// p = mapTo(mainWindow,worldMatrix().map( p));
1.723 + return ((BranchObj*)selection)->getHeading();
1.724 + }
1.725 + ok=false;
1.726 + return QString();
1.727 }
1.728
1.729 void MapEditor::setHeading(const QString &s)
1.730 @@ -1520,14 +1528,20 @@
1.731 (typeid(*selection) == typeid(BranchObj) ||
1.732 typeid(*selection) == typeid(MapCenterObj) ) )
1.733 {
1.734 - ((BranchObj*)selection)->setHeading(s);
1.735 + editingBO=(BranchObj*)selection;
1.736 + saveStateConstSelection(
1.737 + "setHeading (\""+editingBO->getHeading()+"\")",
1.738 + "setHeading (\""+s+"\")",
1.739 + QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(s) );
1.740 + editingBO->setHeading(s );
1.741 + editingBO=NULL;
1.742 mapCenter->reposition();
1.743 adjustCanvasSize();
1.744 ensureSelectionVisible();
1.745 }
1.746 }
1.747
1.748 -void MapEditor::setURL (const QString &s)
1.749 +void MapEditor::setURLInt (const QString &s)
1.750 {
1.751 // Internal function, no saveState needed
1.752 if (selection &&
1.753 @@ -1541,7 +1555,20 @@
1.754 }
1.755 }
1.756
1.757 -void MapEditor::setVymLink (const QString &s)
1.758 +void MapEditor::setHeadingInt(const QString &s)
1.759 +{
1.760 + if (selection &&
1.761 + (typeid(*selection) == typeid(BranchObj) ||
1.762 + typeid(*selection) == typeid(MapCenterObj) ) )
1.763 + {
1.764 + ((BranchObj*)selection)->setHeading(s);
1.765 + mapCenter->reposition();
1.766 + adjustCanvasSize();
1.767 + ensureSelectionVisible();
1.768 + }
1.769 +}
1.770 +
1.771 +void MapEditor::setVymLinkInt (const QString &s)
1.772 {
1.773 // Internal function, no saveState needed
1.774 if (selection &&
1.775 @@ -1557,15 +1584,11 @@
1.776
1.777 void MapEditor::addNewBranch(int pos)
1.778 {
1.779 - // Finish open lineEdits
1.780 - if (lineedit) finishedLineEdit();
1.781 -
1.782 if (selection &&
1.783 (typeid(*selection) == typeid(BranchObj) ||
1.784 typeid(*selection) == typeid(MapCenterObj) ) )
1.785 {
1.786 BranchObj* bo1 = (BranchObj*) selection;
1.787 - saveState(selection, QString("Add new branch to %1").arg(getName(bo1))); //TODO undoCommand
1.788
1.789 bool wasScrolled=false;
1.790 BranchObj *newbo=NULL;
1.791 @@ -1588,14 +1611,65 @@
1.792 newbo=parbo->insertBranch(bo1->getNum()+1);
1.793 } else
1.794 // This should not happen...
1.795 + // ...but it happens if CTRL-A is pressed on MCO,
1.796 + // ignore it then
1.797 return;
1.798 -
1.799 }
1.800 + saveStateX(selection,QString ("delete (\"%1\")").arg(newbo->getSelectString()),QString("Add new branch to %1").arg(getName(bo1))); //TODO undoCommand
1.801
1.802 LinkableMapObj *oldselection=selection;
1.803
1.804 mapCenter->reposition();
1.805 adjustCanvasSize();
1.806 +
1.807 +
1.808 + if (actionSettingsAutoedit->isOn() ||
1.809 + actionSettingsAutoselectHeading->isOn() )
1.810 + {
1.811 + selection->unselect();
1.812 + selection=newbo;
1.813 + selection->select();
1.814 + if (actionSettingsPasteNewHeading->isOn() )
1.815 + {
1.816 + BranchObj *bo2= (BranchObj*)selection;
1.817 + bo2->setHeading("");
1.818 + }
1.819 + if (actionSettingsAutoedit->isOn() )
1.820 + mainWindow->editHeading();
1.821 + if (!actionSettingsAutoselectHeading->isOn()
1.822 + && !wasScrolled)
1.823 + {
1.824 + selection->unselect();
1.825 + selection=oldselection;
1.826 + selection->select();
1.827 + }
1.828 + }
1.829 + }
1.830 +}
1.831 +
1.832 +
1.833 +void MapEditor::addNewBranchHere()
1.834 +{
1.835 + if (selection &&
1.836 + (typeid(*selection) == typeid(BranchObj) ) )
1.837 + {
1.838 + BranchObj* bo1 = (BranchObj*) selection;
1.839 + saveStatePart(selection, QString("Add new branch here").arg(getName(bo1)));
1.840 +
1.841 + bool wasScrolled=false;
1.842 + BranchObj *newbo=NULL;
1.843 + BranchObj *parbo=(BranchObj*)(selection->getParObj());
1.844 + if (parbo)
1.845 + {
1.846 + // add below selection
1.847 + newbo=parbo->insertBranch(bo1->getNum()+1);
1.848 + }
1.849 +
1.850 + LinkableMapObj *oldselection=selection;
1.851 + ((BranchObj*)selection)->moveBranchTo (newbo,-1);
1.852 +
1.853 + mapCenter->reposition();
1.854 + adjustCanvasSize();
1.855 if (actionSettingsAutoedit->isOn() ||
1.856 actionSettingsAutoselectHeading->isOn() )
1.857 {
1.858 @@ -1620,61 +1694,8 @@
1.859 }
1.860 }
1.861
1.862 -
1.863 -void MapEditor::addNewBranchHere()
1.864 -{
1.865 - // Finish open lineEdits
1.866 - if (lineedit) finishedLineEdit();
1.867 -
1.868 - if (selection &&
1.869 - (typeid(*selection) == typeid(BranchObj) ) )
1.870 - {
1.871 - BranchObj* bo1 = (BranchObj*) selection;
1.872 - saveState(selection, QString("Add new branch here").arg(getName(bo1)));
1.873 -
1.874 - bool wasScrolled=false;
1.875 - BranchObj *newbo=NULL;
1.876 - BranchObj *parbo=(BranchObj*)(selection->getParObj());
1.877 - if (parbo)
1.878 - {
1.879 - // add below selection
1.880 - newbo=parbo->insertBranch(bo1->getNum()+1);
1.881 - }
1.882 -
1.883 - LinkableMapObj *oldselection=selection;
1.884 - ((BranchObj*)selection)->moveBranchTo (newbo,-1);
1.885 -
1.886 - mapCenter->reposition();
1.887 - adjustCanvasSize();
1.888 - if (actionSettingsAutoedit->isOn() ||
1.889 - actionSettingsAutoselectHeading->isOn() )
1.890 - {
1.891 - selection->unselect();
1.892 - selection=newbo;
1.893 - selection->select();
1.894 - if (actionSettingsPasteNewHeading->isOn() )
1.895 - {
1.896 - BranchObj *bo2= (BranchObj*)selection;
1.897 - bo2->setHeading("");
1.898 - }
1.899 - if (actionSettingsAutoedit->isOn() )
1.900 - editHeading();
1.901 - if (!actionSettingsAutoselectHeading->isOn()
1.902 - && !wasScrolled)
1.903 - {
1.904 - selection->unselect();
1.905 - selection=oldselection;
1.906 - selection->select();
1.907 - }
1.908 - }
1.909 - }
1.910 -}
1.911 -
1.912 void MapEditor::deleteSelection()
1.913 {
1.914 - // Finish open lineEdits
1.915 - if (lineedit) finishedLineEdit();
1.916 -
1.917 if (selection && typeid(*selection) ==typeid(BranchObj) )
1.918 {
1.919 BranchObj* bo=dynamic_cast <BranchObj*> (selection);
1.920 @@ -1682,12 +1703,12 @@
1.921 bo->unselect();
1.922 if (selection->getDepth()>1)
1.923 // Normal branch, save parent with childs
1.924 - saveState(par,QString("Delete %1").arg(getName(bo)));
1.925 + saveStatePart(par,QString("Delete %1").arg(getName(bo)));
1.926 else
1.927 // Mainbranch, save whole map
1.928 // TODO Better would be to insert mainbranch again at pos
1.929 // But undoCommand is missing right now
1.930 - saveState(QString("Delete %1").arg(getName(bo)));
1.931 + saveStateComplete(QString("Delete %1").arg(getName(bo)));
1.932 selection=NULL;
1.933 par->removeBranch(bo);
1.934 selection=par;
1.935 @@ -1700,7 +1721,7 @@
1.936 {
1.937 FloatImageObj* fio=dynamic_cast <FloatImageObj*> (selection);
1.938 BranchObj* par=(BranchObj*)(fio->getParObj());
1.939 - saveState(par, QString("Delete %1").arg(getName(fio)));
1.940 + saveStatePart(par, QString("Delete %1").arg(getName(fio)));
1.941 fio->unselect();
1.942 selection=NULL;
1.943 par->removeFloatImage(fio);
1.944 @@ -1754,7 +1775,7 @@
1.945 return false;
1.946 }
1.947
1.948 -void MapEditor::select (LinkableMapObj *lmo)
1.949 +void MapEditor::selectInt (LinkableMapObj *lmo)
1.950 {
1.951 if (lmo && selection != lmo)
1.952 {
1.953 @@ -1768,7 +1789,7 @@
1.954
1.955 }
1.956
1.957 -void MapEditor::selectNextBranch()
1.958 +void MapEditor::selectNextBranchInt()
1.959 {
1.960 // Increase number of branch
1.961 if (selection)
1.962 @@ -1848,7 +1869,7 @@
1.963 }
1.964 }
1.965
1.966 -void MapEditor::selectPrevBranch()
1.967 +void MapEditor::selectPrevBranchInt()
1.968 {
1.969 // Decrease number of branch
1.970 if (selection)
1.971 @@ -1929,40 +1950,34 @@
1.972
1.973 void MapEditor::selectUpperBranch()
1.974 {
1.975 - // Finish open lineEdits
1.976 - if (lineedit) finishedLineEdit();
1.977 -
1.978 if (selection)
1.979 {
1.980 if (typeid(*selection) == typeid(BranchObj))
1.981 {
1.982 if (selection->getOrientation()==OrientRightOfCenter)
1.983 - selectPrevBranch();
1.984 + selectPrevBranchInt();
1.985 else
1.986 if (selection->getDepth()==1)
1.987 - selectNextBranch();
1.988 + selectNextBranchInt();
1.989 else
1.990 - selectPrevBranch();
1.991 + selectPrevBranchInt();
1.992 }
1.993 }
1.994 }
1.995
1.996 void MapEditor::selectLowerBranch()
1.997 {
1.998 - // Finish open lineEdits
1.999 - if (lineedit) finishedLineEdit();
1.1000 -
1.1001 if (selection)
1.1002 {
1.1003 if (typeid(*selection) == typeid(BranchObj))
1.1004 {
1.1005 if (selection->getOrientation()==OrientRightOfCenter)
1.1006 - selectNextBranch();
1.1007 + selectNextBranchInt();
1.1008 else
1.1009 if (selection->getDepth()==1)
1.1010 - selectPrevBranch();
1.1011 + selectPrevBranchInt();
1.1012 else
1.1013 - selectNextBranch();
1.1014 + selectNextBranchInt();
1.1015 }
1.1016 }
1.1017 }
1.1018 @@ -1970,9 +1985,6 @@
1.1019
1.1020 void MapEditor::selectLeftBranch()
1.1021 {
1.1022 - // Finish open lineEdits
1.1023 - if (lineedit) finishedLineEdit();
1.1024 -
1.1025 BranchObj* bo;
1.1026 BranchObj* par;
1.1027 if (selection)
1.1028 @@ -2032,9 +2044,6 @@
1.1029
1.1030 void MapEditor::selectRightBranch()
1.1031 {
1.1032 - // Finish open lineEdits
1.1033 - if (lineedit) finishedLineEdit();
1.1034 -
1.1035 BranchObj* bo;
1.1036 BranchObj* par;
1.1037
1.1038 @@ -2046,7 +2055,7 @@
1.1039 bo=par->getLastSelectedBranch();
1.1040 if (bo)
1.1041 {
1.1042 - // Workaround for relecting on left and right side
1.1043 + // Workaround for reselecting on left and right side
1.1044 if (bo->getOrientation()==OrientLeftOfCenter)
1.1045 bo=par->getFirstBranch();
1.1046 if (bo)
1.1047 @@ -2092,9 +2101,6 @@
1.1048
1.1049 void MapEditor::selectFirstBranch()
1.1050 {
1.1051 - // Finish open lineEdits
1.1052 - if (lineedit) finishedLineEdit();
1.1053 -
1.1054 BranchObj *bo1;
1.1055 BranchObj *bo2;
1.1056 BranchObj* par;
1.1057 @@ -2117,9 +2123,6 @@
1.1058
1.1059 void MapEditor::selectLastBranch()
1.1060 {
1.1061 - // Finish open lineEdits
1.1062 - if (lineedit) finishedLineEdit();
1.1063 -
1.1064 BranchObj *bo1;
1.1065 BranchObj *bo2;
1.1066 BranchObj* par;
1.1067 @@ -2147,13 +2150,11 @@
1.1068
1.1069 void MapEditor::selectBackgroundColor()
1.1070 {
1.1071 - // Finish open lineEdits
1.1072 - if (lineedit) finishedLineEdit();
1.1073 -
1.1074 QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this );
1.1075 if ( !col.isValid() ) return;
1.1076 setBackgroundColor( col );
1.1077 - saveState(QString("Set background color of map to %1").arg(col.name()));
1.1078 + //TODO undocomm
1.1079 + saveStateComplete(QString("Set background color of map to %1").arg(col.name()));
1.1080 }
1.1081
1.1082 void MapEditor::setBackgroundColor(QColor c)
1.1083 @@ -2183,7 +2184,7 @@
1.1084 typeid(*selection) == typeid(MapCenterObj))
1.1085 {
1.1086 BranchObj *bo=(BranchObj*)selection;
1.1087 - saveState(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand
1.1088 + saveStatePart(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand
1.1089 bo->setColor(actColor); // color branch
1.1090 }
1.1091 }
1.1092 @@ -2197,7 +2198,7 @@
1.1093 typeid(*selection) == typeid(MapCenterObj))
1.1094 {
1.1095 BranchObj *bo=(BranchObj*)selection;
1.1096 - saveState(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand
1.1097 + saveStatePart(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand
1.1098 bo->setColorChilds(actColor); // color links, color childs
1.1099 }
1.1100 }
1.1101 @@ -2212,12 +2213,20 @@
1.1102 typeid(*selection) == typeid(MapCenterObj))
1.1103 {
1.1104 BranchObj *bo=(BranchObj*)selection;
1.1105 - QString s;
1.1106 + QString u,r;
1.1107 if (bo->isSetStandardFlag(f))
1.1108 - s="Unset";
1.1109 + {
1.1110 + r="unsetFlag";
1.1111 + u="setFlag";
1.1112 + }
1.1113 else
1.1114 - s="Set";
1.1115 - saveState(selection, QString("%1 standard flag \"%2\" of %3").arg(s).arg(f).arg(getName(bo)));// TODO undoCommand
1.1116 + {
1.1117 + u="unsetFlag";
1.1118 + r="setFlag";
1.1119 + }
1.1120 + saveStateConstSelection(QString("%1 (\"%2\")").arg(u).arg(f),
1.1121 + QString("%1 (\"%2\")").arg(r).arg(f),
1.1122 + QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo)));
1.1123 bo->toggleStandardFlag (f,actionSettingsUseFlagGroups->isOn());
1.1124 adjustCanvasSize();
1.1125 }
1.1126 @@ -2311,7 +2320,7 @@
1.1127 if ( ok)
1.1128 {
1.1129 // user entered something and pressed OK
1.1130 - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text));
1.1131 + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text));
1.1132 bo->setURL (text);
1.1133 updateActions();
1.1134 }
1.1135 @@ -2333,7 +2342,7 @@
1.1136 typeid(*selection) == typeid(MapCenterObj)) )
1.1137 {
1.1138 BranchObj *bo=(BranchObj*)selection;
1.1139 - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo)));
1.1140 + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo)));
1.1141 bo->setURL (bo->getHeading());
1.1142 updateActions();
1.1143 }
1.1144 @@ -2346,7 +2355,7 @@
1.1145 {
1.1146 BranchObj *bo=(BranchObj*)selection;
1.1147 QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
1.1148 - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo)));
1.1149 + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo)));
1.1150 bo->setURL (url);
1.1151 updateActions();
1.1152 }
1.1153 @@ -2359,7 +2368,7 @@
1.1154 {
1.1155 BranchObj *bo=(BranchObj*)selection;
1.1156 QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
1.1157 - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo)));
1.1158 + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo)));
1.1159 bo->setURL (url);
1.1160 updateActions();
1.1161 }
1.1162 @@ -2381,7 +2390,7 @@
1.1163 QString fn;
1.1164 if ( fd->exec() == QDialog::Accepted )
1.1165 {
1.1166 - saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile()));
1.1167 + saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile()));
1.1168 bo->setVymLink (fd->selectedFile() );
1.1169 updateActions();
1.1170 mapCenter->reposition();
1.1171 @@ -2397,7 +2406,7 @@
1.1172 typeid(*selection) == typeid(MapCenterObj)) )
1.1173 {
1.1174 BranchObj *bo=(BranchObj*)selection;
1.1175 - saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo)));
1.1176 + saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo)));
1.1177 bo->setVymLink ("" );
1.1178 updateActions();
1.1179 mapCenter->reposition();
1.1180 @@ -2425,7 +2434,7 @@
1.1181 oo->setHideInExport(true);
1.1182 s="Set";
1.1183 }
1.1184 - saveState(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand
1.1185 + saveStateComplete(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand
1.1186 actionEditToggleHideExport->setOn (oo->hideInExport());
1.1187 updateActions();
1.1188 mapCenter->reposition();
1.1189 @@ -2453,9 +2462,9 @@
1.1190 BranchObj* par=(BranchObj*)(bo->getParObj());
1.1191 QString s=QString("Remove %1 and keep its childs").arg(getName(bo));
1.1192 if (bo->getDepth()==1)
1.1193 - saveState(s);
1.1194 + saveStateComplete(s);
1.1195 else
1.1196 - saveState(selection->getParObj(),s); // TODO undoCommand
1.1197 + saveStatePart(selection->getParObj(),s); // TODO undoCommand
1.1198 QString sel=selection->getSelectString();
1.1199 unselect();
1.1200 par->removeBranchHere(bo);
1.1201 @@ -2468,7 +2477,7 @@
1.1202 {
1.1203 if (selection && (typeid(*selection) == typeid(BranchObj) ))
1.1204 {
1.1205 - saveState(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection)));
1.1206 + saveStatePart(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection)));
1.1207 ((BranchObj*)selection)->removeChilds();
1.1208 mapCenter->reposition();
1.1209 }
1.1210 @@ -2512,7 +2521,7 @@
1.1211 // Finally show dialog
1.1212 if (dia.exec() == QDialog::Accepted)
1.1213 {
1.1214 - saveState("Edit info about map"); //TODO undoCommand
1.1215 + saveStateComplete("Edit info about map"); //TODO undoCommand
1.1216 mapCenter->setAuthor (dia.getAuthor() );
1.1217 mapCenter->setComment (dia.getComment() );
1.1218 }
1.1219 @@ -2550,8 +2559,16 @@
1.1220 pix.fill( defLinkColor );
1.1221 actionFormatLinkColor->setIconSet( pix );
1.1222
1.1223 - actionEditUndo->setEnabled( mapChanged );
1.1224 actionFileSave->setEnabled( mapUnsaved );
1.1225 + if (undoSet.readNumEntry("/history/undosAvail",0)>0)
1.1226 + actionEditUndo->setEnabled( true);
1.1227 + else
1.1228 + actionEditUndo->setEnabled( false);
1.1229 +
1.1230 + if (undoSet.readNumEntry("/history/redosAvail",0)>0)
1.1231 + actionEditRedo->setEnabled( true);
1.1232 + else
1.1233 + actionEditRedo->setEnabled( false);
1.1234
1.1235 if (selection)
1.1236 {
1.1237 @@ -2710,7 +2727,7 @@
1.1238 {
1.1239 linkstyle=ls;
1.1240
1.1241 - saveState("Set link style"); // TODO undoCommand
1.1242 + saveStateComplete("Set link style"); // TODO undoCommand
1.1243 BranchObj *bo;
1.1244 bo=mapCenter->first();
1.1245 bo=bo->next();
1.1246 @@ -2798,13 +2815,10 @@
1.1247
1.1248 void MapEditor::selectLinkColor()
1.1249 {
1.1250 - // Finish open lineEdits
1.1251 - if (lineedit) finishedLineEdit();
1.1252 -
1.1253 QColor col = QColorDialog::getColor( defLinkColor, this );
1.1254 if ( !col.isValid() ) return;
1.1255 setLinkColor( col );
1.1256 - saveState(QString("Set link color to %1").arg(col.name())); //TODO undoCommand
1.1257 + saveStateComplete(QString("Set link color to %1").arg(col.name())); //TODO undoCommand
1.1258
1.1259 }
1.1260
1.1261 @@ -2820,7 +2834,7 @@
1.1262 s="Unscroll";
1.1263 else
1.1264 s="Scroll";
1.1265 - saveState(selection, QString ("%1 %2").arg(s).arg(getName(bo)));
1.1266 + saveStatePart(selection, QString ("%1 %2").arg(s).arg(getName(bo)));
1.1267 bo->toggleScroll();
1.1268 adjustCanvasSize();
1.1269 canvas()->update();
1.1270 @@ -2860,7 +2874,7 @@
1.1271 QString fn;
1.1272 if ( fd->exec() == QDialog::Accepted )
1.1273 {
1.1274 - saveState(selection, QString("Add floatimage to %1").arg(getName(selection)));
1.1275 + saveStatePart(selection, QString("Add floatimage to %1").arg(getName(selection)));
1.1276 // FIXME in QT4 use: lastImageDir=fd->directory();
1.1277 lastImageDir=QDir (fd->dirPath());
1.1278 QStringList flist = fd->selectedFiles();
1.1279 @@ -2968,7 +2982,7 @@
1.1280 selection->setHideLinkUnselected(b);
1.1281 }
1.1282
1.1283 -void MapEditor::importDir(BranchObj *dst, QDir d)
1.1284 +void MapEditor::importDirInt(BranchObj *dst, QDir d)
1.1285 {
1.1286 if (selection &&
1.1287 (typeid(*selection) == typeid(BranchObj)) ||
1.1288 @@ -2996,7 +3010,7 @@
1.1289 else
1.1290 {
1.1291 // Recursively add subdirs
1.1292 - importDir (bo,d);
1.1293 + importDirInt (bo,d);
1.1294 d.cdUp();
1.1295 }
1.1296 }
1.1297 @@ -3034,7 +3048,7 @@
1.1298 if ( fd->exec() == QDialog::Accepted )
1.1299 {
1.1300 BranchObj *bo=((BranchObj*)selection);
1.1301 - importDir (bo,QDir(fd->selectedFile()) );
1.1302 + importDirInt (bo,QDir(fd->selectedFile()) );
1.1303 mapCenter->reposition();
1.1304 adjustCanvasSize();
1.1305 canvas()->update();
1.1306 @@ -3061,7 +3075,7 @@
1.1307
1.1308 void MapEditor::editXLink(int i)
1.1309 {
1.1310 - qDebug ("ko.");
1.1311 + qDebug ("ko."); //FIXME Huh?
1.1312 if (selection &&
1.1313 (typeid(*selection) == typeid(BranchObj)) ||
1.1314 (typeid(*selection) == typeid(MapCenterObj)) )
1.1315 @@ -3081,7 +3095,7 @@
1.1316 }
1.1317 if (dia.deleteXLink())
1.1318 ((BranchObj*)selection)->deleteXLinkAt(i);
1.1319 - saveState("Edit xLink"); //TODO undoCommand
1.1320 + saveStateComplete("Edit xLink"); //TODO undoCommand
1.1321 }
1.1322 }
1.1323 }
1.1324 @@ -3091,32 +3105,43 @@
1.1325 {
1.1326 cout << "MapEditor::testFunction() called\n";
1.1327
1.1328 - mapCenter->positionBBox();
1.1329 +/*
1.1330 + bool ok;
1.1331 + QString text = QInputDialog::getText(
1.1332 + this,
1.1333 + tr("QInputDialog::getText()"),
1.1334 + tr("User name:"), QLineEdit::Normal,
1.1335 + QDir::home().dirName(), &ok, Qt::FramelessWindowHint);
1.1336 +*/
1.1337 +
1.1338 + QDialog *d =new QDialog(NULL);
1.1339 + QLineEdit *le=new QLineEdit (d);
1.1340 +// d->setModal (true);
1.1341 + d->setWindowFlags (Qt::FramelessWindowHint);
1.1342 + le->setFocus();
1.1343 + le->setText ("Foo");
1.1344 + le->selectAll();
1.1345 + connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
1.1346 + d->exec();
1.1347 + qWarning( le->text());
1.1348 return;
1.1349 -
1.1350 +
1.1351 +
1.1352 +
1.1353 +/*
1.1354 WarningDialog dia;
1.1355 dia.setCancelButton (true);
1.1356 dia.setText("This is a longer \nWarning");
1.1357 dia.setCaption("Warning: Flux problem");
1.1358 dia.setShowAgainName("/warnings/mapeditor");
1.1359 + dia.setWindowFlags (Qt::FramelessWindowHint);
1.1360 if (dia.exec()==QDialog::Accepted)
1.1361 cout << "accepted!\n";
1.1362 else
1.1363 cout << "canceled!\n";
1.1364 return;
1.1365 -
1.1366 - QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
1.1367 -
1.1368 - QProcess *proc= new QProcess (this);
1.1369 - proc->start( ub);
1.1370 - if (!proc->waitForStarted());
1.1371 - {
1.1372 - QMessageBox::warning(0,
1.1373 - tr("Warning"),
1.1374 - tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
1.1375 - }
1.1376 -
1.1377 -
1.1378 +*/
1.1379 +
1.1380 /* Hide hidden stuff temporary, maybe add this as regular function somewhere
1.1381 if (hidemode==HideNone)
1.1382 {
1.1383 @@ -3222,9 +3247,6 @@
1.1384 return;
1.1385 }
1.1386
1.1387 - // Finish open lineEdits
1.1388 - if (lineedit) finishedLineEdit();
1.1389 -
1.1390 QPoint p = inverseWorldMatrix().map(e->pos());
1.1391 LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
1.1392
1.1393 @@ -3239,7 +3261,7 @@
1.1394 if (!foname.isEmpty())
1.1395 {
1.1396 // systemFlag clicked
1.1397 - select (lmo);
1.1398 + selectInt (lmo);
1.1399 if (foname=="url")
1.1400 {
1.1401 if (e->state() & Qt::ControlModifier)
1.1402 @@ -3297,7 +3319,7 @@
1.1403 }
1.1404 if (lmo)
1.1405 {
1.1406 - select (lmo);
1.1407 + selectInt (lmo);
1.1408 // Left Button Move Branches
1.1409 if (e->button() == Qt::LeftButton )
1.1410 {
1.1411 @@ -3370,7 +3392,7 @@
1.1412 if (typeid(*selection) == typeid(FloatImageObj))
1.1413 {
1.1414 FloatObj *fo=(FloatObj*)selection;
1.1415 - saveState(
1.1416 + saveStateConstSelection(
1.1417 "move "+qpointToString(movingObj_orgPos),fo->getSelectString() ,
1.1418 QString("Move %1").arg(getName(selection)));
1.1419 fo->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.1420 @@ -3387,7 +3409,8 @@
1.1421 {
1.1422 if (typeid(*fo) == typeid(FloatImageObj))
1.1423 {
1.1424 - saveState(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) );
1.1425 + //TODO undocom
1.1426 + saveStateComplete(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) );
1.1427 FloatImageObj *fio=(FloatImageObj*)(fo);
1.1428 ((BranchObj*)(lmo))->addFloatImage (fio);
1.1429 fio->unselect();
1.1430 @@ -3513,7 +3536,7 @@
1.1431 tmpXLink->setEnd ( ((BranchObj*)(dst)) );
1.1432 tmpXLink->updateXLink();
1.1433 tmpXLink->activate();
1.1434 - saveState(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand
1.1435 + saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand
1.1436 } else
1.1437 {
1.1438 delete(tmpXLink);
1.1439 @@ -3578,11 +3601,11 @@
1.1440 if (dst->getDepth()==0)
1.1441 bs->move (savePos);
1.1442 }
1.1443 - saveState (undoCom,bs->getSelectString(),QString("Relink %1 to %2").arg(getName(bs)).arg(getName(dst)) );
1.1444 + saveStateConstSelection (undoCom,bs->getSelectString(),QString("Relink %1 to %2").arg(getName(bs)).arg(getName(dst)) );
1.1445 } else
1.1446 if (selection->getDepth()==1)
1.1447 // If we have moved mainbranch only save endposition
1.1448 - saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString(), QString("Move %1 to %2").arg(getName(selection)).arg(qpointToString(movingObj_orgPos)));
1.1449 + saveStateConstSelection("move "+qpointToString(movingObj_orgPos), selection->getSelectString(), QString("Move %1 to %2").arg(getName(selection)).arg(qpointToString(movingObj_orgPos)));
1.1450
1.1451 // Draw the original link, before selection was moved around
1.1452 mapCenter->reposition();
1.1453 @@ -3599,9 +3622,6 @@
1.1454
1.1455 void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e)
1.1456 {
1.1457 - // Finish open lineEdits
1.1458 - if (lineedit) finishedLineEdit();
1.1459 -
1.1460 if (e->button() == Qt::LeftButton )
1.1461 {
1.1462 QPoint p = inverseWorldMatrix().map(e->pos());
1.1463 @@ -3782,7 +3802,7 @@
1.1464 if (update)
1.1465 {
1.1466 //FIXME saveState has to be called earlier for each of the drops...
1.1467 - saveState("Drop Event"); //TODO undo Command
1.1468 + saveStateComplete("Drop Event"); //TODO undo Command
1.1469 mapCenter->reposition();
1.1470 adjustCanvasSize();
1.1471 canvas()->update();
1.1472 @@ -3797,7 +3817,7 @@
1.1473 (typeid(*selection) == typeid(MapCenterObj)) )
1.1474 {
1.1475 BranchObj *bo=((BranchObj*)selection);
1.1476 - saveState(selection,QString("Add floatimage to %1").arg(getName(bo)));
1.1477 + saveStatePart(selection,QString("Add floatimage to %1").arg(getName(bo)));
1.1478 //QString fn=fd->selectedFile();
1.1479 //lastImageDir=fn.left(fn.findRev ("/"));
1.1480 bo->addFloatImage();