Krita Source Code Documentation
Loading...
Searching...
No Matches
KoMarkerItemDelegate.cpp
Go to the documentation of this file.
1
/* This file is part of the KDE project
2
* SPDX-FileCopyrightText: 2011 Thorsten Zachmann <zachmann@kde.org>
3
* SPDX-FileCopyrightText: 2011 Jean-Nicolas Artaud <jeannicolasartaud@gmail.com>
4
*
5
* SPDX-License-Identifier: LGPL-2.0-or-later
6
*/
7
8
#include "
KoMarkerItemDelegate.h
"
9
10
#include <
KoPathShape.h
>
11
#include <
KoMarker.h
>
12
13
#include <QPainter>
14
#include <QPen>
15
16
#include "
kis_global.h
"
17
18
KoMarkerItemDelegate::KoMarkerItemDelegate
(
KoFlake::MarkerPosition
position, QObject *parent)
19
: QAbstractItemDelegate(parent)
20
, m_position(position)
21
{
22
}
23
24
KoMarkerItemDelegate::~KoMarkerItemDelegate
()
25
{
26
}
27
28
void
KoMarkerItemDelegate::paint
(QPainter *painter,
const
QStyleOptionViewItem &option,
const
QModelIndex &index)
const
29
{
30
if
(option.state & QStyle::State_Selected) {
31
painter->fillRect(option.rect, option.palette.highlight());
32
}
33
34
QPen pen(option.palette.text(), 2);
35
KoMarker
*marker = index.data(Qt::DecorationRole).value<
KoMarker
*>();
36
drawMarkerPreview
(painter, option.rect.adjusted(1, 0, -1, 0), pen, marker,
m_position
);
37
}
38
39
QSize
KoMarkerItemDelegate::sizeHint
(
const
QStyleOptionViewItem & option,
const
QModelIndex &index)
const
40
{
41
Q_UNUSED(option);
42
Q_UNUSED(index);
43
return
QSize(80,30);
44
}
45
46
void
KoMarkerItemDelegate::drawMarkerPreview
(QPainter *painter,
const
QRect &
rect
,
const
QPen &pen,
KoMarker
*marker,
KoFlake::MarkerPosition
position)
47
{
48
if
(marker) {
49
marker->
drawPreview
(painter,
rect
, pen, position);
50
}
else
{
51
const
qreal centerY = QRectF(
rect
).center().y();
52
QPen oldPen = painter->pen();
53
painter->setPen(pen);
54
painter->drawLine(
rect
.left(), centerY,
rect
.right(), centerY);
55
painter->setPen(oldPen);
56
}
57
}
KoMarkerItemDelegate.h
KoMarker.h
KoPathShape.h
KoMarkerItemDelegate::drawMarkerPreview
static void drawMarkerPreview(QPainter *painter, const QRect &rect, const QPen &pen, KoMarker *marker, KoFlake::MarkerPosition position)
Definition
KoMarkerItemDelegate.cpp:46
KoMarkerItemDelegate::paint
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition
KoMarkerItemDelegate.cpp:28
KoMarkerItemDelegate::sizeHint
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition
KoMarkerItemDelegate.cpp:39
KoMarkerItemDelegate::~KoMarkerItemDelegate
~KoMarkerItemDelegate() override
Definition
KoMarkerItemDelegate.cpp:24
KoMarkerItemDelegate::m_position
KoFlake::MarkerPosition m_position
Definition
KoMarkerItemDelegate.h:28
KoMarkerItemDelegate::KoMarkerItemDelegate
KoMarkerItemDelegate(KoFlake::MarkerPosition position, QObject *parent=0)
Definition
KoMarkerItemDelegate.cpp:18
KoMarker
Definition
KoMarker.cpp:29
KoMarker::drawPreview
void drawPreview(QPainter *painter, const QRectF &previewRect, const QPen &pen, KoFlake::MarkerPosition position)
Definition
KoMarker.cpp:285
kis_global.h
KoFlake::MarkerPosition
MarkerPosition
Definition
KoFlake.h:41
rect
Definition
xcftools.h:129
libs
widgets
KoMarkerItemDelegate.cpp
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52