+
+void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
+{
+ if (!bv)
+ return;
+ WordLangTuple wl;
+ docstring_list suggestions;
+ pos_type from = bv->cursor().pos();
+ pos_type to = from;
+ Paragraph const & par = bv->cursor().paragraph();
+ if (!par.spellCheck(from, to, wl, suggestions))
+ return;
+ LYXERR(Debug::GUI, "Misspelled Word! Suggested Words = ");
+ size_t i = 0;
+ MenuItem item(MenuItem::Submenu, qt_("More Spelling Suggestions"));
+ item.setSubmenu(MenuDefinition(qt_("More Spelling Suggestions")));
+ for (; i != suggestions.size(); ++i) {
+ docstring const & suggestion = suggestions[i];
+ LYXERR(Debug::GUI, suggestion);
+ MenuItem w(MenuItem::Command, toqstr(suggestion),
+ FuncRequest(LFUN_WORD_REPLACE, suggestion));
+ if (i < 10)
+ add(w);
+ else
+ item.submenu().add(w);
+ }
+ if (i >= 10)
+ add(item);
+ if (i > 0)
+ add(MenuItem(MenuItem::Separator));
+ docstring arg = wl.word() + " " + from_ascii(wl.lang_code());
+ if (!wl.lang_variety().empty())
+ arg += from_ascii("-") + from_ascii(wl.lang_variety());
+ add(MenuItem(MenuItem::Command, qt_("Add to personal dictionary|c"),
+ FuncRequest(LFUN_SPELLING_ADD, arg)));
+ add(MenuItem(MenuItem::Command, qt_("Ignore all|I"),
+ FuncRequest(LFUN_SPELLING_IGNORE, arg)));
+
+}
+
+