diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index a75ebc252a..1217dfb043 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -951,45 +951,13 @@ void MenuDefinition::expandToc(Buffer const * buf) if (cit->first == "tableofcontents") continue; - string const & floatName = floatlist.getType(cit->first).listName(); - QString label; - bool in_other_list = true; - if (!floatName.empty()) { - label = qt_(floatName); - in_other_list = false; - } - else if (cit->first == "child") { - label = qt_("Child Documents"); - in_other_list = false; - } else if (cit->first == "graphics") - label = qt_("List of Graphics"); - else if (cit->first == "equation") - label = qt_("List of Equations"); - else if (cit->first == "index") - label = qt_("List of Indexes"); - else if (cit->first == "listing") { + if (cit->first == "listing") { // FIXME: the listing navigate menu causes a crash for unknown // reason. See http://bugzilla.lyx.org/show_bug.cgi?id=4613 - // This is a temporary fix: - //label = qt_("List of Listings"); continue; } - else if (cit->first == "marginalnote") - label = qt_("List of Marginal notes"); - else if (cit->first == "note") - label = qt_("List of Notes"); - else if (cit->first == "footnote") - label = qt_("List of Footnotes"); - else if (cit->first == "label") - label = qt_("Labels and References"); - else if (cit->first == "citation") - label = qt_("List of Citations"); - else - // This should not happen unless the entry is missing above. - label = qt_("Other floats: ") + toqstr(cit->first); MenuDefinition submenu; - if (cit->second.size() >= 30) { FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first); submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f)); @@ -997,20 +965,20 @@ void MenuDefinition::expandToc(Buffer const * buf) TocIterator ccit = cit->second.begin(); TocIterator eend = cit->second.end(); for (; ccit != eend; ++ccit) { - QString const label = limitStringLength(ccit->str()); - submenu.add(MenuItem(MenuItem::Command, label, + submenu.add(MenuItem(MenuItem::Command, + limitStringLength(ccit->str()), FuncRequest(ccit->action()))); } } - MenuItem item(MenuItem::Submenu, label); + MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params())); item.setSubmenu(submenu); - if (in_other_list) - other_lists.add(item); - else { + if (floatlist.typeExist(cit->first) || cit->first == "child") { + // Those two types deserve to be in the main menu. item.setSubmenu(submenu); add(item); - } + } else + other_lists.add(item); } if (!other_lists.empty()) { MenuItem item(MenuItem::Submenu, qt_("Other Lists")); @@ -1018,16 +986,14 @@ void MenuDefinition::expandToc(Buffer const * buf) add(item); } - // Handle normal TOC cit = toc_list.find("tableofcontents"); if (cit == end) { addWithStatusCheck(MenuItem(MenuItem::Command, qt_("No Table of contents"), FuncRequest())); - } else { + } else expandToc2(cit->second, 0, cit->second.size(), 0); - } } diff --git a/src/frontends/qt4/TocModel.cpp b/src/frontends/qt4/TocModel.cpp index 6d6198ed71..ce23f24dc4 100644 --- a/src/frontends/qt4/TocModel.cpp +++ b/src/frontends/qt4/TocModel.cpp @@ -14,14 +14,11 @@ #include "TocModel.h" #include "Buffer.h" -#include "BufferParams.h" #include "BufferView.h" -#include "DocIterator.h" #include "Cursor.h" -#include "FloatList.h" +#include "DocIterator.h" #include "FuncRequest.h" #include "LyXFunc.h" -#include "TextClass.h" #include "support/convert.h" #include "support/debug.h" @@ -232,39 +229,6 @@ void TocModels::updateBackend() const } -QString TocModels::guiName(string const & type) const -{ - if (type == "tableofcontents") - return qt_("Table of Contents"); - if (type == "child") - return qt_("Child Documents"); - if (type == "graphics") - return qt_("List of Graphics"); - if (type == "equation") - return qt_("List of Equations"); - if (type == "footnote") - return qt_("List of Footnotes"); - if (type == "listing") - return qt_("List of Listings"); - if (type == "index") - return qt_("List of Indexes"); - if (type == "marginalnote") - return qt_("List of Marginal notes"); - if (type == "note") - return qt_("List of Notes"); - if (type == "citation") - return qt_("List of Citations"); - if (type == "label") - return qt_("Labels and References"); - - FloatList const & floats = bv_->buffer().params().documentClass().floats(); - if (floats.typeExist(type)) - return qt_(floats.getType(type).listName()); - - return qt_(type); -} - - void TocModels::reset(BufferView const * bv) { bv_ = bv; @@ -277,7 +241,7 @@ void TocModels::reset(BufferView const * bv) TocList::const_iterator end = tocs.end(); for (; it != end; ++it) { types_.push_back(toqstr(it->first)); - type_names_.push_back(guiName(it->first)); + type_names_.push_back(guiName(it->first, bv->buffer().params())); models_.push_back(new TocModel(it->second)); } } diff --git a/src/frontends/qt4/TocModel.h b/src/frontends/qt4/TocModel.h index 393577e11a..2bf4c43282 100644 --- a/src/frontends/qt4/TocModel.h +++ b/src/frontends/qt4/TocModel.h @@ -98,8 +98,6 @@ Q_SIGNALS: private: /// void clear(); - /// Return the guiname from a given cmdName of the TOC param - QString guiName(std::string const & type) const; /// BufferView const * bv_; /// diff --git a/src/frontends/qt4/qt_helpers.cpp b/src/frontends/qt4/qt_helpers.cpp index 05841fd392..df24f8870e 100644 --- a/src/frontends/qt4/qt_helpers.cpp +++ b/src/frontends/qt4/qt_helpers.cpp @@ -19,8 +19,11 @@ #include "frontends/alert.h" +#include "BufferParams.h" +#include "FloatList.h" #include "Language.h" #include "Length.h" +#include "TextClass.h" #include "support/debug.h" #include "support/filetools.h" @@ -474,4 +477,38 @@ QStringList fileFilters(QString const & desc) return list; } + +QString guiName(string const & type, BufferParams const & bp) +{ + if (type == "tableofcontents") + return qt_("Table of Contents"); + if (type == "child") + return qt_("Child Documents"); + if (type == "graphics") + return qt_("List of Graphics"); + if (type == "equation") + return qt_("List of Equations"); + if (type == "footnote") + return qt_("List of Footnotes"); + if (type == "listing") + return qt_("List of Listings"); + if (type == "index") + return qt_("List of Indexes"); + if (type == "marginalnote") + return qt_("List of Marginal notes"); + if (type == "note") + return qt_("List of Notes"); + if (type == "citation") + return qt_("List of Citations"); + if (type == "label") + return qt_("Labels and References"); + + FloatList const & floats = bp.documentClass().floats(); + if (floats.typeExist(type)) + return qt_(floats.getType(type).listName()); + + return qt_(type); +} + + } // namespace lyx diff --git a/src/frontends/qt4/qt_helpers.h b/src/frontends/qt4/qt_helpers.h index 66a9235ef2..66ec9e6f96 100644 --- a/src/frontends/qt4/qt_helpers.h +++ b/src/frontends/qt4/qt_helpers.h @@ -32,6 +32,7 @@ namespace lyx { namespace support { class FileName; } +class BufferParams; class LyXErr; LyXErr & operator<<(LyXErr &, QString const &); @@ -121,6 +122,10 @@ QString getExtension(QString const & name); QString makeAbsPath(QString const & relpath, QString const & base); QString changeExtension(QString const & oldname, QString const & ext); +/// \return the display string associated with given type and buffer +/// parameter. +QString guiName(std::string const & type, BufferParams const & bp); + } // namespace lyx #endif // QTHELPERS_H