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(Dialog & dialog)
39 // On Mac show as a drawer at the right
40 //setView(new DockView<GuiToc, TocWidget>(
41 // *dialog, qtoc, &gui_view, _("Outline"), Qt::RightDockWidgetArea, Qt::Drawer));
43 //setView(new DockView<GuiToc, TocWidget>(
44 // *dialog, qtoc, &gui_view, _("Outline")));
49 bool GuiToc::canOutline(int type) const
54 return canOutline(type);
58 int GuiToc::getTocDepth(int type)
62 return toc_models_[type]->modelDepth();
66 QStandardItemModel * GuiToc::tocModel(int type)
71 if (toc_models_.empty()) {
72 LYXERR(Debug::GUI) << "GuiToc::tocModel(): no types available " << endl;
77 << "GuiToc: type " << type
78 << " toc_models_.size() " << toc_models_.size()
81 BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
82 return toc_models_[type];
86 QModelIndex const GuiToc::getCurrentIndex(int type) const
91 // FIXME: The TocBackend infrastructure is not ready for LOF and LOT
92 // This is because a proper ParConstIterator is not constructed in
93 // InsetCaption::addToToc()
97 return toc_models_[type]->modelIndex(getCurrentTocItem(type));
101 void GuiToc::goTo(int type, QModelIndex const & index)
103 if (type < 0 || !index.isValid()
104 || index.model() != toc_models_[type]) {
106 << "GuiToc::goTo(): QModelIndex is invalid!"
111 BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
113 TocIterator const it = toc_models_[type]->tocIterator(index);
115 LYXERR(Debug::GUI) << "GuiToc::goTo " << to_utf8(it->str()) << endl;
117 ControlToc::goTo(*it);
121 bool GuiToc::initialiseParams(std::string const & data)
123 if (!ControlToc::initialiseParams(data))
131 void GuiToc::updateView()
134 TocList::const_iterator it = tocs().begin();
135 TocList::const_iterator end = tocs().end();
136 for (; it != end; ++it)
137 toc_models_.push_back(new TocModel(it->second));
141 } // namespace frontend
144 #include "GuiToc_moc.cpp"