From a44d7862c8e92ad2bc2d0d56e542066e688d5c82 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Tue, 16 Feb 2016 14:56:26 +0300 Subject: QDate: mark getDate() as const. This method does not modify the object. Can't change the API, so overload and mark the old function for removal in Qt 6. Change-Id: I4aee2bc19209646adc21388375aedd20a09129d0 Reviewed-by: Edward Welbourne Reviewed-by: Marc Mutz --- src/corelib/tools/qdatetime.cpp | 15 ++++++++++++++- src/corelib/tools/qdatetime.h | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 280f9ea006..e794da8326 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -975,9 +975,11 @@ bool QDate::setDate(int year, int month, int day) Returns 0 if the date is invalid. + \note In Qt versions prior to 5.7, this function is marked as non-\c{const}. + \sa year(), month(), day(), isValid() */ -void QDate::getDate(int *year, int *month, int *day) +void QDate::getDate(int *year, int *month, int *day) const { ParsedDate pd = { 0, 0, 0 }; if (isValid()) @@ -991,6 +993,17 @@ void QDate::getDate(int *year, int *month, int *day) *day = pd.day; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/*! + \overload + \internal +*/ +void QDate::getDate(int *year, int *month, int *day) +{ + qAsConst(*this).getDate(year, month, day); +} +#endif // < Qt 6 + /*! Returns a QDate object containing a date \a ndays later than the date of this object (or earlier if \a ndays is negative). diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index af91ad0fe5..ee3be5553b 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -99,7 +99,10 @@ QT_DEPRECATED inline bool setYMD(int y, int m, int d) bool setDate(int year, int month, int day); - void getDate(int *year, int *month, int *day); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + void getDate(int *year, int *month, int *day); // ### Qt 6: remove +#endif // < Qt 6 + void getDate(int *year, int *month, int *day) const; QDate addDays(qint64 days) const Q_REQUIRED_RESULT; QDate addMonths(int months) const Q_REQUIRED_RESULT; -- cgit v1.2.3