12 : QAbstractListModel(parent),
16 for (
int i = Qt::NoPen; i < Qt::CustomDashLine; i++) {
17 QPen pen(
static_cast<Qt::PenStyle
>(i));
33 case Qt::DecorationRole: {
36 if (index.row() < Qt::CustomDashLine)
37 pen.setStyle(
static_cast<Qt::PenStyle
>(index.row()));
38 else if (index.row() <
m_styles.count())
39 pen.setDashPattern(
m_styles[index.row()]);
43 pen.setStyle(Qt::NoPen);
47 case Qt::SizeHintRole:
48 return QSize(100, 15);
66 if (style < Qt::CustomDashLine) {
73 }
else if (style == Qt::CustomDashLine) {
75 int index =
m_styles.indexOf(dashes, Qt::CustomDashLine);
KoLineStyleModel(QObject *parent=0)
bool addCustomStyle(const QVector< qreal > &style)
adds the given style to the model
int setLineStyle(Qt::PenStyle style, const QVector< qreal > &dashes)
selects the given style
QList< QVector< qreal > > m_styles
the added styles
QVector< qreal > m_tempStyle
a temporary added style
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
bool m_hasTempStyle
state of the temporary style
int rowCount(const QModelIndex &parent=QModelIndex()) const override