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>
19 #include <QApplication>
28 /** This class is an Qt2 GUI base class.
30 class QDialogView : public QObject, public Dialog::View {
34 QDialogView(Dialog &, docstring const &);
36 virtual ~QDialogView() {}
38 bool readOnly() const;
40 /// the dialog has changed contents
41 virtual void changed();
47 /// build the actual dialog
48 virtual void build_dialog() = 0;
50 virtual void build() = 0;
53 /// Create the dialog if necessary, update it and display it.
55 /// update the dialog's contents
56 virtual void update_contents() = 0;
58 virtual bool isVisible() const;
60 /// is the dialog currently valid ?
61 virtual bool isValid();
67 // dialog closed from WM
70 // Restore button clicked
76 // Apply button clicked
79 // Close button clicked
82 /// Pointer to the actual instantiation of the Qt dialog
83 virtual QWidget * form() const = 0;
87 template <class GUIDialog>
88 class QView: public QDialogView {
90 QView(Dialog & p, docstring const & t): QDialogView(p, t)
96 virtual void update() {
97 dialog_->setUpdatesEnabled(false);
99 // protect the BC from unwarranted state transitions
104 dialog_->setUpdatesEnabled(true);
109 virtual void build() {
110 // protect the BC from unwarranted state transitions
116 /// Pointer to the actual instantiation of the Qt dialog
117 virtual GUIDialog * form() const { return dialog_.get(); }
119 /// Real GUI implementation.
120 boost::scoped_ptr<GUIDialog> dialog_;
124 template <class Controller, class Base>
125 class QController: public Base
129 QController(Dialog & p, docstring const & t): Base(p, t)
132 /// The parent controller
133 Controller & controller()
134 { return static_cast<Controller &>(this->getController()); }
136 /// The parent controller
137 Controller const & controller() const
138 { return static_cast<Controller const &>(this->getController()); }
141 } // namespace frontend
144 #endif // QDIALOGVIEW_H