]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDialog.h
Compil fix.
[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         // Close button clicked or closed from WindowManager
56         void slotClose();
57         ///
58         void closeEvent(QCloseEvent * e);
59
60 public:
61         /** Check whether we may apply our data.
62          *
63          *  The buttons are disabled if not and (re-)enabled if yes.
64          */
65         void setButtonsValid(bool valid);
66
67         /** \name Dialog Components
68          *  Methods to access the various components making up a dialog.
69          */
70         //@{
71         ButtonController const & bc() const { return bc_; }
72         ButtonController & bc() { return bc_; }
73         //@}
74
75         /// the dialog has changed contents
76         virtual void changed();
77
78         virtual void enableView(bool enable);
79
80         /// default: do nothing
81         virtual void applyView() {}
82         /// default: do nothing
83         virtual void updateContents() {}
84
85 public:
86         /// is the dialog currently valid ?
87         virtual bool isValid() { return true; }
88
89 public:
90
91         /** When applying, it's useful to know whether the dialog is about
92          *  to close or not (no point refreshing the display for example).
93          */
94         bool isClosing() const { return is_closing_; }
95
96         /// Update the display of the dialog whilst it is still visible.
97         virtual void updateView();
98
99 private:
100         ButtonController bc_;
101         /// are we updating ?
102         bool updating_;
103
104         bool is_closing_;
105 };
106
107
108 } // namespace frontend
109 } // namespace lyx
110
111 #endif // GUIDIALOG_H