MCPcopy Create free account
hub / github.com/KDAB/GammaRay / sizeHint

Method sizeHint

plugins/quickinspector/quickitemdelegate.cpp:97–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97QSize QuickItemDelegate::sizeHint(const QStyleOptionViewItem &option,
98 const QModelIndex &index) const
99{
100 Q_UNUSED(option);
101
102 // this gets us the cached value for empty cells
103 const auto sh = index.data(Qt::SizeHintRole);
104 if (sh.isValid())
105 return sh.toSize();
106
107 QSize textSize = m_view->fontMetrics().size(Qt::TextSingleLine, index.data(Qt::DisplayRole).toString());
108
109 QSize decorationSize;
110 if (index.column() == 0) {
111 int flags = index.data(QuickItemModelRole::ItemFlags).value<int>();
112
113 int icons = 1;
114 if ((flags & QuickItemModelRole::OutOfView) && (~flags & QuickItemModelRole::Invisible))
115 icons++;
116
117 if (flags & (QuickItemModelRole::HasFocus | QuickItemModelRole::HasActiveFocus))
118 icons++;
119
120 decorationSize = QSize(icons * 20, 16);
121 }
122
123 return { textSize.width() + decorationSize.width() + 5,
124 qMax(textSize.height(), decorationSize.height()) };
125}
126
127void QuickItemDelegate::setTextColor(const QVariant &textColor, const QPersistentModelIndex &index)
128{

Callers 2

resizeEventMethod · 0.45

Calls 5

QSizeClass · 0.85
columnMethod · 0.80
dataMethod · 0.45
isValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected