]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrintindex.cpp
New inset dialog for InsetPrintIndex (only used with multiple indices)..
[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
43         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
44         bc().setOK(okPB);
45         bc().setCancel(cancelPB);
46 }
47
48
49 void GuiPrintindex::change_adaptor()
50 {
51         changed();
52 }
53
54
55 void GuiPrintindex::updateContents()
56 {
57         typedef IndicesList::const_iterator const_iterator;
58
59         IndicesList const & indiceslist = buffer().params().indiceslist();
60         docstring const cur_index = params_["type"];
61
62         indicesCO->clear();
63
64         const_iterator const begin = indiceslist.begin();
65         const_iterator const end = indiceslist.end();
66         for (const_iterator it = begin; it != end; ++it)
67                 indicesCO->addItem(toqstr(it->index()),
68                         QVariant(toqstr(it->shortcut())));
69
70         int const pos = indicesCO->findData(toqstr(cur_index));
71         indicesCO->setCurrentIndex(pos);
72 }
73
74
75 void GuiPrintindex::applyView()
76 {
77         QString const index = indicesCO->itemData(
78                 indicesCO->currentIndex()).toString();
79         params_["type"] = qstring_to_ucs4(index);
80 }
81
82
83 void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
84 {
85         int const pos = indicesCO->findData(toqstr(params_["type"]));
86         indicesCO->setCurrentIndex(pos);
87         bc().setValid(isValid());
88 }
89
90
91 bool GuiPrintindex::initialiseParams(string const & data)
92 {
93         // The name passed with LFUN_INSET_APPLY is also the name
94         // used to identify the mailer.
95         InsetCommand::string2params("index_print", data, params_);
96         return true;
97 }
98
99
100 void GuiPrintindex::dispatchParams()
101 {
102         std::string const lfun = InsetCommand::params2string("index_print", params_);
103         dispatch(FuncRequest(getLfun(), lfun));
104 }
105
106
107 Dialog * createGuiPrintindex(GuiView & lv) { return new GuiPrintindex(lv); }
108
109
110 } // namespace frontend
111 } // namespace lyx
112
113 #include "moc_GuiPrintindex.cpp"