1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Charts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30// W A R N I N G
31// -------------
32//
33// This file is not part of the Qt Chart API. It exists purely as an
34// implementation detail. This header file may change from version to
35// version without notice, or even be removed.
36//
37// We mean it.
38
39#ifndef QABSTRACTBARSERIES_P_H
40#define QABSTRACTBARSERIES_P_H
41
42#include <QtCharts/QAbstractBarSeries>
43#include <private/qabstractseries_p.h>
44#include <QtCore/QStringList>
45#include <QtCharts/QAbstractSeries>
46#include <QtCharts/private/qchartglobal_p.h>
47
48QT_CHARTS_BEGIN_NAMESPACE
49
50class QBarModelMapper;
51class QBarCategoryAxis;
52class QLegendMarker;
53
54class Q_CHARTS_PRIVATE_EXPORT QAbstractBarSeriesPrivate : public QAbstractSeriesPrivate
55{
56 Q_OBJECT
57public:
58 QAbstractBarSeriesPrivate(QAbstractBarSeries *parent);
59 int categoryCount() const;
60
61 void setBarWidth(qreal width);
62 qreal barWidth() const;
63
64 void setVisible(bool visible);
65 void setLabelsVisible(bool visible);
66
67 void initializeDomain();
68 void initializeAxes();
69 void initializeAnimations(QChart::AnimationOptions options, int duration, QEasingCurve &curve);
70 void initializeTheme(int index, ChartTheme* theme, bool forced = false);
71
72 QList<QLegendMarker*> createLegendMarkers(QLegend *legend);
73
74 virtual QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
75 QAbstractAxis* createDefaultAxis(Qt::Orientation orientation) const;
76
77 bool append(QBarSet *set);
78 bool remove(QBarSet *set);
79 bool append(QList<QBarSet *> sets);
80 bool remove(QList<QBarSet *> sets);
81 bool insert(int index, QBarSet *set);
82
83 QBarSet *barsetAt(int index);
84 qreal min();
85 qreal max();
86 qreal valueAt(int set, int category);
87 qreal percentageAt(int set, int category);
88 qreal categorySum(int category);
89 qreal absoluteCategorySum(int category);
90 qreal maxCategorySum();
91 qreal minX();
92 qreal maxX();
93 qreal categoryTop(int category);
94 qreal categoryBottom(int category);
95 qreal top();
96 qreal bottom();
97
98 bool blockBarUpdate();
99
100 qreal labelsAngle() const;
101 void setVisualsDirty(bool dirty) { m_visualsDirty = dirty; }
102 bool visualsDirty() const { return m_visualsDirty; }
103 void setLabelsDirty(bool dirty) { m_labelsDirty = dirty; }
104 bool labelsDirty() const { return m_labelsDirty; }
105
106Q_SIGNALS:
107 void clicked(int index, QBarSet *barset);
108 void pressed(int index, QBarSet *barset);
109 void released(int index, QBarSet *barset);
110 void doubleClicked(int index, QBarSet *barset);
111 void updatedBars();
112 void updatedLayout();
113 void restructuredBars();
114 void labelsVisibleChanged(bool visible);
115 void visibleChanged();
116 void setValueChanged(int index, QBarSet *barset);
117 void setValueAdded(int index, int count, QBarSet *barset);
118 void setValueRemoved(int index, int count, QBarSet *barset);
119
120private Q_SLOTS:
121 void handleSetValueChange(int index);
122 void handleSetValueAdd(int index, int count);
123 void handleSetValueRemove(int index, int count);
124
125private:
126 void populateCategories(QBarCategoryAxis *axis);
127
128protected:
129 QList<QBarSet *> m_barSets;
130 qreal m_barWidth;
131 bool m_labelsVisible;
132 bool m_visible;
133 bool m_blockBarUpdate;
134 QString m_labelsFormat;
135 QAbstractBarSeries::LabelsPosition m_labelsPosition;
136 qreal m_labelsAngle;
137 int m_labelsPrecision;
138 bool m_visualsDirty;
139 bool m_labelsDirty;
140
141private:
142 Q_DECLARE_PUBLIC(QAbstractBarSeries)
143 friend class HorizontalBarChartItem;
144 friend class BarChartItem;
145};
146
147QT_CHARTS_END_NAMESPACE
148
149#endif // QABSTRACTBARSERIES_P_H
150

source code of qtcharts/src/charts/barchart/qabstractbarseries_p.h