X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=src%2Ftreedelegate.cpp;fp=src%2Ftreedelegate.cpp;h=519ba78405dd33cc1e9d6c1e573cdc8d42f34a22;hb=d483bd8e6523c23c6f1d8908a2e0611c2bc9ff4f;hp=0000000000000000000000000000000000000000;hpb=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git diff --git a/src/treedelegate.cpp b/src/treedelegate.cpp new file mode 100644 index 0000000..519ba78 --- /dev/null +++ b/src/treedelegate.cpp @@ -0,0 +1,21 @@ +#include "treedelegate.h" + +TreeDelegate::TreeDelegate(QObject *) {} + +QString TreeDelegate::displayText(const QVariant &value, const QLocale &) const +{ + return value.toString().trimmed(); +} + +void TreeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + QStyleOptionViewItem local_option = option; + QVariant color_text_v = index.model()->data(index, Qt::ForegroundRole); + QColor color_text = color_text_v.isValid() ? color_text_v.value() + : local_option.palette.color(QPalette::Text); + // clobber the selection coloring with ordinary coloring + // local_option.palette.setColor(QPalette::Highlight, color_base); + local_option.palette.setColor(QPalette::HighlightedText, color_text); + QStyledItemDelegate::paint(painter, local_option, index) ; +}