summaryrefslogtreecommitdiffstats
path: root/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/test_QT_TR_NOOP_context_bis.cpp
blob: 7d30a38ceb9fe05d44b32610361aa5898e0d9dd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only


























#include <QtCore>
#include "my_include.h"
// Testing with two files to check that patch https://codereview.qt-project.org/c/qt/qttools/+/338709/1..3 still works
int X = 111222332444;

// Q_OBJECT declared in an other file
class FooChild : public Foo
{
    const char *c_noop = QT_TR_NOOP("context Foo. noop");
};

// No Q_OBJECT. Q_DECLARE_TR_FUNCTIONS. It is enough for tr, it is enough for QT_TR_NOOP
class OnlyQDeclare
{
    Q_DECLARE_TR_FUNCTIONS(ONLY_Q)
    const char *c_noop = QT_TR_NOOP("context ONLY_Q. noop");
    const char *c_noop_n = QT_TR_N_NOOP("context ONLY_Q. noop N");
};

// Show the message warning that the QT_TR_NOOP is ignored because no context could be found.
class Nothing
{
    const char *c_noop = QT_TR_NOOP("context Nothing. noop with no Q_OBJECT nor Q_DECLARE_TR_FUNCTIONS");
};

// The closest Q_OBJECT or Q_DECLARE_TR_FUNCTIONS gives the context
class WithQObject
{
  Q_OBJECT
  class Nested
  {
    Q_DECLARE_TR_FUNCTIONS(IN_NESTED)
    QString c_tr = tr("context IN_NESTED. tr");
    const char *c_noop = QT_TR_NOOP("context IN_NESTED. noop");
    const char *c_noop_translate = QT_TRANSLATE_NOOP("my_arg", "context my_arg. translate_noop");
  };
};

// The closest Q_OBJECT or Q_DECLARE_TR_FUNCTIONS gives the context
class WithQDeclareTr
{
  Q_DECLARE_TR_FUNCTIONS(A_CONTEXT)
  class Nested
  {
    Q_OBJECT
    QString c_tr = tr("context WithQDeclareTr::Nested. tr");
    const char *c_noop = QT_TR_NOOP("context WithQDeclareTr::Nested. noop");
  };
};

// Case where Q_OBJECT is not seen. Behavior reproduces tr function behavior
namespace test1 {
  class AA
  {
   Q_OBJECT
  public:
    class A {};
  };

  class B : public AA::A
  {
    //QString c_tr = tr(" the Q_OBJECT is not seen"); // this will generate an error.
    const char *c_noop = QT_TR_NOOP("the Q_OBJECT is not seen"); // Once exploring the bases of B (that is AA:A)
                                                        // we are not looking for the parents
                                                        // AA is the parent of A in terms of CXXContextDecl::getParent()
                                                        // This reproduced tr behavior.
  };
}

namespace test2 {
  class AA
  {
    Q_OBJECT
  public:
    class A {};
  };

  class C {};

  class BB
  {
    Q_OBJECT
  public:
    class B : public AA::A, public C
    {
      QString c_tr = tr("context test2::BB. tr");
      const char *c_noop = QT_TR_NOOP("context test2::BB. noop");
    };
  };
}

namespace test3 {
  class AA
  {
    Q_OBJECT
  public:
    class A {};
  };

  class D {Q_OBJECT};
  class C : public D {};

  class BB
  {
    Q_OBJECT
  public:
    class B : public AA::A, public C
    {
      QString c_tr = tr("context test3::D. tr");
      const char *c_noop = QT_TR_NOOP("context test3::D. noop");
    };
  };
}

namespace test4 {

  class A
  {
    Q_OBJECT
  public:
    class B
    {
    public:
      class C
      {
    Q_OBJECT
      public:
    class D
    {
      QString c_tr = tr("context is test4::A::B::C. tr");
      const char *c_noop = QT_TR_NOOP("context is test4::A::B::C. noop");
    };
      };
    };
  };

}