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 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
62 return toc_models_[type_];
66 QStandardItemModel * QToc::setTocModel(int type)
71 << "QToc: type_ " << type_
72 << " toc_models_.size() " << toc_models_.size()
75 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
76 return toc_models_[type_];
80 QModelIndex const QToc::getCurrentIndex()
82 vector<string> const & types = getTypes();
83 TocIterator const it = getCurrentTocItem(types[type_]);
85 lyxerr[Debug::GUI] << "QToc::getCurrentIndex(): TocItem is invalid!" << endl;
89 return toc_models_[type_]->modelIndex(it);
93 void QToc::goTo(QModelIndex const & index)
95 if (!index.isValid()) {
97 << "QToc::goTo(): QModelIndex is invalid!"
102 TocIterator const it = toc_models_[type_]->tocIterator(index);
105 << "QToc::goTo " << lyx::to_utf8(it->str())
108 it->goTo(kernel().lyxview());
116 QStringList type_list;
120 vector<string> const & types = getTypes();
124 string const & selected_type = toc::getType(params().getCmdName());
125 lyxerr[Debug::GUI] << "selected_type " << selected_type << endl;
128 for (size_t i = 0; i != types.size(); ++i) {
129 string const & type_str = types[i];
130 type_list.append(toqstr(getGuiName(type_str)));
131 if (type_str == selected_type)
135 << "QToc: new type " << type_str
136 << "\ttoc_models_.size() " << toc_models_.size()
139 toc_models_.push_back(new TocModel(getContents(types[i])));
141 type_model_.setStringList(type_list);
145 void QToc::updateToc(int type)
147 toc_models_[type] = new TocModel(getContents(getTypes()[type]));
151 } // namespace frontend