Changeset View
Changeset View
Standalone View
Standalone View
src/core/inputtextmanager.h
Show All 23 Lines | |||||
24 | #include <QJsonObject> | 24 | #include <QJsonObject> | ||
25 | #include <QObject> | 25 | #include <QObject> | ||
26 | 26 | | |||
27 | #include "libruqola_private_export.h" | 27 | #include "libruqola_private_export.h" | ||
28 | class InputCompleterModel; | 28 | class InputCompleterModel; | ||
29 | class LIBRUQOLACORE_TESTS_EXPORT InputTextManager : public QObject | 29 | class LIBRUQOLACORE_TESTS_EXPORT InputTextManager : public QObject | ||
30 | { | 30 | { | ||
31 | Q_OBJECT | 31 | Q_OBJECT | ||
32 | Q_PROPERTY(InputCompleterModel* inputCompleterModel READ inputCompleterModel CONSTANT) | ||||
32 | public: | 33 | public: | ||
33 | enum CompletionForType { | 34 | enum CompletionForType { | ||
34 | Channel = 0, | 35 | Channel = 0, | ||
35 | User | 36 | User | ||
36 | }; | 37 | }; | ||
37 | explicit InputTextManager(QObject *parent = nullptr); | 38 | explicit InputTextManager(QObject *parent = nullptr); | ||
38 | ~InputTextManager() override; | 39 | ~InputTextManager() override; | ||
39 | 40 | | |||
40 | Q_REQUIRED_RESULT InputCompleterModel *inputCompleterModel() const; | 41 | Q_REQUIRED_RESULT InputCompleterModel *inputCompleterModel() const; | ||
41 | 42 | | |||
42 | void inputTextCompleter(const QJsonObject &obj); | 43 | void inputTextCompleter(const QJsonObject &obj); | ||
43 | 44 | | |||
44 | Q_REQUIRED_RESULT QString replaceWord(const QString &newWord, const QString &str, int position); | 45 | Q_INVOKABLE Q_REQUIRED_RESULT QString replaceWord(const QString &newWord, const QString &str, int position); | ||
45 | Q_REQUIRED_RESULT QString applyCompletion(const QString &newWord, const QString &str, int *pPosition); | 46 | Q_REQUIRED_RESULT QString applyCompletion(const QString &newWord, const QString &str, int *pPosition); | ||
46 | 47 | | |||
47 | void setInputTextChanged(const QString &str, int position); | 48 | Q_INVOKABLE void setInputTextChanged(const QString &str, int position); | ||
48 | 49 | | |||
49 | void clearCompleter(); | 50 | void clearCompleter(); | ||
50 | 51 | | |||
51 | //Only for autotests | 52 | //Only for autotests | ||
52 | Q_REQUIRED_RESULT QString searchWord(const QString &text, int position); | 53 | Q_REQUIRED_RESULT QString searchWord(const QString &text, int position); | ||
53 | 54 | | |||
54 | Q_SIGNALS: | 55 | Q_SIGNALS: | ||
55 | void inputCompleter(const QString &pattern, const QString &exceptions, InputTextManager::CompletionForType type); | 56 | void inputCompleter(const QString &pattern, const QString &exceptions, InputTextManager::CompletionForType type); | ||
56 | 57 | | |||
57 | private: | 58 | private: | ||
58 | Q_DISABLE_COPY(InputTextManager) | 59 | Q_DISABLE_COPY(InputTextManager) | ||
59 | InputCompleterModel *mInputCompleterModel = nullptr; | 60 | InputCompleterModel *mInputCompleterModel = nullptr; | ||
60 | }; | 61 | }; | ||
61 | 62 | | |||
62 | #endif // INPUTTEXTMANAGER_H | 63 | #endif // INPUTTEXTMANAGER_H |