Commit 7667f4b0 authored by Sune Stolborg Vuorela's avatar Sune Stolborg Vuorela
Browse files

deprecate QTextCodec public api

QTextCodec has been deprecated in Qt6, so also deprecate the api we have
using it.

This is not fully perfect, given we have more mappings than QTextCodec
itself, but it is the hand we have been given for now.

Apps cans till use QTextCodec by pulling in Qt5Compat, but we should not
have it on public api.
parent f0ff68d8
......@@ -58,7 +58,7 @@ ecm_generate_export_header(KF5Codecs
GROUP_BASE_NAME KF
VERSION ${KF_VERSION}
DEPRECATED_BASE_VERSION 0
DEPRECATION_VERSIONS 5.5 5.56
DEPRECATION_VERSIONS 5.5 5.56 5.84
EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT}
)
......
......@@ -46,27 +46,37 @@ public:
*/
virtual ~KCharsets();
#if KCODECS_ENABLE_DEPRECATED_SINCE(5, 84)
/**
* Provided for compatibility.
* @deprecated apps should use QTextCodec::codecForName in Qt5 or Qt5Compat in Qt6 or
* port to QStringEncoder
* @param name the name of the codec
* @return the QTextCodec. If the desired codec could not be found,
* it returns a default (ISO 8859-1) codec
*/
KCODECS_DEPRECATED_VERSION(5, 84, "use QTextCodec codecForName or QStringEncoder")
QTextCodec *codecForName(const QString &name) const;
#endif
#if KCODECS_ENABLE_DEPRECATED_SINCE(5, 84)
/**
* Tries to find a QTextCodec to convert the given encoding from and to
* Unicode.
*
* If no codec could be found, the ISO 8859-1 codec will be returned an
* and @p ok will be set to false.
* @deprecated apps should use QTextCodec::codecForName in Qt5 or Qt5Compat in Qt6 or
* port to QStringEncoder
*
* @param n the name of the codec
* @param ok true if a matching codec has been found, false if not
* @return the QTextCodec. If the desired codec could not be found,
* it returns a default (ISO 8859-1) codec
*/
KCODECS_DEPRECATED_VERSION(5, 84, "use QTextCodec codecForName or QStringEncoder")
QTextCodec *codecForName(const QString &n, bool &ok) const;
#endif
/**
* The global charset manager.
......@@ -145,17 +155,22 @@ public:
QString encodingForName(const QString &descriptiveName) const;
private:
#if KCODECS_ENABLE_DEPRECATED_SINCE(5, 84)
/**
* @brief Get the QTextCodec for the name or return NULL
*
* This function is similar to KCharsets::codecForName except that it
* can return a NULL value when the name was not found.
* @deprecated apps should use QTextCodec::codecForName in Qt5 or Qt5Compat in Qt6 or
* port to QStringEncoder
*
* @param n name of the text codec
* @return pointer to the QTextCodec or NULL
* @todo Make this function public when it is clear what API is needed.
*/
KCODECS_DEPRECATED_VERSION(5, 84, "use QTextCodec codecForName or QStringEncoder")
QTextCodec *codecForNameOrNull(const QByteArray &n) const;
#endif
private:
std::unique_ptr<KCharsetsPrivate> const d;
......
......@@ -46,7 +46,7 @@ class KEncodingProberPrivate;
* prober.feed(data);
* prober.feed(moredata);
* if (prober.confidence() > 0.6)
* QString out = QTextCodec::codecForName(prober.encoding())->toUnicode(data);
* encoding = prober.encoding();
* \endcode
*
* At least 256 characters are needed to change the ProberState from Probing to FoundIt.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment