2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiIndex.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* 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>
|
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
#include "GuiIndex.h"
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
#include "ControlCommand.h"
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "debug.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2007-04-25 08:42:22 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QCloseEvent>
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
using std::string;
|
|
|
|
|
2007-04-25 08:42:22 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-09-08 22:08:46 +00:00
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Base implementation
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
GuiIndexDialogBase::GuiIndexDialogBase(LyXView & lv,
|
2007-09-08 22:08:46 +00:00
|
|
|
docstring const & title, QString const & label, std::string const & name)
|
|
|
|
: GuiDialog(lv, name)
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
label_ = label;
|
2007-04-25 08:42:22 +00:00
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
setViewTitle(title);
|
2007-09-08 22:08:46 +00:00
|
|
|
setController(new ControlCommand(*this, name, name));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-08-31 22:16:11 +00:00
|
|
|
connect(keywordED, SIGNAL(textChanged(const QString &)),
|
2007-04-25 08:42:22 +00:00
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
|
|
|
setFocusProxy(keywordED);
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
keywordLA->setText(label_);
|
|
|
|
|
2007-04-25 08:42:22 +00:00
|
|
|
keywordED->setWhatsThis( qt_(
|
|
|
|
"The format of the entry in the index.\n"
|
|
|
|
"\n"
|
|
|
|
"An entry can be specified as a sub-entry of\n"
|
|
|
|
"another with \"!\":\n"
|
|
|
|
"\n"
|
|
|
|
"cars!mileage\n"
|
|
|
|
"\n"
|
|
|
|
"You can cross-refer to another entry like so:\n"
|
|
|
|
"\n"
|
|
|
|
"cars!mileage|see{economy}\n"
|
|
|
|
"\n"
|
|
|
|
"For further details refer to the local LaTeX\n"
|
|
|
|
"documentation.\n")
|
|
|
|
);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
|
|
bc().setOK(okPB);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
bc().addReadOnly(keywordED);
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
ControlCommand & GuiIndexDialogBase::controller() const
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
return static_cast<ControlCommand &>(Dialog::controller());
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiIndexDialogBase::change_adaptor()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiIndexDialogBase::reject()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
slotClose();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiIndexDialogBase::closeEvent(QCloseEvent * e)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
slotWMHide();
|
|
|
|
e->accept();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiIndexDialogBase::update_contents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-10-20 13:53:43 +00:00
|
|
|
docstring const contents = controller().params()["name"];
|
2007-09-05 20:33:29 +00:00
|
|
|
keywordED->setText(toqstr(contents));
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().setValid(!contents.empty());
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void GuiIndexDialogBase::applyView()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
controller().params()["name"] = qstring_to_ucs4(keywordED->text());
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bool GuiIndexDialogBase::isValid()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
return !keywordED->text().isEmpty();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2007-09-08 22:08:46 +00:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Index Dialog
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
GuiIndexDialog::GuiIndexDialog(LyXView & lv)
|
|
|
|
: GuiIndexDialogBase(lv, _("Index Entry"), qt_("&Keyword:"), "index")
|
|
|
|
{
|
|
|
|
keywordED->setWhatsThis( qt_(
|
|
|
|
"The format of the entry in the index.\n"
|
|
|
|
"\n"
|
|
|
|
"An entry can be specified as a sub-entry of\n"
|
|
|
|
"another with \"!\":\n"
|
|
|
|
"\n"
|
|
|
|
"cars!mileage\n"
|
|
|
|
"\n"
|
|
|
|
"You can cross-refer to another entry like so:\n"
|
|
|
|
"\n"
|
|
|
|
"cars!mileage|see{economy}\n"
|
|
|
|
"\n"
|
|
|
|
"For further details refer to the local LaTeX\n"
|
|
|
|
"documentation.\n")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Label Dialog
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
GuiLabelDialog::GuiLabelDialog(LyXView & lv)
|
|
|
|
: GuiIndexDialogBase(lv, _("Label"), qt_("&Label:"), "label")
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 08:42:22 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiIndex_moc.cpp"
|