Hello,

This small patch adds a much desired feature without any sensible performance penalty: List of changes in the Navigator pane.

The list is presented as follow:

Deletion (author1) aaaa
Insertion (author2) bbbb
Insertion (author1) cccc
Insertion (author2) dddd
...

An alternative would be to present the changes classified by authors:

+ author1
   Deletion: aaaa
   Insertion: bbbb
+ author2
   Insertion: cccc
   Deletion: dddd
...

Or we could also put the author first in order to make use of the sort check box:
author1 - Deletion: aaaa
author2 - Insertion: bbbb
author1 - Insertion: cccc
author1 - Insertion: dddd
...

Ideas? Comments, Objection?

Abdel.
Index: src/Changes.cpp
===================================================================
--- src/Changes.cpp     (revision 26602)
+++ src/Changes.cpp     (working copy)
@@ -17,9 +17,11 @@
 #include "Author.h"
 #include "BufferParams.h"
 #include "LaTeXFeatures.h"
+#include "Paragraph.h"
+#include "TocBackend.h"
 
 #include "support/debug.h"
-
+#include "support/gettext.h"
 #include "support/lassert.h"
 
 #include <ostream>
@@ -381,4 +383,35 @@
                        authorList.get(it->change.author).setUsed(true);
 }
 
+
+void Changes::addToToc(DocIterator const & cdit, AuthorList const & 
author_list,
+       Toc & change_list) const
+{
+       if (table_.empty())
+               return;
+
+       DocIterator dit = cdit;
+
+       ChangeTable::const_iterator it = table_.begin();
+       ChangeTable::const_iterator const itend = table_.end();
+
+       for (; it != itend; ++it) {
+               docstring str;
+               switch (it->change.type) {
+               case Change::UNCHANGED:
+                       continue;
+               case Change::DELETED:
+                       str = _("Deletion");
+                       break;
+               case Change::INSERTED:
+                       str = _("Insertion");
+                       break;
+               }
+               str += " (" + author_list.get(it->change.author).name() + ") ";
+               str += dit.paragraph().asString(it->range.start, it->range.end);
+               dit.pos() = it->range.start;
+               change_list.push_back(TocItem(dit, 0, str));
+       }
+}
+
 } // namespace lyx
Index: src/Changes.h
===================================================================
--- src/Changes.h       (revision 26602)
+++ src/Changes.h       (working copy)
@@ -27,6 +27,8 @@
 namespace lyx {
 
 class AuthorList;
+class DocIterator;
+class Toc;
 
 class Change {
 public:
@@ -92,8 +94,6 @@
        /// return true if there is a change in the given range (excluding end)
        bool isChanged(pos_type start, pos_type end) const;
 
-       ///
-
        /// output latex to mark a transition between two change types
        /// returns length of text outputted
        static int latexMarkChange(odocstream & os, BufferParams const & 
bparams,
@@ -106,6 +106,10 @@
        ///
        void checkAuthors(AuthorList const & authorList);
 
+       ///
+       void addToToc(DocIterator const & cdit, AuthorList const & author_list,
+               Toc & change_list) const;
+
 private:
        class Range {
        public:
Index: src/insets/InsetText.cpp
===================================================================
--- src/insets/InsetText.cpp    (revision 26602)
+++ src/insets/InsetText.cpp    (working copy)
@@ -14,6 +14,7 @@
 
 #include "insets/InsetOptArg.h"
 
+#include "Author.h"
 #include "buffer_funcs.h"
 #include "Buffer.h"
 #include "BufferParams.h"
@@ -453,6 +454,7 @@
        DocIterator dit = cdit;
        dit.push_back(CursorSlice(*this));
        Toc & toc = buffer().tocBackend().toc("tableofcontents");
+       Toc & change_list = buffer().tocBackend().toc("changes");
 
        BufferParams const & bufparams = buffer_->params();
        const int min_toclevel = bufparams.documentClass().min_toclevel();
@@ -498,6 +500,9 @@
                                tocstring = par.asString(AS_STR_LABEL);
                        toc.push_back(TocItem(dit, toclevel - min_toclevel, 
tocstring));
                }
+               
+               // And now the list of changes.
+               par.addChangesToToc(dit, buffer().params().authors(), 
change_list);
        }
 }
 
Index: src/Paragraph.cpp
===================================================================
--- src/Paragraph.cpp   (revision 26602)
+++ src/Paragraph.cpp   (working copy)
@@ -279,6 +279,13 @@
 }
 
 
+void Paragraph::addChangesToToc(DocIterator const & cdit, AuthorList const & 
author_list,
+       Toc & change_list) const
+{
+       d->changes_.addToToc(cdit, author_list, change_list);
+}
+
+
 bool Paragraph::isChanged(pos_type start, pos_type end) const
 {
        LASSERT(start >= 0 && start <= size(), /**/);
Index: src/Paragraph.h
===================================================================
--- src/Paragraph.h     (revision 26602)
+++ src/Paragraph.h     (working copy)
@@ -33,6 +33,7 @@
 class Counters;
 class Cursor;
 class CursorSlice;
+class DocIterator;
 class DocumentClass;
 class Inset;
 class InsetBibitem;
@@ -47,8 +48,8 @@
 class PainterInfo;
 class ParagraphParameters;
 class TexRow;
+class Toc;
 
-
 class FontSpan {
 public:
        /// Invalid font span containing no character
@@ -100,6 +101,9 @@
        int id() const;
 
        ///
+       void addChangesToToc(DocIterator const & cdit, AuthorList const & 
author_list,
+               Toc & change_list) const;
+       ///
        Language const * getParLanguage(BufferParams const &) const;
        ///
        bool isRTL(BufferParams const &) const;

Reply via email to