File indexing completed on 2025-03-23 06:49:37
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 CHARTAXISSOURCE_H 0009 #define CHARTAXISSOURCE_H 0010 0011 #include "ChartDataSource.h" 0012 0013 class XYChart; 0014 0015 /** 0016 * A data source that provides values from a chart's axis as data. 0017 */ 0018 class QUICKCHARTS_EXPORT ChartAxisSource : public ChartDataSource 0019 { 0020 Q_OBJECT 0021 QML_ELEMENT 0022 0023 public: 0024 enum class Axis { XAxis, YAxis }; 0025 Q_ENUM(Axis) 0026 0027 /** 0028 * Constructor 0029 * 0030 * @param parent TODO 0031 */ 0032 ChartAxisSource(QObject *parent = nullptr); 0033 0034 Q_PROPERTY(XYChart *chart READ chart WRITE setChart NOTIFY chartChanged) 0035 XYChart *chart() const; 0036 Q_SLOT void setChart(XYChart *newChart); 0037 Q_SIGNAL void chartChanged(); 0038 0039 Q_PROPERTY(ChartAxisSource::Axis axis READ axis WRITE setAxis NOTIFY axisChanged) 0040 ChartAxisSource::Axis axis() const; 0041 Q_SLOT void setAxis(ChartAxisSource::Axis newAxis); 0042 Q_SIGNAL void axisChanged(); 0043 0044 Q_PROPERTY(int itemCount READ itemCount WRITE setItemCount NOTIFY itemCountChanged) 0045 virtual int itemCount() const override; 0046 Q_SLOT void setItemCount(int newItemCount); 0047 Q_SIGNAL void itemCountChanged(); 0048 0049 virtual QVariant item(int index) const override; 0050 QVariant minimum() const override; 0051 QVariant maximum() const override; 0052 0053 private: 0054 XYChart *m_chart = nullptr; 0055 Axis m_axis = Axis::XAxis; 0056 int m_itemCount = 2; 0057 }; 0058 0059 #endif // CHARTAXISSOURCE_H