]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Dialog.h
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / Dialog.h
index 8f6cea63170d46a2c52d7d3c96c676f446ff528b..1bd75673c54af9c076edf8a516b393216793c48f 100644 (file)
 #ifndef DIALOG_H
 #define DIALOG_H
 
-#include "lfuns.h"
+#include "FuncCode.h"
 
 #include "support/strfwd.h"
 
+#include <QString>
+
+class QWidget;
+
 namespace lyx {
 
 class Buffer;
@@ -47,10 +51,34 @@ 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.
-       Dialog(GuiView & lv, std::string const & name);
+       /// \param title is the window title used for decoration.
+       Dialog(GuiView & lv, QString const & name, QString const & title);
 
        virtual ~Dialog();
 
+       virtual QWidget * asQWidget() = 0;
+       virtual QWidget const * asQWidget() const = 0;
+
+       /// Session key.
+       /**
+        * This key must be used for any session setting.
+        **/
+       QString sessionKey() const;
+
+       /// Save session settings.
+       /**
+        * This default implementation saves the geometry state.
+        * Reimplement to save more settings.
+        **/
+       virtual void saveSession() const;
+
+       /// Restore session settings.
+       /**
+        * This default implementation restores the geometry state.
+        * Reimplement to restore more settings.
+        **/
+       virtual void restoreSession();
+
        /** \name Container Access
         *  These methods are publicly accessible because they are invoked
         *  by the parent container acting on commands from the LyX kernel.
@@ -58,30 +86,21 @@ public:
        //@{
        /// \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.
-       virtual void showData(std::string const & /*data*/) {}
-       virtual void updateData(std::string const & /*data*/) {}
-
-       virtual void hide() {}
-
+       virtual void showData(std::string const & data);
+       virtual void updateData(std::string const & data);
        //@}
 
        /** Check whether we may apply our data.
         *
         *  The buttons are disabled if not and (re-)enabled if yes.
         */
-       virtual void checkStatus() {}
+       virtual void checkStatus();
 
        /** When applying, it's useful to know whether the dialog is about
         *  to close or not (no point refreshing the display for example).
         */
        virtual bool isClosing() const { return false; }
 
-
-       /** \c Button controller part
-        */
-       virtual void setButtonsValid(bool /*valid*/) {}
-
-
        /** \c View part
         *  of a Model-Controller-View split of a generic dialog.
         *  These few methods are all that a generic dialog needs of a
@@ -95,20 +114,24 @@ public:
        virtual void applyView() = 0;
 
        /// Hide the dialog from sight
-       virtual void hideView() = 0;
+       void hideView();
 
        /// Create the dialog if necessary, update it and display it.
-       virtual void showView() = 0;
+       void showView();
 
        /// Update the display of the dialog whilst it is still visible.
        virtual void updateView() = 0;
 
+       // Default Implementation does nothing.
+       // Each dialog has to choose what control to enable or disable.
+       virtual void enableView(bool /*enable*/) {}
+
        /// \return true if the dialog is visible.
-       virtual bool isVisibleView() const = 0;
+       virtual bool isVisibleView() const;
        //@}
 
-       ///
-       std::string name() const;
+       /// Dialog identifier.
+       QString name() const { return name_; }
 
        //@{
        /** Enable the controller to initialise its data structures.
@@ -142,7 +165,7 @@ public:
         * It should be used in dispatchParams(), too for consistency reasons.
         *  \returns the lfun that is sent for applying the data.
         */
-       virtual kb_action getLfun() const { return LFUN_INSET_APPLY; }
+       virtual FuncCode getLfun() const { return LFUN_INSET_APPLY; }
 
        /** Check whether we may apply our data.
         *
@@ -205,7 +228,7 @@ public:
        //@{
        bool isBufferAvailable() const;
        bool isBufferReadonly() const;
-       std::string const bufferFilepath() const;
+       QString bufferFilepath() const;
        //@}
 
        /// The type of the current buffer.
@@ -227,13 +250,18 @@ public:
        //@}
 
 protected:
-       virtual void apply() {}
+       ///
+       void setTitle(QString const & title) { title_ = title; }
+       ///
+       virtual void apply();
 
 private:
        /** The Dialog's name is the means by which a dialog identifies
         *  itself to the LyXView.
         */
-       char const * const name_;
+       QString const name_;
+       ///
+       QString title_;
        ///
        GuiView * lyxview_;