#include <KoLineStyleSelector.h>
A custom combobox widget for selecting line styles.
Definition at line 14 of file KoLineStyleSelector.cpp.
◆ KoLineStyleSelector()
| KoLineStyleSelector::KoLineStyleSelector |
( |
QWidget * | parent = 0 | ) |
|
|
explicit |
Definition at line 25 of file KoLineStyleSelector.cpp.
26 : QComboBox(parent),
d(
new Private(
this))
27{
30}
The line style item delegate for rendering the styles.
References d.
◆ ~KoLineStyleSelector()
| KoLineStyleSelector::~KoLineStyleSelector |
( |
| ) |
|
|
override |
◆ addCustomStyle()
| bool KoLineStyleSelector::addCustomStyle |
( |
const QVector< qreal > & | style | ) |
|
Adds a new line style to the combobox.
If the style already exists, it is not added to the selector.
- Parameters
-
| style | the line style to add |
- Returns
- true if style is unique among the existing styles and was added, else false
Definition at line 58 of file KoLineStyleSelector.cpp.
59{
60 return d->model->addCustomStyle(style);
61}
References d.
◆ lineDashes()
| QVector< qreal > KoLineStyleSelector::lineDashes |
( |
| ) |
const |
Returns the dashes of the current line style.
Definition at line 76 of file KoLineStyleSelector.cpp.
77{
78 QPen pen = itemData(currentIndex(), Qt::DecorationRole).value<QPen>();
79 return pen.dashPattern();
80}
◆ lineStyle()
| Qt::PenStyle KoLineStyleSelector::lineStyle |
( |
| ) |
const |
Returns the current line style.
Definition at line 70 of file KoLineStyleSelector.cpp.
71{
72 QPen pen = itemData(currentIndex(), Qt::DecorationRole).value<QPen>();
73 return pen.style();
74}
◆ paintEvent()
| void KoLineStyleSelector::paintEvent |
( |
QPaintEvent * | pe | ) |
|
|
overrideprotected |
Definition at line 37 of file KoLineStyleSelector.cpp.
38{
39 QComboBox::paintEvent(pe);
40
41 QStyleOptionComboBox option;
42 option.initFrom(this);
43 option.frame = hasFrame();
44 QRect
r = style()->subControlRect(QStyle::CC_ComboBox, &option, QStyle::SC_ComboBoxEditField,
this);
45 if (!option.frame)
46 r.adjust(-14, 0, 14, 1);
47
48 QPen pen = itemData(currentIndex(), Qt::DecorationRole).value<QPen>();
49
50 QPainter painter(this);
51 painter.setPen(pen);
52 if (!(option.state & QStyle::State_Enabled)) {
53 painter.setOpacity(0.5);
54 }
55 painter.drawLine(
r.left(),
r.center().y(),
r.right(),
r.center().y());
56}
◆ Private()
| KoLineStyleSelector::Private |
( |
QWidget * | parent | ) |
|
|
inline |
◆ setLineStyle()
| void KoLineStyleSelector::setLineStyle |
( |
Qt::PenStyle | style, |
|
|
const QVector< qreal > & | dashes = QVector<qreal>() ) |
Selects the specified style.
If the style was already added it gets selected. If the style was not added already it gets temporary added and selected.
- Parameters
-
| style | the style to display |
| dashes | the dashes of the style if style == Qt::CustomDashLine |
Definition at line 63 of file KoLineStyleSelector.cpp.
64{
65 int index =
d->model->setLineStyle(style, dashes);
66 if (index >= 0)
67 setCurrentIndex(index);
68}
References d.
| Private* const KoLineStyleSelector::d |
|
private |
◆ model
The documentation for this class was generated from the following files: