Changeset View
Changeset View
Standalone View
Standalone View
src/core/backgroundchecker.cpp
| Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 29 | do { | |||
|---|---|---|---|---|---|
| 43 | } | 43 | } | ||
| 44 | // current sentence done, grab next suitable | 44 | // current sentence done, grab next suitable | ||
| 45 | 45 | | |||
| 46 | sentenceOffset = -1; | 46 | sentenceOffset = -1; | ||
| 47 | const bool autodetectLanguage = currentDict.testAttribute(Speller::AutoDetectLanguage); | 47 | const bool autodetectLanguage = currentDict.testAttribute(Speller::AutoDetectLanguage); | ||
| 48 | const bool ignoreUpperCase = !currentDict.testAttribute(Speller::CheckUppercase); | 48 | const bool ignoreUpperCase = !currentDict.testAttribute(Speller::CheckUppercase); | ||
| 49 | while (mainTokenizer.hasNext()) { | 49 | while (mainTokenizer.hasNext()) { | ||
| 50 | QStringRef sentence = mainTokenizer.next(); | 50 | QStringRef sentence = mainTokenizer.next(); | ||
| 51 | if (autodetectLanguage) { | 51 | if (autodetectLanguage && !autoDetectLanguageDisabled) { | ||
| 52 | if (!mainTokenizer.isSpellcheckable()) { | 52 | if (!mainTokenizer.isSpellcheckable()) { | ||
| 53 | continue; | 53 | continue; | ||
| 54 | } | 54 | } | ||
| 55 | // FIXME: find best from family en -> en_US, en_GB, ... ? | 55 | // FIXME: find best from family en -> en_US, en_GB, ... ? | ||
| 56 | currentDict.setLanguage(mainTokenizer.language()); | 56 | currentDict.setLanguage(mainTokenizer.language()); | ||
| 57 | } | 57 | } | ||
| 58 | sentenceOffset = sentence.position(); | 58 | sentenceOffset = sentence.position(); | ||
| 59 | words.setBuffer(sentence.toString()); | 59 | words.setBuffer(sentence.toString()); | ||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
| 114 | { | 114 | { | ||
| 115 | return QString(); | 115 | return QString(); | ||
| 116 | } | 116 | } | ||
| 117 | 117 | | |||
| 118 | void BackgroundChecker::finishedCurrentFeed() | 118 | void BackgroundChecker::finishedCurrentFeed() | ||
| 119 | { | 119 | { | ||
| 120 | } | 120 | } | ||
| 121 | 121 | | |||
| 122 | bool BackgroundChecker::autoDetectLanguageDisabled() const | ||||
| 123 | { | ||||
| 124 | return d->autoDetectLanguageDisabled; | ||||
| 125 | } | ||||
| 126 | | ||||
| 127 | void BackgroundChecker::setAutoDetectLanguageDisabled(bool autoDetectDisabled) | ||||
| 128 | { | ||||
| 129 | d->autoDetectLanguageDisabled = autoDetectDisabled; | ||||
| 130 | } | ||||
| 131 | | ||||
| 122 | void BackgroundChecker::setSpeller(const Speller &speller) | 132 | void BackgroundChecker::setSpeller(const Speller &speller) | ||
| 123 | { | 133 | { | ||
| 134 | d->autoDetectLanguageDisabled = true; | ||||
aacid: question from someone that has never really used this setSpeller API.
Is this behaviour change… | |||||
| 124 | d->currentDict = speller; | 135 | d->currentDict = speller; | ||
| 125 | } | 136 | } | ||
| 126 | 137 | | |||
| 127 | Speller BackgroundChecker::speller() const | 138 | Speller BackgroundChecker::speller() const | ||
| 128 | { | 139 | { | ||
| 129 | return d->currentDict; | 140 | return d->currentDict; | ||
| 130 | } | 141 | } | ||
| 131 | 142 | | |||
| Show All 15 Lines | |||||
| 147 | QStringList BackgroundChecker::suggest(const QString &word) const | 158 | QStringList BackgroundChecker::suggest(const QString &word) const | ||
| 148 | { | 159 | { | ||
| 149 | return d->currentDict.suggest(word); | 160 | return d->currentDict.suggest(word); | ||
| 150 | } | 161 | } | ||
| 151 | 162 | | |||
| 152 | void BackgroundChecker::changeLanguage(const QString &lang) | 163 | void BackgroundChecker::changeLanguage(const QString &lang) | ||
| 153 | { | 164 | { | ||
| 154 | // this sets language only for current sentence | 165 | // this sets language only for current sentence | ||
| 166 | d->autoDetectLanguageDisabled = true; | ||||
aacid: same question here | |||||
| 155 | d->currentDict.setLanguage(lang); | 167 | d->currentDict.setLanguage(lang); | ||
| 156 | } | 168 | } | ||
| 157 | 169 | | |||
| 158 | void BackgroundChecker::continueChecking() | 170 | void BackgroundChecker::continueChecking() | ||
| 159 | { | 171 | { | ||
| 160 | d->continueChecking(); | 172 | d->continueChecking(); | ||
| 161 | } | 173 | } | ||
| 162 | 174 | | |||
| ▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines | |||||
question from someone that has never really used this setSpeller API.
Is this behaviour change for sure 100% of the times wanted?
If not you should add a new API that is setSpeller(speller, bool)