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 "qt_helpers.h"
18 #include <QStandardItemModel>
20 class QSortFilterProxyModel;
32 /// A QStandardItemModel that gives access to the reset method.
33 /// This is needed in order to fix http://bugzilla.lyx.org/show_bug.cgi?id=3740
34 class TocTypeModel : public QStandardItemModel
38 TocTypeModel(QObject * parent);
43 /// A class that adapt the TocBackend of a Buffer into standard Qt models for
44 /// GUI visualisation.
45 /// There is one TocModel per list in the TocBackend.
50 TocModel(QObject * parent);
52 void reset(Toc const & toc);
58 QAbstractItemModel * model();
60 QAbstractItemModel const * model() const;
62 void sort(bool sort_it);
64 bool isSorted() const { return is_sorted_; }
66 TocItem const & tocItem(QModelIndex const & index) const;
68 QModelIndex modelIndex(DocIterator const & dit) const;
70 int modelDepth() const;
74 void populate(unsigned int & index, QModelIndex const & parent);
76 TocTypeModel * model_;
78 QSortFilterProxyModel * sorted_model_;
90 /// A container for the different TocModels.
91 class TocModels : public QObject
98 void reset(BufferView const * bv);
100 int depth(QString const & type);
102 QAbstractItemModel * model(QString const & type);
104 QAbstractItemModel * nameModel();
106 QModelIndex currentIndex(QString const & type) const;
108 void goTo(QString const & type, QModelIndex const & index) const;
110 void init(Buffer const & buffer);
112 void updateBackend() const;
114 void sort(QString const & type, bool sort_it);
116 bool isSorted(QString const & type) const;
119 /// Signal that the internal toc_models_ has been reset.
123 typedef QHash<QString, TocModel *>::const_iterator const_iterator;
124 typedef QHash<QString, TocModel *>::iterator iterator;
128 BufferView const * bv_;
130 QHash<QString, TocModel *> models_;
132 TocTypeModel * names_;
134 QSortFilterProxyModel * names_sorted_;
137 } // namespace frontend