9#include "settingsimpl_p.h"
10#include "spellerplugin_p.h"
12#include "core_debug.h"
29 void init(
const QString &lang)
31 Loader *loader = Loader::openLoader();
32 settings = loader->settings();
40 dict = Loader::openLoader()->cachedSpeller(language);
45 if (settings->modified()) {
47 settings->setModified(
false);
49 return !dict.isNull();
54 Loader::openLoader()->clearSpellerCache();
58 QSharedPointer<SpellerPlugin> dict;
59 SettingsImpl *settings =
nullptr;
63Speller::Speller(
const QString &lang)
64 : d(new SpellerPrivate)
71 qCDebug(SONNET_LOG_CORE) <<
"deleting" <<
this <<
"for" << d->language;
74Speller::Speller(
const Speller &speller)
75 : d(new SpellerPrivate)
77 d->language = speller.language();
81Speller &Speller::operator=(
const Speller &speller)
83 d->language = speller.language();
93 return d->dict->isCorrect(word);
101 return d->dict->isMisspelled(word);
109 return d->dict->suggest(word);
117 return d->dict->checkAndSuggest(word, suggestions);
125 return d->dict->storeReplacement(bad, good);
133 return d->dict->addToPersonal(word);
141 return d->dict->addToSession(word);
149 return d->dict->language();
159void Speller::restore()
162 d->settings->restore();
169 Loader *l = Loader::openLoader();
175 Loader *l = Loader::openLoader();
176 return l->languages();
181 Loader *l = Loader::openLoader();
182 return l->languageNames();
185void Speller::setDefaultLanguage(
const QString &lang)
187 if (d->settings->setDefaultLanguage(lang)) {
192QString Speller::defaultLanguage()
const
194 return d->settings->defaultLanguage();
197void Speller::setDefaultClient(
const QString &client)
199 if (d->settings->setDefaultClient(client)) {
204QString Speller::defaultClient()
const
206 return d->settings->defaultClient();
209void Speller::setAttribute(Attribute attr,
bool b)
213 d->settings->setCheckUppercase(b);
215 case SkipRunTogether:
216 d->settings->setSkipRunTogether(b);
218 case AutoDetectLanguage:
219 d->settings->setAutodetectLanguage(b);
225bool Speller::testAttribute(Attribute attr)
const
229 return d->settings->checkUppercase();
230 case SkipRunTogether:
231 return d->settings->skipRunTogether();
232 case AutoDetectLanguage:
233 return d->settings->autodetectLanguage();
240 return !d->dict.isNull();
251 Loader *l = Loader::openLoader();
255 for (
const QString &tag : lst) {
256 langs.
insert(l->languageNameForCode(tag), tag);
264 Loader *l = Loader::openLoader();
267 for (
const QString &tag : l->settings()->preferredLanguages()) {
268 langs.
insert(l->languageNameForCode(tag), tag);
QMap< QString, QString > preferredDictionaries() const
bool checkAndSuggest(const QString &word, QStringList &suggestions) const
Convenience method calling isCorrect() and suggest() if the word isn't correct.
bool addToSession(const QString &word)
Adds word to the words recognizable in the current session.
QStringList availableBackends() const
QStringList availableLanguageNames() const
bool isMisspelled(const QString &word) const
Checks the given word.
QStringList suggest(const QString &word) const
Fetches suggestions for the word.
QMap< QString, QString > availableDictionaries() const
bool addToPersonal(const QString &word)
Adds word to the list of of personal words.
bool isCorrect(const QString &word) const
Checks the given word.
bool storeReplacement(const QString &bad, const QString &good)
Stores user defined good replacement for the bad word.
void setLanguage(const QString &lang)
Sets the language supported by this speller.
QStringList availableLanguages() const
iterator insert(const Key &key, const T &value)