File indexing completed on 2024-03-24 16:04:30
0001 /* 0002 SPDX-FileCopyrightText: 2012 Miha Čančula <miha@noughmad.eu> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "testdoxdelegate.h" 0008 0009 TestDoxDelegate::TestDoxDelegate(QObject* parent): QItemDelegate(parent), 0010 failBrush(KColorScheme::View, KColorScheme::NegativeText), 0011 passBrush(KColorScheme::View, KColorScheme::PositiveText) 0012 { 0013 0014 } 0015 0016 TestDoxDelegate::~TestDoxDelegate() 0017 { 0018 0019 } 0020 0021 void TestDoxDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const 0022 { 0023 const QString line = index.data().toString(); 0024 QStyleOptionViewItem opt = option; 0025 if (line.startsWith(QLatin1String(" [x]"))) 0026 { 0027 highlight(opt, passBrush); 0028 } 0029 else if (line.startsWith(QLatin1String(" [ ]"))) 0030 { 0031 highlight(opt, failBrush); 0032 } 0033 QItemDelegate::paint(painter, opt, index); 0034 } 0035 0036 void TestDoxDelegate::highlight(QStyleOptionViewItem& option, const KStatefulBrush& brush, bool bold) const 0037 { 0038 option.font.setBold(bold); 0039 option.palette.setBrush(QPalette::Text, brush.brush(option.palette)); 0040 } 0041