File indexing completed on 2024-05-12 16:02:09
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "KoLineStyleItemDelegate_p.h" 0008 0009 #include <QPen> 0010 #include <QPainter> 0011 0012 KoLineStyleItemDelegate::KoLineStyleItemDelegate(QObject * parent) 0013 : QAbstractItemDelegate(parent) 0014 { 0015 } 0016 0017 void KoLineStyleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 0018 { 0019 painter->save(); 0020 0021 if (option.state & QStyle::State_Selected) 0022 painter->fillRect(option.rect, option.palette.highlight()); 0023 0024 QPen pen = index.data(Qt::DecorationRole).value<QPen>(); 0025 pen.setBrush(option.palette.text()); // use the view-specific palette; the model hardcodes this to black 0026 painter->setPen(pen); 0027 painter->drawLine(option.rect.left(), option.rect.center().y(), option.rect.right(), option.rect.center().y()); 0028 0029 painter->restore(); 0030 } 0031 0032 QSize KoLineStyleItemDelegate::sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const 0033 { 0034 return QSize(100, 15); 0035 }