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