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 "debug.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2007-04-06 16:27:10 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QTextEdit>
|
2007-04-25 10:57:54 +00:00
|
|
|
#include <QWhatsThis>
|
|
|
|
#include <QCloseEvent>
|
2006-11-04 17:55:36 +00:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiNomenclature::GuiNomenclature(GuiView & lv)
|
2007-10-07 14:41:49 +00:00
|
|
|
: GuiCommand(lv, "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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
void GuiNomenclature::closeEvent(QCloseEvent * e)
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
2007-09-11 17:06:15 +00:00
|
|
|
slotClose();
|
2007-04-25 10:57:54 +00:00
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
void GuiNomenclature::updateContents()
|
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
|
|
|
|
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"
|