| 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 DATASOURCE_H |
| 9 | #define DATASOURCE_H |
| 10 | |
| 11 | #include <QObject> |
| 12 | #include <qqmlregistration.h> |
| 13 | |
| 14 | #include "quickcharts_export.h" |
| 15 | |
| 16 | /*! |
| 17 | * \qmltype ChartDataSource |
| 18 | * \inqmlmodule org.kde.quickcharts |
| 19 | * |
| 20 | * \brief Abstract base class for data sources. |
| 21 | * |
| 22 | * This is a common base class for all data sources. It cannot be created from |
| 23 | * QML. |
| 24 | */ |
| 25 | class QUICKCHARTS_EXPORT ChartDataSource : public QObject |
| 26 | { |
| 27 | Q_OBJECT |
| 28 | QML_NAMED_ELEMENT(DataSource) |
| 29 | QML_UNCREATABLE("Abstract Base Class" ) |
| 30 | |
| 31 | public: |
| 32 | explicit ChartDataSource(QObject *parent = nullptr); |
| 33 | virtual ~ChartDataSource() = default; |
| 34 | |
| 35 | virtual int itemCount() const = 0; |
| 36 | virtual QVariant item(int index) const = 0; |
| 37 | virtual QVariant minimum() const = 0; |
| 38 | virtual QVariant maximum() const = 0; |
| 39 | |
| 40 | virtual QVariant first() const; |
| 41 | |
| 42 | Q_SIGNAL void dataChanged(); |
| 43 | |
| 44 | protected: |
| 45 | static bool variantCompare(const QVariant &lhs, const QVariant &rhs); |
| 46 | }; |
| 47 | |
| 48 | #endif // DATASOURCE_H |
| 49 | |