4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
15 #include "controllers/Dialog.h"
17 #include "qt_helpers.h"
27 /// Window Dialog container for LyX dialogs.
28 /// This template class that encapsulates a given Widget inside a
29 /// QDialog and presents a Dialog interface
30 template<class MyController, class MyWidget>
31 class DialogView : public QDialog, public Dialog
35 GuiViewBase & parent, ///< the main window where to dock.
36 std::string const & name, ///< dialog identifier.
37 bool modal = false, ///< Window modality.
38 Qt::WindowFlags flags = 0
40 : QDialog(&parent, flags), name_(name)
43 MyController * c = new MyController(*this);
45 controller_->setLyXView(parent);
46 widget_ = new MyWidget(*c, this);
47 setWindowTitle("LyX: " + widget_->windowTitle());
50 /// Dialog inherited methods
55 controller().clearParams();
58 void showData(std::string const & data)
60 controller_->initialiseParams(data);
65 widget_->updateView(); // make sure its up-to-date
70 bool isVisibleView() const { return QDialog::isVisible(); }
71 void checkStatus() { updateView(); }
72 void redraw() { redrawView(); }
74 void updateData(std::string const & data)
76 controller_->initialiseParams(data);
81 widget_->updateView();
83 void partialUpdateView(int /*id*/) {}
84 Controller & controller() { return *controller_; }
85 std::string name() const { return name_; }
88 /// The encapsulated widget.
90 Controller * controller_;
97 #endif // DIALOG_VIEW_H