#include <config.h>
#include "GuiBibitem.h"
-#include "ControlCommand.h"
+
#include "qt_helpers.h"
-#include <QCloseEvent>
+#include "insets/InsetCommand.h"
+
#include <QLineEdit>
#include <QPushButton>
namespace frontend {
-GuiBibitemDialog::GuiBibitemDialog(LyXView & lv)
- : GuiDialog(lv, "bibitem")
+GuiBibitem::GuiBibitem(QWidget * parent) : InsetParamsWidget(parent)
{
setupUi(this);
- setViewTitle(_("Bibliography Entry Settings"));
- setController(new ControlCommand(*this, "bibitem", "bibitem"));
-
- connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
-
- connect(keyED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(labelED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
-
- bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
- bc().setOK(okPB);
- bc().setCancel(closePB);
- bc().addReadOnly(keyED);
- bc().addReadOnly(labelED);
-}
-
-
-ControlCommand & GuiBibitemDialog::controller() const
-{
- return static_cast<ControlCommand &>(GuiDialog::controller());
-}
-
-void GuiBibitemDialog::change_adaptor()
-{
- changed();
-}
-
-
-void GuiBibitemDialog::closeEvent(QCloseEvent *e)
-{
- slotWMHide();
- e->accept();
+ connect(keyED, SIGNAL(textChanged(QString)),
+ this, SIGNAL(changed()));
+ connect(labelED, SIGNAL(textChanged(QString)),
+ this, SIGNAL(changed()));
+ connect(literalCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
}
-void GuiBibitemDialog::update_contents()
+void GuiBibitem::paramsToDialog(Inset const * inset)
{
- keyED->setText(toqstr(controller().params()["key"]));
- labelED->setText(toqstr(controller().params()["label"]));
+ InsetCommand const * ic = static_cast<InsetCommand const *>(inset);
+ InsetCommandParams const & params = ic->params();
+ keyED->setText(toqstr(params["key"]));
+ labelED->setText(toqstr(params["label"]));
+ literalCB->setChecked(params["literal"] == "true");
}
-void GuiBibitemDialog::applyView()
+docstring GuiBibitem::dialogToParams() const
{
- controller().params()["key"] = qstring_to_ucs4(keyED->text());
- controller().params()["label"] = qstring_to_ucs4(labelED->text());
+ InsetCommandParams params(insetCode());
+ params["key"] = qstring_to_ucs4(keyED->text());
+ params["label"] = qstring_to_ucs4(labelED->text());
+ params["literal"] = literalCB->isChecked()
+ ? from_ascii("true") : from_ascii("false");
+ return from_utf8(InsetCommand::params2string(params));
}
-bool GuiBibitemDialog::isValid()
+bool GuiBibitem::checkWidgets(bool readonly) const
{
+ keyED->setReadOnly(readonly);
+ labelED->setReadOnly(readonly);
+ if (!InsetParamsWidget::checkWidgets())
+ return false;
return !keyED->text().isEmpty();
}
} // namespace frontend
} // namespace lyx
-#include "GuiBibitem_moc.cpp"
+#include "moc_GuiBibitem.cpp"