qtwebkit-plugins icon indicating copy to clipboard operation
qtwebkit-plugins copied to clipboard

Library vs bundle: unported changes?

Open lahwaacz opened this issue 8 years ago • 2 comments

There is a difference between spellcheck.{h,cpp} in this library and the files bundled with QupZilla. Why were the changes not ported here?

--- a/qtwebkit-plugins/src/spellcheck/spellcheck.cpp
+++ b/qupzilla/src/lib/plugins/qtwebkit/spellcheck/spellcheck.cpp
@@ -1,6 +1,6 @@
 /* ============================================================
-* qtwebkit-spellcheck Spell checking plugin using Hunspell
-* Copyright (C) 2013  David Rosca <[email protected]>
+* QupZilla - WebKit based browser
+* Copyright (C) 2013-2014  David Rosca <[email protected]>
 *
 * 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
@@ -23,39 +23,32 @@

 SpellCheck::SpellCheck()
     : QWebSpellChecker()
-    , m_speller(0)
 {
-    m_speller = new Speller();
-
-    if (!m_speller->initialize()) {
-        delete m_speller;
-        m_speller = 0;
-    }
 }

 bool SpellCheck::isContinousSpellCheckingEnabled() const
 {
-    return true;
+    return Speller::instance()->isEnabled();
 }

 void SpellCheck::toggleContinousSpellChecking()
 {
 }

-void SpellCheck::learnWord(const QString& word)
+void SpellCheck::learnWord(const QString &word)
 {
     Q_UNUSED(word);
 }

-void SpellCheck::ignoreWordInSpellDocument(const QString& word)
+void SpellCheck::ignoreWordInSpellDocument(const QString &word)
 {
     Q_UNUSED(word);
 }

-void SpellCheck::checkSpellingOfString(const QString& word,
+void SpellCheck::checkSpellingOfString(const QString &word,
                                        int* misspellingLocation, int* misspellingLength)
 {
-    if (misspellingLocation == NULL || misspellingLength == NULL || !m_speller) {
+    if (misspellingLocation == NULL || misspellingLength == NULL) {
         return;
     }

@@ -74,8 +67,8 @@ void SpellCheck::checkSpellingOfString(const QString& word,
         if (endOfWord(boundary, finder.type()) && inWord) {
             end = finder.position();
             QString str = finder.string().mid(start, end - start);
-            if (isValidWord(str)) {
-                if (m_speller->isMisspelled(str)) {
+            if (Speller::isValidWord(str)) {
+                if (Speller::instance()->isMisspelled(str)) {
                     *misspellingLocation = start;
                     *misspellingLength = end - start;
                 }
@@ -91,32 +84,30 @@ void SpellCheck::checkSpellingOfString(const QString& word,
     }
 }

-QString SpellCheck::autoCorrectSuggestionForMisspelledWord(const QString& word)
+QString SpellCheck::autoCorrectSuggestionForMisspelledWord(const QString &word)
 {
     /* Auto correcting mispelled words is really not a great idea */
     Q_UNUSED(word)
     return QString();
 #if 0
-    QStringList words = m_speller->suggest(word);
-    if (words.size() > 0)
+    QStringList words = Speller::instance()->suggest(word);
+    if (words.size() > 0) {
         return words[0];
-    else
+    }
+    else {
         return QString();
+    }

     return QString();
 #endif
 }

-void SpellCheck::guessesForWord(const QString& word,
-                                const QString& context, QStringList& guesses)
+void SpellCheck::guessesForWord(const QString &word,
+                                const QString &context, QStringList &guesses)
 {
     Q_UNUSED(context);

-    if (!m_speller) {
-        return;
-    }
-
-    QStringList words = m_speller->suggest(word);
+    QStringList words = Speller::instance()->suggest(word);
     guesses = words;
 }

@@ -129,30 +120,15 @@ void SpellCheck::toggleGrammarChecking()
 {
 }

-void SpellCheck::checkGrammarOfString(const QString&, QList<GrammarDetail>&,
+void SpellCheck::checkGrammarOfString(const QString &, QList<GrammarDetail> &,
                                       int* badGrammarLocation, int* badGrammarLength)
 {
     Q_UNUSED(badGrammarLocation);
     Q_UNUSED(badGrammarLength);
 }

-bool SpellCheck::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;
-}
-
 bool SpellCheck::endOfWord(const QTextBoundaryFinder::BoundaryReasons &reasons,
-               const QTextBoundaryFinder::BoundaryType &type)
+                           const QTextBoundaryFinder::BoundaryType &type)
 {
 #if QT_VERSION < 0x050000
     Q_UNUSED(type)
@@ -164,7 +140,7 @@ bool SpellCheck::endOfWord(const QTextBoundaryFinder::BoundaryReasons &reasons,
 }

 bool SpellCheck::startOfWord(const QTextBoundaryFinder::BoundaryReasons &reasons,
-               const QTextBoundaryFinder::BoundaryType &type)
+                             const QTextBoundaryFinder::BoundaryType &type)
 {
 #if QT_VERSION < 0x050000
     Q_UNUSED(type)
@@ -174,8 +150,3 @@ bool SpellCheck::startOfWord(const QTextBoundaryFinder::BoundaryReasons &reasons
            (type & QTextBoundaryFinder::Word);
 #endif
 }
-
-SpellCheck::~SpellCheck()
-{
-    delete m_speller;
-}

lahwaacz avatar Jun 04 '16 17:06 lahwaacz