#include "FuncStatus.h"
#include "LyXFunc.h"
+#include <string>
namespace lyx {
namespace frontend {
+Dialog::Dialog(GuiView & lv, std::string const & name)
+ : lyxview_(&lv), name_(name.c_str())
+{}
+
+
Dialog::~Dialog()
{}
+std::string Dialog::name() const
+{
+ return name_;
+}
+
bool Dialog::canApply() const
{
- FuncRequest const fr(getLfun(), name());
+ FuncRequest const fr(getLfun(), name_);
FuncStatus const fs(getStatus(fr));
return fs.enabled();
}
}
-void Dialog::updateDialog(std::string const & name) const
+void Dialog::updateDialog() const
{
- dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name));
+ dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name_));
}
-void Dialog::disconnect(std::string const & name) const
+void Dialog::disconnect() const
{
- lyxview_->disconnectDialog(name);
+ lyxview_->disconnectDialog(name_);
}
/// \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) : lyxview_(&lv) {}
+ Dialog(GuiView & lv, std::string const & name);
+
virtual ~Dialog();
/** \name Container Access
//@}
///
- virtual std::string name() const = 0;
+ std::string name() const;
//@{
/** Enable the controller to initialise its data structures.
* It must, therefore, ask the kernel to provide this information.
* \param name is used to identify the dialog to the kernel.
*/
- void updateDialog(std::string const & name) const;
+ void updateDialog() const;
/** A request from the Controller that future changes to the data
* stored by the dialog are not applied to the inset currently
* a new inset at the cursor position.
* \param name is used to identify the dialog to the kernel.
*/
- void disconnect(std::string const & name) const;
+ void disconnect() const;
/** \name Kernel Wrappers
* Simple wrapper functions to Buffer methods.
virtual void apply() {}
private:
+ /** The Dialog's name is the means by which a dialog identifies
+ * itself to the LyXView.
+ */
+ char const * const name_;
+ ///
GuiView * lyxview_;
-private:
/// intentionally unimplemented, therefore uncopiable
Dialog(Dialog const &);
void operator=(Dialog const &);
bool modal = false, ///< Window modality.
Qt::WindowFlags flags = 0
)
- : QDialog(&parent, flags), name_(name)
+ : QDialog(&parent, flags), Dialog(parent, name)
{
setModal(modal);
QGridLayout * gridLayout = new QGridLayout(this);
{
widget_->updateView();
}
- std::string name() const { return name_; }
//@}
private:
/// The encapsulated widget.
MyWidget * widget_;
- std::string name_;
void showEvent(QShowEvent * e)
{
QSettings settings;
- std::string key = name_ + "/geometry";
+ std::string key = name() + "/geometry";
QDialog::restoreGeometry(settings.value(key.c_str()).toByteArray());
QDialog::showEvent(e);
}
void closeEvent(QCloseEvent * e)
{
QSettings settings;
- std::string key = name_ + "/geometry";
+ std::string key = name() + "/geometry";
settings.setValue(key.c_str(), QDialog::saveGeometry());
QDialog::closeEvent(e);
}
Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
Qt::WindowFlags flags = 0
)
- : QDockWidget(&parent, flags), Dialog(parent), name_(name)
+ : QDockWidget(&parent, flags), Dialog(parent, name)
{
if (flags & Qt::Drawer)
setFeatures(QDockWidget::NoDockWidgetFeatures);
updateView();
}
bool isClosing() const { return false; }
- std::string name() const { return name_; }
//@}
-private:
- std::string name_;
};
} // frontend
namespace frontend {
GuiDialog::GuiDialog(GuiView & lv, std::string const & name)
- : Dialog(lv), is_closing_(false), name_(name)
+ : Dialog(lv, name), is_closing_(false)
{}
// Tell the controller that a request to refresh the dialog's contents
// has been received. It's up to the controller to supply the necessary
// info by calling GuiDialog::updateView().
- updateDialog(name_);
+ updateDialog();
bc().restore();
}
return;
if (!initialiseParams(data)) {
- lyxerr << "Dialog \"" << name_
+ lyxerr << "Dialog \"" << name()
<< "\" failed to translate the data "
"string passed to show()" << std::endl;
return;
return;
if (!initialiseParams(data)) {
- lyxerr << "Dialog \"" << name_
+ lyxerr << "Dialog \"" << name()
<< "\" could not be initialized" << std::endl;
return;
}
clearParams();
hideView();
- Dialog::disconnect(name_);
+ Dialog::disconnect();
}
dispatchParams();
if (disconnectOnApply() && !is_closing_) {
- Dialog::disconnect(name_);
+ Dialog::disconnect();
initialiseParams(string());
updateView();
}
void GuiDialog::showEvent(QShowEvent * e)
{
QSettings settings;
- string key = name_ + "/geometry";
+ string key = name() + "/geometry";
restoreGeometry(settings.value(key.c_str()).toByteArray());
QDialog::showEvent(e);
}
void GuiDialog::closeEvent(QCloseEvent * e)
{
QSettings settings;
- string key = name_ + "/geometry";
+ string key = name() + "/geometry";
settings.setValue(key.c_str(), saveGeometry());
QDialog::closeEvent(e);
}
*/
bool isClosing() const { return is_closing_; }
- ///
- std::string name() const { return name_; }
-
void apply();
/// Update the display of the dialog whilst it is still visible.
bool updating_;
bool is_closing_;
- /** The Dialog's name is the means by which a dialog identifies
- * itself to the kernel.
- */
- std::string name_;
};
namespace frontend {
GuiParagraph::GuiParagraph(GuiView & lv)
- : Dialog(lv)
+ : Dialog(lv, "paragraph")
{
setupUi(this);
setWindowTitle(qt_("Paragraph Settings"));
// A bit clunky, but the dialog will request
// that the kernel provides it with the necessary
// data.
- dialog->updateDialog(dialog->name());
+ dialog->updateDialog();
}
}
}