]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDialogView.h
renaming of some methods that hurt the eyes + removal of:
[lyx.git] / src / frontends / qt4 / GuiDialogView.h
1 // -*- C++ -*-
2 /**
3  * \file GuiDialogView.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 GUIDIALOGVIEW_H
13 #define GUIDIALOGVIEW_H
14
15 #include "GuiDialog.h"
16
17 #include <boost/scoped_ptr.hpp>
18
19 #include <QApplication>
20 #include <QWidget>
21 #include <QObject>
22
23 namespace lyx {
24 namespace frontend {
25
26 /** This class is an Qt2 GUI base class.
27  */
28 class GuiDialogView : public QObject, public Dialog::View
29 {
30         Q_OBJECT
31 public:
32         ///
33         GuiDialogView(GuiDialog &, docstring const &);
34         ///
35         virtual ~GuiDialogView() {}
36         ///
37         bool readOnly() const;
38
39         /// the dialog has changed contents
40         virtual void changed();
41
42         ///
43         ButtonController & bc();
44
45 protected:
46         /// build the actual dialog
47         virtual void build_dialog() = 0;
48         /// Build the dialog
49         virtual void build();
50         /// Hide the dialog.
51         virtual void hideView();
52         /// Create the dialog if necessary, update it and display it.
53         virtual void showView();
54         /// update the dialog's contents
55         virtual void update_contents() = 0;
56         ///
57         virtual bool isVisibleView() const;
58         /// is the dialog currently valid ?
59         virtual bool isValid();
60
61         /// are we updating ?
62         bool updating_;
63         ///
64         GuiDialog & parent_;
65
66 public Q_SLOTS:
67         // dialog closed from WM
68         void slotWMHide();
69         // Restore button clicked
70         void slotRestore();
71         // OK button clicked
72         void slotOK();
73         // Apply button clicked
74         void slotApply();
75         // Close button clicked
76         void slotClose();
77
78 private:
79         /// Pointer to the actual instantiation of the Qt dialog
80         virtual QWidget * form() const = 0;
81 };
82
83
84 template <class GUIDialog>
85 class GuiView : public GuiDialogView {
86 protected:
87         GuiView(GuiDialog & p, docstring const & t)
88                 : GuiDialogView(p, t)
89         {}
90
91         virtual ~GuiView() {}
92
93         /// update the dialog
94         virtual void updateView() {
95                 dialog_->setUpdatesEnabled(false);
96
97                 // protect the BC from unwarranted state transitions
98                 updating_ = true;
99                 update_contents();
100                 updating_ = false;
101
102                 dialog_->setUpdatesEnabled(true);
103                 dialog_->update();
104         }
105
106         /// Pointer to the actual instantiation of the Qt dialog
107         virtual GUIDialog * form() const { return dialog_.get(); }
108
109         /// Real GUI implementation.
110         boost::scoped_ptr<GUIDialog> dialog_;
111 };
112
113 } // namespace frontend
114 } // namespace lyx
115
116 #endif // GUIDIALOGVIEW_H