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);
41 #if QT_VERSION >= 0x040600
42 void beginResetModel();
47 /// A class that adapt the TocBackend of a Buffer into standard Qt models for
48 /// GUI visualisation.
49 /// There is one TocModel per list in the TocBackend.
54 TocModel(QObject * parent);
56 void reset(Toc const & toc);
60 void updateItem(DocIterator const & dit);
64 QAbstractItemModel * model();
66 QAbstractItemModel const * model() const;
68 void sort(bool sort_it);
70 bool isSorted() const { return is_sorted_; }
72 TocItem const & tocItem(QModelIndex const & index) const;
74 QModelIndex modelIndex(DocIterator const & dit) const;
76 int modelDepth() const;
80 void populate(unsigned int & index, QModelIndex const & parent);
82 TocTypeModel * model_;
84 QSortFilterProxyModel * sorted_model_;
96 /// A container for the different TocModels.
97 class TocModels : public QObject
104 void reset(BufferView const * bv);
106 int depth(QString const & type);
108 QAbstractItemModel * model(QString const & type);
110 QAbstractItemModel * nameModel();
112 QModelIndex currentIndex(QString const & type) const;
114 void goTo(QString const & type, QModelIndex const & index) const;
116 void init(Buffer const & buffer);
118 void updateBackend() const;
120 void updateItem(QString const & type, DocIterator const & dit);
122 void sort(QString const & type, bool sort_it);
124 bool isSorted(QString const & type) const;
125 /// the item that is currently selected
126 TocItem const currentItem(QString const & type,
127 QModelIndex const & index) const;
130 /// Signal that the internal toc_models_ has been reset.
134 typedef QHash<QString, TocModel *>::const_iterator const_iterator;
135 typedef QHash<QString, TocModel *>::iterator iterator;
139 BufferView const * bv_;
141 QHash<QString, TocModel *> models_;
143 TocTypeModel * names_;
145 QSortFilterProxyModel * names_sorted_;
148 } // namespace frontend