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))
125 void QToc::updateType()
127 QStringList type_list;
129 vector<docstring> const & type_names = typeNames();
130 BOOST_ASSERT(!type_names.empty());
131 for (size_t i = 0; i != type_names.size(); ++i)
132 type_list.append(toqstr(type_names[i]));
134 type_model_.setStringList(type_list);
138 void QToc::updateToc()
141 TocList::const_iterator it = tocs().begin();
142 TocList::const_iterator end = tocs().end();
143 for (; it != end; ++it)
144 toc_models_.push_back(new TocModel(it->second));
148 } // namespace frontend
151 #include "QToc_moc.cpp"