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.
18 #include "qt_helpers.h"
22 #include "controllers/ControlToc.h"
36 GuiToc::GuiToc(Dialog & dialog, QObject * parent)
37 : QObject(parent), ControlToc(dialog)
42 bool GuiToc::canOutline(int type) const
47 return ControlToc::canOutline(type);
51 int GuiToc::getTocDepth(int type)
55 return toc_models_[type]->modelDepth();
59 QStandardItemModel * GuiToc::tocModel(int type)
64 if (toc_models_.empty()) {
65 LYXERR(Debug::GUI) << "GuiToc::tocModel(): no types available " << endl;
70 << "GuiToc: type " << type
71 << " toc_models_.size() " << toc_models_.size()
74 BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
75 return toc_models_[type];
79 QModelIndex const GuiToc::getCurrentIndex(int type) const
84 // FIXME: The TocBackend infrastructure is not ready for LOF and LOT
85 // This is because a proper ParConstIterator is not constructed in
86 // InsetCaption::addToToc()
90 return toc_models_[type]->modelIndex(getCurrentTocItem(type));
94 void GuiToc::goTo(int type, QModelIndex const & index)
96 if (type < 0 || !index.isValid()
97 || index.model() != toc_models_[type]) {
99 << "GuiToc::goTo(): QModelIndex is invalid!"
104 BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
106 TocIterator const it = toc_models_[type]->tocIterator(index);
108 LYXERR(Debug::GUI) << "GuiToc::goTo " << to_utf8(it->str()) << endl;
110 ControlToc::goTo(*it);
114 bool GuiToc::initialiseParams(std::string const & data)
116 if (!ControlToc::initialiseParams(data))
124 void GuiToc::update()
127 TocList::const_iterator it = tocs().begin();
128 TocList::const_iterator end = tocs().end();
129 for (; it != end; ++it)
130 toc_models_.push_back(new TocModel(it->second));
134 } // namespace frontend
137 #include "GuiToc_moc.cpp"