]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToc.h
a308f06adea7b0c97bdebce93e5b74b0ec3aee5e
[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 "DockView.h"
19
20 #include "insets/InsetCommandParams.h"
21
22 #include "TocBackend.h"
23
24 #include <QObject>
25 #include <QStandardItemModel>
26 #include <QStringListModel>
27
28 #include <vector>
29
30 namespace lyx {
31 namespace frontend {
32
33 class TocModel;
34 class TocWidget;
35
36 class GuiToc : public DockView
37 {
38         Q_OBJECT
39
40 public:
41         ///
42         GuiToc(
43                 GuiViewBase & parent, ///< the main window where to dock.
44                 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
45                 Qt::WindowFlags flags = 0);
46
47         ///
48         bool initialiseParams(std::string const & data);
49         ///
50         void updateView();
51         /// Test if outlining operation is possible
52         bool canOutline(int type) const;
53
54         QStandardItemModel * tocModel(int type);
55         ///
56         QModelIndex currentIndex(int type) const;
57         ///
58         void goTo(int type, QModelIndex const & index);
59         ///
60         int getType();
61         ///
62         int getTocDepth(int type);
63
64 Q_SIGNALS:
65         /// Signal that the internal toc_models_ has been reset.
66         void modelReset();
67
68 private:
69         ///
70         TocWidget * widget_;
71         ///
72         std::vector<TocModel *> toc_models_;
73
74 public:
75         ///
76         TocList const & tocs() const;
77
78         /// Return the list of types available
79         std::vector<docstring> const & typeNames() const
80         { return type_names_; }
81
82         ///
83         int selectedType() { return selected_type_; }
84
85         /// Return the first TocItem before the cursor
86         TocIterator currentTocItem(int type) const;
87
88         /// Apply the selected outlining operation
89         void outlineUp();
90         ///
91         void outlineDown();
92         ///
93         void outlineIn();
94         ///
95         void outlineOut();
96         ///
97         void updateBackend();
98
99         std::vector<std::string> types_;
100         std::vector<docstring> type_names_;
101         int selected_type_;
102
103         /// Return the guiname from a given cmdName of the TOC param
104         docstring guiName(std::string const & type) const;
105
106         /// clean-up on hide.
107         void clearParams() { params_.clear(); }
108         ///
109         void dispatchParams();
110         ///
111         bool isBufferDependent() const { return true; }
112
113 private:
114         ///
115         InsetCommandParams params_;
116 };
117
118 } // namespace frontend
119 } // namespace lyx
120
121 #endif // GUITOC_H