2 * \file GuiPrintindex.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
7 * \author Martin Vermeer
8 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
15 #include "GuiPrintindex.h"
17 #include "qt_helpers.h"
20 #include "BufferParams.h"
21 #include "FuncRequest.h"
22 #include "IndicesList.h"
24 #include "insets/InsetCommand.h"
26 #include <QPushButton>
33 GuiPrintindex::GuiPrintindex(GuiView & lv)
34 : GuiDialog(lv, "index_print", qt_("Index Settings")),
35 params_(insetCode("index_print"))
39 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
40 connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotClose()));
41 connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
42 connect(subindexCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
44 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
46 bc().setCancel(cancelPB);
50 void GuiPrintindex::change_adaptor()
56 void GuiPrintindex::updateContents()
58 typedef IndicesList::const_iterator const_iterator;
60 IndicesList const & indiceslist = buffer().params().indiceslist();
61 docstring const cur_index = params_["type"];
65 const_iterator const begin = indiceslist.begin();
66 const_iterator const end = indiceslist.end();
67 for (const_iterator it = begin; it != end; ++it)
68 indicesCO->addItem(toqstr(it->index()),
69 QVariant(toqstr(it->shortcut())));
71 int const pos = indicesCO->findData(toqstr(cur_index));
72 indicesCO->setCurrentIndex(pos);
73 subindexCB->setChecked(params_.getCmdName() == "printsubindex");
77 void GuiPrintindex::applyView()
79 QString const index = indicesCO->itemData(
80 indicesCO->currentIndex()).toString();
81 if (subindexCB->isChecked())
82 params_.setCmdName("printsubindex");
84 params_.setCmdName("printindex");
85 params_["type"] = qstring_to_ucs4(index);
89 void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
91 int const pos = indicesCO->findData(toqstr(params_["type"]));
92 subindexCB->setChecked(params_.getCmdName() == "printsubindex");
93 indicesCO->setCurrentIndex(pos);
94 bc().setValid(isValid());
98 bool GuiPrintindex::initialiseParams(string const & data)
100 // The name passed with LFUN_INSET_APPLY is also the name
101 // used to identify the mailer.
102 InsetCommand::string2params("index_print", data, params_);
107 void GuiPrintindex::dispatchParams()
109 std::string const lfun = InsetCommand::params2string("index_print", params_);
110 dispatch(FuncRequest(getLfun(), lfun));
114 Dialog * createGuiPrintindex(GuiView & lv) { return new GuiPrintindex(lv); }
117 } // namespace frontend
120 #include "moc_GuiPrintindex.cpp"