Translate AM/PM under the QDateTimeParser context so it is consistent

In order to ensure that the same text will be used in both QDateTimeParser
and QDateTimeEdit, use the QDateTimeParser context for the AM and PM
strings.

Task-number: QTBUG-251
Change-Id: I89b0809825251181440bf19cbe5828024a43acfb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
Andy Shaw 2015-01-02 10:09:21 +01:00 committed by Giuseppe D'Angelo
parent 765fea8dad
commit e22d75d0b1
3 changed files with 11 additions and 10 deletions

View File

@ -1362,11 +1362,11 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex
\internal
returns
0 if str == QDateTimeEdit::tr("AM")
1 if str == QDateTimeEdit::tr("PM")
2 if str can become QDateTimeEdit::tr("AM")
3 if str can become QDateTimeEdit::tr("PM")
4 if str can become QDateTimeEdit::tr("PM") and can become QDateTimeEdit::tr("AM")
0 if str == tr("AM")
1 if str == tr("PM")
2 if str can become tr("AM")
3 if str can become tr("PM")
4 if str can become tr("PM") and can become tr("AM")
-1 can't become anything sensible
*/
@ -1737,9 +1737,9 @@ QDateTime QDateTimeParser::getMaximum() const
QString QDateTimeParser::getAmPmText(AmPm ap, Case cs) const
{
if (ap == AmText) {
return (cs == UpperCase ? QLatin1String("AM") : QLatin1String("am"));
return (cs == UpperCase ? tr("AM") : tr("am"));
} else {
return (cs == UpperCase ? QLatin1String("PM") : QLatin1String("pm"));
return (cs == UpperCase ? tr("PM") : tr("pm"));
}
}

View File

@ -54,7 +54,7 @@
# include "QtCore/qvariant.h"
#endif
#include "QtCore/qvector.h"
#include "QtCore/qcoreapplication.h"
#define QDATETIMEEDIT_TIME_MIN QTime(0, 0, 0, 0)
#define QDATETIMEEDIT_TIME_MAX QTime(23, 59, 59, 999)
@ -72,6 +72,7 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QDateTimeParser
{
Q_DECLARE_TR_FUNCTIONS(QDateTimeParser)
public:
enum Context {
FromString,

View File

@ -2316,9 +2316,9 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event)
QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const
{
if (ap == AmText) {
return (cs == UpperCase ? QDateTimeEdit::tr("AM") : QDateTimeEdit::tr("am"));
return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
} else {
return (cs == UpperCase ? QDateTimeEdit::tr("PM") : QDateTimeEdit::tr("pm"));
return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
}
}