summaryrefslogtreecommitdiffstats
path: root/katapult/plugins/catalogs/spellcatalog
diff options
context:
space:
mode:
Diffstat (limited to 'katapult/plugins/catalogs/spellcatalog')
-rw-r--r--katapult/plugins/catalogs/spellcatalog/Makefile.am19
-rw-r--r--katapult/plugins/catalogs/spellcatalog/actioncopyspelling.cpp80
-rw-r--r--katapult/plugins/catalogs/spellcatalog/actioncopyspelling.h51
-rw-r--r--katapult/plugins/catalogs/spellcatalog/cr128-action-katapultspellcheck.pngbin0 -> 8211 bytes
-rw-r--r--katapult/plugins/catalogs/spellcatalog/crsc-action-katapultspellcheck.svgzbin0 -> 1396 bytes
-rw-r--r--katapult/plugins/catalogs/spellcatalog/katapult_spellcatalog.desktop43
-rw-r--r--katapult/plugins/catalogs/spellcatalog/settings.ui65
-rw-r--r--katapult/plugins/catalogs/spellcatalog/spellcatalog.cpp122
-rw-r--r--katapult/plugins/catalogs/spellcatalog/spellcatalog.h73
-rw-r--r--katapult/plugins/catalogs/spellcatalog/spelling.cpp133
-rw-r--r--katapult/plugins/catalogs/spellcatalog/spelling.h74
11 files changed, 660 insertions, 0 deletions
diff --git a/katapult/plugins/catalogs/spellcatalog/Makefile.am b/katapult/plugins/catalogs/spellcatalog/Makefile.am
new file mode 100644
index 0000000..eb07f58
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/Makefile.am
@@ -0,0 +1,19 @@
+# Copyright (C) 2006 Jonathan Riddell
+
+# set the include path for X, qt and KDE
+INCLUDES = -I$(top_srcdir)/katapult/common $(all_includes)
+
+# header files
+noinst_HEADERS = actioncopyspelling.h spellcatalog.h spelling.h
+
+# use automoc
+METASOURCES = AUTO
+
+KDE_ICON = AUTO
+
+# our plugin
+kde_module_LTLIBRARIES = katapult_spellcatalog.la
+katapult_spellcatalog_la_SOURCES = settings.ui spellcatalog.cpp spelling.cpp actioncopyspelling.cpp
+katapult_spellcatalog_la_LDFLAGS = -module $(KDE_RPATH) $(KDE_PLUGIN) $(all_libraries)
+katapult_spellcatalog_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KIO) $(top_builddir)/katapult/common/libkatapult.la
+kde_services_DATA = katapult_spellcatalog.desktop
diff --git a/katapult/plugins/catalogs/spellcatalog/actioncopyspelling.cpp b/katapult/plugins/catalogs/spellcatalog/actioncopyspelling.cpp
new file mode 100644
index 0000000..87857d3
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/actioncopyspelling.cpp
@@ -0,0 +1,80 @@
+/***************************************************************************
+ * Copyright (C) 2006 Jonathan Riddell *
+ * jriddell@ubuntu.com *
+ * *
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kapplication.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klocale.h>
+
+#include <qclipboard.h>
+
+#include "spellcatalog.h"
+#include "spelling.h"
+#include "katapultitem.h"
+#include "actioncopyspelling.h"
+
+ActionCopySpelling::ActionCopySpelling()
+ : KatapultAction(), _spelling(0)
+{
+}
+
+ActionCopySpelling::~ActionCopySpelling()
+{
+}
+
+QString ActionCopySpelling::text() const
+{
+ if (_spelling->parseError()) {
+ return i18n("Parse Error");
+ } else {
+ return _spelling->result();
+ }
+}
+
+QPixmap ActionCopySpelling::icon(int size) const
+{
+ return KGlobal::iconLoader()->loadIcon("katapultspellcheck", KIcon::NoGroup, size);
+}
+
+bool ActionCopySpelling::accepts(const KatapultItem* item) const
+{
+ bool accept = strcmp(item->className(), "Spelling") == 0;
+ if (accept) {
+ _spelling = (const Spelling*)item;
+ }
+ return accept;
+}
+
+void ActionCopySpelling::execute(const KatapultItem* item) const
+{
+ if (strcmp(item->className(), "Spelling") == 0) {
+ _spelling = (const Spelling*)item;
+
+ _spelling->evaluate();
+
+ // Copy calculation and result into clipboard (unless there's a parse error).
+ if (!_spelling->parseError()) {
+ _spelling->copyToClipboard();
+ }
+ }
+}
diff --git a/katapult/plugins/catalogs/spellcatalog/actioncopyspelling.h b/katapult/plugins/catalogs/spellcatalog/actioncopyspelling.h
new file mode 100644
index 0000000..e15c3d9
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/actioncopyspelling.h
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (C) 2006 Jonathan Riddell *
+ * jriddell@ubuntu.com *
+ * *
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef ACTIONCOPYSPELLING_H
+#define ACTIONCOPYSPELLING_H
+
+#include "katapultaction.h"
+
+class KatapultItem;
+class Spelling;
+
+/**
+@author Tobi Vollebregt
+*/
+class ActionCopySpelling : public KatapultAction
+{
+ public:
+ ActionCopySpelling();
+ ~ActionCopySpelling();
+
+ virtual void execute(const KatapultItem*) const;
+ virtual bool accepts(const KatapultItem*) const;
+ virtual QString text() const;
+ virtual QPixmap icon(int) const;
+
+ private:
+ //_expr needs to be mutable because accepts() is const.
+ mutable const Spelling* _spelling;
+
+};
+
+#endif
diff --git a/katapult/plugins/catalogs/spellcatalog/cr128-action-katapultspellcheck.png b/katapult/plugins/catalogs/spellcatalog/cr128-action-katapultspellcheck.png
new file mode 100644
index 0000000..f11344d
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/cr128-action-katapultspellcheck.png
Binary files differ
diff --git a/katapult/plugins/catalogs/spellcatalog/crsc-action-katapultspellcheck.svgz b/katapult/plugins/catalogs/spellcatalog/crsc-action-katapultspellcheck.svgz
new file mode 100644
index 0000000..2105fa5
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/crsc-action-katapultspellcheck.svgz
Binary files differ
diff --git a/katapult/plugins/catalogs/spellcatalog/katapult_spellcatalog.desktop b/katapult/plugins/catalogs/spellcatalog/katapult_spellcatalog.desktop
new file mode 100644
index 0000000..035ee06
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/katapult_spellcatalog.desktop
@@ -0,0 +1,43 @@
+# Copyright (C) 2006 Jonathan Riddell
+[Desktop Entry]
+Name=Spell Catalog
+Name[ar]=مستعرض التدقيق الأملائي ( Spell Catalog )
+Name[bg]=Каталог за проверка на правописа
+Name[da]=Katalogisér stavning
+Name[de]=Rechtschreibung-Katalog
+Name[el]=Κατάλογος ορθογραφίας
+Name[es]=Catalogador de ortografía
+Name[et]=Õigekirjakataloog
+Name[fr]=Catalogue orthographique
+Name[ga]=Catalóg Litrithe
+Name[gl]=Catálogo de Ortografia
+Name[it]=Catalogo controllo ortografico
+Name[ja]=スペルカタログ
+Name[nb]=Stavekatalog
+Name[nl]=Spelcatalogus
+Name[pt]=Catálogo de Ortografia
+Name[pt_BR]=Catálogo de Ortografia
+Name[sv]=Stavningskatalog
+Name[uk]=Каталог правопису
+Comment=Check the spelling of a word
+Comment[ar]=دقًق املائيا في الكلمة
+Comment[bg]=Проверка правописа на дума
+Comment[da]=Tjek stavning af et ord
+Comment[de]=Die Schreibweise eines Wortes überprüfen
+Comment[el]=Ορθογραφικός έλεγχος μιας λέξης
+Comment[es]=Comprueba la ortografía de una palabra
+Comment[et]=Sõna õigekirja kontroll
+Comment[fr]=Vérifier l'orthographe d'un mot
+Comment[gl]=Verifica a ortografia dunha palabra
+Comment[it]=Controllo ortografico di una parola
+Comment[ja]=単語のスペルをチェック
+Comment[nb]=Sjekk skrivemåten for et ord
+Comment[nl]=Controleert de spelling van een woord
+Comment[pt]=Verificar a ortografia de uma palavra
+Comment[pt_BR]=Verificar a ortografia de uma palavra
+Comment[sv]=Kontrollera stavningen av ett ord
+Comment[uk]=Перевірити правопис слова
+ServiceTypes=Katapult/Catalog
+Type=Service
+X-KDE-Library=katapult_spellcatalog
+X-Katapult-ID=Spell Catalog
diff --git a/katapult/plugins/catalogs/spellcatalog/settings.ui b/katapult/plugins/catalogs/spellcatalog/settings.ui
new file mode 100644
index 0000000..402b416
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/settings.ui
@@ -0,0 +1,65 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>SpellCatalogSettings</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SpellCatalogSettings</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>356</width>
+ <height>265</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Settings</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>triggerWordLE</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>triggerWordLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Trigger Word:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>introLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Use with: "spell myword"</string>
+ </property>
+ </widget>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>150</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<tabstops>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/katapult/plugins/catalogs/spellcatalog/spellcatalog.cpp b/katapult/plugins/catalogs/spellcatalog/spellcatalog.cpp
new file mode 100644
index 0000000..5cbdbed
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/spellcatalog.cpp
@@ -0,0 +1,122 @@
+/***************************************************************************
+ * Copyright (C) 2006 Jonathan Riddell *
+ * jriddell@ubuntu.com *
+ * *
+ * Copyright (C) 2005 Tobi Vollebregt *
+ * tobivollebregt@gmail.com *
+ * *
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kservicegroup.h>
+#include <ksycocaentry.h>
+#include <ksycocatype.h>
+#include <kapplication.h>
+
+#include <qlineedit.h>
+#include <qlabel.h>
+
+#include "settings.h"
+#include "spellcatalog.h"
+#include "actionregistry.h"
+#include "actioncopyspelling.h"
+#include "status.h"
+
+K_EXPORT_COMPONENT_FACTORY( katapult_spellcatalog,
+ KGenericFactory<SpellCatalog>( "katapult_spellcatalog" ) )
+
+SpellCatalog::SpellCatalog(QObject*, const char*, const QStringList&): _result(this, QString::null)
+{
+ ActionRegistry::self()->registerAction(new ActionCopySpelling());
+}
+
+SpellCatalog::~SpellCatalog()
+{
+}
+
+void SpellCatalog::queryChanged()
+{
+ int newStatus = 0;
+ QString cmd = query();
+ int origLength = cmd.length();
+
+ if (cmd.isEmpty()) {
+ reset();
+ setBestMatch(Match());
+ } else {
+ if (accepts(cmd)) {
+ _result.setText(cmd);
+
+ setBestMatch(Match(&_result, _result.parseError() ? 10 : 100, origLength));
+ //set status.
+ //add S_Multiple to make sure katapult doesn't auto-exec and close the window
+ //add S_Active to make sure katapult doesn't start the hideTimer or clearTimer
+ newStatus = S_HasResults | S_Multiple | S_Active;
+ } else {
+ newStatus = 0;
+ }
+ }
+ setStatus(newStatus);
+}
+
+bool SpellCatalog::accepts(const QString& str) const
+{
+ //accept if we begin with the triggerWord
+ int length = _triggerWord.length();
+ return str.left(length + 1) == _triggerWord + " ";
+}
+
+void SpellCatalog::readSettings(KConfigBase* config)
+{
+ _triggerWord = config->readEntry("TriggerWord", i18n("Should be short, easy and quick to type", "spell"));
+}
+
+void SpellCatalog::writeSettings(KConfigBase* config)
+{
+ config->writeEntry("TriggerWord", _triggerWord);
+}
+
+QWidget * SpellCatalog::configure()
+{
+ SpellCatalogSettings* settings = new SpellCatalogSettings();
+
+ settings->triggerWordLE->setText(_triggerWord);
+ connect(settings->triggerWordLE, SIGNAL(textChanged(const QString&)), this, SLOT(triggerWordChanged(const QString&)));
+
+ settings->introLabel->setText(i18n("Use with \"%1 myword\"").arg(_triggerWord));
+
+ return settings;
+}
+
+void SpellCatalog::triggerWordChanged(const QString& triggerWord)
+{
+ _triggerWord = QString(triggerWord);
+}
+
+int SpellCatalog::triggerWordLength()
+{
+ return _triggerWord.length();
+}
+
+void SpellCatalog::reset()
+{
+ _result.setText(QString::null);
+}
+
+#include "spellcatalog.moc"
diff --git a/katapult/plugins/catalogs/spellcatalog/spellcatalog.h b/katapult/plugins/catalogs/spellcatalog/spellcatalog.h
new file mode 100644
index 0000000..86181dc
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/spellcatalog.h
@@ -0,0 +1,73 @@
+/***************************************************************************
+ * Copyright (C) 2006 Jonathan Riddell *
+ * jriddell@ubuntu.com *
+ * *
+ * Copyright (C) 2005 Tobi Vollebregt *
+ * tobivollebregt@gmail.com *
+ * *
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef SPELLCATALOG_H
+#define SPELLCATALOG_H
+
+#include <kgenericfactory.h>
+
+#include <qstring.h>
+
+#include "spelling.h"
+#include "katapultcatalog.h"
+
+class QWidget;
+
+/**
+@author Jonathan Riddell
+ */
+class SpellCatalog : public KatapultCatalog
+{
+ Q_OBJECT
+
+ public:
+
+ SpellCatalog(QObject*, const char*, const QStringList&);
+ virtual ~SpellCatalog();
+
+ virtual void readSettings(KConfigBase*);
+ virtual void writeSettings(KConfigBase*);
+ virtual QWidget* configure();
+ int triggerWordLength();
+
+ protected:
+
+ virtual void queryChanged();
+
+ private:
+ bool accepts(const QString&) const;
+
+ QString _triggerWord;
+
+ Spelling _result; // The one result (there's always one).
+
+ void reset();
+
+ protected slots:
+ void triggerWordChanged(const QString& triggerWord);
+
+};
+
+#endif
diff --git a/katapult/plugins/catalogs/spellcatalog/spelling.cpp b/katapult/plugins/catalogs/spellcatalog/spelling.cpp
new file mode 100644
index 0000000..fe08355
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/spelling.cpp
@@ -0,0 +1,133 @@
+/***************************************************************************
+ * Copyright (C) 2006 Jonathan Riddell *
+ * jriddell@ubuntu.com *
+ * *
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kservice.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kapplication.h>
+
+#include <qclipboard.h>
+
+#include "spellcatalog.h"
+#include "spelling.h"
+
+
+Spelling::Spelling(SpellCatalog* catalog, const QString& text): KatapultItem(), _catalog(catalog), _text(text)
+{
+ spellChecker = new KSpell( 0, "caption", this, SLOT(spellCheckerReady()) );
+
+ connect( spellChecker, SIGNAL(misspelling(const QString&, const QStringList&, unsigned int)),
+ this, SLOT(spellCheckerMisspelling(const QString&, const QStringList&, unsigned int)) );
+
+ connect( spellChecker, SIGNAL(corrected(const QString&, const QString&, unsigned int)),
+ this, SLOT(spellCheckerCorrected(const QString&, const QString&, unsigned int)) );
+
+ evaluate();
+}
+
+Spelling::~Spelling() {
+ delete spellChecker;
+}
+
+void Spelling::spellCheckerReady() {
+}
+
+void Spelling::spellCheckerCorrected(const QString& /*originalword*/, const QString& /*newword*/, unsigned int /*pos*/) {
+ corrected = true;
+}
+
+void Spelling::spellCheckerMisspelling(const QString& /*originalword*/, const QStringList& suggestions, unsigned int /*pos*/) {
+ misspelt = true;
+ suggestedWords = suggestions.join(",");
+}
+
+QPixmap Spelling::icon(int size) const
+{
+ const char* icon = "checkmark";
+ if (_parseError || misspelt) {
+ icon = "no";
+ }
+ return KGlobal::iconLoader()->loadIcon(icon, KIcon::NoGroup, size);
+}
+
+QString Spelling::text() const
+{
+ return _text;
+}
+
+void Spelling::setText(const QString& text)
+{
+ _text = text;
+ evaluate();
+}
+
+QString Spelling::result() const
+{
+ return _result;
+}
+
+bool Spelling::parseError() const
+{
+ return _parseError;
+}
+
+SpellCatalog* Spelling::catalog() const
+{
+ return _catalog;
+}
+
+void Spelling::evaluate() const
+{
+ int length = catalog()->triggerWordLength();
+
+ QString text = _text.mid(length + 1); // + 1 for space
+
+ misspelt = false;
+ corrected = false;
+
+ _parseError = false;
+ if (!_text.isEmpty()) {
+ _result = "my result";
+ spellChecker->checkWord(text);
+
+ while (corrected == false) {
+ kapp->processEvents();
+ }
+
+ if (misspelt) {
+ _result = suggestedWords;
+ } else {
+ _result = "Correct";
+ }
+ } else {
+ _parseError = true;
+ }
+}
+
+void Spelling::copyToClipboard() const {
+ QClipboard* clipBoard = QApplication::clipboard();
+ clipBoard->setText(suggestedWords, QClipboard::Clipboard);
+ clipBoard->setText(suggestedWords, QClipboard::Selection);
+}
+
+#include "spelling.moc"
diff --git a/katapult/plugins/catalogs/spellcatalog/spelling.h b/katapult/plugins/catalogs/spellcatalog/spelling.h
new file mode 100644
index 0000000..ea4b846
--- /dev/null
+++ b/katapult/plugins/catalogs/spellcatalog/spelling.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ * Copyright (C) 2006 Jonathan Riddell *
+ * jriddell@ubuntu.com *
+ * *
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef SPELLING_H
+#define SPELLING_H
+
+#include <kspell.h>
+
+#include <katapultitem.h>
+
+class SpellCatalog;
+
+/**
+@author Tobi Vollebregt
+*/
+class Spelling : public KatapultItem
+{
+ Q_OBJECT
+ public:
+ Spelling(SpellCatalog*, const QString&);
+ ~Spelling();
+
+ virtual QPixmap icon(int) const;
+ virtual QString text() const;
+
+ void setText(const QString&);
+ QString result() const;
+ bool parseError() const;
+
+ //evaluate() must be const, or ActionEvaluateSpelling::execute() can't call it.
+ //It makes sense because evaluate() does _not_ change the expression,
+ //it just calculates the result and remembers that.
+ void evaluate() const;
+
+ SpellCatalog* catalog() const;
+
+ void copyToClipboard() const;
+
+ private:
+ SpellCatalog* const _catalog;
+ QString _text;
+ mutable QString _result;
+ mutable bool _parseError;
+ KSpell* spellChecker;
+ mutable bool misspelt;
+ mutable bool corrected;
+ QString suggestedWords;
+
+ protected slots:
+ void spellCheckerReady();
+ void spellCheckerCorrected(const QString& originalword, const QString& newword, unsigned int pos);
+ void spellCheckerMisspelling(const QString& originalword, const QStringList& suggestions, unsigned int pos);
+};
+
+#endif