lyx_mirror/src/frontends/qt4/GuiNomencl.cpp
Richard Heck 0787ade6c0 This is the first part of a cleanup of how we handle the InsetCommand hierarchy. This part starts to disentangle the type of the inset from the command that a single instance of the inset represents. This involves two sorts of changes:
(i) The file format is changed, so that command insets are represented as:
    \begin_inset CommandInset insetype
    LatexCommand command
    ...
    \end_inset
This involves some lyx2lyx and changes to the readInset() routine in factory.cpp
(ii) The InsetCommand and InsetCommandParams classes also have to be changed, as the command name was used in these classes for various purposes for which the inset type ought really to be used.
Further clean-up to come.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20544 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-27 18:24:18 +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"));
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()
{
return static_cast<ControlCommand &>(GuiDialog::controller());
}
void GuiNomenclDialog::change_adaptor()
{
changed();
}
void GuiNomenclDialog::reject()
{
slotClose();
}
void GuiNomenclDialog::closeEvent(QCloseEvent * e)
{
slotClose();
e->accept();
}
void GuiNomenclDialog::updateContents()
{
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"