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

Method sizeHint

launcher/ui/instanceview/InstanceDelegate.cpp:330–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328}
329
330QSize ListViewDelegate::sizeHint(const QStyleOptionViewItem &option,
331 const QModelIndex &index) const
332{
333 QStyleOptionViewItem opt = option;
334 initStyleOption(&opt, index);
335 opt.features |= QStyleOptionViewItem::WrapText;
336 opt.text = index.data().toString();
337 opt.textElideMode = Qt::ElideRight;
338 opt.displayAlignment = Qt::AlignTop | Qt::AlignHCenter;
339
340 QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
341 const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, &option, opt.widget) + 1;
342 int height = 48 + textMargin * 2 + 5; // TODO: turn constants into variables
343 QSize szz = viewItemTextSize(&opt);
344 height += szz.height();
345 // FIXME: maybe the icon items could scale and keep proportions?
346 QSize sz(100, height);
347 return sz;
348}
349
350class NoReturnTextEdit: public QTextEdit
351{

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