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 ARRAYSOURCE_H |
9 | #define ARRAYSOURCE_H |
10 | |
11 | #include <QVariantList> |
12 | |
13 | #include "ChartDataSource.h" |
14 | |
15 | /** |
16 | * A data source that provides entries of an array as data. |
17 | */ |
18 | class QUICKCHARTS_EXPORT ArraySource : public ChartDataSource |
19 | { |
20 | Q_OBJECT |
21 | QML_ELEMENT |
22 | |
23 | public: |
24 | /** |
25 | * Constructor |
26 | * |
27 | * @param parent TODO |
28 | */ |
29 | explicit ArraySource(QObject *parent = nullptr); |
30 | |
31 | virtual int itemCount() const override; |
32 | virtual QVariant item(int index) const override; |
33 | QVariant minimum() const override; |
34 | QVariant maximum() const override; |
35 | |
36 | Q_PROPERTY(QVariantList array READ array WRITE setArray NOTIFY dataChanged) |
37 | QVariantList array() const; |
38 | void setArray(const QVariantList &array); |
39 | |
40 | Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY dataChanged) |
41 | bool wrap() const; |
42 | void setWrap(bool wrap); |
43 | |
44 | private: |
45 | QVariantList m_array; |
46 | bool m_wrap = false; |
47 | }; |
48 | |
49 | #endif // ARRAYSOURCE_H |
50 | |