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