]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrintindex.cpp
* Add support for splitindex's \printsubindex command. File format change.
[lyx.git] / src / frontends / qt4 / GuiPrintindex.cpp
1 /**
2  * \file GuiPrintindex.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  * \author Martin Vermeer
8  * \author Jürgen Spitzmüller
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "GuiPrintindex.h"
16
17 #include "qt_helpers.h"
18
19 #include "Buffer.h"
20 #include "BufferParams.h"
21 #include "FuncRequest.h"
22 #include "IndicesList.h"
23
24 #include "insets/InsetCommand.h"
25
26 #include <QPushButton>
27
28 using namespace std;
29
30 namespace lyx {
31 namespace frontend {
32
33 GuiPrintindex::GuiPrintindex(GuiView & lv)
34         : GuiDialog(lv, "index_print", qt_("Index Settings")),
35           params_(insetCode("index_print"))
36 {
37         setupUi(this);
38
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()));
43
44         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
45         bc().setOK(okPB);
46         bc().setCancel(cancelPB);
47 }
48
49
50 void GuiPrintindex::change_adaptor()
51 {
52         changed();
53 }
54
55
56 void GuiPrintindex::updateContents()
57 {
58         typedef IndicesList::const_iterator const_iterator;
59
60         IndicesList const & indiceslist = buffer().params().indiceslist();
61         docstring const cur_index = params_["type"];
62
63         indicesCO->clear();
64
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())));
70
71         int const pos = indicesCO->findData(toqstr(cur_index));
72         indicesCO->setCurrentIndex(pos);
73         subindexCB->setChecked(params_.getCmdName() == "printsubindex");
74 }
75
76
77 void GuiPrintindex::applyView()
78 {
79         QString const index = indicesCO->itemData(
80                 indicesCO->currentIndex()).toString();
81         if (subindexCB->isChecked())
82                 params_.setCmdName("printsubindex");
83         else
84                 params_.setCmdName("printindex");
85         params_["type"] = qstring_to_ucs4(index);
86 }
87
88
89 void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
90 {
91         int const pos = indicesCO->findData(toqstr(params_["type"]));
92         subindexCB->setChecked(params_.getCmdName() == "printsubindex");
93         indicesCO->setCurrentIndex(pos);
94         bc().setValid(isValid());
95 }
96
97
98 bool GuiPrintindex::initialiseParams(string const & data)
99 {
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_);
103         return true;
104 }
105
106
107 void GuiPrintindex::dispatchParams()
108 {
109         std::string const lfun = InsetCommand::params2string("index_print", params_);
110         dispatch(FuncRequest(getLfun(), lfun));
111 }
112
113
114 Dialog * createGuiPrintindex(GuiView & lv) { return new GuiPrintindex(lv); }
115
116
117 } // namespace frontend
118 } // namespace lyx
119
120 #include "moc_GuiPrintindex.cpp"