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

Method paint

plugins/quickopen/expandingtree/expandingdelegate.cpp:63–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void ExpandingDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optionOld, const QModelIndex& index) const
64{
65 QStyleOptionViewItem option(optionOld);
66
67 m_currentIndex = index;
68
69 adjustStyle(index, option);
70
71 const QModelIndex sourceIndex = model()->mapToSource(index);
72 if (index.column() == 0) {
73 model()->placeExpandingWidget(sourceIndex);
74 }
75
76 //Make sure the decorations are painted at the top, because the center of expanded items will be filled with the embedded widget.
77 if (model()->isPartiallyExpanded(sourceIndex) == ExpandingWidgetModel::ExpandUpwards) {
78 m_cachedAlignment = Qt::AlignBottom;
79 } else {
80 m_cachedAlignment = Qt::AlignTop;
81 }
82
83 option.decorationAlignment = m_cachedAlignment;
84 option.displayAlignment = m_cachedAlignment;
85
86 //qCDebug( PLUGIN_QUICKOPEN ) << "Painting row " << index.row() << ", column " << index.column() << ", internal " << index.internalPointer() << ", drawselected " << option.showDecorationSelected << ", selected " << (option.state & QStyle::State_Selected);
87
88 m_cachedHighlights.clear();
89 m_backgroundColor = getUsedBackgroundColor(option, index);
90
91 if (model()->indexIsItem(sourceIndex)) {
92 m_currentColumnStart = 0;
93 m_cachedHighlights = createHighlighting(index, option);
94 }
95
96 /*qCDebug( PLUGIN_QUICKOPEN ) << "Highlights for line:";
97 foreach (const QTextLayout::FormatRange& fr, m_cachedHighlights)
98 qCDebug( PLUGIN_QUICKOPEN ) << fr.start << " len " << fr.length << " format ";*/
99
100 QItemDelegate::paint(painter, option, index);
101
102 ///This is a bug workaround for the Qt raster paint engine: It paints over widgets embedded into the viewport when updating due to mouse events
103 ///@todo report to Qt Software
104 if (model()->isExpanded(sourceIndex) && model()->expandingWidget(sourceIndex)) {
105 model()->expandingWidget(sourceIndex)->update();
106 }
107}
108
109QVector<QTextLayout::FormatRange> ExpandingDelegate::createHighlighting(const QModelIndex& index, QStyleOptionViewItem& option) const
110{

Callers

nothing calls this directly

Calls 12

modelFunction · 0.85
getUsedBackgroundColorFunction · 0.85
paintFunction · 0.85
placeExpandingWidgetMethod · 0.80
isPartiallyExpandedMethod · 0.80
indexIsItemMethod · 0.80
isExpandedMethod · 0.80
mapToSourceMethod · 0.45
columnMethod · 0.45
clearMethod · 0.45
expandingWidgetMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected