1 | /* |
2 | * This file is part of KQuickCharts |
3 | * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl> |
4 | * |
5 | * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
6 | */ |
7 | |
8 | #ifndef CHARTAXISSOURCE_H |
9 | #define CHARTAXISSOURCE_H |
10 | |
11 | #include "ChartDataSource.h" |
12 | |
13 | class XYChart; |
14 | |
15 | /*! |
16 | * \qmltype ChartAxisSource |
17 | * \inherits ChartDataSource |
18 | * \inqmlmodule org.kde.quickcharts |
19 | * |
20 | * \brief A data source that provides values from a chart's axis as data. |
21 | */ |
22 | class QUICKCHARTS_EXPORT ChartAxisSource : public ChartDataSource |
23 | { |
24 | Q_OBJECT |
25 | QML_ELEMENT |
26 | |
27 | public: |
28 | enum class Axis { XAxis, YAxis }; |
29 | Q_ENUM(Axis) |
30 | |
31 | ChartAxisSource(QObject *parent = nullptr); |
32 | |
33 | /*! |
34 | * \qmlproperty XYChart ChartAxisSource::chart |
35 | */ |
36 | Q_PROPERTY(XYChart *chart READ chart WRITE setChart NOTIFY chartChanged) |
37 | XYChart *chart() const; |
38 | Q_SLOT void setChart(XYChart *newChart); |
39 | Q_SIGNAL void chartChanged(); |
40 | /*! |
41 | * \qmlproperty enumeration ChartAxisSource::axis |
42 | */ |
43 | Q_PROPERTY(ChartAxisSource::Axis axis READ axis WRITE setAxis NOTIFY axisChanged) |
44 | ChartAxisSource::Axis axis() const; |
45 | Q_SLOT void setAxis(ChartAxisSource::Axis newAxis); |
46 | Q_SIGNAL void axisChanged(); |
47 | /*! |
48 | * \qmlproperty int ChartAxisSource::itemCount |
49 | */ |
50 | Q_PROPERTY(int itemCount READ itemCount WRITE setItemCount NOTIFY itemCountChanged) |
51 | int itemCount() const override; |
52 | Q_SLOT void setItemCount(int newItemCount); |
53 | Q_SIGNAL void itemCountChanged(); |
54 | |
55 | QVariant item(int index) const override; |
56 | QVariant minimum() const override; |
57 | QVariant maximum() const override; |
58 | |
59 | private: |
60 | XYChart *m_chart = nullptr; |
61 | Axis m_axis = Axis::XAxis; |
62 | int m_itemCount = 2; |
63 | }; |
64 | |
65 | #endif // CHARTAXISSOURCE_H |
66 | |