#include <config.h>
#include "GuiBibitem.h"
-#include "Qt2BC.h"
+
#include "qt_helpers.h"
-#include <QCloseEvent>
+#include "insets/InsetCommand.h"
+
#include <QLineEdit>
#include <QPushButton>
namespace lyx {
namespace frontend {
-/////////////////////////////////////////////////////////////////////
-//
-// GuiBibItemDialog
-//
-/////////////////////////////////////////////////////////////////////
-GuiBibitemDialog::GuiBibitemDialog(GuiBibitem * form)
- : form_(form)
+GuiBibitem::GuiBibitem(QWidget * parent) : InsetParamsWidget(parent)
{
setupUi(this);
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-
- connect(keyED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
- connect(labelED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
-}
-
-
-void GuiBibitemDialog::change_adaptor()
-{
- form_->changed();
-}
-
-
-void GuiBibitemDialog::closeEvent(QCloseEvent *e)
-{
- form_->slotWMHide();
- e->accept();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// GuiBibItem
-//
-/////////////////////////////////////////////////////////////////////
-
-
-GuiBibitem::GuiBibitem(Dialog & parent)
- : GuiView<GuiBibitemDialog>(parent, _("Bibliography Entry Settings"))
-{
-}
-
-
-void GuiBibitem::build_dialog()
-{
- dialog_.reset(new GuiBibitemDialog(this));
- bcview().setOK(dialog_->okPB);
- bcview().setCancel(dialog_->closePB);
- bcview().addReadOnly(dialog_->keyED);
- bcview().addReadOnly(dialog_->labelED);
+ connect(keyED, SIGNAL(textChanged(QString)),
+ this, SIGNAL(changed()));
+ connect(labelED, SIGNAL(textChanged(QString)),
+ this, SIGNAL(changed()));
+ connect(literalCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
}
-void GuiBibitem::update_contents()
+void GuiBibitem::paramsToDialog(Inset const * inset)
{
- dialog_->keyED->setText(toqstr(controller().params()["key"]));
- dialog_->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 GuiBibitem::apply()
+docstring GuiBibitem::dialogToParams() const
{
- controller().params()["key"] = qstring_to_ucs4(dialog_->keyED->text());
- controller().params()["label"] = qstring_to_ucs4(dialog_->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 GuiBibitem::isValid()
+bool GuiBibitem::checkWidgets(bool readonly) const
{
- return !dialog_->keyED->text().isEmpty();
+ 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"