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();
46 BOOST_ASSERT(type_ >= 0 && type_ < int(types.size()));
47 return ControlToc::canOutline(types[type_]);
51 QStandardItemModel * QToc::tocModel()
54 << "QToc: type_ " << type_
55 << " toc_models_.size() " << toc_models_.size()
58 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
59 return toc_models_[type_];
63 QStandardItemModel * QToc::setTocModel(int type)
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 QModelIndex const QToc::getCurrentIndex()
79 vector<string> const & types = getTypes();
80 TocIterator const it = getCurrentTocItem(types[type_]);
82 lyxerr[Debug::GUI] << "QToc::getCurrentIndex(): TocItem is invalid!" << endl;
86 return toc_models_[type_]->modelIndex(it);
90 void QToc::goTo(QModelIndex const & index)
92 if (!index.isValid()) {
94 << "QToc::goTo(): QModelIndex is invalid!"
99 TocIterator const it = toc_models_[type_]->tocIterator(index);
102 << "QToc::goTo " << it->str()
105 it->goTo(kernel().lyxview());
113 QStringList type_list;
117 vector<string> const & types = getTypes();
118 string const & selected_type = toc::getType(params().getCmdName());
119 lyxerr[Debug::GUI] << "selected_type " << selected_type << endl;
122 for (size_t i = 0; i != types.size(); ++i) {
123 string const & type_str = types[i];
124 type_list.append(toqstr(getGuiName(type_str)));
125 if (type_str == selected_type)
129 << "QToc: new type " << type_str
130 << "\ttoc_models_.size() " << toc_models_.size()
133 toc_models_.push_back(new TocModel(getContents(types[i])));
135 type_model_.setStringList(type_list);
139 void QToc::updateToc(int type)
141 toc_models_[type] = new TocModel(getContents(getTypes()[type]));
145 } // namespace frontend