+
+struct SpellcheckerWidget::Private
+{
+ Private(SpellcheckerWidget * parent, DockView * dv, GuiView * gv)
+ : p(parent), dv_(dv), gv_(gv), incheck_(false), wrap_around_(false) {}
+ /// update from controller
+ void updateSuggestions(docstring_list & words);
+ /// move to next position after current word
+ void forward();
+ /// check text until next misspelled/unknown word
+ void check();
+ /// close the spell checker dialog
+ void hide() const;
+ /// make/restore a selection between from and to
+ void setSelection(DocIterator const & from, DocIterator const & to) const;
+ /// if no selection was checked:
+ /// ask the user if the check should start over
+ bool continueFromBeginning();
+ /// set the given language in language chooser
+ void setLanguage(Language const * lang);
+ /// test and set guard flag
+ bool inCheck() {
+ if (incheck_)
+ return true;
+ incheck_ = true;
+ return false;
+ }
+ void canCheck() { incheck_ = false; }
+ /// check for wrap around
+ void wrapAround(bool flag) {
+ wrap_around_ = flag;
+ if (flag) {
+ end_ = start_;
+ }
+ }
+ /// test for existing association with a document buffer
+ /// and test for already active check
+ bool disabled() {
+ return gv_->documentBufferView() == 0 || inCheck();
+ }
+ /// the cursor position of the buffer view
+ DocIterator const cursor() const;
+ /// status checks
+ bool isCurrentBuffer(DocIterator const & cursor) const;
+ bool isWrapAround(DocIterator const & cursor) const;
+ bool isWrapAround() const { return wrap_around_; }
+ bool atLastPos(DocIterator const & cursor) const;
+ /// validate the cached doc iterators
+ /// The spell checker dialog is not modal.
+ /// The user may change the buffer being checked and break the iterators.
+ void fixPositionsIfBroken();
+ ///
+ Ui::SpellcheckerUi ui;
+ ///
+ SpellcheckerWidget * p;
+ ///
+ DockView * dv_;
+ ///
+ GuiView * gv_;
+ /// current word being checked and lang code
+ WordLangTuple word_;
+ /// cursor position where spell checking starts
+ DocIterator start_;
+ /// range to spell check
+ /// for selection both are non-empty
+ /// after wrap around the start position becomes the end
+ DocIterator begin_;
+ DocIterator end_;
+ ///
+ bool incheck_;
+ ///
+ bool wrap_around_;
+};
+
+
+SpellcheckerWidget::SpellcheckerWidget(GuiView * gv, DockView * dv, QWidget * parent)
+ : QTabWidget(parent), d(new Private(this, dv, gv))