Fixed #162, subsgrid scrollbar didn't update to to reflect changed line counts in the grid after various operations.

Fixed #171, style storages can no longer be created with illegal filename characters, they are replaced with underscores.

Originally committed to SVN as r553.
This commit is contained in:
Niels Martin Hansen 2006-11-23 19:08:46 +00:00
parent 7b68c13318
commit 5c80e6fad2
3 changed files with 72 additions and 1 deletions

View file

@ -19,6 +19,9 @@ Please visit http://aegisub.net to download latest version
- Misc. fixes for building on Linux (Azzy) - Misc. fixes for building on Linux (Azzy)
- Redesigned the FexTracker configuration window (jfs) - Redesigned the FexTracker configuration window (jfs)
- Framegrabs from the video now also includes framenumber in the filename (jfs) - Framegrabs from the video now also includes framenumber in the filename (jfs)
- Scrollbar in main subs grid didn't always allow scrolling through all the subs (jfs)
- You can now no longer create a style storage whose name is invalid as a filename, instead the illegal characters are replaced with a safe character and a warning is displayed (jfs)
o Previously those storages seemed to be created correctly, but were never written to disk and thus lost
= 1.10 beta - 2006.08.07 =========================== = 1.10 beta - 2006.08.07 ===========================

View file

@ -332,6 +332,21 @@ void DialogStyleManager::OnChangeCatalog (wxCommandEvent &event) {
void DialogStyleManager::OnCatalogNew (wxCommandEvent &event) { void DialogStyleManager::OnCatalogNew (wxCommandEvent &event) {
wxString name = wxGetTextFromUser(_("New storage name:"), _("New catalog entry"), _T(""), this); wxString name = wxGetTextFromUser(_("New storage name:"), _("New catalog entry"), _T(""), this);
if (!name.empty()) { if (!name.empty()) {
// Remove bad characters from the name
wxString badchars = wxFileName::GetForbiddenChars();
int badchars_removed = 0;
for (size_t i = 0; i < name.Length(); ++i) {
for (size_t j = 0; j < badchars.Length(); ++j) {
if (name[i] == badchars[j]) {
name[i] = _T('_');
++badchars_removed;
}
}
}
if (badchars_removed > 0) {
wxLogWarning(_("The specified catalog name contains one or more illegal characters. They have been replaced with underscores instead.\nThe catalog has been renamed to \"%s\"."), name.c_str());
}
Store.Clear(); Store.Clear();
StorageList->Clear(); StorageList->Clear();
CatalogList->Append(name); CatalogList->Append(name);

View file

@ -306,79 +306,98 @@ void SubtitlesGrid::OnKeyDown(wxKeyEvent &event) {
/////////////////////// ///////////////////////
// Duplicate selection // Duplicate selection
void SubtitlesGrid::OnDuplicate (wxCommandEvent &WXUNUSED(&event)) { void SubtitlesGrid::OnDuplicate (wxCommandEvent &WXUNUSED(&event)) {
BeginBatch();
wxArrayInt sels = GetSelection(); wxArrayInt sels = GetSelection();
DuplicateLines(sels.front(),sels.back()); DuplicateLines(sels.front(),sels.back());
EndBatch();
} }
////////////////////////////////////////////// //////////////////////////////////////////////
// Duplicate selection and shift by one frame // Duplicate selection and shift by one frame
void SubtitlesGrid::OnDuplicateNextFrame (wxCommandEvent &WXUNUSED(&event)) { void SubtitlesGrid::OnDuplicateNextFrame (wxCommandEvent &WXUNUSED(&event)) {
BeginBatch();
wxArrayInt sels = GetSelection(); wxArrayInt sels = GetSelection();
DuplicateLines(sels.front(),sels.back(),true); DuplicateLines(sels.front(),sels.back(),true);
EndBatch();
} }
///////////// /////////////
// Call swap // Call swap
void SubtitlesGrid::OnSwap (wxCommandEvent &event) { void SubtitlesGrid::OnSwap (wxCommandEvent &event) {
BeginBatch();
wxArrayInt sels = GetSelection(); wxArrayInt sels = GetSelection();
SwapLines(sels.front(),sels.back()); SwapLines(sels.front(),sels.back());
EndBatch();
} }
/////////////////////////// ///////////////////////////
// Call join (concatenate) // Call join (concatenate)
void SubtitlesGrid::OnJoinConcat (wxCommandEvent &event) { void SubtitlesGrid::OnJoinConcat (wxCommandEvent &event) {
BeginBatch();
wxArrayInt sels = GetSelection(); wxArrayInt sels = GetSelection();
JoinLines(sels.front(),sels.back(),true); JoinLines(sels.front(),sels.back(),true);
EndBatch();
} }
/////////////////////// ///////////////////////
// Call join (replace) // Call join (replace)
void SubtitlesGrid::OnJoinReplace (wxCommandEvent &event) { void SubtitlesGrid::OnJoinReplace (wxCommandEvent &event) {
BeginBatch();
wxArrayInt sels = GetSelection(); wxArrayInt sels = GetSelection();
JoinLines(sels.front(),sels.back(),false); JoinLines(sels.front(),sels.back(),false);
EndBatch();
} }
//////////////// ////////////////
// Adjoin lines // Adjoin lines
void SubtitlesGrid::OnAdjoin (wxCommandEvent &event) { void SubtitlesGrid::OnAdjoin (wxCommandEvent &event) {
BeginBatch();
wxArrayInt sels = GetSelection(); wxArrayInt sels = GetSelection();
AdjoinLines(sels.front(),sels.back(),true); AdjoinLines(sels.front(),sels.back(),true);
EndBatch();
} }
void SubtitlesGrid::OnAdjoin2 (wxCommandEvent &event) { void SubtitlesGrid::OnAdjoin2 (wxCommandEvent &event) {
BeginBatch();
wxArrayInt sels = GetSelection(); wxArrayInt sels = GetSelection();
AdjoinLines(sels.front(),sels.back(),false); AdjoinLines(sels.front(),sels.back(),false);
EndBatch();
} }
//////////////////////// ////////////////////////
// Call join as karaoke // Call join as karaoke
void SubtitlesGrid::OnJoinAsKaraoke (wxCommandEvent &event) { void SubtitlesGrid::OnJoinAsKaraoke (wxCommandEvent &event) {
BeginBatch();
wxArrayInt sels = GetSelection(); wxArrayInt sels = GetSelection();
JoinAsKaraoke(sels.front(),sels.back()); JoinAsKaraoke(sels.front(),sels.back());
EndBatch();
} }
///////////////////////// /////////////////////////
// Call split by karaoke // Call split by karaoke
void SubtitlesGrid::OnSplitByKaraoke (wxCommandEvent &event) { void SubtitlesGrid::OnSplitByKaraoke (wxCommandEvent &event) {
BeginBatch();
wxArrayInt sels = GetSelection(); wxArrayInt sels = GetSelection();
for (int i = sels.size()-1; i >= 0; i--) { for (int i = sels.size()-1; i >= 0; i--) {
SplitLineByKaraoke(sels[i]); SplitLineByKaraoke(sels[i]);
} }
ass->FlagAsModified(); ass->FlagAsModified();
CommitChanges(); CommitChanges();
EndBatch();
} }
////////////////////// //////////////////////
// Call insert before // Call insert before
void SubtitlesGrid::OnInsertBefore (wxCommandEvent &event) { void SubtitlesGrid::OnInsertBefore (wxCommandEvent &event) {
BeginBatch();
// Find line // Find line
int n = GetFirstSelRow(); int n = GetFirstSelRow();
@ -399,12 +418,14 @@ void SubtitlesGrid::OnInsertBefore (wxCommandEvent &event) {
InsertLine(def,n,false); InsertLine(def,n,false);
SelectRow(n); SelectRow(n);
editBox->SetToLine(n); editBox->SetToLine(n);
EndBatch();
} }
///////////////////// /////////////////////
// Call insert after // Call insert after
void SubtitlesGrid::OnInsertAfter (wxCommandEvent &event) { void SubtitlesGrid::OnInsertAfter (wxCommandEvent &event) {
BeginBatch();
// Find line // Find line
int n = GetFirstSelRow(); int n = GetFirstSelRow();
int nrows = GetRows(); int nrows = GetRows();
@ -427,12 +448,14 @@ void SubtitlesGrid::OnInsertAfter (wxCommandEvent &event) {
InsertLine(def,n,true); InsertLine(def,n,true);
SelectRow(n+1); SelectRow(n+1);
editBox->SetToLine(n+1); editBox->SetToLine(n+1);
EndBatch();
} }
///////////////////////////////// /////////////////////////////////
// Call insert before with video // Call insert before with video
void SubtitlesGrid::OnInsertBeforeVideo (wxCommandEvent &event) { void SubtitlesGrid::OnInsertBeforeVideo (wxCommandEvent &event) {
BeginBatch();
// Find line // Find line
int n = GetFirstSelRow(); int n = GetFirstSelRow();
@ -447,12 +470,14 @@ void SubtitlesGrid::OnInsertBeforeVideo (wxCommandEvent &event) {
InsertLine(def,n,false); InsertLine(def,n,false);
SelectRow(n); SelectRow(n);
editBox->SetToLine(n); editBox->SetToLine(n);
EndBatch();
} }
//////////////////////////////// ////////////////////////////////
// Call insert after with video // Call insert after with video
void SubtitlesGrid::OnInsertAfterVideo (wxCommandEvent &event) { void SubtitlesGrid::OnInsertAfterVideo (wxCommandEvent &event) {
BeginBatch();
// Find line // Find line
int n = GetFirstSelRow(); int n = GetFirstSelRow();
@ -467,6 +492,7 @@ void SubtitlesGrid::OnInsertAfterVideo (wxCommandEvent &event) {
InsertLine(def,n,true); InsertLine(def,n,true);
SelectRow(n+1); SelectRow(n+1);
editBox->SetToLine(n+1); editBox->SetToLine(n+1);
EndBatch();
} }
@ -494,41 +520,52 @@ void SubtitlesGrid::OnPasteLines (wxCommandEvent &WXUNUSED(&event)) {
/////////////////////////////// ///////////////////////////////
// Copy selection to clipboard // Copy selection to clipboard
void SubtitlesGrid::OnDeleteLines (wxCommandEvent &WXUNUSED(&event)) { void SubtitlesGrid::OnDeleteLines (wxCommandEvent &WXUNUSED(&event)) {
BeginBatch();
DeleteLines(GetSelection()); DeleteLines(GetSelection());
EndBatch();
} }
////////////////////////// //////////////////////////
// Set start to video pos // Set start to video pos
void SubtitlesGrid::OnSetStartToVideo(wxCommandEvent &event) { void SubtitlesGrid::OnSetStartToVideo(wxCommandEvent &event) {
BeginBatch();
SetSubsToVideo(true); SetSubsToVideo(true);
EndBatch();
} }
//////////////////////// ////////////////////////
// Set end to video pos // Set end to video pos
void SubtitlesGrid::OnSetEndToVideo(wxCommandEvent &event) { void SubtitlesGrid::OnSetEndToVideo(wxCommandEvent &event) {
BeginBatch();
SetSubsToVideo(false); SetSubsToVideo(false);
EndBatch();
} }
////////////////////////// //////////////////////////
// Set video pos to start // Set video pos to start
void SubtitlesGrid::OnSetVideoToStart(wxCommandEvent &event) { void SubtitlesGrid::OnSetVideoToStart(wxCommandEvent &event) {
BeginBatch();
SetVideoToSubs(true); SetVideoToSubs(true);
EndBatch();
} }
//////////////////////// ////////////////////////
// Set video pos to end // Set video pos to end
void SubtitlesGrid::OnSetVideoToEnd(wxCommandEvent &event) { void SubtitlesGrid::OnSetVideoToEnd(wxCommandEvent &event) {
BeginBatch();
SetVideoToSubs(false); SetVideoToSubs(false);
EndBatch();
} }
///////////////////// /////////////////////
// 1,1+2,2 Recombine // 1,1+2,2 Recombine
void SubtitlesGrid::On1122Recombine(wxCommandEvent &event) { void SubtitlesGrid::On1122Recombine(wxCommandEvent &event) {
BeginBatch();
// Get selection // Get selection
bool cont; bool cont;
wxArrayInt sel = GetSelection(&cont); wxArrayInt sel = GetSelection(&cont);
@ -547,12 +584,16 @@ void SubtitlesGrid::On1122Recombine(wxCommandEvent &event) {
// Delete middle // Delete middle
DeleteLines(GetRangeArray(n+1,n+1)); DeleteLines(GetRangeArray(n+1,n+1));
EndBatch();
} }
/////////////////// ///////////////////
// 1+2,2 Recombine // 1+2,2 Recombine
void SubtitlesGrid::On122Recombine(wxCommandEvent &event) { void SubtitlesGrid::On122Recombine(wxCommandEvent &event) {
BeginBatch();
// Get selection // Get selection
bool cont; bool cont;
wxArrayInt sel = GetSelection(&cont); wxArrayInt sel = GetSelection(&cont);
@ -584,12 +625,16 @@ void SubtitlesGrid::On122Recombine(wxCommandEvent &event) {
} else { } else {
parentFrame->StatusTimeout(_T("Unable to recombine: Second line is not a suffix of first one.")); parentFrame->StatusTimeout(_T("Unable to recombine: Second line is not a suffix of first one."));
} }
EndBatch();
} }
/////////////////// ///////////////////
// 1,1+2 Recombine // 1,1+2 Recombine
void SubtitlesGrid::On112Recombine(wxCommandEvent &event) { void SubtitlesGrid::On112Recombine(wxCommandEvent &event) {
BeginBatch();
// Get selection // Get selection
bool cont; bool cont;
wxArrayInt sel = GetSelection(&cont); wxArrayInt sel = GetSelection(&cont);
@ -621,6 +666,8 @@ void SubtitlesGrid::On112Recombine(wxCommandEvent &event) {
} else { } else {
parentFrame->StatusTimeout(_T("Unable to recombine: First line is not a prefix of second one.")); parentFrame->StatusTimeout(_T("Unable to recombine: First line is not a prefix of second one."));
} }
EndBatch();
} }
@ -790,14 +837,18 @@ void SubtitlesGrid::CopyLines(wxArrayInt target) {
//////////////////// ////////////////////
// Cut to clipboard // Cut to clipboard
void SubtitlesGrid::CutLines(wxArrayInt target) { void SubtitlesGrid::CutLines(wxArrayInt target) {
BeginBatch();
CopyLines(target); CopyLines(target);
DeleteLines(target); DeleteLines(target);
EndBatch();
} }
////////////////////////////// //////////////////////////////
// Paste lines from clipboard // Paste lines from clipboard
void SubtitlesGrid::PasteLines(int n) { void SubtitlesGrid::PasteLines(int n) {
BeginBatch();
// Prepare text // Prepare text
wxString data = _T(""); wxString data = _T("");
@ -843,6 +894,8 @@ void SubtitlesGrid::PasteLines(int n) {
editBox->SetToLine(n+1); editBox->SetToLine(n+1);
} }
} }
EndBatch();
} }
@ -1196,7 +1249,7 @@ void SubtitlesGrid::SplitLineByKaraoke(int lineNumber) {
kcount++; kcount++;
} }
// POSSIBLE BUG! If the above code throws an exception, the blocks are never cleared!! // POSSIBLE BUG/LEAK! If the above code throws an exception, the blocks are never cleared!!
line->ClearBlocks(); line->ClearBlocks();
{ {