]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/TocWidget.h
3545a44e1c9f93713dac09a5c5f330ff8a2d476d
[lyx.git] / src / frontends / qt / TocWidget.h
1 // -*- C++ -*-
2 /**
3  * \file TocWidget.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 Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef TOC_WIDGET_H
14 #define TOC_WIDGET_H
15
16 #include "ui_TocUi.h"
17
18 #include "FuncCode.h"
19
20 #include <QString>
21 #include <QWidget>
22
23 class QModelIndex;
24 class QPoint;
25 class QTimer;
26
27 namespace lyx {
28
29 class Cursor;
30 class DispatchResult;
31 class FuncRequest;
32 class FuncStatus;
33 class Inset;
34
35 namespace frontend {
36
37 class GuiView;
38
39 class TocWidget : public QWidget, public Ui::TocUi
40 {
41         Q_OBJECT
42 public:
43         ///
44         TocWidget(GuiView & gui_view, QWidget * parent = 0);
45
46         /// Initialise GUI.
47         void init(QString const & str);
48         ///
49         void doDispatch(Cursor & cur, FuncRequest const & fr, DispatchResult & dr);
50         ///send request to lyx::dispatch with proper guiview handle
51         ///(if ToC is detached current_view can be different window)
52         void sendDispatch(FuncRequest fr);
53         ///
54         bool getStatus(Cursor & cur, FuncRequest const & fr, FuncStatus & status)
55                 const;
56
57 public Q_SLOTS:
58         /// Schedule an update of the dialog, delaying expensive operations
59         void updateView();
60         /// Update completely without delay
61         void updateViewNow();
62
63 protected Q_SLOTS:
64         ///
65         void select(QModelIndex const & index);
66         ///
67         void goTo(QModelIndex const &);
68
69         void on_tocTV_activated(QModelIndex const &);
70         void on_tocTV_pressed(QModelIndex const &);
71         void on_updateTB_clicked();
72         void on_sortCB_stateChanged(int state);
73         void on_persistentCB_stateChanged(int state);
74         void on_depthSL_valueChanged(int depth);
75         void on_typeCO_currentIndexChanged(int value);
76         void on_moveUpTB_clicked();
77         void on_moveDownTB_clicked();
78         void on_moveInTB_clicked();
79         void on_moveOutTB_clicked();
80         void filterContents();
81
82         void showContextMenu(const QPoint & pos);
83
84 private Q_SLOTS:
85         /// Perform the expensive update operations
86         void finishUpdateView();
87
88 private:
89         ///
90         void enableControls(bool enable = true);
91         ///
92         bool canOutline()
93                 { return current_type_ == "tableofcontents"; }
94         /// It is not possible to have synchronous navigation in a correct
95         /// and efficient way with the label and change type because Toc::item()
96         /// does a linear search. Even when fixed, it might even not be desirable
97         /// to do so if we want to support drag&drop of labels and references.
98         bool canNavigate()
99                 { return current_type_ != "label" && current_type_ != "change"; }
100         ///
101         bool isSortable()
102                 { return current_type_ != "tableofcontents"; }
103         ///
104         void setTreeDepth(int depth);
105         ///
106         void outline(FuncCode func_code);
107         /// finds the inset that is connected to the current item,
108         /// if any, otherwise return null
109         Inset * itemInset() const;
110         ///
111         QString current_type_;
112
113         /// depth of list shown
114         int depth_;
115         /// persistence of uncollapsed nodes in toc view
116         bool persistent_;
117         ///
118         GuiView & gui_view_;
119         // Timer for scheduling expensive update operations
120         QTimer * timer_;
121 };
122
123 } // namespace frontend
124 } // namespace lyx
125
126 #endif // TOC_WIDGET_H