]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiBibitem.cpp
GuiBibtex: Use appropriate title when using Biblatex
[lyx.git] / src / frontends / qt4 / GuiBibitem.cpp
index 4c651cec4664747c23ec67772348608f5975ed8b..b29f8a8704c3d089b9ce476c7b79b6898f394b25 100644 (file)
 #include <config.h>
 
 #include "GuiBibitem.h"
+
 #include "qt_helpers.h"
-#include "FuncRequest.h"
 
-#include <QCloseEvent>
+#include "insets/InsetCommand.h"
+
 #include <QLineEdit>
 #include <QPushButton>
 
@@ -23,65 +24,50 @@ namespace lyx {
 namespace frontend {
 
 
-GuiBibitem::GuiBibitem(GuiView & lv)
-       : GuiCommand(lv, "bibitem")
+GuiBibitem::GuiBibitem(QWidget * parent) : InsetParamsWidget(parent)
 {
        setupUi(this);
-       setViewTitle(_("Bibliography Entry Settings"));
-
-       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
-       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
 
        connect(keyED, SIGNAL(textChanged(QString)),
-               this, SLOT(change_adaptor()));
+               this, SIGNAL(changed()));
        connect(labelED, SIGNAL(textChanged(QString)),
-               this, SLOT(change_adaptor()));
-
-       bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
-       bc().setOK(okPB);
-       bc().setCancel(closePB);
-       bc().addReadOnly(keyED);
-       bc().addReadOnly(labelED);
-}
-
-
-void GuiBibitem::change_adaptor()
-{
-       changed();
+               this, SIGNAL(changed()));
+       connect(literalCB, SIGNAL(clicked()),
+               this, SIGNAL(changed()));
 }
 
 
-void GuiBibitem::closeEvent(QCloseEvent *e)
+void GuiBibitem::paramsToDialog(Inset const * inset)
 {
-       slotClose();
-       e->accept();
+       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::updateContents()
+docstring GuiBibitem::dialogToParams() const
 {
-       keyED->setText(toqstr(params_["key"]));
-       labelED->setText(toqstr(params_["label"]));
+       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));
 }
 
 
-void GuiBibitem::applyView()
-{
-       params_["key"] = qstring_to_ucs4(keyED->text());
-       params_["label"] = qstring_to_ucs4(labelED->text());
-}
-
-
-bool GuiBibitem::isValid()
+bool GuiBibitem::checkWidgets(bool readonly) const
 {
+       keyED->setReadOnly(readonly);
+       labelED->setReadOnly(readonly);
+       if (!InsetParamsWidget::checkWidgets())
+               return false;
        return !keyED->text().isEmpty();
 }
 
-
-Dialog * createGuiBibitem(GuiView & lv) { return new GuiBibitem(lv); }
-
-
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiBibitem_moc.cpp"
+#include "moc_GuiBibitem.cpp"