From faa7f72c417b4ccd9b794b32b988312186d62e59 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 28 Dec 2012 16:50:41 +0100 Subject: Krazy Fixes, first shot --- src/kspellplugin.cpp | 76 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 24 deletions(-) (limited to 'src/kspellplugin.cpp') diff --git a/src/kspellplugin.cpp b/src/kspellplugin.cpp index 1186eb44..7b20b4a4 100644 --- a/src/kspellplugin.cpp +++ b/src/kspellplugin.cpp @@ -3,6 +3,7 @@ * This file is a part of the rekonq project * * Copyright (C) 2012 by Lindsay Mathieson +* Copyright (C) 2012 by Andrea Diamantini * * * This program is free software; you can redistribute it and/or @@ -24,16 +25,45 @@ * ============================================================ */ -#include -#include +// Self Includes #include "kspellplugin.h" + +// KDE Includes +#include + +// Qt Includes #include +// Auto Includes #include "rekonq.h" +// Defines #define methodDebug() kDebug("KWebSpellChecker: %s", __FUNCTION__) -///////////////////////////// + +// --------------------------------------------------------------------------------------------- + + +static bool isValidWord(const QString &str) +{ + if (str.isEmpty() || (str.length() == 1 && !str[0].isLetter())) + { + return false; + } + const int length = str.length(); + for (int i = 0; i < length; ++i) + { + if (!str[i].isNumber()) + { + return true; + } + } + // 'str' only contains numbers + return false; +} + + +// --------------------------------------------------------------------------------------------- // KWebSpellChecker @@ -42,48 +72,36 @@ KWebSpellChecker::KWebSpellChecker() m_speller = new Sonnet::Speller(); } + KWebSpellChecker::~KWebSpellChecker() { delete m_speller; } + bool KWebSpellChecker::isContinousSpellCheckingEnabled() const { return ReKonfig::automaticSpellChecking(); } + void KWebSpellChecker::toggleContinousSpellChecking() { ReKonfig::setAutomaticSpellChecking(! ReKonfig::automaticSpellChecking()); } + void KWebSpellChecker::learnWord(const QString& word) { Q_UNUSED(word); } + void KWebSpellChecker::ignoreWordInSpellDocument(const QString& word) { Q_UNUSED(word); } -static bool isValidWord(const QString &str) -{ - if (str.isEmpty() || (str.length() == 1 && !str[0].isLetter())) - { - return false; - } - const int length = str.length(); - for (int i = 0; i < length; ++i) - { - if (!str[i].isNumber()) - { - return true; - } - } - // 'str' only contains numbers - return false; -} void KWebSpellChecker::checkSpellingOfString(const QString& word, int* misspellingLocation, int* misspellingLength) { @@ -131,8 +149,10 @@ void KWebSpellChecker::checkSpellingOfString(const QString& word, int* misspelli } } + QString KWebSpellChecker::autoCorrectSuggestionForMisspelledWord(const QString& word) { + Q_UNUSED(word); /* QStringList words = m_speller->suggest(word); if (words.size() > 0) @@ -141,10 +161,10 @@ QString KWebSpellChecker::autoCorrectSuggestionForMisspelledWord(const QString& return QString(""); */ - - return QString(""); + return QString(); } + void KWebSpellChecker::guessesForWord(const QString& word, const QString& context, QStringList& guesses) { Q_UNUSED(context); @@ -153,15 +173,18 @@ void KWebSpellChecker::guessesForWord(const QString& word, const QString& contex guesses = words; } + bool KWebSpellChecker::isGrammarCheckingEnabled() { return false; } + void KWebSpellChecker::toggleGrammarChecking() { } + void KWebSpellChecker::checkGrammarOfString(const QString&, QList&, int* badGrammarLocation, int* badGrammarLength) { Q_UNUSED(badGrammarLocation); @@ -169,12 +192,15 @@ void KWebSpellChecker::checkGrammarOfString(const QString&, QList } -//////////////////////////////////////////// +// ---------------------------------------------------------------------------------------------------------------- // KWebKitPlatformPlugin + + KWebKitPlatformPlugin::KWebKitPlatformPlugin() { } + KWebKitPlatformPlugin::~KWebKitPlatformPlugin() { } @@ -185,6 +211,7 @@ bool KWebKitPlatformPlugin::supportsExtension(Extension ext) const return ext == SpellChecker; } + QObject* KWebKitPlatformPlugin::createExtension(Extension ext) const { if (ext == SpellChecker) @@ -193,6 +220,7 @@ QObject* KWebKitPlatformPlugin::createExtension(Extension ext) const return NULL; } + +// ---------------------------------------------------------------------------------------------------------------- Q_EXPORT_PLUGIN2(kwebspellchecker, KWebKitPlatformPlugin); Q_IMPORT_PLUGIN(kwebspellchecker) - -- cgit v1.2.1