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 ControlToc::goTo(*it);
128 void QToc::updateType()
131 QStringList type_list;
133 vector<string> const & types = getTypes();
135 type_model_.setStringList(type_list);
140 string selected_type ;
141 if(params()["type"].empty()) //Then plain toc...
142 selected_type = params().getCmdName();
144 selected_type = to_ascii(params()["type"]);
147 for (size_t i = 0; i != types.size(); ++i) {
148 string const & type_str = types[i];
149 type_list.append(toqstr(getGuiName(type_str)));
150 if (type_str == selected_type)
154 << "QToc: new type " << type_str
155 << "\ttoc_models_.size() " << toc_models_.size()
159 type_model_.setStringList(type_list);
163 void QToc::updateToc()
166 vector<string> const & types = getTypes();
168 for (size_t i = 0; i != types.size(); ++i) {
170 toc_models_.push_back(new TocModel(getContents(types[i])));
176 } // namespace frontend