lyx_mirror/src/frontends/qt4/GuiNomencl.cpp
André Pönitz 94e61a3bc9 shuffle some frontend stuff around. merge controller(base) and "Kernel". Make frontend::Dialog pure virtual
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20202 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-10 22:32:59 +00:00

113 lines
2.4 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 "GuiNomencl.h"
#include "debug.h"
#include "ControlCommand.h"
#include "qt_helpers.h"
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QTextEdit>
#include <QWhatsThis>
#include <QCloseEvent>
using std::string;
namespace lyx {
namespace frontend {
GuiNomenclDialog::GuiNomenclDialog(LyXView & lv)
: GuiDialog(lv, "nomenclature")
{
setupUi(this);
setController(new ControlCommand(*this, "nomenclature", "nomenclature"));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(symbolED, SIGNAL(textChanged(const QString&)),
this, SLOT(change_adaptor()));
connect(descriptionTE, SIGNAL(textChanged()),
this, SLOT(change_adaptor()));
setFocusProxy(descriptionTE);
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
bc().addReadOnly(symbolED);
bc().addReadOnly(descriptionTE);
bc().addReadOnly(prefixED);
}
ControlCommand & GuiNomenclDialog::controller() const
{
return static_cast<ControlCommand &>(GuiDialog::controller());
}
void GuiNomenclDialog::change_adaptor()
{
changed();
}
void GuiNomenclDialog::reject()
{
slotClose();
}
void GuiNomenclDialog::closeEvent(QCloseEvent * e)
{
slotWMHide();
e->accept();
}
void GuiNomenclDialog::update_contents()
{
prefixED->setText(toqstr(controller().params()["prefix"]));
symbolED->setText(toqstr(controller().params()["symbol"]));
QString description = toqstr(controller().params()["description"]);
description.replace("\\\\","\n");
descriptionTE->setPlainText(description);
bc().setValid(isValid());
}
void GuiNomenclDialog::applyView()
{
controller().params()["prefix"] = qstring_to_ucs4(prefixED->text());
controller().params()["symbol"] = qstring_to_ucs4(symbolED->text());
QString description = descriptionTE->toPlainText();
description.replace('\n',"\\\\");
controller().params()["description"] = qstring_to_ucs4(description);
}
bool GuiNomenclDialog::isValid()
{
QString const description = descriptionTE->toPlainText();
return !symbolED->text().isEmpty() && !description.isEmpty();
}
} // namespace frontend
} // namespace lyx
#include "GuiNomencl_moc.cpp"