From: Vincent van Ravesteijn Date: Mon, 29 Mar 2010 17:58:00 +0000 (+0000) Subject: Fix bug #2009:'|'-character in headings confuses TOC list in navigate menu. X-Git-Tag: 2.0.0~3661 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=111bb609322320d8e5e0c1c36d4e310b0441d577;p=features.git 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 --- diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index 0e7a57bde8..fe6e5da5d8 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -194,12 +194,17 @@ public: ~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) 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 '|' QString fulllabel() const { return label_;} @@ -717,7 +722,7 @@ void MenuDefinition::expandGraphicsGroups(BufferView const * bv) add(MenuItem(MenuItem::Command, qt_("No Group"), FuncRequest(LFUN_SET_GRAPHICS_GROUP))); for (; it != end; it++) { - addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(*it), + addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(*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) { QString label(4 * max(0, toc_list[i].depth() - depth), ' '); label += limitStringLength(toc_list[i].str()); - if (toc_list[i].depth() == depth - && shortcut_count < 9) { - if (label.contains(QString::number(shortcut_count + 1))) - label += '|' + QString::number(++shortcut_count); + if (toc_list[i].depth() == depth) { + label += '|'; + if (shortcut_count < 9) { + if (label.contains(QString::number(shortcut_count + 1))) + label += QString::number(++shortcut_count); + } } add(MenuItem(MenuItem::Command, label, 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), ' '); label += limitStringLength(toc_list[pos].str()); - if (toc_list[pos].depth() == depth && - shortcut_count < 9) { - if (label.contains(QString::number(shortcut_count + 1))) - label += '|' + QString::number(++shortcut_count); + if (toc_list[pos].depth() == depth) { + label += '|'; + if (shortcut_count < 9) { + if (label.contains(QString::number(shortcut_count + 1))) + label += QString::number(++shortcut_count); + } } if (new_pos == pos + 1) { add(MenuItem(MenuItem::Command, @@ -1177,7 +1186,7 @@ void MenuDefinition::expandToc(Buffer const * buf) TocIterator eend = cit->second.end(); for (; ccit != eend; ++ccit) { submenu.add(MenuItem(MenuItem::Command, - limitStringLength(ccit->str()), + limitStringLength(ccit->str()) + '|', FuncRequest(ccit->action()))); } } @@ -1218,7 +1227,7 @@ void MenuDefinition::expandPasteRecent(Buffer const * buf) docstring_list::const_iterator end = sel.end(); 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(index)))); } } @@ -1286,7 +1295,8 @@ void MenuDefinition::expandBranches(Buffer const * buf) if (ii < 10) { label = convert(ii) + ". " + label + char_type('|') + convert(ii); - } + } else + label += char_type('|'); child_branches.addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label), FuncRequest(LFUN_BRANCH_INSERT,