Commit 64d1bfb3 authored by twanvl's avatar twanvl

Also register choice_images under their non-canonical name.

TODO: be consistent with thumbnail generation, where the value is converted to canonical form first.
parent 2d8eeeb2
...@@ -192,7 +192,8 @@ void ChoiceStyle::initImage() { ...@@ -192,7 +192,8 @@ void ChoiceStyle::initImage() {
// OR_ELSE // OR_ELSE
ScriptCustomCollectionP lookup(new ScriptCustomCollection()); ScriptCustomCollectionP lookup(new ScriptCustomCollection());
FOR_EACH(ci, choice_images) { FOR_EACH(ci, choice_images) {
lookup->key_value[ci.first] = ci.second.getValidScriptP(); lookup->key_value[uncanonical_name_form(ci.first)] =
lookup->key_value[ci.first] = ci.second.getValidScriptP();
} }
Script& script = image.getMutableScript(); Script& script = image.getMutableScript();
script.addInstruction(I_PUSH_CONST, lookup); script.addInstruction(I_PUSH_CONST, lookup);
......
...@@ -193,6 +193,19 @@ String canonical_name_form(const String& str) { ...@@ -193,6 +193,19 @@ String canonical_name_form(const String& str) {
return ret; return ret;
} }
Char uncanonical_name_form(Char c) {
if (c == _('_')) return _(' ');
return c;
}
String uncanonical_name_form(const String& str) {
String ret;
ret.reserve(str.size());
FOR_EACH_CONST(c, str) {
ret += uncanonical_name_form((Char)c);
}
return ret;
}
String name_to_caption(const String& str) { String name_to_caption(const String& str) {
String ret; String ret;
ret.reserve(str.size()); ret.reserve(str.size());
......
...@@ -153,9 +153,11 @@ String capitalize(const String&); ...@@ -153,9 +153,11 @@ String capitalize(const String&);
String capitalize_sentence(const String&); String capitalize_sentence(const String&);
/// Convert a field name to canonical form /// Convert a field name to canonical form
/** - currently only use '_' instead of ' '. /** - currently only convert ' ' to '_'.
*/ */
String canonical_name_form(const String&); String canonical_name_form(const String&);
/// Undo canonical_name_form, this used to be the canonical name form until 2.0.1
String uncanonical_name_form(const String&);
/// Convert a field name to a string that can be shown to the user /// Convert a field name to a string that can be shown to the user
String name_to_caption(const String&); String name_to_caption(const String&);
...@@ -204,8 +206,8 @@ bool is_substr_i(const String& str, size_t pos, const String& cmp); ...@@ -204,8 +206,8 @@ bool is_substr_i(const String& str, size_t pos, const String& cmp);
size_t find_i(const String& heystack, const String& needle); size_t find_i(const String& heystack, const String& needle);
/// Compare two strings for equality, b may contain ' ' where a contains '_' /// Compare two strings for equality, b may contain ' ' where a contains '_'
/** canoncial_name_compare(a,b) == (cannocial_name_form(a) == b) /** canoncial_name_compare(a,b) == (canocial_name_form(a) == b)
* b should already be in cannonical name form * b should already be in canonical name form, i.e. use _ to separate words.
*/ */
bool canoncial_name_compare(const String& a, const Char* b); bool canoncial_name_compare(const String& a, const Char* b);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment