2006-11-04 17:55:36 +00:00
|
|
|
/**
|
|
|
|
* \file QNomencl.C
|
|
|
|
* 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 "debug.h"
|
|
|
|
#include "ControlCommand.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include "QNomenclDialog.h"
|
|
|
|
#include "QNomencl.h"
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "ButtonController.h"
|
2007-04-06 16:27:10 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QTextEdit>
|
2006-11-04 17:55:36 +00:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-03-22 23:07:24 +00:00
|
|
|
typedef QController<ControlCommand, QView<QNomenclDialog> > nomencl_base_class;
|
2006-11-04 17:55:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
QNomencl::QNomencl(Dialog & parent, docstring const & title)
|
2007-03-22 23:07:24 +00:00
|
|
|
: nomencl_base_class(parent, title)
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QNomencl::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QNomenclDialog(this));
|
|
|
|
|
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
bcview().addReadOnly(dialog_->symbolED);
|
2007-04-06 16:27:10 +00:00
|
|
|
bcview().addReadOnly(dialog_->descriptionTE);
|
2006-11-04 17:55:36 +00:00
|
|
|
bcview().addReadOnly(dialog_->prefixED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QNomencl::update_contents()
|
|
|
|
{
|
|
|
|
dialog_->prefixED->setText(toqstr(controller().params()["prefix"]));
|
|
|
|
dialog_->symbolED->setText(toqstr(controller().params()["symbol"]));
|
2007-04-06 16:27:10 +00:00
|
|
|
QString description = toqstr(controller().params()["description"]);
|
|
|
|
description.replace("\\\\","\n");
|
|
|
|
dialog_->descriptionTE->setPlainText(description);
|
2006-11-04 17:55:36 +00:00
|
|
|
|
|
|
|
bc().valid(isValid());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QNomencl::apply()
|
|
|
|
{
|
|
|
|
controller().params()["prefix"] = qstring_to_ucs4(dialog_->prefixED->text());
|
|
|
|
controller().params()["symbol"] = qstring_to_ucs4(dialog_->symbolED->text());
|
2007-04-06 16:27:10 +00:00
|
|
|
QString description = dialog_->descriptionTE->toPlainText();
|
|
|
|
description.replace('\n',"\\\\");
|
|
|
|
controller().params()["description"] = qstring_to_ucs4(description);
|
2006-11-04 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QNomencl::isValid()
|
|
|
|
{
|
2007-04-06 16:27:10 +00:00
|
|
|
QString const description = dialog_->descriptionTE->toPlainText();
|
|
|
|
return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
|
2006-11-04 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|