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
20 #include <boost/scoped_ptr.hpp>
25 #include <qapplication.h>
29 /** This class is an Qt2 GUI base class.
31 class Qt2Base : public QObject, public ViewBase
36 Qt2Base(QString const &);
41 /// build the actual dialog
42 virtual void build_dialog() = 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 /// the dialog has changed contents
51 virtual void changed();
53 /// is the dialog currently valid ?
54 virtual bool isValid();
63 // dialog closed from WM
66 // Restore button clicked
72 // Apply button clicked
75 // Close button clicked
79 /// Pointer to the actual instantiation of xform's form
80 virtual QDialog * form() const = 0;
83 /// dialog title, displayed by WM.
88 template <class Dialog>
89 class Qt2DB: public Qt2Base
92 Qt2DB(QString const &);
95 virtual void update();
100 /// Pointer to the actual instantiation of the Qt dialog
101 virtual QDialog * form() const;
103 /// Real GUI implementation.
104 boost::scoped_ptr<Dialog> dialog_;
109 template <class Dialog>
110 Qt2DB<Dialog>::Qt2DB(QString const & t)
115 template <class Dialog>
116 QDialog * Qt2DB<Dialog>::form() const
118 return dialog_.get();
122 template <class Dialog>
123 void Qt2DB<Dialog>::update()
125 form()->setUpdatesEnabled(false);
127 // protect the BC from unwarranted state transitions
129 qApp->processEvents();
132 qApp->processEvents();
135 form()->setUpdatesEnabled(true);
140 template <class Dialog>
141 void Qt2DB<Dialog>::build()
143 // protect the BC from unwarranted state transitions
145 qApp->processEvents();
148 qApp->processEvents();
153 template <class Controller, class Base>
154 class Qt2CB: public Base
157 bool readOnly() const {
158 return controller().bufferIsReadonly();
163 Qt2CB(QString const &);
164 /// The parent controller
165 Controller & controller();
166 /// The parent controller
167 Controller const & controller() const;
171 template <class Controller, class Base>
172 Qt2CB<Controller, Base>::Qt2CB(QString const & t)
177 template <class Controller, class Base>
178 Controller & Qt2CB<Controller, Base>::controller()
180 return static_cast<Controller &>(getController());
184 template <class Controller, class Base>
185 Controller const & Qt2CB<Controller, Base>::controller() const
187 return static_cast<Controller const &>(getController());