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_UTF8) );
00191 setClient ( kc->readNumEntry ("KSpell_Client", KS_CLIENT_ASPELL));
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" KDELIBSUFF "/ispell");
00444 if (!dir.exists() || !dir.isDir())
00445 dir.setFile ("/usr/local/lib" KDELIBSUFF "/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" KDELIBSUFF "/aspell-0.60");
00513 if (!dir.exists() || !dir.isDir())
00514 dir.setFile ("/usr/local/lib" KDELIBSUFF "/aspell");
00515 if (!dir.exists() || !dir.isDir())
00516 dir.setFile ("/usr/share/aspell");
00517 if (!dir.exists() || !dir.isDir())
00518 dir.setFile ("/usr/local/share/aspell");
00519 if (!dir.exists() || !dir.isDir()) return;
00520
00521 kdDebug(750) << "KSpellConfig::getAvailDictsAspell "
00522 << dir.filePath() << " " << dir.dirPath() << endl;
00523
00524 const QDir thedir (dir.filePath(),"*");
00525 const QStringList entryList = thedir.entryList();
00526
00527 kdDebug(750) << "KSpellConfig" << thedir.path() << "\n" << endl;
00528 kdDebug(750) << "entryList().count()="
00529 << entryList.count() << endl;
00530
00531 QStringList::const_iterator entryListItr = entryList.constBegin();
00532 const QStringList::const_iterator entryListEnd = entryList.constEnd();
00533
00534 for ( ; entryListItr != entryListEnd; ++entryListItr)
00535 {
00536 QString fname, lname, hname;
00537 fname = *entryListItr;
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549 if ( !( fname.endsWith(".rws") || fname.endsWith(".multi") ) ) {
00550
00551 continue;
00552 }
00553 if (fname[0] != '.')
00554 {
00555
00556
00557 if (fname.endsWith(".multi")) fname.remove (fname.length()-6,6);
00558
00559 if (fname.endsWith(".rws")) fname.remove (fname.length()-4,4);
00560
00561 if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
00562 {
00563
00564
00565 langfnames.remove ( langfnames.begin() );
00566 langfnames.prepend ( fname );
00567
00568 hname=i18n("default spelling dictionary"
00569 ,"Default - %1").arg(hname);
00570
00571 dictcombo->changeItem (hname,0);
00572 }
00573 else
00574 {
00575 langfnames.append (fname);
00576 dictcombo->insertItem (hname);
00577 }
00578 }
00579 }
00580 }
00581
00582 void
00583 KSpellConfig::fillDicts( QComboBox* box, QStringList* dictionaries )
00584 {
00585 langfnames.clear();
00586 if ( box ) {
00587 if ( iclient == KS_CLIENT_ISPELL ) {
00588 box->clear();
00589 langfnames.append("");
00590 box->insertItem( i18n("ISpell Default") );
00591
00592
00593 QFileInfo dir ("/usr/lib/ispell");
00594 if (!dir.exists() || !dir.isDir())
00595 dir.setFile ("/usr/local/lib/ispell");
00596 if (!dir.exists() || !dir.isDir())
00597 dir.setFile ("/usr/local/share/ispell");
00598 if (!dir.exists() || !dir.isDir())
00599 dir.setFile ("/usr/share/ispell");
00600
00601
00602
00603
00604
00605 if (!dir.exists() || !dir.isDir()) return;
00606
00607 kdDebug(750) << "KSpellConfig::getAvailDictsIspell "
00608 << dir.filePath() << " " << dir.dirPath() << endl;
00609
00610 const QDir thedir (dir.filePath(),"*.hash");
00611 const QStringList entryList = thedir.entryList();
00612
00613 kdDebug(750) << "KSpellConfig" << thedir.path() << "\n" << endl;
00614 kdDebug(750) << "entryList().count()="
00615 << entryList.count() << endl;
00616
00617 QStringList::const_iterator entryListItr = entryList.constBegin();
00618 const QStringList::const_iterator entryListEnd = entryList.constEnd();
00619
00620 for ( ; entryListItr != entryListEnd; ++entryListItr)
00621 {
00622 QString fname, lname, hname;
00623 fname = *entryListItr;
00624
00625
00626 if (fname.endsWith(".hash")) fname.remove (fname.length()-5,5);
00627
00628 if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
00629 {
00630
00631
00632 langfnames.remove ( langfnames.begin() );
00633 langfnames.prepend ( fname );
00634
00635 hname=i18n("default spelling dictionary"
00636 ,"Default - %1 [%2]").arg(hname).arg(fname);
00637
00638 box->changeItem (hname,0);
00639 }
00640 else
00641 {
00642 langfnames.append (fname);
00643 hname=hname+" ["+fname+"]";
00644
00645 box->insertItem (hname);
00646 }
00647 }
00648 } else if ( iclient == KS_CLIENT_HSPELL ) {
00649 box->clear();
00650 box->insertItem( i18n("Hebrew") );
00651 langfnames.append("");
00652 sChangeEncoding( KS_E_CP1255 );
00653 } else if ( iclient == KS_CLIENT_ZEMBEREK ) {
00654 box->clear();
00655 box->insertItem( i18n("Turkish") );
00656 langfnames.append("");
00657 sChangeEncoding( KS_E_UTF8 );
00658 }
00659 else {
00660 box->clear();
00661 langfnames.append("");
00662 box->insertItem (i18n("ASpell Default"));
00663
00664
00665
00666 QFileInfo dir ("/usr/lib" KDELIBSUFF "/aspell");
00667 if (!dir.exists() || !dir.isDir())
00668 dir.setFile ("/usr/lib" KDELIBSUFF "/aspell-0.60");
00669 if (!dir.exists() || !dir.isDir())
00670 dir.setFile ("/usr/local/lib" KDELIBSUFF "/aspell");
00671 if (!dir.exists() || !dir.isDir())
00672 dir.setFile ("/usr/share/aspell");
00673 if (!dir.exists() || !dir.isDir())
00674 dir.setFile ("/usr/local/share/aspell");
00675 if (!dir.exists() || !dir.isDir()) return;
00676
00677 kdDebug(750) << "KSpellConfig::getAvailDictsAspell "
00678 << dir.filePath() << " " << dir.dirPath() << endl;
00679
00680 const QDir thedir (dir.filePath(),"*");
00681 const QStringList entryList = thedir.entryList();
00682
00683 kdDebug(750) << "KSpellConfig" << thedir.path() << "\n" << endl;
00684 kdDebug(750) << "entryList().count()="
00685 << entryList.count() << endl;
00686
00687 QStringList::const_iterator entryListItr = entryList.constBegin();
00688 const QStringList::const_iterator entryListEnd = entryList.constEnd();
00689
00690 for ( ; entryListItr != entryListEnd; ++entryListItr)
00691 {
00692 QString fname, lname, hname;
00693 fname = *entryListItr;
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705 if ( !( fname.endsWith(".rws") || fname.endsWith(".multi") ) ) {
00706
00707 continue;
00708 }
00709 if (fname[0] != '.')
00710 {
00711
00712
00713 if (fname.endsWith(".multi")) fname.remove (fname.length()-6,6);
00714
00715 if (fname.endsWith(".rws")) fname.remove (fname.length()-4,4);
00716
00717 if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
00718 {
00719
00720
00721 langfnames.remove ( langfnames.begin() );
00722 langfnames.prepend ( fname );
00723
00724 hname=i18n("default spelling dictionary"
00725 ,"Default - %1").arg(hname);
00726
00727 box->changeItem (hname,0);
00728 }
00729 else
00730 {
00731 langfnames.append (fname);
00732 box->insertItem (hname);
00733 }
00734 }
00735 }
00736 }
00737 int whichelement = langfnames.findIndex(qsdict);
00738 if ( whichelement >= 0 ) {
00739 box->setCurrentItem( whichelement );
00740 }
00741 if ( dictionaries )
00742 *dictionaries = langfnames;
00743 }
00744 }
00745
00746
00747
00748
00749
00750 void
00751 KSpellConfig::setClient (int c)
00752 {
00753 iclient = c;
00754
00755 if (clientcombo)
00756 clientcombo->setCurrentItem(c);
00757 }
00758
00759 void
00760 KSpellConfig::setNoRootAffix (bool b)
00761 {
00762 bnorootaffix=b;
00763
00764 if(cb1)
00765 cb1->setChecked(b);
00766 }
00767
00768 void
00769 KSpellConfig::setRunTogether(bool b)
00770 {
00771 bruntogether=b;
00772
00773 if(cb2)
00774 cb2->setChecked(b);
00775 }
00776
00777 void
00778 KSpellConfig::setDictionary (const QString s)
00779 {
00780 qsdict=s;
00781
00782 if (qsdict.length()>5)
00783 if ((signed)qsdict.find(".hash")==(signed)qsdict.length()-5)
00784 qsdict.remove (qsdict.length()-5,5);
00785
00786
00787 if(dictcombo)
00788 {
00789 int whichelement=-1;
00790 if (dictFromList())
00791 {
00792 whichelement = langfnames.findIndex(s);
00793
00794 if(whichelement >= 0)
00795 {
00796 dictcombo->setCurrentItem(whichelement);
00797 }
00798 }
00799 }
00800
00801
00802 }
00803
00804 void
00805 KSpellConfig::setDictFromList (bool dfl)
00806 {
00807
00808 dictfromlist=dfl;
00809 }
00810
00811
00812
00813
00814
00815
00816
00817
00818 void
00819 KSpellConfig::setEncoding (int enctype)
00820 {
00821 enc=enctype;
00822
00823 if(encodingcombo)
00824 encodingcombo->setCurrentItem(enctype);
00825 }
00826
00827
00828
00829
00830 int
00831 KSpellConfig::client () const
00832 {
00833 return iclient;
00834 }
00835
00836
00837 bool
00838 KSpellConfig::noRootAffix () const
00839 {
00840 return bnorootaffix;
00841 }
00842
00843 bool
00844 KSpellConfig::runTogether() const
00845 {
00846 return bruntogether;
00847 }
00848
00849 const
00850 QString KSpellConfig::dictionary () const
00851 {
00852 return qsdict;
00853 }
00854
00855
00856
00857
00858
00859
00860
00861
00862 int
00863 KSpellConfig::encoding () const
00864 {
00865 return enc;
00866 }
00867
00868 void
00869 KSpellConfig::sRunTogether(bool)
00870 {
00871 setRunTogether (cb2->isChecked());
00872 emit configChanged();
00873 }
00874
00875 void
00876 KSpellConfig::sNoAff(bool)
00877 {
00878 setNoRootAffix (cb1->isChecked());
00879 emit configChanged();
00880 }
00881
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 void
00908 KSpellConfig::sSetDictionary (int i)
00909 {
00910 setDictionary (langfnames[i]);
00911 setDictFromList (true);
00912 QTimer::singleShot( 0, this, SIGNAL( configChanged() ) );
00913 }
00914
00915 void
00916 KSpellConfig::sDictionary(bool on)
00917 {
00918 if (on)
00919 {
00920 dictcombo->setEnabled (true);
00921 setDictionary (langfnames[dictcombo->currentItem()] );
00922 setDictFromList (true);
00923 }
00924 else
00925 {
00926 dictcombo->setEnabled (false);
00927 }
00928 emit configChanged();
00929 }
00930
00931 void
00932 KSpellConfig::sPathDictionary(bool on)
00933 {
00934 return;
00935
00936
00937 if (on)
00938 {
00939
00940
00941
00942 setDictFromList (false);
00943 }
00944 else
00945 {
00946
00947
00948 }
00949 emit configChanged();
00950 }
00951
00952
00953 void KSpellConfig::activateHelp( void )
00954 {
00955 sHelp();
00956 }
00957
00958 void KSpellConfig::sHelp( void )
00959 {
00960 kapp->invokeHelp("configuration", "kspell");
00961 }
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975 void
00976 KSpellConfig::operator= (const KSpellConfig &ksc)
00977 {
00978
00979
00980 setNoRootAffix (ksc.noRootAffix());
00981 setRunTogether (ksc.runTogether());
00982 setDictionary (ksc.dictionary());
00983 setDictFromList (ksc.dictFromList());
00984
00985 setEncoding (ksc.encoding());
00986 setClient (ksc.client());
00987
00988 fillInDialog();
00989 }
00990
00991
00992 void
00993 KSpellConfig::setIgnoreList (QStringList _ignorelist)
00994 {
00995 ignorelist=_ignorelist;
00996 }
00997
00998 QStringList
00999 KSpellConfig::ignoreList () const
01000 {
01001 return ignorelist;
01002 }
01003
01004
01005 void
01006 KSpellConfig::setReplaceAllList (QStringList _replacelist)
01007 {
01008 d->replacelist=_replacelist;
01009 }
01010
01011 QStringList
01012 KSpellConfig::replaceAllList() const
01013 {
01014 return d->replacelist;
01015 }
01016
01017 #include "ksconfig.moc"
01018
01019
01020