2006-11-04 17:55:36 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiNomencl.cpp
|
2006-11-04 17:55:36 +00:00
|
|
|
* 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>
|
|
|
|
|
2010-10-27 20:15:35 +00:00
|
|
|
#include "GuiNomenclature.h"
|
2007-09-03 05:59:32 +00:00
|
|
|
|
2006-11-04 17:55:36 +00:00
|
|
|
#include "qt_helpers.h"
|
2008-04-20 09:24:14 +00:00
|
|
|
|
2010-10-27 20:01:49 +00:00
|
|
|
#include "insets/InsetNomencl.h"
|
2006-11-04 17:55:36 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2006-11-04 17:55:36 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2010-10-27 20:01:49 +00:00
|
|
|
GuiNomenclature::GuiNomenclature(QWidget * parent) : InsetParamsWidget(parent)
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-10-07 14:41:49 +00:00
|
|
|
connect(symbolED, SIGNAL(textChanged(QString)),
|
2010-10-27 20:01:49 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-04-25 10:57:54 +00:00
|
|
|
connect(descriptionTE, SIGNAL(textChanged()),
|
2010-10-27 20:01:49 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-04-25 10:57:54 +00:00
|
|
|
|
|
|
|
setFocusProxy(descriptionTE);
|
2007-09-05 20:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-27 20:01:49 +00:00
|
|
|
void GuiNomenclature::paramsToDialog(Inset const * inset)
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
2010-10-27 20:01:49 +00:00
|
|
|
InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
|
|
|
|
InsetCommandParams const & params = nomencl->params();
|
2007-04-25 10:57:54 +00:00
|
|
|
|
2010-10-27 20:01:49 +00:00
|
|
|
prefixED->setText(toqstr(params["prefix"]));
|
|
|
|
symbolED->setText(toqstr(params["symbol"]));
|
|
|
|
QString description = toqstr(params["description"]);
|
2007-04-06 16:27:10 +00:00
|
|
|
description.replace("\\\\","\n");
|
2007-09-05 20:33:29 +00:00
|
|
|
descriptionTE->setPlainText(description);
|
2009-11-06 15:22:21 +00:00
|
|
|
descriptionTE->setFocus();
|
2006-11-04 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-27 20:01:49 +00:00
|
|
|
docstring GuiNomenclature::dialogToParams() const
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
2010-10-27 20:01:49 +00:00
|
|
|
InsetCommandParams params(insetCode());
|
|
|
|
params["prefix"] = qstring_to_ucs4(prefixED->text());
|
|
|
|
params["symbol"] = qstring_to_ucs4(symbolED->text());
|
2007-09-05 20:33:29 +00:00
|
|
|
QString description = descriptionTE->toPlainText();
|
2007-04-06 16:27:10 +00:00
|
|
|
description.replace('\n',"\\\\");
|
2010-10-27 20:01:49 +00:00
|
|
|
params["description"] = qstring_to_ucs4(description);
|
|
|
|
return from_ascii(InsetNomencl::params2string("nomenclature", params));
|
2006-11-04 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-27 20:01:49 +00:00
|
|
|
bool GuiNomenclature::checkWidgets() const
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
2010-10-27 20:01:49 +00:00
|
|
|
if (!InsetParamsWidget::checkWidgets())
|
|
|
|
return false;
|
2007-09-05 20:33:29 +00:00
|
|
|
QString const description = descriptionTE->toPlainText();
|
|
|
|
return !symbolED->text().isEmpty() && !description.isEmpty();
|
2006-11-04 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 10:57:54 +00:00
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiNomencl.cpp"
|