MCPcopy Create free account
hub / github.com/IgKh/katvan / documentNaturalSize

Function documentNaturalSize

core/katvan_editortooltip.cpp:125–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125static QSizeF documentNaturalSize(QTextDocument* doc)
126{
127 qreal width = 0;
128
129 // Also forces whole layout to complete
130 QSizeF fullSize = doc->size();
131
132 for (QTextBlock b = doc->begin(); b != doc->end(); b = b.next()) {
133 QTextLayout* tl = b.layout();
134 for (int i = 0; i < tl->lineCount(); i++) {
135 QTextLine line = tl->lineAt(i);
136 // Need to consider line offsets, for e.g. list bullets (as in `color`)
137 width = qMax(width, line.naturalTextWidth() + tl->position().x() + line.position().x());
138 }
139 }
140 return QSizeF { width, fullSize.height() };
141}
142
143static QSize calculateBrowserSize(QTextDocument* doc, bool& needsScrollBar)
144{

Callers 1

calculateBrowserSizeFunction · 0.85

Calls 3

beginMethod · 0.80
endMethod · 0.80
positionMethod · 0.80

Tested by

no test coverage detected