diff --git a/development/FORMAT b/development/FORMAT index 107b1ff762..0e04fb23af 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,9 +1,13 @@ LyX file-format changes ----------------------- +2009-04-26 Jürgen Spitzmüller + * Format incremented to 354: support for splitindex's + \printindex* and \printsubindex*. + 2009-04-26 Jürgen Spitzmüller * Format incremented to 353: support for splitindex's - printsubindex. + \printsubindex. 2009-04-15 Jürgen Spitzmüller * Format incremented to 352: splitindex support. diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index a811b531ad..63280f62a4 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -580,6 +580,31 @@ def revert_subindex(document): i = i + 1 +def revert_printindexall(document): + " Reverts \\print[sub]index* CommandInset types " + i = find_token(document.header, '\\use_indices', 0) + if i == -1: + document.warning("Malformed LyX document: Missing \\use_indices.") + return + indices = get_value(document.header, "\\use_indices", i) + i = 0 + while True: + i = find_token(document.body, "\\begin_inset CommandInset index_print", i) + if i == -1: + return + k = find_end_of_inset(document.body, i) + ctype = get_value(document.body, 'LatexCommand', i, k) + if ctype != "printindex*" and ctype != "printsubindex*": + i = i + 1 + continue + if indices == "false": + del document.body[i:k+1] + else: + subst = [put_cmd_in_ert("\\" + ctype + "{}")] + document.body[i:k+1] = subst + i = i + 1 + + ## # Conversion hub # @@ -592,10 +617,12 @@ convert = [[346, []], [350, []], [351, []], [352, [convert_splitindex]], - [353, []] + [353, []], + [354, []] ] -revert = [[352, [revert_subindex]], +revert = [[353, [revert_printindexall]], + [352, [revert_subindex]], [351, [revert_splitindex]], [350, [revert_backgroundcolor]], [349, [revert_outputformat]], diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc index a320fa48bb..bf7e30d4db 100644 --- a/lib/ui/stdcontext.inc +++ b/lib/ui/stdcontext.inc @@ -520,6 +520,7 @@ Menuset # Menu "context-indexprint" + Item "All Indices|A" "next-inset-modify check-printindex*" IndicesListsContext Separator Item "Subindex|b" "next-inset-modify toggle-subindex" diff --git a/src/Buffer.cpp b/src/Buffer.cpp index ff1451a588..cdc45a6dde 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -125,7 +125,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 353; // jspitzm: subindex support +int const LYX_FORMAT = 354; // jspitzm: support for \print[sub]index* typedef map DepClean; typedef map > RefCache; diff --git a/src/frontends/qt4/GuiPrintindex.cpp b/src/frontends/qt4/GuiPrintindex.cpp index a175f8b651..ef9e0fac60 100644 --- a/src/frontends/qt4/GuiPrintindex.cpp +++ b/src/frontends/qt4/GuiPrintindex.cpp @@ -21,11 +21,14 @@ #include "FuncRequest.h" #include "IndicesList.h" +#include "support/lstrings.h" + #include "insets/InsetCommand.h" #include using namespace std; +using namespace lyx::support; namespace lyx { namespace frontend { @@ -58,10 +61,14 @@ void GuiPrintindex::updateContents() typedef IndicesList::const_iterator const_iterator; IndicesList const & indiceslist = buffer().params().indiceslist(); - docstring const cur_index = params_["type"]; + docstring const cur_index = suffixIs(params_.getCmdName(), '*') ? + from_ascii("printall") : params_["type"]; indicesCO->clear(); + indicesCO->addItem(qt_(""), + QVariant(QString("printall"))); + const_iterator const begin = indiceslist.begin(); const_iterator const end = indiceslist.end(); for (const_iterator it = begin; it != end; ++it) @@ -78,17 +85,24 @@ void GuiPrintindex::applyView() { QString const index = indicesCO->itemData( indicesCO->currentIndex()).toString(); + string cmd = "printindex"; if (subindexCB->isChecked()) - params_.setCmdName("printsubindex"); + cmd = "printsubindex"; + if (index == QString("printall")) + cmd += '*'; + params_.setCmdName(cmd); + if (index == QString("printall")) + params_["type"] = docstring(); else - params_.setCmdName("printindex"); - params_["type"] = qstring_to_ucs4(index); + params_["type"] = qstring_to_ucs4(index); } void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/) { - int const pos = indicesCO->findData(toqstr(params_["type"])); + int const pos = suffixIs(params_.getCmdName(), '*') ? + indicesCO->findData(QString("printall")) : + indicesCO->findData(toqstr(params_["type"])); subindexCB->setChecked(params_.getCmdName() == "printsubindex"); indicesCO->setCurrentIndex(pos); bc().setValid(isValid()); diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index d18c407dc9..eb0084ecda 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -398,34 +398,53 @@ ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */) docstring InsetPrintIndex::screenLabel() const { - if ((!buffer().masterBuffer()->params().use_indices + bool const printall = suffixIs(getCmdName(), '*'); + bool const multind = buffer().masterBuffer()->params().use_indices; + if ((!multind && getParam("type") == from_ascii("idx")) - || getParam("type").empty()) + || (getParam("type").empty() && !printall)) return _("Index"); Buffer const & realbuffer = *buffer().masterBuffer(); IndicesList const & indiceslist = realbuffer.params().indiceslist(); Index const * index = indiceslist.findShortcut(getParam("type")); - if (!index) + if (!index && !printall) return _("Unknown index type!"); - docstring res = index->index(); - if (!buffer().masterBuffer()->params().use_indices) + docstring res = printall ? _("All indices") : index->index(); + if (!multind) res += " (" + _("non-active") + ")"; - else if (getCmdName() == "printsubindex") + else if (contains(getCmdName(), "printsubindex")) res += " (" + _("subindex") + ")"; return res; } +bool InsetPrintIndex::isCompatibleCommand(string const & s) +{ + return s == "printindex" || s == "printsubindex" + || s == "printindex*" || s == "printsubindex*"; +} + + void InsetPrintIndex::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action) { case LFUN_INSET_MODIFY: { if (cmd.argument() == from_ascii("toggle-subindex")) { - if (getCmdName() == "printindex") - setCmdName("printsubindex"); + string cmd = getCmdName(); + if (contains(cmd, "printindex")) + cmd = subst(cmd, "printindex", "printsubindex"); else - setCmdName("printindex"); + cmd = subst(cmd, "printsubindex", "printindex"); + setCmdName(cmd); + break; + } else if (cmd.argument() == from_ascii("check-printindex*")) { + string cmd = getCmdName(); + if (suffixIs(cmd, '*')) + break; + cmd += '*'; + setParam("type", docstring()); + setCmdName(cmd); break; } InsetCommandParams p(INDEX_PRINT_CODE); @@ -455,13 +474,22 @@ bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_INSET_MODIFY: { if (cmd.argument() == from_ascii("toggle-subindex")) { status.setEnabled(buffer().masterBuffer()->params().use_indices); - status.setOnOff(getCmdName() == "printsubindex"); + status.setOnOff(contains(getCmdName(), "printsubindex")); + return true; + } else if (cmd.argument() == from_ascii("check-printindex*")) { + status.setEnabled(buffer().masterBuffer()->params().use_indices); + status.setOnOff(suffixIs(getCmdName(), '*')); return true; } if (cmd.getArg(0) == "index_print" && cmd.getArg(1) == "CommandInset") { InsetCommandParams p(INDEX_PRINT_CODE); InsetCommand::string2params("index_print", to_utf8(cmd.argument()), p); + if (suffixIs(p.getCmdName(), '*')) { + status.setEnabled(true); + status.setOnOff(false); + return true; + } Buffer const & realbuffer = *buffer().masterBuffer(); IndicesList const & indiceslist = realbuffer.params().indiceslist(); diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h index 83bf4beaa8..7bcb0c94b9 100644 --- a/src/insets/InsetIndex.h +++ b/src/insets/InsetIndex.h @@ -98,8 +98,7 @@ public: /// static std::string defaultCommand() { return "printindex"; }; /// - static bool isCompatibleCommand(std::string const & s) - { return s == "printindex" || s == "printsubindex"; } + static bool isCompatibleCommand(std::string const & s); /// int latex(odocstream &, OutputParams const &) const; ///