]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiSpellchecker.h
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / GuiSpellchecker.h
index d7c8023a300e7a1fab4e608902cc4ec55ab04ce4..19186ee2117e7096a96a59d39327a42c65b0d25e 100644 (file)
  *
  * \author John Levon
  * \author Kalle Dalheimer
+ * \author Edwin Leuven
  *
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef QSPELLCHECKER_H
-#define QSPELLCHECKER_H
+#ifndef GUISPELLCHECKER_H
+#define GUISPELLCHECKER_H
 
-#include "GuiDialogView.h"
+#include "GuiDialog.h"
 #include "ui_SpellcheckerUi.h"
-
-#include <QDialog>
-#include <QCloseEvent>
+#include "Dialog.h"
+#include "WordLangTuple.h"
 
 class QListWidgetItem;
 
 namespace lyx {
-namespace frontend {
-
-class GuiSpellchecker;
-
-class GuiSpellcheckerDialog: public QDialog, public Ui::SpellcheckerUi {
-       Q_OBJECT
-public:
-       GuiSpellcheckerDialog(GuiSpellchecker * form);
-public Q_SLOTS:
-       virtual void suggestionChanged(QListWidgetItem *);
-
-protected Q_SLOTS:
-       virtual void acceptClicked();
-       virtual void addClicked();
-       virtual void replaceClicked();
-       virtual void ignoreClicked();
-       virtual void replaceChanged(const QString &);
-       virtual void reject();
 
-protected:
-       virtual void closeEvent(QCloseEvent * e);
+class SpellBase;
 
-private:
-       GuiSpellchecker * form_;
-};
-
-
-class ControlSpellchecker;
+namespace frontend {
 
-class GuiSpellchecker
-       : public QController<ControlSpellchecker, GuiView<GuiSpellcheckerDialog> >
+class GuiSpellchecker : public GuiDialog, public Ui::SpellcheckerUi
 {
+       Q_OBJECT
+
 public:
-       friend class GuiSpellcheckerDialog;
+       GuiSpellchecker(GuiView & lv);
+       ~GuiSpellchecker();
 
-       GuiSpellchecker(Dialog &);
+public Q_SLOTS:
+       void suggestionChanged(QListWidgetItem *);
 
-       /// update from controller
-       void partialUpdate(int id);
-private:
+private Q_SLOTS:
        void accept();
        void add();
        void ignore();
        void replace();
+       void replaceChanged(const QString &);
+       void reject();
+
+private:
+       /// update from controller
+       void partialUpdate(int id);
+       ///
+       void updateContents();
+
+       ///
+       enum State {
+               SPELL_PROGRESSED, //< update progress bar
+               SPELL_FOUND_WORD //< found a bad word
+       };
 
-       /// Apply changes
-       virtual void apply() {}
        ///
-       virtual void update_contents();
-       /// build the dialog
-       virtual void build_dialog();
+       bool initialiseParams(std::string const & data);
+       ///
+       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 &);
+
+       /// replace all occurances of word
+       void replaceAll(docstring const &);
+       /// insert word in personal dictionary
+       void insert();
+       /// ignore all occurances of word
+       void ignoreAll();
+       /// check text until next misspelled/unknown word
+       /// returns true when finished
+       void check();
+       /// get suggestion
+       docstring getSuggestion() const;
+       /// get word
+       docstring getWord() const;
+       /// returns progress value
+       int getProgress() const { return oldval_; }
+       /// returns word count
+       int getCount() const { return count_; }
+       /// give error message is spellchecker dies
+       bool checkAlive();
+       /// 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
+       int oldval_;
+       int newvalue_;
+       /// word count
+       int count_;
+       /// The actual spellchecker object
+       SpellBase * speller_;
 };
 
 } // namespace frontend
 } // namespace lyx
 
-#endif // QSPELLCHECKER_H
+#endif // GUISPELLCHECKER_H