File indexing completed on 2024-05-12 04:39:28
0001 /* 0002 SPDX-FileCopyrightText: 2012 Miha Čančula <miha@noughmad.eu> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "qttestdelegate.h" 0008 0009 0010 QtTestDelegate::QtTestDelegate(QObject* parent) : QItemDelegate(parent), 0011 passBrush(KColorScheme::View, KColorScheme::PositiveText), 0012 failBrush(KColorScheme::View, KColorScheme::NegativeText), 0013 xFailBrush(KColorScheme::View, KColorScheme::InactiveText), 0014 xPassBrush(KColorScheme::View, KColorScheme::NeutralText), 0015 debugBrush(KColorScheme::View, KColorScheme::NormalText) 0016 { 0017 0018 } 0019 0020 QtTestDelegate::~QtTestDelegate() 0021 { 0022 0023 } 0024 0025 void QtTestDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const 0026 { 0027 const QString line = index.data().toString(); 0028 QStyleOptionViewItem opt = option; 0029 if (line.startsWith(QLatin1String("PASS :"))) 0030 { 0031 highlight(opt, passBrush); 0032 } 0033 else if (line.startsWith(QLatin1String("FAIL! :"))) 0034 { 0035 highlight(opt, failBrush); 0036 } 0037 else if (line.startsWith(QLatin1String("XFAIL :")) || line.startsWith(QLatin1String("SKIP :"))) 0038 { 0039 highlight(opt, xFailBrush); 0040 } 0041 else if (line.startsWith(QLatin1String("XPASS :"))) 0042 { 0043 highlight(opt, xPassBrush); 0044 } 0045 else if (line.startsWith(QLatin1String("QDEBUG :"))) 0046 { 0047 highlight(opt, debugBrush); 0048 } 0049 QItemDelegate::paint(painter, opt, index); 0050 } 0051 0052 void QtTestDelegate::highlight(QStyleOptionViewItem& option, const KStatefulBrush& brush, bool bold) const 0053 { 0054 option.font.setBold(bold); 0055 option.palette.setBrush(QPalette::Text, brush.brush(option.palette)); 0056 } 0057 0058 #include "moc_qttestdelegate.cpp"