3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
17 #include "qt_helpers.h"
21 #include "ControlToc.h"
35 GuiToc::GuiToc(LyXView & lv)
36 : GuiDialog(lv, "toc")
38 setViewTitle(_("Outline"));
39 setController(new ControlToc(*this));
41 // On Mac show as a drawer at the right
42 //setView(new DockView<GuiToc, TocWidget>(
43 // *dialog, qtoc, &gui_view, _("Outline"), Qt::RightDockWidgetArea, Qt::Drawer));
45 //setView(new DockView<GuiToc, TocWidget>(
46 // *dialog, qtoc, &gui_view, _("Outline")));
48 bc().setPolicy(ButtonPolicy::OkCancelPolicy);
52 ControlToc & GuiToc::controller() const
54 return static_cast<ControlToc &>(Dialog::controller());
58 bool GuiToc::canOutline(int type) const
63 return controller().canOutline(type);
67 int GuiToc::getTocDepth(int type)
71 return toc_models_[type]->modelDepth();
75 QStandardItemModel * GuiToc::tocModel(int type)
80 if (toc_models_.empty()) {
81 LYXERR(Debug::GUI) << "GuiToc::tocModel(): no types available " << endl;
86 << "GuiToc: type " << type
87 << " toc_models_.size() " << toc_models_.size()
90 BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
91 return toc_models_[type];
95 QModelIndex const GuiToc::getCurrentIndex(int type) const
100 // FIXME: The TocBackend infrastructure is not ready for LOF and LOT
101 // This is because a proper ParConstIterator is not constructed in
102 // InsetCaption::addToToc()
103 if(!canOutline(type))
104 return QModelIndex();
106 return toc_models_[type]->modelIndex(controller().getCurrentTocItem(type));
110 void GuiToc::goTo(int type, QModelIndex const & index)
112 if (type < 0 || !index.isValid()
113 || index.model() != toc_models_[type]) {
115 << "GuiToc::goTo(): QModelIndex is invalid!"
120 BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
122 TocIterator const it = toc_models_[type]->tocIterator(index);
124 LYXERR(Debug::GUI) << "GuiToc::goTo " << to_utf8(it->str()) << endl;
126 controller().goTo(*it);
130 bool GuiToc::initialiseParams(std::string const & data)
132 if (!controller().initialiseParams(data))
140 void GuiToc::updateView()
143 TocList::const_iterator it = controller().tocs().begin();
144 TocList::const_iterator end = controller().tocs().end();
145 for (; it != end; ++it)
146 toc_models_.push_back(new TocModel(it->second));
150 } // namespace frontend
153 #include "GuiToc_moc.cpp"