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 {
35 Qt2Base(QString const &);
39 /// build the actual dialog
40 virtual void build_dialog() = 0;
43 /// Create the dialog if necessary, update it and display it.
45 /// update the dialog's contents
46 virtual void update_contents() = 0;
48 virtual bool isVisible() const;
50 /// the dialog has changed contents
51 virtual void changed();
53 /// is the dialog currently valid ?
54 virtual bool isValid();
62 // dialog closed from WM
65 // Restore button clicked
71 // Apply button clicked
74 // Close button clicked
77 /// Pointer to the actual instantiation of the Qt dialog
78 virtual QDialog * form() const = 0;
81 /// dialog title, displayed by WM.
86 template <class Dialog>
87 class Qt2DB: public Qt2Base {
89 Qt2DB(QString const &);
92 virtual void update();
97 /// Pointer to the actual instantiation of the Qt dialog
98 virtual QDialog * form() const;
100 /// Real GUI implementation.
101 boost::scoped_ptr<Dialog> dialog_;
106 template <class Dialog>
107 Qt2DB<Dialog>::Qt2DB(QString const & t)
112 template <class Dialog>
113 QDialog * Qt2DB<Dialog>::form() const
115 return dialog_.get();
119 template <class Dialog>
120 void Qt2DB<Dialog>::update()
122 form()->setUpdatesEnabled(false);
124 // protect the BC from unwarranted state transitions
126 qApp->processEvents();
129 qApp->processEvents();
132 form()->setUpdatesEnabled(true);
137 template <class Dialog>
138 void Qt2DB<Dialog>::build()
140 // protect the BC from unwarranted state transitions
142 qApp->processEvents();
145 qApp->processEvents();
150 template <class Controller, class Base>
151 class Qt2CB: public Base
154 bool readOnly() const {
155 return controller().bufferIsReadonly();
160 Qt2CB(QString const &);
161 /// The parent controller
162 Controller & controller();
163 /// The parent controller
164 Controller const & controller() const;
168 template <class Controller, class Base>
169 Qt2CB<Controller, Base>::Qt2CB(QString const & t)
174 template <class Controller, class Base>
175 Controller & Qt2CB<Controller, Base>::controller()
177 return static_cast<Controller &>(getController());
181 template <class Controller, class Base>
182 Controller const & Qt2CB<Controller, Base>::controller() const
184 return static_cast<Controller const &>(getController());