Bug 342076 - The marker for the current section only shows up for the first page of a chapter
Summary: The marker for the current section only shows up for the first page of a chapter
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 0.20.2
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-21 15:05 UTC by miklos
Modified: 2016-03-21 23:30 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
okular_marker.diff (1.61 KB, patch)
2016-02-06 18:44 UTC, miklos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description miklos 2014-12-21 15:05:18 UTC
In the Contents panel there is a green triangle that's supposed to appear before the current section/chapter. However, it only shows up, when the currently displayed page is the first page of a section, and the section title that is on the current page is visible in the outline view.

In my understanding the green marker should show which of the sections currently displayed in the outline contains the currently displayed page. E.g. I'm on page 139, which is the third page of section 4.4.3. Now the outline should show the marker at section 4, if it's collapsed; at 4.4, if it's expanded one level; and at 4.4.3, if it's fully expanded. Currently no marker is shown for any of these cases.

I'm using Debian Unstable, I don't know if this has been fixed in newer versions of Okular.

Reproducible: Always
Comment 1 Albert Astals Cid 2014-12-21 16:54:53 UTC
Please attach a file and to use and a screenshot showing your problem.
Comment 2 Oliver Sander 2014-12-21 20:27:33 UTC
In can confirm this with the current git master.  To reproduce just pick any LaTeX-generated file with a toc, e.g.: http://arxiv.org/pdf/1301.2539
Set up okular so that it shows the toc in the left part.  The green triangle appears when viewing page one (which contains the chapter heading "1. Introduction".  It disappears when scrolling to page 2 (which does not contain a chapter heading).  It reappears when scrolling to page 3 which contains the beginning of Chapter 2.
Comment 3 miklos 2014-12-21 21:13:16 UTC
Oliver's link is a good example.
Comment 4 Albert Astals Cid 2014-12-21 21:46:23 UTC
Ah, Oliver description is easier to understand, that's just how it was coded.

Besides I don't think what you suggest can be done, nothing in the specification guarantees the Table Of Contents is sorted.

What would you do when that happens?

And what when the TOC has multiple sublevels? And multiple TOC items pointing to the same page?
Comment 5 miklos 2014-12-21 22:35:00 UTC
If you can generate the TOC tree, and you can jump to specific pages when a TOC element is clicked, you have a sorted representation of the document structure. You just need to find the TOC element that points to the highest page number that is lower or equal than the currently displayed page. Add the marker to that TOC element, if visible, to its parent, if not (use a recursion). If multiple TOC elements point to the same page, select the first one (deterministically).
Comment 6 Albert Astals Cid 2014-12-22 00:29:03 UTC
I disagree, and actually querying the whole TOC tree is quite a bad idea since on big documents it can be veeeeeeeeeeeeeeery slow.

But if someone comes up with a patch we can discuss over it.
Comment 7 miklos 2016-02-06 18:44:07 UTC
Created attachment 97055 [details]
okular_marker.diff

(In reply to Albert Astals Cid from comment #6)
> I disagree, and actually querying the whole TOC tree is quite a bad idea
> since on big documents it can be veeeeeeeeeeeeeeery slow.
> 
> But if someone comes up with a patch we can discuss over it.

Today I noticed that this bug is still open, and I decided to take a look at the code. You worry about querying the whole TOC tree? The current code does exactly that to find the items matching the current page!

I came up with the attached patch that half-solves the problem, and doesn't go over the entire TOC tree :) The remaining task is to teach TOCModel::data() to only set KIcon to nodes that either have no children or are not expanded. The latter is a bit difficult, as the model knows nothing about the treeview. I'm open to suggestions.
Comment 8 Albert Astals Cid 2016-02-07 22:50:28 UTC
Please use reviewboard for patches, it's much easier to review them in there
Comment 9 miklos 2016-02-08 17:52:21 UTC
(In reply to Albert Astals Cid from comment #8)
> Please use reviewboard for patches, it's much easier to review them in there

OK, I did that.
Comment 10 Albert Astals Cid 2016-03-21 23:30:27 UTC
Git commit 1371ccfa28cf777dd04d3f67a1947e41b02dba0d by Albert Astals Cid, on behalf of Miklós Máté.
Committed on 21/03/2016 at 23:29.
Pushed by aacid into branch 'Applications/16.04'.

Show TOC marker for parents if the children is collapsed
REVIEWS: 127013

M  +59   -12   ui/tocmodel.cpp

http://commits.kde.org/okular/1371ccfa28cf777dd04d3f67a1947e41b02dba0d