| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QTGRAPHS_QXYSERIES_H |
| 5 | #define QTGRAPHS_QXYSERIES_H |
| 6 | |
| 7 | #include <QtGraphs/qabstractseries.h> |
| 8 | #include <QtGraphs/qgraphsglobal.h> |
| 9 | |
| 10 | QT_BEGIN_NAMESPACE |
| 11 | class QModelIndex; |
| 12 | class QXYSeriesPrivate; |
| 13 | class QXYModelMapper; |
| 14 | |
| 15 | class Q_GRAPHS_EXPORT QXYSeries : public QAbstractSeries |
| 16 | { |
| 17 | Q_OBJECT |
| 18 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL) |
| 19 | Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor NOTIFY |
| 20 | selectedColorChanged FINAL) |
| 21 | Q_PROPERTY(QQmlComponent *pointDelegate READ pointDelegate WRITE setPointDelegate NOTIFY pointDelegateChanged FINAL) |
| 22 | Q_PROPERTY(bool draggable READ isDraggable WRITE setDraggable NOTIFY draggableChanged FINAL) |
| 23 | Q_PROPERTY(QList<qsizetype> selectedPoints READ selectedPoints NOTIFY selectedPointsChanged FINAL) |
| 24 | Q_PROPERTY(qsizetype count READ count NOTIFY countChanged FINAL) |
| 25 | |
| 26 | protected: |
| 27 | explicit QXYSeries(QXYSeriesPrivate &dd, QObject *parent = nullptr); |
| 28 | |
| 29 | public: |
| 30 | Q_INVOKABLE void append(qreal x, qreal y); |
| 31 | Q_INVOKABLE void append(QPointF point); |
| 32 | Q_INVOKABLE void append(const QList<QPointF> &points); |
| 33 | Q_INVOKABLE void replace(qreal oldX, qreal oldY, qreal newX, qreal newY); |
| 34 | Q_INVOKABLE void replace(QPointF oldPoint, QPointF newPoint); |
| 35 | Q_INVOKABLE void replace(qsizetype index, qreal newX, qreal newY); |
| 36 | Q_INVOKABLE void replace(qsizetype index, QPointF newPoint); |
| 37 | Q_INVOKABLE void replace(const QList<QPointF> &points); |
| 38 | Q_INVOKABLE void remove(qreal x, qreal y); |
| 39 | Q_INVOKABLE void remove(QPointF point); |
| 40 | Q_INVOKABLE void remove(qsizetype index); |
| 41 | Q_INVOKABLE void insert(qsizetype index, QPointF point); |
| 42 | Q_INVOKABLE void clear(); |
| 43 | Q_INVOKABLE QPointF at(qsizetype index) const; |
| 44 | Q_INVOKABLE qsizetype find(QPointF point) const; |
| 45 | Q_INVOKABLE void removeMultiple(qsizetype index, qsizetype count); |
| 46 | Q_INVOKABLE bool take(QPointF point); |
| 47 | |
| 48 | ~QXYSeries() override; |
| 49 | |
| 50 | QList<QPointF> points() const; |
| 51 | |
| 52 | QXYSeries &operator<<(QPointF point); |
| 53 | QXYSeries &operator<<(const QList<QPointF> &points); |
| 54 | |
| 55 | void setColor(QColor newColor); |
| 56 | QColor color() const; |
| 57 | |
| 58 | void setSelectedColor(QColor color); |
| 59 | QColor selectedColor() const; |
| 60 | |
| 61 | qsizetype count() const; |
| 62 | |
| 63 | Q_INVOKABLE bool isPointSelected(qsizetype index) const; |
| 64 | Q_INVOKABLE void selectPoint(qsizetype index); |
| 65 | Q_INVOKABLE void deselectPoint(qsizetype index); |
| 66 | Q_INVOKABLE void setPointSelected(qsizetype index, bool selected); |
| 67 | Q_INVOKABLE void selectAllPoints(); |
| 68 | Q_INVOKABLE void deselectAllPoints(); |
| 69 | Q_INVOKABLE void selectPoints(const QList<qsizetype> &indexes); |
| 70 | Q_INVOKABLE void deselectPoints(const QList<qsizetype> &indexes); |
| 71 | Q_INVOKABLE void toggleSelection(const QList<qsizetype> &indexes); |
| 72 | QList<qsizetype> selectedPoints() const; |
| 73 | |
| 74 | QQmlComponent *pointDelegate() const; |
| 75 | void setPointDelegate(QQmlComponent *newPointDelegate); |
| 76 | |
| 77 | QML_ELEMENT |
| 78 | QML_UNCREATABLE("XYSeries is an abstract base class." ) |
| 79 | |
| 80 | bool isDraggable() const; |
| 81 | void setDraggable(bool newDraggable); |
| 82 | |
| 83 | Q_SIGNALS: |
| 84 | void pointReplaced(qsizetype index); |
| 85 | void pointRemoved(qsizetype index); |
| 86 | void pointAdded(qsizetype index); |
| 87 | Q_REVISION(6, 9) void pointsAdded(qsizetype start, qsizetype end); |
| 88 | void colorChanged(QColor color); |
| 89 | void selectedColorChanged(QColor color); |
| 90 | void pointsReplaced(); |
| 91 | void pointsRemoved(qsizetype index, qsizetype count); |
| 92 | void selectedPointsChanged(); |
| 93 | void pointDelegateChanged(); |
| 94 | void draggableChanged(); |
| 95 | void seriesUpdated(); |
| 96 | void countChanged(); |
| 97 | |
| 98 | Q_REVISION(6, 9) void clicked(QPoint point); |
| 99 | Q_REVISION(6, 9) void doubleClicked(QPoint point); |
| 100 | Q_REVISION(6, 9) void pressed(QPoint point); |
| 101 | Q_REVISION(6, 9) void released(QPoint point); |
| 102 | |
| 103 | private: |
| 104 | friend class PointRenderer; |
| 105 | friend class QGraphPointAnimation; |
| 106 | friend class QGraphTransition; |
| 107 | Q_DECLARE_PRIVATE(QXYSeries) |
| 108 | Q_DISABLE_COPY(QXYSeries) |
| 109 | }; |
| 110 | |
| 111 | QT_END_NAMESPACE |
| 112 | |
| 113 | #endif // QTGRAPHS_QXYSERIES_H |
| 114 | |