]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiToc.cpp
Add missing initialization
[lyx.git] / src / frontends / qt4 / GuiToc.cpp
index 507d0d05430dd59e702e7c17ad1213cceb999e5c..e124a468b428c48cf161d2341fa84c5633d973f2 100644 (file)
@@ -33,42 +33,18 @@ 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),
+         widget_(new TocWidget(parent, this)),
+         is_closing_(false)
 {
-       widget_ = new TocWidget(parent, this);
        setWidget(widget_);
-}
-
-
-GuiToc::~GuiToc()
-{
-       delete widget_;
+       setFocusProxy(widget_);
 }
 
 
 void GuiToc::updateView()
 {
-#ifndef Q_WS_MACX
-       widget_->updateView();
-       return;
-#endif
-
        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 ((features() & DockWidgetClosable) && !lyxview().isFullScreen()) {
-               setWindowFlags(Qt::Drawer);
-               setFeatures(NoDockWidgetFeatures);
-               // Setting features hides the dialog, see Qt's doc.
-               show();
-       }
 }
 
 
@@ -88,23 +64,38 @@ void GuiToc::enableView(bool enable)
 {
        if (!enable)
                // In the opposite case, updateView() will be called anyway.
-               widget_->updateView();
+               widget_->updateViewNow();
+}
+
+
+void GuiToc::closeEvent(QCloseEvent * /*event*/)
+{
+       is_closing_ = true;
+       static_cast<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);
 }
 
 
 Dialog * createGuiToc(GuiView & lv)
 {
-       GuiView & guiview = static_cast<GuiView &>(lv);
-#ifdef Q_WS_MACX
-       // On Mac show as a drawer at the right
-       return new GuiToc(guiview, Qt::RightDockWidgetArea, Qt::Drawer);
-#else
-       return new GuiToc(guiview);
-#endif
+       return new GuiToc(lv);
 }
 
 
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiToc_moc.cpp"
+#include "moc_GuiToc.cpp"