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 QToc::QToc(Dialog & dialog, QObject * parent)
37 : QObject(parent), ControlToc(dialog)
42 bool QToc::canOutline(int type) const
47 return ControlToc::canOutline(type);
51 int QToc::getTocDepth(int type)
55 return toc_models_[type]->modelDepth();
59 QStandardItemModel * QToc::tocModel(int type)
64 if (toc_models_.empty()) {
65 LYXERR(Debug::GUI) << "QToc::tocModel(): no types available " << endl;
70 << "QToc: 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 QToc::getCurrentIndex(int type) const
84 return toc_models_[type]->modelIndex(getCurrentTocItem(type));
88 void QToc::goTo(int type, QModelIndex const & index)
90 if (type < 0 || !index.isValid()
91 || index.model() != toc_models_[type]) {
93 << "QToc::goTo(): QModelIndex is invalid!"
98 BOOST_ASSERT(type >= 0 && type < int(toc_models_.size()));
100 TocIterator const it = toc_models_[type]->tocIterator(index);
102 LYXERR(Debug::GUI) << "QToc::goTo " << to_utf8(it->str()) << endl;
104 ControlToc::goTo(*it);
108 bool QToc::initialiseParams(std::string const & data)
110 if (!ControlToc::initialiseParams(data))
121 TocList::const_iterator it = tocs().begin();
122 TocList::const_iterator end = tocs().end();
123 for (; it != end; ++it)
124 toc_models_.push_back(new TocModel(it->second));
128 } // namespace frontend
131 #include "QToc_moc.cpp"