]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
Remove some methods from 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 <string>
21
22
23 #include <QMainWindow>
24
25 class QCloseEvent;
26 class QDragEnterEvent;
27 class QDropEvent;
28 class QMenu;
29 class QShowEvent;
30
31
32 namespace lyx {
33
34 class ToolbarInfo;
35
36 namespace frontend {
37
38 class Dialog;
39 class GuiToolbar;
40 class GuiWorkArea;
41
42 /**
43  * GuiView - Qt4 implementation of LyXView
44  *
45  * qt4-private implementation of the main LyX window.
46  *
47  * Note: a QObject emits a destroyed(QObject *) Qt signal when it
48  * is deleted. This might be useful for closing other dialogs
49  * depending on a given GuiView.
50  */
51 class GuiView : public QMainWindow, public LyXView
52 {
53         Q_OBJECT
54 public:
55         /// create a main window of the given dimensions
56         GuiView(int id);
57
58         ~GuiView();
59
60         ///
61         ///
62         int id() const { return id_; }
63         void close();
64         void setFocus();
65         void setBusy(bool);
66
67         /// add toolbar, if newline==true, add a toolbar break before the toolbar
68         GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
69         virtual void updateStatusBar();
70         virtual void message(docstring const & str);
71         virtual bool hasFocus() const;
72         void updateLayoutChoice(bool force);
73         bool isToolbarVisible(std::string const & id);
74         void updateToolbars();
75         ///
76         QMenu * createPopupMenu();
77
78         /// dispatch to current BufferView
79         void dispatch(FuncRequest const & cmd);
80
81         /// \return the buffer currently shown in this window
82         Buffer * buffer();
83         Buffer const * buffer() const;
84         /// set a buffer to the current workarea.
85         void setBuffer(Buffer * b); ///< \c Buffer to set.
86
87         /// GuiBufferDelegate.
88         ///@{
89         void resetAutosaveTimers();
90         void errors(std::string const &);
91         void structureChanged() { updateToc(); }
92         ///@}
93         
94         /// called on timeout
95         void autoSave();
96         ///
97         void updateEmbeddedFiles();
98
99         /// \return the current buffer view.
100         BufferView * view();
101
102         /// load a buffer into the current workarea.
103         Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
104                 bool tolastfiles = true);  ///< append to the "Open recent" menu?
105
106         /** redraw \c inset in all the BufferViews in which it is currently
107          *  visible. If successful return a pointer to the owning Buffer.
108          */
109         Buffer const * updateInset(Inset const *);
110         ///
111         void restartCursor();
112
113         /// \return the \c Workarea associated to \p  Buffer
114         /// \retval 0 if no \c WorkArea is found.
115         GuiWorkArea * workArea(Buffer & buffer);
116
117         /// Add a \c WorkArea 
118         /// \return the \c Workarea associated to \p  Buffer
119         /// \retval 0 if no \c WorkArea is found.
120         GuiWorkArea * addWorkArea(Buffer & buffer);
121         ///
122         void setCurrentWorkArea(GuiWorkArea * work_area);
123         ///
124         void removeWorkArea(GuiWorkArea * work_area);
125         /// return the current WorkArea (the one that has the focus).
126         GuiWorkArea const * currentWorkArea() const;
127
128 Q_SIGNALS:
129         void closing(int);
130
131 public Q_SLOTS:
132         /// idle timeout.
133         /// clear any temporary message and replace with current status.
134         void clearMessage();
135
136 private Q_SLOTS:
137         ///
138         void updateWindowTitle(GuiWorkArea * wa);
139
140         ///
141         void on_currentWorkAreaChanged(GuiWorkArea *);
142
143         /// slots to change the icon size
144         void smallSizedIcons();
145         void normalSizedIcons();
146         void bigSizedIcons();
147
148 private:
149         ///
150         void addTabWorkArea();
151
152         /// connect to signals in the given BufferView
153         void connectBufferView(BufferView & bv);
154         /// disconnect from signals in the given BufferView
155         void disconnectBufferView();
156         /// connect to signals in the given buffer
157         void connectBuffer(Buffer & buf);
158         /// disconnect from signals in the given buffer
159         void disconnectBuffer();
160         ///
161         void updateToc();
162         ///
163         void dragEnterEvent(QDragEnterEvent * ev);
164         ///
165         void dropEvent(QDropEvent * ev);
166         /// make sure we quit cleanly
167         void closeEvent(QCloseEvent * e);
168         ///
169         void showEvent(QShowEvent *);
170
171         /// in order to catch Tab key press.
172         bool event(QEvent * e);
173         bool focusNextPrevChild(bool);
174
175         ///
176         struct GuiViewPrivate;
177         GuiViewPrivate & d;
178
179 public:
180         ///
181         /// dialogs for this view
182         ///
183
184         /** Check the status of all visible dialogs and disable or reenable
185          *  them as appropriate.
186          *
187          *  Disabling is needed for example when a dialog is open and the
188          *  cursor moves to a position where the corresponding inset is not
189          *  allowed.
190          */
191         void checkStatus();
192
193         /// Hide all visible dialogs
194         void hideAll() const;
195         /// Hide any dialogs that require a buffer for them to operate
196         void hideBufferDependent() const;
197         /** Update visible, buffer-dependent dialogs
198             If the bool is true then a buffer change has occurred
199             else it is still the same buffer.
200          */
201         void updateBufferDependent(bool) const;
202
203         /** \param name == "bibtex", "citation" etc; an identifier used to
204             launch a particular dialog.
205             \param data is a string representation of the Inset contents.
206             It is often little more than the output from Inset::write.
207             It is passed to, and parsed by, the frontend dialog.
208             Several of these dialogs do not need any data,
209             so it defaults to string().
210             \param inset ownership is _not_ passed to the frontend dialog.
211             It is stored internally and used by the kernel to ascertain
212             what to do with the FuncRequest dispatched from the frontend
213             dialog on 'Apply'; should it be used to create a new inset at
214             the current cursor position or modify an existing, 'open' inset?
215         */
216         void showDialog(std::string const & name,
217                 std::string const & data, Inset * inset = 0);
218
219         /** \param name == "citation", "bibtex" etc; an identifier used
220             to update the contents of a particular dialog with \param data.
221             See the comments to 'show', above.
222         */
223         void updateDialog(std::string const & name, std::string const & data);
224
225         /// Is the dialog currently visible?
226         bool isDialogVisible(std::string const & name) const;
227
228         /** All Dialogs of the given \param name will be closed if they are
229             connected to the given \param inset.
230         */
231         void hideDialog(std::string const & name, Inset * inset);
232         ///
233         void disconnectDialog(std::string const & name);
234         ///
235         Inset * getOpenInset(std::string const & name) const;
236
237 private:
238         ///
239         Dialog * find_or_build(std::string const & name);
240         ///
241         Dialog * build(std::string const & name);
242
243         /// This view ID.
244         int id_;
245 };
246
247 } // namespace frontend
248 } // namespace lyx
249
250 #endif // GUIVIEW_H