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