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-11-29 07:04:28 +00:00
|
|
|
#include "support/debug.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2007-04-25 08:42:22 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QCloseEvent>
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
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-11-23 09:44:02 +00:00
|
|
|
GuiIndexDialogBase::GuiIndexDialogBase(GuiView & lv,
|
2007-09-08 22:08:46 +00:00
|
|
|
docstring const & title, QString const & label, std::string const & name)
|
2007-10-07 14:59:01 +00:00
|
|
|
: GuiCommand(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-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
|
|
|
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-11 17:06:15 +00:00
|
|
|
slotClose();
|
2007-09-05 20:33:29 +00:00
|
|
|
e->accept();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-11 18:33:42 +00:00
|
|
|
void GuiIndexDialogBase::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-10-07 14:59:01 +00:00
|
|
|
docstring const contents = 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-10-07 14:59:01 +00:00
|
|
|
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
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiIndex::GuiIndex(GuiView & lv)
|
2007-09-08 22:08:46 +00:00
|
|
|
: 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")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiIndex(GuiView & lv) { return new GuiIndex(lv); }
|
2007-10-07 14:59:01 +00:00
|
|
|
|
|
|
|
|
2007-09-08 22:08:46 +00:00
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Label Dialog
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiLabel::GuiLabel(GuiView & lv)
|
2007-09-08 22:08:46 +00:00
|
|
|
: GuiIndexDialogBase(lv, _("Label"), qt_("&Label:"), "label")
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
|
2007-10-07 14:59:01 +00:00
|
|
|
|
|
|
|
|
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"
|