2009-04-17 14:29:32 +00:00
|
|
|
/**
|
|
|
|
* \file GuiPrintindex.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author Martin Vermeer
|
|
|
|
* \author Jürgen Spitzmüller
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GuiPrintindex.h"
|
|
|
|
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include "Buffer.h"
|
|
|
|
#include "BufferParams.h"
|
|
|
|
#include "FuncRequest.h"
|
|
|
|
#include "IndicesList.h"
|
|
|
|
|
2009-04-27 06:10:25 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2009-04-17 14:29:32 +00:00
|
|
|
#include "insets/InsetCommand.h"
|
|
|
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
|
|
|
using namespace std;
|
2009-04-27 06:10:25 +00:00
|
|
|
using namespace lyx::support;
|
2009-04-17 14:29:32 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
GuiPrintindex::GuiPrintindex(GuiView & lv)
|
|
|
|
: GuiDialog(lv, "index_print", qt_("Index Settings")),
|
|
|
|
params_(insetCode("index_print"))
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
|
|
|
connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
2009-04-26 11:24:38 +00:00
|
|
|
connect(subindexCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
2017-01-30 06:44:55 +00:00
|
|
|
connect(literalCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
2009-04-17 14:29:32 +00:00
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
|
|
bc().setOK(okPB);
|
|
|
|
bc().setCancel(cancelPB);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintindex::change_adaptor()
|
|
|
|
{
|
|
|
|
changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintindex::updateContents()
|
|
|
|
{
|
|
|
|
typedef IndicesList::const_iterator const_iterator;
|
|
|
|
|
|
|
|
IndicesList const & indiceslist = buffer().params().indiceslist();
|
2009-04-27 06:10:25 +00:00
|
|
|
docstring const cur_index = suffixIs(params_.getCmdName(), '*') ?
|
|
|
|
from_ascii("printall") : params_["type"];
|
2009-04-17 14:29:32 +00:00
|
|
|
|
|
|
|
indicesCO->clear();
|
|
|
|
|
2009-05-02 15:54:45 +00:00
|
|
|
indicesCO->addItem(qt_("<All indexes>"),
|
2009-04-27 06:10:25 +00:00
|
|
|
QVariant(QString("printall")));
|
|
|
|
|
2009-04-17 14:29:32 +00:00
|
|
|
const_iterator const begin = indiceslist.begin();
|
|
|
|
const_iterator const end = indiceslist.end();
|
|
|
|
for (const_iterator it = begin; it != end; ++it)
|
|
|
|
indicesCO->addItem(toqstr(it->index()),
|
|
|
|
QVariant(toqstr(it->shortcut())));
|
|
|
|
|
|
|
|
int const pos = indicesCO->findData(toqstr(cur_index));
|
|
|
|
indicesCO->setCurrentIndex(pos);
|
2009-04-26 11:24:38 +00:00
|
|
|
subindexCB->setChecked(params_.getCmdName() == "printsubindex");
|
2017-01-30 06:44:55 +00:00
|
|
|
literalCB->setChecked(params_["literal"] == "true");
|
2009-04-17 14:29:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintindex::applyView()
|
|
|
|
{
|
|
|
|
QString const index = indicesCO->itemData(
|
|
|
|
indicesCO->currentIndex()).toString();
|
2009-04-27 06:10:25 +00:00
|
|
|
string cmd = "printindex";
|
2009-04-26 11:24:38 +00:00
|
|
|
if (subindexCB->isChecked())
|
2009-04-27 06:10:25 +00:00
|
|
|
cmd = "printsubindex";
|
|
|
|
if (index == QString("printall"))
|
|
|
|
cmd += '*';
|
|
|
|
params_.setCmdName(cmd);
|
|
|
|
if (index == QString("printall"))
|
|
|
|
params_["type"] = docstring();
|
2009-04-26 11:24:38 +00:00
|
|
|
else
|
2009-04-27 06:10:25 +00:00
|
|
|
params_["type"] = qstring_to_ucs4(index);
|
2017-01-30 06:44:55 +00:00
|
|
|
params_["literal"] = literalCB->isChecked()
|
|
|
|
? from_ascii("true") : from_ascii("false");
|
2009-04-17 14:29:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
|
|
|
|
{
|
2009-04-27 06:10:25 +00:00
|
|
|
int const pos = suffixIs(params_.getCmdName(), '*') ?
|
|
|
|
indicesCO->findData(QString("printall")) :
|
|
|
|
indicesCO->findData(toqstr(params_["type"]));
|
2009-04-26 11:24:38 +00:00
|
|
|
subindexCB->setChecked(params_.getCmdName() == "printsubindex");
|
2009-04-17 14:29:32 +00:00
|
|
|
indicesCO->setCurrentIndex(pos);
|
2017-01-30 06:44:55 +00:00
|
|
|
literalCB->setChecked(params_["literal"] == "true");
|
2009-04-17 14:29:32 +00:00
|
|
|
bc().setValid(isValid());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GuiPrintindex::initialiseParams(string const & data)
|
|
|
|
{
|
|
|
|
// The name passed with LFUN_INSET_APPLY is also the name
|
|
|
|
// used to identify the mailer.
|
2010-10-29 00:25:28 +00:00
|
|
|
InsetCommand::string2params(data, params_);
|
2009-05-22 16:26:15 +00:00
|
|
|
paramsToDialog(params_);
|
2009-04-17 14:29:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPrintindex::dispatchParams()
|
|
|
|
{
|
2010-10-29 00:25:28 +00:00
|
|
|
std::string const lfun = InsetCommand::params2string(params_);
|
2009-04-17 14:29:32 +00:00
|
|
|
dispatch(FuncRequest(getLfun(), lfun));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Dialog * createGuiPrintindex(GuiView & lv) { return new GuiPrintindex(lv); }
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#include "moc_GuiPrintindex.cpp"
|