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;
34 /// A class that adapt the TocBackend of a Buffer into standard Qt models for
35 /// GUI visualisation.
36 /// There is one TocModel per list in the TocBackend.
41 TocModel(QObject * parent);
43 void reset(Toc const & toc);
47 void updateItem(DocIterator const & dit);
51 QAbstractItemModel * model();
53 QAbstractItemModel const * model() const;
55 void sort(bool sort_it);
57 bool isSorted() const { return is_sorted_; }
59 TocItem const & tocItem(QModelIndex const & index) const;
61 QModelIndex modelIndex(DocIterator const & dit) const;
63 int modelDepth() const;
67 void populate(unsigned int & index, QModelIndex const & parent);
69 TocTypeModel * model_;
71 QSortFilterProxyModel * sorted_model_;
83 /// A container for the different TocModels.
84 class TocModels : public QObject
91 void reset(BufferView const * bv);
93 int depth(QString const & type);
95 QAbstractItemModel * model(QString const & type);
97 QAbstractItemModel * nameModel();
99 QModelIndex currentIndex(QString const & type) const;
101 void goTo(QString const & type, QModelIndex const & index) const;
103 void init(Buffer const & buffer);
105 void updateBackend() const;
107 void updateItem(QString const & type, DocIterator const & dit);
109 void sort(QString const & type, bool sort_it);
111 bool isSorted(QString const & type) const;
112 /// the item that is currently selected
113 TocItem const currentItem(QString const & type,
114 QModelIndex const & index) const;
117 /// Signal that the internal toc_models_ has been reset.
121 typedef QHash<QString, TocModel *>::const_iterator const_iterator;
122 typedef QHash<QString, TocModel *>::iterator iterator;
126 BufferView const * bv_;
128 QHash<QString, TocModel *> models_;
130 TocTypeModel * names_;
132 QSortFilterProxyModel * names_sorted_;
135 } // namespace frontend