mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-19 12:20:27 +00:00
e15a8f3551
File format change. This allows for the relevant InsetCommand-based dialogs (such as citation text before/after, Bibitem label, hyperlink name etc.) to provide both the input of verbatim code or text that is transformed to proper LaTeX code. Some dialogs (Nomencl, Href) already had some methods (although they could not be toggled), which are now centralized and streamlined. The initial work of this patch has been done by Georg Baum (see http://www.lyx.org/trac/attachment/ticket/2751/x.diff) Fixes: #2751, #8227.
141 lines
3.5 KiB
C++
141 lines
3.5 KiB
C++
/**
|
|
* \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"
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "insets/InsetCommand.h"
|
|
|
|
#include <QPushButton>
|
|
|
|
using namespace std;
|
|
using namespace lyx::support;
|
|
|
|
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()));
|
|
connect(subindexCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
|
connect(literalCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
|
|
|
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();
|
|
docstring const cur_index = suffixIs(params_.getCmdName(), '*') ?
|
|
from_ascii("printall") : params_["type"];
|
|
|
|
indicesCO->clear();
|
|
|
|
indicesCO->addItem(qt_("<All indexes>"),
|
|
QVariant(QString("printall")));
|
|
|
|
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);
|
|
subindexCB->setChecked(params_.getCmdName() == "printsubindex");
|
|
literalCB->setChecked(params_["literal"] == "true");
|
|
}
|
|
|
|
|
|
void GuiPrintindex::applyView()
|
|
{
|
|
QString const index = indicesCO->itemData(
|
|
indicesCO->currentIndex()).toString();
|
|
string cmd = "printindex";
|
|
if (subindexCB->isChecked())
|
|
cmd = "printsubindex";
|
|
if (index == QString("printall"))
|
|
cmd += '*';
|
|
params_.setCmdName(cmd);
|
|
if (index == QString("printall"))
|
|
params_["type"] = docstring();
|
|
else
|
|
params_["type"] = qstring_to_ucs4(index);
|
|
params_["literal"] = literalCB->isChecked()
|
|
? from_ascii("true") : from_ascii("false");
|
|
}
|
|
|
|
|
|
void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
|
|
{
|
|
int const pos = suffixIs(params_.getCmdName(), '*') ?
|
|
indicesCO->findData(QString("printall")) :
|
|
indicesCO->findData(toqstr(params_["type"]));
|
|
subindexCB->setChecked(params_.getCmdName() == "printsubindex");
|
|
indicesCO->setCurrentIndex(pos);
|
|
literalCB->setChecked(params_["literal"] == "true");
|
|
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.
|
|
InsetCommand::string2params(data, params_);
|
|
paramsToDialog(params_);
|
|
return true;
|
|
}
|
|
|
|
|
|
void GuiPrintindex::dispatchParams()
|
|
{
|
|
std::string const lfun = InsetCommand::params2string(params_);
|
|
dispatch(FuncRequest(getLfun(), lfun));
|
|
}
|
|
|
|
|
|
Dialog * createGuiPrintindex(GuiView & lv) { return new GuiPrintindex(lv); }
|
|
|
|
|
|
} // namespace frontend
|
|
} // namespace lyx
|
|
|
|
#include "moc_GuiPrintindex.cpp"
|