]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
make LyXView almost pure virtual. Merge implementation with 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                 int maximized,
66                 unsigned int iconSizeXY,
67                 const std::string & geometryArg);
68         virtual void saveGeometry();
69         virtual void setBusy(bool);
70         /// add toolbar, if newline==true, add a toolbar break before the toolbar
71         GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
72         virtual void updateStatusBar();
73         virtual void message(docstring const & str);
74         virtual void clearMessage();
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         /// show - display the top-level window
86         void showView();
87
88         /// menu item has been selected
89         void activated(FuncRequest const &);
90
91         ///
92         QMenu * createPopupMenu();
93
94         ///
95         void addTabWorkArea();
96
97         /// dispatch to current BufferView
98         void dispatch(FuncRequest const & cmd);
99
100         /// \return the buffer currently shown in this window
101         Buffer * buffer();
102         Buffer const * buffer() const;
103         /// set a buffer to the current workarea.
104         void setBuffer(Buffer * b); ///< \c Buffer to set.
105
106 Q_SIGNALS:
107         void closing(int);
108
109 public Q_SLOTS:
110         /// idle timeout
111         void update_view_state_qt();
112
113         ///
114         void updateWindowTitle(GuiWorkArea * wa);
115
116         ///
117         void on_currentWorkAreaChanged(GuiWorkArea *);
118
119         /// slots to change the icon size
120         void smallSizedIcons();
121         void normalSizedIcons();
122         void bigSizedIcons();
123
124 private:
125         /// make sure we quit cleanly
126         virtual void closeEvent(QCloseEvent * e);
127         ///
128         virtual void resizeEvent(QResizeEvent * e);
129         ///
130         virtual void moveEvent(QMoveEvent * e);
131
132         /// \return the \c Workarea associated to \p  Buffer
133         /// \retval 0 if no \c WorkArea is found.
134         WorkArea * workArea(Buffer & buffer);
135
136         /// Add a \c WorkArea 
137         /// \return the \c Workarea associated to \p  Buffer
138         /// \retval 0 if no \c WorkArea is found.
139         WorkArea * addWorkArea(Buffer & buffer);
140         void setCurrentWorkArea(WorkArea * work_area);
141         void removeWorkArea(WorkArea * work_area);
142         WorkArea const * currentWorkArea() const;
143         WorkArea * currentWorkArea();
144
145         ///
146         void resetAutosaveTimer();
147         ///
148         void showErrorList(std::string const & error_type);
149         ///
150         void structureChanged() { updateToc(); }
151         ///
152         void connectBuffer(Buffer & buf);
153         ///
154         void disconnectBuffer();
155         ///
156         void connectBufferView(BufferView & bv);
157         ///
158         void disconnectBufferView();
159         ////
160         void showDialog(std::string const & name);
161         void showDialogWithData(std::string const & name,
162                 std::string const & data);
163         void showInsetDialog(std::string const & name,
164                 std::string const & data, Inset * inset);
165         void updateDialog(std::string const & name,
166                 std::string const & data);
167         
168         ///
169         void updateToc();
170
171         ///
172         void dragEnterEvent(QDragEnterEvent * ev);
173         ///
174         void dropEvent(QDropEvent * ev);
175
176         /// in order to catch Tab key press.
177         bool event(QEvent * e);
178         bool focusNextPrevChild(bool);
179         ///
180         QRect updateFloatingGeometry();
181         /// called on timeout
182         void autoSave();
183         ///
184         void updateEmbeddedFiles();
185
186         /// \return the current buffer view.
187         BufferView * view();
188
189         /// get access to the dialogs
190         Dialogs & getDialogs() { return *dialogs_; }
191         ///
192         Dialogs const & getDialogs() const { return *dialogs_; }
193
194         //@}
195
196         /// load a buffer into the current workarea.
197         Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
198                 bool tolastfiles = true);  ///< append to the "Open recent" menu?
199
200         /** redraw \c inset in all the BufferViews in which it is currently
201          *  visible. If successful return a pointer to the owning Buffer.
202          */
203         Buffer const * updateInset(Inset const *);
204
205
206 private:
207         ///
208         struct GuiViewPrivate;
209         GuiViewPrivate & d;
210
211         ///
212         QTimer statusbar_timer_;
213
214         /// are we quitting by the menu?
215         bool quitting_by_menu_;
216
217         ///
218         QRect floatingGeometry_;
219
220         void setIconSize(unsigned int size);
221
222         struct ToolbarSize {
223                 int top_width;
224                 int bottom_width;
225                 int left_height;
226                 int right_height;
227         };
228
229         ToolbarSize toolbarSize_;
230
231         /// auto-saving of buffers
232         Timeout * const autosave_timeout_;
233         /// dialogs for this view
234         Dialogs * dialogs_;
235 };
236
237
238 } // namespace frontend
239 } // namespace lyx
240
241 #endif // GUIVIEW_H