From 04e46436ad49c94a38c12e1e44d071c93f7ea462 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 11 Mar 2008 10:27:33 +0000 Subject: [PATCH] * add "List of Graphics" * don't append "(embedded)" to embedded list items. * limit the number of entry to 30 items and offer to open the Navigator if above. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23659 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiToc.cpp | 5 ++++- src/frontends/qt4/Menus.cpp | 26 +++++++++++++++++--------- src/insets/InsetGraphics.cpp | 16 +++++++++++++++- src/insets/InsetGraphics.h | 4 ++++ src/insets/InsetInclude.cpp | 14 ++++++++------ 5 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index 076c62a0f4..d6ab24257c 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -145,7 +145,8 @@ bool GuiToc::initialiseParams(string const & data) new_type = "table"; else if (str.contains("\"algorithm")) new_type = "algorithm"; - } + } else + new_type = toqstr(data); types_.clear(); type_names_.clear(); @@ -225,6 +226,8 @@ docstring GuiToc::guiName(string const & type) const return _("Child Documents"); if (type == "embedded") return _("Embedded Files"); + if (type == "graphics") + return _("List of Graphics"); if (type == "equation") return _("List of Equations"); if (type == "footnote") diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index 671d426ddb..8f81ddb051 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -904,15 +904,6 @@ void MenuDefinition::expandToc(Buffer const * buf) if (cit->first == "tableofcontents") continue; - // All the rest is for floats - MenuDefinition submenu; - 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, - FuncRequest(ccit->action()))); - } string const & floatName = floatlist.getType(cit->first).listName(); QString label; bool in_other_list = true; @@ -925,6 +916,8 @@ void MenuDefinition::expandToc(Buffer const * buf) in_other_list = false; } else if (cit->first == "embedded") label = qt_("Embedded Files"); + 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") @@ -945,6 +938,21 @@ void MenuDefinition::expandToc(Buffer const * buf) // 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)); + } else { + 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, + FuncRequest(ccit->action()))); + } + } + MenuItem item(MenuItem::Submenu, label); item.setSubmenu(submenu); if (in_other_list) diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 4fc28beb86..13de24daab 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -54,6 +54,7 @@ TODO #include "Converter.h" #include "Cursor.h" #include "DispatchResult.h" +#include "EmbeddedFiles.h" #include "ErrorList.h" #include "Exporter.h" #include "Format.h" @@ -66,7 +67,7 @@ TODO #include "Mover.h" #include "OutputParams.h" #include "sgml.h" -#include "EmbeddedFiles.h" +#include "TocBackend.h" #include "frontends/alert.h" @@ -915,6 +916,19 @@ void InsetGraphics::editGraphics(InsetGraphicsParams const & p, } +void InsetGraphics::addToToc(ParConstIterator const & cpit) const +{ + TocBackend & backend = buffer().tocBackend(); + + docstring str = params_.filename.displayName(); + if (params_.filename.embedded()) { + backend.toc("embedded").push_back(TocItem(cpit, 0, str)); + str += _(" (embedded)"); + } + backend.toc("graphics").push_back(TocItem(cpit, 0, str)); +} + + string const InsetGraphicsMailer::name_("graphics"); InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset) diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h index 6d2da3bc6a..b1270bb30c 100644 --- a/src/insets/InsetGraphics.h +++ b/src/insets/InsetGraphics.h @@ -34,6 +34,7 @@ public: /// ~InsetGraphics(); /// + bool isLabeled() const { return true; } void metrics(MetricsInfo &, Dimension &) const; /// EDITABLE editable() const; @@ -79,6 +80,9 @@ public: void registerEmbeddedFiles(EmbeddedFileList &) const; /// void updateEmbeddedFile(EmbeddedFile const &); + /// + void addToToc(ParConstIterator const &) const; + /// Force inset into LTR environment if surroundings are RTL? virtual bool forceLTR() const { return true; } protected: diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index c2b3aeb6ed..9b003c7f27 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -875,13 +875,15 @@ void InsetInclude::addToToc(ParConstIterator const & cpit) const if (caption.empty()) return; Toc & toc = backend.toc("listing"); - docstring const str = convert(toc.size() + 1) + docstring str = convert(toc.size() + 1) + ". " + from_utf8(caption); + if (embedded_status) { + backend.toc("embedded").push_back(TocItem(cpit, 0, str)); + str += _(" (embedded)"); + } ParConstIterator pit = cpit; pit.push_back(*this); toc.push_back(TocItem(pit, 0, str)); - if (embedded_status) - backend.toc("embedded").push_back(TocItem(cpit, 0, str)); return; } Buffer const * const childbuffer = getChildBuffer(buffer(), params()); @@ -895,11 +897,11 @@ void InsetInclude::addToToc(ParConstIterator const & cpit) const Toc & toc = backend.toc("child"); docstring str = childbuffer->fileName().displayName(); - if (embedded_status) + if (embedded_status) { + backend.toc("embedded").push_back(TocItem(cpit, 0, str)); str += _(" (embedded)"); + } toc.push_back(TocItem(cpit, 0, str)); - if (embedded_status) - backend.toc("embedded").push_back(TocItem(cpit, 0, str)); TocList & toclist = backend.tocs(); TocList const & childtoclist = childbuffer->tocBackend().tocs(); -- 2.39.2