]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToolbar.h
b4a4b6efbe6e839dadc6914c20d4617c8b8a2e82
[lyx.git] / src / frontends / qt4 / GuiToolbar.h
1 // -*- C++ -*-
2 /**
3  * \file GuiToolbar.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author John Levon
9  * \author Jean-Marc Lasgouttes
10  * \author Angus Leeming
11  * \author Abdelrazak Younes
12  *
13  * Full author contact details are available in file CREDITS.
14  */
15
16 #ifndef GUITOOLBAR_H
17 #define GUITOOLBAR_H
18
19 #include "Session.h"
20
21 #include <QList>
22 #include <QToolBar>
23 #include <QComboBox>
24
25 class QStandardItemModel;
26
27 namespace lyx {
28
29 class Inset;
30 class DocumentClass;
31 class ToolbarItem;
32
33 namespace frontend {
34
35 class GuiCommandBuffer;
36 class GuiFilterProxyModel;
37 class GuiView;
38 class Action;
39
40
41 class GuiLayoutBox : public QComboBox
42 {
43         Q_OBJECT
44 public:
45         GuiLayoutBox(GuiView &);
46
47         /// select the right layout in the combobox.
48         void set(docstring const & layout);
49         /// Populate the layout combobox.
50         void updateContents(bool reset);
51         /// Add Item to Layout box according to sorting settings from preferences
52         void addItemSort(docstring const & item, bool sorted);
53
54         ///
55         bool eventFilter(QObject *o, QEvent *e);
56         ///
57         QString const & filter() { return filter_; }
58
59 private Q_SLOTS:
60         ///
61         void selected(int index);
62
63 private:
64         ///
65         void resetFilter();
66         ///
67         void setFilter(QString const & s);
68
69         ///
70         GuiView & owner_;
71         ///
72         DocumentClass const * text_class_;
73         ///
74         Inset const * inset_;
75         
76         /// the layout model: 1st column translated, 2nd column raw layout name
77         QStandardItemModel * model_;
78         /// the proxy model filtering \c model_
79         GuiFilterProxyModel * filterModel_;
80         /// the (model-) index of the last successful selection
81         int lastSel_;
82         /// the character filter
83         QString filter_;
84 };
85
86
87 class GuiToolbar : public QToolBar
88 {
89         Q_OBJECT
90 public:
91         GuiToolbar(ToolbarInfo const &, GuiView &);
92
93         /// Add a button to the bar.
94         void add(ToolbarItem const & item);
95         /** update toolbar information
96         * ToolbarInfo will then be saved by session
97         */
98         void saveInfo(ToolbarSection::ToolbarInfo & info);
99         /// Refresh the contents of the bar.
100         void updateContents();
101         ///
102         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
103
104         Action * addItem(ToolbarItem const & item);
105
106 Q_SIGNALS:
107         void updated();
108
109 private:
110
111         QList<Action *> actions_;
112         GuiView & owner_;
113
114         GuiLayoutBox * layout_;
115         GuiCommandBuffer * command_buffer_;
116 };
117
118 } // namespace frontend
119 } // namespace lyx
120
121 #endif // GUITOOLBAR_H