]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiToc.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiToc.cpp
index 268f373313daa41359548acd7a4cc04b4d2f46da..787bbb7058b458efddfa609794727b95ecb02925 100644 (file)
@@ -33,7 +33,7 @@ namespace lyx {
 namespace frontend {
 
 GuiToc::GuiToc(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
-       : DockView(parent, "toc", qt_("Outline"), area, flags)
+       : DockView(parent, "toc", qt_("Outline"), area, flags), is_closing_(false)
 {
        widget_ = new TocWidget(parent, this);
        setWidget(widget_);
@@ -49,21 +49,26 @@ GuiToc::~GuiToc()
 void GuiToc::updateView()
 {
 #ifndef Q_WS_MACX
-               widget_->updateView();
-               return;
+       widget_->updateView();
+       return;
 #endif
 
-       // Special code for Mac drawer.
-       if (windowFlags() & Qt::Drawer && lyxview().isFullScreen()) {
+       widget_->updateView();
+
+       // For Mac: switch to a docked TOC in fullscreen mode.
+       // We use the features() here instead of WindowFlags because
+       // the latter are not reliable (always returns Qt::Drawer).
+       if (!(features() & DockWidgetClosable) && lyxview().isFullScreen()) {
                setWindowFlags(Qt::Widget);
                setFeatures(DockWidgetClosable);
+               // Setting features hides the dialog, see Qt's doc.
                show();
-       } else if (windowFlags() & Qt::Widget && !lyxview().isFullScreen()) {
+       } else if ((features() & DockWidgetClosable) && !lyxview().isFullScreen()) {
                setWindowFlags(Qt::Drawer);
                setFeatures(NoDockWidgetFeatures);
+               // Setting features hides the dialog, see Qt's doc.
                show();
        }
-       widget_->updateView();
 }
 
 
@@ -81,7 +86,30 @@ void GuiToc::dispatchParams()
 
 void GuiToc::enableView(bool enable)
 {
-       widget_->setEnabled(enable);
+       if (!enable)
+               // In the opposite case, updateView() will be called anyway.
+               widget_->updateView();
+}
+
+
+void GuiToc::closeEvent(QCloseEvent * /*event*/)
+{
+       is_closing_ = true;
+       ((GuiView *)parent())->updateToolbars();
+       is_closing_ = false;
+}
+
+
+void GuiToc::doDispatch(Cursor & cur, FuncRequest const & cmd)
+{
+       widget_->doDispatch(cur, cmd);
+}
+
+
+bool GuiToc::getStatus(Cursor & cur, FuncRequest const & cmd,
+       FuncStatus & status) const
+{
+       return widget_->getStatus(cur, cmd, status);
 }
 
 
@@ -100,4 +128,4 @@ Dialog * createGuiToc(GuiView & lv)
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiToc_moc.cpp"
+#include "moc_GuiToc.cpp"