]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/TocModel.h
Mac compile fix.
[lyx.git] / src / frontends / qt4 / TocModel.h
1 // -*- C++ -*-
2 /**
3  * \file TocModel.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef TOCMODEL_H
13 #define TOCMODEL_H
14
15 #include "qt_helpers.h"
16
17 #include <QList>
18 #include <QStandardItemModel>
19 #include <QStringList>
20
21 namespace lyx {
22
23 class Buffer;
24 class BufferView;
25 class DocIterator;
26 class Toc;
27 class TocItem;
28
29 namespace frontend {
30
31 class TocModel : public QStandardItemModel
32 {
33 public:
34         ///
35         TocModel(Toc const & toc);
36         ///
37         TocItem const & tocItem(QModelIndex const & index) const;
38         ///
39         QModelIndex modelIndex(DocIterator const & dit) const;
40         ///
41         int modelDepth() const;
42
43 private:
44         ///
45         void populate(unsigned int & index, QModelIndex const & parent);
46         ///
47         QList<QModelIndex> toc_indexes_;
48         ///
49         Toc const & toc_;
50         ///
51         int maxdepth_;
52         int mindepth_;
53 };
54
55
56 class TocModels: public QObject
57 {
58         Q_OBJECT
59 public:
60         ///
61         TocModels(): bv_(0) {}
62         ///
63         ~TocModels() { clear(); }
64         ///
65         void reset(BufferView const * bv);
66         ///
67         int depth(int type);
68         ///
69         QStandardItemModel * model(int type);
70         ///
71         QModelIndex currentIndex(int type) const;
72         ///
73         void goTo(int type, QModelIndex const & index) const;
74         ///
75         void init(Buffer const & buffer);
76         /// Test if outlining operation is possible
77         bool canOutline(int type) const;
78         /// Return the list of types available
79         QStringList const & typeNames() const { return type_names_; }
80         ///
81         void updateBackend() const;
82         ///
83         int decodeType(QString const & str) const;
84
85 Q_SIGNALS:
86         /// Signal that the internal toc_models_ has been reset.
87         void modelReset();
88
89 private:
90         ///
91         void clear();
92         ///
93         BufferView const * bv_;
94         ///
95         QList<TocModel *> models_;
96         ///
97         QStringList types_;
98         ///
99         QStringList type_names_;
100 };
101
102 } // namespace frontend
103 } // namespace lyx
104
105 #endif // TOCMODEL_H