Krita Source Code Documentation
Loading...
Searching...
No Matches
KoLineStyleItemDelegate.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
8
9#include <QPen>
10#include <QPainter>
11
13 : QAbstractItemDelegate(parent)
14{
15}
16
17void KoLineStyleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
18{
19 painter->save();
20
21 if (option.state & QStyle::State_Selected)
22 painter->fillRect(option.rect, option.palette.highlight());
23
24 QPen pen = index.data(Qt::DecorationRole).value<QPen>();
25 pen.setBrush(option.palette.text()); // use the view-specific palette; the model hardcodes this to black
26 painter->setPen(pen);
27 painter->drawLine(option.rect.left(), option.rect.center().y(), option.rect.right(), option.rect.center().y());
28
29 painter->restore();
30}
31
32QSize KoLineStyleItemDelegate::sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const
33{
34 return QSize(100, 15);
35}
KoLineStyleItemDelegate(QObject *parent=0)
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override