QDateTimeParser: fix handling of AM/PM texts
An AM/PM field is only fixed-width if the locale's AM and PM texts have the same length, which we shouldn't take for granted. (They're not in Albanian, Bosnian or Cherokee.) In sectionMaxSize(), count tells us the case, so we shouldn't be taking both case variants into account, only the one we need. Change-Id: I03b985cc5bf74c34742480558cef08af6343ed93 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
380d97e1bd
commit
cdcfb7c4f9
|
|
@ -640,13 +640,10 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const
|
|||
case LastSection:
|
||||
return 0;
|
||||
|
||||
case AmPmSection: {
|
||||
const int lowerMax = qMax(getAmPmText(AmText, LowerCase).size(),
|
||||
getAmPmText(PmText, LowerCase).size());
|
||||
const int upperMax = qMax(getAmPmText(AmText, UpperCase).size(),
|
||||
getAmPmText(PmText, UpperCase).size());
|
||||
return qMax(lowerMax, upperMax);
|
||||
}
|
||||
case AmPmSection:
|
||||
// Special: "count" here is a case flag, not field width !
|
||||
return qMax(getAmPmText(AmText, count ? UpperCase : LowerCase).size(),
|
||||
getAmPmText(PmText, count ? UpperCase : LowerCase).size());
|
||||
|
||||
case Hour24Section:
|
||||
case Hour12Section:
|
||||
|
|
@ -1937,7 +1934,12 @@ QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const
|
|||
ret |= FixedWidth;
|
||||
break;
|
||||
case AmPmSection:
|
||||
ret |= FixedWidth;
|
||||
// Some locales have different length AM and PM texts.
|
||||
if (getAmPmText(AmText, sn.count ? UpperCase : LowerCase).size()
|
||||
== getAmPmText(PmText, sn.count ? UpperCase : LowerCase).size()) {
|
||||
// Only relevant to DateTimeEdit's fixups in parse().
|
||||
ret |= FixedWidth;
|
||||
}
|
||||
break;
|
||||
case TimeZoneSection:
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue