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

Method sizeHint

launcher/ui/instanceview/InstanceDelegate.cpp:350–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350QSize ListViewDelegate::sizeHint(const QStyleOptionViewItem &option,
351 const QModelIndex &index) const
352{
353 QStyleOptionViewItem opt = option;
354 initStyleOption(&opt, index);
355 opt.features |= QStyleOptionViewItem::WrapText;
356 opt.text = index.data().toString();
357 opt.textElideMode = Qt::ElideRight;
358 opt.displayAlignment = Qt::AlignTop | Qt::AlignHCenter;
359
360 QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
361 const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, &option, opt.widget) + 1;
362 int height = 48 + textMargin * 2 + 5; // TODO: turn constants into variables
363 QSize szz = viewItemTextSize(&opt);
364 height += szz.height();
365 // FIXME: maybe the icon items could scale and keep proportions?
366 QSize sz(100, height);
367 return sz;
368}
369
370class NoReturnTextEdit: public QTextEdit
371{

Callers 2

geometryRectMethod · 0.45
updateMethod · 0.45

Calls 3

viewItemTextSizeFunction · 0.85
toStringMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected