MCPcopy Create free account
hub / github.com/KDE/kdevelop / drawDisplay

Method drawDisplay

plugins/projectmanagerview/projectmodelitemdelegate.cpp:137–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137void ProjectModelItemDelegate::drawDisplay(QPainter* painter, const QStyleOptionViewItem& option,
138 const QRect& rect, const QString& text) const
139{
140 QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled)
141 ? QPalette::Normal : QPalette::Disabled;
142 if (option.state & QStyle::State_Editing) {
143 painter->save();
144 painter->setPen(option.palette.color(cg, QPalette::Text));
145 painter->drawRect(rect.adjusted(0, 0, -1, -1));
146 painter->restore();
147 }
148
149 if(text.isEmpty()) {
150 return;
151 }
152
153 if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
154 cg = QPalette::Inactive;
155 }
156 if (option.state & QStyle::State_Selected) {
157 painter->setPen(option.palette.color(cg, QPalette::HighlightedText));
158 } else {
159 painter->setPen(option.palette.color(cg, QPalette::Text));
160 }
161
162 QFontMetrics fm(painter->fontMetrics());
163 painter->drawText(rect, fm.elidedText(text, Qt::ElideRight, rect.width()));
164}
165
166bool ProjectModelItemDelegate::helpEvent(QHelpEvent* event,
167 QAbstractItemView* view, const QStyleOptionViewItem& option,

Callers

nothing calls this directly

Calls 2

saveMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected