diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-02-16 14:56:26 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-02-17 11:19:52 +0000 |
commit | a44d7862c8e92ad2bc2d0d56e542066e688d5c82 (patch) | |
tree | 0f981df50a505bb8aa9efeea0442023c75a7f1e3 /src/corelib/tools | |
parent | 56ad625f7843bb66bef2a0ef9b5c97d354fbdb25 (diff) |
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 <edward.welbourne@theqtcompany.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 15 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime.h | 5 |
2 files changed, 18 insertions, 2 deletions
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; |