]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiHyperlink.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiHyperlink.cpp
index 7cb9cc61d4ad7f5c4791eb3416fd9708c5137d96..c063ca236260789badf89e16a8178c55e010e019 100644 (file)
@@ -24,8 +24,8 @@ namespace lyx {
        namespace frontend {
                bool operator==(lyx::docstring const & d, char const * c)
                  { return lyx::operator ==(d, c); }
-       }
-}
+       } // namespace frontend
+} // namespace lyx
 #endif
 
 
@@ -40,6 +40,8 @@ GuiHyperlink::GuiHyperlink(QWidget * parent) : InsetParamsWidget(parent)
                this, SIGNAL(changed()));
        connect(nameED, SIGNAL(textChanged(const QString &)),
                this, SIGNAL(changed()));
+       connect(literalCB, SIGNAL(clicked()),
+               this, SIGNAL(changed()));
        connect(webRB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(emailRB, SIGNAL(clicked()),
@@ -58,6 +60,7 @@ void GuiHyperlink::paramsToDialog(Inset const * inset)
 
        targetED->setText(toqstr(params["target"]));
        nameED->setText(toqstr(params["name"]));
+       literalCB->setChecked(params["literal"] == "true");
        docstring const & type = params["type"];
        if (type.empty())
                webRB->setChecked(true);
@@ -68,6 +71,24 @@ void GuiHyperlink::paramsToDialog(Inset const * inset)
 }
 
 
+bool GuiHyperlink::initialiseParams(std::string const & sdata)
+{
+       InsetCommandParams params(insetCode());
+       if (!InsetCommand::string2params(sdata, params))
+               return false;
+       targetED->setText(toqstr(params["target"]));
+       nameED->setText(toqstr(params["name"]));
+       literalCB->setChecked(params["literal"] == "true");
+       if (params["type"] == from_utf8("mailto:"))
+               emailRB->setChecked(true);
+       else if (params["type"] == from_utf8("file:"))
+               fileRB->setChecked(true);
+       else
+               webRB->setChecked(true);
+       return true;
+}
+
+
 docstring GuiHyperlink::dialogToParams() const
 {
        InsetCommandParams params(insetCode());
@@ -75,18 +96,23 @@ docstring GuiHyperlink::dialogToParams() const
        params["target"] = qstring_to_ucs4(targetED->text());
        params["name"] = qstring_to_ucs4(nameED->text());
        if (webRB->isChecked())
-               params["type"] = qstring_to_ucs4("");
+               params["type"] = from_utf8("");
        else if (emailRB->isChecked())
-               params["type"] = qstring_to_ucs4("mailto:");
+               params["type"] = from_utf8("mailto:");
        else if (fileRB->isChecked())
-               params["type"] = qstring_to_ucs4("file:");
+               params["type"] = from_utf8("file:");
+       params["literal"] = literalCB->isChecked()
+                       ? from_ascii("true") : from_ascii("false");
        params.setCmdName("href");
        return from_utf8(InsetHyperlink::params2string(params));
 }
 
 
-bool GuiHyperlink::checkWidgets() const
+bool GuiHyperlink::checkWidgets(bool readonly) const
 {
+       targetED->setReadOnly(readonly);
+       nameED->setReadOnly(readonly);
+       typeGB->setEnabled(!readonly);
        if (!InsetParamsWidget::checkWidgets())
                return false;
        return !targetED->text().isEmpty() || !nameED->text().isEmpty();