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