]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToolbar.h
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[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 <QAbstractProxyModel>
22 #include <QComboBox>
23 #include <QList>
24 #include <QToolBar>
25
26 class QSortFilterProxyModel;
27 class QStandardItemModel;
28
29 namespace lyx {
30
31 class DocumentClass;
32 class Inset;
33 class ToolbarItem;
34
35 namespace frontend {
36
37 class Action;
38 class GuiCommandBuffer;
39 class GuiLayoutFilterModel;
40 class GuiView;
41 class LayoutItemDelegate;
42
43 class GuiLayoutBox : public QComboBox
44 {
45         Q_OBJECT
46 public:
47         GuiLayoutBox(GuiToolbar * bar, GuiView &);
48
49         /// select the right layout in the combobox.
50         void set(docstring const & layout);
51         /// Populate the layout combobox.
52         void updateContents(bool reset);
53         /// Add Item to Layout box according to sorting settings from preferences
54         void addItemSort(docstring const & item, docstring const & category,
55                 bool sorted, bool sortedByCat);
56
57         ///
58         void showPopup();
59         
60         ///
61         bool eventFilter(QObject * o, QEvent * e);
62         ///
63         QString const & filter() { return filter_; }
64
65 private Q_SLOTS:
66         ///
67         void selected(int index);
68         ///
69         void setIconSize(QSize size);
70
71 private:
72         friend class LayoutItemDelegate;
73
74         ///
75         void resetFilter();
76         ///
77         void setFilter(QString const & s);
78         ///
79         QString charFilterRegExp(QString const & filter);
80         ///
81         void countCategories();
82         
83         ///
84         GuiView & owner_;
85         ///
86         GuiToolbar * bar_;
87         ///
88         DocumentClass const * text_class_;
89         ///
90         Inset const * inset_;
91         
92         /// the layout model: 1st column translated, 2nd column raw layout name
93         QStandardItemModel * model_;
94         /// the proxy model filtering \c model_
95         GuiLayoutFilterModel * filterModel_;
96         /// the (model-) index of the last successful selection
97         int lastSel_;
98         /// the character filter
99         QString filter_;
100         ///
101         LayoutItemDelegate * layoutItemDelegate_;
102         ///
103         unsigned visibleCategories_;
104         ///
105         bool inShowPopup_;
106 };
107
108
109 class GuiToolbar : public QToolBar
110 {
111         Q_OBJECT
112 public:
113         GuiToolbar(ToolbarInfo const &, GuiView &);
114
115         /// Add a button to the bar.
116         void add(ToolbarItem const & item);
117         /** update toolbar information
118         * ToolbarInfo will then be saved by session
119         */
120         void saveInfo(ToolbarSection::ToolbarInfo & info);
121         /// Refresh the contents of the bar.
122         void updateContents();
123         ///
124         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
125
126         ///
127         Action * addItem(ToolbarItem const & item);
128
129 Q_SIGNALS:
130         ///
131         void updated();
132
133 private:
134         ///
135         QList<Action *> actions_;
136         ///
137         GuiView & owner_;
138
139         ///
140         GuiLayoutBox * layout_;
141         ///
142         GuiCommandBuffer * command_buffer_;
143 };
144
145 } // namespace frontend
146 } // namespace lyx
147
148 #endif // GUITOOLBAR_H