From ab98adf9250bc4711baa6172b180bafe741e2fc0 Mon Sep 17 00:00:00 2001 From: Guillaume Munch Date: Mon, 30 Nov 2015 15:27:43 +0000 Subject: [PATCH] Move Tocs to the "Other lists" submenu based on a blacklist This causes user-defined Tocs to appear in the main list --- src/TocBackend.cpp | 22 ++++++++++++++++++++++ src/TocBackend.h | 3 +++ src/frontends/qt4/Menus.cpp | 3 +-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/TocBackend.cpp b/src/TocBackend.cpp index 2b13d1febf..399278456d 100644 --- a/src/TocBackend.cpp +++ b/src/TocBackend.cpp @@ -339,4 +339,26 @@ docstring TocBackend::outlinerName(string const & type) const } +bool TocBackend::isOther(std::string const & type) +{ + // This is where having an Enum of types would have been more elegant... + return type == "graphics" + || type == "note" + || type == "branch" + || type == "change" + || type == "label" + || type == "citation" + || type == "equation" + || type == "footnote" + || type == "marginalnote" + || type == "nomencl" + || type == "listings" + || type == "math-macro" + || type == "external" + || type == "senseless" + || type == "index" + || type.substr(0,6) == "index:"; +} + + } // namespace lyx diff --git a/src/TocBackend.h b/src/TocBackend.h index 10bfff1ea0..eaa1ce99e2 100644 --- a/src/TocBackend.h +++ b/src/TocBackend.h @@ -180,6 +180,9 @@ public: odocstringstream & os, size_t max_length) const; /// docstring outlinerName(std::string const & type) const; + /// Whether a toc type is less important and appears in the "Other lists" + /// submenu + static bool isOther(std::string const & type); private: /// diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index de0c887d52..c442b9b7d7 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -1310,7 +1310,6 @@ void MenuDefinition::expandToc(Buffer const * buf) } MenuDefinition other_lists; - FloatList const & floatlist = buf->params().documentClass().floats(); TocList const & toc_list = buf->tocBackend().tocs(); TocList::const_iterator cit = toc_list.begin(); TocList::const_iterator end = toc_list.end(); @@ -1328,7 +1327,7 @@ void MenuDefinition::expandToc(Buffer const * buf) MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params())); item.setSubmenu(submenu); // deserves to be in the main menu? - if (floatlist.typeExist(cit->first) || cit->first == "child") + if (!TocBackend::isOther(cit->first)) add(item); else other_lists.add(item);