]> git.sven.stormbind.net Git - sven/vym.git/blob - src/treedelegate.cpp
Replace Pierre as the maintainer
[sven/vym.git] / src / treedelegate.cpp
1 #include "treedelegate.h"
2
3 TreeDelegate::TreeDelegate(QObject *) {}
4
5 QString TreeDelegate::displayText(const QVariant &value, const QLocale &) const
6 {
7     return value.toString().trimmed();
8 }
9
10 void TreeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
11     const QModelIndex &index) const
12 {
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) ;
21 }