4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS
17 #include <boost/scoped_ptr.hpp>
22 #include <qapplication.h>
26 /** This class is an Qt2 GUI base class.
28 class QDialogView : public QObject, public Dialog::View {
32 QDialogView(Dialog &, QString const &);
34 virtual ~QDialogView() {}
36 bool readOnly() const;
39 /// build the actual dialog
40 virtual void build_dialog() = 0;
42 virtual void build() = 0;
45 /// Create the dialog if necessary, update it and display it.
47 /// update the dialog's contents
48 virtual void update_contents() = 0;
50 virtual bool isVisible() const;
52 /// the dialog has changed contents
53 virtual void changed();
55 /// is the dialog currently valid ?
56 virtual bool isValid();
64 // dialog closed from WM
67 // Restore button clicked
73 // Apply button clicked
76 // Close button clicked
79 /// Pointer to the actual instantiation of the Qt dialog
80 virtual QDialog * form() const = 0;
83 /// dialog title, displayed by WM.
88 template <class GUIDialog>
89 class QView: public QDialogView {
91 QView(Dialog &, QString const &);
94 virtual void update();
99 /// Pointer to the actual instantiation of the Qt dialog
100 virtual QDialog * form() const;
102 /// Real GUI implementation.
103 boost::scoped_ptr<GUIDialog> dialog_;
108 template <class GUIDialog>
109 QView<GUIDialog>::QView(Dialog & p, QString const & t)
114 template <class GUIDialog>
115 QDialog * QView<GUIDialog>::form() const
117 return dialog_.get();
121 template <class GUIDialog>
122 void QView<GUIDialog>::update()
124 form()->setUpdatesEnabled(false);
126 // protect the BC from unwarranted state transitions
128 qApp->processEvents();
131 qApp->processEvents();
134 form()->setUpdatesEnabled(true);
139 template <class GUIDialog>
140 void QView<GUIDialog>::build()
142 // protect the BC from unwarranted state transitions
144 qApp->processEvents();
147 qApp->processEvents();
152 template <class Controller, class Base>
153 class QController: public Base
157 QController(Dialog &, QString const &);
158 /// The parent controller
159 Controller & controller();
160 /// The parent controller
161 Controller const & controller() const;
165 template <class Controller, class Base>
166 QController<Controller, Base>::QController(Dialog & p, QString const & t)
171 template <class Controller, class Base>
172 Controller & QController<Controller, Base>::controller()
174 return static_cast<Controller &>(getController());
178 template <class Controller, class Base>
179 Controller const & QController<Controller, Base>::controller() const
181 return static_cast<Controller const &>(getController());
185 #endif // QDIALOGVIEW_H