mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-16 16:18:22 +00:00
e15a8f3551
File format change. This allows for the relevant InsetCommand-based dialogs (such as citation text before/after, Bibitem label, hyperlink name etc.) to provide both the input of verbatim code or text that is transformed to proper LaTeX code. Some dialogs (Nomencl, Href) already had some methods (although they could not be toggled), which are now centralized and streamlined. The initial work of this patch has been done by Georg Baum (see http://www.lyx.org/trac/attachment/ticket/2751/x.diff) Fixes: #2751, #8227.
92 lines
2.3 KiB
C++
92 lines
2.3 KiB
C++
/**
|
|
* \file GuiNomencl.cpp
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author John Levon
|
|
* \author O. U. Baran
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "GuiNomenclature.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
#include "insets/InsetNomencl.h"
|
|
|
|
using namespace std;
|
|
|
|
namespace lyx {
|
|
namespace frontend {
|
|
|
|
GuiNomenclature::GuiNomenclature(QWidget * parent) : InsetParamsWidget(parent)
|
|
{
|
|
setupUi(this);
|
|
connect(symbolED, SIGNAL(textChanged(QString)),
|
|
this, SIGNAL(changed()));
|
|
connect(descriptionTE, SIGNAL(textChanged()),
|
|
this, SIGNAL(changed()));
|
|
connect(literalCB, SIGNAL(clicked()),
|
|
this, SIGNAL(changed()));
|
|
|
|
setFocusProxy(descriptionTE);
|
|
}
|
|
|
|
|
|
void GuiNomenclature::paramsToDialog(Inset const * inset)
|
|
{
|
|
InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
|
|
InsetCommandParams const & params = nomencl->params();
|
|
|
|
prefixED->setText(toqstr(params["prefix"]));
|
|
symbolED->setText(toqstr(params["symbol"]));
|
|
literalCB->setChecked(params["literal"] == "true");
|
|
QString description = toqstr(params["description"]);
|
|
description.replace("\\\\","\n");
|
|
descriptionTE->setPlainText(description);
|
|
descriptionTE->setFocus();
|
|
}
|
|
|
|
|
|
docstring GuiNomenclature::dialogToParams() const
|
|
{
|
|
InsetCommandParams params(insetCode());
|
|
params["prefix"] = qstring_to_ucs4(prefixED->text());
|
|
params["symbol"] = qstring_to_ucs4(symbolED->text());
|
|
QString description = descriptionTE->toPlainText();
|
|
description.replace('\n',"\\\\");
|
|
params["description"] = qstring_to_ucs4(description);
|
|
params["literal"] = literalCB->isChecked()
|
|
? from_ascii("true") : from_ascii("false");
|
|
return from_utf8(InsetNomencl::params2string(params));
|
|
}
|
|
|
|
|
|
bool GuiNomenclature::initialiseParams(std::string const & data)
|
|
{
|
|
InsetCommandParams p(insetCode());
|
|
if (!InsetCommand::string2params(data, p))
|
|
return false;
|
|
symbolED->setText(toqstr(p["symbol"]));
|
|
return true;
|
|
}
|
|
|
|
|
|
bool GuiNomenclature::checkWidgets(bool readonly) const
|
|
{
|
|
symbolED->setReadOnly(readonly);
|
|
descriptionTE->setReadOnly(readonly);
|
|
if (!InsetParamsWidget::checkWidgets())
|
|
return false;
|
|
QString const description = descriptionTE->toPlainText();
|
|
return !symbolED->text().isEmpty() && !description.isEmpty();
|
|
}
|
|
|
|
} // namespace frontend
|
|
} // namespace lyx
|
|
|
|
#include "moc_GuiNomenclature.cpp"
|