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 "controllers/ControlToc.h"
35 QToc::QToc(Dialog & parent)
42 bool QToc::canOutline()
44 vector<string> const & types = getTypes();
49 BOOST_ASSERT(type_ >= 0 && type_ < int(types.size()));
50 return ControlToc::canOutline(types[type_]);
54 QStandardItemModel * QToc::tocModel()
57 << "QToc: type_ " << type_
58 << " toc_models_.size() " << toc_models_.size()
61 if (toc_models_.empty())
64 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
65 return toc_models_[type_];
69 QStandardItemModel * QToc::setTocModel(int type)
74 << "QToc: type_ " << type_
75 << " toc_models_.size() " << toc_models_.size()
78 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
79 return toc_models_[type_];
83 QModelIndex const QToc::getCurrentIndex()
85 vector<string> const & types = getTypes();
86 TocIterator const it = getCurrentTocItem(types[type_]);
88 lyxerr[Debug::GUI] << "QToc::getCurrentIndex(): TocItem is invalid!" << endl;
92 return toc_models_[type_]->modelIndex(it);
96 void QToc::goTo(QModelIndex const & index)
98 if (!index.isValid()) {
100 << "QToc::goTo(): QModelIndex is invalid!"
105 TocIterator const it = toc_models_[type_]->tocIterator(index);
108 << "QToc::goTo " << lyx::to_utf8(it->str())
111 it->goTo(kernel().lyxview());
119 QStringList type_list;
123 vector<string> const & types = getTypes();
125 type_model_.setStringList(type_list);
130 string const & selected_type = toc::getType(params().getCmdName());
131 lyxerr[Debug::GUI] << "selected_type " << selected_type << endl;
134 for (size_t i = 0; i != types.size(); ++i) {
135 string const & type_str = types[i];
136 type_list.append(toqstr(getGuiName(type_str)));
137 if (type_str == selected_type)
141 << "QToc: new type " << type_str
142 << "\ttoc_models_.size() " << toc_models_.size()
145 toc_models_.push_back(new TocModel(getContents(types[i])));
147 type_model_.setStringList(type_list);
151 void QToc::updateToc(int type)
153 toc_models_[type] = new TocModel(getContents(getTypes()[type]));
157 } // namespace frontend