]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDialog.h
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiDialog.h
1 // -*- C++ -*-
2 /**
3  * \file GuiDialog.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GUIDIALOG_H
13 #define GUIDIALOG_H
14
15 #include "Dialog.h"
16 #include "ButtonController.h"
17
18 #include <QDialog>
19
20
21 namespace lyx {
22 namespace frontend {
23
24 /// Base class for historical LyX dialogs.
25 /** 
26   * \warning New dialogs should use the leaner classes \c DialogView or
27   * \c DockView depending on the intent. Eventally, old dialog should be
28   * converted to \c DialogView too.
29   */
30 class GuiDialog : public QDialog, public Dialog
31 {
32         Q_OBJECT
33
34 public:
35         /// \param lv is the access point for the dialog to the LyX kernel.
36         /// \param name is the identifier given to the dialog by its parent
37         /// container.
38         /// \param title is the window title used for decoration.
39         GuiDialog(GuiView & lv, QString const & name, QString const & title);
40
41         virtual QWidget * asQWidget() { return this; }
42         virtual QWidget const * asQWidget() const { return this; }
43
44 public Q_SLOTS:
45         /** \name Buttons
46          *  These methods are publicly accessible because they are invoked
47          *  by the View when the user presses... guess what ;-)
48          */
49         // Restore button clicked
50         void slotRestore();
51         // OK button clicked
52         void slotOK();
53         // Apply button clicked
54         void slotApply();
55         // AutoApply checkbox clicked
56         void slotAutoApply();
57         // Close button clicked or closed from WindowManager
58         void slotClose();
59         ///
60         void closeEvent(QCloseEvent * e);
61
62 public:
63         /** Check whether we may apply our data.
64          *
65          *  The buttons are disabled if not and (re-)enabled if yes.
66          */
67         void setButtonsValid(bool valid);
68
69         /** \name Dialog Components
70          *  Methods to access the various components making up a dialog.
71          */
72         //@{
73         ButtonController const & bc() const { return bc_; }
74         ButtonController & bc() { return bc_; }
75         //@}
76
77         /// the dialog has changed contents
78         virtual void changed();
79
80         virtual void enableView(bool enable);
81
82         /// default: do nothing
83         virtual void applyView() {}
84         /// default: do nothing
85         virtual void updateContents() {}
86
87 public:
88         /// is the dialog currently valid ?
89         virtual bool isValid() { return true; }
90
91 public:
92
93         /** When applying, it's useful to know whether the dialog is about
94          *  to close or not (no point refreshing the display for example).
95          */
96         bool isClosing() const { return is_closing_; }
97
98         /// Update the display of the dialog whilst it is still visible.
99         virtual void updateView();
100
101 private:
102         ButtonController bc_;
103         /// are we updating ?
104         bool updating_;
105
106         bool is_closing_;
107 };
108
109
110 } // namespace frontend
111 } // namespace lyx
112
113 #endif // GUIDIALOG_H