]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToc.h
95beb91b43655c5f57c0511f5a61585f346f9fc1
[lyx.git] / src / frontends / qt4 / GuiToc.h
1 // -*- C++ -*-
2 /**
3  * \file GuiToc.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Kalle Dalheimer
9  * \author Angus Leeming
10  * \author Abdelrazak Younes
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef GUITOC_H
16 #define GUITOC_H
17
18 #include "TocBackend.h"
19 #include "Dialog.h"
20 #include "insets/InsetCommandParams.h"
21
22 #include <QObject>
23 #include <QStandardItemModel>
24 #include <QStringListModel>
25
26 #include <vector>
27
28 namespace lyx {
29 namespace frontend {
30
31 class TocModel;
32
33 class GuiToc : public QObject, public Controller
34 {
35         Q_OBJECT
36
37 public:
38         ///
39         GuiToc(Dialog &);
40
41         ///
42         bool initialiseParams(std::string const & data);
43         ///
44         void updateView();
45         /// Test if outlining operation is possible
46         bool canOutline(int type) const;
47
48         QStandardItemModel * tocModel(int type);
49         ///
50         QModelIndex currentIndex(int type) const;
51         ///
52         void goTo(int type, QModelIndex const & index);
53         ///
54         int getType();
55         ///
56         int getTocDepth(int type);
57
58 Q_SIGNALS:
59         /// Signal that the internal toc_models_ has been reset.
60         void modelReset();
61
62 private:
63         friend class TocWidget;
64         ///
65         std::vector<TocModel *> toc_models_;
66
67         ///
68         TocList const & tocs() const;
69
70         /// Return the list of types available
71         std::vector<docstring> const & typeNames() const
72         { return type_names_; }
73
74         ///
75         int selectedType() { return selected_type_; }
76
77         /// Return the first TocItem before the cursor
78         TocIterator currentTocItem(int type) const;
79
80         /// Apply the selected outlining operation
81         void outlineUp();
82         ///
83         void outlineDown();
84         ///
85         void outlineIn();
86         ///
87         void outlineOut();
88         ///
89         void updateBackend();
90
91         std::vector<std::string> types_;
92         std::vector<docstring> type_names_;
93         int selected_type_;
94
95         /// Return the guiname from a given cmdName of the TOC param
96         docstring guiName(std::string const & type) const;
97
98         /// clean-up on hide.
99         void clearParams() { params_.clear(); }
100         ///
101         void dispatchParams();
102         ///
103         bool isBufferDependent() const { return true; }
104
105 private:
106         ///
107         InsetCommandParams params_;
108 };
109
110 } // namespace frontend
111 } // namespace lyx
112
113 #endif // GUITOC_H