]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToolbar.h
do what the FIXME suggested
[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 <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         void showPopup();
57         
58         ///
59         bool eventFilter(QObject * o, QEvent * e);
60         ///
61         QString const & filter() { return filter_; }
62
63 private Q_SLOTS:
64         ///
65         void selected(int index);
66
67 private:
68         ///
69         void resetFilter();
70         ///
71         void setFilter(QString const & s);
72
73         ///
74         GuiView & owner_;
75         ///
76         DocumentClass const * text_class_;
77         ///
78         Inset const * inset_;
79         
80         /// the layout model: 1st column translated, 2nd column raw layout name
81         QStandardItemModel * model_;
82         /// the proxy model filtering \c model_
83         GuiFilterProxyModel * filterModel_;
84         /// the (model-) index of the last successful selection
85         int lastSel_;
86         /// the character filter
87         QString filter_;
88         ///
89         FilterItemDelegate * filterItemDelegate_;
90 };
91
92
93 class GuiToolbar : public QToolBar
94 {
95         Q_OBJECT
96 public:
97         GuiToolbar(ToolbarInfo const &, GuiView &);
98
99         /// Add a button to the bar.
100         void add(ToolbarItem const & item);
101         /** update toolbar information
102         * ToolbarInfo will then be saved by session
103         */
104         void saveInfo(ToolbarSection::ToolbarInfo & info);
105         /// Refresh the contents of the bar.
106         void updateContents();
107         ///
108         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
109
110         Action * addItem(ToolbarItem const & item);
111
112 Q_SIGNALS:
113         void updated();
114
115 private:
116
117         QList<Action *> actions_;
118         GuiView & owner_;
119
120         GuiLayoutBox * layout_;
121         GuiCommandBuffer * command_buffer_;
122 };
123
124 } // namespace frontend
125 } // namespace lyx
126
127 #endif // GUITOOLBAR_H