mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-04 16:14:00 +01:00
Prohibit duplication of any metadata tag names (up to case); comments
This commit is contained in:
22
src/Tags.cpp
22
src/Tags.cpp
@@ -525,7 +525,7 @@ bool Tags::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (n == wxT("id3v2")) {
|
if (n == wxT("id3v2")) {
|
||||||
// LLL: This is obsolute, but it must be handled and ignored.
|
// LLL: This is obsolete, but it must be handled and ignored.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SetTag(n, v);
|
SetTag(n, v);
|
||||||
@@ -931,6 +931,8 @@ bool TagsEditor::TransferDataFromWindow()
|
|||||||
|
|
||||||
mLocal.Clear();
|
mLocal.Clear();
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
|
// Get tag name from the grid
|
||||||
|
|
||||||
wxString n = mGrid->GetCellValue(i, 0);
|
wxString n = mGrid->GetCellValue(i, 0);
|
||||||
wxString v = mGrid->GetCellValue(i, 1);
|
wxString v = mGrid->GetCellValue(i, 1);
|
||||||
|
|
||||||
@@ -938,6 +940,7 @@ bool TagsEditor::TransferDataFromWindow()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map special tag names back to internal keys
|
||||||
if (n.CmpNoCase(wxGetTranslation(LABEL_ARTIST)) == 0) {
|
if (n.CmpNoCase(wxGetTranslation(LABEL_ARTIST)) == 0) {
|
||||||
n = TAG_ARTIST;
|
n = TAG_ARTIST;
|
||||||
}
|
}
|
||||||
@@ -984,6 +987,8 @@ bool TagsEditor::TransferDataToWindow()
|
|||||||
mGrid->AppendRows();
|
mGrid->AppendRows();
|
||||||
|
|
||||||
mGrid->SetReadOnly(i, 0);
|
mGrid->SetReadOnly(i, 0);
|
||||||
|
// The special tag name that's displayed and translated may not match
|
||||||
|
// the key string used for internal lookup.
|
||||||
mGrid->SetCellValue(i, 0, wxGetTranslation( labelmap[i].label ) );
|
mGrid->SetCellValue(i, 0, wxGetTranslation( labelmap[i].label ) );
|
||||||
mGrid->SetCellValue(i, 1, mLocal.GetTag(labelmap[i].name));
|
mGrid->SetCellValue(i, 1, mLocal.GetTag(labelmap[i].name));
|
||||||
|
|
||||||
@@ -1041,12 +1046,19 @@ void TagsEditor::OnChange(wxGridEvent & event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString n = mGrid->GetCellValue(event.GetRow(), 0);
|
// Do not permit duplication of any of the tags.
|
||||||
for (size_t i = 0; i < STATICCNT; i++) {
|
// Tags differing only in case are nondistinct.
|
||||||
if (n.CmpNoCase(labelmap[i].label) == 0) {
|
auto row = event.GetRow();
|
||||||
|
const wxString key0 = mGrid->GetCellValue(row, 0).Upper();
|
||||||
|
auto nn = mGrid->GetNumberRows();
|
||||||
|
for (decltype(nn) ii = 0; ii < nn; ++ii) {
|
||||||
|
if (ii == row)
|
||||||
|
continue;
|
||||||
|
auto key = mGrid->GetCellValue(ii, 0).Upper();
|
||||||
|
if (key0.CmpNoCase(key) == 0) {
|
||||||
ischanging = true;
|
ischanging = true;
|
||||||
wxBell();
|
wxBell();
|
||||||
mGrid->SetGridCursor(i, 0);
|
mGrid->SetGridCursor(ii, 0);
|
||||||
event.Veto();
|
event.Veto();
|
||||||
ischanging = false;
|
ischanging = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user