File indexing completed on 2025-01-12 04:36:26

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2018 Kevin Ottens <ervin@kde.org>
0003 
0004 #ifndef STROKELISTITEM_H
0005 #define STROKELISTITEM_H
0006 
0007 #include "strokepainter.h"
0008 #include <QImage>
0009 #include <QQuickPaintedItem>
0010 
0011 #include "sketchmodel.h"
0012 #include "stroke.h"
0013 
0014 class StrokeListItem : public QQuickPaintedItem
0015 {
0016     Q_OBJECT
0017     Q_PROPERTY(Stroke::Type type READ type WRITE setType NOTIFY typeChanged)
0018     Q_PROPERTY(SketchModel *model READ model WRITE setModel NOTIFY modelChanged)
0019 public:
0020     explicit StrokeListItem(QQuickItem *parent = nullptr);
0021 
0022     Q_INVOKABLE void addStroke(const Stroke &stroke);
0023     Q_INVOKABLE void eraseArea(const QVector2D &center, float radius);
0024 
0025     void paint(QPainter *painter) override;
0026 
0027     Stroke::Type type() const;
0028     SketchModel *model() const;
0029 
0030 public Q_SLOTS:
0031     void setType(Stroke::Type type);
0032     void setModel(SketchModel *model);
0033 
0034 Q_SIGNALS:
0035     void typeChanged(Stroke::Type type);
0036     void modelChanged(SketchModel *model);
0037 
0038 private:
0039     Stroke::Type m_type = Stroke::Type::Outline;
0040     SketchModel *m_model = nullptr;
0041 
0042     StrokePainter m_strokepainter;
0043 };
0044 
0045 #endif // STROKELISTITEM_H