+// -*- C++ -*-
/* This file is part of
* ======================================================
*
#ifndef CONTROLINSET_H
#define CONTROLINSET_H
+#include "support/LAssert.h"
+#include "debug.h"
#include "ControlConnections.h"
class Inset;
///
ControlInset(LyXView &, Dialogs &);
/// Allow the View access to the local copy.
- Params & params() const;
+ Params & params();
+ ///
+ Params const & params() const;
protected:
/// Slots connected in the daughter classes c-tor.
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...
/// 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; }
Memory is allocated only whilst the dialog is visible.
*/
Params * params_;
-};
-
-
-#include "LyXView.h"
-#include "support/LAssert.h"
+ /// 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)
{}
{
connectInset();
- if ( !arg.empty() )
+ if (!arg.empty())
bc().valid(); // so that the user can press Ok
show(getParams(arg));
setDaughterParams();
+ if (!dialog_built_) {
+ view().build();
+ dialog_built_ = true;
+ }
+
bc().readOnly(isReadonly());
view().show();
}
applyParamsToInset();
else
applyParamsNoInset();
+
+ if (disconnectOnApply() && !isClosing()) {
+ *params_ = getParams(string());
+ inset_ = 0;
+ ih_.disconnect();
+
+ view().update();
+ }
+}
+
+
+template <class Inset, class Params>
+Params & ControlInset<Inset, Params>::params()
+{
+ lyx::Assert(params_);
+ return *params_;
}
template <class Inset, class Params>
-Params & ControlInset<Inset, Params>::params() const
+Params const & ControlInset<Inset, Params>::params() const
{
- Assert(params_);
+ lyx::Assert(params_);
return *params_;
}
template <class Inset, class Params>
Inset * ControlInset<Inset, Params>::inset() const
{
- Assert(inset_);
+ lyx::Assert(inset_);
return inset_;
}