1// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
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 QWAYLANDINPUTMETHODEVENTBUILDER_H
5#define QWAYLANDINPUTMETHODEVENTBUILDER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QInputMethodEvent>
19#include <private/qglobal_p.h>
20
21QT_BEGIN_NAMESPACE
22
23class QWaylandInputMethodEventBuilder
24{
25public:
26 QWaylandInputMethodEventBuilder() = default;
27 ~QWaylandInputMethodEventBuilder();
28
29 void reset();
30
31 void setCursorPosition(int32_t index, int32_t anchor);
32 void setDeleteSurroundingText(uint32_t beforeLength, uint32_t afterLength);
33
34 void addPreeditStyling(uint32_t index, uint32_t length, uint32_t style);
35 void setPreeditCursor(int32_t index);
36
37 QInputMethodEvent *buildCommit(const QString &text);
38 QInputMethodEvent *buildPreedit(const QString &text);
39
40 static int indexFromWayland(const QString &text, int length, int base = 0);
41 static int indexToWayland(const QString &text, int length, int base = 0);
42
43 static int trimmedIndexFromWayland(const QString &text, int length, int base = 0);
44private:
45 QPair<int, int> replacementForDeleteSurrounding();
46
47 int32_t m_anchor = 0;
48 int32_t m_cursor = 0;
49 uint32_t m_deleteBefore = 0;
50 uint32_t m_deleteAfter = 0;
51
52 int32_t m_preeditCursor = 0;
53 QList<QInputMethodEvent::Attribute> m_preeditStyles;
54};
55
56struct QWaylandInputMethodContentType {
57 uint32_t hint = 0;
58 uint32_t purpose = 0;
59
60 static QWaylandInputMethodContentType convert(Qt::InputMethodHints hints);
61 static QWaylandInputMethodContentType convertV3(Qt::InputMethodHints hints);
62};
63
64
65QT_END_NAMESPACE
66
67#endif // QWAYLANDINPUTMETHODEVENTBUILDER_H
68

source code of qtbase/src/plugins/platforms/wayland/shared/qwaylandinputmethodeventbuilder_p.h