X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiDialog.h;h=2359d740122f260fad455380a79d27bb112613a4;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=42e6b47d22bc68f95cc1b2004f47217630355217;hpb=94e61a3bc9c136554afd8f23fd4d49c2f4e394ba;p=lyx.git diff --git a/src/frontends/qt4/GuiDialog.h b/src/frontends/qt4/GuiDialog.h index 42e6b47d22..2359d74012 100644 --- a/src/frontends/qt4/GuiDialog.h +++ b/src/frontends/qt4/GuiDialog.h @@ -16,14 +16,17 @@ #include "ButtonController.h" #include -#include + namespace lyx { namespace frontend { -/** \c Dialog collects the different parts of a Model-Controller-View - * split of a generic dialog together. - */ +/// Base class for historical LyX dialogs. +/** + * \warning New dialogs should use the leaner classes \c DialogView or + * \c DockView depending on the intent. Eventally, old dialog should be + * converted to \c DialogView too. + */ class GuiDialog : public QDialog, public Dialog { Q_OBJECT @@ -32,38 +35,35 @@ public: /// \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. - explicit GuiDialog(LyXView & lv, std::string const & name); - ~GuiDialog(); + /// \param title is the window title used for decoration. + GuiDialog(GuiView & lv, QString const & name, QString const & title); + + virtual QWidget * asQWidget() { return this; } + virtual QWidget const * asQWidget() const { return this; } public Q_SLOTS: - // dialog closed from WM - void slotWMHide(); + /** \name Buttons + * These methods are publicly accessible because they are invoked + * by the View when the user presses... guess what ;-) + */ // Restore button clicked void slotRestore(); // OK button clicked void slotOK(); // Apply button clicked void slotApply(); - // Close button clicked + // AutoApply checkbox clicked + void slotAutoApply(); + // Close button clicked or closed from WindowManager void slotClose(); + /// + void closeEvent(QCloseEvent * e); public: - /** \name Buttons - * These methods are publicly accessible because they are invoked - * by the View when the user presses... guess what ;-) - */ - //@{ - void ApplyButton(); - void OKButton(); - void CancelButton(); - void RestoreButton(); - //@} - /** Check whether we may apply our data. * * The buttons are disabled if not and (re-)enabled if yes. */ - void checkStatus(); void setButtonsValid(bool valid); /** \name Dialog Components @@ -74,99 +74,39 @@ public: ButtonController & bc() { return bc_; } //@} - void setViewTitle(docstring const & title); - - /// - bool readOnly() const; - /// the dialog has changed contents virtual void changed(); + virtual void enableView(bool enable); + /// default: do nothing virtual void applyView() {} /// default: do nothing - virtual void update_contents() {} + virtual void updateContents() {} -protected: - /// Hide the dialog. - virtual void hideView(); - /// Create the dialog if necessary, update it and display it. - virtual void showView(); - /// - virtual bool isVisibleView() const; +public: /// is the dialog currently valid ? virtual bool isValid() { return true; } public: - /** \name Container Access - * These methods are publicly accessible because they are invoked - * by the parent container acting on commands from the LyX kernel. - */ - //@{ - /// \param data is a string encoding of the data to be displayed. - /// It is passed to the Controller to be translated into a useable form. - void showData(std::string const & data); - void updateData(std::string const & data); - - void hide(); - - /** This function is called, for example, if the GUI colours - * have been changed. - */ - void redraw() { redrawView(); } - //@} /** When applying, it's useful to know whether the dialog is about * to close or not (no point refreshing the display for example). */ bool isClosing() const { return is_closing_; } - /** \name Dialog Specialization - * Methods to set the Controller and View and so specialise - * to a particular dialog. - */ - //@{ - /// \param ptr is stored and destroyed by \c Dialog. - void setController(Controller * ptr); - //@} - - /** \name Dialog Components - * Methods to access the various components making up a dialog. - */ - //@{ - virtual Controller & controller() const { return *controller_; } - //@} - - /** Defaults to nothing. Can be used by the Controller, however, to - * indicate to the View that something has changed and that the - * dialog therefore needs updating. - * \param id identifies what should be updated. - */ - virtual void partialUpdateView(int /*id*/) {} - - /// - std::string name() const { return name_; } - - void apply(); - void redrawView() {} - -private: /// Update the display of the dialog whilst it is still visible. virtual void updateView(); +private: ButtonController bc_; /// are we updating ? bool updating_; bool is_closing_; - /** The Dialog's name is the means by which a dialog identifies - * itself to the kernel. - */ - std::string name_; - Controller * controller_; - LyXView * lyxview_; // FIXME: replace by moving to constructor }; + } // namespace frontend } // namespace lyx