mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
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:
parent
a7bd6fa27d
commit
4cee8187bb
@ -543,7 +543,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
void timerAddHistoryWhenDone_Tick(object sender, EventArgs e)
|
void timerAddHistoryWhenDone_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_timerAddHistoryWhenDone.Stop();
|
_timerAddHistoryWhenDone.Stop();
|
||||||
_subtitle.MakeHistoryForUndo(_timerAddHistoryWhenDoneText, GetCurrentSubtitleFormat(), _fileDateTime);
|
_subtitle.MakeHistoryForUndo(_timerAddHistoryWhenDoneText, GetCurrentSubtitleFormat(), _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioWaveForm_OnZoomedChanged(object sender, EventArgs e)
|
void AudioWaveForm_OnZoomedChanged(object sender, EventArgs e)
|
||||||
@ -1158,7 +1158,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
|
|
||||||
public void MakeHistoryForUndo(string description)
|
public void MakeHistoryForUndo(string description)
|
||||||
{
|
{
|
||||||
_subtitle.MakeHistoryForUndo(description, GetCurrentSubtitleFormat(), _fileDateTime);
|
_subtitle.MakeHistoryForUndo(description, GetCurrentSubtitleFormat(), _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1996,7 +1996,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
}
|
}
|
||||||
else
|
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);
|
_oldSubtitleFormat.RemoveNativeFormatting(_subtitle);
|
||||||
SaveSubtitleListviewIndexes();
|
SaveSubtitleListviewIndexes();
|
||||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||||
@ -3421,7 +3421,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
string oldFileName = _fileName;
|
string oldFileName = _fileName;
|
||||||
DateTime oldFileDateTime = _fileDateTime;
|
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)
|
if (string.Compare(oldFileName, _fileName, true) == 0)
|
||||||
_fileDateTime = oldFileDateTime; // undo will not give overwrite-newer-file warning
|
_fileDateTime = oldFileDateTime; // undo will not give overwrite-newer-file warning
|
||||||
@ -3878,6 +3878,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
if (i <_subtitleAlternate.Paragraphs.Count)
|
if (i <_subtitleAlternate.Paragraphs.Count)
|
||||||
_subtitleAlternate.Paragraphs.RemoveAt(i);
|
_subtitleAlternate.Paragraphs.RemoveAt(i);
|
||||||
}
|
}
|
||||||
|
_subtitleAlternate.Renumber(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var indexes = new List<int>();
|
var indexes = new List<int>();
|
||||||
@ -3981,6 +3982,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
||||||
{
|
{
|
||||||
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
|
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
|
||||||
|
_subtitleAlternate.Renumber(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_networkSession != null)
|
if (_networkSession != null)
|
||||||
@ -4056,6 +4058,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
||||||
{
|
{
|
||||||
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
|
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
|
||||||
|
_subtitleAlternate.Renumber(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_networkSession != null)
|
if (_networkSession != null)
|
||||||
@ -4472,6 +4475,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
originalNew.Text = Utilities.AutoBreakLine(lines[1]);
|
originalNew.Text = Utilities.AutoBreakLine(lines[1]);
|
||||||
}
|
}
|
||||||
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(originalNew);
|
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(originalNew);
|
||||||
|
_subtitleAlternate.Renumber(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4661,6 +4665,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
original.Text = ChangeAllLinesItalictoSingleItalic(original.Text);
|
original.Text = ChangeAllLinesItalictoSingleItalic(original.Text);
|
||||||
original.Text = Utilities.AutoBreakLine(original.Text);
|
original.Text = Utilities.AutoBreakLine(original.Text);
|
||||||
_subtitleAlternate.Paragraphs.Remove(originalNext);
|
_subtitleAlternate.Paragraphs.Remove(originalNext);
|
||||||
|
_subtitleAlternate.Renumber(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8555,7 +8560,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(pluginResult) && pluginResult.Length > 10 && text != pluginResult)
|
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());
|
string[] lineArray = pluginResult.Split(Environment.NewLine.ToCharArray());
|
||||||
List<string> lines = new List<string>();
|
List<string> lines = new List<string>();
|
||||||
foreach (string line in lineArray)
|
foreach (string line in lineArray)
|
||||||
@ -10010,6 +10015,8 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
_changeAlternate = subtitle.Paragraphs.Count > 0;
|
_changeAlternate = subtitle.Paragraphs.Count > 0;
|
||||||
|
if (_changeAlternate)
|
||||||
|
_subtitleAlternate.Renumber(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@
|
|||||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN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+11,10 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
public DateTime FileModified { get; set; }
|
public DateTime FileModified { get; set; }
|
||||||
public Subtitle Subtitle { get; set; }
|
public Subtitle Subtitle { get; set; }
|
||||||
public string SubtitleFormatFriendlyName { 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;
|
Index = index;
|
||||||
Timestamp = DateTime.Now;
|
Timestamp = DateTime.Now;
|
||||||
@ -21,6 +23,8 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
FileName = fileName;
|
FileName = fileName;
|
||||||
FileModified = fileModified;
|
FileModified = fileModified;
|
||||||
SubtitleFormatFriendlyName = subtitleFormatFriendlyName;
|
SubtitleFormatFriendlyName = subtitleFormatFriendlyName;
|
||||||
|
OriginalSubtitle = new Subtitle(originalSubtitle);
|
||||||
|
OriginalSubtitleFileName = originalSubtitleFileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,13 +122,13 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
return null;
|
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
|
// don't fill memory with history - use a max rollback points
|
||||||
if (_history.Count > 50)
|
if (_history.Count > 50)
|
||||||
_history.RemoveAt(0);
|
_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
|
public bool CanUndo
|
||||||
@ -139,14 +139,7 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UndoLast()
|
public string UndoHistory(int index, out string subtitleFormatFriendlyName, out DateTime fileModified, out Subtitle originalSubtitle, out string originalSubtitleFileName)
|
||||||
{
|
|
||||||
string subtitleFormatFriendlyName;
|
|
||||||
DateTime fileModified;
|
|
||||||
UndoHistory(_history.Count - 1, out subtitleFormatFriendlyName, out fileModified);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string UndoHistory(int index, out string subtitleFormatFriendlyName, out DateTime fileModified)
|
|
||||||
{
|
{
|
||||||
_paragraphs.Clear();
|
_paragraphs.Clear();
|
||||||
foreach (Paragraph p in _history[index].Subtitle.Paragraphs)
|
foreach (Paragraph p in _history[index].Subtitle.Paragraphs)
|
||||||
@ -155,6 +148,9 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
subtitleFormatFriendlyName = _history[index].SubtitleFormatFriendlyName;
|
subtitleFormatFriendlyName = _history[index].SubtitleFormatFriendlyName;
|
||||||
FileName = _history[index].FileName;
|
FileName = _history[index].FileName;
|
||||||
fileModified = _history[index].FileModified;
|
fileModified = _history[index].FileModified;
|
||||||
|
originalSubtitle = _history[index].OriginalSubtitle;
|
||||||
|
originalSubtitleFileName = _history[index].OriginalSubtitleFileName;
|
||||||
|
|
||||||
return FileName;
|
return FileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user