| 1 | // Copyright (C) 2024 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | // |
| 5 | // W A R N I N G |
| 6 | // ------------- |
| 7 | // |
| 8 | // This file is not part of the QtGraphs API. It exists purely as an |
| 9 | // implementation detail. This header file may change from version to |
| 10 | // version without notice, or even be removed. |
| 11 | // |
| 12 | // We mean it. |
| 13 | |
| 14 | #ifndef QQUICKGRAPHSBARSSERIES_P_H |
| 15 | #define QQUICKGRAPHSBARSSERIES_P_H |
| 16 | |
| 17 | #include "common/theme/qquickgraphscolor_p.h" |
| 18 | #include "gradientholder_p.h" |
| 19 | #include "qbar3dseries.h" |
| 20 | |
| 21 | #include <QtQml/qqml.h> |
| 22 | #include <QtQuick/private/qquickrectangle_p.h> |
| 23 | #include <private/qgraphsglobal_p.h> |
| 24 | #include <private/qgraphstheme_p.h> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class QQuickGraphsBar3DSeries : public QBar3DSeries |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren CONSTANT) |
| 32 | // This property is overloaded to use QPointF instead of QPoint to work around |
| 33 | // qml bug where Qt.point(0, 0) can't be assigned due to error "Cannot assign |
| 34 | // QPointF to QPoint". |
| 35 | Q_PROPERTY( |
| 36 | QPointF selectedBar READ selectedBar WRITE setSelectedBar NOTIFY selectedBarChanged FINAL) |
| 37 | // This is static method in parent class, overload as constant property for qml. |
| 38 | Q_PROPERTY(QPointF invalidSelectionPosition READ invalidSelectionPosition CONSTANT) |
| 39 | Q_PROPERTY(QQuickGradient *baseGradient READ baseGradient WRITE setBaseGradient NOTIFY |
| 40 | baseGradientChanged FINAL) |
| 41 | Q_PROPERTY(QQuickGradient *singleHighlightGradient READ singleHighlightGradient WRITE |
| 42 | setSingleHighlightGradient NOTIFY singleHighlightGradientChanged FINAL) |
| 43 | Q_PROPERTY(QQuickGradient *multiHighlightGradient READ multiHighlightGradient WRITE |
| 44 | setMultiHighlightGradient NOTIFY multiHighlightGradientChanged FINAL) |
| 45 | Q_PROPERTY(QQmlListProperty<QQuickGraphsColor> rowColors READ rowColors CONSTANT) |
| 46 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
| 47 | |
| 48 | QML_NAMED_ELEMENT(Bar3DSeries) |
| 49 | |
| 50 | public: |
| 51 | explicit QQuickGraphsBar3DSeries(QObject *parent = 0); |
| 52 | ~QQuickGraphsBar3DSeries() override; |
| 53 | |
| 54 | QQmlListProperty<QObject> seriesChildren(); |
| 55 | static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); |
| 56 | |
| 57 | void setSelectedBar(QPointF position); |
| 58 | QPointF selectedBar() const; |
| 59 | QPointF invalidSelectionPosition() const; |
| 60 | |
| 61 | void setBaseGradient(QQuickGradient *gradient); |
| 62 | QQuickGradient *baseGradient() const; |
| 63 | void setSingleHighlightGradient(QQuickGradient *gradient); |
| 64 | QQuickGradient *singleHighlightGradient() const; |
| 65 | void setMultiHighlightGradient(QQuickGradient *gradient); |
| 66 | QQuickGradient *multiHighlightGradient() const; |
| 67 | |
| 68 | QQmlListProperty<QQuickGraphsColor> rowColors(); |
| 69 | static void appendRowColorsFunc(QQmlListProperty<QQuickGraphsColor> *list, |
| 70 | QQuickGraphsColor *color); |
| 71 | static qsizetype countRowColorsFunc(QQmlListProperty<QQuickGraphsColor> *list); |
| 72 | static QQuickGraphsColor *atRowColorsFunc(QQmlListProperty<QQuickGraphsColor> *list, |
| 73 | qsizetype index); |
| 74 | static void clearRowColorsFunc(QQmlListProperty<QQuickGraphsColor> *list); |
| 75 | |
| 76 | public Q_SLOTS: |
| 77 | void handleBaseGradientUpdate(); |
| 78 | void handleSingleHighlightGradientUpdate(); |
| 79 | void handleMultiHighlightGradientUpdate(); |
| 80 | void handleRowColorUpdate(); |
| 81 | |
| 82 | Q_SIGNALS: |
| 83 | void selectedBarChanged(QPointF position); |
| 84 | void baseGradientChanged(QQuickGradient *gradient); |
| 85 | void singleHighlightGradientChanged(QQuickGradient *gradient); |
| 86 | void multiHighlightGradientChanged(QQuickGradient *gradient); |
| 87 | |
| 88 | private: |
| 89 | GradientHolder m_gradients; |
| 90 | |
| 91 | QList<QQuickGraphsColor *> m_rowColors; |
| 92 | bool m_dummyColors = false; |
| 93 | |
| 94 | void addColor(QQuickGraphsColor *color); |
| 95 | QList<QQuickGraphsColor *> colorList(); |
| 96 | void clearColors(); |
| 97 | void clearDummyColors(); |
| 98 | |
| 99 | void setGradientHelper(QQuickGradient *newGradient, |
| 100 | QQuickGradient *memberGradient, |
| 101 | GradientType type); |
| 102 | }; |
| 103 | |
| 104 | QT_END_NAMESPACE |
| 105 | |
| 106 | #endif |
| 107 |
