|
|
6bed19c |
diff -ur kdelibs-3.5.8/kdeui/ksconfig.cpp kdelibs-3.5.8-kspell-hunspell/kdeui/ksconfig.cpp
|
|
|
6bed19c |
--- kdelibs-3.5.8/kdeui/ksconfig.cpp 2007-10-08 11:52:12.000000000 +0200
|
|
|
6bed19c |
+++ kdelibs-3.5.8-kspell-hunspell/kdeui/ksconfig.cpp 2007-12-22 01:45:47.000000000 +0100
|
|
|
6bed19c |
@@ -1,6 +1,7 @@
|
|
|
6bed19c |
/* This file is part of the KDE libraries
|
|
|
6bed19c |
Copyright (C) 1997 David Sweet <dsweet@kde.org>
|
|
|
6bed19c |
Copyright (C) 2000-2001 Wolfram Diestel <wolfram@steloj.de>
|
|
|
6bed19c |
+ Copyright (C) 2007 Kevin Kofler <Kevin@tigcc.ticalc.org>
|
|
|
6bed19c |
|
|
|
6bed19c |
This library is free software; you can redistribute it and/or
|
|
|
6bed19c |
modify it under the terms of the GNU Library General Public
|
|
|
6bed19c |
@@ -149,6 +150,7 @@
|
|
|
6bed19c |
clientcombo->insertItem( i18n("Aspell") );
|
|
|
6bed19c |
clientcombo->insertItem( i18n("Hspell") );
|
|
|
6bed19c |
clientcombo->insertItem( i18n("Zemberek") );
|
|
|
6bed19c |
+ clientcombo->insertItem( i18n("Hunspell") );
|
|
|
6bed19c |
connect( clientcombo, SIGNAL (activated(int)), this,
|
|
|
6bed19c |
SLOT (sChangeClient(int)) );
|
|
|
6bed19c |
glay->addMultiCellWidget( clientcombo, 4, 4, 1, 2 );
|
|
|
6bed19c |
@@ -240,8 +242,10 @@
|
|
|
6bed19c |
dictcombo->insertItem( i18n("Turkish") );
|
|
|
6bed19c |
sChangeEncoding( KS_E_UTF8 );
|
|
|
6bed19c |
}
|
|
|
6bed19c |
- else
|
|
|
6bed19c |
+ else if ( iclient == KS_CLIENT_ASPELL )
|
|
|
6bed19c |
getAvailDictsAspell();
|
|
|
6bed19c |
+ else
|
|
|
6bed19c |
+ getAvailDictsHunspell();
|
|
|
6bed19c |
}
|
|
|
6bed19c |
emit configChanged();
|
|
|
6bed19c |
}
|
|
|
6bed19c |
@@ -399,8 +403,10 @@
|
|
|
6bed19c |
langfnames.append("");
|
|
|
6bed19c |
dictcombo->insertItem( i18n("Turkish") );
|
|
|
6bed19c |
}
|
|
|
6bed19c |
- else
|
|
|
6bed19c |
+ else if ( iclient == KS_CLIENT_ASPELL )
|
|
|
6bed19c |
getAvailDictsAspell();
|
|
|
6bed19c |
+ else
|
|
|
6bed19c |
+ getAvailDictsHunspell();
|
|
|
6bed19c |
|
|
|
6bed19c |
// select the used dictionary in the list
|
|
|
6bed19c |
int whichelement=-1;
|
|
|
6bed19c |
@@ -583,6 +589,62 @@
|
|
|
6bed19c |
}
|
|
|
6bed19c |
}
|
|
|
6bed19c |
|
|
|
6bed19c |
+void KSpellConfig::getAvailDictsHunspell () {
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ langfnames.clear();
|
|
|
6bed19c |
+ dictcombo->clear();
|
|
|
6bed19c |
+ langfnames.append(""); // Default
|
|
|
6bed19c |
+ dictcombo->insertItem( i18n("Hunspell Default") );
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ // dictionary path
|
|
|
6bed19c |
+ QFileInfo dir ("/usr/share/myspell");
|
|
|
6bed19c |
+ if (!dir.exists() || !dir.isDir())
|
|
|
6bed19c |
+ dir.setFile ("/usr/share/hunspell");
|
|
|
6bed19c |
+ if (!dir.exists() || !dir.isDir()) return;
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ kdDebug(750) << "KSpellConfig::getAvailDictsHunspell "
|
|
|
6bed19c |
+ << dir.filePath() << " " << dir.dirPath() << endl;
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ const QDir thedir (dir.filePath(),"*.dic");
|
|
|
6bed19c |
+ const QStringList entryList = thedir.entryList();
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ kdDebug(750) << "KSpellConfig" << thedir.path() << "\n" << endl;
|
|
|
6bed19c |
+ kdDebug(750) << "entryList().count()="
|
|
|
6bed19c |
+ << entryList.count() << endl;
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ QStringList::const_iterator entryListItr = entryList.constBegin();
|
|
|
6bed19c |
+ const QStringList::const_iterator entryListEnd = entryList.constEnd();
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ for ( ; entryListItr != entryListEnd; ++entryListItr)
|
|
|
6bed19c |
+ {
|
|
|
6bed19c |
+ QString fname, lname, hname;
|
|
|
6bed19c |
+ fname = *entryListItr;
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ // remove .dic
|
|
|
6bed19c |
+ if (fname.endsWith(".dic")) fname.remove (fname.length()-4,4);
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
|
|
|
6bed19c |
+ { // This one is the KDE default language
|
|
|
6bed19c |
+ // so place it first in the lists (overwrite "Default")
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ langfnames.remove ( langfnames.begin() );
|
|
|
6bed19c |
+ langfnames.prepend ( fname );
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ hname=i18n("default spelling dictionary"
|
|
|
6bed19c |
+ ,"Default - %1 [%2]").arg(hname).arg(fname);
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ dictcombo->changeItem (hname,0);
|
|
|
6bed19c |
+ }
|
|
|
6bed19c |
+ else
|
|
|
6bed19c |
+ {
|
|
|
6bed19c |
+ langfnames.append (fname);
|
|
|
6bed19c |
+ hname=hname+" ["+fname+"]";
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ dictcombo->insertItem (hname);
|
|
|
6bed19c |
+ }
|
|
|
6bed19c |
+ }
|
|
|
6bed19c |
+}
|
|
|
6bed19c |
+
|
|
|
6bed19c |
void
|
|
|
6bed19c |
KSpellConfig::fillDicts( QComboBox* box, QStringList* dictionaries )
|
|
|
6bed19c |
{
|
|
|
6bed19c |
@@ -661,8 +723,7 @@
|
|
|
6bed19c |
box->insertItem( i18n("Turkish") );
|
|
|
6bed19c |
langfnames.append("");
|
|
|
6bed19c |
sChangeEncoding( KS_E_UTF8 );
|
|
|
6bed19c |
- }
|
|
|
6bed19c |
- else {
|
|
|
6bed19c |
+ } else if ( iclient == KS_CLIENT_ASPELL ) {
|
|
|
6bed19c |
box->clear();
|
|
|
6bed19c |
langfnames.append(""); // Default
|
|
|
6bed19c |
box->insertItem (i18n("ASpell Default"));
|
|
|
6bed19c |
@@ -741,6 +802,58 @@
|
|
|
6bed19c |
}
|
|
|
6bed19c |
}
|
|
|
6bed19c |
}
|
|
|
6bed19c |
+ } else {
|
|
|
6bed19c |
+ box->clear();
|
|
|
6bed19c |
+ langfnames.append(""); // Default
|
|
|
6bed19c |
+ box->insertItem( i18n("Hunspell Default") );
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ // dictionary path
|
|
|
6bed19c |
+ QFileInfo dir ("/usr/share/myspell");
|
|
|
6bed19c |
+ if (!dir.exists() || !dir.isDir())
|
|
|
6bed19c |
+ dir.setFile ("/usr/share/hunspell");
|
|
|
6bed19c |
+ if (!dir.exists() || !dir.isDir()) return;
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ kdDebug(750) << "KSpellConfig::getAvailDictsHunspell "
|
|
|
6bed19c |
+ << dir.filePath() << " " << dir.dirPath() << endl;
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ const QDir thedir (dir.filePath(),"*.dic");
|
|
|
6bed19c |
+ const QStringList entryList = thedir.entryList();
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ kdDebug(750) << "KSpellConfig" << thedir.path() << "\n" << endl;
|
|
|
6bed19c |
+ kdDebug(750) << "entryList().count()="
|
|
|
6bed19c |
+ << entryList.count() << endl;
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ QStringList::const_iterator entryListItr = entryList.constBegin();
|
|
|
6bed19c |
+ const QStringList::const_iterator entryListEnd = entryList.constEnd();
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ for ( ; entryListItr != entryListEnd; ++entryListItr)
|
|
|
6bed19c |
+ {
|
|
|
6bed19c |
+ QString fname, lname, hname;
|
|
|
6bed19c |
+ fname = *entryListItr;
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ // remove .dic
|
|
|
6bed19c |
+ if (fname.endsWith(".dic")) fname.remove (fname.length()-4,4);
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ if (interpret (fname, lname, hname) && langfnames.first().isEmpty())
|
|
|
6bed19c |
+ { // This one is the KDE default language
|
|
|
6bed19c |
+ // so place it first in the lists (overwrite "Default")
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ langfnames.remove ( langfnames.begin() );
|
|
|
6bed19c |
+ langfnames.prepend ( fname );
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ hname=i18n("default spelling dictionary"
|
|
|
6bed19c |
+ ,"Default - %1 [%2]").arg(hname).arg(fname);
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ box->changeItem (hname,0);
|
|
|
6bed19c |
+ }
|
|
|
6bed19c |
+ else
|
|
|
6bed19c |
+ {
|
|
|
6bed19c |
+ langfnames.append (fname);
|
|
|
6bed19c |
+ hname=hname+" ["+fname+"]";
|
|
|
6bed19c |
+
|
|
|
6bed19c |
+ box->insertItem (hname);
|
|
|
6bed19c |
+ }
|
|
|
6bed19c |
+ }
|
|
|
6bed19c |
}
|
|
|
6bed19c |
int whichelement = langfnames.findIndex(qsdict);
|
|
|
6bed19c |
if ( whichelement >= 0 ) {
|
|
|
6bed19c |
diff -ur kdelibs-3.5.8/kdeui/ksconfig.h kdelibs-3.5.8-kspell-hunspell/kdeui/ksconfig.h
|
|
|
6bed19c |
--- kdelibs-3.5.8/kdeui/ksconfig.h 2005-10-10 17:06:38.000000000 +0200
|
|
|
6bed19c |
+++ kdelibs-3.5.8-kspell-hunspell/kdeui/ksconfig.h 2007-12-22 01:35:25.000000000 +0100
|
|
|
6bed19c |
@@ -1,5 +1,6 @@
|
|
|
6bed19c |
/* This file is part of the KDE libraries
|
|
|
6bed19c |
Copyright (C) 1997 David Sweet <dsweet@kde.org>
|
|
|
6bed19c |
+ Copyright (C) 2007 Kevin Kofler <Kevin@tigcc.ticalc.org>
|
|
|
6bed19c |
|
|
|
6bed19c |
This library is free software; you can redistribute it and/or
|
|
|
6bed19c |
modify it under the terms of the GNU Library General Public
|
|
|
6bed19c |
@@ -61,7 +62,8 @@
|
|
|
6bed19c |
KS_CLIENT_ISPELL=0,
|
|
|
6bed19c |
KS_CLIENT_ASPELL=1,
|
|
|
6bed19c |
KS_CLIENT_HSPELL=2,
|
|
|
6bed19c |
- KS_CLIENT_ZEMBEREK=3
|
|
|
6bed19c |
+ KS_CLIENT_ZEMBEREK=3,
|
|
|
6bed19c |
+ KS_CLIENT_HUNSPELL=4
|
|
|
6bed19c |
};
|
|
|
6bed19c |
|
|
|
6bed19c |
/**
|
|
|
6bed19c |
@@ -283,6 +285,7 @@
|
|
|
6bed19c |
KSpellConfigPrivate *d;
|
|
|
6bed19c |
void getAvailDictsIspell();
|
|
|
6bed19c |
void getAvailDictsAspell();
|
|
|
6bed19c |
+ void getAvailDictsHunspell();
|
|
|
6bed19c |
};
|
|
|
6bed19c |
|
|
|
6bed19c |
#endif // KDELIBS_KSCONFIG_H
|
|
|
6bed19c |
diff -ur kdelibs-3.5.8/kdeui/kspell.cpp kdelibs-3.5.8-kspell-hunspell/kdeui/kspell.cpp
|
|
|
6bed19c |
--- kdelibs-3.5.8/kdeui/kspell.cpp 2005-10-10 17:06:38.000000000 +0200
|
|
|
6bed19c |
+++ kdelibs-3.5.8-kspell-hunspell/kdeui/kspell.cpp 2007-12-22 02:26:29.000000000 +0100
|
|
|
6bed19c |
@@ -2,6 +2,7 @@
|
|
|
6bed19c |
Copyright (C) 1997 David Sweet <dsweet@kde.org>
|
|
|
6bed19c |
Copyright (C) 2000-2001 Wolfram Diestel <wolfram@steloj.de>
|
|
|
6bed19c |
Copyright (C) 2003 Zack Rusin <zack@kde.org>
|
|
|
6bed19c |
+ Copyright (C) 2007 Kevin Kofler <Kevin@tigcc.ticalc.org>
|
|
|
6bed19c |
|
|
|
6bed19c |
This library is free software; you can redistribute it and/or
|
|
|
6bed19c |
modify it under the terms of the GNU Library General Public
|
|
|
6bed19c |
@@ -181,9 +182,14 @@
|
|
|
6bed19c |
*proc << "zpspell";
|
|
|
6bed19c |
kdDebug(750) << "Using zemberek(zpspell)" << endl;
|
|
|
6bed19c |
break;
|
|
|
6bed19c |
+ case KS_CLIENT_HUNSPELL:
|
|
|
6bed19c |
+ *proc << "hunspell";
|
|
|
6bed19c |
+ kdDebug(750) << "Using hunspell" << endl;
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
}
|
|
|
6bed19c |
|
|
|
6bed19c |
- if ( ksconfig->client() == KS_CLIENT_ISPELL || ksconfig->client() == KS_CLIENT_ASPELL )
|
|
|
6bed19c |
+ // Hunspell doesn't need all of these options, but it'll ignore those it doesn't understand.
|
|
|
6bed19c |
+ if ( ksconfig->client() == KS_CLIENT_ISPELL || ksconfig->client() == KS_CLIENT_ASPELL || ksconfig->client() == KS_CLIENT_HUNSPELL )
|
|
|
6bed19c |
{
|
|
|
6bed19c |
*proc << "-a" << "-S";
|
|
|
6bed19c |
|
|
|
6bed19c |
@@ -201,8 +207,8 @@
|
|
|
6bed19c |
*proc << "-t";
|
|
|
6bed19c |
break;
|
|
|
6bed19c |
case Nroff:
|
|
|
6bed19c |
- //only ispell supports
|
|
|
6bed19c |
- if ( ksconfig->client() == KS_CLIENT_ISPELL )
|
|
|
6bed19c |
+ //only ispell and hunspell support
|
|
|
6bed19c |
+ if ( ksconfig->client() == KS_CLIENT_ISPELL || ksconfig->client() == KS_CLIENT_HUNSPELL )
|
|
|
6bed19c |
*proc << "-n";
|
|
|
6bed19c |
break;
|
|
|
6bed19c |
case Text:
|
|
|
6bed19c |
@@ -239,7 +245,60 @@
|
|
|
6bed19c |
// option, so kspell tries again without it. That's why as 'ps -ax'
|
|
|
6bed19c |
// shows "ispell -a -S ..." withou the "-Tlatin2" option.
|
|
|
6bed19c |
|
|
|
6bed19c |
- if ( trystart<1 ) {
|
|
|
6bed19c |
+ if ( ksconfig->client() == KS_CLIENT_HUNSPELL && trystart<1 ) {
|
|
|
6bed19c |
+ // Note: This sets I/O encoding. Hunspell correctly handles dictionary encoding != I/O encoding.
|
|
|
6bed19c |
+ // It will be faster if the I/O encoding matches the dictionary encoding, but using UTF-8 is always safe.
|
|
|
6bed19c |
+ switch ( ksconfig->encoding() )
|
|
|
6bed19c |
+ {
|
|
|
6bed19c |
+ case KS_E_LATIN1:
|
|
|
6bed19c |
+ *proc << "-i" << "ISO-8859-1";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_LATIN2:
|
|
|
6bed19c |
+ *proc << "-i" << "ISO-8859-2";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_LATIN3:
|
|
|
6bed19c |
+ *proc << "-i" << "ISO-8859-3";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_LATIN4:
|
|
|
6bed19c |
+ *proc << "-i" << "ISO-8859-4";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_LATIN5:
|
|
|
6bed19c |
+ *proc << "-i" << "ISO-8859-5";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_LATIN7:
|
|
|
6bed19c |
+ *proc << "-i" << "ISO-8859-7";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_LATIN8:
|
|
|
6bed19c |
+ *proc << "-i" << "ISO-8859-8";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_LATIN9:
|
|
|
6bed19c |
+ *proc << "-i" << "ISO-8859-9";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_LATIN13:
|
|
|
6bed19c |
+ *proc << "-i" << "ISO-8859-13";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_LATIN15:
|
|
|
6bed19c |
+ *proc << "-i" << "ISO-8859-15";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_UTF8:
|
|
|
6bed19c |
+ *proc << "-i" << "UTF-8";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_KOI8R:
|
|
|
6bed19c |
+ *proc << "-i" << "KOI8-R";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_KOI8U:
|
|
|
6bed19c |
+ *proc << "-i" << "KOI8-U";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_CP1251:
|
|
|
6bed19c |
+ *proc << "-i" << "CP1251";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ case KS_E_CP1255:
|
|
|
6bed19c |
+ *proc << "-i" << "CP1255";
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ default:
|
|
|
6bed19c |
+ break;
|
|
|
6bed19c |
+ }
|
|
|
6bed19c |
+ } else if ( trystart<1 ) {
|
|
|
6bed19c |
switch ( ksconfig->encoding() )
|
|
|
6bed19c |
{
|
|
|
6bed19c |
case KS_E_LATIN1:
|