MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / viewItemTextSize

Function viewItemTextSize

launcher/ui/instanceview/InstanceDelegate.cpp:162–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162static QSize viewItemTextSize(const QStyleOptionViewItem* option)
163{
164 QStyle* style = option->widget ? option->widget->style() : QApplication::style();
165 QTextOption textOption;
166 textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
167 QTextLayout textLayout;
168 textLayout.setTextOption(textOption);
169 textLayout.setFont(option->font);
170 textLayout.setText(option->text);
171 const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, option, option->widget) + 1;
172 QRect bounds(0, 0, 100 - 2 * textMargin, 600);
173 qreal height = 0, widthUsed = 0;
174 viewItemTextLayout(textLayout, bounds.width(), height, widthUsed);
175 const QSize size(qCeil(widthUsed), qCeil(height));
176 return QSize(size.width() + 2 * textMargin, size.height());
177}
178
179void ListViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
180{

Callers 1

sizeHintMethod · 0.85

Calls 3

setFontMethod · 0.80
viewItemTextLayoutFunction · 0.70
setTextMethod · 0.45

Tested by

no test coverage detected