diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-10-27 20:26:56 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-11-02 05:57:56 +0000 |
commit | 8b7a4b8dd8ffd4c55fd013179242ecd42441d6a9 (patch) | |
tree | 9629a156fcaca875d70feab0f3f525f96c4ceafe | |
parent | a5a1f338aa0077b5e29bdf774ad4183f1c8c59d9 (diff) |
QLocale: add const version of formattedDataSize
QLocale::formattedDataSize() was not marked const when it was added
although the function is const.
Add a const overload and mark the non-const version as deprecated and
remove it with Qt6
Fixes: QTBUG-71445
Change-Id: I56d051d9928b5e00cdaca7a874c543fed27a888d
Reviewed-by: Luca Beldi <v.ronin@yahoo.it>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 15 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.h | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 38bd195fba..4d5924a03e 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3881,6 +3881,19 @@ QString QLocale::toCurrencyString(double value, const QString &symbol, int preci \sa formattedDataSize() */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/*! + \obsolete + + Use the const version instead. +*/ +QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats format) +{ + const auto *that = this; + return that->formattedDataSize(bytes, precision, format); +} +#endif + /*! \since 5.10 @@ -3897,7 +3910,7 @@ QString QLocale::toCurrencyString(double value, const QString &symbol, int preci whereas \c DataSizeSIFormat uses the older SI quantifiers k, M, etc., and \c DataSizeTraditionalFormat abuses them. */ -QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats format) +QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats format) const { int power, base = 1000; if (!bytes) { diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index af0eb2929e..1fbd96c6d5 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -1066,7 +1066,10 @@ public: { return toCurrencyString(double(i), symbol, precision); } #endif +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QString formattedDataSize(qint64 bytes, int precision = 2, DataSizeFormats format = DataSizeIecFormat); +#endif + QString formattedDataSize(qint64 bytes, int precision = 2, DataSizeFormats format = DataSizeIecFormat) const; QStringList uiLanguages() const; |