]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiSpellchecker.cpp
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / GuiSpellchecker.cpp
index f942304e08894afda4c27515d0be3da1372ed60b..4e6143ad8d1e4be20a5037ba433867f500657373 100644 (file)
 #include "BufferView.h"
 #include "Cursor.h"
 #include "CutAndPaste.h"
-#include "debug.h"
-#include "gettext.h"
 #include "Language.h"
 #include "LyXRC.h"
 #include "Paragraph.h"
 
-#include "support/textutils.h"
-#include "support/convert.h"
+#include "support/debug.h"
 #include "support/docstring.h"
+#include "support/gettext.h"
+#include "support/lstrings.h"
+#include "support/textutils.h"
 
-#include <QProgressBar>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QListWidget>
 #include <QListWidgetItem>
-#include <QCloseEvent>
-#include <QSyntaxHighlighter>
-#include <QTextCharFormat>
-#include <QTextDocument>
 
 #if defined(USE_ASPELL)
 # include "ASpell_local.h"
 
 #include "frontends/alert.h"
 
-using std::advance;
-using std::distance;
-using std::endl;
-using std::string;
-
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 namespace frontend {
 
-using support::bformat;
-using support::contains;
 
-GuiSpellchecker::GuiSpellchecker(LyXView & lv)
-       : GuiDialog(lv, "spellchecker"), exitEarly_(false),
+GuiSpellchecker::GuiSpellchecker(GuiView & lv)
+       : GuiDialog(lv, "spellchecker", qt_("Spellchecker")), exitEarly_(false),
          oldval_(0), newvalue_(0), count_(0), speller_(0)
 {
        setupUi(this);
-       setViewTitle(_("Spellchecker"));
 
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
        connect(replacePB, SIGNAL(clicked()), this, SLOT(replace()));
@@ -124,13 +110,6 @@ void GuiSpellchecker::replaceChanged(const QString & str)
 }
 
 
-void GuiSpellchecker::closeEvent(QCloseEvent * e)
-{
-       slotClose();
-       GuiDialog::closeEvent(e);
-}
-
-
 void GuiSpellchecker::reject()
 {
        slotClose();
@@ -244,9 +223,9 @@ static SpellBase * getSpeller(BufferParams const & bp)
 }
 
 
-bool GuiSpellchecker::initialiseParams(std::string const &)
+bool GuiSpellchecker::initialiseParams(string const &)
 {
-       LYXERR(Debug::GUI) << "Spellchecker::initialiseParams" << endl;
+       LYXERR(Debug::GUI, "Spellchecker::initialiseParams");
 
        speller_ = getSpeller(buffer().params());
        if (!speller_)
@@ -273,7 +252,7 @@ bool GuiSpellchecker::initialiseParams(std::string const &)
 
 void GuiSpellchecker::clearParams()
 {
-       LYXERR(Debug::GUI) << "Spellchecker::clearParams" << endl;
+       LYXERR(Debug::GUI, "Spellchecker::clearParams");
        delete speller_;
        speller_ = 0;
 }
@@ -337,7 +316,7 @@ static WordLangTuple nextWord(Cursor & cur, ptrdiff_t & progress)
 
 void GuiSpellchecker::check()
 {
-       LYXERR(Debug::GUI) << "Check the spelling of a word" << endl;
+       LYXERR(Debug::GUI, "Check the spelling of a word");
 
        SpellBase::Result res = SpellBase::OK;
 
@@ -347,8 +326,8 @@ void GuiSpellchecker::check()
 
        ptrdiff_t start = 0;
        ptrdiff_t total = 0;
-       DocIterator it = DocIterator(buffer().inset());
-       for (start = 0; it != cur; it.forwardPos())
+       DocIterator it = doc_iterator_begin(buffer().inset());
+       for (start = 1; it != cur; it.forwardPos())
                ++start;
 
        for (total = start; it; it.forwardPos())
@@ -372,7 +351,7 @@ void GuiSpellchecker::check()
                float progress = total ? float(start)/total : 1;
                newvalue_ = int(100.0 * progress);
                if (newvalue_!= oldval_) {
-                       LYXERR(Debug::GUI) << "Updating spell progress." << endl;
+                       LYXERR(Debug::GUI, "Updating spell progress.");
                        oldval_ = newvalue_;
                        // set progress bar
                        partialUpdate(SPELL_PROGRESSED);
@@ -389,7 +368,7 @@ void GuiSpellchecker::check()
                        return;
        }
 
-       LYXERR(Debug::GUI) << "Found word \"" << to_utf8(getWord()) << "\"" << endl;
+       LYXERR(Debug::GUI, "Found word \"" << to_utf8(getWord()) << "\"");
 
        int const size = cur.selEnd().pos() - cur.selBegin().pos();
        cur.pos() -= size;
@@ -401,7 +380,7 @@ void GuiSpellchecker::check()
 
        // set suggestions
        if (res != SpellBase::OK && res != SpellBase::IGNORED_WORD) {
-               LYXERR(Debug::GUI) << "Found a word needing checking." << endl;
+               LYXERR(Debug::GUI, "Found a word needing checking.");
                partialUpdate(SPELL_FOUND_WORD);
        }
 }
@@ -446,8 +425,8 @@ void GuiSpellchecker::showSummary()
 
 void GuiSpellchecker::replace(docstring const & replacement)
 {
-       LYXERR(Debug::GUI) << "GuiSpellchecker::replace("
-                          << to_utf8(replacement) << ")" << std::endl;
+       LYXERR(Debug::GUI, "GuiSpellchecker::replace("
+                          << to_utf8(replacement) << ")");
        cap::replaceSelectionWithString(bufferview()->cursor(), replacement, true);
        buffer().markDirty();
        // If we used an LFUN, we would not need that
@@ -491,7 +470,7 @@ void GuiSpellchecker::ignoreAll()
 }
 
 
-Dialog * createGuiSpellchecker(LyXView & lv) { return new GuiSpellchecker(lv); }
+Dialog * createGuiSpellchecker(GuiView & lv) { return new GuiSpellchecker(lv); }
 
 } // namespace frontend
 } // namespace lyx