X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Finsets%2FInsetNote.cpp;h=d3c1b1e2b49938e7bf4fc4dab8d526502e1e07a2;hb=5eb7add4092708a5a0dbabf303164be624aff72f;hp=3d641a8a683b9ebf7d8f5699d10853734787fe61;hpb=b8f05bdd501b152c4fd8ce43a2f18d59db90070f;p=lyx.git diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 3d641a8a68..d3c1b1e2b4 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -27,7 +27,7 @@ #include "InsetIterator.h" #include "LaTeXFeatures.h" #include "Lexer.h" -#include "MetricsInfo.h" +#include "LyXRC.h" #include "OutputParams.h" #include "ParIterator.h" #include "TextClass.h" @@ -171,11 +171,15 @@ bool InsetNote::showInsetDialog(BufferView * bv) const void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd) { - switch (cmd.action) { + switch (cmd.action()) { case LFUN_INSET_MODIFY: + cur.recordUndoInset(ATOMIC_UNDO, this); string2params(to_utf8(cmd.argument()), params_); setButtonLabel(); + // what we really want here is a TOC update, but that means + // a full buffer update + cur.forceBufferUpdate(); break; case LFUN_INSET_DIALOG_UPDATE: @@ -192,7 +196,7 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd) bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & flag) const { - switch (cmd.action) { + switch (cmd.action()) { case LFUN_INSET_MODIFY: // disallow comment and greyed out in commands @@ -223,8 +227,8 @@ void InsetNote::addToToc(DocIterator const & cpit) Toc & toc = buffer().tocBackend().toc("note"); docstring str; str = notetranslator_loc().find(params_.type) + from_ascii(": ") - + getNewLabel(str); - toc.push_back(TocItem(pit, 0, str)); + + text().getPar(0).asString(); + toc.push_back(TocItem(pit, 0, str, toolTipText())); // Proceed with the rest of the inset. InsetCollapsable::addToToc(cpit); } @@ -351,6 +355,11 @@ docstring InsetNote::contextMenu(BufferView const &, int, int) const return from_ascii("context-note"); } +bool InsetNote::allowSpellCheck() const +{ + return (params_.type == InsetNoteParams::Greyedout || lyxrc.spellcheck_notes); +} + string InsetNote::params2string(InsetNoteParams const & params) { @@ -384,37 +393,4 @@ void InsetNote::string2params(string const & in, InsetNoteParams & params) } -bool mutateNotes(Cursor & cur, string const & source, string const & target) -{ - InsetNoteParams::Type typeSrc = notetranslator().find(source); - InsetNoteParams::Type typeTrt = notetranslator().find(target); - // syntax check of arguments - string src = notetranslator().find(typeSrc); - string trt = notetranslator().find(typeTrt); - if (src != source || trt != target) - return false; - - // did we found some conforming inset? - bool ret = false; - - cur.beginUndoGroup(); - Inset & inset = cur.buffer()->inset(); - InsetIterator it = inset_iterator_begin(inset); - InsetIterator const end = inset_iterator_end(inset); - for (; it != end; ++it) { - if (it->lyxCode() == NOTE_CODE) { - InsetNote & ins = static_cast(*it); - if (ins.params().type == typeSrc) { - cur.buffer()->undo().recordUndo(it); - FuncRequest fr(LFUN_INSET_MODIFY, "note Note " + target); - ins.dispatch(cur, fr); - ret = true; - } - } - } - cur.endUndoGroup(); - - return ret; -} - } // namespace lyx