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()
63 << "QToc: type_ " << type_
64 << " toc_models_.size() " << toc_models_.size()
67 if (toc_models_.empty())
70 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
71 return toc_models_[type_];
75 QStandardItemModel * QToc::setTocModel(int type)
80 << "QToc: type_ " << type_
81 << " toc_models_.size() " << toc_models_.size()
84 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
85 return toc_models_[type_];
89 QModelIndex const QToc::getCurrentIndex()
91 vector<string> const & types = getTypes();
92 TocIterator const it = getCurrentTocItem(types[type_]);
94 lyxerr[Debug::GUI] << "QToc::getCurrentIndex(): TocItem is invalid!" << endl;
98 return toc_models_[type_]->modelIndex(it);
102 void QToc::goTo(QModelIndex const & index)
104 if (!index.isValid()) {
106 << "QToc::goTo(): QModelIndex is invalid!"
111 TocIterator const it = toc_models_[type_]->tocIterator(index);
114 << "QToc::goTo " << lyx::to_utf8(it->str())
117 ControlToc::goTo(*it);
134 void QToc::updateType()
137 QStringList type_list;
139 vector<string> const & types = getTypes();
141 type_model_.setStringList(type_list);
146 string selected_type ;
147 if(params()["type"].empty()) //Then plain toc...
148 selected_type = params().getCmdName();
150 selected_type = to_ascii(params()["type"]);
153 for (size_t i = 0; i != types.size(); ++i) {
154 string const & type_str = types[i];
155 type_list.append(toqstr(getGuiName(type_str)));
156 if (type_str == selected_type)
160 << "QToc: new type " << type_str
161 << "\ttoc_models_.size() " << toc_models_.size()
165 type_model_.setStringList(type_list);
169 void QToc::updateToc()
172 vector<string> const & types = getTypes();
174 for (size_t i = 0; i != types.size(); ++i) {
176 toc_models_.push_back(new TocModel(getContents(types[i])));
182 } // namespace frontend