1.1 --- a/mapeditor.cpp Wed Sep 06 12:47:06 2006 +0000
1.2 +++ b/mapeditor.cpp Fri Sep 08 12:30:09 2006 +0000
1.3 @@ -209,7 +209,8 @@
1.4 fileName=tr("unnamed");
1.5 mapName="";
1.6
1.7 - undosTotal=settings.readNumEntry("/mapeditor/undoLevels",50);
1.8 + stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",5);
1.9 + undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal));
1.10
1.11 // Initialize find routine
1.12 itFind=NULL;
1.13 @@ -232,6 +233,11 @@
1.14 updateViewCenter();
1.15
1.16 mapCenter->reposition(); // for positioning heading
1.17 +
1.18 + // Initialize history window;
1.19 + historyWindow.setME(this);
1.20 + historyWindow.setStepsTotal(stepsTotal);
1.21 + historyWindow.update (undoSet);
1.22 }
1.23
1.24 MapEditor::~MapEditor()
1.25 @@ -545,11 +551,12 @@
1.26 setChanged();
1.27
1.28 int undosAvail=undoSet.readNumEntry ("/history/undosAvail",0);
1.29 + int redosAvail=undoSet.readNumEntry ("/history/redosAvail",0);
1.30 int curStep=undoSet.readNumEntry ("/history/curStep",0);
1.31 // Find out current undo directory
1.32 - if (undosAvail<undosTotal) undosAvail++;
1.33 + if (undosAvail<stepsTotal) undosAvail++;
1.34 curStep++;
1.35 - if (curStep>undosTotal) curStep=1;
1.36 + if (curStep>stepsTotal) curStep=1;
1.37
1.38 QString backupXML;
1.39 QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
1.40 @@ -594,8 +601,9 @@
1.41 /* TODO remove after testing
1.42 */
1.43 //cout << " into="<< histPath.toStdString()<<endl;
1.44 - cout << " undosTotal="<<undosTotal<<
1.45 + cout << " stepsTotal="<<stepsTotal<<
1.46 ", undosAvail="<<undosAvail<<
1.47 + ", redosAvail="<<redosAvail<<
1.48 ", curStep="<<curStep<<endl;
1.49 cout << " ---------------------------"<<endl;
1.50 cout << " comment="<<comment.toStdString()<<endl;
1.51 @@ -1292,10 +1300,13 @@
1.52 int curStep=undoSet.readNumEntry (QString("/history/curStep"));
1.53 int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
1.54 int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
1.55 - if (redosAvail>0) redosAvail--;
1.56 - if (undosAvail<undosTotal) undosAvail++;
1.57 + // Can we undo at all?
1.58 + if (redosAvail<1) return;
1.59 + redosAvail--;
1.60 +
1.61 + if (undosAvail<stepsTotal) undosAvail++;
1.62 curStep++;
1.63 - if (curStep>undosTotal) curStep=1;
1.64 + if (curStep>stepsTotal) curStep=1;
1.65 QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
1.66 QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
1.67 QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
1.68 @@ -1335,6 +1346,7 @@
1.69 undoSet.setEntry ("/history/curStep",QString::number(curStep));
1.70 undoSet.writeSettings(histPath);
1.71
1.72 + historyWindow.update (undoSet);
1.73 updateActions();
1.74
1.75 /* TODO remove testing
1.76 @@ -1356,6 +1368,10 @@
1.77 int curStep=undoSet.readNumEntry (QString("/history/curStep"));
1.78 int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
1.79 int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
1.80 +
1.81 + // Can we undo at all?
1.82 + if (undosAvail<1) return;
1.83 +
1.84 QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
1.85 QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
1.86 QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
1.87 @@ -1387,7 +1403,7 @@
1.88
1.89 undosAvail--;
1.90 curStep--;
1.91 - if (curStep<1) curStep=undosTotal;
1.92 + if (curStep<1) curStep=stepsTotal;
1.93
1.94 redosAvail++;
1.95
1.96 @@ -1405,9 +1421,30 @@
1.97 undoSet.setEntry ("/history/curStep",QString::number(curStep));
1.98 undoSet.writeSettings(histPath);
1.99
1.100 + historyWindow.update (undoSet);
1.101 updateActions();
1.102 }
1.103
1.104 +void MapEditor::gotoStep (int i)
1.105 +{
1.106 + // Restore variables
1.107 + int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
1.108 +
1.109 + if (i<0) return;
1.110 +
1.111 + // Clicking above current steps let's us undo things
1.112 + if (i<undosAvail)
1.113 + {
1.114 + for (int j=0; j<undosAvail-i; j++) undo();
1.115 + return;
1.116 + }
1.117 + // Clicking below current steps let's us rendo things
1.118 + if (i>undosAvail)
1.119 + for (int j=undosAvail; j<i; j++) redo();
1.120 +
1.121 + // And ignore clicking the current row ;-)
1.122 +}
1.123 +
1.124 void MapEditor::undoXML(const QString &undoSel, const QString &bakMapPath)
1.125 {
1.126 QString bakMapDir=bakMapPath.left(bakMapPath.findRev("/"));