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://www.lyx.org/trac/ticket/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);
56 void updateItem(DocIterator const & dit);
60 QAbstractItemModel * model();
62 QAbstractItemModel const * model() const;
64 void sort(bool sort_it);
66 bool isSorted() const { return is_sorted_; }
68 TocItem const & tocItem(QModelIndex const & index) const;
70 QModelIndex modelIndex(DocIterator const & dit) const;
72 int modelDepth() const;
76 void populate(unsigned int & index, QModelIndex const & parent);
78 TocTypeModel * model_;
80 QSortFilterProxyModel * sorted_model_;
92 /// A container for the different TocModels.
93 class TocModels : public QObject
100 void reset(BufferView const * bv);
102 int depth(QString const & type);
104 QAbstractItemModel * model(QString const & type);
106 QAbstractItemModel * nameModel();
108 QModelIndex currentIndex(QString const & type) const;
110 void goTo(QString const & type, QModelIndex const & index) const;
112 void init(Buffer const & buffer);
114 void updateBackend() const;
116 void updateItem(QString const & type, DocIterator const & dit);
118 void sort(QString const & type, bool sort_it);
120 bool isSorted(QString const & type) const;
121 /// the item that is currently selected
122 TocItem const currentItem(QString const & type,
123 QModelIndex const & index) const;
126 /// Signal that the internal toc_models_ has been reset.
130 typedef QHash<QString, TocModel *>::const_iterator const_iterator;
131 typedef QHash<QString, TocModel *>::iterator iterator;
135 BufferView const * bv_;
137 QHash<QString, TocModel *> models_;
139 TocTypeModel * names_;
141 QSortFilterProxyModel * names_sorted_;
144 } // namespace frontend