File indexing completed on 2025-03-23 03:42:18
0001 /* 0002 * This file is part of KQuickCharts 0003 * SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org> 0004 * SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org> 0005 * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl> 0006 * 0007 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0008 */ 0009 0010 #ifndef COLORGRADIENTSOURCE_H 0011 #define COLORGRADIENTSOURCE_H 0012 0013 #include <QColor> 0014 #include <QList> 0015 0016 #include "ChartDataSource.h" 0017 0018 /** 0019 * A data source that provides a hue-shifted color as data. 0020 */ 0021 class QUICKCHARTS_EXPORT ColorGradientSource : public ChartDataSource 0022 { 0023 Q_OBJECT 0024 QML_ELEMENT 0025 0026 public: 0027 explicit ColorGradientSource(QObject *parent = nullptr); 0028 0029 Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor NOTIFY baseColorChanged) 0030 QColor baseColor() const; 0031 void setBaseColor(const QColor &newBaseColor); 0032 Q_SIGNAL void baseColorChanged(); 0033 0034 Q_PROPERTY(int itemCount READ itemCount WRITE setItemCount NOTIFY itemCountChanged) 0035 void setItemCount(int newItemCount); 0036 Q_SIGNAL void itemCountChanged(); 0037 0038 Q_PROPERTY(QVariantList colors READ colors NOTIFY dataChanged) 0039 QVariantList colors() const; 0040 0041 int itemCount() const override; 0042 QVariant item(int index) const override; 0043 QVariant minimum() const override; 0044 QVariant maximum() const override; 0045 0046 private: 0047 void regenerateColors(); 0048 0049 QColor m_baseColor = Qt::blue; 0050 int m_itemCount = 0; 0051 QList<QColor> m_colors; 0052 }; 0053 0054 #endif // COLORGRADIENTSOURCE_H