]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiLabel.cpp
rename buffer parameter math_number_before to math_numbering_side
[lyx.git] / src / frontends / qt4 / GuiLabel.cpp
index b90723e958f6fabda1a02a3613110c6025db84e4..d5b207f7738ce426aa8b7f19e6c6d341b7b4d27b 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "qt_helpers.h"
 
-#include "support/debug.h"
+#include "insets/InsetLabel.h"
 
 #include <QLabel>
 #include <QPushButton>
@@ -27,65 +27,56 @@ namespace frontend {
 
 /////////////////////////////////////////////////////////////////
 //
-// Base implementation
+// GuiLabel
 //
 /////////////////////////////////////////////////////////////////
 
-GuiLabel::GuiLabel(GuiView & lv)
-       : GuiCommand(lv, "label", qt_("Label"))
+GuiLabel::GuiLabel(QWidget * parent) : InsetParamsWidget(parent)
 {
        setupUi(this);
 
-       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
-       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
        connect(keywordED, SIGNAL(textChanged(const QString &)),
-               this, SLOT(change_adaptor()));
+               this, SIGNAL(changed()));
 
        setFocusProxy(keywordED);
-
-       bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
-       bc().setOK(okPB);
-       bc().setCancel(closePB);
-       bc().addReadOnly(keywordED);
-}
-
-
-void GuiLabel::change_adaptor()
-{
-       changed();
 }
 
 
-void GuiLabel::reject()
+void GuiLabel::paramsToDialog(Inset const * inset)
 {
-       slotClose();
+       InsetLabel const * label = static_cast<InsetLabel const *>(inset);
+       InsetCommandParams const & params = label->params();
+       keywordED->setText(toqstr(params["name"]));
 }
 
 
-void GuiLabel::updateContents()
+docstring GuiLabel::dialogToParams() const
 {
-       docstring const contents = params_["name"];
-       keywordED->setText(toqstr(contents));
-       bc().setValid(!contents.empty());
+       InsetCommandParams params(insetCode());
+       params["name"] = qstring_to_ucs4(keywordED->text());
+       return from_utf8(InsetLabel::params2string(params));
 }
 
 
-void GuiLabel::applyView()
+bool GuiLabel::initialiseParams(std::string const & data)
 {
-       params_["name"] = qstring_to_ucs4(keywordED->text());
+       InsetCommandParams p(insetCode());
+       if (!InsetCommand::string2params(data, p))
+               return false;
+       keywordED->setText(toqstr(p["name"]));
+       return true;
 }
 
 
-bool GuiLabel::isValid()
+bool GuiLabel::checkWidgets(bool readonly) const
 {
+       keywordED->setReadOnly(readonly);
+       if (!InsetParamsWidget::checkWidgets())
+               return false;
        return !keywordED->text().isEmpty();
 }
 
-
-Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
-
-
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiLabel_moc.cpp"
+#include "moc_GuiLabel.cpp"