| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef PINYINDECODERSERVICE_P_H |
| 5 | #define PINYINDECODERSERVICE_P_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 <QObject> |
| 19 | |
| 20 | QT_BEGIN_NAMESPACE |
| 21 | namespace QtVirtualKeyboard { |
| 22 | |
| 23 | class PinyinDecoderService : public QObject |
| 24 | { |
| 25 | Q_OBJECT |
| 26 | Q_DISABLE_COPY(PinyinDecoderService) |
| 27 | explicit PinyinDecoderService(QObject *parent = nullptr); |
| 28 | |
| 29 | public: |
| 30 | ~PinyinDecoderService(); |
| 31 | |
| 32 | static PinyinDecoderService *getInstance(); |
| 33 | |
| 34 | bool init(); |
| 35 | void setUserDictionary(bool enabled); |
| 36 | bool isUserDictionaryEnabled() const; |
| 37 | void setLimits(int maxSpelling, int maxHzsLen); |
| 38 | int search(const QString &spelling); |
| 39 | int deleteSearch(int pos, bool isPosInSpellingId, bool clearFixedInThisStep); |
| 40 | void resetSearch(); |
| 41 | QString pinyinString(bool decoded); |
| 42 | int pinyinStringLength(bool decoded); |
| 43 | QList<int> spellingStartPositions(); |
| 44 | QString candidateAt(int index); |
| 45 | QList<QString> fetchCandidates(int index, int count, int sentFixedLen); |
| 46 | int chooceCandidate(int index); |
| 47 | int cancelLastChoice(); |
| 48 | int fixedLength(); |
| 49 | void flushCache(); |
| 50 | QList<QString> predictionList(const QString &history); |
| 51 | |
| 52 | private: |
| 53 | static QScopedPointer<PinyinDecoderService> _instance; |
| 54 | bool initDone; |
| 55 | }; |
| 56 | |
| 57 | } // namespace QtVirtualKeyboard |
| 58 | QT_END_NAMESPACE |
| 59 | |
| 60 | #endif // PINYINDECODERSERVICE_P_H |
| 61 |
