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 "support/lstrings.h"
26 #include "insets/InsetCommand.h"
28 #include <QPushButton>
31 using namespace lyx::support;
36 GuiPrintindex::GuiPrintindex(GuiView & lv)
37 : GuiDialog(lv, "index_print", qt_("Index Settings")),
38 params_(insetCode("index_print"))
42 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
43 connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotClose()));
44 connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
45 connect(subindexCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
46 connect(literalCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
48 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
50 bc().setCancel(cancelPB);
54 void GuiPrintindex::change_adaptor()
60 void GuiPrintindex::updateContents()
62 typedef IndicesList::const_iterator const_iterator;
64 IndicesList const & indiceslist = buffer().params().indiceslist();
65 docstring const cur_index = suffixIs(params_.getCmdName(), '*') ?
66 from_ascii("printall") : params_["type"];
70 indicesCO->addItem(qt_("<All indexes>"),
71 QVariant(QString("printall")));
73 const_iterator const begin = indiceslist.begin();
74 const_iterator const end = indiceslist.end();
75 for (const_iterator it = begin; it != end; ++it)
76 indicesCO->addItem(toqstr(it->index()),
77 QVariant(toqstr(it->shortcut())));
79 int const pos = indicesCO->findData(toqstr(cur_index));
80 indicesCO->setCurrentIndex(pos);
81 subindexCB->setChecked(params_.getCmdName() == "printsubindex");
82 literalCB->setChecked(params_["literal"] == "true");
86 void GuiPrintindex::applyView()
88 QString const index = indicesCO->itemData(
89 indicesCO->currentIndex()).toString();
90 string cmd = "printindex";
91 if (subindexCB->isChecked())
92 cmd = "printsubindex";
93 if (index == QString("printall"))
95 params_.setCmdName(cmd);
96 if (index == QString("printall"))
97 params_["type"] = docstring();
99 params_["type"] = qstring_to_ucs4(index);
100 params_["literal"] = literalCB->isChecked()
101 ? from_ascii("true") : from_ascii("false");
105 void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
107 int const pos = suffixIs(params_.getCmdName(), '*') ?
108 indicesCO->findData(QString("printall")) :
109 indicesCO->findData(toqstr(params_["type"]));
110 subindexCB->setChecked(params_.getCmdName() == "printsubindex");
111 indicesCO->setCurrentIndex(pos);
112 literalCB->setChecked(params_["literal"] == "true");
113 bc().setValid(isValid());
117 bool GuiPrintindex::initialiseParams(string const & data)
119 // The name passed with LFUN_INSET_APPLY is also the name
120 // used to identify the mailer.
121 InsetCommand::string2params(data, params_);
122 paramsToDialog(params_);
127 void GuiPrintindex::dispatchParams()
129 std::string const lfun = InsetCommand::params2string(params_);
130 dispatch(FuncRequest(getLfun(), lfun));
134 Dialog * createGuiPrintindex(GuiView & lv) { return new GuiPrintindex(lv); }
137 } // namespace frontend
140 #include "moc_GuiPrintindex.cpp"