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();
}
-void SpellcheckerWidget::on_replaceCO_highlighted(const QString & str)
+void SpellcheckerWidget::on_replaceCO_highlighted(int index)
{
+ QString const str = d->ui.replaceCO->itemText(index);
QListWidget * lw = d->ui.suggestionsLW;
if (lw->currentItem() && lw->currentItem()->text() == str)
return;
if (isCurrentBuffer(bvcur)) {
if (!begin_.empty() && !end_.empty()) {
// restore previous selection
- setSelection(begin_, end_);
+ bv->setSelection(begin_, end_);
} else {
// restore cursor position
bvcur.setCursor(start_);
}
}
-void SpellcheckerWidget::Private::setSelection(
- DocIterator const & from, DocIterator const & to) const
-{
- BufferView * bv = gv_->documentBufferView();
- DocIterator end = to;
-
- if (from.pit() != end.pit()) {
- // there are multiple paragraphs in selection
- Cursor & bvcur = bv->cursor();
- bvcur.setCursor(from);
- bvcur.clearSelection();
- bvcur.selection(true);
- bvcur.setCursor(end);
- bvcur.selection(true);
- } else {
- // FIXME LFUN
- // If we used a LFUN, dispatch would do all of this for us
- int const size = end.pos() - from.pos();
- bv->putSelectionAt(from, size, false);
- }
- bv->processUpdateFlags(Update::Force | Update::FitCursor);
-}
-
void SpellcheckerWidget::Private::forward()
{
DocIterator const from = cursor();
if (isWrapAround(cursor())) {
hide();
}
+ // If we reached the end of the document
+ // and have not yet wrapped (which was
+ // checked above), continue from beginning
+ if (cursor().pit() == cursor().lastpit()
+ && cursor().pos() == cursor().lastpos()
+ && cursor().text()->isMainText())
+ continueFromBeginning();
}
}
+void SpellcheckerWidget::on_skipAllPB_clicked()
+{
+ /// ignore all occurrences of word
+ if (d->disabled())
+ return;
+ LYXERR(Debug::GUI, "Spellchecker: skip all button");
+ if (d->word_.lang() && !d->word_.word().empty())
+ theSpellChecker()->accept(d->word_);
+ d->forward();
+ d->check();
+ d->canCheck();
+}
+
+
void SpellcheckerWidget::on_ignoreAllPB_clicked()
{
/// ignore all occurrences of word
return;
LYXERR(Debug::GUI, "Spellchecker: ignore all button");
if (d->word_.lang() && !d->word_.word().empty())
- theSpellChecker()->accept(d->word_);
+ dispatch(FuncRequest(LFUN_SPELLING_ADD_LOCAL,
+ d->word_.word() + " " + from_ascii(d->word_.lang()->lang())));
d->forward();
d->check();
d->canCheck();
}
+void SpellcheckerWidget::on_skipPB_clicked()
+{
+ /// ignore this occurrence of word
+ if (d->disabled())
+ return;
+ LYXERR(Debug::GUI, "Spellchecker: skip button");
+ d->forward();
+ d->check();
+ d->canCheck();
+}
+
+
void SpellcheckerWidget::on_ignorePB_clicked()
{
/// ignore this occurrence of word
if (d->disabled())
return;
LYXERR(Debug::GUI, "Spellchecker: ignore button");
+ dispatch(FuncRequest(LFUN_FONT_NO_SPELLCHECK));
d->forward();
d->check();
d->canCheck();
return;
setLanguage(word_lang.lang());
// mark misspelled word
- setSelection(from, to);
+ bv->setSelection(from, to);
// enable relevant widgets
updateView();
}