]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
Some more cosmetics and removal of unused methods in GuiView.
[lyx.git] / src / frontends / qt4 / GuiView.h
1 // -*- C++ -*-
2 /**
3  * \file GuiView.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 Bjornes
8  * \author John Levon
9  * \author Abdelrazak Younes
10  * \author Peter Kümmel
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef GUI_VIEW_H
16 #define GUI_VIEW_H
17
18 #include "frontends/LyXView.h"
19
20 #include <QMainWindow>
21 #include <QTimer>
22
23 class QCloseEvent;
24 class QDragEnterEvent;
25 class QDropEvent;
26 class QMenu;
27
28
29 namespace lyx {
30
31 class Timeout;
32
33 namespace frontend {
34
35 class GuiToolbar;
36 class GuiWorkArea;
37
38 QWidget * mainWindow();
39
40 /**
41  * GuiView - Qt4 implementation of LyXView
42  *
43  * qt4-private implementation of the main LyX window.
44  *
45  * Note: a QObject emits a destroyed(QObject *) Qt signal when it
46  * is deleted. This might be useful for closing other dialogs
47  * depending on a given GuiView.
48  */
49 class GuiView : public QMainWindow, public LyXView
50 {
51         Q_OBJECT
52 public:
53         /// create a main window of the given dimensions
54         GuiView(int id);
55
56         ~GuiView();
57
58         virtual void init();
59         virtual void close();
60         virtual void setFocus();
61         virtual void setGeometry(
62                 unsigned int width,
63                 unsigned int height,
64                 int posx, int posy,
65                 Maximized maximized,
66                 unsigned int iconSizeXY,
67                 const std::string & geometryArg);
68         /// save the geometry state in the session manager.
69         virtual void saveGeometry();
70         virtual void setBusy(bool);
71         /// add toolbar, if newline==true, add a toolbar break before the toolbar
72         GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
73         virtual void updateStatusBar();
74         virtual void message(docstring const & str);
75         virtual bool hasFocus() const;
76         void showMiniBuffer(bool);
77         void openMenu(docstring const &);
78         void openLayoutList();
79         void updateLayoutChoice(bool force);
80         bool isToolbarVisible(std::string const & id);
81         void updateToolbars();
82         ToolbarInfo * getToolbarInfo(std::string const & name);
83         void toggleToolbarState(std::string const & name, bool allowauto);
84         ///
85         QMenu * createPopupMenu();
86
87         /// dispatch to current BufferView
88         void dispatch(FuncRequest const & cmd);
89
90         /// \return the buffer currently shown in this window
91         Buffer * buffer();
92         Buffer const * buffer() const;
93         /// set a buffer to the current workarea.
94         void setBuffer(Buffer * b); ///< \c Buffer to set.
95
96         /// GuiBufferDelegate.
97         ///@{
98         void resetAutosaveTimers();
99         void errors(std::string const &);
100         void structureChanged() { updateToc(); }
101         ///@}
102
103         ////
104         void showDialog(std::string const & name);
105         void showDialogWithData(std::string const & name,
106                 std::string const & data);
107         void showInsetDialog(std::string const & name,
108                 std::string const & data, Inset * inset);
109         void updateDialog(std::string const & name,
110                 std::string const & data);
111         
112         /// called on timeout
113         void autoSave();
114         ///
115         void updateEmbeddedFiles();
116
117         /// \return the current buffer view.
118         BufferView * view();
119
120         /// get access to the dialogs
121         Dialogs & getDialogs() { return *dialogs_; }
122         ///
123         Dialogs const & getDialogs() const { return *dialogs_; }
124
125         /// load a buffer into the current workarea.
126         Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
127                 bool tolastfiles = true);  ///< append to the "Open recent" menu?
128
129         /** redraw \c inset in all the BufferViews in which it is currently
130          *  visible. If successful return a pointer to the owning Buffer.
131          */
132         Buffer const * updateInset(Inset const *);
133         ///
134         void restartCursor();
135
136         /// \return the \c Workarea associated to \p  Buffer
137         /// \retval 0 if no \c WorkArea is found.
138         GuiWorkArea * workArea(Buffer & buffer);
139
140         /// Add a \c WorkArea 
141         /// \return the \c Workarea associated to \p  Buffer
142         /// \retval 0 if no \c WorkArea is found.
143         GuiWorkArea * addWorkArea(Buffer & buffer);
144         ///
145         void setCurrentWorkArea(GuiWorkArea * work_area);
146         ///
147         void removeWorkArea(GuiWorkArea * work_area);
148         /// return the current WorkArea (the one that has the focus).
149         GuiWorkArea const * currentWorkArea() const;
150
151 Q_SIGNALS:
152         void closing(int);
153
154 public Q_SLOTS:
155         /// idle timeout.
156         /// clear any temporary message and replace with current status.
157         void clearMessage();
158
159 private Q_SLOTS:
160         ///
161         void updateWindowTitle(GuiWorkArea * wa);
162
163         ///
164         void on_currentWorkAreaChanged(GuiWorkArea *);
165
166         /// slots to change the icon size
167         void smallSizedIcons();
168         void normalSizedIcons();
169         void bigSizedIcons();
170
171 private:
172         ///
173         void addTabWorkArea();
174
175         /// connect to signals in the given BufferView
176         void connectBufferView(BufferView & bv);
177         /// disconnect from signals in the given BufferView
178         void disconnectBufferView();
179         /// connect to signals in the given buffer
180         void connectBuffer(Buffer & buf);
181         /// disconnect from signals in the given buffer
182         void disconnectBuffer();
183         ///
184         void updateToc();
185         ///
186         void dragEnterEvent(QDragEnterEvent * ev);
187         ///
188         void dropEvent(QDropEvent * ev);
189         /// make sure we quit cleanly
190         virtual void closeEvent(QCloseEvent * e);
191         ///
192         virtual void resizeEvent(QResizeEvent * e);
193         ///
194         virtual void moveEvent(QMoveEvent * e);
195
196         /// in order to catch Tab key press.
197         bool event(QEvent * e);
198         bool focusNextPrevChild(bool);
199         ///
200         QRect updateFloatingGeometry();
201         ///
202         void setIconSize(unsigned int size);
203
204         ///
205         struct GuiViewPrivate;
206         GuiViewPrivate & d;
207
208         ///
209         QTimer statusbar_timer_;
210
211         /// are we quitting by the menu?
212         bool quitting_by_menu_;
213
214         ///
215         QRect floatingGeometry_;
216
217         struct ToolbarSize {
218                 int top_width;
219                 int bottom_width;
220                 int left_height;
221                 int right_height;
222         };
223
224         ToolbarSize toolbarSize_;
225
226         /// auto-saving of buffers
227         Timeout * const autosave_timeout_;
228         /// dialogs for this view
229         Dialogs * dialogs_;
230 };
231
232
233 } // namespace frontend
234 } // namespace lyx
235
236 #endif // GUIVIEW_H