mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
Move LFUN_NOTES_MUTATE dispatch to BufferView.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25368 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4fa59cbd9b
commit
397afb607f
@ -59,6 +59,7 @@
|
|||||||
#include "insets/InsetGraphics.h"
|
#include "insets/InsetGraphics.h"
|
||||||
#include "insets/InsetRef.h"
|
#include "insets/InsetRef.h"
|
||||||
#include "insets/InsetText.h"
|
#include "insets/InsetText.h"
|
||||||
|
#include "insets/InsetNote.h"
|
||||||
|
|
||||||
#include "frontends/alert.h"
|
#include "frontends/alert.h"
|
||||||
#include "frontends/Application.h"
|
#include "frontends/Application.h"
|
||||||
@ -864,6 +865,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
|
|||||||
case LFUN_SCREEN_RECENTER:
|
case LFUN_SCREEN_RECENTER:
|
||||||
case LFUN_BIBTEX_DATABASE_ADD:
|
case LFUN_BIBTEX_DATABASE_ADD:
|
||||||
case LFUN_BIBTEX_DATABASE_DEL:
|
case LFUN_BIBTEX_DATABASE_DEL:
|
||||||
|
case LFUN_NOTES_MUTATE:
|
||||||
case LFUN_STATISTICS:
|
case LFUN_STATISTICS:
|
||||||
flag.setEnabled(true);
|
flag.setEnabled(true);
|
||||||
break;
|
break;
|
||||||
@ -1401,6 +1403,19 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
|||||||
processUpdateFlags(Update::Force);
|
processUpdateFlags(Update::Force);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Could be rewriten using some command like forall <insetname> <command>
|
||||||
|
// once the insets refactoring is done.
|
||||||
|
case LFUN_NOTES_MUTATE: {
|
||||||
|
if (cmd.argument().empty())
|
||||||
|
break;
|
||||||
|
cur.recordUndoFullDocument();
|
||||||
|
|
||||||
|
if (mutateNotes(cur, cmd.getArg(0), cmd.getArg(1))) {
|
||||||
|
processUpdateFlags(Update::Force);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,6 @@
|
|||||||
#include "insets/InsetListings.h"
|
#include "insets/InsetListings.h"
|
||||||
#include "insets/InsetGraphics.h"
|
#include "insets/InsetGraphics.h"
|
||||||
#include "insets/InsetInclude.h"
|
#include "insets/InsetInclude.h"
|
||||||
#include "insets/InsetNote.h"
|
|
||||||
#include "insets/InsetSpace.h"
|
#include "insets/InsetSpace.h"
|
||||||
#include "insets/InsetTabular.h"
|
#include "insets/InsetTabular.h"
|
||||||
#include "insets/InsetVSpace.h"
|
#include "insets/InsetVSpace.h"
|
||||||
@ -583,7 +582,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
|||||||
case LFUN_INSET_EDIT:
|
case LFUN_INSET_EDIT:
|
||||||
case LFUN_ALL_INSETS_TOGGLE:
|
case LFUN_ALL_INSETS_TOGGLE:
|
||||||
case LFUN_GRAPHICS_GROUPS_UNIFY:
|
case LFUN_GRAPHICS_GROUPS_UNIFY:
|
||||||
case LFUN_NOTES_MUTATE:
|
|
||||||
case LFUN_BUFFER_LANGUAGE:
|
case LFUN_BUFFER_LANGUAGE:
|
||||||
case LFUN_TEXTCLASS_APPLY:
|
case LFUN_TEXTCLASS_APPLY:
|
||||||
case LFUN_TEXTCLASS_LOAD:
|
case LFUN_TEXTCLASS_LOAD:
|
||||||
@ -1416,22 +1414,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOTH GRAPHICS_GROUPS_UNIFY and NOTES_MUTATE should be in Buffer dispatch once
|
|
||||||
// view->cursor() is not needed.
|
|
||||||
// Also they could be rewriten using some command like forall <insetname> <command>
|
|
||||||
// once the insets refactoring is done.
|
|
||||||
case LFUN_NOTES_MUTATE: {
|
|
||||||
LASSERT(lyx_view_ && lyx_view_->view(), /**/);
|
|
||||||
if (argument.empty())
|
|
||||||
break;
|
|
||||||
view()->cursor().recordUndoFullDocument();
|
|
||||||
|
|
||||||
if (mutateNotes(view(), cmd.getArg(0), cmd.getArg(1))) {
|
|
||||||
updateFlags = Update::Force;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LFUN_BUFFER_LANGUAGE: {
|
case LFUN_BUFFER_LANGUAGE: {
|
||||||
LASSERT(lyx_view_, /**/);
|
LASSERT(lyx_view_, /**/);
|
||||||
Buffer & buffer = *lyx_view_->buffer();
|
Buffer & buffer = *lyx_view_->buffer();
|
||||||
|
@ -370,7 +370,7 @@ void InsetNote::string2params(string const & in, InsetNoteParams & params)
|
|||||||
params.read(lex);
|
params.read(lex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mutateNotes(lyx::BufferView * view, string const & source, string const &target)
|
bool mutateNotes(Cursor & cur, string const & source, string const &target)
|
||||||
{
|
{
|
||||||
InsetNoteParams::Type typeSrc = notetranslator().find(source);
|
InsetNoteParams::Type typeSrc = notetranslator().find(source);
|
||||||
InsetNoteParams::Type typeTrt = notetranslator().find(target);
|
InsetNoteParams::Type typeTrt = notetranslator().find(target);
|
||||||
@ -383,7 +383,7 @@ bool mutateNotes(lyx::BufferView * view, string const & source, string const &ta
|
|||||||
// did we found some conforming inset?
|
// did we found some conforming inset?
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
Inset & inset = view->buffer().inset();
|
Inset & inset = cur.buffer().inset();
|
||||||
InsetIterator it = inset_iterator_begin(inset);
|
InsetIterator it = inset_iterator_begin(inset);
|
||||||
InsetIterator const end = inset_iterator_end(inset);
|
InsetIterator const end = inset_iterator_end(inset);
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
@ -391,7 +391,7 @@ bool mutateNotes(lyx::BufferView * view, string const & source, string const &ta
|
|||||||
InsetNote & ins = static_cast<InsetNote &>(*it);
|
InsetNote & ins = static_cast<InsetNote &>(*it);
|
||||||
if (ins.params().type == typeSrc) {
|
if (ins.params().type == typeSrc) {
|
||||||
FuncRequest fr(LFUN_INSET_MODIFY, "note Note " + target);
|
FuncRequest fr(LFUN_INSET_MODIFY, "note Note " + target);
|
||||||
ins.dispatch(view->cursor(), fr);
|
ins.dispatch(cur, fr);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,13 +111,11 @@ private:
|
|||||||
InsetNoteParams params_;
|
InsetNoteParams params_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BufferView;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutate all NoteInsets of "source" type to the "target" type in the document.
|
* Mutate all NoteInsets of "source" type to the "target" type in the document.
|
||||||
* Returns true when some inset was changed.
|
* Returns true when some inset was changed.
|
||||||
*/
|
*/
|
||||||
bool mutateNotes(lyx::BufferView * view, std::string const & source, std::string const &target);
|
bool mutateNotes(lyx::Cursor & cur, std::string const & source, std::string const &target);
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user