2008-02-14 18:06:47 +00:00
|
|
|
/**
|
|
|
|
* \file GuiLabel.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GuiLabel.h"
|
|
|
|
|
2008-04-20 09:24:14 +00:00
|
|
|
#include "FuncRequest.h"
|
2008-02-14 18:06:47 +00:00
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2008-04-20 09:24:14 +00:00
|
|
|
#include "insets/InsetCommand.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
|
2008-02-14 18:06:47 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2008-04-20 09:24:14 +00:00
|
|
|
// GuiLabel
|
2008-02-14 18:06:47 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
GuiLabel::GuiLabel(GuiView & lv)
|
2008-04-20 09:24:14 +00:00
|
|
|
: GuiDialog(lv, "label", qt_("Label")),
|
|
|
|
params_(insetCode("label"))
|
2008-02-14 18:06:47 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
|
|
|
connect(keywordED, SIGNAL(textChanged(const QString &)),
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
|
|
|
setFocusProxy(keywordED);
|
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
|
|
bc().setOK(okPB);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
bc().addReadOnly(keywordED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiLabel::change_adaptor()
|
|
|
|
{
|
|
|
|
changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiLabel::reject()
|
|
|
|
{
|
|
|
|
slotClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiLabel::updateContents()
|
|
|
|
{
|
|
|
|
docstring const contents = params_["name"];
|
|
|
|
keywordED->setText(toqstr(contents));
|
|
|
|
bc().setValid(!contents.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiLabel::applyView()
|
|
|
|
{
|
|
|
|
params_["name"] = qstring_to_ucs4(keywordED->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GuiLabel::isValid()
|
|
|
|
{
|
|
|
|
return !keywordED->text().isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-20 09:24:14 +00:00
|
|
|
bool GuiLabel::initialiseParams(std::string const & data)
|
|
|
|
{
|
|
|
|
InsetCommand::string2params("label", data, params_);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiLabel::dispatchParams()
|
|
|
|
{
|
|
|
|
std::string const lfun = InsetCommand::params2string("label", params_);
|
|
|
|
dispatch(FuncRequest(getLfun(), lfun));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-14 18:06:47 +00:00
|
|
|
Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiLabel.cpp"
|