]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiIndex.cpp
aec568e0b06d48d75239264bc2b612cc2a4bdec5
[lyx.git] / src / frontends / qt4 / GuiIndex.cpp
1 /**
2  * \file GuiIndex.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 "GuiIndex.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/InsetIndex.h"
25
26 #include <QPushButton>
27
28 using namespace std;
29
30 namespace lyx {
31 namespace frontend {
32
33 GuiIndex::GuiIndex(GuiView & lv)
34         : GuiDialog(lv, "index", qt_("Index Entry Settings"))
35 {
36         setupUi(this);
37
38         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
39         connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotClose()));
40         connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
41
42         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
43         bc().setOK(okPB);
44         bc().setCancel(cancelPB);
45 }
46
47
48 void GuiIndex::change_adaptor()
49 {
50         changed();
51 }
52
53
54 void GuiIndex::updateContents()
55 {
56         typedef IndicesList::const_iterator const_iterator;
57
58         IndicesList const & indiceslist = buffer().params().indiceslist();
59         docstring const cur_index = params_.index;
60
61         indicesCO->clear();
62
63         const_iterator const begin = indiceslist.begin();
64         const_iterator const end = indiceslist.end();
65         for (const_iterator it = begin; it != end; ++it)
66                 indicesCO->addItem(toqstr(it->index()),
67                         QVariant(toqstr(it->shortcut())));
68
69         int const pos = indicesCO->findData(toqstr(cur_index));
70         indicesCO->setCurrentIndex(pos);
71 }
72
73
74 void GuiIndex::applyView()
75 {
76         QString const index = indicesCO->itemData(
77                 indicesCO->currentIndex()).toString();
78         params_.index = qstring_to_ucs4(index);
79 }
80
81
82 bool GuiIndex::initialiseParams(string const & sdata)
83 {
84         InsetIndex::string2params(sdata, params_);
85         return true;
86 }
87
88
89 void GuiIndex::clearParams()
90 {
91         params_ = InsetIndexParams();
92 }
93
94
95 void GuiIndex::dispatchParams()
96 {
97         dispatch(FuncRequest(getLfun(), InsetIndex::params2string(params_)));
98 }
99
100
101 Dialog * createGuiIndex(GuiView & lv) { return new GuiIndex(lv); }
102
103
104 } // namespace frontend
105 } // namespace lyx
106
107 #include "moc_GuiIndex.cpp"