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 void QToc::goTo(QModelIndex const & index)
78 if (!index.isValid()) {
80 << "QToc::goTo(): QModelIndex is invalid!"
86 << "QToc::goTo " << toc_models_[type_]->item(index).str
89 ControlToc::goTo(toc_models_[type_]->item(index));
97 QStringList type_list;
101 vector<string> const & types = getTypes();
102 string const & selected_type = toc::getType(params().getCmdName());
103 lyxerr[Debug::GUI] << "selected_type " << selected_type << endl;
106 for (size_t i = 0; i != types.size(); ++i) {
107 string const & type_str = types[i];
108 type_list.append(toqstr(getGuiName(type_str)));
109 if (type_str == selected_type)
113 << "QToc: new type " << type_str
114 << "\ttoc_models_.size() " << toc_models_.size()
117 toc_models_.push_back(new TocModel(getContents(types[i])));
119 type_model_.setStringList(type_list);
123 void QToc::updateToc(int type)
125 vector<string> const & choice = getTypes();
127 toc_models_[type] = new TocModel(getContents(choice[type]));
131 void QToc::move(toc::OutlineOp const operation, QModelIndex & index)
133 int toc_id = toc_models_[type_]->item(index).id_;
134 string toc_str = toc_models_[type_]->item(index).str;
135 toc_str.erase(0, toc_str.find(' ') + 1);
141 << "Toc id " << toc_id
142 << " Toc str " << toc_str
145 index = toc_models_[type_]->index(toc_str);
148 } // namespace frontend