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 "ControlCommand.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-09-05 20:33:29 +00:00
|
|
|
GuiNomenclDialog::GuiNomenclDialog(LyXView & lv)
|
|
|
|
: GuiDialog(lv, "nomenclature")
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
setController(new ControlCommand(*this, "nomenclature", "nomenclature"));
|
2007-04-25 10:57:54 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-04-25 10:57:54 +00:00
|
|
|
connect(symbolED, SIGNAL(textChanged(const 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ControlCommand & GuiNomenclDialog::controller() const
|
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
return static_cast<ControlCommand &>(GuiDialog::controller());
|
2007-04-25 10:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiNomenclDialog::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-08-31 05:53:55 +00:00
|
|
|
void GuiNomenclDialog::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-08-31 05:53:55 +00:00
|
|
|
void GuiNomenclDialog::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-09-05 20:33:29 +00:00
|
|
|
void GuiNomenclDialog::update_contents()
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
prefixED->setText(toqstr(controller().params()["prefix"]));
|
|
|
|
symbolED->setText(toqstr(controller().params()["symbol"]));
|
2007-04-06 16:27:10 +00:00
|
|
|
QString description = toqstr(controller().params()["description"]);
|
|
|
|
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-09-05 20:33:29 +00:00
|
|
|
void GuiNomenclDialog::applyView()
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
controller().params()["prefix"] = qstring_to_ucs4(prefixED->text());
|
|
|
|
controller().params()["symbol"] = qstring_to_ucs4(symbolED->text());
|
|
|
|
QString description = descriptionTE->toPlainText();
|
2007-04-06 16:27:10 +00:00
|
|
|
description.replace('\n',"\\\\");
|
|
|
|
controller().params()["description"] = qstring_to_ucs4(description);
|
2006-11-04 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bool GuiNomenclDialog::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
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 10:57:54 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiNomencl_moc.cpp"
|