summaryrefslogtreecommitdiff
path: root/src/controls/Private/qquickrangeddate_p.h
diff options
context:
space:
mode:
authorOleg Yadrov <oleg.yadrov@qt.io>2017-12-11 16:25:45 -0200
committerMitch Curtis <mitch.curtis@qt.io>2017-12-15 09:42:37 +0000
commit15c909f4170450cdbe01218a0d7cbea55b70fae5 (patch)
tree2d6488db691b6f006327510ae358f2e33b06c148 /src/controls/Private/qquickrangeddate_p.h
parent37592ad9c6df35bdd37609569963fe7361cdad85 (diff)
downloadqtquickcontrols-15c909f4170450cdbe01218a0d7cbea55b70fae5.tar.gz
Calendar: fix bug when NaN is displayed instead of date
I fixed a similar issue last year on the JavaScript side: 094ad30c94a72784449f43ef06d2172d644ab0fd At this time the same thing has been happening in C++. See QTBUG-54559 and the patch for a detailed explanation of the issue. In short, the problem with Calendar is that internally it uses QDate which does not keep information about time, whereas in the JavaScript world date is always combined with time. So, QDate(2017-10-15) is valid, but when during QDate -> JS Date transformation we add time to it (which defaults to midnight (00:00)), it becomes invalid in time zones where the Daylight Saving Time -> Standard Time transition takes place at midnight. To avoid switching the entire QQuickCalendarModel1 to using QDateTime, I modified its date(...) and dateAt(...) methods to return QDateTime with the time part always set to 12:00. That transformation required more changes in QQuickRangedDate1, because Calendar::selectedDate internally is QQuickRangedDate1::selectedDate, and I also had to fix "selected" property binding in the Base Calendar Style as it did take into account the time part of the date, which resulted in wrong behavior with my changes. Task-number: QTBUG-64068 Change-Id: Ia2f7703ff4e5811ef79438c97739da1d8001a7f5 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/controls/Private/qquickrangeddate_p.h')
-rw-r--r--src/controls/Private/qquickrangeddate_p.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/controls/Private/qquickrangeddate_p.h b/src/controls/Private/qquickrangeddate_p.h
index 6ac7bc12..836daa4c 100644
--- a/src/controls/Private/qquickrangeddate_p.h
+++ b/src/controls/Private/qquickrangeddate_p.h
@@ -49,23 +49,23 @@ QT_BEGIN_NAMESPACE
class QQuickRangedDate1 : public QObject
{
Q_OBJECT
- Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged RESET resetDate)
- Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate NOTIFY minimumDateChanged RESET resetMinimumDate)
- Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate NOTIFY maximumDateChanged RESET resetMaximumDate)
+ Q_PROPERTY(QDateTime date READ date WRITE setDate NOTIFY dateChanged RESET resetDate)
+ Q_PROPERTY(QDateTime minimumDate READ minimumDate WRITE setMinimumDate NOTIFY minimumDateChanged RESET resetMinimumDate)
+ Q_PROPERTY(QDateTime maximumDate READ maximumDate WRITE setMaximumDate NOTIFY maximumDateChanged RESET resetMaximumDate)
public:
QQuickRangedDate1();
~QQuickRangedDate1() {}
- QDate date() const { return mDate; }
- void setDate(const QDate &date);
+ QDateTime date() const { return mDate; }
+ void setDate(const QDateTime &date);
void resetDate() {}
- QDate minimumDate() const { return mMinimumDate; }
- void setMinimumDate(const QDate &minimumDate);
+ QDateTime minimumDate() const { return mMinimumDate; }
+ void setMinimumDate(const QDateTime &minimumDate);
void resetMinimumDate() {}
- QDate maximumDate() const { return mMaximumDate; }
- void setMaximumDate(const QDate &maximumDate);
+ QDateTime maximumDate() const { return mMaximumDate; }
+ void setMaximumDate(const QDateTime &maximumDate);
void resetMaximumDate() {}
Q_SIGNALS:
@@ -74,9 +74,9 @@ Q_SIGNALS:
void maximumDateChanged();
private:
- QDate mDate;
- QDate mMinimumDate;
- QDate mMaximumDate;
+ QDateTime mDate;
+ QDateTime mMinimumDate;
+ QDateTime mMaximumDate;
};
QT_END_NAMESPACE