File indexing completed on 2024-11-10 03:40:16

0001 /*
0002  * This file is part of KQuickCharts
0003  * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006  */
0007 
0008 #ifndef DATASOURCE_H
0009 #define DATASOURCE_H
0010 
0011 #include <QObject>
0012 #include <qqmlregistration.h>
0013 
0014 #include "quickcharts_export.h"
0015 
0016 /**
0017  * Abstract base class for data sources.
0018  */
0019 class QUICKCHARTS_EXPORT ChartDataSource : public QObject
0020 {
0021     Q_OBJECT
0022     QML_NAMED_ELEMENT(DataSource)
0023     QML_UNCREATABLE("Abstract Base Class")
0024 
0025 public:
0026     explicit ChartDataSource(QObject *parent = nullptr);
0027     virtual ~ChartDataSource() = default;
0028 
0029     virtual int itemCount() const = 0;
0030     virtual QVariant item(int index) const = 0;
0031     virtual QVariant minimum() const = 0;
0032     virtual QVariant maximum() const = 0;
0033 
0034     virtual QVariant first() const;
0035 
0036     Q_SIGNAL void dataChanged();
0037 
0038 protected:
0039     static bool variantCompare(const QVariant &lhs, const QVariant &rhs);
0040 };
0041 
0042 #endif // DATASOURCE_H