]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlDialogs.h
The reference dialog now disconnects from the inset on Apply. Its behaviour
[lyx.git] / src / frontends / controllers / ControlDialogs.h
index 4026d20daa4d6bc6a47f0d2361ab81fbf3a16f4a..f7dabe94708329a936b82ed2c797d12608ac96d2 100644 (file)
@@ -1,3 +1,4 @@
+// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  *
  * \file ControlDialogs.h
  * \author Angus Leeming <a.leeming@ic.ac.uk>
  *
- * ControlDialogs.h contains the definition of two template controller classes,
- * ControlDialog and ControlInset, rather clumsy names for classes that
- * control the showing, updating and hiding of popups.
- *
- * ControlInset is to be used as a parent class for popups that display and
- * can perhaps modify the contents of an individual inset. An example being the
- * ubiquitous Citation popup.
- *
- * ControlDialog is to be used as a parent class for popups that are not
- * Inset-popups. (An ugly description I know, but I hope the meaning is clear!
- * Can anyone do any better?) Examples would be the Document and Paragraph
- * popups.
- *
- * At the moment, ControlDialog is reaching a state of maturity as several
- * controllers are now derived from it and its required functionality
- * becaomes clear.
- *
- * ControlInset is still in a state of flux as currently only InsetCommand-type
- * insets have a controller.
- *
+ * ControlDialog is to be used as a parent class for dialogs that are not
+ * views onto parameters of insets. (An ugly description I know, but I hope 
+ * the meaning is clear!  * Can anyone do any better?) Examples would be the 
+ * Document and Paragraph dialogs.
  */
 
-#ifndef CONTROLCONNECTIONS2_H
-#define CONTROLCONNECTIONS2_H
+#ifndef CONTROLDIALOGS_H
+#define CONTROLDIALOGS_H
 
 #include "ControlConnections.h"
-#include "LyXView.h"
+#include "debug.h"
 
 /** Base class to control connection/disconnection of signals with the LyX
     kernel for dialogs NOT used with insets.
@@ -57,51 +42,22 @@ protected:
        /// Update the dialog.
        virtual void update();
 
-       /// set the params before show or update
-       virtual void setParams() {}
        /// clean-up on hide.
        virtual void clearParams() {}
-};
-
-
-/** Base class to control connection/disconnection of signals with the LyX
-    kernel for Inset dialogs.
- */
-class Inset;
-
-template <class Inset>
-class ControlInset : public ControlConnectBD
-{
-public:
-       ///
-       ControlInset(LyXView &, Dialogs &);
-
-protected:
-       /// Slot connected to update signal.
-       virtual void updateSlot(bool);
-       /// Connect signals
-       void connectInset(Inset * = 0);
-       /// Disconnect signals
-       virtual void disconnect();
-       ///
-       void disconnectInset();
-
-protected:
-       /// pointer to the inset passed through connectInset
-       Inset * inset_;
+       /// set the params before show or update
+       virtual void setParams() {}
 
 private:
-       /// inset::hide connection.
-       SigC::Connection ih_;
+       /// is the dialog built ?
+       bool dialog_built_;
 };
 
 
-
-
+#include "LyXView.h"
 
 template <class Base>
 ControlDialog<Base>::ControlDialog(LyXView & lv, Dialogs & d)
-       : Base(lv, d)
+       : Base(lv, d), dialog_built_(false)
 {}
 
 
@@ -111,8 +67,15 @@ void ControlDialog<Base>::show()
        if (isBufferDependent() && !lv_.view()->available())
                return;
 
+       connect();
+
        setParams();
 
+       if (!dialog_built_) {
+               view().build();
+               dialog_built_ = true;
+       }
+
        bc().readOnly(isReadonly());
        view().show();
 }
@@ -124,7 +87,7 @@ void ControlDialog<Base>::update()
                return;
 
        setParams();
-       
+
        bc().readOnly(isReadonly());
        view().update();
 }
@@ -138,56 +101,4 @@ void ControlDialog<Base>::hide()
        view().hide();
 }
 
-
-template <class Inset>
-ControlInset<Inset>::ControlInset(LyXView & lv, Dialogs & d)
-       : ControlConnectBD(lv, d),
-         inset_(0), ih_(0)
-{}
-
-
-template <class Inset>
-void ControlInset<Inset>::updateSlot(bool switched)
-{
-       if (switched)
-               hide();
-       else
-               update();
-}
-
-
-template <class Inset>
-void ControlInset<Inset>::disconnect()
-{
-       inset_ = 0;
-       ih_.disconnect();
-       ControlConnectBD::disconnect();
-}
-
-
-template <class Inset>
-void ControlInset<Inset>::connectInset(Inset * inset)
-{
-       // If connected to another inset, disconnect from it.
-       if (inset_) {
-               ih_.disconnect();
-               inset_ = 0;
-       }
-
-       if (inset) {
-               inset_ = inset;
-               ih_ = inset->hideDialog.connect(
-                       SigC::slot(this, &ControlInset::hide));
-       }
-       connect();
-}
-
-
-template <class Inset>
-void ControlInset<Inset>::disconnectInset()
-{
-       ih_.disconnect();
-}
-
-
-#endif // CONTROLCONNECTIONS2_H
+#endif // CONTROLDIALOGS_H