23 #include <QtGui/QCheckBox>
24 #include <QtGui/QComboBox>
25 #include <QtGui/QLabel>
26 #include <QtGui/QLayout>
27 #include <QtCore/QFileInfo>
28 #include <QtCore/QDir>
44 class K3SpellConfigPrivate
60 , d(new K3SpellConfigPrivate)
62 kDebug(750) <<
"Entering K3SpellConfig::K3SpellConfig(K3SpellConfig&)";
78 :
QWidget (parent), nodialog(false)
87 , d(new K3SpellConfigPrivate)
108 QGridLayout *glay =
new QGridLayout(
this );
109 glay->setMargin( 0 );
110 cb0 =
new QCheckBox(
i18nc(
"@option:check",
"Do Spellchecking"),
this );
111 cb0->setObjectName(
"DoSpellChecking" );
112 connect(
cb0, SIGNAL(toggled(
bool)), SLOT(
sDoSpell()) );
113 cb1 =
new QCheckBox(
i18nc(
"@option:check",
114 "Create &root/affix combinations not in dictionary"),
this );
115 cb1->setObjectName(
"NoRootAffix" );
116 connect(
cb1, SIGNAL(toggled(
bool)), SLOT(
sNoAff(
bool)) );
117 glay->addWidget(
cb0, 0, 0, 1, 3 );
118 glay->addWidget(
cb1, 1, 0, 1, 3 );
120 cb2 =
new QCheckBox(
i18nc(
"@option:check",
121 "Consider run-together &words as spelling errors"),
this );
122 cb2->setObjectName(
"RunTogether" );
124 glay->addWidget(
cb2, 2, 0, 1, 3 );
127 dictcombo->setObjectName(
"DictFromList" );
128 dictcombo->setInsertPolicy( QComboBox::NoInsert );
129 connect(
dictcombo, SIGNAL (activated(
int)),
131 glay->addWidget(
dictcombo, 3, 1, 1, 2 );
162 glay->addWidget( tmpQLabel, 4, 0 );
167 clientcombo->addItem(
i18nc(
"@item:inlistbox Spell checker",
"International <application>Ispell</application>") );
168 clientcombo->addItem(
i18nc(
"@item:inlistbox Spell checker",
"<application>Aspell</application>") );
169 clientcombo->addItem(
i18nc(
"@item:inlistbox Spell checker",
"<application>Hspell</application>") );
170 clientcombo->addItem(
i18nc(
"@item:inlistbox Spell checker",
"<application>Zemberek</application>") );
171 clientcombo->addItem(
i18nc(
"@item:inlistbox Spell checker",
"<application>Hunspell</application>") );
172 connect(
clientcombo, SIGNAL (activated(
int)),
this,
176 tmpQLabel =
new QLabel(
i18nc(
"@label:listbox",
"&Client:"),
this );
178 glay->addWidget( tmpQLabel, 5, 0 );
183 connect( pushButton, SIGNAL(clicked()),
this, SLOT(
sHelp()) );
184 glay->addWidget(pushButton, 6, 2);
205 kDebug(750) <<
"Entering K3SpellConfig::readGlobalSettings (see k3sconfig.cpp)";
224 KConfigBase::WriteConfigFlags flags(KConfigBase::Global|KConfigBase::Persistent);
240 kDebug(750) <<
"K3SpellConfig::sChangeEncoding(" << i <<
")";
253 getAvailDictsIspell();
258 dictcombo->addItem(
i18nc(
"@item Spelling dictionary",
"Hebrew") );
263 dictcombo->addItem(
i18nc(
"@item Spelling dictionary",
"Turkish") );
267 getAvailDictsAspell();
269 getAvailDictsHunspell();
280 kDebug(750) <<
"K3SpellConfig::interpret [" << fname <<
"]";
284 if( dname.endsWith(
'+' ) )
285 dname.remove( dname.length()-1, 1 );
287 if( dname.endsWith(
"sml") || dname.endsWith(
"med") || dname.endsWith(
"lrg") ||
288 dname.endsWith(
"xlg"))
289 dname.remove(dname.length()-3,3);
293 int i = dname.indexOf(
'-');
296 extension = dname.mid(i+1);
302 if ( (dname.length() == 2) || (dname.length() == 3) ) {
306 else if ( (dname.length() == 5) && (dname[2] ==
'_') ) {
307 lname = dname.left(2);
310 if ( extension.isEmpty() )
313 extension = country +
" - " + extension;
316 else if ( dname==
"english" || dname==
"american" ||
317 dname==
"british" || dname==
"canadian" ) {
318 lname=
"en"; hname=
i18nc(
"@item Spelling dictionary",
"English");
320 else if ( dname ==
"espa~nol" || dname ==
"espanol" ) {
321 lname=
"es"; hname=
i18nc(
"@item Spelling dictionary",
"Spanish");
323 else if (dname==
"dansk") {
324 lname=
"da"; hname=
i18nc(
"@item Spelling dictionary",
"Danish");
326 else if (dname==
"deutsch") {
327 lname=
"de"; hname=
i18nc(
"@item Spelling dictionary",
"German");
329 else if (dname==
"german") {
330 lname=
"de"; hname=
i18nc(
"@item Spelling dictionary",
"German (new spelling)");
332 else if (dname==
"portuguesb" || dname==
"br") {
333 lname=
"br"; hname=
i18nc(
"@item Spelling dictionary",
"Brazilian Portuguese");
335 else if (dname==
"portugues") {
336 lname=
"pt"; hname=
i18nc(
"@item Spelling dictionary",
"Portuguese");
338 else if (dname==
"esperanto") {
339 lname=
"eo"; hname=
i18nc(
"@item Spelling dictionary",
"Esperanto");
341 else if (dname==
"norsk") {
342 lname=
"no"; hname=
i18nc(
"@item Spelling dictionary",
"Norwegian");
344 else if (dname==
"polish") {
347 else if (dname==
"russian") {
348 lname=
"ru"; hname=
i18nc(
"@item Spelling dictionary",
"Russian");
350 else if (dname==
"slovensko") {
353 else if (dname==
"slovak"){
356 else if (dname==
"czech") {
359 else if (dname==
"svenska") {
360 lname=
"sv"; hname=
i18nc(
"@item Spelling dictionary",
"Swedish");
362 else if (dname==
"swiss") {
363 lname=
"de"; hname=
i18nc(
"@item Spelling dictionary",
"Swiss German");
365 else if (dname==
"ukrainian") {
366 lname=
"uk"; hname=
i18nc(
"@item Spelling dictionary",
"Ukrainian");
368 else if (dname==
"lietuviu" || dname==
"lithuanian") {
369 lname=
"lt"; hname=
i18nc(
"@item Spelling dictionary",
"Lithuanian");
371 else if (dname==
"francais" || dname==
"french") {
372 lname=
"fr"; hname=
i18nc(
"@item Spelling dictionary",
"French");
374 else if (dname==
"belarusian") {
375 lname=
"be"; hname=
i18nc(
"@item Spelling dictionary",
"Belarusian");
377 else if( dname ==
"magyar" ) {
378 lname=
"hu"; hname=
i18nc(
"@item Spelling dictionary",
"Hungarian");
382 lname=
""; hname=
i18nc(
"@item Spelling dictionary",
"Unknown");
384 if (!extension.isEmpty())
386 hname = hname +
" (" + extension +
')';
391 lname==QLatin1String(
"en") ) ||
404 kDebug(750) <<
"K3SpellConfig::fillinDialog";
414 getAvailDictsIspell();
420 dictcombo->addItem(
i18nc(
"@item Spelling dictionary",
"Hebrew") );
425 dictcombo->addItem(
i18nc(
"@item Spelling dictionary",
"Turkish") );
428 getAvailDictsAspell();
430 getAvailDictsHunspell();
440 if (
dictionary().isEmpty() || whichelement!=-1)
443 if (whichelement!=-1)
444 dictcombo->setCurrentIndex(whichelement);
462 void K3SpellConfig::getAvailDictsIspell () {
468 "<application>ISpell</application> Default") );
471 QFileInfo
dir (
"/usr/lib/ispell");
472 if (!
dir.exists() || !
dir.isDir())
473 dir.setFile (
"/usr/local/lib/ispell");
474 if (!
dir.exists() || !
dir.isDir())
475 dir.setFile (
"/usr/local/share/ispell");
476 if (!
dir.exists() || !
dir.isDir())
477 dir.setFile (
"/usr/share/ispell");
478 if (!
dir.exists() || !
dir.isDir())
479 dir.setFile (
"/usr/pkg/lib");
485 if (!
dir.exists() || !
dir.isDir())
return;
487 kDebug(750) <<
"K3SpellConfig::getAvailDictsIspell "
488 <<
dir.filePath() <<
" " <<
dir.path() << endl;
490 const QDir thedir (
dir.filePath(),
"*.hash");
493 kDebug(750) <<
"K3SpellConfig" << thedir.path() <<
"\n";
494 kDebug(750) <<
"entryList().count()="
495 << entryList.count() << endl;
497 QStringList::const_iterator entryListItr = entryList.constBegin();
498 const QStringList::const_iterator entryListEnd = entryList.constEnd();
500 for ( ; entryListItr != entryListEnd; ++entryListItr)
503 fname = *entryListItr;
506 if (fname.endsWith(
".hash")) fname.remove (fname.length()-5,5);
515 hname=
i18nc(
"@item Spelling dictionary: %1 dictionary name, %2 file name",
516 "Default - %1 [%2]", hname, fname);
523 hname=hname+
" ["+fname+
']';
530 void K3SpellConfig::getAvailDictsAspell () {
537 "<application>ASpell</application> Default"));
541 QFileInfo
dir (
"/usr/lib" KDELIBSUFF
"/aspell");
542 if (!
dir.exists() || !
dir.isDir())
543 dir.setFile (
"/usr/lib" KDELIBSUFF
"/aspell-0.60");
544 if (!
dir.exists() || !
dir.isDir())
545 dir.setFile (
"/usr/local/lib" KDELIBSUFF
"/aspell");
546 if (!
dir.exists() || !
dir.isDir())
547 dir.setFile (
"/usr/share/aspell");
548 if (!
dir.exists() || !
dir.isDir())
549 dir.setFile (
"/usr/local/share/aspell");
550 if (!
dir.exists() || !
dir.isDir())
551 dir.setFile (
"/usr/pkg/lib/aspell");
552 if (!
dir.exists() || !
dir.isDir())
return;
554 kDebug(750) <<
"K3SpellConfig::getAvailDictsAspell "
555 <<
dir.filePath() <<
" " <<
dir.path() << endl;
557 const QDir thedir (
dir.filePath(),
"*");
560 kDebug(750) <<
"K3SpellConfig" << thedir.path() <<
"\n";
561 kDebug(750) <<
"entryList().count()="
562 << entryList.count() << endl;
564 QStringList::const_iterator entryListItr = entryList.constBegin();
565 const QStringList::const_iterator entryListEnd = entryList.constEnd();
567 for ( ; entryListItr != entryListEnd; ++entryListItr)
570 fname = *entryListItr;
582 if ( !( fname.endsWith(
".rws") || fname.endsWith(
".multi") ) ) {
590 if (fname.endsWith(
".multi")) fname.remove (fname.length()-6,6);
592 if (fname.endsWith(
".rws")) fname.remove (fname.length()-4,4);
601 hname=
i18nc(
"@item Spelling dictionary: %1 dictionary name",
602 "Default - %1", hname);
615 void K3SpellConfig::getAvailDictsHunspell () {
621 "<application>Hunspell</application> Default") );
624 QFileInfo
dir (
"/usr/share/myspell");
625 if (!
dir.exists() || !
dir.isDir())
626 dir.setFile (
"/usr/share/hunspell");
627 if (!
dir.exists() || !
dir.isDir())
return;
629 kDebug(750) <<
"K3SpellConfig::getAvailDictsHunspell "
630 <<
dir.filePath() <<
" " <<
dir.path() << endl;
632 const QDir thedir (
dir.filePath(),
"*.dic");
635 kDebug(750) <<
"K3SpellConfig" << thedir.path() <<
"\n";
636 kDebug(750) <<
"entryList().count()="
637 << entryList.count() << endl;
639 QStringList::const_iterator entryListItr = entryList.constBegin();
640 const QStringList::const_iterator entryListEnd = entryList.constEnd();
642 for ( ; entryListItr != entryListEnd; ++entryListItr)
645 fname = *entryListItr;
648 if (fname.endsWith(
".dic")) fname.remove (fname.length()-4,4);
657 hname=
i18nc(
"@item Spelling dictionary: %1 dictionary name, %2 file name",
658 "Default - %1 [%2]", hname, fname);
665 hname=hname+
" ["+fname+
']';
680 box->addItem(
i18nc(
"@item Spelling dictionary",
681 "<application>ISpell</application> Default") );
684 QFileInfo
dir (
"/usr/lib/ispell");
685 if (!dir.exists() || !dir.isDir())
686 dir.setFile (
"/usr/local/lib/ispell");
687 if (!dir.exists() || !dir.isDir())
688 dir.setFile (
"/usr/local/share/ispell");
689 if (!dir.exists() || !dir.isDir())
690 dir.setFile (
"/usr/share/ispell");
691 if (!dir.exists() || !dir.isDir())
692 dir.setFile (
"/usr/pkg/lib");
698 if (!dir.exists() || !dir.isDir())
return;
700 kDebug(750) <<
"K3SpellConfig::getAvailDictsIspell "
701 << dir.filePath() <<
" " << dir.path() << endl;
703 const QDir thedir (dir.filePath(),
"*.hash");
706 kDebug(750) <<
"K3SpellConfig" << thedir.path() <<
"\n";
707 kDebug(750) <<
"entryList().count()="
708 << entryList.count() << endl;
710 QStringList::const_iterator entryListItr = entryList.constBegin();
711 const QStringList::const_iterator entryListEnd = entryList.constEnd();
713 for ( ; entryListItr != entryListEnd; ++entryListItr)
716 fname = *entryListItr;
719 if (fname.endsWith(
".hash")) fname.remove (fname.length()-5,5);
728 hname=
i18nc(
"@item Spelling dictionary: %1 dictionary name, %2 file name",
729 "Default - %1 [%2]", hname, fname);
731 box->setItemText (0,hname);
736 hname=hname+
" ["+fname+
']';
738 box->addItem (hname);
743 box->addItem(
i18nc(
"@item Spelling dictionary",
"Hebrew") );
748 box->addItem(
i18nc(
"@item Spelling dictionary",
"Turkish") );
754 box->addItem (
i18nc(
"@item Spelling dictionary",
755 "<application>ASpell</application> Default"));
759 QFileInfo
dir (
"/usr/lib" KDELIBSUFF
"/aspell");
760 if (!dir.exists() || !dir.isDir())
761 dir.setFile (
"/usr/lib" KDELIBSUFF
"/aspell-0.60");
762 if (!dir.exists() || !dir.isDir())
763 dir.setFile (
"/usr/local/lib" KDELIBSUFF
"/aspell");
764 if (!dir.exists() || !dir.isDir())
765 dir.setFile (
"/usr/share/aspell");
766 if (!dir.exists() || !dir.isDir())
767 dir.setFile (
"/usr/local/share/aspell");
768 if (!dir.exists() || !dir.isDir())
769 dir.setFile (
"/usr/pkg/lib/aspell");
770 if (!dir.exists() || !dir.isDir())
return;
772 kDebug(750) <<
"K3SpellConfig::getAvailDictsAspell "
773 << dir.filePath() <<
" " << dir.path() << endl;
775 const QDir thedir (dir.filePath(),
"*");
778 kDebug(750) <<
"K3SpellConfig" << thedir.path() <<
"\n";
779 kDebug(750) <<
"entryList().count()="
780 << entryList.count() << endl;
782 QStringList::const_iterator entryListItr = entryList.constBegin();
783 const QStringList::const_iterator entryListEnd = entryList.constEnd();
785 for ( ; entryListItr != entryListEnd; ++entryListItr)
788 fname = *entryListItr;
800 if ( !( fname.endsWith(
".rws") || fname.endsWith(
".multi") ) ) {
808 if (fname.endsWith(
".multi")) fname.remove (fname.length()-6,6);
810 if (fname.endsWith(
".rws")) fname.remove (fname.length()-4,4);
819 hname=
i18nc(
"@item Spelling dictionary: %1 dictionary name",
820 "Default - %1", hname);
822 box->setItemText (0,hname);
827 box->addItem (hname);
834 box->addItem(
i18nc(
"@item Spelling dictionary",
835 "<application>Hunspell</application> Default") );
838 QFileInfo
dir (
"/usr/share/myspell");
839 if (!dir.exists() || !dir.isDir())
840 dir.setFile (
"/usr/share/hunspell");
841 if (!dir.exists() || !dir.isDir())
return;
843 kDebug(750) <<
"K3SpellConfig::getAvailDictsHunspell "
844 << dir.filePath() <<
" " << dir.path() << endl;
846 const QDir thedir (dir.filePath(),
"*.dic");
849 kDebug(750) <<
"K3SpellConfig" << thedir.path() <<
"\n";
850 kDebug(750) <<
"entryList().count()="
851 << entryList.count() << endl;
853 QStringList::const_iterator entryListItr = entryList.constBegin();
854 const QStringList::const_iterator entryListEnd = entryList.constEnd();
856 for ( ; entryListItr != entryListEnd; ++entryListItr)
859 fname = *entryListItr;
862 if (fname.endsWith(
".dic")) fname.remove (fname.length()-4,4);
871 hname=
i18nc(
"@item Spelling dictionary: %1 dictionary name, %2 file name",
872 "Default - %1 [%2]", hname, fname);
874 box->setItemText (0,hname);
879 hname=hname+
" ["+fname+
']';
881 box->addItem (hname);
886 if ( whichelement >= 0 ) {
887 box->setCurrentIndex( whichelement );
940 if ((
signed)
qsdict.indexOf(
".hash")==(signed)
qsdict.length()-5)
951 if(whichelement >= 0)
953 dictcombo->setCurrentIndex(whichelement);
1177 d->replacelist=_replacelist;
1183 return d->replacelist;
1186 #include "k3sconfig.moc"
void sHelp()
Invokes the help documentation for k3spell.
K3SpellConfig(QWidget *parent=0, K3SpellConfig *spellConfig=0, bool addHelpButton=true)
Constructs a K3SpellConfig with default or custom settings.
bool interpret(const QString &fname, QString &lname, QString &hname)
This takes a dictionary file name and provides both a language abbreviation appropriate for the $LANG...
void sChangeEncoding(int)
bool writeGlobalSettings()
Call this method before this class is deleted if you want the settings you have (or the user has) cho...
bool readGlobalSettings()
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
void fillDicts(QComboBox *box, QStringList *dictionaries=0)
Get the translated dictionary names and, optionally, the corresponding internal dictionary names...
void setNoRootAffix(bool)
Set an ISpell option.
A configuration class/dialog for K3Spell.
QString countryCodeToName(const QString &country) const
bool dictFromList() const
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QString languageCodeToName(const QString &language) const
QString i18nc(const char *ctxt, const char *text)
const QString dictionary() const
KSharedConfigPtr config()
void setDoSpellChecking(bool b)
Activate SpellChecking.
QStringList replaceAllList() const
void sPathDictionary(bool)
virtual ~K3SpellConfig()
Deconstructor.
bool doSpellChecking() const
Options reading routines.
void setDictionary(const QString qs)
Set the name of the dictionary to use.
void setRunTogether(bool)
Set an ISpell option.
void setEncoding(int enctype)
void setIgnoreList(const QStringList &_ignorelist)
Options setting routines.
void setClient(int client)
void setReplaceAllList(const QStringList &_replaceAllList)
The _replaceAllList contains word you like that replace word.
QString dir(const QString &fileClass)
void activateHelp(void)
Use this function to activate the help information for this widget.
void setDictFromList(bool dfl)
QComboBox * encodingcombo
void operator=(const K3SpellConfig &ksc)
T readEntry(const QString &key, const T &aDefault) const
int client() const
Spell checker client,.
QStringList ignoreList() const