]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiHyperlink.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiHyperlink.cpp
index 063bce724ee924c493fa2f9baaef349b4e3d927a..8323b65ff3d3f1f625f602fbfa9f53bbfcc5bdca 100644 (file)
@@ -18,7 +18,6 @@
 #include "insets/InsetCommand.h"
 
 #include <QCheckBox>
-#include <QCloseEvent>
 #include <QLineEdit>
 #include <QPushButton>
 
@@ -27,7 +26,8 @@ namespace lyx {
 namespace frontend {
 
 GuiHyperlink::GuiHyperlink(GuiView & lv)
-       : GuiCommand(lv, "href",qt_("Hyperlink"))
+       : GuiDialog(lv, "href", qt_("Hyperlink")),
+    params_(insetCode("href"))
 {
        setupUi(this);
 
@@ -46,6 +46,8 @@ GuiHyperlink::GuiHyperlink(GuiView & lv)
 
        setFocusProxy(targetED);
 
+       bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
+
        bc().setOK(okPB);
        bc().setCancel(closePB);
        bc().addReadOnly(targetED);
@@ -62,7 +64,7 @@ void GuiHyperlink::changed_adaptor()
 }
 
 
-void GuiHyperlink::updateContents()
+void GuiHyperlink::paramsToDialog(InsetCommandParams const & /*icp*/)
 {
        targetED->setText(toqstr(params_["target"]));
        nameED->setText(toqstr(params_["name"]));
@@ -92,10 +94,24 @@ void GuiHyperlink::applyView()
 
 bool GuiHyperlink::isValid()
 {
-       QString const u = targetED->text();
-       QString const n = nameED->text();
+       return !targetED->text().isEmpty() || !nameED->text().isEmpty();
+}
+
+
+bool GuiHyperlink::initialiseParams(std::string const & data)
+{
+       // The name passed with LFUN_INSET_APPLY is also the name
+       // used to identify the mailer.
+       InsetCommand::string2params("href", data, params_);
+       paramsToDialog(params_);
+       return true;
+}
 
-       return !u.isEmpty() || !n.isEmpty();
+
+void GuiHyperlink::dispatchParams()
+{
+       std::string const lfun = InsetCommand::params2string("href", params_);
+       dispatch(FuncRequest(getLfun(), lfun));
 }
 
 
@@ -106,4 +122,4 @@ Dialog * createGuiHyperlink(GuiView & lv) { return new GuiHyperlink(lv); }
 } // namespace lyx
 
 
-#include "GuiHyperlink_moc.cpp"
+#include "moc_GuiHyperlink.cpp"