Issue #394 - Fixed conflicting names in style storage.

Originally committed to SVN as r1458.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-29 09:45:11 +00:00
parent ad601c46d1
commit 8d69e930f6
3 changed files with 26 additions and 3 deletions

View File

@ -95,10 +95,19 @@ void AssStyleStorage::Clear () {
///////////// /////////////
// Get names // Get names
wxArrayString AssStyleStorage::GetNames() { wxArrayString AssStyleStorage::GetNames() {
using std::list;
wxArrayString names; wxArrayString names;
for (list<AssStyle*>::iterator cur=style.begin();cur!=style.end();cur++) { for (std::list<AssStyle*>::iterator cur=style.begin();cur!=style.end();cur++) {
names.Add((*cur)->name); names.Add((*cur)->name);
} }
return names; return names;
} }
///////////////////////
// Get a style by name
AssStyle *AssStyleStorage::GetStyle(wxString name) {
for (std::list<AssStyle*>::iterator cur=style.begin();cur!=style.end();cur++) {
if ((*cur)->name == name) return *cur;
}
return NULL;
}

View File

@ -56,6 +56,7 @@ public:
std::list<AssStyle*> style; std::list<AssStyle*> style;
wxArrayString GetNames(); wxArrayString GetNames();
AssStyle *GetStyle(wxString name);
void Clear(); void Clear();
void Save(wxString name); void Save(wxString name);
void Load(wxString name); void Load(wxString name);

View File

@ -440,7 +440,20 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
// Check if style name is unique // Check if style name is unique
for (unsigned int i=0;i<styles.Count();i++) { for (unsigned int i=0;i<styles.Count();i++) {
if (styles[i] == newStyleName) { if (styles[i] == newStyleName) {
if (grid->ass->GetStyle(styles[i]) != style) { bool ok = true;
// Local
if (isLocal) {
if (grid->ass->GetStyle(styles[i]) != style) ok = false;
}
// Storage
else {
if (store->GetStyle(styles[i]) != style) ok = false;
}
// Repeated name
if (!ok) {
wxMessageBox(_T("There is already a style with this name. Please choose another name."),_T("Style name conflict."),wxICON_ERROR); wxMessageBox(_T("There is already a style with this name. Please choose another name."),_T("Style name conflict."),wxICON_ERROR);
return; return;
} }