diff -r 5f6e176e9718 -r c79df732d095 mapeditor.cpp --- a/mapeditor.cpp Wed Sep 06 12:47:06 2006 +0000 +++ b/mapeditor.cpp Fri Sep 08 12:30:09 2006 +0000 @@ -209,7 +209,8 @@ fileName=tr("unnamed"); mapName=""; - undosTotal=settings.readNumEntry("/mapeditor/undoLevels",50); + stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",5); + undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal)); // Initialize find routine itFind=NULL; @@ -232,6 +233,11 @@ updateViewCenter(); mapCenter->reposition(); // for positioning heading + + // Initialize history window; + historyWindow.setME(this); + historyWindow.setStepsTotal(stepsTotal); + historyWindow.update (undoSet); } MapEditor::~MapEditor() @@ -545,11 +551,12 @@ setChanged(); int undosAvail=undoSet.readNumEntry ("/history/undosAvail",0); + int redosAvail=undoSet.readNumEntry ("/history/redosAvail",0); int curStep=undoSet.readNumEntry ("/history/curStep",0); // Find out current undo directory - if (undosAvailundosTotal) curStep=1; + if (curStep>stepsTotal) curStep=1; QString backupXML; QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); @@ -594,8 +601,9 @@ /* TODO remove after testing */ //cout << " into="<< histPath.toStdString()<0) redosAvail--; - if (undosAvailundosTotal) curStep=1; + if (curStep>stepsTotal) curStep=1; QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep)); QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep)); QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep)); @@ -1335,6 +1346,7 @@ undoSet.setEntry ("/history/curStep",QString::number(curStep)); undoSet.writeSettings(histPath); + historyWindow.update (undoSet); updateActions(); /* TODO remove testing @@ -1356,6 +1368,10 @@ int curStep=undoSet.readNumEntry (QString("/history/curStep")); int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail")); int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail")); + + // Can we undo at all? + if (undosAvail<1) return; + QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep)); QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep)); QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep)); @@ -1387,7 +1403,7 @@ undosAvail--; curStep--; - if (curStep<1) curStep=undosTotal; + if (curStep<1) curStep=stepsTotal; redosAvail++; @@ -1405,9 +1421,30 @@ undoSet.setEntry ("/history/curStep",QString::number(curStep)); undoSet.writeSettings(histPath); + historyWindow.update (undoSet); updateActions(); } +void MapEditor::gotoStep (int i) +{ + // Restore variables + int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail")); + + if (i<0) return; + + // Clicking above current steps let's us undo things + if (iundosAvail) + for (int j=undosAvail; j