1 #include "treedelegate.h"
3 TreeDelegate::TreeDelegate(QObject *) {}
5 QString TreeDelegate::displayText(const QVariant &value, const QLocale &) const
7 return value.toString().trimmed();
10 void TreeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
11 const QModelIndex &index) const
13 QStyleOptionViewItem local_option = option;
14 QVariant color_text_v = index.model()->data(index, Qt::ForegroundRole);
15 QColor color_text = color_text_v.isValid() ? color_text_v.value<QColor>()
16 : local_option.palette.color(QPalette::Text);
17 // clobber the selection coloring with ordinary coloring
18 // local_option.palette.setColor(QPalette::Highlight, color_base);
19 local_option.palette.setColor(QPalette::HighlightedText, color_text);
20 QStyledItemDelegate::paint(painter, local_option, index) ;