mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
* Add support for splitindex's \printsubindex command. File format change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29409 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c6b4bf67e5
commit
0bd5c5fca8
@ -1,6 +1,10 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2009-04-26 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 353: support for splitindex's
|
||||
printsubindex.
|
||||
|
||||
2009-04-15 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 352: splitindex support.
|
||||
|
||||
|
@ -554,6 +554,32 @@ def convert_splitindex(document):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def revert_subindex(document):
|
||||
" Reverts \\printsubindex 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 != "printsubindex":
|
||||
i = i + 1
|
||||
continue
|
||||
ptype = get_value(document.body, 'type', i, k).strip('"')
|
||||
if indices == "false":
|
||||
del document.body[i:k+1]
|
||||
else:
|
||||
subst = [put_cmd_in_ert("\\printsubindex[" + ptype + "]{}")]
|
||||
document.body[i:k+1] = subst
|
||||
i = i + 1
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -565,10 +591,12 @@ convert = [[346, []],
|
||||
[349, []],
|
||||
[350, []],
|
||||
[351, []],
|
||||
[352, [convert_splitindex]]
|
||||
[352, [convert_splitindex]],
|
||||
[353, []]
|
||||
]
|
||||
|
||||
revert = [[351, [revert_splitindex]],
|
||||
revert = [[352, [revert_subindex]],
|
||||
[351, [revert_splitindex]],
|
||||
[350, [revert_backgroundcolor]],
|
||||
[349, [revert_outputformat]],
|
||||
[348, [revert_xetex]],
|
||||
|
@ -522,6 +522,8 @@ Menuset
|
||||
Menu "context-indexprint"
|
||||
IndicesListsContext
|
||||
Separator
|
||||
Item "Subindex|b" "next-inset-modify toggle-subindex"
|
||||
Separator
|
||||
OptItem "Settings...|S" "inset-settings"
|
||||
End
|
||||
|
||||
|
@ -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 = 352; // jspitzm: splitindex support
|
||||
int const LYX_FORMAT = 353; // jspitzm: subindex support
|
||||
|
||||
typedef map<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
|
@ -39,6 +39,7 @@ GuiPrintindex::GuiPrintindex(GuiView & lv)
|
||||
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()));
|
||||
|
||||
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
||||
bc().setOK(okPB);
|
||||
@ -69,6 +70,7 @@ void GuiPrintindex::updateContents()
|
||||
|
||||
int const pos = indicesCO->findData(toqstr(cur_index));
|
||||
indicesCO->setCurrentIndex(pos);
|
||||
subindexCB->setChecked(params_.getCmdName() == "printsubindex");
|
||||
}
|
||||
|
||||
|
||||
@ -76,6 +78,10 @@ void GuiPrintindex::applyView()
|
||||
{
|
||||
QString const index = indicesCO->itemData(
|
||||
indicesCO->currentIndex()).toString();
|
||||
if (subindexCB->isChecked())
|
||||
params_.setCmdName("printsubindex");
|
||||
else
|
||||
params_.setCmdName("printindex");
|
||||
params_["type"] = qstring_to_ucs4(index);
|
||||
}
|
||||
|
||||
@ -83,6 +89,7 @@ void GuiPrintindex::applyView()
|
||||
void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
|
||||
{
|
||||
int const pos = indicesCO->findData(toqstr(params_["type"]));
|
||||
subindexCB->setChecked(params_.getCmdName() == "printsubindex");
|
||||
indicesCO->setCurrentIndex(pos);
|
||||
bc().setValid(isValid());
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>262</width>
|
||||
<height>108</height>
|
||||
<height>130</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -22,20 +22,17 @@
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<item row="2" column="2" >
|
||||
<widget class="QPushButton" name="cancelPB" >
|
||||
<property name="text" >
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<item row="2" column="1" >
|
||||
<widget class="QPushButton" name="okPB" >
|
||||
<property name="text" >
|
||||
<string>&OK</string>
|
||||
@ -45,6 +42,29 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>78</width>
|
||||
<height>29</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3" >
|
||||
<widget class="QCheckBox" name="subindexCB" >
|
||||
<property name="toolTip" >
|
||||
<string>Check if this index should be part (e.g., a section) of the former one.</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Subindex</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
@ -66,22 +86,12 @@
|
||||
<item>
|
||||
<widget class="QComboBox" name="indicesCO" >
|
||||
<property name="toolTip" >
|
||||
<string>Select the index this entry should be listed in.</string>
|
||||
<string>Select the index that shall be printed at this place of the document.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2" >
|
||||
<widget class="QPushButton" name="cancelPB" >
|
||||
<property name="text" >
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
@ -410,6 +410,8 @@ docstring InsetPrintIndex::screenLabel() const
|
||||
docstring res = index->index();
|
||||
if (!buffer().masterBuffer()->params().use_indices)
|
||||
res += " (" + _("non-active") + ")";
|
||||
else if (getCmdName() == "printsubindex")
|
||||
res += " (" + _("subindex") + ")";
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -419,6 +421,13 @@ 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");
|
||||
else
|
||||
setCmdName("printindex");
|
||||
break;
|
||||
}
|
||||
InsetCommandParams p(INDEX_PRINT_CODE);
|
||||
// FIXME UNICODE
|
||||
InsetCommand::string2params("index_print",
|
||||
@ -427,7 +436,7 @@ void InsetPrintIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
cur.noUpdate();
|
||||
break;
|
||||
}
|
||||
setParam("type", p["type"]);
|
||||
setParams(p);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -444,7 +453,11 @@ bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_MODIFY: {
|
||||
if (cmd.getArg(0) == "index_print"
|
||||
if (cmd.argument() == from_ascii("toggle-subindex")) {
|
||||
status.setEnabled(buffer().masterBuffer()->params().use_indices);
|
||||
status.setOnOff(getCmdName() == "printsubindex");
|
||||
return true;
|
||||
} if (cmd.getArg(0) == "index_print"
|
||||
&& cmd.getArg(1) == "CommandInset") {
|
||||
InsetCommandParams p(INDEX_PRINT_CODE);
|
||||
InsetCommand::string2params("index_print",
|
||||
@ -461,8 +474,7 @@ bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE: {
|
||||
Buffer const & realbuffer = *buffer().masterBuffer();
|
||||
status.setEnabled(realbuffer.params().use_indices);
|
||||
status.setEnabled(buffer().masterBuffer()->params().use_indices);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -98,8 +98,8 @@ public:
|
||||
///
|
||||
static std::string defaultCommand() { return "printindex"; };
|
||||
///
|
||||
static bool isCompatibleCommand(std::string const & s)
|
||||
{ return s == "printindex"; }
|
||||
static bool isCompatibleCommand(std::string const & s)
|
||||
{ return s == "printindex" || s == "printsubindex"; }
|
||||
///
|
||||
int latex(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user