summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qdatetime_p.h
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@nokia.com>2012-08-21 14:46:42 +0200
committerQt by Nokia <qt-info@nokia.com>2012-09-05 21:06:39 +0200
commit2b562b756401da02017ec937fd2716dd6b9863d3 (patch)
tree3578f0a9ead68655887b7b2617ca1aa0695671fc /src/corelib/tools/qdatetime_p.h
parentaba8de1bee8bbb9bc6b92e761a3dda0d829a211e (diff)
Fix 3 digit day being displayed by QDateEdit.
When a QDateEdit has its display format set to "yyyy/MM/dd", its day set to 31 and its month set to 2, it will display 291 as the day until the cursor is moved or the focus changed. This is because QDateTimeParser::parse calls sectionSize() for the day section, which will sometimes return an incorrect size. There are also other display formats affected by this bug (e.g. long day names). For example, (in the context of sectionSize()) when text is "2000/01/31" and displayText() is "2000/2/31", there is a difference between displayText() and text - text is the previous value and displayText() is the new value. The size difference is always due to leading zeroes. This patch makes QDateTimeParser keep track of the quantity of zeroes added to each section and then factors this value into the result of sectionSize() if there is a size difference between text and displayText(). Task-number: QTBUG-26847 Change-Id: I3823cc41167ec920f742cb6a20d39fc5f433c915 Reviewed-by: Mitch Curtis <mitch.curtis@nokia.com> Reviewed-by: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> Reviewed-by: aavit <qt_aavit@ovi.com>
Diffstat (limited to 'src/corelib/tools/qdatetime_p.h')
-rw-r--r--src/corelib/tools/qdatetime_p.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h
index 3861a731d9..ce8be86b09 100644
--- a/src/corelib/tools/qdatetime_p.h
+++ b/src/corelib/tools/qdatetime_p.h
@@ -120,12 +120,15 @@ public:
first.type = FirstSection;
first.pos = -1;
first.count = -1;
+ first.zeroesAdded = 0;
last.type = FirstSection;
last.pos = -1;
last.count = -1;
+ last.zeroesAdded = 0;
none.type = NoSection;
none.pos = -1;
none.count = -1;
+ none.zeroesAdded = 0;
}
virtual ~QDateTimeParser() {}
enum {
@@ -168,6 +171,7 @@ public:
Section type;
mutable int pos;
int count;
+ int zeroesAdded;
};
enum State { // duplicated from QValidator