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, QObject * parent)
36 : QObject(parent), ControlToc(dialog)
41 bool GuiToc::canOutline(int type) const
46 return ControlToc::canOutline(type);
50 int GuiToc::getTocDepth(int type)
54 return toc_models_[type]->modelDepth();
58 QStandardItemModel * GuiToc::tocModel(int type)
63 if (toc_models_.empty()) {
64 LYXERR(Debug::GUI) << "GuiToc::tocModel(): no types available " << endl;
69 << "GuiToc: type " << type
70 << " toc_models_.size() " << toc_models_.size()
73 BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
74 return toc_models_[type];
78 QModelIndex const GuiToc::getCurrentIndex(int type) const
83 // FIXME: The TocBackend infrastructure is not ready for LOF and LOT
84 // This is because a proper ParConstIterator is not constructed in
85 // InsetCaption::addToToc()
89 return toc_models_[type]->modelIndex(getCurrentTocItem(type));
93 void GuiToc::goTo(int type, QModelIndex const & index)
95 if (type < 0 || !index.isValid()
96 || index.model() != toc_models_[type]) {
98 << "GuiToc::goTo(): QModelIndex is invalid!"
103 BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
105 TocIterator const it = toc_models_[type]->tocIterator(index);
107 LYXERR(Debug::GUI) << "GuiToc::goTo " << to_utf8(it->str()) << endl;
109 ControlToc::goTo(*it);
113 bool GuiToc::initialiseParams(std::string const & data)
115 if (!ControlToc::initialiseParams(data))
123 void GuiToc::updateView()
126 TocList::const_iterator it = tocs().begin();
127 TocList::const_iterator end = tocs().end();
128 for (; it != end; ++it)
129 toc_models_.push_back(new TocModel(it->second));
133 } // namespace frontend
136 #include "GuiToc_moc.cpp"