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>
|
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
#include "GuiNomencl.h"
|
|
|
|
|
2006-11-04 17:55:36 +00:00
|
|
|
#include "qt_helpers.h"
|
2008-04-20 09:24:14 +00:00
|
|
|
#include "FuncRequest.h"
|
|
|
|
|
|
|
|
#include "insets/InsetCommand.h"
|
2006-11-04 17:55:36 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
|
|
|
|
2007-04-06 16:27:10 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
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 {
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiNomenclature::GuiNomenclature(GuiView & lv)
|
2008-04-20 09:24:14 +00:00
|
|
|
: GuiDialog(lv, "nomenclature", qt_("Nomenclature")),
|
|
|
|
params_(insetCode("nomenclature"))
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-10-07 14:41:49 +00:00
|
|
|
connect(symbolED, SIGNAL(textChanged(QString)),
|
2007-05-28 22:27:45 +00:00
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-25 10:57:54 +00:00
|
|
|
connect(descriptionTE, SIGNAL(textChanged()),
|
2007-05-28 22:27:45 +00:00
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-25 10:57:54 +00:00
|
|
|
|
|
|
|
setFocusProxy(descriptionTE);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
|
|
bc().setOK(okPB);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
bc().addReadOnly(symbolED);
|
|
|
|
bc().addReadOnly(descriptionTE);
|
|
|
|
bc().addReadOnly(prefixED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
void GuiNomenclature::change_adaptor()
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-04-25 10:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
void GuiNomenclature::reject()
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
slotClose();
|
2007-04-25 10:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-16 11:33:07 +00:00
|
|
|
void GuiNomenclature::paramsToDialog(InsetCommandParams const & /*icp*/)
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
2007-10-07 14:41: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);
|
2006-11-04 17:55:36 +00:00
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().setValid(isValid());
|
2006-11-04 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
void GuiNomenclature::applyView()
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
2007-10-07 14:41:49 +00:00
|
|
|
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',"\\\\");
|
2007-10-07 14:41:49 +00:00
|
|
|
params_["description"] = qstring_to_ucs4(description);
|
2006-11-04 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
bool GuiNomenclature::isValid()
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
|
2008-04-20 09:24:14 +00:00
|
|
|
bool GuiNomenclature::initialiseParams(std::string const & data)
|
|
|
|
{
|
|
|
|
InsetCommand::string2params("nomenclature", data, params_);
|
2008-09-03 12:59:36 +00:00
|
|
|
paramsToDialog(params_);
|
2008-04-20 09:24:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiNomenclature::dispatchParams()
|
|
|
|
{
|
|
|
|
std::string const lfun = InsetCommand::params2string("nomenclature", params_);
|
|
|
|
dispatch(FuncRequest(getLfun(), lfun));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiNomenclature(GuiView & lv)
|
2007-10-07 14:41:49 +00:00
|
|
|
{
|
|
|
|
return new GuiNomenclature(lv);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-04 17:55:36 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 10:57:54 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiNomencl_moc.cpp"
|