2009-05-22 17:17:45 +00:00
|
|
|
/**
|
|
|
|
* \file GuiPrintNomencl.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Jürgen Spitzmüller
|
|
|
|
* \author Uwe Stöhr
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GuiPrintNomencl.h"
|
|
|
|
|
|
|
|
#include "LengthCombo.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
#include "Validator.h"
|
|
|
|
|
|
|
|
#include "FuncRequest.h"
|
|
|
|
|
|
|
|
#include "insets/InsetNomencl.h"
|
|
|
|
|
|
|
|
#include "support/gettext.h"
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2010-10-30 20:14:57 +00:00
|
|
|
GuiPrintNomencl::GuiPrintNomencl(QWidget * parent) : InsetParamsWidget(parent)
|
2009-05-22 17:17:45 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(valueLE, SIGNAL(textChanged(QString)),
|
2010-10-30 20:14:57 +00:00
|
|
|
this, SIGNAL(changed()));
|
2009-05-22 17:17:45 +00:00
|
|
|
connect(unitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2010-10-30 20:14:57 +00:00
|
|
|
this, SIGNAL(changed()));
|
2009-05-22 17:17:45 +00:00
|
|
|
|
|
|
|
valueLE->setValidator(unsignedLengthValidator(valueLE));
|
|
|
|
|
|
|
|
// initialize the length validator
|
2010-10-30 20:14:57 +00:00
|
|
|
addCheckedWidget(valueLE, valueLA);
|
2009-05-22 17:17:45 +00:00
|
|
|
|
2009-05-23 05:30:01 +00:00
|
|
|
setWidthCO->addItem(qt_("Default"),
|
2009-05-22 17:17:45 +00:00
|
|
|
QVariant(toqstr("none")));
|
2009-05-23 05:30:01 +00:00
|
|
|
setWidthCO->addItem(qt_("Longest label width"),
|
2009-05-22 17:17:45 +00:00
|
|
|
QVariant(toqstr("auto")));
|
|
|
|
setWidthCO->addItem(qt_("Custom"),
|
|
|
|
QVariant(toqstr("custom")));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintNomencl::on_setWidthCO_activated(int i)
|
|
|
|
{
|
|
|
|
bool const custom =
|
2011-10-24 23:35:01 +00:00
|
|
|
(setWidthCO->itemData(i).toString() == "custom");
|
2009-05-22 17:17:45 +00:00
|
|
|
valueLE->setEnabled(custom);
|
|
|
|
unitLC->setEnabled(custom);
|
|
|
|
valueLA->setEnabled(custom);
|
|
|
|
changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-30 20:14:57 +00:00
|
|
|
void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
|
2009-05-22 17:17:45 +00:00
|
|
|
{
|
|
|
|
setWidthCO->setCurrentIndex(
|
2010-10-30 20:14:57 +00:00
|
|
|
setWidthCO->findData(toqstr(params["set_width"])));
|
2009-05-22 17:17:45 +00:00
|
|
|
|
2011-10-24 23:35:01 +00:00
|
|
|
lengthToWidgets(valueLE, unitLC,
|
|
|
|
params["width"], Length::defaultUnit());
|
|
|
|
|
|
|
|
bool const custom =
|
|
|
|
(setWidthCO->itemData(setWidthCO->currentIndex()).toString() == "custom");
|
|
|
|
valueLE->setEnabled(custom);
|
|
|
|
unitLC->setEnabled(custom);
|
|
|
|
valueLA->setEnabled(custom);
|
2009-05-22 17:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-30 20:14:57 +00:00
|
|
|
void GuiPrintNomencl::paramsToDialog(Inset const * inset)
|
2009-05-22 17:17:45 +00:00
|
|
|
{
|
2010-10-30 20:14:57 +00:00
|
|
|
InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
|
|
|
|
paramsToDialog(nomencl->params());
|
2009-05-22 17:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-30 20:14:57 +00:00
|
|
|
docstring GuiPrintNomencl::dialogToParams() const
|
2009-05-22 17:17:45 +00:00
|
|
|
{
|
2010-10-30 20:14:57 +00:00
|
|
|
InsetCommandParams params(insetCode());
|
2009-05-22 17:17:45 +00:00
|
|
|
docstring const set_width = qstring_to_ucs4(setWidthCO->itemData(
|
|
|
|
setWidthCO->currentIndex()).toString());
|
2010-10-30 20:14:57 +00:00
|
|
|
params["set_width"] = set_width;
|
2009-05-22 17:17:45 +00:00
|
|
|
docstring width;
|
|
|
|
if (set_width == from_ascii("custom"))
|
|
|
|
width = from_utf8(widgetsToLength(valueLE, unitLC));
|
2010-10-30 20:14:57 +00:00
|
|
|
params["width"] = width;
|
|
|
|
return from_ascii(InsetNomencl::params2string(params));
|
2009-05-22 17:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-30 20:14:57 +00:00
|
|
|
bool GuiPrintNomencl::checkWidgets() const
|
2009-05-22 17:35:50 +00:00
|
|
|
{
|
2010-10-30 20:14:57 +00:00
|
|
|
if (!InsetParamsWidget::checkWidgets())
|
|
|
|
return false;
|
2009-05-26 16:19:03 +00:00
|
|
|
return setWidthCO->itemData(
|
2009-05-22 17:35:50 +00:00
|
|
|
setWidthCO->currentIndex()).toString() != "custom"
|
2009-05-26 16:19:03 +00:00
|
|
|
|| !valueLE->text().isEmpty();
|
2009-05-22 17:35:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 17:17:45 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
|
|
|
|
#include "moc_GuiPrintNomencl.cpp"
|