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>
This commit is contained in:
Anton Kudryavtsev 2016-02-16 14:56:26 +03:00
parent 56ad625f78
commit a44d7862c8
2 changed files with 18 additions and 2 deletions

View File

@ -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).

View File

@ -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;