diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2018-08-07 12:01:39 +0300 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2018-08-16 13:31:39 +0000 |
commit | e803aec1ea21fd00e13b9535a4b536cc43c26ee4 (patch) | |
tree | 7cdcfcebb4de0cf3651aeea56637e335b46f9a18 /src/virtualkeyboard/selectionlistmodel.h | |
parent | cf69f8603e3a1fee24f79d1b446b5ea717e2cf7d (diff) |
Add user dictionary and learning for Hunspell
This change adds user dictionary and learning function for Hunspell.
Learning happens when the user selects the first candidate from the
word candidate list (or presses the space key while the first candidate
is selected) and the word does not exist in the default dictionary.
User can remove a word from user dictionary by long pressing an item
on the word candidate list (and selecting from the menu). This also
allows the user to block words originating from the system dictionary.
The Hunspell user dictionary is hard limited to 100 words. However, when
user enters a word again (which exists in the user dictionary), it will
be prioritized in the dictionary, so the most frequent words stay in the
dictionary.
The dictionaries are language and locale specific and are stored in:
QStandardPaths::GenericConfigLocation + "/qtvirtualkeyboard/hunspell"
The dictionaries are UTF-8 encoded text files and contain one word per line.
The same directory also contains the blacklist files (which also exist per
language and locale). These files contain words which are blacklisted from
the default dictionary.
[ChangeLog] Added user dictionary and learning for Hunspell
Change-Id: Ib0fc70f7eaa14ec49b74000144a75c59313ac0fb
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/virtualkeyboard/selectionlistmodel.h')
-rw-r--r-- | src/virtualkeyboard/selectionlistmodel.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/virtualkeyboard/selectionlistmodel.h b/src/virtualkeyboard/selectionlistmodel.h index ec9b84e3..22d0ed3d 100644 --- a/src/virtualkeyboard/selectionlistmodel.h +++ b/src/virtualkeyboard/selectionlistmodel.h @@ -56,11 +56,19 @@ public: enum Role { DisplayRole = Qt::DisplayRole, - WordCompletionLengthRole = Qt::UserRole + 1 + WordCompletionLengthRole = Qt::UserRole + 1, + DictionaryTypeRole, + CanRemoveSuggestionRole, + }; + enum DictionaryType + { + DefaultDictionary = 0, + UserDictionary }; Q_ENUM(Type) Q_ENUM(Role) + Q_ENUM(DictionaryType) ~SelectionListModel(); void setDataSource(AbstractInputMethod *dataSource, Type type); @@ -72,6 +80,7 @@ public: int count() const; Q_INVOKABLE void selectItem(int index); + Q_INVOKABLE void removeItem(int index); Q_INVOKABLE QVariant dataAt(int index, int role = Qt::DisplayRole) const; Q_SIGNALS: @@ -92,5 +101,6 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtVirtualKeyboard)::SelectionListModel::Type) Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtVirtualKeyboard)::SelectionListModel::Role) +Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtVirtualKeyboard)::SelectionListModel::DictionaryType) #endif // SELECTIONLISTMODEL_H |