00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include <qcheckbox.h>
00023 #include <qcombobox.h>
00024 #include <qlabel.h>
00025 #include <qlayout.h>
00026 #include <qtimer.h>
00027
00028 #include <kapplication.h>
00029 #include <kconfig.h>
00030 #include <kdebug.h>
00031 #include <kdialog.h>
00032 #include <kfiledialog.h>
00033 #include <kglobal.h>
00034 #include <klineedit.h>
00035 #include <klocale.h>
00036 #include <kpushbutton.h>
00037 #include <kstdguiitem.h>
00038
00039 #include "ksconfig.h"
00040
00041 class KSpellConfigPrivate
00042 {
00043 public:
00044 QStringList replacelist;
00045 };
00046
00047
00048 KSpellConfig::KSpellConfig (const KSpellConfig &_ksc)
00049 : QWidget(0, 0), nodialog(true)
00050 , kc(0)
00051 , cb1(0)
00052 , cb2(0)
00053 , dictlist(0)
00054 , dictcombo(0)
00055 , encodingcombo(0)
00056 , clientcombo(0)
00057 {
00058 d = new KSpellConfigPrivate;
00059 setReplaceAllList( _ksc.replaceAllList() );
00060 setNoRootAffix( _ksc.noRootAffix() );
00061 setRunTogether( _ksc.runTogether() );
00062 setDictionary( _ksc.dictionary() );
00063 setDictFromList( _ksc.dictFromList() );
00064
00065 setIgnoreList( _ksc.ignoreList() );
00066 setEncoding( _ksc.encoding() );
00067 setClient( _ksc.client() );
00068 }
00069
00070
00071 KSpellConfig::KSpellConfig( QWidget *parent, const char *name,
00072 KSpellConfig *_ksc, bool addHelpButton )
00073 : QWidget (parent, name), nodialog(false)
00074 , kc(0)
00075 , cb1(0)
00076 , cb2(0)
00077 , dictlist(0)
00078 , dictcombo(0)
00079 , encodingcombo(0)
00080 , clientcombo(0)
00081 {
00082 d = new KSpellConfigPrivate;
00083 kc = KGlobal::config();
00084
00085 if( !_ksc )
00086 {
00087 readGlobalSettings();
00088 }
00089 else
00090 {
00091 setNoRootAffix( _ksc->noRootAffix() );
00092 setRunTogether( _ksc->runTogether() );
00093 setDictionary( _ksc->dictionary() );
00094 setDictFromList( _ksc->dictFromList() );
00095
00096 setIgnoreList( _ksc->ignoreList() );
00097 setEncoding( _ksc->encoding() );
00098 setClient( _ksc->client() );
00099 }
00100
00101 QGridLayout *glay = new QGridLayout( this, 6, 3, 0, KDialog::spacingHint() );
00102 cb1 = new QCheckBox( i18n("Create &root/affix combinations"
00103 " not in dictionary"), this, "NoRootAffix" );
00104 connect( cb1, SIGNAL(toggled(bool)), SLOT(sNoAff(bool)) );
00105 glay->addMultiCellWidget( cb1, 0, 0, 0, 2 );
00106
00107 cb2 = new QCheckBox( i18n("Consider run-together &words"
00108 " as spelling errors"), this, "RunTogether" );
00109 connect( cb2, SIGNAL(toggled(bool)), SLOT(sRunTogether(bool)) );
00110 glay->addMultiCellWidget( cb2, 1, 1, 0, 2 );
00111
00112 dictcombo = new QComboBox( this, "DictFromList" );
00113 dictcombo->setInsertionPolicy( QComboBox::NoInsertion );
00114 connect( dictcombo, SIGNAL (activated(int)),
00115 this, SLOT (sSetDictionary(int)) );
00116 glay->addMultiCellWidget( dictcombo, 2, 2, 1, 2 );
00117
00118 dictlist = new QLabel( dictcombo, i18n("&Dictionary:"), this );
00119 glay->addWidget( dictlist, 2 ,0 );
00120
00121 encodingcombo = new QComboBox( this, "Encoding" );
00122 encodingcombo->insertItem( "US-ASCII" );
00123 encodingcombo->insertItem( "ISO 8859-1" );
00124 encodingcombo->insertItem( "ISO 8859-2" );
00125 encodingcombo->insertItem( "ISO 8859-3" );
00126 encodingcombo->insertItem( "ISO 8859-4" );
00127 encodingcombo->insertItem( "ISO 8859-5" );
00128 encodingcombo->insertItem( "ISO 8859-7" );
00129 encodingcombo->insertItem( "ISO 8859-8" );
00130 encodingcombo->insertItem( "ISO 8859-9" );
00131 encodingcombo->insertItem( "ISO 8859-13" );
00132 encodingcombo->insertItem( "ISO 8859-15" );
00133 encodingcombo->insertItem( "UTF-8" );
00134 encodingcombo->insertItem( "KOI8-R" );
00135 encodingcombo->insertItem( "KOI8-U" );
00136 encodingcombo->insertItem( "CP1251" );
00137 encodingcombo->insertItem( "CP1255" );
00138
00139 connect( encodingcombo, SIGNAL(activated(int)), this,
00140 SLOT(sChangeEncoding(int)) );
00141 glay->addMultiCellWidget( encodingcombo, 3, 3, 1, 2 );
00142
00143 QLabel *tmpQLabel = new QLabel( encodingcombo, i18n("&Encoding:"), this);
00144 glay->addWidget( tmpQLabel, 3, 0 );
00145
00146
00147 clientcombo = new QComboBox( this, "Client" );
00148 clientcombo->insertItem( i18n("International Ispell") );
00149 clientcombo->insertItem( i18n("Aspell") );
00150 clientcombo->insertItem( i18n("Hspell") );
00151 clientcombo->insertItem( i18n("Zemberek") );
00152 connect( clientcombo, SIGNAL (activated(int)), this,
00153 SLOT (sChangeClient(int)) );
00154 glay->addMultiCellWidget( clientcombo, 4, 4, 1, 2 );
00155
00156 tmpQLabel = new QLabel( clientcombo, i18n("&Client:"), this );
00157 glay->addWidget( tmpQLabel, 4, 0 );
00158
00159 if( addHelpButton )
00160 {
00161 QPushButton *pushButton = new KPushButton( KStdGuiItem::help(), this );
00162 connect( pushButton, SIGNAL(clicked()), this, SLOT(sHelp()) );
00163 glay->addWidget(pushButton, 5, 2);
00164 }
00165
00166 fillInDialog();
00167 }
00168
00169 KSpellConfig::~KSpellConfig()
00170 {
00171 delete d;
00172 }
00173
00174
00175 bool
00176 KSpellConfig::dictFromList() const
00177 {
00178 return dictfromlist;
00179 }
00180
00181 bool
00182 KSpellConfig::readGlobalSettings()
00183 {
00184 KConfigGroupSaver cs( kc,"KSpell" );
00185
00186 setNoRootAffix ( kc->readNumEntry("KSpell_NoRootAffix", 0) );
00187 setRunTogether ( kc->readNumEntry("KSpell_RunTogether", 0) );
00188 setDictionary ( kc->readEntry("KSpell_Dictionary") );
00189 setDictFromList ( kc->readNumEntry("KSpell_DictFromList", false) );
00190 setEncoding ( kc->readNumEntry ("KSpell_Encoding", KS_E_ASCII) );
00191 setClient ( kc->readNumEntry ("KSpell_Client", KS_CLIENT_ISPELL) );
00192
00193 return true;
00194 }
00195
00196 bool
00197 KSpellConfig::writeGlobalSettings ()
00198 {
00199 KConfigGroupSaver cs( kc,"KSpell" );
00200
00201 kc->writeEntry ("KSpell_NoRootAffix",(int) noRootAffix(), true, true);
00202 kc->writeEntry ("KSpell_RunTogether", (int) runTogether(), true, true);
00203 kc->writeEntry ("KSpell_Dictionary", dictionary(), true, true);
00204 kc->writeEntry ("KSpell_DictFromList",(int) dictFromList(), true, true);
00205 kc->writeEntry ("KSpell_Encoding", (int) encoding(),
00206 true, true);
00207 kc->writeEntry ("KSpell_Client", client(),
00208 true, true);
00209 kc->sync();
00210
00211 return true;
00212 }
00213
00214 void
00215 KSpellConfig::sChangeEncoding( int i )
00216 {
00217 kdDebug(750) << "KSpellConfig::sChangeEncoding(" << i << ")" << endl;
00218 setEncoding( i );
00219 emit configChanged();
00220 }
00221
00222 void
00223 KSpellConfig::sChangeClient( int i )
00224 {
00225 setClient( i );
00226
00227
00228 if ( dictcombo ) {
00229 if ( iclient == KS_CLIENT_ISPELL )
00230 getAvailDictsIspell();
00231 else if ( iclient == KS_CLIENT_HSPELL )
00232 {
00233 langfnames.clear();
00234 dictcombo->clear();
00235 dictcombo->insertItem( i18n("Hebrew") );
00236 sChangeEncoding( KS_E_CP1255 );
00237 } else if ( iclient == KS_CLIENT_ZEMBEREK ) {
00238 langfnames.clear();
00239 dictcombo->clear();
00240 dictcombo->insertItem( i18n("Turkish") );
00241 sChangeEncoding( KS_E_UTF8 );
00242 }
00243 else
00244 getAvailDictsAspell();
00245 }
00246 emit configChanged();
00247 }
00248
00249
00250 bool
00251 KSpellConfig::interpret( QString &fname, QString &lname,
00252 QString &hname )
00253
00254 {
00255
00256 kdDebug(750) << "KSpellConfig::interpret [" << fname << "]" << endl;
00257
00258 QString dname( fname );
00259
00260 if( dname.endsWith( "+" ) )
00261 dname.remove( dname.length()-1, 1 );
00262
00263 if( dname.endsWith("sml") || dname.endsWith("med") || dname.endsWith("lrg") ||
00264 dname.endsWith("xlg"))
00265 dname.remove(dname.length()-3,3);
00266
00267 QString extension;
00268
00269 int i = dname.find('-');
00270 if ( i != -1 )
00271 {
00272 extension = dname.mid(i+1);
00273 dname.truncate(i);
00274 }
00275
00276
00277
00278 if ( (dname.length() == 2) || (dname.length() == 3) ) {
00279 lname = dname;
00280 hname = KGlobal::locale()->twoAlphaToLanguageName( lname );
00281 }
00282 else if ( (dname.length() == 5) && (dname[2] == '_') ) {
00283 lname = dname.left(2);
00284 hname = KGlobal::locale()->twoAlphaToLanguageName(lname);
00285 QString country = KGlobal::locale()->twoAlphaToCountryName( dname.right(2) );
00286 if ( extension.isEmpty() )
00287 extension = country;
00288 else
00289 extension = country + " - " + extension;
00290 }
00291
00292 else if ( dname=="english" || dname=="american" ||
00293 dname=="british" || dname=="canadian" ) {
00294 lname="en"; hname=i18n("English");
00295 }
00296 else if ( dname == "espa~nol" || dname == "espanol" ) {
00297 lname="es"; hname=i18n("Spanish");
00298 }
00299 else if (dname=="dansk") {
00300 lname="da"; hname=i18n("Danish");
00301 }
00302 else if (dname=="deutsch") {
00303 lname="de"; hname=i18n("German");
00304 }
00305 else if (dname=="german") {
00306 lname="de"; hname=i18n("German (new spelling)");
00307 }
00308 else if (dname=="portuguesb" || dname=="br") {
00309 lname="br"; hname=i18n("Brazilian Portuguese");
00310 }
00311 else if (dname=="portugues") {
00312 lname="pt"; hname=i18n("Portuguese");
00313 }
00314 else if (dname=="esperanto") {
00315 lname="eo"; hname=i18n("Esperanto");
00316 }
00317 else if (dname=="norsk") {
00318 lname="no"; hname=i18n("Norwegian");
00319 }
00320 else if (dname=="polish") {
00321 lname="pl"; hname=i18n("Polish"); sChangeEncoding(KS_E_LATIN2);
00322 }
00323 else if (dname=="russian") {
00324 lname="ru"; hname=i18n("Russian");
00325 }
00326 else if (dname=="slovensko") {
00327 lname="si"; hname=i18n("Slovenian"); sChangeEncoding(KS_E_LATIN2);
00328 }
00329 else if (dname=="slovak"){
00330 lname="sk"; hname=i18n("Slovak"); sChangeEncoding(KS_E_LATIN2);
00331 }
00332 else if (dname=="czech") {
00333 lname="cs"; hname=i18n("Czech"); sChangeEncoding(KS_E_LATIN2);
00334 }
00335 else if (dname=="svenska") {
00336 lname="sv"; hname=i18n("Swedish");
00337 }
00338 else if (dname=="swiss") {
00339 lname="de"; hname=i18n("Swiss German");
00340 }
00341 else if (dname=="ukrainian") {
00342 lname="uk"; hname=i18n("Ukrainian");
00343 }
00344 else if (dname=="lietuviu" || dname=="lithuanian") {
00345 lname="lt"; hname=i18n("Lithuanian");
00346 }
00347 else if (dname=="francais" || dname=="french") {
00348 lname="fr"; hname=i18n("French");
00349 }
00350 else if (dname=="belarusian") {
00351 lname="be"; hname=i18n("Belarusian");
00352 }
00353 else if( dname == "magyar" ) {
00354 lname="hu"; hname=i18n("Hungarian");
00355 sChangeEncoding(KS_E_LATIN2);
00356 }
00357 else {
00358 lname=""; hname=i18n("Unknown ispell dictionary", "Unknown");
00359 }
00360 if (!extension.isEmpty())
00361 {
00362 hname = hname + " (" + extension + ")";
00363 }
00364
00365
00366 if ( ( KGlobal::locale()->language() == QString::fromLatin1("C") &&
00367 lname==QString::fromLatin1("en") ) ||
00368 KGlobal::locale()->language() == lname )
00369 return true;
00370
00371 return false;
00372 }
00373
00374 void
00375 KSpellConfig::fillInDialog ()
00376 {
00377 if ( nodialog )
00378 return;
00379
00380 kdDebug(750) << "KSpellConfig::fillinDialog" << endl;
00381
00382 cb1->setChecked( noRootAffix() );
00383 cb2->setChecked( runTogether() );
00384 encodingcombo->setCurrentItem( encoding() );
00385 clientcombo->setCurrentItem( client() );
00386
00387
00388 if ( iclient == KS_CLIENT_ISPELL )
00389 getAvailDictsIspell();
00390 else if ( iclient == KS_CLIENT_HSPELL )
00391 {
00392 langfnames.clear();
00393 dictcombo->clear();
00394 langfnames.append("");
00395 dictcombo->insertItem( i18n("Hebrew") );
00396 } else if ( iclient == KS_CLIENT_ZEMBEREK ) {
00397 langfnames.clear();
00398 dictcombo->clear();
00399 langfnames.append("");
00400 dictcombo->insertItem( i18n("Turkish") );
00401 }
00402 else
00403 getAvailDictsAspell();
00404
00405
00406 int whichelement=-1;
00407
00408 if ( dictFromList() )
00409 whichelement = langfnames.findIndex(dictionary());
00410
00411 dictcombo->setMinimumWidth (dictcombo->sizeHint().width());
00412
00413 if (dictionary().isEmpty() || whichelement!=-1)
00414 {
00415 setDictFromList (true);
00416 if (whichelement!=-1)
00417 dictcombo->setCurrentItem(whichelement);
00418 }
00419 else
00420
00421 if ( !langfnames.empty() )
00422 {
00423 setDictFromList( true );
00424 dictcombo->setCurrentItem(0);
00425 }
00426 else
00427 setDictFromList( false );
00428
00429 sDictionary( dictFromList() );
00430 sPathDictionary( !dictFromList() );
00431
00432 }
00433
00434
00435 void KSpellConfig::getAvailDictsIspell () {
00436
00437 langfnames.clear();
00438 dictcombo->clear();
00439 langfnames.append("");
00440 dictcombo->insertItem( i18n("ISpell Default") );
00441
00442
00443 QFileInfo dir ("/usr/lib/ispell");
00444 if (!dir.exists() || !dir.isDir())
00445 dir.setFile ("/usr/local/lib/ispell");
00446 if (!dir.exists() || !dir.isDir())
00447 dir.setFile ("/usr/local/share/ispell");
00448 if (!dir.exists() || !dir.isDir())
00449 dir.setFile ("/usr/share/ispell");
00450
00451
00452
00453
00454
00455 if (!dir.exists() || !dir.isDir()) return;
00456
00457 kdDebug(750) << "KSpellConfig::getAvailDictsIspell "
00458 << dir.filePath() << " " << dir.dirPath() << endl;
00459
00460 const QDir thedir (dir.filePath(),"*.hash");
00461 const QStringList entryList = thedir.entryList();
00462
00463 kdDebug(750) << "KSpellConfig" << thedir.path() << "\n" << endl;
00464 kdDebug(750) << "entryList().count()="
00465 << entryList.count() << endl;
00466
00467 QStringList::const_iterator entryListItr = entryList.constBegin();
00468 const QStringList::const_iterator entryListEnd = entryList.constEnd();
00469
00470 for ( ; entryListItr != entryListEnd; ++entryListItr)
00471 {
00472 QString fname, lname, hname;
00473 fname = *entryListItr;
00474
00475
00476 if (fname.endsWith(".hash")) fname.remove (fname.length()-5,5);
00477
00478 if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
00479 {
00480
00481
00482 langfnames.remove ( langfnames.begin() );
00483 langfnames.prepend ( fname );
00484
00485 hname=i18n("default spelling dictionary"
00486 ,"Default - %1 [%2]").arg(hname).arg(fname);
00487
00488 dictcombo->changeItem (hname,0);
00489 }
00490 else
00491 {
00492 langfnames.append (fname);
00493 hname=hname+" ["+fname+"]";
00494
00495 dictcombo->insertItem (hname);
00496 }
00497 }
00498 }
00499
00500 void KSpellConfig::getAvailDictsAspell () {
00501
00502 langfnames.clear();
00503 dictcombo->clear();
00504
00505 langfnames.append("");
00506 dictcombo->insertItem (i18n("ASpell Default"));
00507
00508
00509
00510 QFileInfo dir ( ASPELL_DATADIR );
00511 if (!dir.exists() || !dir.isDir())
00512 dir.setFile ("/usr/lib/aspell");
00513 if (!dir.exists() || !dir.isDir())
00514 dir.setFile ("/usr/lib/aspell-0.60");
00515 if (!dir.exists() || !dir.isDir())
00516 dir.setFile ("/usr/local/lib/aspell");
00517 if (!dir.exists() || !dir.isDir())
00518 dir.setFile ("/usr/share/aspell");
00519 if (!dir.exists() || !dir.isDir())
00520 dir.setFile ("/usr/local/share/aspell");
00521 if (!dir.exists() || !dir.isDir()) return;
00522
00523 kdDebug(750) << "KSpellConfig::getAvailDictsAspell "
00524 << dir.filePath() << " " << dir.dirPath() << endl;
00525
00526 const QDir thedir (dir.filePath(),"*");
00527 const QStringList entryList = thedir.entryList();
00528
00529 kdDebug(750) << "KSpellConfig" << thedir.path() << "\n" << endl;
00530 kdDebug(750) << "entryList().count()="
00531 << entryList.count() << endl;
00532
00533 QStringList::const_iterator entryListItr = entryList.constBegin();
00534 const QStringList::const_iterator entryListEnd = entryList.constEnd();
00535
00536 for ( ; entryListItr != entryListEnd; ++entryListItr)
00537 {
00538 QString fname, lname, hname;
00539 fname = *entryListItr;
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551 if ( !( fname.endsWith(".rws") || fname.endsWith(".multi") ) ) {
00552
00553 continue;
00554 }
00555 if (fname[0] != '.')
00556 {
00557
00558
00559 if (fname.endsWith(".multi")) fname.remove (fname.length()-6,6);
00560
00561 if (fname.endsWith(".rws")) fname.remove (fname.length()-4,4);
00562
00563 if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
00564 {
00565
00566
00567 langfnames.remove ( langfnames.begin() );
00568 langfnames.prepend ( fname );
00569
00570 hname=i18n("default spelling dictionary"
00571 ,"Default - %1").arg(hname);
00572
00573 dictcombo->changeItem (hname,0);
00574 }
00575 else
00576 {
00577 langfnames.append (fname);
00578 dictcombo->insertItem (hname);
00579 }
00580 }
00581 }
00582 }
00583
00584 void
00585 KSpellConfig::fillDicts( QComboBox* box, QStringList* dictionaries )
00586 {
00587 langfnames.clear();
00588 if ( box ) {
00589 if ( iclient == KS_CLIENT_ISPELL ) {
00590 box->clear();
00591 langfnames.append("");
00592 box->insertItem( i18n("ISpell Default") );
00593
00594
00595 QFileInfo dir ("/usr/lib/ispell");
00596 if (!dir.exists() || !dir.isDir())
00597 dir.setFile ("/usr/local/lib/ispell");
00598 if (!dir.exists() || !dir.isDir())
00599 dir.setFile ("/usr/local/share/ispell");
00600 if (!dir.exists() || !dir.isDir())
00601 dir.setFile ("/usr/share/ispell");
00602
00603
00604
00605
00606
00607 if (!dir.exists() || !dir.isDir()) return;
00608
00609 kdDebug(750) << "KSpellConfig::getAvailDictsIspell "
00610 << dir.filePath() << " " << dir.dirPath() << endl;
00611
00612 const QDir thedir (dir.filePath(),"*.hash");
00613 const QStringList entryList = thedir.entryList();
00614
00615 kdDebug(750) << "KSpellConfig" << thedir.path() << "\n" << endl;
00616 kdDebug(750) << "entryList().count()="
00617 << entryList.count() << endl;
00618
00619 QStringList::const_iterator entryListItr = entryList.constBegin();
00620 const QStringList::const_iterator entryListEnd = entryList.constEnd();
00621
00622 for ( ; entryListItr != entryListEnd; ++entryListItr)
00623 {
00624 QString fname, lname, hname;
00625 fname = *entryListItr;
00626
00627
00628 if (fname.endsWith(".hash")) fname.remove (fname.length()-5,5);
00629
00630 if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
00631 {
00632
00633
00634 langfnames.remove ( langfnames.begin() );
00635 langfnames.prepend ( fname );
00636
00637 hname=i18n("default spelling dictionary"
00638 ,"Default - %1 [%2]").arg(hname).arg(fname);
00639
00640 box->changeItem (hname,0);
00641 }
00642 else
00643 {
00644 langfnames.append (fname);
00645 hname=hname+" ["+fname+"]";
00646
00647 box->insertItem (hname);
00648 }
00649 }
00650 } else if ( iclient == KS_CLIENT_HSPELL ) {
00651 box->clear();
00652 box->insertItem( i18n("Hebrew") );
00653 langfnames.append("");
00654 sChangeEncoding( KS_E_CP1255 );
00655 } else if ( iclient == KS_CLIENT_ZEMBEREK ) {
00656 box->clear();
00657 box->insertItem( i18n("Turkish") );
00658 langfnames.append("");
00659 sChangeEncoding( KS_E_UTF8 );
00660 }
00661 else {
00662 box->clear();
00663 langfnames.append("");
00664 box->insertItem (i18n("ASpell Default"));
00665
00666
00667
00668 QFileInfo dir ("/usr/lib/aspell");
00669 if (!dir.exists() || !dir.isDir())
00670 dir.setFile ("/usr/lib/aspell-0.60");
00671 if (!dir.exists() || !dir.isDir())
00672 dir.setFile ("/usr/local/lib/aspell");
00673 if (!dir.exists() || !dir.isDir())
00674 dir.setFile ("/usr/share/aspell");
00675 if (!dir.exists() || !dir.isDir())
00676 dir.setFile ("/usr/local/share/aspell");
00677 if (!dir.exists() || !dir.isDir()) return;
00678
00679 kdDebug(750) << "KSpellConfig::getAvailDictsAspell "
00680 << dir.filePath() << " " << dir.dirPath() << endl;
00681
00682 const QDir thedir (dir.filePath(),"*");
00683 const QStringList entryList = thedir.entryList();
00684
00685 kdDebug(750) << "KSpellConfig" << thedir.path() << "\n" << endl;
00686 kdDebug(750) << "entryList().count()="
00687 << entryList.count() << endl;
00688
00689 QStringList::const_iterator entryListItr = entryList.constBegin();
00690 const QStringList::const_iterator entryListEnd = entryList.constEnd();
00691
00692 for ( ; entryListItr != entryListEnd; ++entryListItr)
00693 {
00694 QString fname, lname, hname;
00695 fname = *entryListItr;
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707 if ( !( fname.endsWith(".rws") || fname.endsWith(".multi") ) ) {
00708
00709 continue;
00710 }
00711 if (fname[0] != '.')
00712 {
00713
00714
00715 if (fname.endsWith(".multi")) fname.remove (fname.length()-6,6);
00716
00717 if (fname.endsWith(".rws")) fname.remove (fname.length()-4,4);
00718
00719 if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
00720 {
00721
00722
00723 langfnames.remove ( langfnames.begin() );
00724 langfnames.prepend ( fname );
00725
00726 hname=i18n("default spelling dictionary"
00727 ,"Default - %1").arg(hname);
00728
00729 box->changeItem (hname,0);
00730 }
00731 else
00732 {
00733 langfnames.append (fname);
00734 box->insertItem (hname);
00735 }
00736 }
00737 }
00738 }
00739 int whichelement = langfnames.findIndex(qsdict);
00740 if ( whichelement >= 0 ) {
00741 box->setCurrentItem( whichelement );
00742 }
00743 if ( dictionaries )
00744 *dictionaries = langfnames;
00745 }
00746 }
00747
00748
00749
00750
00751
00752 void
00753 KSpellConfig::setClient (int c)
00754 {
00755 iclient = c;
00756
00757 if (clientcombo)
00758 clientcombo->setCurrentItem(c);
00759 }
00760
00761 void
00762 KSpellConfig::setNoRootAffix (bool b)
00763 {
00764 bnorootaffix=b;
00765
00766 if(cb1)
00767 cb1->setChecked(b);
00768 }
00769
00770 void
00771 KSpellConfig::setRunTogether(bool b)
00772 {
00773 bruntogether=b;
00774
00775 if(cb2)
00776 cb2->setChecked(b);
00777 }
00778
00779 void
00780 KSpellConfig::setDictionary (const QString s)
00781 {
00782 qsdict=s;
00783
00784 if (qsdict.length()>5)
00785 if ((signed)qsdict.find(".hash")==(signed)qsdict.length()-5)
00786 qsdict.remove (qsdict.length()-5,5);
00787
00788
00789 if(dictcombo)
00790 {
00791 int whichelement=-1;
00792 if (dictFromList())
00793 {
00794 whichelement = langfnames.findIndex(s);
00795
00796 if(whichelement >= 0)
00797 {
00798 dictcombo->setCurrentItem(whichelement);
00799 }
00800 }
00801 }
00802
00803
00804 }
00805
00806 void
00807 KSpellConfig::setDictFromList (bool dfl)
00808 {
00809
00810 dictfromlist=dfl;
00811 }
00812
00813
00814
00815
00816
00817
00818
00819
00820 void
00821 KSpellConfig::setEncoding (int enctype)
00822 {
00823 enc=enctype;
00824
00825 if(encodingcombo)
00826 encodingcombo->setCurrentItem(enctype);
00827 }
00828
00829
00830
00831
00832 int
00833 KSpellConfig::client () const
00834 {
00835 return iclient;
00836 }
00837
00838
00839 bool
00840 KSpellConfig::noRootAffix () const
00841 {
00842 return bnorootaffix;
00843 }
00844
00845 bool
00846 KSpellConfig::runTogether() const
00847 {
00848 return bruntogether;
00849 }
00850
00851 const
00852 QString KSpellConfig::dictionary () const
00853 {
00854 return qsdict;
00855 }
00856
00857
00858
00859
00860
00861
00862
00863
00864 int
00865 KSpellConfig::encoding () const
00866 {
00867 return enc;
00868 }
00869
00870 void
00871 KSpellConfig::sRunTogether(bool)
00872 {
00873 setRunTogether (cb2->isChecked());
00874 emit configChanged();
00875 }
00876
00877 void
00878 KSpellConfig::sNoAff(bool)
00879 {
00880 setNoRootAffix (cb1->isChecked());
00881 emit configChanged();
00882 }
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909 void
00910 KSpellConfig::sSetDictionary (int i)
00911 {
00912 setDictionary (langfnames[i]);
00913 setDictFromList (true);
00914 QTimer::singleShot( 0, this, SIGNAL( configChanged() ) );
00915 }
00916
00917 void
00918 KSpellConfig::sDictionary(bool on)
00919 {
00920 if (on)
00921 {
00922 dictcombo->setEnabled (true);
00923 setDictionary (langfnames[dictcombo->currentItem()] );
00924 setDictFromList (true);
00925 }
00926 else
00927 {
00928 dictcombo->setEnabled (false);
00929 }
00930 emit configChanged();
00931 }
00932
00933 void
00934 KSpellConfig::sPathDictionary(bool on)
00935 {
00936 return;
00937
00938
00939 if (on)
00940 {
00941
00942
00943
00944 setDictFromList (false);
00945 }
00946 else
00947 {
00948
00949
00950 }
00951 emit configChanged();
00952 }
00953
00954
00955 void KSpellConfig::activateHelp( void )
00956 {
00957 sHelp();
00958 }
00959
00960 void KSpellConfig::sHelp( void )
00961 {
00962 kapp->invokeHelp("configuration", "kspell");
00963 }
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977 void
00978 KSpellConfig::operator= (const KSpellConfig &ksc)
00979 {
00980
00981
00982 setNoRootAffix (ksc.noRootAffix());
00983 setRunTogether (ksc.runTogether());
00984 setDictionary (ksc.dictionary());
00985 setDictFromList (ksc.dictFromList());
00986
00987 setEncoding (ksc.encoding());
00988 setClient (ksc.client());
00989
00990 fillInDialog();
00991 }
00992
00993
00994 void
00995 KSpellConfig::setIgnoreList (QStringList _ignorelist)
00996 {
00997 ignorelist=_ignorelist;
00998 }
00999
01000 QStringList
01001 KSpellConfig::ignoreList () const
01002 {
01003 return ignorelist;
01004 }
01005
01006
01007 void
01008 KSpellConfig::setReplaceAllList (QStringList _replacelist)
01009 {
01010 d->replacelist=_replacelist;
01011 }
01012
01013 QStringList
01014 KSpellConfig::replaceAllList() const
01015 {
01016 return d->replacelist;
01017 }
01018
01019 #include "ksconfig.moc"
01020
01021
01022