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()));
47 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
49 bc().setCancel(cancelPB);
53 void GuiPrintindex::change_adaptor()
59 void GuiPrintindex::updateContents()
61 typedef IndicesList::const_iterator const_iterator;
63 IndicesList const & indiceslist = buffer().params().indiceslist();
64 docstring const cur_index = suffixIs(params_.getCmdName(), '*') ?
65 from_ascii("printall") : params_["type"];
69 indicesCO->addItem(qt_("<All indexes>"),
70 QVariant(QString("printall")));
72 const_iterator const begin = indiceslist.begin();
73 const_iterator const end = indiceslist.end();
74 for (const_iterator it = begin; it != end; ++it)
75 indicesCO->addItem(toqstr(it->index()),
76 QVariant(toqstr(it->shortcut())));
78 int const pos = indicesCO->findData(toqstr(cur_index));
79 indicesCO->setCurrentIndex(pos);
80 subindexCB->setChecked(params_.getCmdName() == "printsubindex");
84 void GuiPrintindex::applyView()
86 QString const index = indicesCO->itemData(
87 indicesCO->currentIndex()).toString();
88 string cmd = "printindex";
89 if (subindexCB->isChecked())
90 cmd = "printsubindex";
91 if (index == QString("printall"))
93 params_.setCmdName(cmd);
94 if (index == QString("printall"))
95 params_["type"] = docstring();
97 params_["type"] = qstring_to_ucs4(index);
101 void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
103 int const pos = suffixIs(params_.getCmdName(), '*') ?
104 indicesCO->findData(QString("printall")) :
105 indicesCO->findData(toqstr(params_["type"]));
106 subindexCB->setChecked(params_.getCmdName() == "printsubindex");
107 indicesCO->setCurrentIndex(pos);
108 bc().setValid(isValid());
112 bool GuiPrintindex::initialiseParams(string const & data)
114 // The name passed with LFUN_INSET_APPLY is also the name
115 // used to identify the mailer.
116 InsetCommand::string2params(data, params_);
117 paramsToDialog(params_);
122 void GuiPrintindex::dispatchParams()
124 std::string const lfun = InsetCommand::params2string(params_);
125 dispatch(FuncRequest(getLfun(), lfun));
129 Dialog * createGuiPrintindex(GuiView & lv) { return new GuiPrintindex(lv); }
132 } // namespace frontend
135 #include "moc_GuiPrintindex.cpp"