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 int QToc::getTocDepth()
56 return toc_models_[type_]->modelDepth();
60 QStandardItemModel * QToc::tocModel()
62 if (toc_models_.empty()) {
63 lyxerr[Debug::GUI] << "QToc::tocModel(): no types available " << endl;
68 << "QToc: type_ " << type_
69 << " toc_models_.size() " << toc_models_.size()
72 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
73 return toc_models_[type_];
77 QStandardItemModel * QToc::setTocModel(int type)
82 << "QToc: type_ " << type_
83 << " toc_models_.size() " << toc_models_.size()
86 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
87 return toc_models_[type_];
91 QModelIndex const QToc::getCurrentIndex()
93 vector<string> const & types = getTypes();
94 TocIterator const it = getCurrentTocItem(types[type_]);
96 lyxerr[Debug::GUI] << "QToc::getCurrentIndex(): TocItem is invalid!" << endl;
100 return toc_models_[type_]->modelIndex(it);
104 void QToc::goTo(QModelIndex const & index)
106 if (!index.isValid()) {
108 << "QToc::goTo(): QModelIndex is invalid!"
113 TocIterator const it = toc_models_[type_]->tocIterator(index);
116 << "QToc::goTo " << lyx::to_utf8(it->str())
119 ControlToc::goTo(*it);
136 void QToc::updateType()
139 QStringList type_list;
141 vector<string> const & types = getTypes();
143 type_model_.setStringList(type_list);
145 lyxerr[Debug::GUI] << "QToc::updateType(): no types available " << endl;
149 string selected_type ;
150 if(params()["type"].empty()) //Then plain toc...
151 selected_type = params().getCmdName();
153 selected_type = to_ascii(params()["type"]);
156 for (size_t i = 0; i != types.size(); ++i) {
157 string type_str = types[i];
158 type_list.append(toqstr(getGuiName(type_str)));
159 if (type_str == selected_type)
163 << "QToc: new type " << type_str
164 << "\ttoc_models_.size() " << toc_models_.size()
168 type_model_.setStringList(type_list);
172 void QToc::updateToc()
175 vector<string> const & types = getTypes();
177 for (size_t i = 0; i != types.size(); ++i) {
179 toc_models_.push_back(new TocModel(getContents(types[i])));
185 } // namespace frontend