Warning, file /frameworks/kquickcharts/src/datasource/ColorGradientSource.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 <QVector> 0015 0016 #include "ChartDataSource.h" 0017 0018 /** 0019 * A data source that provides a hue-shifted color as data. 0020 */ 0021 class ColorGradientSource : public ChartDataSource 0022 { 0023 Q_OBJECT 0024 Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor NOTIFY baseColorChanged) 0025 Q_PROPERTY(int itemCount READ itemCount WRITE setItemCount NOTIFY itemCountChanged) 0026 Q_PROPERTY(QVariantList colors READ colors NOTIFY dataChanged) 0027 0028 public: 0029 explicit ColorGradientSource(QObject *parent = nullptr); 0030 0031 int itemCount() const override; 0032 QVariant item(int index) const override; 0033 QVariant minimum() const override; 0034 QVariant maximum() const override; 0035 0036 QColor baseColor() const; 0037 void setBaseColor(const QColor &newBaseColor); 0038 Q_SIGNAL void baseColorChanged(); 0039 0040 void setItemCount(int newItemCount); 0041 Q_SIGNAL void itemCountChanged(); 0042 0043 QVariantList colors() const; 0044 0045 private: 0046 void regenerateColors(); 0047 0048 QColor m_baseColor = Qt::blue; 0049 int m_itemCount = 0; 0050 QVector<QColor> m_colors; 0051 }; 0052 0053 #endif // COLORGRADIENTSOURCE_H