enable = false;
break;
- // FIXME: these cases should be hidden in GuiView::getStatus().
- case LFUN_DIALOG_TOGGLE:
- case LFUN_DIALOG_SHOW:
- case LFUN_UI_TOGGLE:
- case LFUN_DIALOG_UPDATE:
- // FIXME: add special handling for about and prefs dialogs here
- // which do not depend on GuiView.
- if (lyx_view_)
- return lyx_view_->getStatus(cmd);
- else
- enable = false;
- break;
-
// FIXME optimally this should be in Text::getStatus. In such a case the flags
// are not passed when using context menu. This way it works.
case LFUN_SET_GRAPHICS_GROUP: {
break;
}
- case LFUN_TOOLBAR_TOGGLE:
- case LFUN_INSET_APPLY:
- case LFUN_BUFFER_WRITE:
- case LFUN_BUFFER_WRITE_AS:
- case LFUN_SPLIT_VIEW:
- case LFUN_CLOSE_TAB_GROUP:
- case LFUN_COMPLETION_POPUP:
- case LFUN_COMPLETION_INLINE:
- case LFUN_COMPLETION_COMPLETE:
- if (lyx_view_)
- return lyx_view_->getStatus(cmd);
- enable = false;
- break;
-
case LFUN_BUFFER_TOGGLE_READ_ONLY:
flag.setOnOff(buf->isReadonly());
break;
break;
default:
+ // Does the view know something?
+ if (!lyx_view_) {
+ enable = false;
+ break;
+ }
+ if (lyx_view_->getStatus(cmd, flag))
+ break;
+
+ // If we have a BufferView, try cursor position and
+ // then the BufferView.
if (!view()) {
enable = false;
break;
virtual void message(docstring const &) = 0;
///
- virtual FuncStatus getStatus(FuncRequest const & cmd) = 0;
+ virtual bool getStatus(FuncRequest const & cmd, FuncStatus & flag) = 0;
/// dispatch command.
/// \return true if the \c FuncRequest has been dispatched.
virtual bool dispatch(FuncRequest const & cmd) = 0;
}
-FuncStatus GuiView::getStatus(FuncRequest const & cmd)
+bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
{
- FuncStatus flag;
bool enable = true;
Buffer * buf = buffer();
}
case LFUN_INSET_APPLY: {
- if (!buf) {
- enable = false;
- break;
- }
string const name = cmd.getArg(0);
Inset * inset = getOpenInset(name);
if (inset) {
flag |= fs;
} else {
FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
- flag |= getStatus(fr);
+ flag |= lyx::getStatus(fr);
}
enable = flag.enabled();
break;
break;
default:
- if (!view()) {
- enable = false;
- break;
- }
+ return false;
}
if (!enable)
flag.enabled(false);
- return flag;
+ return true;
}
void updateLayoutList();
void updateToolbars();
QMenu * createPopupMenu();
- FuncStatus getStatus(FuncRequest const & cmd);
+ bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
bool dispatch(FuncRequest const & cmd);
///