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.
17 #include "qt_helpers.h"
20 #include "BufferParams.h"
21 #include "FuncRequest.h"
22 #include "IndicesList.h"
23 #include "insets/InsetIndex.h"
25 #include <QPushButton>
32 GuiIndex::GuiIndex(GuiView & lv)
33 : GuiDialog(lv, "index", qt_("Index Entry Settings"))
37 connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
38 this, SLOT(slotButtonBox(QAbstractButton *)));
39 connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
41 rangeCO->addItem(qt_("None"), InsetIndexParams::None);
42 rangeCO->addItem(qt_("Start"), InsetIndexParams::Start);
43 rangeCO->addItem(qt_("End"), InsetIndexParams::End);
44 connect(rangeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
46 pageFormatCO->addItem(qt_("Default"), toqstr("default"));
47 pageFormatCO->addItem(qt_("Bold"), toqstr("textbf"));
48 pageFormatCO->addItem(qt_("Italic"), toqstr("textit"));
49 pageFormatCO->addItem(qt_("Emphasized"), toqstr("emph"));
50 pageFormatCO->addItem(qt_("Custom"), toqstr("custom"));
51 connect(pageFormatCO, SIGNAL(activated(int)), this, SLOT(pageFormatChanged(int)));
53 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
54 bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
55 bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
59 void GuiIndex::change_adaptor()
65 void GuiIndex::pageFormatChanged(int i)
67 QString const pf = pageFormatCO->itemData(i).toString();
68 pageFormatLE->setEnabled(pf == "custom");
73 void GuiIndex::updateContents()
75 typedef IndicesList::const_iterator const_iterator;
77 BufferParams const & bp = buffer().masterBuffer()->params();
78 indicesGB->setEnabled(bp.use_indices);
80 QString const pf = pageFormatCO->itemData(
81 pageFormatCO->currentIndex()).toString();
82 pageFormatLE->setEnabled(pf == "custom");
84 IndicesList const & indiceslist = bp.indiceslist();
85 docstring const cur_index = params_.index;
89 const_iterator const begin = indiceslist.begin();
90 const_iterator const end = indiceslist.end();
91 for (const_iterator it = begin; it != end; ++it)
92 indicesCO->addItem(toqstr(it->index()),
93 QVariant(toqstr(it->shortcut())));
95 int pos = indicesCO->findData(toqstr(cur_index));
96 indicesCO->setCurrentIndex(pos);
98 pos = pageFormatCO->findData(toqstr(params_.pagefmt));
100 pos = pageFormatCO->findData("custom");
101 pageFormatLE->setText(toqstr(params_.pagefmt));
103 pageFormatLE->clear();
104 pageFormatCO->setCurrentIndex(pos);
106 pos = rangeCO->findData(params_.range);
107 rangeCO->setCurrentIndex(pos);
111 void GuiIndex::applyView()
113 QString const index = indicesCO->itemData(
114 indicesCO->currentIndex()).toString();
115 int const range = rangeCO->itemData(
116 rangeCO->currentIndex()).toInt();
117 QString const pagefmt = pageFormatCO->itemData(
118 pageFormatCO->currentIndex()).toString();
119 params_.index = qstring_to_ucs4(index);
120 params_.range = InsetIndexParams::PageRange(range);
121 params_.pagefmt = (pagefmt == "custom")
122 ? fromqstr(pageFormatLE->text())
127 bool GuiIndex::initialiseParams(string const & sdata)
129 InsetIndex::string2params(sdata, params_);
134 void GuiIndex::clearParams()
136 params_ = InsetIndexParams();
140 void GuiIndex::dispatchParams()
142 dispatch(FuncRequest(getLfun(), InsetIndex::params2string(params_)));
146 } // namespace frontend
149 #include "moc_GuiIndex.cpp"