MCPcopy Create free account
hub / github.com/MultiMC/Launcher / viewItemTextSize

Function viewItemTextSize

launcher/ui/instanceview/InstanceDelegate.cpp:161–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

sizeHintMethod · 0.85

Calls 3

setFontMethod · 0.80
viewItemTextLayoutFunction · 0.70
setTextMethod · 0.45

Tested by

no test coverage detected