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 Qt2Base : public QObject, public ViewBase {
32 Qt2Base(QString const &);
36 /// build the actual dialog
37 virtual void build_dialog() = 0;
40 /// Create the dialog if necessary, update it and display it.
42 /// update the dialog's contents
43 virtual void update_contents() = 0;
45 virtual bool isVisible() const;
47 /// the dialog has changed contents
48 virtual void changed();
50 /// is the dialog currently valid ?
51 virtual bool isValid();
59 // dialog closed from WM
62 // Restore button clicked
68 // Apply button clicked
71 // Close button clicked
74 /// Pointer to the actual instantiation of the Qt dialog
75 virtual QDialog * form() const = 0;
78 /// dialog title, displayed by WM.
83 template <class Dialog>
84 class Qt2DB: public Qt2Base {
86 Qt2DB(QString const &);
89 virtual void update();
94 /// Pointer to the actual instantiation of the Qt dialog
95 virtual QDialog * form() const;
97 /// Real GUI implementation.
98 boost::scoped_ptr<Dialog> dialog_;
103 template <class Dialog>
104 Qt2DB<Dialog>::Qt2DB(QString const & t)
109 template <class Dialog>
110 QDialog * Qt2DB<Dialog>::form() const
112 return dialog_.get();
116 template <class Dialog>
117 void Qt2DB<Dialog>::update()
119 form()->setUpdatesEnabled(false);
121 // protect the BC from unwarranted state transitions
123 qApp->processEvents();
126 qApp->processEvents();
129 form()->setUpdatesEnabled(true);
134 template <class Dialog>
135 void Qt2DB<Dialog>::build()
137 // protect the BC from unwarranted state transitions
139 qApp->processEvents();
142 qApp->processEvents();
147 template <class Controller, class Base>
148 class Qt2CB: public Base
151 bool readOnly() const {
152 return controller().bufferIsReadonly();
155 /// The parent controller
156 Controller & controller();
157 /// The parent controller
158 Controller const & controller() const;
162 Qt2CB(QString const &);
166 template <class Controller, class Base>
167 Qt2CB<Controller, Base>::Qt2CB(QString const & t)
172 template <class Controller, class Base>
173 Controller & Qt2CB<Controller, Base>::controller()
175 return static_cast<Controller &>(getController());
179 template <class Controller, class Base>
180 Controller const & Qt2CB<Controller, Base>::controller() const
182 return static_cast<Controller const &>(getController());