From 39ccaa2ea7b69f09a998d6dcb5b8926598d26dd2 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 27 Feb 2008 15:23:22 +0000 Subject: [PATCH] Add list of labels. If I have the time and energy the next step is to cleanup the cross-reference lookup so that we can integrate the cross references in the tree, hence the name "Labels and References". git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23282 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/MenuBackend.cpp | 2 ++ src/frontends/qt4/GuiToc.cpp | 2 ++ src/insets/InsetLabel.cpp | 19 ++++++++++++++++++- src/insets/InsetLabel.h | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/MenuBackend.cpp b/src/MenuBackend.cpp index 7abcf5c5e1..e8d8156f4f 100644 --- a/src/MenuBackend.cpp +++ b/src/MenuBackend.cpp @@ -778,6 +778,8 @@ void expandToc(Menu & tomenu, Buffer const * buf) label = _("List of Notes"); else if (cit->first == "footnote") label = _("List of Foot notes"); + else if (cit->first == "label") + label = _("Labels and References"); // this should not happen now, but if something else like // listings is added later, this can avoid an empty menu name. else diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index b10b864d1f..3dd5ea1b2e 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -233,6 +233,8 @@ docstring GuiToc::guiName(string const & type) const return _("List of Marginal notes"); if (type == "note") return _("List of Notes"); + if (type == "label") + return _("Labels and References"); FloatList const & floats = buffer().params().textClass().floats(); if (floats.typeExist(type)) diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index c0b6b4d19d..047807577e 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -16,8 +16,10 @@ #include "BufferView.h" #include "DispatchResult.h" #include "FuncRequest.h" -#include "Text.h" +#include "ParIterator.h" #include "sgml.h" +#include "Text.h" +#include "TocBackend.h" #include "support/lstrings.h" #include "support/lyxalgo.h" @@ -61,6 +63,21 @@ docstring const InsetLabel::getScreenLabel(Buffer const &) const } +void InsetLabel::addToToc(Buffer const & buf, + ParConstIterator const & cpit) const +{ + ParConstIterator pit = cpit; + pit.push_back(*this); + + //FIXME: It would be really, really, really nice if we could + // construct a tree here with all the cross-reference to this + // label. + + Toc & toc = buf.tocBackend().toc("label"); + toc.push_back(TocItem(pit, 0, getScreenLabel(buf))); +} + + void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action) { diff --git a/src/insets/InsetLabel.h b/src/insets/InsetLabel.h index 640c1ca0fe..cfd9374f53 100644 --- a/src/insets/InsetLabel.h +++ b/src/insets/InsetLabel.h @@ -42,6 +42,8 @@ public: /// static bool isCompatibleCommand(std::string const & s) { return s == "label"; } + /// + void addToToc(Buffer const &, ParConstIterator const &) const; protected: /// virtual void doDispatch(Cursor & cur, FuncRequest & cmd);