mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Fix bug #2009:'|'-character in headings confuses TOC list in navigate menu.
Solution is to search backwards for the last '|' in the string, and to add a '|' to the ones without a shortcut. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33918 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5de10a0123
commit
111bb60932
@ -194,12 +194,17 @@ public:
|
|||||||
~MenuItem() {}
|
~MenuItem() {}
|
||||||
|
|
||||||
/// The label of a given menuitem
|
/// The label of a given menuitem
|
||||||
QString label() const { return label_.split('|')[0]; }
|
QString label() const
|
||||||
|
{
|
||||||
|
int const index = label_.lastIndexOf('|');
|
||||||
|
return index == -1 ? label_ : label_.left(index);
|
||||||
|
}
|
||||||
|
|
||||||
/// The keyboard shortcut (usually underlined in the entry)
|
/// The keyboard shortcut (usually underlined in the entry)
|
||||||
QString shortcut() const
|
QString shortcut() const
|
||||||
{
|
{
|
||||||
return label_.contains('|') ? label_.split('|')[1] : QString();
|
int const index = label_.lastIndexOf('|');
|
||||||
|
return index == -1 ? QString() : label_.mid(index + 1);
|
||||||
}
|
}
|
||||||
/// The complete label, with label and shortcut separated by a '|'
|
/// The complete label, with label and shortcut separated by a '|'
|
||||||
QString fulllabel() const { return label_;}
|
QString fulllabel() const { return label_;}
|
||||||
@ -717,7 +722,7 @@ void MenuDefinition::expandGraphicsGroups(BufferView const * bv)
|
|||||||
add(MenuItem(MenuItem::Command, qt_("No Group"),
|
add(MenuItem(MenuItem::Command, qt_("No Group"),
|
||||||
FuncRequest(LFUN_SET_GRAPHICS_GROUP)));
|
FuncRequest(LFUN_SET_GRAPHICS_GROUP)));
|
||||||
for (; it != end; it++) {
|
for (; it != end; it++) {
|
||||||
addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(*it),
|
addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(*it) + '|',
|
||||||
FuncRequest(LFUN_SET_GRAPHICS_GROUP, *it)));
|
FuncRequest(LFUN_SET_GRAPHICS_GROUP, *it)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1098,10 +1103,12 @@ void MenuDefinition::expandToc2(Toc const & toc_list,
|
|||||||
for (size_t i = from; i < to; ++i) {
|
for (size_t i = from; i < to; ++i) {
|
||||||
QString label(4 * max(0, toc_list[i].depth() - depth), ' ');
|
QString label(4 * max(0, toc_list[i].depth() - depth), ' ');
|
||||||
label += limitStringLength(toc_list[i].str());
|
label += limitStringLength(toc_list[i].str());
|
||||||
if (toc_list[i].depth() == depth
|
if (toc_list[i].depth() == depth) {
|
||||||
&& shortcut_count < 9) {
|
label += '|';
|
||||||
if (label.contains(QString::number(shortcut_count + 1)))
|
if (shortcut_count < 9) {
|
||||||
label += '|' + QString::number(++shortcut_count);
|
if (label.contains(QString::number(shortcut_count + 1)))
|
||||||
|
label += QString::number(++shortcut_count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
add(MenuItem(MenuItem::Command, label,
|
add(MenuItem(MenuItem::Command, label,
|
||||||
FuncRequest(toc_list[i].action())));
|
FuncRequest(toc_list[i].action())));
|
||||||
@ -1115,10 +1122,12 @@ void MenuDefinition::expandToc2(Toc const & toc_list,
|
|||||||
|
|
||||||
QString label(4 * max(0, toc_list[pos].depth() - depth), ' ');
|
QString label(4 * max(0, toc_list[pos].depth() - depth), ' ');
|
||||||
label += limitStringLength(toc_list[pos].str());
|
label += limitStringLength(toc_list[pos].str());
|
||||||
if (toc_list[pos].depth() == depth &&
|
if (toc_list[pos].depth() == depth) {
|
||||||
shortcut_count < 9) {
|
label += '|';
|
||||||
if (label.contains(QString::number(shortcut_count + 1)))
|
if (shortcut_count < 9) {
|
||||||
label += '|' + QString::number(++shortcut_count);
|
if (label.contains(QString::number(shortcut_count + 1)))
|
||||||
|
label += QString::number(++shortcut_count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (new_pos == pos + 1) {
|
if (new_pos == pos + 1) {
|
||||||
add(MenuItem(MenuItem::Command,
|
add(MenuItem(MenuItem::Command,
|
||||||
@ -1177,7 +1186,7 @@ void MenuDefinition::expandToc(Buffer const * buf)
|
|||||||
TocIterator eend = cit->second.end();
|
TocIterator eend = cit->second.end();
|
||||||
for (; ccit != eend; ++ccit) {
|
for (; ccit != eend; ++ccit) {
|
||||||
submenu.add(MenuItem(MenuItem::Command,
|
submenu.add(MenuItem(MenuItem::Command,
|
||||||
limitStringLength(ccit->str()),
|
limitStringLength(ccit->str()) + '|',
|
||||||
FuncRequest(ccit->action())));
|
FuncRequest(ccit->action())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1218,7 +1227,7 @@ void MenuDefinition::expandPasteRecent(Buffer const * buf)
|
|||||||
docstring_list::const_iterator end = sel.end();
|
docstring_list::const_iterator end = sel.end();
|
||||||
|
|
||||||
for (unsigned int index = 0; cit != end; ++cit, ++index) {
|
for (unsigned int index = 0; cit != end; ++cit, ++index) {
|
||||||
add(MenuItem(MenuItem::Command, toqstr(*cit),
|
add(MenuItem(MenuItem::Command, toqstr(*cit) + '|',
|
||||||
FuncRequest(LFUN_PASTE, convert<string>(index))));
|
FuncRequest(LFUN_PASTE, convert<string>(index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1286,7 +1295,8 @@ void MenuDefinition::expandBranches(Buffer const * buf)
|
|||||||
if (ii < 10) {
|
if (ii < 10) {
|
||||||
label = convert<docstring>(ii) + ". " + label
|
label = convert<docstring>(ii) + ". " + label
|
||||||
+ char_type('|') + convert<docstring>(ii);
|
+ char_type('|') + convert<docstring>(ii);
|
||||||
}
|
} else
|
||||||
|
label += char_type('|');
|
||||||
child_branches.addWithStatusCheck(MenuItem(MenuItem::Command,
|
child_branches.addWithStatusCheck(MenuItem(MenuItem::Command,
|
||||||
toqstr(label),
|
toqstr(label),
|
||||||
FuncRequest(LFUN_BRANCH_INSERT,
|
FuncRequest(LFUN_BRANCH_INSERT,
|
||||||
|
Loading…
Reference in New Issue
Block a user