• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • krita API Reference
  • KDE Home
  • Contact Us
 

KritaWidgets

  • sources
  • kfour-appscomplete
  • krita
  • libs
  • widgets
KoMarkerItemDelegate.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  * SPDX-FileCopyrightText: 2011 Thorsten Zachmann <[email protected]>
3  * SPDX-FileCopyrightText: 2011 Jean-Nicolas Artaud <[email protected]>
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 }
QPainter::setPen
void setPen(const QColor &color)
QRect
QRect::right
int right() const
QVariant::value
T value() const
QSize
QPainter::pen
const QPen & pen() const
QPainter
QPainter::fillRect
void fillRect(const QRectF &rectangle, const QBrush &brush)
QPen
QRect::left
int left() const
KoMarkerItemDelegate::sizeHint
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: KoMarkerItemDelegate.cpp:39
KoMarkerItemDelegate.h
QModelIndex::data
QVariant data(int role) const
QAbstractItemDelegate
QObject
QStyleOptionViewItem
KoMarkerItemDelegate::KoMarkerItemDelegate
KoMarkerItemDelegate(KoFlake::MarkerPosition position, QObject *parent=0)
Definition: KoMarkerItemDelegate.cpp:18
KoMarkerItemDelegate::~KoMarkerItemDelegate
~KoMarkerItemDelegate() override
Definition: KoMarkerItemDelegate.cpp:24
QRectF::center
QPointF center() const
QPointF::y
qreal y() const
QPainter::drawLine
void drawLine(const QLineF &line)
QRectF
KoMarkerItemDelegate::paint
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: KoMarkerItemDelegate.cpp:28
QModelIndex
KoMarkerItemDelegate::drawMarkerPreview
static void drawMarkerPreview(QPainter *painter, const QRect &rect, const QPen &pen, KoMarker *marker, KoFlake::MarkerPosition position)
Definition: KoMarkerItemDelegate.cpp:46
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 11:48:22 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KritaWidgets

Skip menu "KritaWidgets"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

krita API Reference

Skip menu "krita API Reference"
  • libs
  •   KritaBasicFlakes
  •   brush
  •   KritaUndo2
  •   KritaFlake
  •   image
  •   KritaPlugin
  •   Krita
  •   KritaPigment
  •   KritaResources
  •   KritaStore
  •   ui
  •   KritaWidgets
  •   KritaWidgetUtils
  • plugins
  •   Assitants
  •   Extensions
  •   Filters
  •   Generators
  •   Formats
  •           src
  •   PaintOps
  •     libpaintop

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal