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