]> git.lyx.org Git - features.git/commitdiff
Do not show subfigures in the menu (bug #9759)
authorGuillaume Munch <gm@lyx.org>
Mon, 31 Aug 2015 02:43:30 +0000 (03:43 +0100)
committerGuillaume Munch <gm@lyx.org>
Tue, 15 Sep 2015 14:25:32 +0000 (15:25 +0100)
* More consistent behavour (no 30 elements limit)
* Subfloats are given depth 1
* Only show depth 0
* Always show "Open outliner..."

src/frontends/qt4/Menus.cpp
src/insets/InsetCaption.cpp
src/insets/InsetCaption.h

index d0b5d91bcb06752553c3628f9050eaf18dcb675c..b8b8c31004780f3a626853aa59a2c67e98ab5e99 100644 (file)
@@ -1312,27 +1312,49 @@ void MenuDefinition::expandToc(Buffer const * buf)
                        continue;
 
                MenuDefinition submenu;
-               if (cit->second.size() >= 30) {
-                       FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
-                       submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f));
-               } else {
+               if (floatlist.typeExist(cit->first)) {
                        TocIterator ccit = cit->second.begin();
                        TocIterator eend = cit->second.end();
                        for (; ccit != eend; ++ccit) {
-                               submenu.add(MenuItem(MenuItem::Command,
-                                       limitStringLength(ccit->str()) + '|',
-                                       FuncRequest(ccit->action())));
+                               if (0 == ccit->depth()) {// omit subfloats
+                                       submenu.add(MenuItem(MenuItem::Command,
+                                                                                limitStringLength(ccit->str()) + '|',
+                                                                                FuncRequest(ccit->action())));
+                               }
                        }
-               }
 
-               MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
-               item.setSubmenu(submenu);
-               if (floatlist.typeExist(cit->first) || cit->first == "child") {
-                       // Those two types deserve to be in the main menu.
+                       FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
+                       submenu.add(MenuItem(MenuItem::Separator));
+                       submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f));
+                       MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
+                       // deserves to be in the main menu.
                        item.setSubmenu(submenu);
                        add(item);
-               } else
-                       other_lists.add(item);
+               } else {
+                       if (cit->second.size() >= 30) {
+                               // FIXME: the behaviour of the interface should not change
+                               // arbitrarily. Each type should be audited to see if the list
+                               // can be optimised like for floats above.
+                               FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
+                               submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f));
+                       } else {
+                               TocIterator ccit = cit->second.begin();
+                               TocIterator eend = cit->second.end();
+                               for (; ccit != eend; ++ccit) {
+                                       submenu.add(MenuItem(MenuItem::Command,
+                                                                                limitStringLength(ccit->str()) + '|',
+                                                                                FuncRequest(ccit->action())));
+                               }
+                       }
+
+                       MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
+                       item.setSubmenu(submenu);
+                       if (cit->first == "child") {
+                               // deserves to be in the main menu.
+                               add(item);
+                       } else
+                               other_lists.add(item);
+               }
        }
        if (!other_lists.empty()) {
                MenuItem item(MenuItem::Submenu, qt_("Other Lists"));
index 2465e7a7279bc3d0ee71d12bae6604bd0800d3b2..b83246920cae5aac6f36722985ce91c4071cc177 100644 (file)
@@ -102,7 +102,7 @@ void InsetCaption::addToToc(DocIterator const & cpit, bool output_active) const
        docstring str = full_label_;
        int length = output_active ? INT_MAX : TOC_ENTRY_LENGTH;
        text().forOutliner(str, length);
-       toc.push_back(TocItem(pit, 0, str, output_active));
+       toc.push_back(TocItem(pit, is_subfloat_ ? 1 : 0, str, output_active));
 
        // Proceed with the rest of the inset.
        InsetText::addToToc(cpit, output_active);
@@ -379,7 +379,7 @@ void InsetCaption::updateBuffer(ParIterator const & it, UpdateType utype)
                else
                        name = master.B_(tclass.floats().getType(type).name());
                docstring counter = from_utf8(type);
-               if (cnts.isSubfloat()) {
+               if ((is_subfloat_ = cnts.isSubfloat())) {
                        // only standard captions allowed in subfloats
                        type_ = "Standard";
                        counter = "sub-" + from_utf8(type);
@@ -402,9 +402,9 @@ void InsetCaption::updateBuffer(ParIterator const & it, UpdateType utype)
                        sec += bformat(from_ascii("(%1$s)"), labelstring);
                }
                if (!sec.empty())
-                       full_label_ = bformat(from_ascii("%1$s %2$s:"), name, sec);
+                       full_label_ = bformat(from_ascii("%1$s %2$s: "), name, sec);
                else
-                       full_label_ = bformat(from_ascii("%1$s #:"), name);
+                       full_label_ = bformat(from_ascii("%1$s #: "), name);
        }
 
        // Do the real work now.
index 26b3b260418560f050aa032d1823a391fa658c50..97f2691629f863bbe44e19a7ecb5bf7db20449d5 100644 (file)
@@ -96,6 +96,8 @@ private:
        ///
        std::string floattype_;
        ///
+       bool is_subfloat_;
+       ///
        std::string type_;
        ///
        docstring custom_label_;