4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * \author Jean-Marc Lasgouttes
10 * \author Angus Leeming
11 * \author Abdelrazak Younes
13 * Full author contact details are available in file CREDITS.
21 #include <QAbstractProxyModel>
25 #include <QToolButton>
27 class QSortFilterProxyModel;
28 class QStandardItemModel;
38 class GuiCommandBuffer;
39 class GuiLayoutFilterModel;
42 class LayoutItemDelegate;
46 class GuiLayoutBox : public QComboBox
50 GuiLayoutBox(GuiToolbar * bar, GuiView &);
52 /// select the right layout in the combobox.
53 void set(docstring const & layout);
54 /// Populate the layout combobox.
55 void updateContents(bool reset);
56 /// Add Item to Layout box according to sorting settings from preferences
57 void addItemSort(docstring const & item, docstring const & category,
58 bool sorted, bool sortedByCat, bool unknown);
64 bool eventFilter(QObject * o, QEvent * e);
66 QString const & filter() { return filter_; }
70 void selected(int index);
72 void setIconSize(QSize size);
75 friend class LayoutItemDelegate;
80 void setFilter(QString const & s);
82 QString charFilterRegExp(QString const & filter);
84 void countCategories();
91 DocumentClass const * text_class_;
95 /// the layout model: 1st column translated, 2nd column raw layout name
96 QStandardItemModel * model_;
97 /// the proxy model filtering \c model_
98 GuiLayoutFilterModel * filterModel_;
99 /// the (model-) index of the last successful selection
101 /// the character filter
104 LayoutItemDelegate * layoutItemDelegate_;
106 unsigned visibleCategories_;
112 class MenuButton : public QToolButton
117 MenuButton(GuiToolbar * bar, ToolbarItem const & item,
118 bool const sticky = false);
120 void mousePressEvent(QMouseEvent * e);
126 ToolbarItem const & tbitem_;
132 void actionTriggered(QAction * action);
137 class GuiToolbar : public QToolBar
142 GuiToolbar(ToolbarInfo const &, GuiView &);
145 void setVisibility(int visibility);
147 /// Add a button to the bar.
148 void add(ToolbarItem const & item);
152 * This key must be used for any session setting.
154 QString sessionKey() const;
155 /// Save session settings.
156 void saveSession() const;
157 /// Restore session settings.
158 void restoreSession();
160 /// Refresh the contents of the bar.
161 void update(bool in_math, bool in_table, bool review,
162 bool in_mathmacrotemplate);
168 GuiCommandBuffer * commandBuffer() { return command_buffer_; }
171 Action * addItem(ToolbarItem const & item);
178 // load flags with saved values
183 void showEvent(QShowEvent *);
188 QList<Action *> actions_;
189 /// initial visibility flags
196 GuiLayoutBox * layout_;
198 GuiCommandBuffer * command_buffer_;
200 ToolbarInfo const & tbinfo_;
205 } // namespace frontend
208 #endif // GUITOOLBAR_H