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>
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiIndex.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "ButtonController.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
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2007-08-31 05:53:55 +00:00
|
|
|
// GuiIndexDialog
|
2007-04-25 08:42:22 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
GuiIndexDialog::GuiIndexDialog(GuiIndex * form)
|
2007-04-25 08:42:22 +00:00
|
|
|
: form_(form)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), form, 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);
|
|
|
|
|
|
|
|
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-08-31 05:53:55 +00:00
|
|
|
void GuiIndexDialog::change_adaptor()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiIndexDialog::reject()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
|
|
|
form_->slotClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiIndexDialog::closeEvent(QCloseEvent * e)
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2007-08-31 05:53:55 +00:00
|
|
|
// GuiIndex
|
2007-04-25 08:42:22 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
GuiIndex::GuiIndex(Dialog & parent, docstring const & title, QString const & label)
|
2007-08-31 22:16:11 +00:00
|
|
|
: GuiView<GuiIndexDialog>(parent, title), label_(label)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiIndex::build_dialog()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-08-31 05:53:55 +00:00
|
|
|
dialog_.reset(new GuiIndexDialog(this));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
dialog_->keywordLA->setText(label_);
|
|
|
|
|
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
bcview().addReadOnly(dialog_->keywordED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiIndex::update_contents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-10-20 13:53:43 +00:00
|
|
|
docstring const contents = controller().params()["name"];
|
2006-03-05 17:24:44 +00:00
|
|
|
dialog_->keywordED->setText(toqstr(contents));
|
|
|
|
|
|
|
|
bc().valid(!contents.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void GuiIndex::apply()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-10-20 13:53:43 +00:00
|
|
|
controller().params()["name"] = qstring_to_ucs4(dialog_->keywordED->text());
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
bool GuiIndex::isValid()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
return !dialog_->keywordED->text().isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 08:42:22 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiIndex_moc.cpp"
|