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