Bug 312138 - Unfolded table of contents folds in upon reloading of document
Summary: Unfolded table of contents folds in upon reloading of document
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 0.15.90
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2012-12-23 22:19 UTC by Oliver Sander
Modified: 2013-01-09 22:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.11


Attachments
Sample pdf file with a toc for testing (17.59 KB, application/pdf)
2012-12-23 22:20 UTC, Oliver Sander
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Sander 2012-12-23 22:19:29 UTC
I work on a large text document using pdflatex.  The latex 'hyperref' package embeds the table of content into the document, and I can browse the toc in okular.  Very nice.  At program start the toc view opens at the top level (only chapter headings are shown, no sections or subsections).  I can then click on a chapter to see the list of subsections it contains.  This all works nicely, but here is the annoyance: If I recompile my document, and okular reloads the pdf file, then the toc 'folds in' and again only the chapter headings are shown.  Since recompilation is frequent in a LaTeX workflow this behavior is somewhat annoying.

I have described the problem for pdf, but the same happens when compiling the TeX source to dvi.

I'll attach a simple pdf file for your convenience.

Reproducible: Always

Steps to Reproduce:
1. Open attached test file
2. Open the toc view in the left column
3. Click on the little right-pointing arrow next to Chapter 'foo', you'll see section 'bar' below
4. In a shell, type 'touch toc-folding.pdf'

Actual Results:  
The toc view goes into its initial state, showing only the chapter 'foo'

Expected Results:  
The toc view should keep its current state, i.e., show 'foo' and 'bar'
Comment 1 Oliver Sander 2012-12-23 22:20:42 UTC
Created attachment 75991 [details]
Sample pdf file with a toc for testing
Comment 2 Albert Astals Cid 2012-12-24 14:39:23 UTC
Sure, that'd be a nice thing, i personally think this is a new feature not a bug, besides it is not trivial how this should work, if the TOC has not changed it is obvious what should happen, but what if the TOC changes? How hard should we try to keep it similar and how do you recognise nodes of the TOC? Because maybe you just changed a typo in a node of the TOC, but how are we going to know it is the same?

Should we store stuff by name? by destinatio page? by destination page and name? there's lots of combinations that have to be considered to know what is the behaviour you want.

So you that are using the feature, can you think about which behaviour would you like (beisdes the obvious reload it perfectly!)?
Comment 3 Oliver Sander 2012-12-24 15:30:50 UTC
Agreed: it's more a wish than a bug.

Also agreed: For non-trivial changes to the document structure it is not clear at all what the desired solution is.

Either one of the following two behaviors would be a definite improvement for me:

a) Keep the toc view in its present state if the toc hasn't changed at all.  Otherwise fold it completely
b) (a bit more involved). Traverse the toc tree.  When a node is found which has changed its name, then fold its subtree completely.  That way, unchanged nodes close to the root are preserved in the view.

Sure we could cook up more intelligent schemes, but I doubt they are worth the effort.
Comment 4 Albert Astals Cid 2012-12-26 21:05:28 UTC
Marking this as a junior job, it should be pretty easy to store the whole tree of the TOC when we trigger the reload and check if the tree is the same after it has happened. Interested people in implementing the junior job please contact the okular-devel@kde.org mailing list if you decide to have a look at this.
Comment 5 Albert Astals Cid 2013-01-09 22:32:42 UTC
Git commit 7c99477f9466f5c7164991195236cdb12d0edba8 by Albert Astals Cid, on behalf of Jaydeep Solanki.
Committed on 09/01/2013 at 23:31.
Pushed by aacid into branch 'master'.

Preserve TOC folding status on document dirty reload

REVIEW: 107994

M  +3    -0    part.cpp
M  +26   -0    ui/toc.cpp
M  +5    -0    ui/toc.h
M  +79   -7    ui/tocmodel.cpp
M  +4    -0    ui/tocmodel.h

http://commits.kde.org/okular/7c99477f9466f5c7164991195236cdb12d0edba8
Comment 6 Albert Astals Cid 2013-01-09 22:33:57 UTC
Jaydeep has implemented the basic functionality, i.e. if the toc is exactly the same, the shape is preserved, otherwise you loose it. If you want something more advanced feel free to open a new bug