Undo now also works for "original subtitle" subtitle

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@584 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-08-09 16:41:30 +00:00
parent a7bd6fa27d
commit 4cee8187bb
4 changed files with 24 additions and 17 deletions

View File

@ -543,7 +543,7 @@ namespace Nikse.SubtitleEdit.Forms
void timerAddHistoryWhenDone_Tick(object sender, EventArgs e)
{
_timerAddHistoryWhenDone.Stop();
_subtitle.MakeHistoryForUndo(_timerAddHistoryWhenDoneText, GetCurrentSubtitleFormat(), _fileDateTime);
_subtitle.MakeHistoryForUndo(_timerAddHistoryWhenDoneText, GetCurrentSubtitleFormat(), _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName);
}
void AudioWaveForm_OnZoomedChanged(object sender, EventArgs e)
@ -1158,7 +1158,7 @@ namespace Nikse.SubtitleEdit.Forms
public void MakeHistoryForUndo(string description)
{
_subtitle.MakeHistoryForUndo(description, GetCurrentSubtitleFormat(), _fileDateTime);
_subtitle.MakeHistoryForUndo(description, GetCurrentSubtitleFormat(), _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName);
}
/// <summary>
@ -1996,7 +1996,7 @@ namespace Nikse.SubtitleEdit.Forms
}
else
{
_subtitle.MakeHistoryForUndo(string.Format(_language.BeforeConvertingToX, GetCurrentSubtitleFormat().FriendlyName), _oldSubtitleFormat, _fileDateTime);
_subtitle.MakeHistoryForUndo(string.Format(_language.BeforeConvertingToX, GetCurrentSubtitleFormat().FriendlyName), _oldSubtitleFormat, _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName);
_oldSubtitleFormat.RemoveNativeFormatting(_subtitle);
SaveSubtitleListviewIndexes();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
@ -3421,7 +3421,7 @@ namespace Nikse.SubtitleEdit.Forms
string oldFileName = _fileName;
DateTime oldFileDateTime = _fileDateTime;
_fileName = _subtitle.UndoHistory(showHistory.SelectedIndex, out subtitleFormatFriendlyName, out _fileDateTime);
_fileName = _subtitle.UndoHistory(showHistory.SelectedIndex, out subtitleFormatFriendlyName, out _fileDateTime, out _subtitleAlternate, out _subtitleAlternateFileName);
if (string.Compare(oldFileName, _fileName, true) == 0)
_fileDateTime = oldFileDateTime; // undo will not give overwrite-newer-file warning
@ -3878,6 +3878,7 @@ namespace Nikse.SubtitleEdit.Forms
if (i <_subtitleAlternate.Paragraphs.Count)
_subtitleAlternate.Paragraphs.RemoveAt(i);
}
_subtitleAlternate.Renumber(1);
}
var indexes = new List<int>();
@ -3981,6 +3982,7 @@ namespace Nikse.SubtitleEdit.Forms
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
_subtitleAlternate.Renumber(1);
}
if (_networkSession != null)
@ -4056,6 +4058,7 @@ namespace Nikse.SubtitleEdit.Forms
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
_subtitleAlternate.Renumber(1);
}
if (_networkSession != null)
@ -4472,6 +4475,7 @@ namespace Nikse.SubtitleEdit.Forms
originalNew.Text = Utilities.AutoBreakLine(lines[1]);
}
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(originalNew);
_subtitleAlternate.Renumber(1);
}
}
@ -4661,6 +4665,7 @@ namespace Nikse.SubtitleEdit.Forms
original.Text = ChangeAllLinesItalictoSingleItalic(original.Text);
original.Text = Utilities.AutoBreakLine(original.Text);
_subtitleAlternate.Paragraphs.Remove(originalNext);
_subtitleAlternate.Renumber(1);
}
}
@ -8555,7 +8560,7 @@ namespace Nikse.SubtitleEdit.Forms
if (!string.IsNullOrEmpty(pluginResult) && pluginResult.Length > 10 && text != pluginResult)
{
_subtitle.MakeHistoryForUndo(string.Format("Before running plugin: {0} {1}", name, version), GetCurrentSubtitleFormat(), _fileDateTime);
_subtitle.MakeHistoryForUndo(string.Format("Before running plugin: {0} {1}", name, version), GetCurrentSubtitleFormat(), _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName);
string[] lineArray = pluginResult.Split(Environment.NewLine.ToCharArray());
List<string> lines = new List<string>();
foreach (string line in lineArray)
@ -10010,6 +10015,8 @@ namespace Nikse.SubtitleEdit.Forms
index++;
}
_changeAlternate = subtitle.Paragraphs.Count > 0;
if (_changeAlternate)
_subtitleAlternate.Renumber(1);
}
}
}

View File

@ -681,7 +681,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAAegBCQHoAQkBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAfgBCQH4AQkBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@ -11,8 +11,10 @@ namespace Nikse.SubtitleEdit.Logic
public DateTime FileModified { get; set; }
public Subtitle Subtitle { get; set; }
public string SubtitleFormatFriendlyName { get; set; }
public Subtitle OriginalSubtitle { get; set; }
public string OriginalSubtitleFileName { get; set; }
public HistoryItem(int index, Subtitle subtitle, string description, string fileName, DateTime fileModified, string subtitleFormatFriendlyName)
public HistoryItem(int index, Subtitle subtitle, string description, string fileName, DateTime fileModified, string subtitleFormatFriendlyName, Subtitle originalSubtitle, string originalSubtitleFileName)
{
Index = index;
Timestamp = DateTime.Now;
@ -21,6 +23,8 @@ namespace Nikse.SubtitleEdit.Logic
FileName = fileName;
FileModified = fileModified;
SubtitleFormatFriendlyName = subtitleFormatFriendlyName;
OriginalSubtitle = new Subtitle(originalSubtitle);
OriginalSubtitleFileName = originalSubtitleFileName;
}
}
}

View File

@ -122,13 +122,13 @@ namespace Nikse.SubtitleEdit.Logic
return null;
}
public void MakeHistoryForUndo(string description, SubtitleFormat subtitleFormat, DateTime fileModified)
public void MakeHistoryForUndo(string description, SubtitleFormat subtitleFormat, DateTime fileModified, Subtitle original, string originalSubtitleFileName)
{
// don't fill memory with history - use a max rollback points
if (_history.Count > 50)
_history.RemoveAt(0);
_history.Add(new HistoryItem(_history.Count, this, description, FileName, fileModified, subtitleFormat.FriendlyName));
_history.Add(new HistoryItem(_history.Count, this, description, FileName, fileModified, subtitleFormat.FriendlyName, original, originalSubtitleFileName));
}
public bool CanUndo
@ -139,14 +139,7 @@ namespace Nikse.SubtitleEdit.Logic
}
}
public void UndoLast()
{
string subtitleFormatFriendlyName;
DateTime fileModified;
UndoHistory(_history.Count - 1, out subtitleFormatFriendlyName, out fileModified);
}
public string UndoHistory(int index, out string subtitleFormatFriendlyName, out DateTime fileModified)
public string UndoHistory(int index, out string subtitleFormatFriendlyName, out DateTime fileModified, out Subtitle originalSubtitle, out string originalSubtitleFileName)
{
_paragraphs.Clear();
foreach (Paragraph p in _history[index].Subtitle.Paragraphs)
@ -155,6 +148,9 @@ namespace Nikse.SubtitleEdit.Logic
subtitleFormatFriendlyName = _history[index].SubtitleFormatFriendlyName;
FileName = _history[index].FileName;
fileModified = _history[index].FileModified;
originalSubtitle = _history[index].OriginalSubtitle;
originalSubtitleFileName = _history[index].OriginalSubtitleFileName;
return FileName;
}