]> git.lyx.org Git - features.git/commitdiff
Re-organize and comment code a bit.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 23 May 2019 00:57:39 +0000 (20:57 -0400)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:30 +0000 (15:48 +0200)
src/frontends/qt4/Menus.cpp

index 91ab3f271e5a7b2a3c17daae75672fc82587d893..3f855c9313bb9a7cbabcfcc5175d574c732b2858 100644 (file)
@@ -1437,42 +1437,42 @@ void MenuDefinition::expandBranches(Buffer const * buf)
        if (!buf || buf->hasReadonlyFlag())
                return;
 
-       BufferParams const & master_params = buf->masterBuffer()->params();
-       BufferParams const & params = buf->params();
-       if (params.branchlist().empty() && master_params.branchlist().empty() ) {
+       BranchList const & master_list =
+               buf->masterBuffer()->params().branchlist();
+       BranchList const & child_list = buf->params().branchlist();
+       if (child_list.empty() && master_list.empty() ) {
                add(MenuItem(MenuItem::Help, qt_("No Branches Set for Document!")));
                return;
        }
 
-       BranchList::const_iterator cit = master_params.branchlist().begin();
-       BranchList::const_iterator end = master_params.branchlist().end();
-
-       for (int ii = 1; cit != end; ++cit, ++ii) {
-               docstring label = cit->branch();
+       BranchList::const_iterator mit = master_list.begin();
+       BranchList::const_iterator const mend = master_list.end();
+       for (int ii = 1; mit != mend; ++mit, ++ii) {
+               // NUM. Branch Name + "|", which triggers an empty shortcut in
+               // case that character should be in the branch name
+               docstring label = convert<docstring>(ii) + ". " +
+                       mit->branch() + char_type('|');
                if (ii < 10) {
-                       label = convert<docstring>(ii) + ". " + label
-                               + char_type('|') + convert<docstring>(ii);
+                       // Add NUM as a keyboard shortcut
+                       label += convert<docstring>(ii);
                }
                addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
                                    FuncRequest(LFUN_BRANCH_INSERT,
-                                               cit->branch())));
+                                               mit->branch())));
        }
 
        if (buf == buf->masterBuffer())
                return;
 
        MenuDefinition child_branches;
-
-       BranchList::const_iterator ccit = params.branchlist().begin();
-       BranchList::const_iterator cend = params.branchlist().end();
-
+       BranchList::const_iterator ccit = child_list.begin();
+       BranchList::const_iterator cend = child_list.end();
        for (int ii = 1; ccit != cend; ++ccit, ++ii) {
-               docstring label = ccit->branch();
+               docstring label = convert<docstring>(ii) + ". " +
+                       ccit->branch() + char_type('|');
                if (ii < 10) {
-                       label = convert<docstring>(ii) + ". " + label
-                               + char_type('|') + convert<docstring>(ii);
-               } else
-                       label += char_type('|');
+                       label += convert<docstring>(ii);
+               }
                child_branches.addWithStatusCheck(MenuItem(MenuItem::Command,
                                    toqstr(label),
                                    FuncRequest(LFUN_BRANCH_INSERT,