#include "GuiDelimiter.h"
#include "GuiIndex.h"
#include "GuiMathMatrix.h"
-#include "GuiNomencl.h"
#include "GuiView.h"
// Uncomment this if you prefer dock widget
Dialog * createGuiListings(LyXView & lv);
Dialog * createGuiLog(LyXView & lv);
Dialog * createGuiMath(LyXView & lv);
-Dialog * createGuiNomencl(LyXView & lv);
+Dialog * createGuiNomenclature(LyXView & lv);
Dialog * createGuiNote(LyXView & lv);
Dialog * createGuiParagraph(LyXView & lv);
Dialog * createGuiPreferences(LyXView & lv);
if (name == "index")
return new GuiIndexDialog(lyxview_);
if (name == "nomenclature")
- return new GuiNomenclDialog(lyxview_);
+ return createGuiNomenclature(lyxview_);
if (name == "label")
return new GuiLabelDialog(lyxview_);
if (name == "log")
} // namespace frontend
} // namespace lyx
+
+/////////////////////////////////////////////////////////////////////
+//
+// Command based dialogs
+//
+/////////////////////////////////////////////////////////////////////
+
+#include "FuncRequest.h"
+#include "insets/InsetCommand.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+GuiCommand::GuiCommand(LyXView & lv, string const & name)
+ : GuiDialog(lv, name), Controller(this), params_(name), lfun_name_(name)
+{
+ setController(this, false);
+}
+
+
+bool GuiCommand::initialiseParams(string const & data)
+{
+ // The name passed with LFUN_INSET_APPLY is also the name
+ // used to identify the mailer.
+ InsetCommandMailer::string2params(lfun_name_, data, params_);
+ return true;
+}
+
+
+void GuiCommand::dispatchParams()
+{
+ if (lfun_name_.empty())
+ return;
+
+ string const lfun =
+ InsetCommandMailer::params2string(lfun_name_, params_);
+ dispatch(FuncRequest(getLfun(), lfun));
+}
+
+} // namespace frontend
+} // namespace lyx
+
#include "GuiDialog_moc.cpp"
#include "Dialog.h"
#include "ButtonController.h"
+#include "insets/InsetCommandParams.h"
+
#include <QDialog>
#include <QObject>
LyXView * lyxview_; // FIXME: replace by moving to constructor
};
+
+class GuiCommand : public GuiDialog, public Controller
+{
+public:
+ /// We need to know with what sort of inset we're associated.
+ GuiCommand(LyXView &, std::string const & name);
+ ///
+ bool initialiseParams(std::string const & data);
+ /// clean-up on hide.
+ void clearParams() { params_.clear(); }
+ /// clean-up on hide.
+ void dispatchParams();
+ ///
+ bool isBufferDependent() const { return true; }
+
+protected:
+ ///
+ InsetCommandParams params_;
+ //FIXME It should be possible to eliminate lfun_name_
+ //now and recover that information from params().insetType().
+ //But let's not do that quite yet.
+ /// Flags what action is taken by Kernel::dispatch()
+ std::string const lfun_name_;
+};
+
} // namespace frontend
} // namespace lyx
#include "GuiNomencl.h"
#include "debug.h"
-#include "ControlCommand.h"
#include "qt_helpers.h"
#include <QLabel>
namespace lyx {
namespace frontend {
-GuiNomenclDialog::GuiNomenclDialog(LyXView & lv)
- : GuiDialog(lv, "nomenclature")
+GuiNomenclature::GuiNomenclature(LyXView & lv)
+ : GuiCommand(lv, "nomenclature")
{
setupUi(this);
- setController(new ControlCommand(*this, "nomenclature"));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
- connect(symbolED, SIGNAL(textChanged(const QString&)),
+ connect(symbolED, SIGNAL(textChanged(QString)),
this, SLOT(change_adaptor()));
connect(descriptionTE, SIGNAL(textChanged()),
this, SLOT(change_adaptor()));
}
-ControlCommand & GuiNomenclDialog::controller()
-{
- return static_cast<ControlCommand &>(GuiDialog::controller());
-}
-
-
-void GuiNomenclDialog::change_adaptor()
+void GuiNomenclature::change_adaptor()
{
changed();
}
-void GuiNomenclDialog::reject()
+void GuiNomenclature::reject()
{
slotClose();
}
-void GuiNomenclDialog::closeEvent(QCloseEvent * e)
+void GuiNomenclature::closeEvent(QCloseEvent * e)
{
slotClose();
e->accept();
}
-void GuiNomenclDialog::updateContents()
+void GuiNomenclature::updateContents()
{
- prefixED->setText(toqstr(controller().params()["prefix"]));
- symbolED->setText(toqstr(controller().params()["symbol"]));
- QString description = toqstr(controller().params()["description"]);
+ prefixED->setText(toqstr(params_["prefix"]));
+ symbolED->setText(toqstr(params_["symbol"]));
+ QString description = toqstr(params_["description"]);
description.replace("\\\\","\n");
descriptionTE->setPlainText(description);
}
-void GuiNomenclDialog::applyView()
+void GuiNomenclature::applyView()
{
- controller().params()["prefix"] = qstring_to_ucs4(prefixED->text());
- controller().params()["symbol"] = qstring_to_ucs4(symbolED->text());
+ params_["prefix"] = qstring_to_ucs4(prefixED->text());
+ params_["symbol"] = qstring_to_ucs4(symbolED->text());
QString description = descriptionTE->toPlainText();
description.replace('\n',"\\\\");
- controller().params()["description"] = qstring_to_ucs4(description);
+ params_["description"] = qstring_to_ucs4(description);
}
-bool GuiNomenclDialog::isValid()
+bool GuiNomenclature::isValid()
{
QString const description = descriptionTE->toPlainText();
return !symbolED->text().isEmpty() && !description.isEmpty();
}
+
+Dialog * createGuiNomenclature(LyXView & lv)
+{
+ return new GuiNomenclature(lv);
+}
+
+
} // namespace frontend
} // namespace lyx
#define GUINOMENCL_H
#include "GuiDialog.h"
-#include "ControlCommand.h"
#include "ui_NomenclUi.h"
namespace lyx {
namespace frontend {
-class GuiNomenclDialog : public GuiDialog, public Ui::NomenclUi
+class GuiNomenclature : public GuiCommand, public Ui::NomenclUi
{
Q_OBJECT
public:
- GuiNomenclDialog(LyXView & lv);
+ GuiNomenclature(LyXView & lv);
private Q_SLOTS:
void change_adaptor();
private:
///
void closeEvent(QCloseEvent * e);
- /// parent controller
- ControlCommand & controller();
///
bool isValid();
/// Apply changes
namespace frontend {
GuiURL::GuiURL(LyXView & lv)
- : GuiDialog(lv, "url"), Controller(this), params_("url")
+ : GuiCommand(lv, "url")
{
setupUi(this);
setViewTitle( _("URL"));
- setController(this, false);
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
}
-bool GuiURL::initialiseParams(std::string const & data)
-{
- // The name passed with LFUN_INSET_APPLY is also the name
- // used to identify the mailer.
- InsetCommandMailer::string2params("name", data, params_);
- return true;
-}
-
-
-void GuiURL::dispatchParams()
-{
- std::string const lfun =
- InsetCommandMailer::params2string("url", params_);
- dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
Dialog * createGuiURL(LyXView & lv) { return new GuiURL(lv); }
#define GUIURL_H
#include "GuiDialog.h"
-#include "ControlCommand.h"
#include "ui_URLUi.h"
#include "insets/InsetCommandParams.h"
namespace lyx {
namespace frontend {
-class GuiURL : public GuiDialog, public Ui::URLUi, public Controller
+class GuiURL : public GuiCommand, public Ui::URLUi
{
Q_OBJECT
private:
void closeEvent(QCloseEvent *);
- /// parent controller
- Controller & controller() { return *this; }
///
bool isValid();
/// apply dialog
void applyView();
/// update dialog
void updateContents();
- ///
- bool initialiseParams(std::string const & data);
- /// clean-up on hide.
- void clearParams() { params_.clear(); }
- /// clean-up on hide.
- void dispatchParams();
- ///
- bool isBufferDependent() const { return true; }
-
-private:
- ///
- InsetCommandParams params_;
};
} // namespace frontend