]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToolbar.h
Typos.
[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
34 namespace frontend {
35
36 class Action;
37 class GuiCommandBuffer;
38 class GuiLayoutFilterModel;
39 class GuiToolbar;
40 class GuiView;
41 class LayoutItemDelegate;
42 class ToolbarInfo;
43 class ToolbarItem;
44
45 class GuiLayoutBox : public QComboBox
46 {
47         Q_OBJECT
48 public:
49         GuiLayoutBox(GuiToolbar * bar, GuiView &);
50
51         /// select the right layout in the combobox.
52         void set(docstring const & layout);
53         /// Populate the layout combobox.
54         void updateContents(bool reset);
55         /// Add Item to Layout box according to sorting settings from preferences
56         void addItemSort(docstring const & item, docstring const & category,
57                 bool sorted, bool sortedByCat, bool unknown);
58
59         ///
60         void showPopup();
61         
62         ///
63         bool eventFilter(QObject * o, QEvent * e);
64         ///
65         QString const & filter() { return filter_; }
66
67 private Q_SLOTS:
68         ///
69         void selected(int index);
70         ///
71         void setIconSize(QSize size);
72
73 private:
74         friend class LayoutItemDelegate;
75
76         ///
77         void resetFilter();
78         ///
79         void setFilter(QString const & s);
80         ///
81         QString charFilterRegExp(QString const & filter);
82         ///
83         void countCategories();
84         
85         ///
86         GuiView & owner_;
87         ///
88         GuiToolbar * bar_;
89         ///
90         DocumentClass const * text_class_;
91         ///
92         Inset const * inset_;
93         
94         /// the layout model: 1st column translated, 2nd column raw layout name
95         QStandardItemModel * model_;
96         /// the proxy model filtering \c model_
97         GuiLayoutFilterModel * filterModel_;
98         /// the (model-) index of the last successful selection
99         int lastSel_;
100         /// the character filter
101         QString filter_;
102         ///
103         LayoutItemDelegate * layoutItemDelegate_;
104         ///
105         unsigned visibleCategories_;
106         ///
107         bool inShowPopup_;
108 };
109
110
111 class GuiToolbar : public QToolBar
112 {
113         Q_OBJECT
114 public:
115         ///
116         GuiToolbar(ToolbarInfo const &, GuiView &);
117
118         ///
119         void setVisibility(int visibility);
120
121         /// Add a button to the bar.
122         void add(ToolbarItem const & item);
123
124         /// Session key.
125         /**
126          * This key must be used for any session setting.
127          **/
128         QString sessionKey() const;
129         /// Save session settings.
130         void saveSession() const;
131         /// Restore session settings.
132         void restoreSession();
133
134         /// Refresh the contents of the bar.
135         void update(bool in_math, bool in_table, bool review,
136                 bool in_mathmacrotemplate);
137
138         ///
139         void toggle();
140
141         ///
142         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
143
144         ///
145         Action * addItem(ToolbarItem const & item);
146
147 Q_SIGNALS:
148         ///
149         void updated();
150
151 private:
152         // load flags with saved values
153         void initFlags();
154         ///
155         void fill();
156         ///
157         void showEvent(QShowEvent *);
158
159         ///
160         QString name_;
161         ///
162         QList<Action *> actions_;
163         /// initial visibility flags
164         int visibility_;
165         ///
166         bool allowauto_;
167         ///
168         GuiView & owner_;
169         ///
170         GuiLayoutBox * layout_;
171         ///
172         GuiCommandBuffer * command_buffer_;
173         ///
174         ToolbarInfo const & tbinfo_;
175         ///
176         bool filled_;
177 };
178
179 } // namespace frontend
180 } // namespace lyx
181
182 #endif // GUITOOLBAR_H