Following Richard's suggestion at http://www.lyx.org/trac/ticket/7790,
I've made a few patches regarding some insets in TOC (Document Outline).
Can someone please check, and commit if everything's fine.
InsetERT.cpp (+InsetERT.h)
Added InsetERT::addToToc, mostly by copying from InsetNote.cpp
Only change is that there's no label "ERT: " in front of every TOC
entry. InsetNote.cpp needs that because it covers three kinds of notes.
InsetListings.cpp (+InsetListings.h)
Added InsetERT::addToToc. Though it was anticipated in qt_helpers.cpp,
it wasn't implemented here. No need for labels in front of the entries,
I guess?
InsetCaption.cpp
A minor change - labels in TOC were something like "Table 1:. xxx xxxxx"
(note the dot after the colon)
qt_helpers.cpp
Added support for "List of ERT's"
--- lyx-devel/src/insets/InsetERT.cpp
+++ lyx-devel/src/insets/InsetERT-PP.cpp
@@ -28,6 +28,7 @@
#include "ParagraphParameters.h"
#include "Paragraph.h"
#include "TextClass.h"
+#include "TocBackend.h"
#include "support/gettext.h"
#include "support/lstrings.h"
@@ -140,6 +141,20 @@
}
+void InsetERT::addToToc(DocIterator const & cpit) const
+{
+ DocIterator pit = cpit;
+ pit.push_back(CursorSlice(const_cast<InsetERT &>(*this)));
+
+ Toc & toc = buffer().tocBackend().toc("ERT");
+ docstring str = from_ascii("");
+ text().forToc(str, TOC_ENTRY_LENGTH);
+ toc.push_back(TocItem(pit, 0, str, toolTipText(docstring(), 3, 60)));
+ // Proceed with the rest of the inset.
+ InsetCollapsable::addToToc(cpit);
+}
+
+
docstring const InsetERT::buttonLabel(BufferView const & bv) const
{
if (decoration() == InsetLayout::CLASSIC)
--- /home/ivo/Temporary/lyx-devel/lyx-devel/src/insets/InsetERT.h
+++ /home/ivo/Temporary/lyx-devel/lyx-devel/src/insets/InsetERT-PP.h
@@ -62,6 +62,8 @@
///
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &)
const;
///
+ void addToToc(DocIterator const &) const;
+ ///
Inset * clone() const { return new InsetERT(*this); }
///
docstring const buttonLabel(BufferView const & bv) const;
--- lyx-devel/src/insets/InsetListings.cpp
+++ lyx-devel/src/insets/InsetListings-PP.cpp
@@ -30,6 +30,7 @@
#include "output_xhtml.h"
#include "OutputParams.h"
#include "TextClass.h"
+#include "TocBackend.h"
#include "support/debug.h"
#include "support/docstream.h"
@@ -344,6 +345,20 @@
}
+void InsetListings::addToToc(DocIterator const & cpit) const
+{
+ DocIterator pit = cpit;
+ pit.push_back(CursorSlice(const_cast<InsetListings &>(*this)));
+
+ Toc & toc = buffer().tocBackend().toc("listing");
+ docstring str = from_ascii("");
+ text().forToc(str, TOC_ENTRY_LENGTH);
+ toc.push_back(TocItem(pit, 0, str, toolTipText(docstring(), 3, 60)));
+ // Proceed with the rest of the inset.
+ InsetCollapsable::addToToc(cpit);
+}
+
+
docstring const InsetListings::buttonLabel(BufferView const & bv) const
{
// FIXME UNICODE
--- lyx-devel/src/insets/InsetListings.h
+++ lyx-devel/src/insets/InsetListings-PP.h
@@ -73,6 +73,8 @@
///
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &)
const;
///
+ void addToToc(DocIterator const &) const;
+ ///
Inset * clone() const { return new InsetListings(*this); }
///
docstring const buttonLabel(BufferView const & bv) const;
--- lyx-devel/src/insets/InsetCaption.cpp
+++ lyx-devel/src/insets/InsetCaption-PP.cpp
@@ -101,7 +101,7 @@
pit.push_back(CursorSlice(const_cast<InsetCaption &>(*this)));
Toc & toc = buffer().tocBackend().toc(type_);
- docstring str = full_label_ + ". ";
+ docstring str = full_label_ + " ";
text().forToc(str, TOC_ENTRY_LENGTH);
toc.push_back(TocItem(pit, 0, str));
--- lyx-devel/src/frontends/qt4/qt_helpers.cpp
+++ lyx-devel/src/frontends/qt4/qt_helpers-PP.cpp
@@ -566,6 +566,8 @@
return qt_("List of Marginal notes");
if (type == "note")
return qt_("List of Notes");
+ if (type == "ERT")
+ return qt_("List of ERT's");
if (type == "citation")
return qt_("List of Citations");
if (type == "label")