diff --git a/src/frontends/qt4/GuiRef.cpp b/src/frontends/qt4/GuiRef.cpp index ae440b05ad..c07ce5ce87 100644 --- a/src/frontends/qt4/GuiRef.cpp +++ b/src/frontends/qt4/GuiRef.cpp @@ -18,6 +18,8 @@ #include "Buffer.h" #include "BufferParams.h" #include "BufferList.h" +#include "BufferView.h" +#include "Cursor.h" #include "FuncRequest.h" #include "qt_helpers.h" @@ -293,10 +295,26 @@ void GuiRef::closeEvent(QCloseEvent * e) void GuiRef::updateContents() { - int orig_type = typeCO->currentIndex(); + QString const orig_type = + typeCO->itemData(typeCO->currentIndex()).toString(); referenceED->clear(); nameED->clear(); + typeCO->clear(); + + // FIXME Bring InsetMathRef on par with InsetRef + // (see #9798) + typeCO->addItem(qt_(""), "ref"); + typeCO->addItem(qt_("()"), "eqref"); + typeCO->addItem(qt_(""), "pageref"); + typeCO->addItem(qt_("on page "), "vpageref"); + typeCO->addItem(qt_(" on page "), "vref"); + if (bufferview()->cursor().inTexted()) { + typeCO->addItem(qt_("Formatted reference"), "formatted"); + typeCO->addItem(qt_("Textual reference"), "nameref"); + typeCO->addItem(qt_("Label only"), "labelonly"); + } else + typeCO->addItem(qt_("Formatted reference"), "prettyref"); referenceED->setText(toqstr(params_["reference"])); nameED->setText(toqstr(params_["name"])); @@ -305,10 +323,15 @@ void GuiRef::updateContents() // restore type settings for new insets bool const new_inset = params_["reference"].empty(); - if (new_inset) - typeCO->setCurrentIndex(orig_type); + if (new_inset) { + int index = typeCO->findData(orig_type); + if (index == -1) + index = 0; + typeCO->setCurrentIndex(index); + } else - typeCO->setCurrentIndex(InsetRef::getType(params_.getCmdName())); + typeCO->setCurrentIndex( + typeCO->findData(toqstr(params_.getCmdName()))); typeCO->setEnabled(typeAllowed() && !isBufferReadonly()); if (!typeAllowed()) typeCO->setCurrentIndex(0); @@ -350,7 +373,7 @@ void GuiRef::applyView() { last_reference_ = referenceED->text(); - params_.setCmdName(InsetRef::getName(typeCO->currentIndex())); + params_.setCmdName(fromqstr(typeCO->itemData(typeCO->currentIndex()).toString())); params_["reference"] = qstring_to_ucs4(last_reference_); params_["name"] = qstring_to_ucs4(nameED->text()); params_["plural"] = pluralCB->isChecked() ? diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 4a49cfbac8..44770e8052 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -56,6 +56,7 @@ bool InsetRef::isCompatibleCommand(string const & s) { || s == "vref" || s == "vpageref" || s == "formatted" + || s == "prettyref" // for InsetMathRef FIXME || s == "eqref" || s == "nameref" || s == "labelonly";