3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
15 #include "ControlCommand.h"
18 #include "qt_helpers.h"
21 #include <QPushButton>
23 #include <QCloseEvent>
31 /////////////////////////////////////////////////////////////////
33 // Base implementation
35 /////////////////////////////////////////////////////////////////
37 GuiIndexDialogBase::GuiIndexDialogBase(LyXView & lv,
38 docstring const & title, QString const & label, std::string const & name)
44 setController(new ControlCommand(*this, name));
46 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
47 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
48 connect(keywordED, SIGNAL(textChanged(const QString &)),
49 this, SLOT(change_adaptor()));
51 setFocusProxy(keywordED);
53 keywordLA->setText(label_);
55 keywordED->setWhatsThis( qt_(
56 "The format of the entry in the index.\n"
58 "An entry can be specified as a sub-entry of\n"
59 "another with \"!\":\n"
63 "You can cross-refer to another entry like so:\n"
65 "cars!mileage|see{economy}\n"
67 "For further details refer to the local LaTeX\n"
71 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
73 bc().setCancel(closePB);
74 bc().addReadOnly(keywordED);
78 ControlCommand & GuiIndexDialogBase::controller()
80 return static_cast<ControlCommand &>(GuiDialog::controller());
84 void GuiIndexDialogBase::change_adaptor()
90 void GuiIndexDialogBase::reject()
96 void GuiIndexDialogBase::closeEvent(QCloseEvent * e)
103 void GuiIndexDialogBase::updateContents()
105 docstring const contents = controller().params()["name"];
106 keywordED->setText(toqstr(contents));
107 bc().setValid(!contents.empty());
111 void GuiIndexDialogBase::applyView()
113 controller().params()["name"] = qstring_to_ucs4(keywordED->text());
117 bool GuiIndexDialogBase::isValid()
119 return !keywordED->text().isEmpty();
123 /////////////////////////////////////////////////////////////////
127 /////////////////////////////////////////////////////////////////
130 GuiIndexDialog::GuiIndexDialog(LyXView & lv)
131 : GuiIndexDialogBase(lv, _("Index Entry"), qt_("&Keyword:"), "index")
133 keywordED->setWhatsThis( qt_(
134 "The format of the entry in the index.\n"
136 "An entry can be specified as a sub-entry of\n"
137 "another with \"!\":\n"
141 "You can cross-refer to another entry like so:\n"
143 "cars!mileage|see{economy}\n"
145 "For further details refer to the local LaTeX\n"
151 /////////////////////////////////////////////////////////////////
155 /////////////////////////////////////////////////////////////////
157 GuiLabelDialog::GuiLabelDialog(LyXView & lv)
158 : GuiIndexDialogBase(lv, _("Label"), qt_("&Label:"), "label")
162 } // namespace frontend
165 #include "GuiIndex_moc.cpp"