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(string 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;
79 template <class Dialog>
80 class Qt2DB: public Qt2Base {
82 Qt2DB(string const &);
85 virtual void update();
90 /// Pointer to the actual instantiation of the Qt dialog
91 virtual QDialog * form() const;
93 /// Real GUI implementation.
94 boost::scoped_ptr<Dialog> dialog_;
99 template <class Dialog>
100 Qt2DB<Dialog>::Qt2DB(string const & t)
105 template <class Dialog>
106 QDialog * Qt2DB<Dialog>::form() const
108 return dialog_.get();
112 template <class Dialog>
113 void Qt2DB<Dialog>::update()
115 form()->setUpdatesEnabled(false);
117 // protect the BC from unwarranted state transitions
119 qApp->processEvents();
122 qApp->processEvents();
125 form()->setUpdatesEnabled(true);
130 template <class Dialog>
131 void Qt2DB<Dialog>::build()
133 // protect the BC from unwarranted state transitions
135 qApp->processEvents();
138 qApp->processEvents();
143 template <class Controller, class Base>
144 class Qt2CB: public Base
147 bool readOnly() const {
148 return controller().bufferIsReadonly();
151 /// The parent controller
152 Controller & controller();
153 /// The parent controller
154 Controller const & controller() const;
158 Qt2CB(string const &);
162 template <class Controller, class Base>
163 Qt2CB<Controller, Base>::Qt2CB(string const & t)
168 template <class Controller, class Base>
169 Controller & Qt2CB<Controller, Base>::controller()
171 return static_cast<Controller &>(getController());
175 template <class Controller, class Base>
176 Controller const & Qt2CB<Controller, Base>::controller() const
178 return static_cast<Controller const &>(getController());