Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 609737 Details for
Bug 854324
Enable multilanguage spelling for PSI 0.15
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Multilanguage spelling patch for PSI 0.15
psi-15-multilang-spelling.diff (text/plain), 7.99 KB, created by
Artem S. Tashkinov
on 2012-09-04 16:07:19 UTC
(
hide
)
Description:
Multilanguage spelling patch for PSI 0.15
Filename:
MIME Type:
Creator:
Artem S. Tashkinov
Created:
2012-09-04 16:07:19 UTC
Size:
7.99 KB
patch
obsolete
>diff -urN psi-0.15-rc1/options/default.xml psi-0.15-rc1-multispell/options/default.xml >--- psi-0.15-rc1/options/default.xml 2012-08-28 06:33:49.000000000 +0600 >+++ psi-0.15-rc1-multispell/options/default.xml 2012-09-04 21:30:56.351780832 +0600 >@@ -205,6 +205,7 @@ > </show-deprecated> > <spell-check comment="Options related to the spell checker"> > <enabled comment="Whether the spell checker is enabled" type="bool">true</enabled> >+ <langs type="QString"></langs> > </spell-check> > <systemtray comment="Options related to the system tray"> > <use-old comment="Use the old system tray code (deprecated)" type="bool">false</use-old> >diff -urN psi-0.15-rc1/src/libpsi/tools/spellchecker/aspellchecker.cpp psi-0.15-rc1-multispell/src/libpsi/tools/spellchecker/aspellchecker.cpp >--- psi-0.15-rc1/src/libpsi/tools/spellchecker/aspellchecker.cpp 2012-08-28 06:33:53.000000000 +0600 >+++ psi-0.15-rc1-multispell/src/libpsi/tools/spellchecker/aspellchecker.cpp 2012-09-04 21:30:56.351780832 +0600 >@@ -33,23 +33,15 @@ > #include "aspellchecker.h" > > ASpellChecker::ASpellChecker() >+ : config_(new_aspell_config()) > { >- config_ = NULL; >- speller_ = NULL; >- config_ = new_aspell_config(); > aspell_config_replace(config_, "encoding", "utf-8"); > #ifdef Q_WS_WIN > aspell_config_replace(config_, "conf-dir", QDir::homePath().toLocal8Bit().data()); > aspell_config_replace(config_, "data-dir", QString("%1/aspell").arg(QCoreApplication::applicationDirPath()).toLocal8Bit().data()); > aspell_config_replace(config_, "dict-dir", QString("%1/aspell").arg(QCoreApplication::applicationDirPath()).toLocal8Bit().data()); > #endif >- AspellCanHaveError* ret = new_aspell_speller(config_); >- if (aspell_error_number(ret) == 0) { >- speller_ = to_aspell_speller(ret); >- } >- else { >- qWarning() << QString("Aspell error: %1").arg(aspell_error_message(ret)); >- } >+ setActiveLanguages(getAllLanguages()); > } > > ASpellChecker::~ASpellChecker() >@@ -59,30 +51,33 @@ > config_ = NULL; > } > >- if(speller_) { >- delete_aspell_speller(speller_); >- speller_ = NULL; >- } >+ clearSpellers(); > } > > bool ASpellChecker::isCorrect(const QString& word) > { >- if(speller_) { >- int correct = aspell_speller_check(speller_, word.toUtf8().constData(), -1); >- return (correct != 0); >+ if(spellers_.isEmpty()) >+ return true; >+ >+ foreach(AspellSpeller* speller, spellers_) { >+ if (aspell_speller_check(speller, word.toUtf8().constData(), -1) != 0) >+ return true; > } >- return true; >+ return false; > } > > QList<QString> ASpellChecker::suggestions(const QString& word) > { > QList<QString> words; >- if (speller_) { >- const AspellWordList* list = aspell_speller_suggest(speller_, word.toUtf8(), -1); >+ >+ foreach(AspellSpeller* speller, spellers_) { >+ const AspellWordList* list = aspell_speller_suggest(speller, word.toUtf8(), -1); > AspellStringEnumeration* elements = aspell_word_list_elements(list); > const char *c_word; > while ((c_word = aspell_string_enumeration_next(elements)) != NULL) { >- words += QString::fromUtf8(c_word); >+ QString suggestion = QString::fromUtf8(c_word); >+ if(suggestion.size() > 2) >+ words.append(suggestion); > } > delete_aspell_string_enumeration(elements); > } >@@ -92,11 +87,11 @@ > bool ASpellChecker::add(const QString& word) > { > bool result = false; >- if (config_ && speller_) { >+ if (config_ && !spellers_.empty()) { > QString trimmed_word = word.trimmed(); > if(!word.isEmpty()) { >- aspell_speller_add_to_personal(speller_, trimmed_word.toUtf8(), trimmed_word.toUtf8().length()); >- aspell_speller_save_all_word_lists(speller_); >+ aspell_speller_add_to_personal(spellers_.first(), trimmed_word.toUtf8(), trimmed_word.toUtf8().length()); >+ aspell_speller_save_all_word_lists(spellers_.first()); > result = true; > } > } >@@ -105,10 +100,63 @@ > > bool ASpellChecker::available() const > { >- return (speller_ != NULL); >+ return !spellers_.isEmpty(); > } > > bool ASpellChecker::writable() const > { > return false; > } >+ >+QList<QString> ASpellChecker::getAllLanguages() const >+{ >+ QList<QString> langs; >+ >+ AspellDictInfoList* dict_info_list = get_aspell_dict_info_list(config_); >+ >+ if (!aspell_dict_info_list_empty(dict_info_list)) >+ { >+ AspellDictInfoEnumeration* dict_info_enum = aspell_dict_info_list_elements(dict_info_list); >+ >+ while (!aspell_dict_info_enumeration_at_end(dict_info_enum)) { >+ const AspellDictInfo* dict_info = aspell_dict_info_enumeration_next(dict_info_enum); >+ QString lang(dict_info -> code); >+ if (lang.contains('_')) >+ lang.truncate(lang.indexOf('_')); >+ if (!langs.contains(lang)) { >+ langs.append(lang); >+ } >+ } >+ >+ delete_aspell_dict_info_enumeration(dict_info_enum); >+ } >+ >+ return langs; >+} >+ >+void ASpellChecker::setActiveLanguages(const QList<QString>& langs) >+{ >+ clearSpellers(); >+ >+ foreach(const QString& lang, langs) >+ { >+ AspellConfig* conf = aspell_config_clone(config_); >+ aspell_config_replace(conf, "lang", lang.toUtf8().constData()); >+ AspellCanHaveError* ret = new_aspell_speller(conf); >+ if (aspell_error_number(ret) == 0) { >+ spellers_.append(to_aspell_speller(ret)); >+ } >+ else { >+ qDebug() << QString("Aspell error: %1").arg(aspell_error_message(ret)); >+ } >+ delete_aspell_config(conf); >+ } >+} >+ >+void ASpellChecker::clearSpellers() >+{ >+ foreach(AspellSpeller* speller, spellers_) >+ delete_aspell_speller(speller); >+ >+ spellers_.clear(); >+} >diff -urN psi-0.15-rc1/src/libpsi/tools/spellchecker/aspellchecker.h psi-0.15-rc1-multispell/src/libpsi/tools/spellchecker/aspellchecker.h >--- psi-0.15-rc1/src/libpsi/tools/spellchecker/aspellchecker.h 2012-08-28 06:33:53.000000000 +0600 >+++ psi-0.15-rc1-multispell/src/libpsi/tools/spellchecker/aspellchecker.h 2012-09-04 21:30:56.351780832 +0600 >@@ -46,9 +46,17 @@ > virtual bool available() const; > virtual bool writable() const; > >+ virtual void setActiveLanguages(const QList<QString>& langs); >+ virtual QList<QString> getAllLanguages() const; >+ >+private: >+ void clearSpellers(); >+ > private: > AspellConfig* config_; >- AspellSpeller* speller_; >+ >+ typedef QList<AspellSpeller*> ASpellers; >+ ASpellers spellers_; > }; > > #endif >diff -urN psi-0.15-rc1/src/libpsi/tools/spellchecker/spellchecker.h psi-0.15-rc1-multispell/src/libpsi/tools/spellchecker/spellchecker.h >--- psi-0.15-rc1/src/libpsi/tools/spellchecker/spellchecker.h 2012-08-28 06:33:53.000000000 +0600 >+++ psi-0.15-rc1-multispell/src/libpsi/tools/spellchecker/spellchecker.h 2012-09-04 21:30:56.355114167 +0600 >@@ -41,6 +41,9 @@ > virtual bool isCorrect(const QString&); > virtual bool add(const QString&); > >+ virtual void setActiveLanguages(const QList<QString>& ) {} >+ virtual QList<QString> getAllLanguages() const { return QList<QString>(); } >+ > protected: > SpellChecker(); > virtual ~SpellChecker(); >diff -urN psi-0.15-rc1/src/psicon.cpp psi-0.15-rc1-multispell/src/psicon.cpp >--- psi-0.15-rc1/src/psicon.cpp 2012-08-28 06:33:49.000000000 +0600 >+++ psi-0.15-rc1-multispell/src/psicon.cpp 2012-09-04 21:34:27.606115254 +0600 >@@ -85,6 +85,7 @@ > #include "anim.h" > #include "psioptions.h" > #include "psirichtext.h" >+#include "spellchecker/aspellchecker.h" > #ifdef PSI_PLUGINS > #include "pluginmanager.h" > #endif >@@ -680,6 +681,9 @@ > optionChanged(tuneUrlFilterOptionPath); > #endif > >+ //init spellchecker >+ optionChanged("options.ui.spell-check.langs"); >+ > return result; > } > >@@ -1280,6 +1284,22 @@ > if (option == "options.p2p.bytestreams.listen-port") { > s5b_init(); > } >+ >+ if (option == "options.ui.spell-check.langs") { >+ QStringList langs = PsiOptions::instance()->getOption(option).toString().split(QRegExp("\\s+"), QString::SkipEmptyParts); >+ if(langs.isEmpty()) { >+ langs = SpellChecker::instance()->getAllLanguages(); >+ QString lang_env = getenv("LANG"); >+ if(!lang_env.isEmpty()) { >+ lang_env = lang_env.split("_").first(); >+ if(langs.contains(lang_env, Qt::CaseInsensitive)) >+ langs = QStringList(lang_env); >+ } >+ } >+ SpellChecker::instance()->setActiveLanguages(langs); >+ return; >+ } >+ > #ifdef USE_PEP > if (option == tuneUrlFilterOptionPath || option == tuneTitleFilterOptionPath) { > d->tuneManager->setTuneFilters(PsiOptions::instance()->getOption(tuneUrlFilterOptionPath).toString().split(QRegExp("\\W+")),
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 854324
: 609737 |
609738
|
609739