Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmldebugtranslationprotocol_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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#ifndef QQMLDEBUGTRANSLATIONPROTOCOL_P_H
4#define QQMLDEBUGTRANSLATIONPROTOCOL_P_H
5//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the Qt API. It exists purely as an
10// implementation detail. This header file may change from version to
11// version without notice, or even be removed.
12//
13// We mean it.
14//
15#include <QtCore/qdatastream.h>
16#include <QtCore/qbuffer.h>
17#include <QtCore/qurl.h>
18#include <QtCore/qobjectdefs.h>
19#include <QtCore/qmetaobject.h>
20#include <QtCore/private/qglobal_p.h>
21#include <tuple>
22
24
26
27enum class Request {
35 // following are obsolete, just provided for compilation compatibility
37};
38
39enum class Reply {
40 LanguageChanged = 101,
45 // following are obsolete, just provided for compilation compatibility
48};
49
51{
52 return ds << int(r);
53}
54
56{
57 int i;
58 ds >> i;
59 r = Request(i);
60 return ds;
61}
62
64{
65 return ds << int(r);
66}
67
69{
70 int i;
71 ds >> i;
72 r = Reply(i);
73 return ds;
74}
75
77 const QString &locale)
78{
79 packet << Request::ChangeLanguage << url << locale;
80 return qobject_cast<QBuffer *>(packet.device())->data();
81}
82
84{
85 packet << Request::ChangeState << state;
86 return qobject_cast<QBuffer *>(packet.device())->data();
87}
88
90{
92 return qobject_cast<QBuffer *>(packet.device())->data();
93}
94
96{
98 return qobject_cast<QBuffer *>(packet.device())->data();
99}
100
102{
104 return qobject_cast<QBuffer *>(packet.device())->data();
105}
106
108{
109 packet << Request::StateList;
110 return qobject_cast<QBuffer *>(packet.device())->data();
111}
112
114{
115 packet << Request::WatchTextElides;
116 return qobject_cast<QBuffer *>(packet.device())->data();
117}
118
120{
122 return qobject_cast<QBuffer *>(packet.device())->data();
123}
124
126{
127public:
129 {
130 return stream >> codeMarker.url
131 >> codeMarker.line
132 >> codeMarker.column;
133 }
134
136 {
137 return stream << codeMarker.url
138 << codeMarker.line
139 << codeMarker.column;
140 }
141
142 friend bool operator<(const CodeMarker &first, const CodeMarker &second)
143 {
144 return std::tie(first.url, first.line, first.column)
145 < std::tie(second.url, second.line, second.column);
146 }
147
148 friend bool operator==(const CodeMarker &first, const CodeMarker &second)
149 {
150 return first.line == second.line
151 && first.column == second.column
152 && first.url == second.url;
153 }
154
156 int line = -1;
157 int column = -1;
158};
160{
161public:
162 enum class Type{
163 Missing,
164 Elided
165 };
166
168 {
169 int t;
170 stream >> issue.codeMarker
171 >> issue.language
172 >> t;
173 issue.type = Type(t);
174 return stream;
175 }
176
178 {
179 return stream << issue.codeMarker
180 << issue.language
181 << int(issue.type);
182 }
183
184 friend bool operator==(const TranslationIssue &first, const TranslationIssue &second)
185 {
186 return first.type == second.type
187 && first.language == second.language
188 && first.codeMarker == second.codeMarker;
189 }
190
192 {
193 QString debugString(QLatin1String(
194 "TranslationIssue(type=%1, line=%2, column=%3, url=%4, language=%5)"));
195 return debugString.arg(type == TranslationIssue::Type::Missing ? QLatin1String("Missing")
196 : QLatin1String("Elided"),
199 }
200
202 Type type = Type::Missing;
204};
206{
207public:
208 QmlElement() = default;
209
211 {
212 return stream >> qmlElement.codeMarker >> qmlElement.elementId >> qmlElement.elementType
213 >> qmlElement.propertyName >> qmlElement.translationId >> qmlElement.translatedText
214 >> qmlElement.fontFamily >> qmlElement.fontPointSize >> qmlElement.fontPixelSize
215 >> qmlElement.fontStyleName >> qmlElement.horizontalAlignment
216 >> qmlElement.verticalAlignment >> qmlElement.stateName;
217 }
218
220 {
221 return stream << qmlElement.codeMarker << qmlElement.elementId << qmlElement.elementType
222 << qmlElement.propertyName << qmlElement.translationId
223 << qmlElement.translatedText << qmlElement.fontFamily
224 << qmlElement.fontPointSize << qmlElement.fontPixelSize
225 << qmlElement.fontStyleName << qmlElement.horizontalAlignment
226 << qmlElement.verticalAlignment << qmlElement.stateName;
227 }
228
242};
243
245{
246public:
247 QmlState() = default;
248
250 {
251 return stream >> qmlState.name;
252 }
253
255 {
256 return stream << qmlState.name;
257 }
258
260};
261}
262
264
265#endif // QQMLDEBUGTRANSLATIONPROTOCOL_P_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatastream.h:46
QIODevice * device() const
Returns the I/O device currently set, or \nullptr if no device is currently set.
friend bool operator==(const CodeMarker &first, const CodeMarker &second)
friend bool operator<(const CodeMarker &first, const CodeMarker &second)
friend QDataStream & operator<<(QDataStream &stream, const CodeMarker &codeMarker)
friend QDataStream & operator>>(QDataStream &stream, CodeMarker &codeMarker)
friend QDataStream & operator<<(QDataStream &stream, const QmlElement &qmlElement)
friend QDataStream & operator>>(QDataStream &stream, QmlElement &qmlElement)
friend QDataStream & operator>>(QDataStream &stream, QmlState &qmlState)
friend QDataStream & operator<<(QDataStream &stream, const QmlState &qmlState)
friend bool operator==(const TranslationIssue &first, const TranslationIssue &second)
friend QDataStream & operator>>(QDataStream &stream, TranslationIssue &issue)
friend QDataStream & operator<<(QDataStream &stream, const TranslationIssue &issue)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Definition qstring.cpp:8870
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8084
\inmodule QtCore
Definition qurl.h:94
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
Definition qurl.cpp:2831
else opt state
[0]
QByteArray createChangeStateRequest(QDataStream &packet, const QString &state)
QByteArray createChangeLanguageRequest(QDataStream &packet, const QUrl &url, const QString &locale)
QByteArray createWatchTextElidesRequest(QDataStream &packet)
QByteArray createTranslationIssuesRequest(QDataStream &packet)
QByteArray createTranslatableTextOccurrencesRequest(QDataStream &packet)
QDataStream & operator>>(QDataStream &ds, Request &r)
QByteArray createDisableWatchTextElidesRequest(QDataStream &packet)
QDataStream & operator<<(QDataStream &ds, Request r)
QByteArray createStateListRequest(QDataStream &packet)
QByteArray createMissingTranslationsRequest(QDataStream &packet)
Combined button and popup list for selecting options.
EGLStreamKHR stream
GLboolean r
[2]
GLenum type
GLint first
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble t
Definition qopenglext.h:243
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
double qreal
Definition qtypes.h:187
QUrl url("example.com")
[constructor-url-reference]
Definition moc.h:23