summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2022-07-28 10:47:20 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2022-07-29 23:04:21 +0200
commit19454b05c2857d8d332ff9e70dcd1d07875dce68 (patch)
tree8a0702dfab66902381235fb8e8f84fea6b8d25e6 /src/corelib
parentea8645d8468c9647e6b5847d9787ca0da1f3262c (diff)
Extract header qtranslation.h from qglobal.h
As a drive-by, fixed the sorting order of header includes. Task-number: QTBUG-99313 Change-Id: I731e397f8488460657b31839c49f07ff3c476c66 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/CMakeLists.txt1
-rw-r--r--src/corelib/global/qglobal.cpp204
-rw-r--r--src/corelib/global/qglobal.h27
-rw-r--r--src/corelib/global/qtranslation.h41
-rw-r--r--src/corelib/global/qtranslation.qdoc206
5 files changed, 250 insertions, 229 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 106a17b65f..9aa0d0b2ee 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -68,6 +68,7 @@ qt_internal_add_module(Core
global/qsystemdetection.h
global/qtnamespacemacros.h
global/qtrace_p.h
+ global/qtranslation.h
global/qtypeinfo.h
global/qvolatile_p.h
global/q20algorithm.h
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 5972ec9a4e..3c9d947577 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -3841,210 +3841,6 @@ bool qunsetenv(const char *varName)
*/
/*!
- \macro QT_TR_NOOP(sourceText)
- \relates <QtGlobal>
-
- Marks the UTF-8 encoded string literal \a sourceText for delayed
- translation in the current context (class).
-
- The macro tells lupdate to collect the string, and expands to
- \a sourceText itself.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 34
-
- The macro QT_TR_NOOP_UTF8() is identical and obsolete; this applies
- to all other _UTF8 macros as well.
-
- \sa QT_TRANSLATE_NOOP(), {Internationalization with Qt}
-*/
-
-/*!
- \macro QT_TRANSLATE_NOOP(context, sourceText)
- \relates <QtGlobal>
-
- Marks the UTF-8 encoded string literal \a sourceText for delayed
- translation in the given \a context. The \a context is typically
- a class name and also needs to be specified as a string literal.
-
- The macro tells lupdate to collect the string, and expands to
- \a sourceText itself.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 35
-
- \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), {Internationalization with Qt}
-*/
-
-/*!
- \macro QT_TRANSLATE_NOOP3(context, sourceText, disambiguation)
- \relates <QtGlobal>
- \since 4.4
-
- Marks the UTF-8 encoded string literal \a sourceText for delayed
- translation in the given \a context with the given \a disambiguation.
- The \a context is typically a class and also needs to be specified
- as a string literal. The string literal \a disambiguation should be
- a short semantic tag to tell apart otherwise identical strings.
-
- The macro tells lupdate to collect the string, and expands to an
- anonymous struct of the two string literals passed as \a sourceText
- and \a disambiguation.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp 36
-
- \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), {Internationalization with Qt}
-*/
-
-/*!
- \macro QT_TR_N_NOOP(sourceText)
- \relates <QtGlobal>
- \since 5.12
-
- Marks the UTF-8 encoded string literal \a sourceText for numerator
- dependent delayed translation in the current context (class).
-
- The macro tells lupdate to collect the string, and expands to
- \a sourceText itself.
-
- The macro expands to \a sourceText.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp qttrnnoop
-
- \sa QT_TR_NOOP, {Internationalization with Qt}
-*/
-
-/*!
- \macro QT_TRANSLATE_N_NOOP(context, sourceText)
- \relates <QtGlobal>
- \since 5.12
-
- Marks the UTF-8 encoded string literal \a sourceText for numerator
- dependent delayed translation in the given \a context.
- The \a context is typically a class name and also needs to be
- specified as a string literal.
-
- The macro tells lupdate to collect the string, and expands to
- \a sourceText itself.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp qttranslatennoop
-
- \sa QT_TRANSLATE_NOOP(), QT_TRANSLATE_N_NOOP3(),
- {Internationalization with Qt}
-*/
-
-/*!
- \macro QT_TRANSLATE_N_NOOP3(context, sourceText, comment)
- \relates <QtGlobal>
- \since 5.12
-
- Marks the UTF-8 encoded string literal \a sourceText for numerator
- dependent delayed translation in the given \a context with the given
- \a comment.
- The \a context is typically a class and also needs to be specified
- as a string literal. The string literal \a comment should be
- a short semantic tag to tell apart otherwise identical strings.
-
- The macro tells lupdate to collect the string, and expands to an
- anonymous struct of the two string literals passed as \a sourceText
- and \a comment.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp qttranslatennoop3
-
- \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), QT_TRANSLATE_NOOP3(),
- {Internationalization with Qt}
-*/
-
-/*!
- \fn QString qtTrId(const char *id, int n = -1)
- \relates <QtGlobal>
- \reentrant
- \since 4.6
-
- \brief The qtTrId function finds and returns a translated string.
-
- Returns a translated string identified by \a id.
- If no matching string is found, the id itself is returned. This
- should not happen under normal conditions.
-
- If \a n >= 0, all occurrences of \c %n in the resulting string
- are replaced with a decimal representation of \a n. In addition,
- depending on \a n's value, the translation text may vary.
-
- Meta data and comments can be passed as documented for QObject::tr().
- In addition, it is possible to supply a source string template like that:
-
- \tt{//% <C string>}
-
- or
-
- \tt{\\begincomment% <C string> \\endcomment}
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp qttrid
-
- Creating QM files suitable for use with this function requires passing
- the \c -idbased option to the \c lrelease tool.
-
- \warning This method is reentrant only if all translators are
- installed \e before calling this method. Installing or removing
- translators while performing translations is not supported. Doing
- so will probably result in crashes or other undesirable behavior.
-
- \sa QObject::tr(), QCoreApplication::translate(), {Internationalization with Qt}
-*/
-
-/*!
- \macro QT_TRID_NOOP(id)
- \relates <QtGlobal>
- \since 4.6
-
- \brief The QT_TRID_NOOP macro marks an id for dynamic translation.
-
- The only purpose of this macro is to provide an anchor for attaching
- meta data like to qtTrId().
-
- The macro expands to \a id.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp qttrid_noop
-
- \sa qtTrId(), {Internationalization with Qt}
-*/
-
-/*!
- \macro QT_TRID_N_NOOP(id)
- \relates <QtGlobal>
- \since 6.3
-
- \brief The QT_TRID_N_NOOP macro marks an id for numerator
- dependent dynamic translation.
-
- The only purpose of this macro is to provide an anchor for attaching
- meta data like to qtTrId().
-
- The macro expands to \a id.
-
- Example:
-
- \snippet code/src_corelib_global_qglobal.cpp qttrid_n_noop
-
- \sa qtTrId(), {Internationalization with Qt}
-*/
-
-/*!
\macro Q_LIKELY(expr)
\relates <QtGlobal>
\since 4.8
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 7d234c74b1..21762c39e2 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1213,30 +1213,6 @@ template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) noexcept -> decltype
#define Q_D(Class) Class##Private * const d = d_func()
#define Q_Q(Class) Class * const q = q_func()
-#define QT_TR_NOOP(x) x
-#define QT_TR_NOOP_UTF8(x) x
-#define QT_TRANSLATE_NOOP(scope, x) x
-#define QT_TRANSLATE_NOOP_UTF8(scope, x) x
-#define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
-#define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
-
-#ifndef QT_NO_TRANSLATION
-
-#define QT_TR_N_NOOP(x) x
-#define QT_TRANSLATE_N_NOOP(scope, x) x
-#define QT_TRANSLATE_N_NOOP3(scope, x, comment) {x, comment}
-
-// Defined in qcoreapplication.cpp
-// The better name qTrId() is reserved for an upcoming function which would
-// return a much more powerful QStringFormatter instead of a QString.
-Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
-
-#define QT_TRID_NOOP(id) id
-#define QT_TRID_N_NOOP(id) id
-
-#endif // QT_NO_TRANSLATION
-
-
#ifdef Q_QDOC
// Just for documentation generation
template<typename T>
@@ -1343,10 +1319,11 @@ QT_END_NAMESPACE
#include <QtCore/qflags.h>
#include <QtCore/qatomic.h>
+#include <QtCore/qforeach.h>
#include <QtCore/qglobalstatic.h>
#include <QtCore/qnumeric.h>
+#include <QtCore/qtranslation.h>
#include <QtCore/qversiontagging.h>
-#include <QtCore/qforeach.h>
#endif /* __cplusplus */
#endif /* !__ASSEMBLER__ */
diff --git a/src/corelib/global/qtranslation.h b/src/corelib/global/qtranslation.h
new file mode 100644
index 0000000000..4c76d7d750
--- /dev/null
+++ b/src/corelib/global/qtranslation.h
@@ -0,0 +1,41 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QTRANSLATION_H
+#define QTRANSLATION_H
+
+#include <QtCore/qglobal.h>
+
+#if 0
+#pragma qt_class(QTranslation)
+#pragma qt_sync_stop_processing
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#define QT_TR_NOOP(x) x
+#define QT_TR_NOOP_UTF8(x) x
+#define QT_TRANSLATE_NOOP(scope, x) x
+#define QT_TRANSLATE_NOOP_UTF8(scope, x) x
+#define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
+#define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
+
+#ifndef QT_NO_TRANSLATION
+
+#define QT_TR_N_NOOP(x) x
+#define QT_TRANSLATE_N_NOOP(scope, x) x
+#define QT_TRANSLATE_N_NOOP3(scope, x, comment) {x, comment}
+
+// Defined in qcoreapplication.cpp
+// The better name qTrId() is reserved for an upcoming function which would
+// return a much more powerful QStringFormatter instead of a QString.
+Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
+
+#define QT_TRID_NOOP(id) id
+#define QT_TRID_N_NOOP(id) id
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_TRANSLATION
+
+#endif /* QTRANSLATION_H */
diff --git a/src/corelib/global/qtranslation.qdoc b/src/corelib/global/qtranslation.qdoc
new file mode 100644
index 0000000000..5310e08bee
--- /dev/null
+++ b/src/corelib/global/qtranslation.qdoc
@@ -0,0 +1,206 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \macro QT_TR_NOOP(sourceText)
+ \relates <QTranslation>
+
+ Marks the UTF-8 encoded string literal \a sourceText for delayed
+ translation in the current context (class).
+
+ The macro tells lupdate to collect the string, and expands to
+ \a sourceText itself.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 34
+
+ The macro QT_TR_NOOP_UTF8() is identical and obsolete; this applies
+ to all other _UTF8 macros as well.
+
+ \sa QT_TRANSLATE_NOOP(), {Internationalization with Qt}
+*/
+
+/*!
+ \macro QT_TRANSLATE_NOOP(context, sourceText)
+ \relates <QTranslation>
+
+ Marks the UTF-8 encoded string literal \a sourceText for delayed
+ translation in the given \a context. The \a context is typically
+ a class name and also needs to be specified as a string literal.
+
+ The macro tells lupdate to collect the string, and expands to
+ \a sourceText itself.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 35
+
+ \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), {Internationalization with Qt}
+*/
+
+/*!
+ \macro QT_TRANSLATE_NOOP3(context, sourceText, disambiguation)
+ \relates <QTranslation>
+ \since 4.4
+
+ Marks the UTF-8 encoded string literal \a sourceText for delayed
+ translation in the given \a context with the given \a disambiguation.
+ The \a context is typically a class and also needs to be specified
+ as a string literal. The string literal \a disambiguation should be
+ a short semantic tag to tell apart otherwise identical strings.
+
+ The macro tells lupdate to collect the string, and expands to an
+ anonymous struct of the two string literals passed as \a sourceText
+ and \a disambiguation.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 36
+
+ \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), {Internationalization with Qt}
+*/
+
+/*!
+ \macro QT_TR_N_NOOP(sourceText)
+ \relates <QTranslation>
+ \since 5.12
+
+ Marks the UTF-8 encoded string literal \a sourceText for numerator
+ dependent delayed translation in the current context (class).
+
+ The macro tells lupdate to collect the string, and expands to
+ \a sourceText itself.
+
+ The macro expands to \a sourceText.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp qttrnnoop
+
+ \sa QT_TR_NOOP, {Internationalization with Qt}
+*/
+
+/*!
+ \macro QT_TRANSLATE_N_NOOP(context, sourceText)
+ \relates <QTranslation>
+ \since 5.12
+
+ Marks the UTF-8 encoded string literal \a sourceText for numerator
+ dependent delayed translation in the given \a context.
+ The \a context is typically a class name and also needs to be
+ specified as a string literal.
+
+ The macro tells lupdate to collect the string, and expands to
+ \a sourceText itself.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp qttranslatennoop
+
+ \sa QT_TRANSLATE_NOOP(), QT_TRANSLATE_N_NOOP3(),
+ {Internationalization with Qt}
+*/
+
+/*!
+ \macro QT_TRANSLATE_N_NOOP3(context, sourceText, comment)
+ \relates <QTranslation>
+ \since 5.12
+
+ Marks the UTF-8 encoded string literal \a sourceText for numerator
+ dependent delayed translation in the given \a context with the given
+ \a comment.
+ The \a context is typically a class and also needs to be specified
+ as a string literal. The string literal \a comment should be
+ a short semantic tag to tell apart otherwise identical strings.
+
+ The macro tells lupdate to collect the string, and expands to an
+ anonymous struct of the two string literals passed as \a sourceText
+ and \a comment.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp qttranslatennoop3
+
+ \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), QT_TRANSLATE_NOOP3(),
+ {Internationalization with Qt}
+*/
+
+/*!
+ \fn QString qtTrId(const char *id, int n = -1)
+ \relates <QTranslation>
+ \reentrant
+ \since 4.6
+
+ \brief The qtTrId function finds and returns a translated string.
+
+ Returns a translated string identified by \a id.
+ If no matching string is found, the id itself is returned. This
+ should not happen under normal conditions.
+
+ If \a n >= 0, all occurrences of \c %n in the resulting string
+ are replaced with a decimal representation of \a n. In addition,
+ depending on \a n's value, the translation text may vary.
+
+ Meta data and comments can be passed as documented for QObject::tr().
+ In addition, it is possible to supply a source string template like that:
+
+ \tt{//% <C string>}
+
+ or
+
+ \tt{\\begincomment% <C string> \\endcomment}
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp qttrid
+
+ Creating QM files suitable for use with this function requires passing
+ the \c -idbased option to the \c lrelease tool.
+
+ \warning This method is reentrant only if all translators are
+ installed \e before calling this method. Installing or removing
+ translators while performing translations is not supported. Doing
+ so will probably result in crashes or other undesirable behavior.
+
+ \sa QObject::tr(), QCoreApplication::translate(), {Internationalization with Qt}
+*/
+
+/*!
+ \macro QT_TRID_NOOP(id)
+ \relates <QTranslation>
+ \since 4.6
+
+ \brief The QT_TRID_NOOP macro marks an id for dynamic translation.
+
+ The only purpose of this macro is to provide an anchor for attaching
+ meta data like to qtTrId().
+
+ The macro expands to \a id.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp qttrid_noop
+
+ \sa qtTrId(), {Internationalization with Qt}
+*/
+
+/*!
+ \macro QT_TRID_N_NOOP(id)
+ \relates <QTranslation>
+ \since 6.3
+
+ \brief The QT_TRID_N_NOOP macro marks an id for numerator
+ dependent dynamic translation.
+
+ The only purpose of this macro is to provide an anchor for attaching
+ meta data like to qtTrId().
+
+ The macro expands to \a id.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp qttrid_n_noop
+
+ \sa qtTrId(), {Internationalization with Qt}
+*/