]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToc.h
fix memory leaks
[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                 GuiView & 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         ~GuiToc();
48
49         ///
50         bool initialiseParams(std::string const & data);
51         ///
52         void updateView();
53         /// Test if outlining operation is possible
54         bool canOutline(int type) const;
55
56         QStandardItemModel * tocModel(int type);
57         ///
58         QModelIndex currentIndex(int type) const;
59         ///
60         void goTo(int type, QModelIndex const & index);
61         ///
62         int getType();
63         ///
64         int getTocDepth(int type);
65
66 Q_SIGNALS:
67         /// Signal that the internal toc_models_ has been reset.
68         void modelReset();
69
70 private:
71         ///
72         TocWidget * widget_;
73         ///
74         std::vector<TocModel *> toc_models_;
75         ///             
76         void clearTocModels();
77
78 public:
79         ///
80         TocList const & tocs() const;
81
82         /// Return the list of types available
83         std::vector<docstring> const & typeNames() const
84         { return type_names_; }
85
86         ///
87         int selectedType() { return selected_type_; }
88
89         /// Return the first TocItem before the cursor
90         TocIterator currentTocItem(int type) const;
91
92         /// Apply the selected outlining operation
93         void outlineUp();
94         ///
95         void outlineDown();
96         ///
97         void outlineIn();
98         ///
99         void outlineOut();
100         ///
101         void updateBackend();
102
103         std::vector<std::string> types_;
104         std::vector<docstring> type_names_;
105         int selected_type_;
106
107         /// Return the guiname from a given cmdName of the TOC param
108         docstring guiName(std::string const & type) const;
109
110         /// clean-up on hide.
111         void clearParams() { params_.clear(); }
112         ///
113         void dispatchParams();
114         ///
115         bool isBufferDependent() const { return true; }
116
117 private:
118         ///
119         InsetCommandParams params_;
120 };
121
122 } // namespace frontend
123 } // namespace lyx
124
125 #endif // GUITOC_H