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"
34 QToc::QToc(Dialog & parent)
41 bool QToc::canOutline()
43 vector<string> const & types = getTypes();
45 BOOST_ASSERT(type_ >= 0 && type_ < int(types.size()));
46 return ControlToc::canOutline(types[type_]);
50 QStandardItemModel * QToc::tocModel()
53 << "QToc: type_ " << type_
54 << " toc_models_.size() " << toc_models_.size()
57 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
58 return toc_models_[type_];
62 QStandardItemModel * QToc::setTocModel(int type)
67 << "QToc: type_ " << type_
68 << " toc_models_.size() " << toc_models_.size()
71 BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
72 return toc_models_[type_];
76 QModelIndex const QToc::getCurrentIndex()
78 vector<string> const & types = getTypes();
79 toc::TocItem const item = getCurrentTocItem(types[type_]);
82 << "QToc::getCurrentIndex(): TocItem is invalid!" << endl;
86 string toc_str = item.str;
87 toc_str.erase(0, toc_str.find(' ') + 1);
89 return toc_models_[type_]->index(toc_str);
93 void QToc::goTo(QModelIndex const & index)
95 if (!index.isValid()) {
97 << "QToc::goTo(): QModelIndex is invalid!"
103 << "QToc::goTo " << toc_models_[type_]->item(index).str
106 ControlToc::goTo(toc_models_[type_]->item(index));
114 QStringList type_list;
118 vector<string> const & types = getTypes();
119 string const & selected_type = toc::getType(params().getCmdName());
120 lyxerr[Debug::GUI] << "selected_type " << selected_type << endl;
123 for (size_t i = 0; i != types.size(); ++i) {
124 string const & type_str = types[i];
125 type_list.append(toqstr(getGuiName(type_str)));
126 if (type_str == selected_type)
130 << "QToc: new type " << type_str
131 << "\ttoc_models_.size() " << toc_models_.size()
134 toc_models_.push_back(new TocModel(getContents(types[i])));
136 type_model_.setStringList(type_list);
140 void QToc::updateToc(int type)
142 vector<string> const & choice = getTypes();
144 toc_models_[type] = new TocModel(getContents(choice[type]));
148 void QToc::move(toc::OutlineOp const operation, QModelIndex & index)
150 int toc_id = toc_models_[type_]->item(index).id_;
151 string toc_str = toc_models_[type_]->item(index).str;
152 toc_str.erase(0, toc_str.find(' ') + 1);
158 << "Toc id " << toc_id
159 << " Toc str " << toc_str
162 index = toc_models_[type_]->index(toc_str);
165 } // namespace frontend