X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiIndex.cpp;h=0f25c93da72f4f3d32825e568e4d8857c8f444fd;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=4f27d2b4d59acbb4bce108b561433c925c7088b5;hpb=9d0ea8aeff32833a90b3fe64df0c5518a9e241be;p=lyx.git diff --git a/src/frontends/qt4/GuiIndex.cpp b/src/frontends/qt4/GuiIndex.cpp index 4f27d2b4d5..0f25c93da7 100644 --- a/src/frontends/qt4/GuiIndex.cpp +++ b/src/frontends/qt4/GuiIndex.cpp @@ -3,7 +3,9 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author John Levon + * \author Angus Leeming + * \author Martin Vermeer + * \author Jürgen Spitzmüller * * Full author contact details are available in file CREDITS. */ @@ -12,151 +14,94 @@ #include "GuiIndex.h" -#include "support/debug.h" #include "qt_helpers.h" -#include -#include -#include -#include +#include "Buffer.h" +#include "BufferParams.h" +#include "FuncRequest.h" +#include "IndicesList.h" + +#include "insets/InsetIndex.h" -using std::string; +#include +using namespace std; namespace lyx { namespace frontend { -///////////////////////////////////////////////////////////////// -// -// Base implementation -// -///////////////////////////////////////////////////////////////// - -GuiIndexDialogBase::GuiIndexDialogBase(GuiView & lv, - docstring const & title, QString const & label, std::string const & name) - : GuiCommand(lv, name) +GuiIndex::GuiIndex(GuiView & lv) + : GuiDialog(lv, "index", qt_("Index Entry Settings")) { - label_ = label; setupUi(this); - setViewTitle(title); 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); - - keywordLA->setText(label_); - - 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") - ); + connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotClose())); + connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); bc().setOK(okPB); - bc().setCancel(closePB); - bc().addReadOnly(keywordED); + bc().setCancel(cancelPB); } -void GuiIndexDialogBase::change_adaptor() +void GuiIndex::change_adaptor() { changed(); } -void GuiIndexDialogBase::reject() +void GuiIndex::updateContents() { - slotClose(); -} + typedef IndicesList::const_iterator const_iterator; + IndicesList const & indiceslist = buffer().params().indiceslist(); + docstring const cur_index = params_.index; -void GuiIndexDialogBase::closeEvent(QCloseEvent * e) -{ - slotClose(); - e->accept(); -} + indicesCO->clear(); + const_iterator const begin = indiceslist.begin(); + const_iterator const end = indiceslist.end(); + for (const_iterator it = begin; it != end; ++it) + indicesCO->addItem(toqstr(it->index()), + QVariant(toqstr(it->shortcut()))); -void GuiIndexDialogBase::updateContents() -{ - docstring const contents = params_["name"]; - keywordED->setText(toqstr(contents)); - bc().setValid(!contents.empty()); + int const pos = indicesCO->findData(toqstr(cur_index)); + indicesCO->setCurrentIndex(pos); } -void GuiIndexDialogBase::applyView() +void GuiIndex::applyView() { - params_["name"] = qstring_to_ucs4(keywordED->text()); + QString const index = indicesCO->itemData( + indicesCO->currentIndex()).toString(); + params_.index = qstring_to_ucs4(index); } -bool GuiIndexDialogBase::isValid() +bool GuiIndex::initialiseParams(string const & data) { - return !keywordED->text().isEmpty(); + InsetIndex::string2params(data, params_); + return true; } -///////////////////////////////////////////////////////////////// -// -// Index Dialog -// -///////////////////////////////////////////////////////////////// +void GuiIndex::clearParams() +{ + params_ = InsetIndexParams(); +} -GuiIndex::GuiIndex(GuiView & lv) - : GuiIndexDialogBase(lv, _("Index Entry"), qt_("&Keyword:"), "index") +void GuiIndex::dispatchParams() { - 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") - ); + dispatch(FuncRequest(getLfun(), InsetIndex::params2string(params_))); } Dialog * createGuiIndex(GuiView & lv) { return new GuiIndex(lv); } -///////////////////////////////////////////////////////////////// -// -// Label Dialog -// -///////////////////////////////////////////////////////////////// - -GuiLabel::GuiLabel(GuiView & lv) - : GuiIndexDialogBase(lv, _("Label"), qt_("&Label:"), "label") -{} - - -Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); } - - } // namespace frontend } // namespace lyx -#include "GuiIndex_moc.cpp" +#include "moc_GuiIndex.cpp"