X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FDialogView.h;h=a95b1a435cd910141d5557a5e5b7ac7c314c7ece;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=6309f0821c73f8b32419cf0832befe25dab6e78f;hpb=738d5b06ba27f238dfdae4a7bd708d9be6b8fd49;p=lyx.git diff --git a/src/frontends/qt4/DialogView.h b/src/frontends/qt4/DialogView.h index 6309f0821c..a95b1a435c 100644 --- a/src/frontends/qt4/DialogView.h +++ b/src/frontends/qt4/DialogView.h @@ -9,89 +9,58 @@ * Full author contact details are available in file CREDITS. */ -#ifndef DIALOG_VIEW_H -#define DIALOG_VIEW_H +#ifndef DIALOGVIEW_H +#define DIALOGVIEW_H -#include "controllers/Dialog.h" +#include "Dialog.h" #include "GuiView.h" -#include "qt_helpers.h" -#include "debug.h" +#include #include -#include - namespace lyx { namespace frontend { -/// Window Dialog container for LyX dialogs. -/// This template class that encapsulates a given Widget inside a -/// QDialog and presents a Dialog interface -template class DialogView : public QDialog, public Dialog { public: - DialogView( - GuiViewBase & parent, ///< the main window where to dock. - std::string const & name, ///< dialog identifier. - bool modal = false, ///< Window modality. - Qt::WindowFlags flags = 0 - ) - : QDialog(&parent, flags), name_(name) - { - setModal(modal); - MyController * c = new MyController(*this); - controller_ = c; - controller_->setLyXView(parent); - widget_ = new MyWidget(*c, this); - setWindowTitle("LyX: " + widget_->windowTitle()); - } + /// \param lv is the access point for the dialog to the LyX kernel. + /// \param name is the identifier given to the dialog by its parent + /// container. + /// \param title is the window title used for decoration. + DialogView(GuiView & lv, QString const & name, QString const & title) + : QDialog(&lv), Dialog(lv, name, "LyX: " + title) + {} - /// Dialog inherited methods + virtual QWidget * asQWidget() { return this; } + virtual QWidget const * asQWidget() const { return this; } + +protected: + /// \name Dialog inherited methods //@{ void applyView() {} - void hideView() - { - controller().clearParams(); - QDialog::hide(); - } - void showData(std::string const & data) - { - controller_->initialiseParams(data); - showView(); - } - void showView() - { - widget_->updateView(); // make sure its up-to-date - QDialog::show(); - raise(); - activateWindow(); - } - bool isVisibleView() const { return QDialog::isVisible(); } - void checkStatus() { updateView(); } - void redraw() { redrawView(); } - void redrawView() {} - void updateData(std::string const & data) + bool initialiseParams(std::string const & /*data*/) { return true; } + void clearParams() {} + //@} + /// Any dialog that overrides this method should make sure to call it. + void closeEvent(QCloseEvent * ev) { - controller_->initialiseParams(data); - updateView(); + clearParams(); + Dialog::disconnect(); + ev->accept(); } - void updateView() + /// Any dialog that overrides this method should make sure to call it. + void hideEvent(QHideEvent * ev) { - widget_->updateView(); + if (!ev->spontaneous()) { + clearParams(); + Dialog::disconnect(); + ev->accept(); + } } - void partialUpdateView(int /*id*/) {} - Controller & controller() { return *controller_; } - std::string name() const { return name_; } - //@} -private: - /// The encapsulated widget. - MyWidget * widget_; - Controller * controller_; - std::string name_; }; -} // frontend -} // lyx +} // namespace frontend +} // namespace lyx -#endif // DIALOG_VIEW_H +#endif // DIALOGVIEW_H