]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDialog.h
dbc32e1a27ef80b3da1dd291cabbcda81a63103a
[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 #include <QObject>
20
21 namespace lyx {
22 namespace frontend {
23
24 /** \c Dialog collects the different parts of a Model-Controller-View
25  *  split of a generic dialog together.
26  */
27 class GuiDialog : public QDialog, public Dialog
28 {
29         Q_OBJECT
30
31 public:
32         /// \param lv is the access point for the dialog to the LyX kernel.
33         /// \param name is the identifier given to the dialog by its parent
34         /// container.
35         GuiDialog(LyXView & lv, std::string const & name);
36         //GuiDialog(GuiDialog &, docstring const &);
37
38 public Q_SLOTS:
39         // dialog closed from WM
40         void slotWMHide();
41         // Restore button clicked
42         void slotRestore();
43         // OK button clicked
44         void slotOK();
45         // Apply button clicked
46         void slotApply();
47         // Close button clicked
48         void slotClose();
49
50 public:
51         /** \name Buttons
52          *  These methods are publicly accessible because they are invoked
53          *  by the View when the user presses... guess what ;-)
54          */
55         //@{
56         void ApplyButton();
57         void OKButton();
58         void CancelButton();
59         void RestoreButton();
60         //@}
61
62         /** Check whether we may apply our data.
63          *
64          *  The buttons are disabled if not and (re-)enabled if yes.
65          */
66         void checkStatus();
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         void preShow();
78         void postShow();
79         void preUpdate();
80         void postUpdate();
81
82         ///
83         bool readOnly() const;
84
85         /// the dialog has changed contents
86         virtual void changed();
87
88         /// default: do nothing
89         virtual void applyView() {}
90         /// default: do nothing
91         virtual void update_contents() {}
92
93 protected:
94         /// Hide the dialog.
95         virtual void hideView();
96         /// Create the dialog if necessary, update it and display it.
97         virtual void showView();
98         ///
99         virtual bool isVisibleView() const;
100         /// is the dialog currently valid ?
101         virtual bool isValid();
102
103 private:
104         /// update the dialog
105         virtual void updateView();
106
107         ButtonController bc_;
108         /// are we updating ?
109         bool updating_;
110 };
111
112 } // namespace frontend
113 } // namespace lyx
114
115 #endif // GUIDIALOG_H