File indexing completed on 2024-04-21 15:02:53

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 SINGLEVALUESOURCE_H
0009 #define SINGLEVALUESOURCE_H
0010 
0011 #include <QVariant>
0012 
0013 #include "ChartDataSource.h"
0014 
0015 /**
0016  * A data source that provides a single value as data.
0017  */
0018 class SingleValueSource : public ChartDataSource
0019 {
0020     Q_OBJECT
0021     Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY dataChanged)
0022 
0023 public:
0024     explicit SingleValueSource(QObject *parent = nullptr);
0025 
0026     virtual int itemCount() const override;
0027     virtual QVariant item(int index) const override;
0028     QVariant minimum() const override;
0029     QVariant maximum() const override;
0030 
0031     QVariant value() const;
0032     void setValue(const QVariant &value);
0033 
0034 private:
0035     QVariant m_value;
0036 };
0037 
0038 #endif // SINGLEVALUESOURCE_H