]> git.lyx.org Git - features.git/blob - src/frontends/qt4/GuiToolbar.h
a bunch of toolbar related renaming.
[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 <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);
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         GuiToolbar(ToolbarInfo const &, GuiView &);
116
117         /// Add a button to the bar.
118         void add(ToolbarItem const & item);
119         /** update toolbar information
120         * ToolbarInfo will then be saved by session
121         */
122         void saveInfo(ToolbarSection::ToolbarInfo & info);
123         /// Refresh the contents of the bar.
124         void updateContents();
125         ///
126         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
127
128         ///
129         Action * addItem(ToolbarItem const & item);
130
131 Q_SIGNALS:
132         ///
133         void updated();
134
135 private:
136         ///
137         QList<Action *> actions_;
138         ///
139         GuiView & owner_;
140
141         ///
142         GuiLayoutBox * layout_;
143         ///
144         GuiCommandBuffer * command_buffer_;
145 };
146
147 } // namespace frontend
148 } // namespace lyx
149
150 #endif // GUITOOLBAR_H