]> git.lyx.org Git - features.git/blob - src/frontends/qt4/GuiToolbar.h
* rich text item delegate to draw the layout filter as underline
[features.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 FilterItemDelegate;
36 class GuiCommandBuffer;
37 class GuiFilterProxyModel;
38 class GuiView;
39 class Action;
40
41
42 class GuiLayoutBox : public QComboBox
43 {
44         Q_OBJECT
45 public:
46         GuiLayoutBox(GuiView &);
47
48         /// select the right layout in the combobox.
49         void set(docstring const & layout);
50         /// Populate the layout combobox.
51         void updateContents(bool reset);
52         /// Add Item to Layout box according to sorting settings from preferences
53         void addItemSort(docstring const & item, bool sorted);
54
55         ///
56         bool eventFilter(QObject * o, QEvent * e);
57         ///
58         QString const & filter() { return filter_; }
59
60 private Q_SLOTS:
61         ///
62         void selected(int index);
63
64 private:
65         ///
66         void resetFilter();
67         ///
68         void setFilter(QString const & s);
69
70         ///
71         GuiView & owner_;
72         ///
73         DocumentClass const * text_class_;
74         ///
75         Inset const * inset_;
76         
77         /// the layout model: 1st column translated, 2nd column raw layout name
78         QStandardItemModel * model_;
79         /// the proxy model filtering \c model_
80         GuiFilterProxyModel * filterModel_;
81         /// the (model-) index of the last successful selection
82         int lastSel_;
83         /// the character filter
84         QString filter_;
85         ///
86         FilterItemDelegate * filterItemDelegate_;
87 };
88
89
90 class GuiToolbar : public QToolBar
91 {
92         Q_OBJECT
93 public:
94         GuiToolbar(ToolbarInfo const &, GuiView &);
95
96         /// Add a button to the bar.
97         void add(ToolbarItem const & item);
98         /** update toolbar information
99         * ToolbarInfo will then be saved by session
100         */
101         void saveInfo(ToolbarSection::ToolbarInfo & info);
102         /// Refresh the contents of the bar.
103         void updateContents();
104         ///
105         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
106
107         Action * addItem(ToolbarItem const & item);
108
109 Q_SIGNALS:
110         void updated();
111
112 private:
113
114         QList<Action *> actions_;
115         GuiView & owner_;
116
117         GuiLayoutBox * layout_;
118         GuiCommandBuffer * command_buffer_;
119 };
120
121 } // namespace frontend
122 } // namespace lyx
123
124 #endif // GUITOOLBAR_H