]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToc.cpp
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / GuiToc.cpp
1 /**
2  * \file GuiToc.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Abdelrazak Younes
8  * \author Angus Leeming
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "GuiToc.h"
16 #include "GuiView.h"
17 #include "DockView.h"
18 #include "TocWidget.h"
19 #include "qt_helpers.h"
20
21 #include "Buffer.h"
22 #include "BufferView.h"
23 #include "BufferParams.h"
24 #include "FuncRequest.h"
25
26 #include "support/debug.h"
27 #include "support/gettext.h"
28 #include "support/lassert.h"
29
30 using namespace std;
31
32 namespace lyx {
33 namespace frontend {
34
35 GuiToc::GuiToc(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
36         : DockView(parent, "toc", qt_("Outline"), area, flags), is_closing_(false)
37 {
38         widget_ = new TocWidget(parent, this);
39         setWidget(widget_);
40         setFocusProxy(widget_);
41 }
42
43
44 GuiToc::~GuiToc()
45 {
46         delete widget_;
47 }
48
49
50 void GuiToc::updateView()
51 {
52         widget_->updateView();
53         return;
54 }
55
56
57 bool GuiToc::initialiseParams(string const & data)
58 {
59         widget_->init(toqstr(data));
60         return true;
61 }
62
63
64 void GuiToc::dispatchParams()
65 {
66 }
67
68
69 void GuiToc::enableView(bool enable)
70 {
71         if (!enable)
72                 // In the opposite case, updateView() will be called anyway.
73                 widget_->updateView();
74 }
75
76
77 void GuiToc::closeEvent(QCloseEvent * /*event*/)
78 {
79         is_closing_ = true;
80         ((GuiView *)parent())->updateToolbars();
81         is_closing_ = false;
82 }
83
84
85 void GuiToc::doDispatch(Cursor & cur, FuncRequest const & cmd)
86 {
87         widget_->doDispatch(cur, cmd);
88 }
89
90
91 bool GuiToc::getStatus(Cursor & cur, FuncRequest const & cmd,
92         FuncStatus & status) const
93 {
94         return widget_->getStatus(cur, cmd, status);
95 }
96
97
98 Dialog * createGuiToc(GuiView & lv)
99 {
100         GuiToc * toc;
101 #ifdef Q_WS_MACX
102         // On Mac show at the right and floating
103         toc = new GuiToc(lv, Qt::RightDockWidgetArea);
104         toc->setFloating(true);
105 #else
106         toc = new GuiToc(lv);
107 #endif
108         return toc;
109 }
110
111
112 } // namespace frontend
113 } // namespace lyx
114
115 #include "moc_GuiToc.cpp"