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