4 * Copyright 2000-2002 the LyX Team
5 * Read the file COPYING
7 * \author Angus Leeming <a.leeming@ic.ac.uk>
23 #include "ButtonPolicies.h"
25 #include <boost/scoped_ptr.hpp>
30 #include <qapplication.h>
34 /** This class is an Qt2 GUI base class.
36 class Qt2Base : public QObject, public ViewBase
41 Qt2Base(QString const &);
46 /// build the actual dialog
47 virtual void build_dialog() = 0;
50 /// Create the dialog if necessary, update it and display it.
52 /// update the dialog's contents
53 virtual void update_contents() = 0;
55 /// the dialog has changed contents
56 virtual void changed();
58 /// is the dialog currently valid ?
59 virtual bool isValid();
68 // dialog closed from WM
71 // Restore button clicked
77 // Apply button clicked
80 // Close button clicked
84 /// Pointer to the actual instantiation of xform's form
85 virtual QDialog * form() const = 0;
88 /// dialog title, displayed by WM.
93 template <class Dialog>
94 class Qt2DB: public Qt2Base
97 Qt2DB(QString const &);
100 virtual void update();
103 virtual void build();
105 /// Pointer to the actual instantiation of the Qt dialog
106 virtual QDialog * form() const;
108 /// Real GUI implementation.
109 boost::scoped_ptr<Dialog> dialog_;
114 template <class Dialog>
115 Qt2DB<Dialog>::Qt2DB(QString const & t)
120 template <class Dialog>
121 QDialog * Qt2DB<Dialog>::form() const
123 return dialog_.get();
127 template <class Dialog>
128 void Qt2DB<Dialog>::update()
130 form()->setUpdatesEnabled(false);
132 // protect the BC from unwarranted state transitions
134 qApp->processEvents();
137 qApp->processEvents();
140 form()->setUpdatesEnabled(true);
145 template <class Dialog>
146 void Qt2DB<Dialog>::build()
148 // protect the BC from unwarranted state transitions
150 qApp->processEvents();
153 qApp->processEvents();
158 template <class Controller, class Base>
159 class Qt2CB: public Base
162 bool readOnly() const {
163 return controller().isReadonly();
168 Qt2CB(QString const &);
169 /// The parent controller
170 Controller & controller();
171 /// The parent controller
172 Controller const & controller() const;
176 template <class Controller, class Base>
177 Qt2CB<Controller, Base>::Qt2CB(QString const & t)
182 template <class Controller, class Base>
183 Controller & Qt2CB<Controller, Base>::controller()
185 return static_cast<Controller &>(getController());
189 template <class Controller, class Base>
190 Controller const & Qt2CB<Controller, Base>::controller() const
192 return static_cast<Controller const &>(getController());