From 903903147924641a84e62432037b006c6bf541b7 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 29 Aug 2012 12:58:35 +0200 Subject: [PATCH] Fix QDateEdit displaying day as a number for short and long day formats When 2 (February) is entered as the month for (e.g.) 31/Jan/2000 (which is following the format: "dd/MMM/yyyy"), the day is corrected to 29 but displayed as its numerical value instead of its short (or long) name. Task-number: QTBUG-27036 QTBUG-19091 Change-Id: I558ee13b224707d22b26c2ec2c045f96118bd5a1 Reviewed-by: Mitch Curtis Reviewed-by: aavit --- src/corelib/tools/qdatetime.cpp | 56 +++++++--- src/corelib/tools/qdatetime_p.h | 5 +- src/widgets/widgets/qdatetimeedit.cpp | 11 +- .../widgets/qdatetimeedit/tst_qdatetimeedit.cpp | 124 +++++++++++++++------ 4 files changed, 135 insertions(+), 61 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 421e6db..cbbf31b 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -4188,7 +4188,8 @@ int QDateTimeParser::getDigit(const QDateTime &t, int index) const case YearSection: return t.date().year(); case MonthSection: return t.date().month(); case DaySection: return t.date().day(); - case DayOfWeekSection: return t.date().day(); + case DayOfWeekSectionShort: + case DayOfWeekSectionLong: return t.date().day(); case AmPmSection: return t.time().hour() > 11 ? 1 : 0; default: break; @@ -4246,7 +4247,8 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const case YearSection: year = newVal; break; case MonthSection: month = newVal; break; case DaySection: - case DayOfWeekSection: + case DayOfWeekSectionShort: + case DayOfWeekSectionLong: if (newVal > 31) { // have to keep legacy behavior. setting the // date to 32 should return false. Setting it @@ -4262,7 +4264,7 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const break; } - if (!(node.type & (DaySection|DayOfWeekSection))) { + if (!(node.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) { if (day < cachedDay) day = cachedDay; const int max = QDate(year, month, 1).daysInMonth(); @@ -4303,7 +4305,8 @@ int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const // stepBy() will work on real years anyway case MonthSection: return 12; case DaySection: - case DayOfWeekSection: return cur.isValid() ? cur.date().daysInMonth() : 31; + case DayOfWeekSectionShort: + case DayOfWeekSectionLong: return cur.isValid() ? cur.date().daysInMonth() : 31; case AmPmSection: return 1; default: break; } @@ -4331,7 +4334,8 @@ int QDateTimeParser::absoluteMin(int s) const case YearSection: return 0; case MonthSection: case DaySection: - case DayOfWeekSection: return 1; + case DayOfWeekSectionShort: + case DayOfWeekSectionLong: return 1; case AmPmSection: return 0; default: break; } @@ -4573,7 +4577,9 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) case 'd': if (parserType != QVariant::Time) { const int repeat = countRepeat(newFormat, i, 4); - const SectionNode sn = { repeat >= 3 ? DayOfWeekSection : DaySection, i - add, repeat, 0 }; + const Section sectionType = (repeat == 4 ? DayOfWeekSectionLong + : (repeat == 3 ? DayOfWeekSectionShort : DaySection)); + const SectionNode sn = { sectionType, i - add, repeat, 0 }; newSectionNodes.append(sn); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); i += sn.count - 1; @@ -4688,7 +4694,8 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const case MinuteSection: case SecondSection: case DaySection: return 2; - case DayOfWeekSection: + case DayOfWeekSectionShort: + case DayOfWeekSectionLong: #ifdef QT_NO_TEXTDATE return 2; #else @@ -4843,7 +4850,8 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde } break; } case MonthSection: - case DayOfWeekSection: + case DayOfWeekSectionShort: + case DayOfWeekSectionLong: if (sn.count >= 3) { if (sn.type == MonthSection) { int min = 1; @@ -5049,7 +5057,8 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos case YearSection: current = &year; break; case YearSection2Digits: current = &year2digits; break; case MonthSection: current = &month; break; - case DayOfWeekSection: current = &dayofweek; break; + case DayOfWeekSectionShort: + case DayOfWeekSectionLong: current = &dayofweek; break; case DaySection: current = &day; num = qMax(1, num); break; case AmPmSection: current = &m; break; default: @@ -5103,10 +5112,10 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos const QDate date(year, month, day); const int diff = dayofweek - date.dayOfWeek(); - if (diff != 0 && state == Acceptable && isSet & DayOfWeekSection) { + if (diff != 0 && state == Acceptable && isSet & (DayOfWeekSectionShort|DayOfWeekSectionLong)) { conflicts = isSet & DaySection; const SectionNode &sn = sectionNode(currentSectionIndex); - if (sn.type == DayOfWeekSection || currentSectionIndex == -1) { + if (sn.type & (DayOfWeekSectionShort|DayOfWeekSectionLong) || currentSectionIndex == -1) { // dayofweek should be preferred day += diff; if (day <= 0) { @@ -5119,7 +5128,7 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos } } bool needfixday = false; - if (sectionType(currentSectionIndex) & (DaySection|DayOfWeekSection)) { + if (sectionType(currentSectionIndex) & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) { cachedDay = day; } else if (cachedDay > day) { day = cachedDay; @@ -5144,8 +5153,15 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos const QLocale loc = locale(); for (int i=0; i 0) { setDigit(v, sectionIndex, min); - if (!(sn.type & (DaySection|DayOfWeekSection)) && sections & DateSectionMask) { + if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) && sections & DateSectionMask) { const int daysInMonth = v.date().daysInMonth(); if (v.date().day() < oldDay && v.date().day() < daysInMonth) { const int adds = qMin(oldDay, daysInMonth); @@ -2061,7 +2061,7 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c } } else { setDigit(v, sectionIndex, max); - if (!(sn.type & (DaySection|DayOfWeekSection)) && sections & DateSectionMask) { + if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) && sections & DateSectionMask) { const int daysInMonth = v.date().daysInMonth(); if (v.date().day() < oldDay && v.date().day() < daysInMonth) { const int adds = qMin(oldDay, daysInMonth); @@ -2079,7 +2079,7 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c setDigit(v, sectionIndex, (steps > 0 ? localmax : localmin)); } } - if (!test && oldDay != v.date().day() && !(sn.type & (DaySection|DayOfWeekSection))) { + if (!test && oldDay != v.date().day() && !(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) { // this should not happen when called from stepEnabled cachedDay = qMax(oldDay, cachedDay); } @@ -2247,7 +2247,8 @@ QDateTimeEdit::Section QDateTimeEditPrivate::convertToPublic(QDateTimeParser::Se case MSecSection: return QDateTimeEdit::MSecSection; case SecondSection: return QDateTimeEdit::SecondSection; case MinuteSection: return QDateTimeEdit::MinuteSection; - case DayOfWeekSection: + case DayOfWeekSectionShort: + case DayOfWeekSectionLong: case DaySection: return QDateTimeEdit::DaySection; case MonthSection: return QDateTimeEdit::MonthSection; case YearSection2Digits: @@ -2274,7 +2275,7 @@ QDateTimeEdit::Sections QDateTimeEditPrivate::convertSections(QDateTimeParser::S ret |= QDateTimeEdit::HourSection; if (s & QDateTimeParser::AmPmSection) ret |= QDateTimeEdit::AmPmSection; - if (s & (QDateTimeParser::DaySection|QDateTimeParser::DayOfWeekSection)) + if (s & (QDateTimeParser::DaySection|QDateTimeParser::DayOfWeekSectionShort|QDateTimeParser::DayOfWeekSectionLong)) ret |= QDateTimeEdit::DaySection; if (s & QDateTimeParser::MonthSection) ret |= QDateTimeEdit::MonthSection; diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index e185e0a..269d5b1 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -3498,6 +3498,7 @@ void tst_QDateTimeEdit::deleteCalendarWidget() typedef QPair KeyPair; typedef QList KeyPairList; +Q_DECLARE_METATYPE(QLocale) Q_DECLARE_METATYPE(KeyPair) Q_DECLARE_METATYPE(KeyPairList) @@ -3519,12 +3520,14 @@ focus changed. void tst_QDateTimeEdit::dateEditCorrectSectionSize_data() { + QTest::addColumn("locale"); QTest::addColumn("defaultDate"); QTest::addColumn("displayFormat"); QTest::addColumn("keyPresses"); QTest::addColumn("expectedDisplayString"); const QDate defaultDate(2000, 1, 1); + const QLocale defaultLocale(QLocale::English, QLocale::Australia); KeyPairList thirtyUpKeypresses; thirtyUpKeypresses.reserve(30); @@ -3614,123 +3617,172 @@ void tst_QDateTimeEdit::dateEditCorrectSectionSize_data() << key(Qt::Key_3) << key(Qt::Key_1) << key(Qt::Key_Tab, Qt::ShiftModifier) << key(Qt::Key_Tab, Qt::ShiftModifier) << key(Qt::Key_Up); - QTest::newRow("fixday, leap, yy/MM/dd") << defaultDate << QString::fromLatin1("yy/MM/dd") + KeyPairList shortAndLongNameIssueKeypresses; + shortAndLongNameIssueKeypresses << key(Qt::Key_Tab) << key(Qt::Key_3) << key(Qt::Key_1) << key(Qt::Key_Up); + + QTest::newRow("no fixday, leap, yy/M/dddd") << defaultLocale << defaultDate << QString::fromLatin1("yy/M/dddd") + << threeDigitDayIssueKeypresses_DayName << QString::fromLatin1("00/2/Tuesday"); + + QTest::newRow("no fixday, leap, yy/M/ddd") << defaultLocale << defaultDate << QString::fromLatin1("yy/M/ddd") + << threeDigitDayIssueKeypresses_DayName << QString::fromLatin1("00/2/Tue"); + + QTest::newRow("no fixday, leap, yy/MM/dddd") << defaultLocale << defaultDate << QString::fromLatin1("yy/MM/dddd") + << threeDigitDayIssueKeypresses_DayName << QString::fromLatin1("00/02/Tuesday"); + + QTest::newRow("fixday, leap, yy/MM/dd") << defaultLocale << defaultDate << QString::fromLatin1("yy/MM/dd") << threeDigitDayIssueKeypresses << QString::fromLatin1("00/02/29"); - QTest::newRow("fixday, leap, yy/MM/d") << defaultDate << QString::fromLatin1("yy/MM/d") + QTest::newRow("fixday, leap, yy/MM/d") << defaultLocale << defaultDate << QString::fromLatin1("yy/MM/d") << threeDigitDayIssueKeypresses << QString::fromLatin1("00/02/29"); - QTest::newRow("fixday, leap, yyyy/M/d") << defaultDate << QString::fromLatin1("yyyy/M/d") + QTest::newRow("fixday, leap, yyyy/M/d") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/M/d") << threeDigitDayIssueKeypresses << QString::fromLatin1("2000/2/29"); - QTest::newRow("no fixday, yyyy/M/d") << defaultDate.addYears(1) << QString::fromLatin1("yyyy/M/d") + QTest::newRow("no fixday, yyyy/M/d") << defaultLocale << defaultDate.addYears(1) << QString::fromLatin1("yyyy/M/d") << threeDigitDayIssueKeypresses_Nofixday << QString::fromLatin1("2001/2/28"); - QTest::newRow("fixday, leap, 2-digit month, yyyy/M/dd") << defaultDate << QString::fromLatin1("yyyy/M/dd") + QTest::newRow("fixday, leap, 2-digit month, yyyy/M/dd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/M/dd") << threeDigitDayIssueKeypresses_TwoDigitMonth << QString::fromLatin1("2000/11/30"); - QTest::newRow("no fixday, leap, 1-digit day, yyyy/M/dd") << defaultDate << QString::fromLatin1("yyyy/M/dd") + QTest::newRow("no fixday, leap, 1-digit day, yyyy/M/dd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/M/dd") << threeDigitDayIssueKeypresses_OneDigitDay << QString::fromLatin1("2000/2/03"); - QTest::newRow("fixday, leap, yyyy/MM/dd") << defaultDate << QString::fromLatin1("yyyy/MM/dd") + QTest::newRow("fixday, leap, yyyy/MM/dd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/MM/dd") << threeDigitDayIssueKeypresses << QString::fromLatin1("2000/02/29"); - QTest::newRow("no fixday, yyyy/MM/dd") << defaultDate.addYears(1) << QString::fromLatin1("yyyy/MM/dd") + QTest::newRow("no fixday, yyyy/MM/dd") << defaultLocale << defaultDate.addYears(1) << QString::fromLatin1("yyyy/MM/dd") << threeDigitDayIssueKeypresses_Nofixday << QString::fromLatin1("2001/02/28"); - QTest::newRow("fixday, leap, 2-digit month, yyyy/MM/dd") << defaultDate << QString::fromLatin1("yyyy/MM/dd") + QTest::newRow("fixday, leap, 2-digit month, yyyy/MM/dd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/MM/dd") << threeDigitDayIssueKeypresses_TwoDigitMonth << QString::fromLatin1("2000/11/30"); - QTest::newRow("fixday, leap, yyyy/dd/MM") << defaultDate << QString::fromLatin1("yyyy/dd/MM") + QTest::newRow("no fixday, leap, yyyy/M/dddd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/M/dddd") + << threeDigitDayIssueKeypresses_DayName << QString::fromLatin1("2000/2/Tuesday"); + + QTest::newRow("no fixday, leap, yyyy/MM/dddd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/MM/dddd") + << threeDigitDayIssueKeypresses_DayName << QString::fromLatin1("2000/02/Tuesday"); + + QTest::newRow("fixday, leap, yyyy/dd/MM") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/dd/MM") << threeDigitDayIssueKeypresses_YearDayMonth << QString::fromLatin1("2000/29/02"); - QTest::newRow("fixday, leap, yyyy/dd/M") << defaultDate << QString::fromLatin1("yyyy/dd/M") + QTest::newRow("fixday, leap, yyyy/dd/M") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/dd/M") << threeDigitDayIssueKeypresses_YearDayMonth << QString::fromLatin1("2000/29/2"); - QTest::newRow("fixday, leap, yyyy/d/M") << defaultDate << QString::fromLatin1("yyyy/d/M") + QTest::newRow("fixday, leap, yyyy/d/M") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/d/M") << threeDigitDayIssueKeypresses_YearDayMonth << QString::fromLatin1("2000/29/2"); - QTest::newRow("fixday, leap, yyyy/MMM/dd") << defaultDate << QString::fromLatin1("yyyy/MMM/dd") + QTest::newRow("fixday, leap, yyyy/MMM/dd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/MMM/dd") << threeDigitDayIssueKeypresses_ShortMonthName << QString::fromLatin1("2000/Feb/29"); - QTest::newRow("fixday, leap, yyyy/MMM/d") << defaultDate << QString::fromLatin1("yyyy/MMM/d") + QTest::newRow("fixday, leap, yyyy/MMM/d") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/MMM/d") << threeDigitDayIssueKeypresses_ShortMonthName << QString::fromLatin1("2000/Feb/29"); - QTest::newRow("fixday, leap, yy/MMM/dd") << defaultDate << QString::fromLatin1("yy/MMM/dd") + QTest::newRow("fixday, leap, yy/MMM/dd") << defaultLocale << defaultDate << QString::fromLatin1("yy/MMM/dd") << threeDigitDayIssueKeypresses_ShortMonthName << QString::fromLatin1("00/Feb/29"); - QTest::newRow("fixday, leap, d/M/yyyy") << defaultDate << QString::fromLatin1("d/M/yyyy") + QTest::newRow("fixday, leap, yyyy/dddd/M") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/dddd/M") + << threeDigitDayIssueKeypresses_DayName_YearDayMonth << QString::fromLatin1("2000/Tuesday/2"); + + QTest::newRow("fixday, leap, yyyy/dddd/MM") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/dddd/MM") + << threeDigitDayIssueKeypresses_DayName_YearDayMonth << QString::fromLatin1("2000/Tuesday/02"); + + QTest::newRow("fixday, leap, d/M/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("d/M/yyyy") << reverseThreeDigitDayIssueKeypresses << QString::fromLatin1("29/2/2000"); - QTest::newRow("fixday, leap, dd/MM/yyyy") << defaultDate << QString::fromLatin1("dd/MM/yyyy") + QTest::newRow("fixday, leap, dd/MM/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("dd/MM/yyyy") << reverseThreeDigitDayIssueKeypresses << QString::fromLatin1("29/02/2000"); - QTest::newRow("fixday, dd/MM/yyyy") << defaultDate.addYears(1) << QString::fromLatin1("dd/MM/yyyy") + QTest::newRow("fixday, dd/MM/yyyy") << defaultLocale << defaultDate.addYears(1) << QString::fromLatin1("dd/MM/yyyy") << reverseThreeDigitDayIssueKeypresses << QString::fromLatin1("28/02/2001"); - QTest::newRow("fixday, leap, d/yy/M") << defaultDate << QString::fromLatin1("d/yy/M") + QTest::newRow("fixday, leap, dddd/MM/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("dddd/MM/yyyy") + << threeDigitDayIssueKeypresses_DayName_DayMonthYear << QString::fromLatin1("Tuesday/02/2000"); + + QTest::newRow("fixday, leap, d/yy/M") << defaultLocale << defaultDate << QString::fromLatin1("d/yy/M") << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/00/2"); - QTest::newRow("fixday, leap, d/yyyy/M") << defaultDate << QString::fromLatin1("d/yyyy/M") + QTest::newRow("fixday, leap, d/yyyy/M") << defaultLocale << defaultDate << QString::fromLatin1("d/yyyy/M") << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/2000/2"); - QTest::newRow("fixday, leap, d/yyyy/MM") << defaultDate << QString::fromLatin1("d/yyyy/MM") + QTest::newRow("fixday, leap, d/yyyy/MM") << defaultLocale << defaultDate << QString::fromLatin1("d/yyyy/MM") << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/2000/02"); - QTest::newRow("fixday, leap, dd/yy/MM") << defaultDate << QString::fromLatin1("dd/yy/MM") + QTest::newRow("fixday, leap, dd/yy/MM") << defaultLocale << defaultDate << QString::fromLatin1("dd/yy/MM") << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/00/02"); - QTest::newRow("fixday, leap, dd/yyyy/M") << defaultDate << QString::fromLatin1("dd/yyyy/M") + QTest::newRow("fixday, leap, dd/yyyy/M") << defaultLocale << defaultDate << QString::fromLatin1("dd/yyyy/M") << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/2000/2"); - QTest::newRow("fixday, leap, dd/yyyy/MM") << defaultDate << QString::fromLatin1("dd/yyyy/MM") + QTest::newRow("fixday, leap, dd/yyyy/MM") << defaultLocale << defaultDate << QString::fromLatin1("dd/yyyy/MM") << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/2000/02"); - QTest::newRow("fixday, leap, M/d/yy") << defaultDate << QString::fromLatin1("M/d/yy") + QTest::newRow("fixday, leap, dddd/yy/M") << defaultLocale << defaultDate << QString::fromLatin1("dddd/yy/M") + << threeDigitDayIssueKeypresses_DayName_DayYearMonth << QString::fromLatin1("Tuesday/00/2"); + + QTest::newRow("fixday, leap, dddd/yy/MM") << defaultLocale << defaultDate << QString::fromLatin1("dddd/yy/MM") + << threeDigitDayIssueKeypresses_DayName_DayYearMonth << QString::fromLatin1("Tuesday/00/02"); + + QTest::newRow("fixday, leap, M/d/yy") << defaultLocale << defaultDate << QString::fromLatin1("M/d/yy") << threeDigitDayIssueKeypresses_MonthDayYear << QString::fromLatin1("2/29/00"); - QTest::newRow("fixday, leap, M/d/yyyy") << defaultDate << QString::fromLatin1("M/d/yyyy") + QTest::newRow("fixday, leap, M/d/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("M/d/yyyy") << threeDigitDayIssueKeypresses_MonthDayYear << QString::fromLatin1("2/29/2000"); - QTest::newRow("fixday, leap, M/dd/yyyy") << defaultDate << QString::fromLatin1("M/dd/yyyy") + QTest::newRow("fixday, leap, M/dd/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("M/dd/yyyy") << threeDigitDayIssueKeypresses_MonthDayYear << QString::fromLatin1("2/29/2000"); - QTest::newRow("fixday, leap, MM/dd/yyyy") << defaultDate << QString::fromLatin1("MM/dd/yyyy") + QTest::newRow("fixday, leap, M/dddd/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("M/dddd/yyyy") + << threeDigitDayIssueKeypresses_DayName_MonthDayYear << QString::fromLatin1("2/Tuesday/2000"); + + QTest::newRow("fixday, leap, MM/dd/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("MM/dd/yyyy") << threeDigitDayIssueKeypresses_MonthDayYear << QString::fromLatin1("02/29/2000"); - QTest::newRow("fixday, leap, M/yyyy/dd") << defaultDate << QString::fromLatin1("M/yyyy/dd") + QTest::newRow("fixday, leap, MM/dddd/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("MM/dddd/yyyy") + << threeDigitDayIssueKeypresses_DayName_MonthDayYear << QString::fromLatin1("02/Tuesday/2000"); + + QTest::newRow("fixday, leap, M/yyyy/dd") << defaultLocale << defaultDate << QString::fromLatin1("M/yyyy/dd") << threeDigitDayIssueKeypresses_MonthYearDay << QString::fromLatin1("2/2000/29"); - QTest::newRow("fixday, leap, M/yy/dd") << defaultDate << QString::fromLatin1("M/yy/dd") + QTest::newRow("fixday, leap, M/yy/dd") << defaultLocale << defaultDate << QString::fromLatin1("M/yy/dd") << threeDigitDayIssueKeypresses_MonthYearDay << QString::fromLatin1("2/00/29"); - QTest::newRow("fixday, leap, M/yy/d") << defaultDate << QString::fromLatin1("M/yy/d") + QTest::newRow("fixday, leap, M/yy/d") << defaultLocale << defaultDate << QString::fromLatin1("M/yy/d") << threeDigitDayIssueKeypresses_MonthYearDay << QString::fromLatin1("2/00/29"); - QTest::newRow("fixday, leap, MM/yyyy/dd") << defaultDate << QString::fromLatin1("MM/yyyy/dd") + QTest::newRow("fixday, leap, MM/yyyy/dd") << defaultLocale << defaultDate << QString::fromLatin1("MM/yyyy/dd") << threeDigitDayIssueKeypresses_MonthYearDay << QString::fromLatin1("02/2000/29"); - QTest::newRow("fixday, leap, MMM/yy/d") << defaultDate << QString::fromLatin1("MMM/yy/d") + QTest::newRow("fixday, leap, MMM/yy/d") << defaultLocale << defaultDate << QString::fromLatin1("MMM/yy/d") << threeDigitDayIssueKeypresses_ShortMonthName_MonthYearDay << QString::fromLatin1("Feb/00/29"); - QTest::newRow("fixday, leap, MMM/yyyy/d") << defaultDate << QString::fromLatin1("MMM/yyyy/d") + QTest::newRow("fixday, leap, MMM/yyyy/d") << defaultLocale << defaultDate << QString::fromLatin1("MMM/yyyy/d") << threeDigitDayIssueKeypresses_ShortMonthName_MonthYearDay << QString::fromLatin1("Feb/2000/29"); - QTest::newRow("fixday, MMM/yyyy/d") << defaultDate.addYears(1) << QString::fromLatin1("MMM/yyyy/d") + QTest::newRow("fixday, MMM/yyyy/d") << defaultLocale << defaultDate.addYears(1) << QString::fromLatin1("MMM/yyyy/d") << threeDigitDayIssueKeypresses_ShortMonthName_MonthYearDay << QString::fromLatin1("Feb/2001/28"); - QTest::newRow("fixday, leap, MMM/yyyy/dd") << defaultDate << QString::fromLatin1("MMM/yyyy/dd") + QTest::newRow("fixday, leap, MMM/yyyy/dd") << defaultLocale << defaultDate << QString::fromLatin1("MMM/yyyy/dd") << threeDigitDayIssueKeypresses_ShortMonthName_MonthYearDay << QString::fromLatin1("Feb/2000/29"); + + QTest::newRow("fixday, leap, dddd, dd. MMMM yyyy") << defaultLocale + << defaultDate << QString::fromLatin1("dddd, dd. MMMM yyyy") + << shortAndLongNameIssueKeypresses << QString::fromLatin1("Tuesday, 29. February 2000"); + + QTest::newRow("fixday, leap, german, dddd, dd. MMMM yyyy") << QLocale(QLocale::German, QLocale::Germany) + << defaultDate << QString::fromLatin1("dddd, dd. MMMM yyyy") + << shortAndLongNameIssueKeypresses << QString::fromLatin1("Dienstag, 29. Februar 2000"); } void tst_QDateTimeEdit::dateEditCorrectSectionSize() { + QFETCH(QLocale, locale); QFETCH(QDate, defaultDate); QFETCH(QString, displayFormat); QFETCH(KeyPairList, keyPresses); QFETCH(QString, expectedDisplayString); QDateEdit edit; + edit.setLocale(locale); edit.setDate(defaultDate); edit.setDisplayFormat(displayFormat); edit.show(); -- 2.7.4