3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
18 #include "TocWidget.h"
19 #include "qt_helpers.h"
22 #include "BufferView.h"
23 #include "BufferParams.h"
24 #include "FuncRequest.h"
26 #include "support/debug.h"
27 #include "support/gettext.h"
28 #include "support/lassert.h"
35 GuiToc::GuiToc(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
36 : DockView(parent, "toc", qt_("Outline"), area, flags), is_closing_(false)
38 widget_ = new TocWidget(parent, this);
49 void GuiToc::updateView()
52 widget_->updateView();
56 widget_->updateView();
58 // For Mac: switch to a docked TOC in fullscreen mode.
59 // We use the features() here instead of WindowFlags because
60 // the latter are not reliable (always returns Qt::Drawer).
61 if (!(features() & DockWidgetClosable) && lyxview().isFullScreen()) {
62 setWindowFlags(Qt::Widget);
63 setFeatures(DockWidgetClosable);
64 // Setting features hides the dialog, see Qt's doc.
66 } else if ((features() & DockWidgetClosable) && !lyxview().isFullScreen()) {
67 setWindowFlags(Qt::Drawer);
68 setFeatures(NoDockWidgetFeatures);
69 // Setting features hides the dialog, see Qt's doc.
75 bool GuiToc::initialiseParams(string const & data)
77 widget_->init(toqstr(data));
82 void GuiToc::dispatchParams()
87 void GuiToc::enableView(bool enable)
90 // In the opposite case, updateView() will be called anyway.
91 widget_->updateView();
95 void GuiToc::closeEvent(QCloseEvent * /*event*/)
98 ((GuiView *)parent())->updateToolbars();
103 void GuiToc::doDispatch(Cursor & cur, FuncRequest const & cmd)
105 widget_->doDispatch(cur, cmd);
109 bool GuiToc::getStatus(Cursor & cur, FuncRequest const & cmd,
110 FuncStatus & status) const
112 return widget_->getStatus(cur, cmd, status);
116 Dialog * createGuiToc(GuiView & lv)
118 GuiView & guiview = static_cast<GuiView &>(lv);
120 // On Mac show as a drawer at the right
121 return new GuiToc(guiview, Qt::RightDockWidgetArea, Qt::Drawer);
123 return new GuiToc(guiview);
128 } // namespace frontend
131 #include "moc_GuiToc.cpp"