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 & parent)
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);
103 << "QToc::goTo " << lyx::to_utf8(it->str())
106 ControlToc::goTo(*it);
118 void QToc::updateType()
120 QStringList type_list;
122 vector<docstring> const & type_names = typeNames();
123 BOOST_ASSERT(!type_names.empty());
124 for (size_t i = 0; i != type_names.size(); ++i)
125 type_list.append(toqstr(type_names[i]));
127 type_model_.setStringList(type_list);
131 void QToc::updateToc()
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 "QToc_moc.cpp"