Skip to content

Commit 19454b0

Browse files
author
Sona Kurazyan
committed
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>
1 parent ea8645d commit 19454b0

File tree

5 files changed

+250
-229
lines changed

5 files changed

+250
-229
lines changed

src/corelib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ qt_internal_add_module(Core
6868
global/qsystemdetection.h
6969
global/qtnamespacemacros.h
7070
global/qtrace_p.h
71+
global/qtranslation.h
7172
global/qtypeinfo.h
7273
global/qvolatile_p.h
7374
global/q20algorithm.h

src/corelib/global/qglobal.cpp

Lines changed: 0 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,210 +3840,6 @@ bool qunsetenv(const char *varName)
38403840
enumeration's underlying type.
38413841
*/
38423842

3843-
/*!
3844-
\macro QT_TR_NOOP(sourceText)
3845-
\relates <QtGlobal>
3846-
3847-
Marks the UTF-8 encoded string literal \a sourceText for delayed
3848-
translation in the current context (class).
3849-
3850-
The macro tells lupdate to collect the string, and expands to
3851-
\a sourceText itself.
3852-
3853-
Example:
3854-
3855-
\snippet code/src_corelib_global_qglobal.cpp 34
3856-
3857-
The macro QT_TR_NOOP_UTF8() is identical and obsolete; this applies
3858-
to all other _UTF8 macros as well.
3859-
3860-
\sa QT_TRANSLATE_NOOP(), {Internationalization with Qt}
3861-
*/
3862-
3863-
/*!
3864-
\macro QT_TRANSLATE_NOOP(context, sourceText)
3865-
\relates <QtGlobal>
3866-
3867-
Marks the UTF-8 encoded string literal \a sourceText for delayed
3868-
translation in the given \a context. The \a context is typically
3869-
a class name and also needs to be specified as a string literal.
3870-
3871-
The macro tells lupdate to collect the string, and expands to
3872-
\a sourceText itself.
3873-
3874-
Example:
3875-
3876-
\snippet code/src_corelib_global_qglobal.cpp 35
3877-
3878-
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), {Internationalization with Qt}
3879-
*/
3880-
3881-
/*!
3882-
\macro QT_TRANSLATE_NOOP3(context, sourceText, disambiguation)
3883-
\relates <QtGlobal>
3884-
\since 4.4
3885-
3886-
Marks the UTF-8 encoded string literal \a sourceText for delayed
3887-
translation in the given \a context with the given \a disambiguation.
3888-
The \a context is typically a class and also needs to be specified
3889-
as a string literal. The string literal \a disambiguation should be
3890-
a short semantic tag to tell apart otherwise identical strings.
3891-
3892-
The macro tells lupdate to collect the string, and expands to an
3893-
anonymous struct of the two string literals passed as \a sourceText
3894-
and \a disambiguation.
3895-
3896-
Example:
3897-
3898-
\snippet code/src_corelib_global_qglobal.cpp 36
3899-
3900-
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), {Internationalization with Qt}
3901-
*/
3902-
3903-
/*!
3904-
\macro QT_TR_N_NOOP(sourceText)
3905-
\relates <QtGlobal>
3906-
\since 5.12
3907-
3908-
Marks the UTF-8 encoded string literal \a sourceText for numerator
3909-
dependent delayed translation in the current context (class).
3910-
3911-
The macro tells lupdate to collect the string, and expands to
3912-
\a sourceText itself.
3913-
3914-
The macro expands to \a sourceText.
3915-
3916-
Example:
3917-
3918-
\snippet code/src_corelib_global_qglobal.cpp qttrnnoop
3919-
3920-
\sa QT_TR_NOOP, {Internationalization with Qt}
3921-
*/
3922-
3923-
/*!
3924-
\macro QT_TRANSLATE_N_NOOP(context, sourceText)
3925-
\relates <QtGlobal>
3926-
\since 5.12
3927-
3928-
Marks the UTF-8 encoded string literal \a sourceText for numerator
3929-
dependent delayed translation in the given \a context.
3930-
The \a context is typically a class name and also needs to be
3931-
specified as a string literal.
3932-
3933-
The macro tells lupdate to collect the string, and expands to
3934-
\a sourceText itself.
3935-
3936-
Example:
3937-
3938-
\snippet code/src_corelib_global_qglobal.cpp qttranslatennoop
3939-
3940-
\sa QT_TRANSLATE_NOOP(), QT_TRANSLATE_N_NOOP3(),
3941-
{Internationalization with Qt}
3942-
*/
3943-
3944-
/*!
3945-
\macro QT_TRANSLATE_N_NOOP3(context, sourceText, comment)
3946-
\relates <QtGlobal>
3947-
\since 5.12
3948-
3949-
Marks the UTF-8 encoded string literal \a sourceText for numerator
3950-
dependent delayed translation in the given \a context with the given
3951-
\a comment.
3952-
The \a context is typically a class and also needs to be specified
3953-
as a string literal. The string literal \a comment should be
3954-
a short semantic tag to tell apart otherwise identical strings.
3955-
3956-
The macro tells lupdate to collect the string, and expands to an
3957-
anonymous struct of the two string literals passed as \a sourceText
3958-
and \a comment.
3959-
3960-
Example:
3961-
3962-
\snippet code/src_corelib_global_qglobal.cpp qttranslatennoop3
3963-
3964-
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), QT_TRANSLATE_NOOP3(),
3965-
{Internationalization with Qt}
3966-
*/
3967-
3968-
/*!
3969-
\fn QString qtTrId(const char *id, int n = -1)
3970-
\relates <QtGlobal>
3971-
\reentrant
3972-
\since 4.6
3973-
3974-
\brief The qtTrId function finds and returns a translated string.
3975-
3976-
Returns a translated string identified by \a id.
3977-
If no matching string is found, the id itself is returned. This
3978-
should not happen under normal conditions.
3979-
3980-
If \a n >= 0, all occurrences of \c %n in the resulting string
3981-
are replaced with a decimal representation of \a n. In addition,
3982-
depending on \a n's value, the translation text may vary.
3983-
3984-
Meta data and comments can be passed as documented for QObject::tr().
3985-
In addition, it is possible to supply a source string template like that:
3986-
3987-
\tt{//% <C string>}
3988-
3989-
or
3990-
3991-
\tt{\\begincomment% <C string> \\endcomment}
3992-
3993-
Example:
3994-
3995-
\snippet code/src_corelib_global_qglobal.cpp qttrid
3996-
3997-
Creating QM files suitable for use with this function requires passing
3998-
the \c -idbased option to the \c lrelease tool.
3999-
4000-
\warning This method is reentrant only if all translators are
4001-
installed \e before calling this method. Installing or removing
4002-
translators while performing translations is not supported. Doing
4003-
so will probably result in crashes or other undesirable behavior.
4004-
4005-
\sa QObject::tr(), QCoreApplication::translate(), {Internationalization with Qt}
4006-
*/
4007-
4008-
/*!
4009-
\macro QT_TRID_NOOP(id)
4010-
\relates <QtGlobal>
4011-
\since 4.6
4012-
4013-
\brief The QT_TRID_NOOP macro marks an id for dynamic translation.
4014-
4015-
The only purpose of this macro is to provide an anchor for attaching
4016-
meta data like to qtTrId().
4017-
4018-
The macro expands to \a id.
4019-
4020-
Example:
4021-
4022-
\snippet code/src_corelib_global_qglobal.cpp qttrid_noop
4023-
4024-
\sa qtTrId(), {Internationalization with Qt}
4025-
*/
4026-
4027-
/*!
4028-
\macro QT_TRID_N_NOOP(id)
4029-
\relates <QtGlobal>
4030-
\since 6.3
4031-
4032-
\brief The QT_TRID_N_NOOP macro marks an id for numerator
4033-
dependent dynamic translation.
4034-
4035-
The only purpose of this macro is to provide an anchor for attaching
4036-
meta data like to qtTrId().
4037-
4038-
The macro expands to \a id.
4039-
4040-
Example:
4041-
4042-
\snippet code/src_corelib_global_qglobal.cpp qttrid_n_noop
4043-
4044-
\sa qtTrId(), {Internationalization with Qt}
4045-
*/
4046-
40473843
/*!
40483844
\macro Q_LIKELY(expr)
40493845
\relates <QtGlobal>

src/corelib/global/qglobal.h

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,30 +1213,6 @@ template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) noexcept -> decltype
12131213
#define Q_D(Class) Class##Private * const d = d_func()
12141214
#define Q_Q(Class) Class * const q = q_func()
12151215

1216-
#define QT_TR_NOOP(x) x
1217-
#define QT_TR_NOOP_UTF8(x) x
1218-
#define QT_TRANSLATE_NOOP(scope, x) x
1219-
#define QT_TRANSLATE_NOOP_UTF8(scope, x) x
1220-
#define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
1221-
#define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
1222-
1223-
#ifndef QT_NO_TRANSLATION
1224-
1225-
#define QT_TR_N_NOOP(x) x
1226-
#define QT_TRANSLATE_N_NOOP(scope, x) x
1227-
#define QT_TRANSLATE_N_NOOP3(scope, x, comment) {x, comment}
1228-
1229-
// Defined in qcoreapplication.cpp
1230-
// The better name qTrId() is reserved for an upcoming function which would
1231-
// return a much more powerful QStringFormatter instead of a QString.
1232-
Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
1233-
1234-
#define QT_TRID_NOOP(id) id
1235-
#define QT_TRID_N_NOOP(id) id
1236-
1237-
#endif // QT_NO_TRANSLATION
1238-
1239-
12401216
#ifdef Q_QDOC
12411217
// Just for documentation generation
12421218
template<typename T>
@@ -1343,10 +1319,11 @@ QT_END_NAMESPACE
13431319
#include <QtCore/qflags.h>
13441320

13451321
#include <QtCore/qatomic.h>
1322+
#include <QtCore/qforeach.h>
13461323
#include <QtCore/qglobalstatic.h>
13471324
#include <QtCore/qnumeric.h>
1325+
#include <QtCore/qtranslation.h>
13481326
#include <QtCore/qversiontagging.h>
1349-
#include <QtCore/qforeach.h>
13501327

13511328
#endif /* __cplusplus */
13521329
#endif /* !__ASSEMBLER__ */

src/corelib/global/qtranslation.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (C) 2022 The Qt Company Ltd.
2+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3+
4+
#ifndef QTRANSLATION_H
5+
#define QTRANSLATION_H
6+
7+
#include <QtCore/qglobal.h>
8+
9+
#if 0
10+
#pragma qt_class(QTranslation)
11+
#pragma qt_sync_stop_processing
12+
#endif
13+
14+
QT_BEGIN_NAMESPACE
15+
16+
#define QT_TR_NOOP(x) x
17+
#define QT_TR_NOOP_UTF8(x) x
18+
#define QT_TRANSLATE_NOOP(scope, x) x
19+
#define QT_TRANSLATE_NOOP_UTF8(scope, x) x
20+
#define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
21+
#define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
22+
23+
#ifndef QT_NO_TRANSLATION
24+
25+
#define QT_TR_N_NOOP(x) x
26+
#define QT_TRANSLATE_N_NOOP(scope, x) x
27+
#define QT_TRANSLATE_N_NOOP3(scope, x, comment) {x, comment}
28+
29+
// Defined in qcoreapplication.cpp
30+
// The better name qTrId() is reserved for an upcoming function which would
31+
// return a much more powerful QStringFormatter instead of a QString.
32+
Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
33+
34+
#define QT_TRID_NOOP(id) id
35+
#define QT_TRID_N_NOOP(id) id
36+
37+
QT_END_NAMESPACE
38+
39+
#endif // QT_NO_TRANSLATION
40+
41+
#endif /* QTRANSLATION_H */

0 commit comments

Comments
 (0)