Skip to content

Draft: Table of Contents Word Wrap

Jamal Bouajjaj requested to merge electro/okular:tco_word_wrap into master

As suggested by Bug#439223, this PR adds word wrapping to the table of contents, as well as adds a setting for that.

This is still a WIP, as what I cannot figure out how to do it is change an item's height to match the word-wrapped content. My attempt was to add a Qt::SizeHintRole to the TCOModel's data callback, but that doesn't seem to work:

QSize baseSize(20, 10000);
QFontMetrics metrics(this->data(index, Qt::FontRole).value<QFont>());
QRect outRect = metrics.boundingRect(QRect(QPoint(0, 0), baseSize), Qt::AlignLeft, item->text);
baseSize.setHeight(outRect.height());
return baseSize;

This is what it looks like right now to the lack of height adjustment:

image

I also need to find a way for Okular to add the TCOWordWrap setting to it's internal config file without deleting it and having Okular regenerate that.

Edited by Jamal Bouajjaj

Merge request reports