1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4// W A R N I N G
5// -------------
6//
7// This file is not part of the Qt Chart API. It exists purely as an
8// implementation detail. This header file may change from version to
9// version without notice, or even be removed.
10//
11// We mean it.
12
13#ifndef CANDLESTICKCHARTITEM_P_H
14#define CANDLESTICKCHARTITEM_P_H
15
16#include <private/chartitem_p.h>
17#include <QtCharts/private/qchartglobal_p.h>
18
19QT_BEGIN_NAMESPACE
20
21class Candlestick;
22class CandlestickAnimation;
23class QCandlestickSeries;
24class QCandlestickSet;
25
26class Q_CHARTS_PRIVATE_EXPORT CandlestickChartItem : public ChartItem
27{
28 Q_OBJECT
29
30public:
31 CandlestickChartItem(QCandlestickSeries *series, QGraphicsItem *item = nullptr);
32 ~CandlestickChartItem();
33
34 void setAnimation(CandlestickAnimation *animation);
35
36 QRectF boundingRect() const override;
37 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
38
39public Q_SLOTS:
40 void handleDomainUpdated() override;
41 void handleLayoutUpdated();
42 void handleCandlesticksUpdated();
43 void handleCandlestickSeriesChange();
44
45private Q_SLOTS:
46 void handleCandlestickSetsAdd(const QList<QCandlestickSet *> &sets);
47 void handleCandlestickSetsRemove(const QList<QCandlestickSet *> &sets);
48 void handleDataStructureChanged();
49
50private:
51 bool updateCandlestickGeometry(Candlestick *item, int index);
52 void updateCandlestickAppearance(Candlestick *item, QCandlestickSet *set);
53
54 void addTimestamp(qreal timestamp);
55 void removeTimestamp(qreal timestamp);
56 void updateTimePeriod();
57
58protected:
59 QRectF m_boundingRect;
60 QCandlestickSeries *m_series; // Not owned.
61 int m_seriesIndex;
62 int m_seriesCount;
63 QHash<QCandlestickSet *, Candlestick *> m_candlesticks;
64 QList<qreal> m_timestamps;
65 qreal m_timePeriod;
66 CandlestickAnimation *m_animation;
67};
68
69QT_END_NAMESPACE
70
71#endif // CANDLESTICKCHARTITEM_P_H
72

source code of qtcharts/src/charts/candlestickchart/candlestickchartitem_p.h