]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/TocWidget.h
Use the command-alternatives sequence as defined in menus.bind
[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 <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);
43         ///
44         bool getStatus(Cursor & cur, FuncRequest const & fr, FuncStatus & status)
45                 const;
46
47 public Q_SLOTS:
48         /// Schedule an update of the dialog, delaying expensive operations
49         void updateView();
50         /// Update completely without delay
51         void updateViewNow();
52
53 protected Q_SLOTS:
54         ///
55         void select(QModelIndex const & index);
56         ///
57         void goTo(QModelIndex const &);
58
59         void on_tocTV_activated(QModelIndex const &);
60         void on_tocTV_pressed(QModelIndex const &);
61         void on_updateTB_clicked();
62         void on_sortCB_stateChanged(int state);
63         void on_persistentCB_stateChanged(int state);
64         void on_depthSL_valueChanged(int depth);
65         void on_typeCO_currentIndexChanged(int value);
66         void on_moveUpTB_clicked();
67         void on_moveDownTB_clicked();
68         void on_moveInTB_clicked();
69         void on_moveOutTB_clicked();
70         void filterContents();
71
72         void showContextMenu(const QPoint & pos);
73
74 private Q_SLOTS:
75         /// Perform the expensive update operations
76         void finishUpdateView();
77
78 private:
79         ///
80         void enableControls(bool enable = true);
81         ///
82         bool canOutline()
83                 { return current_type_ == "tableofcontents"; }
84         /// It is not possible to have synchronous navigation in a correct
85         /// and efficient way with the label and change type because Toc::item()
86         /// does a linear search. Even when fixed, it might even not be desirable
87         /// to do so if we want to support drag&drop of labels and references.
88         bool canNavigate()
89                 { return current_type_ != "label" && current_type_ != "change"; }
90         ///
91         bool isSortable()
92                 { return current_type_ != "tableofcontents"; }
93         ///
94         void setTreeDepth(int depth);
95         ///
96         void outline(FuncCode func_code);
97         /// finds the inset that is connected to the current item,
98         /// if any, otherwise return null
99         Inset * itemInset() const;
100         ///
101         QString current_type_;
102
103         /// depth of list shown
104         int depth_;
105         /// persistence of uncollapsed nodes in toc view
106         bool persistent_;
107         ///
108         GuiView & gui_view_;
109         // Timer for scheduling expensive update operations
110         QTimer * timer_;
111 };
112
113 } // namespace frontend
114 } // namespace lyx
115
116 #endif // TOC_WIDGET_H