X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FDialog.h;h=5f958e79d0d835a552354de0cf7a704437b913c6;hb=b7f6b979d0f889f08e735f35378bb20ba3788b4b;hp=f764164ef1b541973e6111c419444fd5bbda6a1d;hpb=a98f82c292c7047478e3362449ab21aa35e03375;p=lyx.git diff --git a/src/frontends/qt4/Dialog.h b/src/frontends/qt4/Dialog.h index f764164ef1..5f958e79d0 100644 --- a/src/frontends/qt4/Dialog.h +++ b/src/frontends/qt4/Dialog.h @@ -14,9 +14,13 @@ #include "FuncCode.h" +#include "insets/InsetCode.h" + +#include "support/strfwd.h" + #include -#include +class QSettings; class QWidget; namespace lyx { @@ -24,6 +28,7 @@ namespace lyx { class Buffer; class BufferView; class FuncRequest; +class Inset; namespace frontend { @@ -40,11 +45,10 @@ enum KernelDocType DOCBOOK }; - /** \c Dialog collects the different parts of a Model-Controller-View * split of a generic dialog together. */ -class Dialog +class Dialog { public: /// \param lv is the access point for the dialog to the LyX kernel. @@ -69,7 +73,7 @@ public: * This default implementation saves the geometry state. * Reimplement to save more settings. **/ - virtual void saveSession() const; + virtual void saveSession(QSettings & settings) const; /// Restore session settings. /** @@ -86,9 +90,11 @@ 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); //@} + /// \return inset at current cursor location. + Inset const * inset(InsetCode code) const; + /** Check whether we may apply our data. * * The buttons are disabled if not and (re-)enabled if yes. @@ -115,9 +121,17 @@ public: /// Hide the dialog from sight void hideView(); - /// Create the dialog if necessary, update it and display it. + /// Prepare dialog and display it. void showView(); + /// Prepare dialog before view. + void prepareView(); + + /// Decide wether the dialog should grab thekeyboard focus when shown. + /// This method defaults to true, override if a different behaviour + /// is wanted. + virtual bool wantInitialFocus() const { return true; } + /// Update the display of the dialog whilst it is still visible. virtual void updateView() = 0; @@ -145,10 +159,15 @@ public: /// Enable the Controller to dispatch its data back to the LyX kernel. virtual void dispatchParams() = 0; + /** \return true if the dialog should be updated when the + * buffer has changed. + */ + virtual bool isBufferDependent() const = 0; + /** \return true if the dialog should be shown only when * a buffer is open. */ - virtual bool isBufferDependent() const = 0; + virtual bool needBufferOpen() const = 0; /** \return true if the dialog can apply data also * for ReadOnly buffers. @@ -184,11 +203,6 @@ public: */ virtual bool disconnectOnApply() const { return false; } - /** \return true if Dialog::View::show() should not display the dialog - * after running update. Currently, only ControlSpellchecker - * makes use of that. - */ - virtual bool exitEarly() const { return false; } //@} /** \c Kernel part: a wrapper making the LyX kernel available to the dialog. @@ -217,7 +231,6 @@ public: * stored by the dialog are not applied to the inset currently * connected to the dialog. Instead, they will be used to generate * a new inset at the cursor position. - * \param name is used to identify the dialog to the kernel. */ void disconnect() const; @@ -227,7 +240,7 @@ public: //@{ bool isBufferAvailable() const; bool isBufferReadonly() const; - QString bufferFilepath() const; + QString bufferFilePath() const; //@} /// The type of the current buffer. @@ -238,13 +251,12 @@ public: * We should aim to reduce/remove these from the interface. */ //@{ - GuiView & lyxview() { return *lyxview_; } - GuiView const & lyxview() const { return *lyxview_; } - - Buffer & buffer(); + GuiView const & lyxview() const { return lyxview_; } + /// Current buffer Buffer const & buffer() const; - - BufferView * bufferview(); + /// Main document buffer + Buffer const & documentBuffer() const; + /// Current BufferView BufferView const * bufferview() const; //@} @@ -253,21 +265,22 @@ protected: void setTitle(QString const & title) { title_ = title; } /// virtual void apply(); + /// To be called when the buffer view has changed + virtual void onBufferViewChanged() = 0; private: /** The Dialog's name is the means by which a dialog identifies - * itself to the LyXView. + * itself to the GuiView. */ QString const name_; /// QString title_; /// - GuiView * lyxview_; + GuiView & lyxview_; /// intentionally unimplemented, therefore uncopiable Dialog(Dialog const &); void operator=(Dialog const &); - };