diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index 3ba5df32c8..528c4863e8 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -97,6 +97,13 @@ void GuiToc::doDispatch(Cursor & cur, FuncRequest const & cmd) } +bool GuiToc::getStatus(Cursor & cur, FuncRequest const & cmd, + FuncStatus & status) const +{ + return widget_->getStatus(cur, cmd, status); +} + + Dialog * createGuiToc(GuiView & lv) { GuiView & guiview = static_cast(lv); diff --git a/src/frontends/qt4/GuiToc.h b/src/frontends/qt4/GuiToc.h index efbb818f75..c7a797fb67 100644 --- a/src/frontends/qt4/GuiToc.h +++ b/src/frontends/qt4/GuiToc.h @@ -59,6 +59,8 @@ public: bool isBufferDependent() const { return true; } /// void doDispatch(Cursor & cur, FuncRequest const & fr); + /// + bool getStatus(Cursor & cur, FuncRequest const & fr, FuncStatus & fs) const; private: /// diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 3f0bb7be53..6157a09293 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1206,7 +1206,12 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) buf = 0; if (cmd.origin == FuncRequest::TOC) { - //FIXME: dispatch this to the toc + GuiToc * toc = static_cast(findOrBuild("toc", false)); + FuncStatus fs; + if (toc->getStatus(view()->cursor(), cmd, fs)) + flag |= fs; + else + flag.setEnabled(false); return true; } diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index 3387722d52..f44283ef80 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -21,6 +21,7 @@ #include "Buffer.h" #include "CutAndPaste.h" #include "FuncRequest.h" +#include "FuncStatus.h" #include "LyXFunc.h" #include "Menus.h" #include "TocBackend.h" @@ -95,7 +96,7 @@ void TocWidget::showContextMenu(const QPoint & pos) } -void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd) +Inset * TocWidget::itemInset() const { QModelIndex const & index = tocTV->currentIndex(); TocItem const & item = @@ -116,6 +117,25 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd) tmp_dit.pop_back(); inset = &tmp_dit.inset(); } + return inset; +} + + +bool TocWidget::getStatus(Cursor & cur, FuncRequest const & cmd, + FuncStatus & status) const +{ + Inset * inset = itemInset(); + + FuncRequest tmpcmd(cmd); + if (inset) + return inset->getStatus(cur, tmpcmd, status); + return false; +} + + +void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd) +{ + Inset * inset = itemInset(); FuncRequest tmpcmd(cmd); if (inset) diff --git a/src/frontends/qt4/TocWidget.h b/src/frontends/qt4/TocWidget.h index 809d4600f3..d2ca8b8375 100644 --- a/src/frontends/qt4/TocWidget.h +++ b/src/frontends/qt4/TocWidget.h @@ -36,8 +36,11 @@ public: /// Initialise GUI. void init(QString const & str); - + /// void doDispatch(Cursor & cur, FuncRequest const & fr); + /// + bool getStatus(Cursor & cur, FuncRequest const & fr, FuncStatus & status) + const; public Q_SLOTS: /// Update the display of the dialog whilst it is still visible. @@ -70,6 +73,9 @@ private: void setTreeDepth(int depth); /// void outline(int func_code); + /// finds the inset that is connected to the current item, + /// if any, otherwise return null + Inset * itemInset() const; /// QString current_type_;