summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qdatetimeedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets/qdatetimeedit.cpp')
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index acab768d75..3e6afdb586 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -2307,13 +2307,31 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event)
style()->drawComplexControl(QStyle::CC_ComboBox, &optCombo, &p, this);
}
+/*
+ Returns the string for AM and PM markers.
+
+ If a translation for "AM" and "PM" is installed, then use that.
+ Otherwise, use the default implementation, which uses the locale.
+*/
QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const
{
+ QString original;
+ QString translated;
if (ap == AmText) {
- return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
+ original = QLatin1String(cs == UpperCase ? "AM" : "am");
+ translated = (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
} else {
- return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
+ original = QLatin1String(cs == UpperCase ? "PM" : "pm");
+ translated = (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
}
+
+ // This logic fails if a translation exists but doesn't change the string,
+ // which we can accept as a corner-case for which a locale-derived answer
+ // will be acceptable.
+ if (original != translated)
+ return translated;
+
+ return QDateTimeParser::getAmPmText(ap, cs);
}
int QDateTimeEditPrivate::absoluteIndex(QDateTimeEdit::Section s, int index) const
@@ -2601,7 +2619,7 @@ void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw)
QVBoxLayout *widgetLayout = qobject_cast<QVBoxLayout*>(layout());
if (!widgetLayout) {
widgetLayout = new QVBoxLayout(this);
- widgetLayout->setMargin(0);
+ widgetLayout->setContentsMargins(QMargins());
widgetLayout->setSpacing(0);
}
delete calendar.data();