Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hierarchical LABELS View under Structure #1258

Closed
neta-elad opened this issue Sep 6, 2020 · 5 comments
Closed

Hierarchical LABELS View under Structure #1258

neta-elad opened this issue Sep 6, 2020 · 5 comments
Labels

Comments

@neta-elad
Copy link

Hi, I would like to develop an enhancement to the structure panel, but it's my first time so I need some help. I want to split labels according to some character (probably ":" by default), and then show the labels in the Structure panel in a hierarchical way. I.e., if we have the following labels in a document: fig:a,thm:a,fig:b,thm:b instead of showing them in flat view as:

+-- Structure
|   +-- LABELS
|   |   +-- fig:a
|   |   +-- thm:a
|   |   +-- fig:b
|   |   +-- thm:b

it will be shown using two inner-trees for fig and thm:

+-- Structure
|   +-- LABELS
|   |   +-- fig
|   |   |   +-- a
|   |   |   +-- b
|   |   +-- thm
|   |   |   +-- a
|   |   |   +-- b

I found the src/tests/structureview_t.cpp test which seems related, and the insertElementWithSignal method in src/latexdocument.cpp that also seems relevant, but I'm not sure how to run the test (after I modify it to test my expected behaviour), and in general how to continue from here. I'd be very glad for a little guidance, I'm sure I could take it away by myself afterwards.

The end goal is to make all of this configurable, and also work for other parts of the Structure panel (like todo), but for now I just want to see how to do it for labels (which are most often separated to different types according to different prefixes).

@sunderme
Copy link
Member

sunderme commented Sep 6, 2020

txs uses the model/view mechanism for displaying the structure.
The actual widget is an extended Qtreeview (see qt documentation) as StructureTreeView.
The model is called LatexDocumentsModel which actually translates the data into the visual representation. The actual data is stored in StructureEntry , a tree data structure with parent/children relations.
in the method patchStructure, document is parsed and the above mentioned data is updated.

The insertElementWitchSignal is necessary as the viewer element needs to be informed when the structure is changed. All similar signals serve the same purpose. The tricky part is that failure to do so correctly results in crashes.
As the labels are presented as a linear list, that is probably not so complicated to change, but be careful.

@neta-elad
Copy link
Author

Thank you very much! Also, how can I run the src/tests/structureview_t.cpp?

@sunderme
Copy link
Member

sunderme commented Sep 6, 2020

It is run automatically with debug builds (first run or option --execute-tests)

@neta-elad
Copy link
Author

Is there a way to only run a specific test instead of the entire suite?

@sunderme
Copy link
Member

sunderme commented Sep 7, 2020

no, unless you change the code in testmanager.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants