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>
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
#include "ControlCommand.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiNomencl.h"
|
2006-11-04 17:55:36 +00:00
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "ButtonController.h"
|
2007-08-31 22:16:11 +00:00
|
|
|
|
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-04-25 10:57:54 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2007-08-31 05:53:55 +00:00
|
|
|
// GuiNomenclDialog
|
2007-04-25 10:57:54 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
GuiNomenclDialog::GuiNomenclDialog(GuiNomencl * form)
|
2007-04-25 10:57:54 +00:00
|
|
|
: form_(form)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
|
|
|
|
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-08-31 05:53:55 +00:00
|
|
|
void GuiNomenclDialog::show()
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
|
|
|
QDialog::show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiNomenclDialog::change_adaptor()
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiNomenclDialog::reject()
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
|
|
|
form_->slotClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiNomenclDialog::closeEvent(QCloseEvent * e)
|
2007-04-25 10:57:54 +00:00
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2007-08-31 05:53:55 +00:00
|
|
|
// GuiNomencl
|
2007-04-25 10:57:54 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
GuiNomencl::GuiNomencl(Dialog & parent, docstring const & title)
|
2007-08-31 22:16:11 +00:00
|
|
|
: GuiView<GuiNomenclDialog>(parent, title)
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiNomencl::build_dialog()
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
2007-08-31 05:53:55 +00:00
|
|
|
dialog_.reset(new GuiNomenclDialog(this));
|
2006-11-04 17:55:36 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiNomencl::update_contents()
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiNomencl::apply()
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
bool GuiNomencl::isValid()
|
2006-11-04 17:55:36 +00:00
|
|
|
{
|
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
|
2007-04-25 10:57:54 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiNomencl_moc.cpp"
|