]> git.lyx.org Git - features.git/commitdiff
Spellchecker: More simplifications.
authorAbdelrazak Younes <younes@lyx.org>
Sat, 4 Apr 2009 17:25:14 +0000 (17:25 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 4 Apr 2009 17:25:14 +0000 (17:25 +0000)
This change makes it possible (at long last!) to go to the work area, do some edition and then come back to the SpellChecker. We probably need a [Continue] button.

* Buffer::nextWord(): go back a bit to return the current word.

* SpellChecker and Dialog: get rid of the complicated, useless exitEarly() handling.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29092 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/frontends/qt4/Dialog.cpp
src/frontends/qt4/Dialog.h
src/frontends/qt4/GuiSpellchecker.cpp
src/frontends/qt4/GuiSpellchecker.h

index 04572db74b212fd0c7137f987da07554ea34e51b..90ce575534cfa13f7ac00c5ad3c89f2c74014ea9 100644 (file)
@@ -3091,8 +3091,12 @@ bool Buffer::nextWord(DocIterator & from, DocIterator & to,
        bool inword = false;
        bool ignoreword = false;
        string lang_code;
+       // Go backward a bit if needed in order to return the word currently
+       // pointed by 'from'.
+       while (from && from.pos() && isLetter(from))
+               from.backwardPos();
+       // OK, we start from here.
        to = from;
-
        while (to.depth()) {
                if (isLetter(to)) {
                        if (!inword) {
index a7e0b51df951bf092ec2bc4109aee760d0f06cc2..d1ff82fc7f4d1f13ca9af65034e17772f08447ad 100644 (file)
@@ -158,8 +158,6 @@ void Dialog::showView()
        // Make sure the dialog controls are correctly enabled/disabled with
        // readonly status.
        checkStatus();
-       if (exitEarly())
-               return;
 
        QWidget * w = asQWidget();
        w->setWindowTitle(title_);
index 06243457e157d67252b4ee7e1a36055a9a4fd6bf..39242223999bb023df3448779a6044447d8aa703 100644 (file)
@@ -195,11 +195,6 @@ public:
         */
        virtual bool disconnectOnApply() const { return false; }
 
-       /** \return true if Dialog::View::show() should not display the dialog
-        *   after running update. Currently, only ControlSpellchecker
-        *   makes use of that.
-       */
-       virtual bool exitEarly() const { return false; }
        //@}
 
        /** \c Kernel part: a wrapper making the LyX kernel available to the dialog.
index 56969abeeca2404c46a657fcc7515023aef1c5e1..b5dadeb5f6000d9857d87625e0dd70062ed6fc11 100644 (file)
@@ -48,7 +48,7 @@ namespace frontend {
 
 
 GuiSpellchecker::GuiSpellchecker(GuiView & lv)
-       : GuiDialog(lv, "spellchecker", qt_("Spellchecker")), exitEarly_(false),
+       : GuiDialog(lv, "spellchecker", qt_("Spellchecker")),
          progress_(0), count_(0)
 {
        setupUi(this);
@@ -108,31 +108,8 @@ void GuiSpellchecker::reject()
 
 void GuiSpellchecker::updateContents()
 {
-       // The clauses below are needed because the spellchecker
-       // has many flaws (see bugs 1950, 2218).
-       // Basically, we have to distinguish the case where a
-       // spellcheck has already been performed for the whole
-       // document (exitEarly() == true, isVisible() == false) 
-       // from the rest (exitEarly() == false, isVisible() == true).
-       // FIXME: rewrite the whole beast!
-       static bool check_after_early_exit;
-       if (exitEarly()) {
-               // a spellcheck has already been performed,
+       if (hasFocus())
                check();
-               check_after_early_exit = true;
-       }
-       else if (isVisible()) {
-               // the above check triggers a second update,
-               // and isVisible() is true then. Prevent a
-               // second check that skips the first word
-               if (check_after_early_exit)
-                       // don't check, but reset the bool.
-                       // business as usual after this.
-                       check_after_early_exit = false;
-               else
-                       // perform spellcheck (default case)
-                       check();
-       }
 }
 
 
@@ -195,21 +172,12 @@ bool GuiSpellchecker::initialiseParams(string const &)
 }
 
 
-void GuiSpellchecker::clearParams()
-{
-       LYXERR(Debug::GUI, "Spellchecker::clearParams");
-}
-
-
 void GuiSpellchecker::check()
 {
        LYXERR(Debug::GUI, "Check the spelling of a word");
 
        DocIterator from = bufferview()->cursor();
-       while (from && from.pos() && isLetter(from))
-               from.backwardPos();
        DocIterator to;
-       exitEarly_ = false;
        WordLangTuple word_lang;
        docstring_list suggestions;
 
@@ -231,9 +199,11 @@ void GuiSpellchecker::check()
        // end of document
        if (from == to) {
                showSummary();
-               exitEarly_ = true;
                return;
        }
+       if (!isVisible())
+               show();
+
        word_ = word_lang;
 
        int const progress_bar = total_
index 1aebefae3cc31ffaab2cb2fd55a53693fd4fad24..d2bccdd932bc98dcae9f5b31329b01d693b4af27 100644 (file)
@@ -56,13 +56,11 @@ private:
        ///
        bool initialiseParams(std::string const & data);
        ///
-       void clearParams();
+       void clearParams() {}
        /// Not needed here
        void dispatchParams() {}
        ///
        bool isBufferDependent() const { return true; }
-       ///
-       bool exitEarly() const { return exitEarly_; }
 
        /// replace word with replacement
        void replace(docstring const &);
@@ -77,8 +75,6 @@ private:
        /// show count of checked words at normal exit
        void showSummary();
 
-       /// set to true when spellchecking is finished
-       bool exitEarly_;
        /// current word being checked and lang code
        WordLangTuple word_;
        /// values for progress