c2b7e80
diff -ur kdelibs-4.0.0/kde3support/kdeui/k3sconfig.cpp kdelibs-4.0.0-k3spell-hunspell/kde3support/kdeui/k3sconfig.cpp
c2b7e80
--- kdelibs-4.0.0/kde3support/kdeui/k3sconfig.cpp	2008-01-05 00:59:41.000000000 +0100
c2b7e80
+++ kdelibs-4.0.0-k3spell-hunspell/kde3support/kdeui/k3sconfig.cpp	2008-01-19 16:47:04.000000000 +0100
c2b7e80
@@ -1,6 +1,7 @@
c2b7e80
 /* This file is part of the KDE libraries
c2b7e80
    Copyright (C) 1997 David Sweet <dsweet@kde.org>
c2b7e80
    Copyright (C) 2000-2001 Wolfram Diestel <wolfram@steloj.de>
c2b7e80
+   Copyright (C) 2007-2008 Kevin Kofler <Kevin@tigcc.ticalc.org>
c2b7e80
 
c2b7e80
    This library is free software; you can redistribute it and/or
c2b7e80
    modify it under the terms of the GNU Library General Public
c2b7e80
@@ -167,6 +168,7 @@
c2b7e80
   clientcombo->addItem( i18nc("@item:inlistbox Spell checker", "<application>Aspell</application>") );
c2b7e80
   clientcombo->addItem( i18nc("@item:inlistbox Spell checker", "<application>Hspell</application>") );
c2b7e80
   clientcombo->addItem( i18nc("@item:inlistbox Spell checker", "<application>Zemberek</application>") );
c2b7e80
+  clientcombo->addItem( i18nc("@item:inlistbox Spell checker", "<application>Hunspell</application>") );
c2b7e80
   connect( clientcombo, SIGNAL (activated(int)), this,
c2b7e80
 	   SLOT (sChangeClient(int)) );
c2b7e80
   glay->addWidget( clientcombo, 5, 1, 1, 2 );
c2b7e80
@@ -261,8 +263,10 @@
c2b7e80
       dictcombo->addItem( i18nc("@item Spelling dictionary", "Turkish") );
c2b7e80
       sChangeEncoding( KS_E_UTF8 );
c2b7e80
     }
c2b7e80
-    else
c2b7e80
+    else if ( iclient == KS_CLIENT_ASPELL )
c2b7e80
       getAvailDictsAspell();
c2b7e80
+    else
c2b7e80
+      getAvailDictsHunspell();
c2b7e80
   }
c2b7e80
   emit configChanged();
c2b7e80
 }
c2b7e80
@@ -420,8 +424,10 @@
c2b7e80
     langfnames.append("");
c2b7e80
     dictcombo->addItem( i18nc("@item Spelling dictionary", "Turkish") );
c2b7e80
   }
c2b7e80
-  else
c2b7e80
+  else if ( iclient == KS_CLIENT_ASPELL )
c2b7e80
     getAvailDictsAspell();
c2b7e80
+  else
c2b7e80
+    getAvailDictsHunspell();
c2b7e80
 
c2b7e80
   // select the used dictionary in the list
c2b7e80
   int whichelement=-1;
c2b7e80
@@ -606,6 +612,63 @@
c2b7e80
   }
c2b7e80
 }
c2b7e80
 
c2b7e80
+void K3SpellConfig::getAvailDictsHunspell () {
c2b7e80
+
c2b7e80
+  langfnames.clear();
c2b7e80
+  dictcombo->clear();
c2b7e80
+  langfnames.append(""); // Default
c2b7e80
+  dictcombo->addItem( i18nc("@item Spelling dictionary",
c2b7e80
+                            "<application>Hunspell</application> Default") );
c2b7e80
+
c2b7e80
+  // dictionary path
c2b7e80
+  QFileInfo dir ("/usr/share/myspell");
c2b7e80
+  if (!dir.exists() || !dir.isDir())
c2b7e80
+    dir.setFile ("/usr/share/hunspell");
c2b7e80
+  if (!dir.exists() || !dir.isDir()) return;
c2b7e80
+
c2b7e80
+  kDebug(750) << "K3SpellConfig::getAvailDictsHunspell "
c2b7e80
+	       << dir.filePath() << " " << dir.path() << endl;
c2b7e80
+
c2b7e80
+  const QDir thedir (dir.filePath(),"*.dic");
c2b7e80
+  const QStringList entryList = thedir.entryList();
c2b7e80
+
c2b7e80
+  kDebug(750) << "K3SpellConfig" << thedir.path() << "\n";
c2b7e80
+  kDebug(750) << "entryList().count()="
c2b7e80
+	       << entryList.count() << endl;
c2b7e80
+
c2b7e80
+  QStringList::const_iterator entryListItr = entryList.constBegin();
c2b7e80
+  const QStringList::const_iterator entryListEnd = entryList.constEnd();
c2b7e80
+
c2b7e80
+  for ( ; entryListItr != entryListEnd; ++entryListItr)
c2b7e80
+  {
c2b7e80
+    QString fname, lname, hname;
c2b7e80
+    fname = *entryListItr;
c2b7e80
+
c2b7e80
+    // remove .dic
c2b7e80
+    if (fname.endsWith(".dic")) fname.remove (fname.length()-4,4);
c2b7e80
+
c2b7e80
+    if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
c2b7e80
+    { // This one is the KDE default language
c2b7e80
+      // so place it first in the lists (overwrite "Default")
c2b7e80
+
c2b7e80
+      langfnames.removeFirst();
c2b7e80
+      langfnames.prepend ( fname );
c2b7e80
+
c2b7e80
+      hname=i18nc("@item Spelling dictionary: %1 dictionary name, %2 file name",
c2b7e80
+                  "Default - %1 [%2]", hname, fname);
c2b7e80
+
c2b7e80
+      dictcombo->setItemText (0,hname);
c2b7e80
+    }
c2b7e80
+    else
c2b7e80
+    {
c2b7e80
+      langfnames.append (fname);
c2b7e80
+      hname=hname+" ["+fname+']';
c2b7e80
+
c2b7e80
+      dictcombo->addItem (hname);
c2b7e80
+    }
c2b7e80
+  }
c2b7e80
+}
c2b7e80
+
c2b7e80
 void
c2b7e80
 K3SpellConfig::fillDicts( QComboBox* box, QStringList* dictionaries )
c2b7e80
 {
c2b7e80
@@ -685,8 +748,7 @@
c2b7e80
       box->addItem( i18nc("@item Spelling dictionary", "Turkish") );
c2b7e80
       langfnames.append("");
c2b7e80
       sChangeEncoding( KS_E_UTF8 );
c2b7e80
-    }
c2b7e80
-    else {
c2b7e80
+    } else if ( iclient == KS_CLIENT_ASPELL ) {
c2b7e80
       box->clear();
c2b7e80
       langfnames.append(""); // Default
c2b7e80
       box->addItem (i18nc("@item Spelling dictionary",
c2b7e80
@@ -766,6 +828,59 @@
c2b7e80
           }
c2b7e80
         }
c2b7e80
       }
c2b7e80
+    } else {
c2b7e80
+      box->clear();
c2b7e80
+      langfnames.append(""); // Default
c2b7e80
+      box->addItem( i18nc("@item Spelling dictionary",
c2b7e80
+                          "<application>Hunspell</application> Default") );
c2b7e80
+
c2b7e80
+      // dictionary path
c2b7e80
+      QFileInfo dir ("/usr/share/myspell");
c2b7e80
+      if (!dir.exists() || !dir.isDir())
c2b7e80
+        dir.setFile ("/usr/share/hunspell");
c2b7e80
+      if (!dir.exists() || !dir.isDir()) return;
c2b7e80
+
c2b7e80
+      kDebug(750) << "K3SpellConfig::getAvailDictsHunspell "
c2b7e80
+                   << dir.filePath() << " " << dir.path() << endl;
c2b7e80
+
c2b7e80
+      const QDir thedir (dir.filePath(),"*.dic");
c2b7e80
+      const QStringList entryList = thedir.entryList();
c2b7e80
+
c2b7e80
+      kDebug(750) << "K3SpellConfig" << thedir.path() << "\n";
c2b7e80
+      kDebug(750) << "entryList().count()="
c2b7e80
+                   << entryList.count() << endl;
c2b7e80
+
c2b7e80
+      QStringList::const_iterator entryListItr = entryList.constBegin();
c2b7e80
+      const QStringList::const_iterator entryListEnd = entryList.constEnd();
c2b7e80
+
c2b7e80
+      for ( ; entryListItr != entryListEnd; ++entryListItr)
c2b7e80
+      {
c2b7e80
+        QString fname, lname, hname;
c2b7e80
+        fname = *entryListItr;
c2b7e80
+
c2b7e80
+        // remove .dic
c2b7e80
+        if (fname.endsWith(".dic")) fname.remove (fname.length()-4,4);
c2b7e80
+
c2b7e80
+        if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
c2b7e80
+        { // This one is the KDE default language
c2b7e80
+          // so place it first in the lists (overwrite "Default")
c2b7e80
+
c2b7e80
+          langfnames.erase ( langfnames.begin() );
c2b7e80
+          langfnames.prepend ( fname );
c2b7e80
+
c2b7e80
+          hname=i18nc("@item Spelling dictionary: %1 dictionary name, %2 file name",
c2b7e80
+                      "Default - %1 [%2]", hname, fname);
c2b7e80
+
c2b7e80
+          box->setItemText (0,hname);
c2b7e80
+        }
c2b7e80
+        else
c2b7e80
+        {
c2b7e80
+          langfnames.append (fname);
c2b7e80
+          hname=hname+" ["+fname+']';
c2b7e80
+
c2b7e80
+          box->addItem (hname);
c2b7e80
+        }
c2b7e80
+      }
c2b7e80
     }
c2b7e80
     int whichelement = langfnames.indexOf(qsdict);
c2b7e80
     if ( whichelement >= 0 ) {
c2b7e80
diff -ur kdelibs-4.0.0/kde3support/kdeui/k3sconfig.h kdelibs-4.0.0-k3spell-hunspell/kde3support/kdeui/k3sconfig.h
c2b7e80
--- kdelibs-4.0.0/kde3support/kdeui/k3sconfig.h	2008-01-05 00:59:41.000000000 +0100
c2b7e80
+++ kdelibs-4.0.0-k3spell-hunspell/kde3support/kdeui/k3sconfig.h	2008-01-19 16:25:43.000000000 +0100
c2b7e80
@@ -1,5 +1,6 @@
c2b7e80
 /* This file is part of the KDE libraries
c2b7e80
    Copyright (C) 1997 David Sweet <dsweet@kde.org>
c2b7e80
+   Copyright (C) 2007-2008 Kevin Kofler <Kevin@tigcc.ticalc.org>
c2b7e80
 
c2b7e80
    This library is free software; you can redistribute it and/or
c2b7e80
    modify it under the terms of the GNU Library General Public
c2b7e80
@@ -60,7 +61,8 @@
c2b7e80
   KS_CLIENT_ISPELL=0,
c2b7e80
   KS_CLIENT_ASPELL=1,
c2b7e80
   KS_CLIENT_HSPELL=2,
c2b7e80
-  KS_CLIENT_ZEMBEREK=3
c2b7e80
+  KS_CLIENT_ZEMBEREK=3,
c2b7e80
+  KS_CLIENT_HUNSPELL=4
c2b7e80
 };
c2b7e80
 
c2b7e80
 /**
c2b7e80
@@ -287,6 +289,7 @@
c2b7e80
     K3SpellConfigPrivate *const d;
c2b7e80
     void getAvailDictsIspell();
c2b7e80
     void getAvailDictsAspell();
c2b7e80
+    void getAvailDictsHunspell();
c2b7e80
 };
c2b7e80
 
c2b7e80
 #endif // KDELIBS_KSCONFIG_H
c2b7e80
diff -ur kdelibs-4.0.0/kde3support/kdeui/k3spell.cpp kdelibs-4.0.0-k3spell-hunspell/kde3support/kdeui/k3spell.cpp
c2b7e80
--- kdelibs-4.0.0/kde3support/kdeui/k3spell.cpp	2008-01-05 00:59:41.000000000 +0100
c2b7e80
+++ kdelibs-4.0.0-k3spell-hunspell/kde3support/kdeui/k3spell.cpp	2008-01-19 16:44:00.000000000 +0100
c2b7e80
@@ -2,6 +2,7 @@
c2b7e80
    Copyright (C) 1997 David Sweet <dsweet@kde.org>
c2b7e80
    Copyright (C) 2000-2001 Wolfram Diestel <wolfram@steloj.de>
c2b7e80
    Copyright (C) 2003 Zack Rusin <zack@kde.org>
c2b7e80
+   Copyright (C) 2007-2008 Kevin Kofler <Kevin@tigcc.ticalc.org>
c2b7e80
 
c2b7e80
    This library is free software; you can redistribute it and/or
c2b7e80
    modify it under the terms of the GNU Library General Public
c2b7e80
@@ -218,9 +219,14 @@
c2b7e80
     *proc << "zpspell";
c2b7e80
     kDebug(750) << "Using zemberek(zpspell)";
c2b7e80
     break;
c2b7e80
+  case KS_CLIENT_HUNSPELL:
c2b7e80
+    *proc << "hunspell";
c2b7e80
+    kDebug(750) << "Using hunspell";
c2b7e80
+    break;
c2b7e80
   }
c2b7e80
 
c2b7e80
-  if ( ksconfig->client() == KS_CLIENT_ISPELL || ksconfig->client() == KS_CLIENT_ASPELL )
c2b7e80
+  // Hunspell doesn't need all of these options, but it'll ignore those it doesn't understand.
c2b7e80
+  if ( ksconfig->client() == KS_CLIENT_ISPELL || ksconfig->client() == KS_CLIENT_ASPELL || ksconfig->client() == KS_CLIENT_HUNSPELL )
c2b7e80
   {
c2b7e80
     *proc << "-a" << "-S";
c2b7e80
 
c2b7e80
@@ -238,8 +244,8 @@
c2b7e80
       *proc << "-t";
c2b7e80
       break;
c2b7e80
     case Nroff:
c2b7e80
-      //only ispell supports
c2b7e80
-      if ( ksconfig->client() == KS_CLIENT_ISPELL )
c2b7e80
+      //only ispell and hunspell support
c2b7e80
+      if ( ksconfig->client() == KS_CLIENT_ISPELL || ksconfig->client() == KS_CLIENT_HUNSPELL )
c2b7e80
         *proc << "-n";
c2b7e80
       break;
c2b7e80
     case Text:
c2b7e80
@@ -276,7 +282,60 @@
c2b7e80
   // option, so k3spell tries again without it.  That's why as 'ps -ax'
c2b7e80
   // shows "ispell -a -S ..." withou the "-Tlatin2" option.
c2b7e80
 
c2b7e80
-    if ( trystart<1 ) {
c2b7e80
+    if ( ksconfig->client() == KS_CLIENT_HUNSPELL && trystart<1 ) {
c2b7e80
+      // Note: This sets I/O encoding. Hunspell correctly handles dictionary encoding != I/O encoding.
c2b7e80
+      // It will be faster if the I/O encoding matches the dictionary encoding, but using UTF-8 is always safe.
c2b7e80
+      switch ( ksconfig->encoding() )
c2b7e80
+      {
c2b7e80
+      case KS_E_LATIN1:
c2b7e80
+	*proc << "-i" << "ISO-8859-1";
c2b7e80
+	break;
c2b7e80
+      case KS_E_LATIN2:
c2b7e80
+	*proc << "-i" << "ISO-8859-2";
c2b7e80
+	break;
c2b7e80
+      case KS_E_LATIN3:
c2b7e80
+	*proc << "-i" << "ISO-8859-3";
c2b7e80
+        break;
c2b7e80
+      case KS_E_LATIN4:
c2b7e80
+	*proc << "-i" << "ISO-8859-4";
c2b7e80
+        break;
c2b7e80
+      case KS_E_LATIN5:
c2b7e80
+	*proc << "-i" << "ISO-8859-5";
c2b7e80
+        break;
c2b7e80
+      case KS_E_LATIN7:
c2b7e80
+	*proc << "-i" << "ISO-8859-7";
c2b7e80
+        break;
c2b7e80
+      case KS_E_LATIN8:
c2b7e80
+	*proc << "-i" << "ISO-8859-8";
c2b7e80
+        break;
c2b7e80
+      case KS_E_LATIN9:
c2b7e80
+	*proc << "-i" << "ISO-8859-9";
c2b7e80
+        break;
c2b7e80
+      case KS_E_LATIN13:
c2b7e80
+	*proc << "-i" << "ISO-8859-13";
c2b7e80
+        break;
c2b7e80
+      case KS_E_LATIN15:
c2b7e80
+	*proc << "-i" << "ISO-8859-15";
c2b7e80
+        break;
c2b7e80
+      case KS_E_UTF8:
c2b7e80
+	*proc << "-i" << "UTF-8";
c2b7e80
+        break;
c2b7e80
+      case KS_E_KOI8R:
c2b7e80
+	*proc << "-i" << "KOI8-R";
c2b7e80
+        break;
c2b7e80
+      case KS_E_KOI8U:
c2b7e80
+	*proc << "-i" << "KOI8-U";
c2b7e80
+        break;
c2b7e80
+      case KS_E_CP1251:
c2b7e80
+	*proc << "-i" << "CP1251";
c2b7e80
+        break;
c2b7e80
+      case KS_E_CP1255:
c2b7e80
+	*proc << "-i" << "CP1255";
c2b7e80
+        break;
c2b7e80
+      default:
c2b7e80
+        break;
c2b7e80
+      }
c2b7e80
+    } else if ( trystart<1 ) {
c2b7e80
       switch ( ksconfig->encoding() )
c2b7e80
       {
c2b7e80
       case KS_E_LATIN1: