mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Cleanup LyXFunc::dispatch() following JMarc advice.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21797 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
27442f7c9e
commit
1133419a59
@ -197,7 +197,7 @@ bool import(LyXView * lv, FileName const & filename,
|
||||
: changeExtension(filename.absFilename(),
|
||||
formats.extension(loader_format));
|
||||
lv->view()->insertPlaintextFile(filename2, as_paragraphs);
|
||||
lv->dispatch(FuncRequest(LFUN_MARK_OFF));
|
||||
lv->dispatch(FuncRequest(LFUN_MARK_OFF), true);
|
||||
}
|
||||
|
||||
// we are done
|
||||
@ -847,35 +847,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
} else {
|
||||
switch (action) {
|
||||
|
||||
// Let the frontend dispatch its own actions.
|
||||
case LFUN_WINDOW_NEW:
|
||||
case LFUN_WINDOW_CLOSE:
|
||||
case LFUN_LYX_QUIT:
|
||||
BOOST_ASSERT(theApp());
|
||||
theApp()->dispatch(cmd);
|
||||
// Nothing more to do.
|
||||
return;
|
||||
|
||||
// Let lyx_view_ dispatch its own actions.
|
||||
case LFUN_BUFFER_SWITCH:
|
||||
case LFUN_BUFFER_NEXT:
|
||||
case LFUN_BUFFER_PREVIOUS:
|
||||
case LFUN_COMMAND_EXECUTE:
|
||||
case LFUN_DROP_LAYOUTS_CHOICE:
|
||||
case LFUN_MENU_OPEN:
|
||||
case LFUN_TOOLBAR_TOGGLE:
|
||||
case LFUN_DIALOG_UPDATE:
|
||||
case LFUN_DIALOG_TOGGLE:
|
||||
case LFUN_DIALOG_DISCONNECT_INSET:
|
||||
case LFUN_DIALOG_HIDE:
|
||||
case LFUN_DIALOG_SHOW:
|
||||
case LFUN_INSET_APPLY:
|
||||
BOOST_ASSERT(lyx_view_);
|
||||
lyx_view_->dispatch(cmd);
|
||||
if (lyx_view_->view())
|
||||
updateFlags = lyx_view_->view()->cursor().result().update();
|
||||
break;
|
||||
|
||||
case LFUN_WORD_FIND_FORWARD:
|
||||
case LFUN_WORD_FIND_BACKWARD: {
|
||||
BOOST_ASSERT(lyx_view_ && lyx_view_->view());
|
||||
@ -1844,10 +1815,29 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
default: {
|
||||
BOOST_ASSERT(theApp());
|
||||
// Let the frontend dispatch its own actions.
|
||||
if (theApp()->dispatch(cmd))
|
||||
// Nothing more to do.
|
||||
return;
|
||||
|
||||
// Let the current LyXView dispatch its own actions.
|
||||
BOOST_ASSERT(lyx_view_);
|
||||
if (lyx_view_->dispatch(cmd, false)) {
|
||||
if (lyx_view_->view())
|
||||
updateFlags = lyx_view_->view()->cursor().result().update();
|
||||
break;
|
||||
}
|
||||
|
||||
// FIXME: Probably a good idea to inverse the Cursor and BufferView
|
||||
// dispatching.
|
||||
|
||||
// Let the current Cursor dispatch its own actions.
|
||||
BOOST_ASSERT(lyx_view_->view());
|
||||
view()->cursor().dispatch(cmd);
|
||||
updateFlags = view()->cursor().result().update();
|
||||
if (!view()->cursor().result().dispatched())
|
||||
// Let the current BufferView dispatch its own actions.
|
||||
updateFlags = view()->dispatch(cmd);
|
||||
break;
|
||||
}
|
||||
@ -1868,9 +1858,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
|
||||
//Do we have a selection?
|
||||
theSelection().haveSelection(view()->cursor().selection());
|
||||
|
||||
if (view()->cursor().inTexted()) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!quitting && lyx_view_) {
|
||||
|
@ -156,7 +156,8 @@ public:
|
||||
///
|
||||
virtual FuncStatus getStatus(FuncRequest const & cmd) = 0;
|
||||
/// dispatch command.
|
||||
virtual void dispatch(FuncRequest const & cmd) = 0;
|
||||
/// \return true if the \c FuncRequest has been dispatched.
|
||||
virtual bool dispatch(FuncRequest const & cmd) = 0;
|
||||
|
||||
///
|
||||
virtual void resetGui() = 0;
|
||||
|
@ -75,7 +75,10 @@ public:
|
||||
///
|
||||
virtual FuncStatus getStatus(FuncRequest const & cmd) = 0;
|
||||
/// dispatch command.
|
||||
virtual void dispatch(FuncRequest const & cmd) = 0;
|
||||
/// \param propagate: indicate if the dispatch should be probagated to
|
||||
/// the main lyx::dispatch().
|
||||
/// \return true if the \c FuncRequest has been dispatched.
|
||||
virtual bool dispatch(FuncRequest const & cmd, bool propagate) = 0;
|
||||
|
||||
///
|
||||
virtual void restartCursor() = 0;
|
||||
|
@ -237,7 +237,7 @@ FuncStatus GuiApplication::getStatus(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
|
||||
void GuiApplication::dispatch(FuncRequest const & cmd)
|
||||
bool GuiApplication::dispatch(FuncRequest const & cmd)
|
||||
{
|
||||
switch(cmd.action) {
|
||||
|
||||
@ -281,8 +281,12 @@ void GuiApplication::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
// Notify the caller that the action has not been dispatched.
|
||||
return false;
|
||||
}
|
||||
|
||||
// The action has been dispatched.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
/// Method inherited from \c Application class
|
||||
//@{
|
||||
virtual FuncStatus getStatus(FuncRequest const &);
|
||||
virtual void dispatch(FuncRequest const &);
|
||||
virtual bool dispatch(FuncRequest const &);
|
||||
virtual void resetGui();
|
||||
virtual Clipboard & clipboard();
|
||||
virtual Selection & selection();
|
||||
|
@ -1018,7 +1018,7 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
|
||||
void GuiView::dispatch(FuncRequest const & cmd)
|
||||
bool GuiView::dispatch(FuncRequest const & cmd, bool propagate)
|
||||
{
|
||||
BufferView * bv = view();
|
||||
// By default we won't need any update.
|
||||
@ -1161,16 +1161,19 @@ void GuiView::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
default:
|
||||
theLyXFunc().setLyXView(this);
|
||||
lyx::dispatch(cmd);
|
||||
return;
|
||||
if (propagate) {
|
||||
theLyXFunc().setLyXView(this);
|
||||
lyx::dispatch(cmd);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!bv)
|
||||
return;
|
||||
bv->processUpdateFlags(bv->cursor().result().update());
|
||||
// We won't need any new update.
|
||||
bv->cursor().updateFlags(Update::None);
|
||||
if (bv) {
|
||||
bv->processUpdateFlags(bv->cursor().result().update());
|
||||
// We won't need any new update.
|
||||
bv->cursor().updateFlags(Update::None);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
void updateToolbars();
|
||||
QMenu * createPopupMenu();
|
||||
FuncStatus getStatus(FuncRequest const & cmd);
|
||||
void dispatch(FuncRequest const & cmd);
|
||||
bool dispatch(FuncRequest const & cmd, bool propagate = true);
|
||||
|
||||
///
|
||||
void setLayoutDialog(GuiLayoutBox *);
|
||||
|
Loading…
Reference in New Issue
Block a user