]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlInset.h
The reference dialog now disconnects from the inset on Apply. Its behaviour
[lyx.git] / src / frontends / controllers / ControlInset.h
index 8ef34e543d272ded08f058aa95d380012c3df47c..755a4476df79dd459e6ffc36afc36cc56d4fb4d4 100644 (file)
@@ -20,6 +20,7 @@
 #define CONTROLINSET_H
 
 #include "support/LAssert.h"
+#include "debug.h" 
 #include "ControlConnections.h"
 
 class Inset;
@@ -45,7 +46,7 @@ protected:
        Inset * inset() const;
 
 private:
-       /** These 6 methods are all that the individual daughter classes
+       /** These 7 methods are all that the individual daughter classes
            should need to instantiate. */
 
        /// if the inset exists then do this...
@@ -66,6 +67,10 @@ private:
        /// clean-up any daughter class-particular data on hide().
        virtual void clearDaughterParams() {}
 
+       /** Some dialogs may find it beneficial to disconnect from the inset
+        when the Apply button is pressed. E.g., doing this with the citation
+        dialog allows multiple citiations to be inserted easily. */
+       virtual bool disconnectOnApply() { return false; }
 
 
        
@@ -95,13 +100,17 @@ private:
            Memory is allocated only whilst the dialog is visible.
        */
        Params * params_;
+
+       /// is the dialog built ?
+       bool dialog_built_;
 };
 
 
 template <class Inset, class Params>
 ControlInset<Inset, Params>::ControlInset(LyXView & lv, Dialogs & d)
        : ControlConnectBD(lv, d),
-         inset_(0), ih_(0), params_(0)
+         inset_(0), ih_(0), params_(0), dialog_built_(false)
 {}
 
 
@@ -120,7 +129,7 @@ void ControlInset<Inset, Params>::createInset(string const & arg)
 {
        connectInset();
 
-       if ( !arg.empty() )
+       if (!arg.empty())
                bc().valid(); // so that the user can press Ok
 
        show(getParams(arg));
@@ -135,6 +144,11 @@ void ControlInset<Inset, Params>::show(Params const & params)
 
        setDaughterParams();
 
+       if (!dialog_built_) {
+               view().build();
+               dialog_built_ = true;
+       }
+
        bc().readOnly(isReadonly());
        view().show();
 }
@@ -184,6 +198,14 @@ void ControlInset<Inset, Params>::apply()
                applyParamsToInset();
        else
                applyParamsNoInset();
+
+       if (disconnectOnApply() && !isClosing()) {
+               *params_ = getParams(string());
+               inset_ = 0;
+               ih_.disconnect();
+
+               view().update();
+       }
 }