Author: vfr
Date: Mon May 31 14:02:00 2010
New Revision: 34552
URL: http://www.lyx.org/trac/changeset/34552

Log:
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.

see r33918.

Modified:
   lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/Menus.cpp
   lyx-devel/branches/BRANCH_1_6_X/status.16x

Modified: lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/Menus.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/Menus.cpp Mon May 31 
11:50:24 2010        (r34551)
+++ lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/Menus.cpp Mon May 31 
14:02:00 2010        (r34552)
@@ -170,12 +170,17 @@
        ~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_;}
@@ -648,7 +653,7 @@
        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)));
        }
 }
@@ -884,10 +889,12 @@
                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())));
@@ -901,10 +908,12 @@
 
                        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,
@@ -964,7 +973,7 @@
                        TocIterator eend = cit->second.end();
                        for (; ccit != eend; ++ccit) {
                                submenu.add(MenuItem(MenuItem::Command,
-                                       limitStringLength(ccit->str()),
+                                       limitStringLength(ccit->str()) + '|',
                                        FuncRequest(ccit->action())));
                        }
                }
@@ -1003,7 +1012,7 @@
        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<string>(index))));
        }
 }
@@ -1077,7 +1086,8 @@
                if (ii < 10) {
                        label = convert<docstring>(ii) + ". " + label
                                + char_type('|') + convert<docstring>(ii);
-               }
+               } else
+                       label += char_type('|');
                child_branches.addWithStatusCheck(MenuItem(MenuItem::Command,
                                    toqstr(label),
                                    FuncRequest(LFUN_BRANCH_INSERT,

Modified: lyx-devel/branches/BRANCH_1_6_X/status.16x
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/status.16x  Mon May 31 11:50:24 2010        
(r34551)
+++ lyx-devel/branches/BRANCH_1_6_X/status.16x  Mon May 31 14:02:00 2010        
(r34552)
@@ -35,8 +35,8 @@
 
 * USER INTERFACE
 
-- Layout and template file for document class article(IEEEtran) has been 
updated for
-  IEEEtran 1.7a.
+- Layout and template file for document class article(IEEEtran) has been
+  updated for IEEEtran 1.7a.
 
 
 * DOCUMENTATION AND LOCALIZATION
@@ -59,15 +59,16 @@
 
 * DOCUMENT INPUT/OUTPUT
 
-- Fix reverse search when the document name contains a character which is
-  forbidden in LaTeX filenames (such as spaces).
+- Fix reverse search when the document name contains a character
+  which is forbidden in LaTeX filenames (such as spaces).
 
-- Improve reverse search for documents containing index insets (bug 6649).
+- Improve reverse search for documents containing index insets
+  (bug 6649).
 
 - Honour physical paper size settings on output (bug 5247).
 
-- Fix compilation error in documents containing text parts in Arabic and
-  Farsi (bug 6714).
+- Fix compilation error in documents containing text parts in Arabic
+  and Farsi (bug 6714).
 
 - Output references to section numbers in the correct direction in
   documents with right-to-left-languages (bug 6711).
@@ -80,11 +81,14 @@
 
 - Don't allow creating multiple buffers with same name (bug 6645).
 
-- Don't automatically overwrite files on export from command line, unless
-  the newly introduced -f flag is used (bug 2762).
+- Don't automatically overwrite files on export from command line,
+  unless the newly introduced -f flag is used (bug 2762).
 
-- Allow to overwrite files without dialog popup on export from GUI (bug 2844).
+- Allow to overwrite files without dialog popup on export from GUI
+  (bug 2844).
 
+- Make sure that the '|'-character in headings does not confuse the
+  TOC list in navigate menu (bug 2009).
 
 * USER INTERFACE
 

Reply via email to