MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / viewItemTextSize

Function viewItemTextSize

launcher/ui/instanceview/InstanceDelegate.cpp:181–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181static QSize viewItemTextSize(const QStyleOptionViewItem *option)
182{
183 QStyle *style = option->widget ? option->widget->style() : QApplication::style();
184 QTextOption textOption;
185 textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
186 QTextLayout textLayout;
187 textLayout.setTextOption(textOption);
188 textLayout.setFont(option->font);
189 textLayout.setText(option->text);
190 const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, option, option->widget) + 1;
191 QRect bounds(0, 0, 100 - 2 * textMargin, 600);
192 qreal height = 0, widthUsed = 0;
193 viewItemTextLayout(textLayout, bounds.width(), height, widthUsed);
194 const QSize size(qCeil(widthUsed), qCeil(height));
195 return QSize(size.width() + 2 * textMargin, size.height());
196}
197
198void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
199 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