]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToolbar.h
refine browseRelFile in function addExtraEmbeddedFile
[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(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 private:
70         friend class LayoutItemDelegate;
71
72         ///
73         void resetFilter();
74         ///
75         void setFilter(QString const & s);
76         ///
77         QString charFilterRegExp(QString const & filter);
78         ///
79         void countCategories();
80         
81         ///
82         GuiView & owner_;
83         ///
84         DocumentClass const * text_class_;
85         ///
86         Inset const * inset_;
87         
88         /// the layout model: 1st column translated, 2nd column raw layout name
89         QStandardItemModel * model_;
90         /// the proxy model filtering \c model_
91         GuiLayoutFilterModel * filterModel_;
92         /// the (model-) index of the last successful selection
93         int lastSel_;
94         /// the character filter
95         QString filter_;
96         ///
97         LayoutItemDelegate * layoutItemDelegate_;
98         ///
99         unsigned visibleCategories_;
100         ///
101         bool inShowPopup_;
102 };
103
104
105 class GuiToolbar : public QToolBar
106 {
107         Q_OBJECT
108 public:
109         GuiToolbar(ToolbarInfo const &, GuiView &);
110
111         /// Add a button to the bar.
112         void add(ToolbarItem const & item);
113         /** update toolbar information
114         * ToolbarInfo will then be saved by session
115         */
116         void saveInfo(ToolbarSection::ToolbarInfo & info);
117         /// Refresh the contents of the bar.
118         void updateContents();
119         ///
120         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
121
122         Action * addItem(ToolbarItem const & item);
123
124 Q_SIGNALS:
125         void updated();
126
127 private:
128
129         QList<Action *> actions_;
130         GuiView & owner_;
131
132         GuiLayoutBox * layout_;
133         GuiCommandBuffer * command_buffer_;
134 };
135
136 } // namespace frontend
137 } // namespace lyx
138
139 #endif // GUITOOLBAR_H