4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
15 #include "TocBackend.h"
17 #include "qt_helpers.h"
19 #include <QStandardItemModel>
29 class TocModel : public QStandardItemModel
35 TocModel(Toc const & toc) { populate(toc); }
39 void populate(Toc const & toc);
41 TocIterator tocIterator(QModelIndex const & index) const;
43 QModelIndex modelIndex(TocIterator const & it) const;
45 int modelDepth() const;
49 void populate(TocIterator & it, TocIterator const & end,
50 QModelIndex const & parent);
52 typedef std::map<QModelIndex, TocIterator> TocMap;
54 typedef std::map<TocIterator, QModelIndex> ModelMap;
65 class TocModels: public QObject
70 TocModels(): bv_(0) {}
72 TocModels::~TocModels() { clear(); }
74 void reset(BufferView const * bv);
78 QStandardItemModel * model(int type);
80 QModelIndex TocModels::currentIndex(int type) const;
82 void goTo(int type, QModelIndex const & index) const;
84 void TocModels::init(Buffer const & buffer);
85 /// Test if outlining operation is possible
86 bool canOutline(int type) const;
87 /// Return the list of types available
88 QStringList const & typeNames() const { return type_names_; }
90 void updateBackend() const;
92 int decodeType(QString const & str) const;
95 /// Signal that the internal toc_models_ has been reset.
101 /// Return the guiname from a given cmdName of the TOC param
102 QString guiName(std::string const & type) const;
104 BufferView const * bv_;
106 std::vector<TocModel *> models_;
110 QStringList type_names_;
113 } // namespace frontend