@@ -0,0 +1,8 | |||||
|
1 | Qt Charts 2.1.1 | |||
|
2 | ||||
|
3 | Fixed issues | |||
|
4 | ------------ | |||
|
5 | - Fixed crash with empty BarSet values | |||
|
6 | - Fixed model resetting with model mapper | |||
|
7 | - Fixed crash when axis range is infinite | |||
|
8 | - Fixed clearing the chart title |
@@ -1,123 +1,123 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QAREASERIES_H |
|
30 | #ifndef QAREASERIES_H | |
31 | #define QAREASERIES_H |
|
31 | #define QAREASERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/QAbstractSeries> |
|
34 | #include <QtCharts/QAbstractSeries> | |
35 | #include <QtGui/QPen> |
|
35 | #include <QtGui/QPen> | |
36 | #include <QtGui/QBrush> |
|
36 | #include <QtGui/QBrush> | |
37 |
|
37 | |||
38 | QT_CHARTS_BEGIN_NAMESPACE |
|
38 | QT_CHARTS_BEGIN_NAMESPACE | |
39 | class QLineSeries; |
|
39 | class QLineSeries; | |
40 | class QAreaSeriesPrivate; |
|
40 | class QAreaSeriesPrivate; | |
41 |
|
41 | |||
42 | class QT_CHARTS_EXPORT QAreaSeries : public QAbstractSeries |
|
42 | class QT_CHARTS_EXPORT QAreaSeries : public QAbstractSeries | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 | Q_PROPERTY(QLineSeries *upperSeries READ upperSeries) |
|
45 | Q_PROPERTY(QLineSeries *upperSeries READ upperSeries) | |
46 | Q_PROPERTY(QLineSeries *lowerSeries READ lowerSeries) |
|
46 | Q_PROPERTY(QLineSeries *lowerSeries READ lowerSeries) | |
47 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
47 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
48 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
48 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
49 | Q_PROPERTY(QString pointLabelsFormat READ pointLabelsFormat WRITE setPointLabelsFormat NOTIFY pointLabelsFormatChanged) |
|
49 | Q_PROPERTY(QString pointLabelsFormat READ pointLabelsFormat WRITE setPointLabelsFormat NOTIFY pointLabelsFormatChanged) | |
50 | Q_PROPERTY(bool pointLabelsVisible READ pointLabelsVisible WRITE setPointLabelsVisible NOTIFY pointLabelsVisibilityChanged) |
|
50 | Q_PROPERTY(bool pointLabelsVisible READ pointLabelsVisible WRITE setPointLabelsVisible NOTIFY pointLabelsVisibilityChanged) | |
51 | Q_PROPERTY(QFont pointLabelsFont READ pointLabelsFont WRITE setPointLabelsFont NOTIFY pointLabelsFontChanged) |
|
51 | Q_PROPERTY(QFont pointLabelsFont READ pointLabelsFont WRITE setPointLabelsFont NOTIFY pointLabelsFontChanged) | |
52 | Q_PROPERTY(QColor pointLabelsColor READ pointLabelsColor WRITE setPointLabelsColor NOTIFY pointLabelsColorChanged) |
|
52 | Q_PROPERTY(QColor pointLabelsColor READ pointLabelsColor WRITE setPointLabelsColor NOTIFY pointLabelsColorChanged) | |
53 | Q_PROPERTY(bool pointLabelsClipping READ pointLabelsClipping WRITE setPointLabelsClipping NOTIFY pointLabelsClippingChanged) |
|
53 | Q_PROPERTY(bool pointLabelsClipping READ pointLabelsClipping WRITE setPointLabelsClipping NOTIFY pointLabelsClippingChanged) | |
54 |
|
54 | |||
55 | public: |
|
55 | public: | |
56 |
explicit QAreaSeries(QObject *parent = |
|
56 | explicit QAreaSeries(QObject *parent = Q_NULLPTR); | |
57 |
explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = |
|
57 | explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = Q_NULLPTR); | |
58 | ~QAreaSeries(); |
|
58 | ~QAreaSeries(); | |
59 |
|
59 | |||
60 | public: |
|
60 | public: | |
61 | QAbstractSeries::SeriesType type() const; |
|
61 | QAbstractSeries::SeriesType type() const; | |
62 |
|
62 | |||
63 | void setUpperSeries(QLineSeries *series); |
|
63 | void setUpperSeries(QLineSeries *series); | |
64 | QLineSeries *upperSeries() const; |
|
64 | QLineSeries *upperSeries() const; | |
65 | void setLowerSeries(QLineSeries *series); |
|
65 | void setLowerSeries(QLineSeries *series); | |
66 | QLineSeries *lowerSeries() const; |
|
66 | QLineSeries *lowerSeries() const; | |
67 |
|
67 | |||
68 | void setPen(const QPen &pen); |
|
68 | void setPen(const QPen &pen); | |
69 | QPen pen() const; |
|
69 | QPen pen() const; | |
70 |
|
70 | |||
71 | void setBrush(const QBrush &brush); |
|
71 | void setBrush(const QBrush &brush); | |
72 | QBrush brush() const; |
|
72 | QBrush brush() const; | |
73 |
|
73 | |||
74 | void setColor(const QColor &color); |
|
74 | void setColor(const QColor &color); | |
75 | QColor color() const; |
|
75 | QColor color() const; | |
76 |
|
76 | |||
77 | void setBorderColor(const QColor &color); |
|
77 | void setBorderColor(const QColor &color); | |
78 | QColor borderColor() const; |
|
78 | QColor borderColor() const; | |
79 |
|
79 | |||
80 | void setPointsVisible(bool visible = true); |
|
80 | void setPointsVisible(bool visible = true); | |
81 | bool pointsVisible() const; |
|
81 | bool pointsVisible() const; | |
82 |
|
82 | |||
83 | void setPointLabelsFormat(const QString &format); |
|
83 | void setPointLabelsFormat(const QString &format); | |
84 | QString pointLabelsFormat() const; |
|
84 | QString pointLabelsFormat() const; | |
85 |
|
85 | |||
86 | void setPointLabelsVisible(bool visible = true); |
|
86 | void setPointLabelsVisible(bool visible = true); | |
87 | bool pointLabelsVisible() const; |
|
87 | bool pointLabelsVisible() const; | |
88 |
|
88 | |||
89 | void setPointLabelsFont(const QFont &font); |
|
89 | void setPointLabelsFont(const QFont &font); | |
90 | QFont pointLabelsFont() const; |
|
90 | QFont pointLabelsFont() const; | |
91 |
|
91 | |||
92 | void setPointLabelsColor(const QColor &color); |
|
92 | void setPointLabelsColor(const QColor &color); | |
93 | QColor pointLabelsColor() const; |
|
93 | QColor pointLabelsColor() const; | |
94 |
|
94 | |||
95 | void setPointLabelsClipping(bool enabled = true); |
|
95 | void setPointLabelsClipping(bool enabled = true); | |
96 | bool pointLabelsClipping() const; |
|
96 | bool pointLabelsClipping() const; | |
97 |
|
97 | |||
98 | Q_SIGNALS: |
|
98 | Q_SIGNALS: | |
99 | void clicked(const QPointF &point); |
|
99 | void clicked(const QPointF &point); | |
100 | void hovered(const QPointF &point, bool state); |
|
100 | void hovered(const QPointF &point, bool state); | |
101 | void pressed(const QPointF &point); |
|
101 | void pressed(const QPointF &point); | |
102 | void released(const QPointF &point); |
|
102 | void released(const QPointF &point); | |
103 | void doubleClicked(const QPointF &point); |
|
103 | void doubleClicked(const QPointF &point); | |
104 | void selected(); |
|
104 | void selected(); | |
105 | void colorChanged(QColor color); |
|
105 | void colorChanged(QColor color); | |
106 | void borderColorChanged(QColor color); |
|
106 | void borderColorChanged(QColor color); | |
107 | void pointLabelsFormatChanged(const QString &format); |
|
107 | void pointLabelsFormatChanged(const QString &format); | |
108 | void pointLabelsVisibilityChanged(bool visible); |
|
108 | void pointLabelsVisibilityChanged(bool visible); | |
109 | void pointLabelsFontChanged(const QFont &font); |
|
109 | void pointLabelsFontChanged(const QFont &font); | |
110 | void pointLabelsColorChanged(const QColor &color); |
|
110 | void pointLabelsColorChanged(const QColor &color); | |
111 | void pointLabelsClippingChanged(bool clipping); |
|
111 | void pointLabelsClippingChanged(bool clipping); | |
112 |
|
112 | |||
113 | private: |
|
113 | private: | |
114 | Q_DECLARE_PRIVATE(QAreaSeries) |
|
114 | Q_DECLARE_PRIVATE(QAreaSeries) | |
115 | Q_DISABLE_COPY(QAreaSeries) |
|
115 | Q_DISABLE_COPY(QAreaSeries) | |
116 | friend class AreaLegendMarker; |
|
116 | friend class AreaLegendMarker; | |
117 | friend class AreaChartItem; |
|
117 | friend class AreaChartItem; | |
118 | friend class QAreaLegendMarkerPrivate; |
|
118 | friend class QAreaLegendMarkerPrivate; | |
119 | }; |
|
119 | }; | |
120 |
|
120 | |||
121 | QT_CHARTS_END_NAMESPACE |
|
121 | QT_CHARTS_END_NAMESPACE | |
122 |
|
122 | |||
123 | #endif // QAREASERIES_H |
|
123 | #endif // QAREASERIES_H |
@@ -1,90 +1,90 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QBARCATEGORYAXIS_H |
|
30 | #ifndef QBARCATEGORYAXIS_H | |
31 | #define QBARCATEGORYAXIS_H |
|
31 | #define QBARCATEGORYAXIS_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractAxis> |
|
33 | #include <QtCharts/QAbstractAxis> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QBarCategoryAxisPrivate; |
|
37 | class QBarCategoryAxisPrivate; | |
38 |
|
38 | |||
39 | class QT_CHARTS_EXPORT QBarCategoryAxis : public QAbstractAxis |
|
39 | class QT_CHARTS_EXPORT QBarCategoryAxis : public QAbstractAxis | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) |
|
42 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) | |
43 | Q_PROPERTY(QString min READ min WRITE setMin NOTIFY minChanged) |
|
43 | Q_PROPERTY(QString min READ min WRITE setMin NOTIFY minChanged) | |
44 | Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged) |
|
44 | Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged) | |
45 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
45 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 |
explicit QBarCategoryAxis(QObject *parent = |
|
48 | explicit QBarCategoryAxis(QObject *parent = Q_NULLPTR); | |
49 | ~QBarCategoryAxis(); |
|
49 | ~QBarCategoryAxis(); | |
50 |
|
50 | |||
51 | protected: |
|
51 | protected: | |
52 |
QBarCategoryAxis(QBarCategoryAxisPrivate &d, QObject *parent = |
|
52 | QBarCategoryAxis(QBarCategoryAxisPrivate &d, QObject *parent = Q_NULLPTR); | |
53 |
|
53 | |||
54 | public: |
|
54 | public: | |
55 | AxisType type() const; |
|
55 | AxisType type() const; | |
56 | void append(const QStringList &categories); |
|
56 | void append(const QStringList &categories); | |
57 | void append(const QString &category); |
|
57 | void append(const QString &category); | |
58 | void remove(const QString &category); |
|
58 | void remove(const QString &category); | |
59 | void insert(int index, const QString &category); |
|
59 | void insert(int index, const QString &category); | |
60 | void replace(const QString &oldCategory, const QString &newCategory); |
|
60 | void replace(const QString &oldCategory, const QString &newCategory); | |
61 | Q_INVOKABLE void clear(); |
|
61 | Q_INVOKABLE void clear(); | |
62 | void setCategories(const QStringList &categories); |
|
62 | void setCategories(const QStringList &categories); | |
63 | QStringList categories(); |
|
63 | QStringList categories(); | |
64 | int count() const; |
|
64 | int count() const; | |
65 | QString at(int index) const; |
|
65 | QString at(int index) const; | |
66 |
|
66 | |||
67 | //range handling |
|
67 | //range handling | |
68 | void setMin(const QString &minCategory); |
|
68 | void setMin(const QString &minCategory); | |
69 | QString min() const; |
|
69 | QString min() const; | |
70 | void setMax(const QString &maxCategory); |
|
70 | void setMax(const QString &maxCategory); | |
71 | QString max() const; |
|
71 | QString max() const; | |
72 | void setRange(const QString &minCategory, const QString &maxCategory); |
|
72 | void setRange(const QString &minCategory, const QString &maxCategory); | |
73 |
|
73 | |||
74 | Q_SIGNALS: |
|
74 | Q_SIGNALS: | |
75 | void categoriesChanged(); |
|
75 | void categoriesChanged(); | |
76 | void minChanged(const QString &min); |
|
76 | void minChanged(const QString &min); | |
77 | void maxChanged(const QString &max); |
|
77 | void maxChanged(const QString &max); | |
78 | void rangeChanged(const QString &min, const QString &max); |
|
78 | void rangeChanged(const QString &min, const QString &max); | |
79 | void countChanged(); |
|
79 | void countChanged(); | |
80 |
|
80 | |||
81 | private: |
|
81 | private: | |
82 | Q_DECLARE_PRIVATE(QBarCategoryAxis) |
|
82 | Q_DECLARE_PRIVATE(QBarCategoryAxis) | |
83 | Q_DISABLE_COPY(QBarCategoryAxis) |
|
83 | Q_DISABLE_COPY(QBarCategoryAxis) | |
84 | friend class ChartBarCategoryAxisX; |
|
84 | friend class ChartBarCategoryAxisX; | |
85 | friend class ChartBarCategoryAxisY; |
|
85 | friend class ChartBarCategoryAxisY; | |
86 | }; |
|
86 | }; | |
87 |
|
87 | |||
88 | QT_CHARTS_END_NAMESPACE |
|
88 | QT_CHARTS_END_NAMESPACE | |
89 |
|
89 | |||
90 | #endif // QBARCATEGORYAXIS_H |
|
90 | #endif // QBARCATEGORYAXIS_H |
@@ -1,91 +1,91 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QCATEGORYAXIS_H |
|
30 | #ifndef QCATEGORYAXIS_H | |
31 | #define QCATEGORYAXIS_H |
|
31 | #define QCATEGORYAXIS_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractAxis> |
|
33 | #include <QtCharts/QAbstractAxis> | |
34 | #include <QtCharts/QValueAxis> |
|
34 | #include <QtCharts/QValueAxis> | |
35 |
|
35 | |||
36 | QT_CHARTS_BEGIN_NAMESPACE |
|
36 | QT_CHARTS_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QCategoryAxisPrivate; |
|
38 | class QCategoryAxisPrivate; | |
39 |
|
39 | |||
40 | class QT_CHARTS_EXPORT QCategoryAxis : public QValueAxis |
|
40 | class QT_CHARTS_EXPORT QCategoryAxis : public QValueAxis | |
41 | { |
|
41 | { | |
42 | Q_OBJECT |
|
42 | Q_OBJECT | |
43 | Q_PROPERTY(qreal startValue READ startValue WRITE setStartValue) |
|
43 | Q_PROPERTY(qreal startValue READ startValue WRITE setStartValue) | |
44 | Q_PROPERTY(int count READ count) |
|
44 | Q_PROPERTY(int count READ count) | |
45 | Q_PROPERTY(QStringList categoriesLabels READ categoriesLabels) |
|
45 | Q_PROPERTY(QStringList categoriesLabels READ categoriesLabels) | |
46 | Q_PROPERTY(AxisLabelsPosition labelsPosition READ labelsPosition WRITE setLabelsPosition NOTIFY labelsPositionChanged) |
|
46 | Q_PROPERTY(AxisLabelsPosition labelsPosition READ labelsPosition WRITE setLabelsPosition NOTIFY labelsPositionChanged) | |
47 | Q_ENUMS(AxisLabelsPosition) |
|
47 | Q_ENUMS(AxisLabelsPosition) | |
48 |
|
48 | |||
49 | public: |
|
49 | public: | |
50 |
|
50 | |||
51 | enum AxisLabelsPosition { |
|
51 | enum AxisLabelsPosition { | |
52 | AxisLabelsPositionCenter = 0x0, |
|
52 | AxisLabelsPositionCenter = 0x0, | |
53 | AxisLabelsPositionOnValue = 0x1 |
|
53 | AxisLabelsPositionOnValue = 0x1 | |
54 | }; |
|
54 | }; | |
55 |
|
55 | |||
56 |
explicit QCategoryAxis(QObject *parent = |
|
56 | explicit QCategoryAxis(QObject *parent = Q_NULLPTR); | |
57 | ~QCategoryAxis(); |
|
57 | ~QCategoryAxis(); | |
58 |
|
58 | |||
59 | protected: |
|
59 | protected: | |
60 |
QCategoryAxis(QCategoryAxisPrivate &d, QObject *parent = |
|
60 | QCategoryAxis(QCategoryAxisPrivate &d, QObject *parent = Q_NULLPTR); | |
61 |
|
61 | |||
62 | public: |
|
62 | public: | |
63 | AxisType type() const; |
|
63 | AxisType type() const; | |
64 |
|
64 | |||
65 | void append(const QString &label, qreal categoryEndValue); |
|
65 | void append(const QString &label, qreal categoryEndValue); | |
66 | void remove(const QString &label); |
|
66 | void remove(const QString &label); | |
67 | void replaceLabel(const QString &oldLabel, const QString &newLabel); |
|
67 | void replaceLabel(const QString &oldLabel, const QString &newLabel); | |
68 |
|
68 | |||
69 | qreal startValue(const QString &categoryLabel = QString()) const; |
|
69 | qreal startValue(const QString &categoryLabel = QString()) const; | |
70 | void setStartValue(qreal min); |
|
70 | void setStartValue(qreal min); | |
71 |
|
71 | |||
72 | qreal endValue(const QString &categoryLabel) const; |
|
72 | qreal endValue(const QString &categoryLabel) const; | |
73 |
|
73 | |||
74 | QStringList categoriesLabels(); |
|
74 | QStringList categoriesLabels(); | |
75 | int count() const; |
|
75 | int count() const; | |
76 |
|
76 | |||
77 | QCategoryAxis::AxisLabelsPosition labelsPosition() const; |
|
77 | QCategoryAxis::AxisLabelsPosition labelsPosition() const; | |
78 | void setLabelsPosition(QCategoryAxis::AxisLabelsPosition position); |
|
78 | void setLabelsPosition(QCategoryAxis::AxisLabelsPosition position); | |
79 |
|
79 | |||
80 | Q_SIGNALS: |
|
80 | Q_SIGNALS: | |
81 | void categoriesChanged(); |
|
81 | void categoriesChanged(); | |
82 | void labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position); |
|
82 | void labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position); | |
83 |
|
83 | |||
84 | private: |
|
84 | private: | |
85 | Q_DECLARE_PRIVATE(QCategoryAxis) |
|
85 | Q_DECLARE_PRIVATE(QCategoryAxis) | |
86 | Q_DISABLE_COPY(QCategoryAxis) |
|
86 | Q_DISABLE_COPY(QCategoryAxis) | |
87 | }; |
|
87 | }; | |
88 |
|
88 | |||
89 | QT_CHARTS_END_NAMESPACE |
|
89 | QT_CHARTS_END_NAMESPACE | |
90 |
|
90 | |||
91 | #endif // QCATEGORYAXIS_H |
|
91 | #endif // QCATEGORYAXIS_H |
@@ -1,89 +1,89 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QDATETIMEAXIS_H |
|
30 | #ifndef QDATETIMEAXIS_H | |
31 | #define QDATETIMEAXIS_H |
|
31 | #define QDATETIMEAXIS_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractAxis> |
|
33 | #include <QtCharts/QAbstractAxis> | |
34 |
|
34 | |||
35 | QT_BEGIN_NAMESPACE |
|
35 | QT_BEGIN_NAMESPACE | |
36 | class QDateTime; |
|
36 | class QDateTime; | |
37 | QT_END_NAMESPACE |
|
37 | QT_END_NAMESPACE | |
38 |
|
38 | |||
39 | QT_CHARTS_BEGIN_NAMESPACE |
|
39 | QT_CHARTS_BEGIN_NAMESPACE | |
40 |
|
40 | |||
41 | class QDateTimeAxisPrivate; |
|
41 | class QDateTimeAxisPrivate; | |
42 |
|
42 | |||
43 | class QT_CHARTS_EXPORT QDateTimeAxis : public QAbstractAxis |
|
43 | class QT_CHARTS_EXPORT QDateTimeAxis : public QAbstractAxis | |
44 | { |
|
44 | { | |
45 | Q_OBJECT |
|
45 | Q_OBJECT | |
46 | Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount NOTIFY tickCountChanged) |
|
46 | Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount NOTIFY tickCountChanged) | |
47 | Q_PROPERTY(QDateTime min READ min WRITE setMin NOTIFY minChanged) |
|
47 | Q_PROPERTY(QDateTime min READ min WRITE setMin NOTIFY minChanged) | |
48 | Q_PROPERTY(QDateTime max READ max WRITE setMax NOTIFY maxChanged) |
|
48 | Q_PROPERTY(QDateTime max READ max WRITE setMax NOTIFY maxChanged) | |
49 | Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged) |
|
49 | Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged) | |
50 |
|
50 | |||
51 | public: |
|
51 | public: | |
52 |
explicit QDateTimeAxis(QObject *parent = |
|
52 | explicit QDateTimeAxis(QObject *parent = Q_NULLPTR); | |
53 | ~QDateTimeAxis(); |
|
53 | ~QDateTimeAxis(); | |
54 |
|
54 | |||
55 | protected: |
|
55 | protected: | |
56 |
QDateTimeAxis(QDateTimeAxisPrivate &d, QObject *parent = |
|
56 | QDateTimeAxis(QDateTimeAxisPrivate &d, QObject *parent = Q_NULLPTR); | |
57 |
|
57 | |||
58 | public: |
|
58 | public: | |
59 | AxisType type() const; |
|
59 | AxisType type() const; | |
60 |
|
60 | |||
61 | //range handling |
|
61 | //range handling | |
62 | void setMin(QDateTime min); |
|
62 | void setMin(QDateTime min); | |
63 | QDateTime min() const; |
|
63 | QDateTime min() const; | |
64 | void setMax(QDateTime max); |
|
64 | void setMax(QDateTime max); | |
65 | QDateTime max() const; |
|
65 | QDateTime max() const; | |
66 | void setRange(QDateTime min, QDateTime max); |
|
66 | void setRange(QDateTime min, QDateTime max); | |
67 |
|
67 | |||
68 | void setFormat(QString format); |
|
68 | void setFormat(QString format); | |
69 | QString format() const; |
|
69 | QString format() const; | |
70 |
|
70 | |||
71 | //ticks handling |
|
71 | //ticks handling | |
72 | void setTickCount(int count); |
|
72 | void setTickCount(int count); | |
73 | int tickCount() const; |
|
73 | int tickCount() const; | |
74 |
|
74 | |||
75 | Q_SIGNALS: |
|
75 | Q_SIGNALS: | |
76 | void minChanged(QDateTime min); |
|
76 | void minChanged(QDateTime min); | |
77 | void maxChanged(QDateTime max); |
|
77 | void maxChanged(QDateTime max); | |
78 | void rangeChanged(QDateTime min, QDateTime max); |
|
78 | void rangeChanged(QDateTime min, QDateTime max); | |
79 | void formatChanged(QString format); |
|
79 | void formatChanged(QString format); | |
80 | void tickCountChanged(int tick); |
|
80 | void tickCountChanged(int tick); | |
81 |
|
81 | |||
82 | private: |
|
82 | private: | |
83 | Q_DECLARE_PRIVATE(QDateTimeAxis) |
|
83 | Q_DECLARE_PRIVATE(QDateTimeAxis) | |
84 | Q_DISABLE_COPY(QDateTimeAxis) |
|
84 | Q_DISABLE_COPY(QDateTimeAxis) | |
85 | }; |
|
85 | }; | |
86 |
|
86 | |||
87 | QT_CHARTS_END_NAMESPACE |
|
87 | QT_CHARTS_END_NAMESPACE | |
88 |
|
88 | |||
89 | #endif // QDATETIMEAXIS_H |
|
89 | #endif // QDATETIMEAXIS_H |
@@ -1,88 +1,88 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QLOGVALUEAXIS_H |
|
30 | #ifndef QLOGVALUEAXIS_H | |
31 | #define QLOGVALUEAXIS_H |
|
31 | #define QLOGVALUEAXIS_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractAxis> |
|
33 | #include <QtCharts/QAbstractAxis> | |
34 |
|
34 | |||
35 | QT_BEGIN_NAMESPACE |
|
35 | QT_BEGIN_NAMESPACE | |
36 | class QDateTime; |
|
36 | class QDateTime; | |
37 | QT_END_NAMESPACE |
|
37 | QT_END_NAMESPACE | |
38 |
|
38 | |||
39 | QT_CHARTS_BEGIN_NAMESPACE |
|
39 | QT_CHARTS_BEGIN_NAMESPACE | |
40 |
|
40 | |||
41 | class QLogValueAxisPrivate; |
|
41 | class QLogValueAxisPrivate; | |
42 |
|
42 | |||
43 | class QT_CHARTS_EXPORT QLogValueAxis : public QAbstractAxis |
|
43 | class QT_CHARTS_EXPORT QLogValueAxis : public QAbstractAxis | |
44 | { |
|
44 | { | |
45 | Q_OBJECT |
|
45 | Q_OBJECT | |
46 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) |
|
46 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) | |
47 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) |
|
47 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) | |
48 | Q_PROPERTY(QString labelFormat READ labelFormat WRITE setLabelFormat NOTIFY labelFormatChanged) |
|
48 | Q_PROPERTY(QString labelFormat READ labelFormat WRITE setLabelFormat NOTIFY labelFormatChanged) | |
49 | Q_PROPERTY(qreal base READ base WRITE setBase NOTIFY baseChanged) |
|
49 | Q_PROPERTY(qreal base READ base WRITE setBase NOTIFY baseChanged) | |
50 |
|
50 | |||
51 | public: |
|
51 | public: | |
52 |
explicit QLogValueAxis(QObject *parent = |
|
52 | explicit QLogValueAxis(QObject *parent = Q_NULLPTR); | |
53 | ~QLogValueAxis(); |
|
53 | ~QLogValueAxis(); | |
54 |
|
54 | |||
55 | protected: |
|
55 | protected: | |
56 |
QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent = |
|
56 | QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent = Q_NULLPTR); | |
57 |
|
57 | |||
58 | public: |
|
58 | public: | |
59 | AxisType type() const; |
|
59 | AxisType type() const; | |
60 |
|
60 | |||
61 | //range handling |
|
61 | //range handling | |
62 | void setMin(qreal min); |
|
62 | void setMin(qreal min); | |
63 | qreal min() const; |
|
63 | qreal min() const; | |
64 | void setMax(qreal max); |
|
64 | void setMax(qreal max); | |
65 | qreal max() const; |
|
65 | qreal max() const; | |
66 | void setRange(qreal min, qreal max); |
|
66 | void setRange(qreal min, qreal max); | |
67 |
|
67 | |||
68 | void setLabelFormat(const QString &format); |
|
68 | void setLabelFormat(const QString &format); | |
69 | QString labelFormat() const; |
|
69 | QString labelFormat() const; | |
70 |
|
70 | |||
71 | void setBase(qreal base); |
|
71 | void setBase(qreal base); | |
72 | qreal base() const; |
|
72 | qreal base() const; | |
73 |
|
73 | |||
74 | Q_SIGNALS: |
|
74 | Q_SIGNALS: | |
75 | void minChanged(qreal min); |
|
75 | void minChanged(qreal min); | |
76 | void maxChanged(qreal max); |
|
76 | void maxChanged(qreal max); | |
77 | void rangeChanged(qreal min, qreal max); |
|
77 | void rangeChanged(qreal min, qreal max); | |
78 | void labelFormatChanged(const QString &format); |
|
78 | void labelFormatChanged(const QString &format); | |
79 | void baseChanged(qreal base); |
|
79 | void baseChanged(qreal base); | |
80 |
|
80 | |||
81 | private: |
|
81 | private: | |
82 | Q_DECLARE_PRIVATE(QLogValueAxis) |
|
82 | Q_DECLARE_PRIVATE(QLogValueAxis) | |
83 | Q_DISABLE_COPY(QLogValueAxis) |
|
83 | Q_DISABLE_COPY(QLogValueAxis) | |
84 | }; |
|
84 | }; | |
85 |
|
85 | |||
86 | QT_CHARTS_END_NAMESPACE |
|
86 | QT_CHARTS_END_NAMESPACE | |
87 |
|
87 | |||
88 | #endif // QLOGVALUEAXIS_H |
|
88 | #endif // QLOGVALUEAXIS_H |
@@ -1,218 +1,218 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QABSTRACTAXIS_H |
|
30 | #ifndef QABSTRACTAXIS_H | |
31 | #define QABSTRACTAXIS_H |
|
31 | #define QABSTRACTAXIS_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtGui/QPen> |
|
34 | #include <QtGui/QPen> | |
35 | #include <QtGui/QFont> |
|
35 | #include <QtGui/QFont> | |
36 | #include <QtCore/QVariant> |
|
36 | #include <QtCore/QVariant> | |
37 |
|
37 | |||
38 | QT_CHARTS_BEGIN_NAMESPACE |
|
38 | QT_CHARTS_BEGIN_NAMESPACE | |
39 |
|
39 | |||
40 | class QAbstractAxisPrivate; |
|
40 | class QAbstractAxisPrivate; | |
41 |
|
41 | |||
42 | class QT_CHARTS_EXPORT QAbstractAxis : public QObject |
|
42 | class QT_CHARTS_EXPORT QAbstractAxis : public QObject | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 | //visibility |
|
45 | //visibility | |
46 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
|
46 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) | |
47 | //arrow |
|
47 | //arrow | |
48 | Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged) |
|
48 | Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged) | |
49 | Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged) |
|
49 | Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged) | |
50 | Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged) |
|
50 | Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged) | |
51 | //labels |
|
51 | //labels | |
52 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
52 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) | |
53 | Q_PROPERTY(QBrush labelsBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged) |
|
53 | Q_PROPERTY(QBrush labelsBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged) | |
54 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) |
|
54 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) | |
55 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged) |
|
55 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged) | |
56 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) |
|
56 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) | |
57 | //grid |
|
57 | //grid | |
58 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) |
|
58 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) | |
59 | Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged) |
|
59 | Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged) | |
60 | Q_PROPERTY(bool minorGridVisible READ isMinorGridLineVisible WRITE setMinorGridLineVisible NOTIFY minorGridVisibleChanged) |
|
60 | Q_PROPERTY(bool minorGridVisible READ isMinorGridLineVisible WRITE setMinorGridLineVisible NOTIFY minorGridVisibleChanged) | |
61 | Q_PROPERTY(QPen minorGridLinePen READ minorGridLinePen WRITE setMinorGridLinePen NOTIFY minorGridLinePenChanged) |
|
61 | Q_PROPERTY(QPen minorGridLinePen READ minorGridLinePen WRITE setMinorGridLinePen NOTIFY minorGridLinePenChanged) | |
62 | Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged) |
|
62 | Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged) | |
63 | Q_PROPERTY(QColor minorGridLineColor READ minorGridLineColor WRITE setMinorGridLineColor NOTIFY minorGridLineColorChanged) |
|
63 | Q_PROPERTY(QColor minorGridLineColor READ minorGridLineColor WRITE setMinorGridLineColor NOTIFY minorGridLineColorChanged) | |
64 | //shades |
|
64 | //shades | |
65 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
|
65 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) | |
66 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
|
66 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) | |
67 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
|
67 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) | |
68 | Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged) |
|
68 | Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged) | |
69 | Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged) |
|
69 | Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged) | |
70 | //title |
|
70 | //title | |
71 | Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged) |
|
71 | Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged) | |
72 | Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged) |
|
72 | Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged) | |
73 | Q_PROPERTY(bool titleVisible READ isTitleVisible WRITE setTitleVisible NOTIFY titleVisibleChanged) |
|
73 | Q_PROPERTY(bool titleVisible READ isTitleVisible WRITE setTitleVisible NOTIFY titleVisibleChanged) | |
74 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged) |
|
74 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged) | |
75 | //orientation |
|
75 | //orientation | |
76 | Q_PROPERTY(Qt::Orientation orientation READ orientation) |
|
76 | Q_PROPERTY(Qt::Orientation orientation READ orientation) | |
77 | //aligment |
|
77 | //aligment | |
78 | Q_PROPERTY(Qt::Alignment alignment READ alignment) |
|
78 | Q_PROPERTY(Qt::Alignment alignment READ alignment) | |
79 | Q_PROPERTY(bool reverse READ isReverse WRITE setReverse NOTIFY reverseChanged) |
|
79 | Q_PROPERTY(bool reverse READ isReverse WRITE setReverse NOTIFY reverseChanged) | |
80 |
|
80 | |||
81 | public: |
|
81 | public: | |
82 |
|
82 | |||
83 | enum AxisType { |
|
83 | enum AxisType { | |
84 | AxisTypeNoAxis = 0x0, |
|
84 | AxisTypeNoAxis = 0x0, | |
85 | AxisTypeValue = 0x1, |
|
85 | AxisTypeValue = 0x1, | |
86 | AxisTypeBarCategory = 0x2, |
|
86 | AxisTypeBarCategory = 0x2, | |
87 | AxisTypeCategory = 0x4, |
|
87 | AxisTypeCategory = 0x4, | |
88 | AxisTypeDateTime = 0x8, |
|
88 | AxisTypeDateTime = 0x8, | |
89 | AxisTypeLogValue = 0x10 |
|
89 | AxisTypeLogValue = 0x10 | |
90 | }; |
|
90 | }; | |
91 |
|
91 | |||
92 | Q_DECLARE_FLAGS(AxisTypes, AxisType) |
|
92 | Q_DECLARE_FLAGS(AxisTypes, AxisType) | |
93 |
|
93 | |||
94 | protected: |
|
94 | protected: | |
95 |
explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = |
|
95 | explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = Q_NULLPTR); | |
96 |
|
96 | |||
97 | public: |
|
97 | public: | |
98 | ~QAbstractAxis(); |
|
98 | ~QAbstractAxis(); | |
99 |
|
99 | |||
100 | virtual AxisType type() const = 0; |
|
100 | virtual AxisType type() const = 0; | |
101 |
|
101 | |||
102 | //visibility handling |
|
102 | //visibility handling | |
103 | bool isVisible() const; |
|
103 | bool isVisible() const; | |
104 | void setVisible(bool visible = true); |
|
104 | void setVisible(bool visible = true); | |
105 | void show(); |
|
105 | void show(); | |
106 | void hide(); |
|
106 | void hide(); | |
107 |
|
107 | |||
108 | //arrow handling |
|
108 | //arrow handling | |
109 | bool isLineVisible() const; |
|
109 | bool isLineVisible() const; | |
110 | void setLineVisible(bool visible = true); |
|
110 | void setLineVisible(bool visible = true); | |
111 | void setLinePen(const QPen &pen); |
|
111 | void setLinePen(const QPen &pen); | |
112 | QPen linePen() const; |
|
112 | QPen linePen() const; | |
113 | void setLinePenColor(QColor color); |
|
113 | void setLinePenColor(QColor color); | |
114 | QColor linePenColor() const; |
|
114 | QColor linePenColor() const; | |
115 |
|
115 | |||
116 | //grid handling |
|
116 | //grid handling | |
117 | bool isGridLineVisible() const; |
|
117 | bool isGridLineVisible() const; | |
118 | void setGridLineVisible(bool visible = true); |
|
118 | void setGridLineVisible(bool visible = true); | |
119 | void setGridLinePen(const QPen &pen); |
|
119 | void setGridLinePen(const QPen &pen); | |
120 | QPen gridLinePen() const; |
|
120 | QPen gridLinePen() const; | |
121 | bool isMinorGridLineVisible() const; |
|
121 | bool isMinorGridLineVisible() const; | |
122 | void setMinorGridLineVisible(bool visible = true); |
|
122 | void setMinorGridLineVisible(bool visible = true); | |
123 | void setMinorGridLinePen(const QPen &pen); |
|
123 | void setMinorGridLinePen(const QPen &pen); | |
124 | QPen minorGridLinePen() const; |
|
124 | QPen minorGridLinePen() const; | |
125 | void setGridLineColor(const QColor &color); |
|
125 | void setGridLineColor(const QColor &color); | |
126 | QColor gridLineColor(); |
|
126 | QColor gridLineColor(); | |
127 | void setMinorGridLineColor(const QColor &color); |
|
127 | void setMinorGridLineColor(const QColor &color); | |
128 | QColor minorGridLineColor(); |
|
128 | QColor minorGridLineColor(); | |
129 |
|
129 | |||
130 | //labels handling |
|
130 | //labels handling | |
131 | bool labelsVisible() const; |
|
131 | bool labelsVisible() const; | |
132 | void setLabelsVisible(bool visible = true); |
|
132 | void setLabelsVisible(bool visible = true); | |
133 | void setLabelsBrush(const QBrush &brush); |
|
133 | void setLabelsBrush(const QBrush &brush); | |
134 | QBrush labelsBrush() const; |
|
134 | QBrush labelsBrush() const; | |
135 | void setLabelsFont(const QFont &font); |
|
135 | void setLabelsFont(const QFont &font); | |
136 | QFont labelsFont() const; |
|
136 | QFont labelsFont() const; | |
137 | void setLabelsAngle(int angle); |
|
137 | void setLabelsAngle(int angle); | |
138 | int labelsAngle() const; |
|
138 | int labelsAngle() const; | |
139 | void setLabelsColor(QColor color); |
|
139 | void setLabelsColor(QColor color); | |
140 | QColor labelsColor() const; |
|
140 | QColor labelsColor() const; | |
141 |
|
141 | |||
142 | //title handling |
|
142 | //title handling | |
143 | bool isTitleVisible() const; |
|
143 | bool isTitleVisible() const; | |
144 | void setTitleVisible(bool visible = true); |
|
144 | void setTitleVisible(bool visible = true); | |
145 | void setTitleBrush(const QBrush &brush); |
|
145 | void setTitleBrush(const QBrush &brush); | |
146 | QBrush titleBrush() const; |
|
146 | QBrush titleBrush() const; | |
147 | void setTitleFont(const QFont &font); |
|
147 | void setTitleFont(const QFont &font); | |
148 | QFont titleFont() const; |
|
148 | QFont titleFont() const; | |
149 | void setTitleText(const QString &title); |
|
149 | void setTitleText(const QString &title); | |
150 | QString titleText() const; |
|
150 | QString titleText() const; | |
151 |
|
151 | |||
152 | //shades handling |
|
152 | //shades handling | |
153 | bool shadesVisible() const; |
|
153 | bool shadesVisible() const; | |
154 | void setShadesVisible(bool visible = true); |
|
154 | void setShadesVisible(bool visible = true); | |
155 | void setShadesPen(const QPen &pen); |
|
155 | void setShadesPen(const QPen &pen); | |
156 | QPen shadesPen() const; |
|
156 | QPen shadesPen() const; | |
157 | void setShadesBrush(const QBrush &brush); |
|
157 | void setShadesBrush(const QBrush &brush); | |
158 | QBrush shadesBrush() const; |
|
158 | QBrush shadesBrush() const; | |
159 | void setShadesColor(QColor color); |
|
159 | void setShadesColor(QColor color); | |
160 | QColor shadesColor() const; |
|
160 | QColor shadesColor() const; | |
161 | void setShadesBorderColor(QColor color); |
|
161 | void setShadesBorderColor(QColor color); | |
162 | QColor shadesBorderColor() const; |
|
162 | QColor shadesBorderColor() const; | |
163 |
|
163 | |||
164 | Qt::Orientation orientation() const; |
|
164 | Qt::Orientation orientation() const; | |
165 | Qt::Alignment alignment() const; |
|
165 | Qt::Alignment alignment() const; | |
166 |
|
166 | |||
167 | //range handling |
|
167 | //range handling | |
168 | void setMin(const QVariant &min); |
|
168 | void setMin(const QVariant &min); | |
169 | void setMax(const QVariant &max); |
|
169 | void setMax(const QVariant &max); | |
170 | void setRange(const QVariant &min, const QVariant &max); |
|
170 | void setRange(const QVariant &min, const QVariant &max); | |
171 |
|
171 | |||
172 | //reverse handling |
|
172 | //reverse handling | |
173 | void setReverse(bool reverse = true); |
|
173 | void setReverse(bool reverse = true); | |
174 | bool isReverse() const; |
|
174 | bool isReverse() const; | |
175 |
|
175 | |||
176 | Q_SIGNALS: |
|
176 | Q_SIGNALS: | |
177 | void visibleChanged(bool visible); |
|
177 | void visibleChanged(bool visible); | |
178 | void linePenChanged(const QPen &pen); |
|
178 | void linePenChanged(const QPen &pen); | |
179 | void lineVisibleChanged(bool visible); |
|
179 | void lineVisibleChanged(bool visible); | |
180 | void labelsVisibleChanged(bool visible); |
|
180 | void labelsVisibleChanged(bool visible); | |
181 | void labelsBrushChanged(const QBrush &brush); |
|
181 | void labelsBrushChanged(const QBrush &brush); | |
182 | void labelsFontChanged(const QFont &pen); |
|
182 | void labelsFontChanged(const QFont &pen); | |
183 | void labelsAngleChanged(int angle); |
|
183 | void labelsAngleChanged(int angle); | |
184 | void gridLinePenChanged(const QPen &pen); |
|
184 | void gridLinePenChanged(const QPen &pen); | |
185 | void gridVisibleChanged(bool visible); |
|
185 | void gridVisibleChanged(bool visible); | |
186 | void minorGridVisibleChanged(bool visible); |
|
186 | void minorGridVisibleChanged(bool visible); | |
187 | void minorGridLinePenChanged(const QPen &pen); |
|
187 | void minorGridLinePenChanged(const QPen &pen); | |
188 | void gridLineColorChanged(const QColor &color); |
|
188 | void gridLineColorChanged(const QColor &color); | |
189 | void minorGridLineColorChanged(const QColor &color); |
|
189 | void minorGridLineColorChanged(const QColor &color); | |
190 | void colorChanged(QColor color); |
|
190 | void colorChanged(QColor color); | |
191 | void labelsColorChanged(QColor color); |
|
191 | void labelsColorChanged(QColor color); | |
192 | void titleTextChanged(const QString &title); |
|
192 | void titleTextChanged(const QString &title); | |
193 | void titleBrushChanged(const QBrush &brush); |
|
193 | void titleBrushChanged(const QBrush &brush); | |
194 | void titleVisibleChanged(bool visible); |
|
194 | void titleVisibleChanged(bool visible); | |
195 | void titleFontChanged(const QFont &font); |
|
195 | void titleFontChanged(const QFont &font); | |
196 | void shadesVisibleChanged(bool visible); |
|
196 | void shadesVisibleChanged(bool visible); | |
197 | void shadesColorChanged(QColor color); |
|
197 | void shadesColorChanged(QColor color); | |
198 | void shadesBorderColorChanged(QColor color); |
|
198 | void shadesBorderColorChanged(QColor color); | |
199 | void shadesPenChanged(const QPen &pen); |
|
199 | void shadesPenChanged(const QPen &pen); | |
200 | void shadesBrushChanged(const QBrush &brush); |
|
200 | void shadesBrushChanged(const QBrush &brush); | |
201 | void reverseChanged(bool reverse); |
|
201 | void reverseChanged(bool reverse); | |
202 |
|
202 | |||
203 | protected: |
|
203 | protected: | |
204 | QScopedPointer<QAbstractAxisPrivate> d_ptr; |
|
204 | QScopedPointer<QAbstractAxisPrivate> d_ptr; | |
205 | friend class ChartDataSet; |
|
205 | friend class ChartDataSet; | |
206 | friend class ChartPresenter; |
|
206 | friend class ChartPresenter; | |
207 | friend class ChartThemeManager; |
|
207 | friend class ChartThemeManager; | |
208 | friend class AbstractDomain; |
|
208 | friend class AbstractDomain; | |
209 | friend class ChartAxisElement; |
|
209 | friend class ChartAxisElement; | |
210 | friend class XYChart; |
|
210 | friend class XYChart; | |
211 |
|
211 | |||
212 | private: |
|
212 | private: | |
213 | Q_DISABLE_COPY(QAbstractAxis) |
|
213 | Q_DISABLE_COPY(QAbstractAxis) | |
214 | }; |
|
214 | }; | |
215 |
|
215 | |||
216 | QT_CHARTS_END_NAMESPACE |
|
216 | QT_CHARTS_END_NAMESPACE | |
217 |
|
217 | |||
218 | #endif // QABSTRACTAXIS_H |
|
218 | #endif // QABSTRACTAXIS_H |
@@ -1,466 +1,472 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #include <QtCharts/QValueAxis> |
|
30 | #include <QtCharts/QValueAxis> | |
31 | #include <private/qvalueaxis_p.h> |
|
31 | #include <private/qvalueaxis_p.h> | |
32 | #include <private/chartvalueaxisx_p.h> |
|
32 | #include <private/chartvalueaxisx_p.h> | |
33 | #include <private/chartvalueaxisy_p.h> |
|
33 | #include <private/chartvalueaxisy_p.h> | |
34 | #include <private/abstractdomain_p.h> |
|
34 | #include <private/abstractdomain_p.h> | |
35 | #include <private/polarchartvalueaxisangular_p.h> |
|
35 | #include <private/polarchartvalueaxisangular_p.h> | |
36 | #include <private/polarchartvalueaxisradial_p.h> |
|
36 | #include <private/polarchartvalueaxisradial_p.h> | |
37 | #include <private/chartdataset_p.h> |
|
37 | #include <private/chartdataset_p.h> | |
38 | #include <private/chartpresenter_p.h> |
|
38 | #include <private/chartpresenter_p.h> | |
39 | #include <private/charttheme_p.h> |
|
39 | #include <private/charttheme_p.h> | |
40 |
|
40 | #include <private/charthelpers_p.h> | ||
41 |
|
41 | |||
42 | QT_CHARTS_BEGIN_NAMESPACE |
|
42 | QT_CHARTS_BEGIN_NAMESPACE | |
43 | /*! |
|
43 | /*! | |
44 | \class QValueAxis |
|
44 | \class QValueAxis | |
45 | \inmodule Qt Charts |
|
45 | \inmodule Qt Charts | |
46 | \brief The QValueAxis class is used for manipulating chart's axis. |
|
46 | \brief The QValueAxis class is used for manipulating chart's axis. | |
47 |
|
47 | |||
48 | ValueAxis can be setup to show axis line with tick marks, grid lines and shades. |
|
48 | ValueAxis can be setup to show axis line with tick marks, grid lines and shades. | |
49 | Values of axis are drawn to position of ticks. |
|
49 | Values of axis are drawn to position of ticks. | |
50 |
|
50 | |||
51 | Example code on how to use QValueAxis. |
|
51 | Example code on how to use QValueAxis. | |
52 | \code |
|
52 | \code | |
53 | QChartView *chartView = new QChartView; |
|
53 | QChartView *chartView = new QChartView; | |
54 | QLineSeries *series = new QLineSeries; |
|
54 | QLineSeries *series = new QLineSeries; | |
55 | // ... |
|
55 | // ... | |
56 | chartView->chart()->addSeries(series); |
|
56 | chartView->chart()->addSeries(series); | |
57 |
|
57 | |||
58 | QValueAxis *axisX = new QValueAxis; |
|
58 | QValueAxis *axisX = new QValueAxis; | |
59 | axisX->setRange(10, 20.5); |
|
59 | axisX->setRange(10, 20.5); | |
60 | axisX->setTickCount(10); |
|
60 | axisX->setTickCount(10); | |
61 | axisX->setLabelFormat("%.2f"); |
|
61 | axisX->setLabelFormat("%.2f"); | |
62 | chartView->chart()->setAxisX(axisX, series); |
|
62 | chartView->chart()->setAxisX(axisX, series); | |
63 | \endcode |
|
63 | \endcode | |
64 | */ |
|
64 | */ | |
65 | /*! |
|
65 | /*! | |
66 | \qmltype ValueAxis |
|
66 | \qmltype ValueAxis | |
67 | \instantiates QValueAxis |
|
67 | \instantiates QValueAxis | |
68 | \inqmlmodule QtCharts |
|
68 | \inqmlmodule QtCharts | |
69 |
|
69 | |||
70 | \inherits AbstractAxis |
|
70 | \inherits AbstractAxis | |
71 | \brief The ValueAxis element is used for manipulating chart's axes |
|
71 | \brief The ValueAxis element is used for manipulating chart's axes | |
72 |
|
72 | |||
73 | ValueAxis can be setup to show axis line with tick marks, grid lines and shades. |
|
73 | ValueAxis can be setup to show axis line with tick marks, grid lines and shades. | |
74 | Values of axis are drawn to position of ticks |
|
74 | Values of axis are drawn to position of ticks | |
75 |
|
75 | |||
76 | Example about using ValueAxis: |
|
76 | Example about using ValueAxis: | |
77 | \code |
|
77 | \code | |
78 | ChartView { |
|
78 | ChartView { | |
79 | ValueAxis { |
|
79 | ValueAxis { | |
80 | id: xAxis |
|
80 | id: xAxis | |
81 | min: 0 |
|
81 | min: 0 | |
82 | max: 10 |
|
82 | max: 10 | |
83 | } |
|
83 | } | |
84 | // Add a few series... |
|
84 | // Add a few series... | |
85 | } |
|
85 | } | |
86 | \endcode |
|
86 | \endcode | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \property QValueAxis::min |
|
90 | \property QValueAxis::min | |
91 | Defines the minimum value on the axis. |
|
91 | Defines the minimum value on the axis. | |
92 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. |
|
92 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. | |
93 | */ |
|
93 | */ | |
94 | /*! |
|
94 | /*! | |
95 | \qmlproperty real ValueAxis::min |
|
95 | \qmlproperty real ValueAxis::min | |
96 | Defines the minimum value on the axis. |
|
96 | Defines the minimum value on the axis. | |
97 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. |
|
97 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. | |
98 | */ |
|
98 | */ | |
99 |
|
99 | |||
100 | /*! |
|
100 | /*! | |
101 | \property QValueAxis::max |
|
101 | \property QValueAxis::max | |
102 | Defines the maximum value on the axis. |
|
102 | Defines the maximum value on the axis. | |
103 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. |
|
103 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. | |
104 | */ |
|
104 | */ | |
105 | /*! |
|
105 | /*! | |
106 | \qmlproperty real ValueAxis::max |
|
106 | \qmlproperty real ValueAxis::max | |
107 | Defines the maximum value on the axis. |
|
107 | Defines the maximum value on the axis. | |
108 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. |
|
108 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. | |
109 | */ |
|
109 | */ | |
110 |
|
110 | |||
111 | /*! |
|
111 | /*! | |
112 | \property QValueAxis::tickCount |
|
112 | \property QValueAxis::tickCount | |
113 | Defines the number of ticks on the axis. This indicates how many grid lines are drawn on the |
|
113 | Defines the number of ticks on the axis. This indicates how many grid lines are drawn on the | |
114 | chart. The default value is 5, and it can not be below 2. |
|
114 | chart. The default value is 5, and it can not be below 2. | |
115 | */ |
|
115 | */ | |
116 | /*! |
|
116 | /*! | |
117 | \qmlproperty int ValueAxis::tickCount |
|
117 | \qmlproperty int ValueAxis::tickCount | |
118 | Defines the number of ticks on the axis. This indicates how many grid lines are drawn on the |
|
118 | Defines the number of ticks on the axis. This indicates how many grid lines are drawn on the | |
119 | chart. The default value is 5, and it can not be below 2. |
|
119 | chart. The default value is 5, and it can not be below 2. | |
120 | */ |
|
120 | */ | |
121 |
|
121 | |||
122 | /*! |
|
122 | /*! | |
123 | \property QValueAxis::minorTickCount |
|
123 | \property QValueAxis::minorTickCount | |
124 | Defines the number of minor ticks on the axis. This indicates how many grid lines are drawn |
|
124 | Defines the number of minor ticks on the axis. This indicates how many grid lines are drawn | |
125 | between major ticks on the chart. Labels are not drawn for minor ticks. The default value is 0. |
|
125 | between major ticks on the chart. Labels are not drawn for minor ticks. The default value is 0. | |
126 | */ |
|
126 | */ | |
127 | /*! |
|
127 | /*! | |
128 | \qmlproperty int ValueAxis::minorTickCount |
|
128 | \qmlproperty int ValueAxis::minorTickCount | |
129 | Defines the number of minor ticks on the axis. This indicates how many grid lines are drawn |
|
129 | Defines the number of minor ticks on the axis. This indicates how many grid lines are drawn | |
130 | between major ticks on the chart. Labels are not drawn for minor ticks. The default value is 0. |
|
130 | between major ticks on the chart. Labels are not drawn for minor ticks. The default value is 0. | |
131 | */ |
|
131 | */ | |
132 |
|
132 | |||
133 | /*! |
|
133 | /*! | |
134 | \property QValueAxis::labelFormat |
|
134 | \property QValueAxis::labelFormat | |
135 | Defines the label format of the axis. |
|
135 | Defines the label format of the axis. | |
136 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, and c. |
|
136 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, and c. | |
137 | See QString::sprintf() for additional details. |
|
137 | See QString::sprintf() for additional details. | |
138 |
|
138 | |||
139 | If the QChart::localizeNumbers is \c{true}, the supported specifiers are limited to: d, e, E, f, |
|
139 | If the QChart::localizeNumbers is \c{true}, the supported specifiers are limited to: d, e, E, f, | |
140 | g, G, and i. Also, only the precision modifier is supported. The rest of the formatting comes from |
|
140 | g, G, and i. Also, only the precision modifier is supported. The rest of the formatting comes from | |
141 | the default QLocale of the application. |
|
141 | the default QLocale of the application. | |
142 | */ |
|
142 | */ | |
143 | /*! |
|
143 | /*! | |
144 | \qmlproperty real ValueAxis::labelFormat |
|
144 | \qmlproperty real ValueAxis::labelFormat | |
145 | Defines the label format of the axis. |
|
145 | Defines the label format of the axis. | |
146 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, and c. |
|
146 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, and c. | |
147 | See QString::sprintf() for additional details. |
|
147 | See QString::sprintf() for additional details. | |
148 |
|
148 | |||
149 | If the ChartView::localizeNumbers is \c{true}, the supported specifiers are limited to: d, e, E, f, |
|
149 | If the ChartView::localizeNumbers is \c{true}, the supported specifiers are limited to: d, e, E, f, | |
150 | g, G, and i. Also, only the precision modifier is supported. The rest of the formatting comes from |
|
150 | g, G, and i. Also, only the precision modifier is supported. The rest of the formatting comes from | |
151 | the default QLocale of the application. |
|
151 | the default QLocale of the application. | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | \fn void QValueAxis::minChanged(qreal min) |
|
155 | \fn void QValueAxis::minChanged(qreal min) | |
156 | Axis emits signal when \a min of axis has changed. |
|
156 | Axis emits signal when \a min of axis has changed. | |
157 | */ |
|
157 | */ | |
158 | /*! |
|
158 | /*! | |
159 | \qmlsignal ValueAxis::onMinChanged(real min) |
|
159 | \qmlsignal ValueAxis::onMinChanged(real min) | |
160 | Axis emits signal when \a min of axis has changed. |
|
160 | Axis emits signal when \a min of axis has changed. | |
161 | */ |
|
161 | */ | |
162 |
|
162 | |||
163 | /*! |
|
163 | /*! | |
164 | \fn void QValueAxis::maxChanged(qreal max) |
|
164 | \fn void QValueAxis::maxChanged(qreal max) | |
165 | Axis emits signal when \a max of axis has changed. |
|
165 | Axis emits signal when \a max of axis has changed. | |
166 | */ |
|
166 | */ | |
167 | /*! |
|
167 | /*! | |
168 | \qmlsignal ValueAxis::onMaxChanged(real max) |
|
168 | \qmlsignal ValueAxis::onMaxChanged(real max) | |
169 | Axis emits signal when \a max of axis has changed. |
|
169 | Axis emits signal when \a max of axis has changed. | |
170 | */ |
|
170 | */ | |
171 |
|
171 | |||
172 | /*! |
|
172 | /*! | |
173 | \fn void QValueAxis::tickCountChanged(int tickCount) |
|
173 | \fn void QValueAxis::tickCountChanged(int tickCount) | |
174 | Axis emits signal when \a tickCount of axis has changed. |
|
174 | Axis emits signal when \a tickCount of axis has changed. | |
175 | */ |
|
175 | */ | |
176 | /*! |
|
176 | /*! | |
177 | \qmlsignal ValueAxis::tickCountChanged(int tickCount) |
|
177 | \qmlsignal ValueAxis::tickCountChanged(int tickCount) | |
178 | Axis emits signal when \a tickCount of axis has changed. |
|
178 | Axis emits signal when \a tickCount of axis has changed. | |
179 | */ |
|
179 | */ | |
180 |
|
180 | |||
181 | /*! |
|
181 | /*! | |
182 | \fn void QValueAxis::minorTickCountChanged(int minorTickCount) |
|
182 | \fn void QValueAxis::minorTickCountChanged(int minorTickCount) | |
183 | Axis emits signal when \a minorTickCount of axis has changed. |
|
183 | Axis emits signal when \a minorTickCount of axis has changed. | |
184 | */ |
|
184 | */ | |
185 | /*! |
|
185 | /*! | |
186 | \qmlsignal ValueAxis::minorTickCountChanged(int minorTickCount) |
|
186 | \qmlsignal ValueAxis::minorTickCountChanged(int minorTickCount) | |
187 | Axis emits signal when \a minorTickCount of axis has changed. |
|
187 | Axis emits signal when \a minorTickCount of axis has changed. | |
188 | */ |
|
188 | */ | |
189 |
|
189 | |||
190 | /*! |
|
190 | /*! | |
191 | \fn void QValueAxis::rangeChanged(qreal min, qreal max) |
|
191 | \fn void QValueAxis::rangeChanged(qreal min, qreal max) | |
192 | Axis emits signal when \a min or \a max of axis has changed. |
|
192 | Axis emits signal when \a min or \a max of axis has changed. | |
193 | */ |
|
193 | */ | |
194 |
|
194 | |||
195 | /*! |
|
195 | /*! | |
196 | \fn void QValueAxis::labelFormatChanged(const QString &format) |
|
196 | \fn void QValueAxis::labelFormatChanged(const QString &format) | |
197 | Axis emits signal when \a format of axis labels has changed. |
|
197 | Axis emits signal when \a format of axis labels has changed. | |
198 | */ |
|
198 | */ | |
199 | /*! |
|
199 | /*! | |
200 | \qmlsignal ValueAxis::labelFormatChanged(const QString &format) |
|
200 | \qmlsignal ValueAxis::labelFormatChanged(const QString &format) | |
201 | Axis emits signal when \a format of axis labels has changed. |
|
201 | Axis emits signal when \a format of axis labels has changed. | |
202 | */ |
|
202 | */ | |
203 |
|
203 | |||
204 | /*! |
|
204 | /*! | |
205 | Constructs an axis object which is a child of \a parent. |
|
205 | Constructs an axis object which is a child of \a parent. | |
206 | */ |
|
206 | */ | |
207 | QValueAxis::QValueAxis(QObject *parent) : |
|
207 | QValueAxis::QValueAxis(QObject *parent) : | |
208 | QAbstractAxis(*new QValueAxisPrivate(this), parent) |
|
208 | QAbstractAxis(*new QValueAxisPrivate(this), parent) | |
209 | { |
|
209 | { | |
210 |
|
210 | |||
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | /*! |
|
213 | /*! | |
214 | \internal |
|
214 | \internal | |
215 | */ |
|
215 | */ | |
216 | QValueAxis::QValueAxis(QValueAxisPrivate &d, QObject *parent) |
|
216 | QValueAxis::QValueAxis(QValueAxisPrivate &d, QObject *parent) | |
217 | : QAbstractAxis(d, parent) |
|
217 | : QAbstractAxis(d, parent) | |
218 | { |
|
218 | { | |
219 |
|
219 | |||
220 | } |
|
220 | } | |
221 |
|
221 | |||
222 | /*! |
|
222 | /*! | |
223 | Destroys the object |
|
223 | Destroys the object | |
224 | */ |
|
224 | */ | |
225 | QValueAxis::~QValueAxis() |
|
225 | QValueAxis::~QValueAxis() | |
226 | { |
|
226 | { | |
227 | Q_D(QValueAxis); |
|
227 | Q_D(QValueAxis); | |
228 | if (d->m_chart) |
|
228 | if (d->m_chart) | |
229 | d->m_chart->removeAxis(this); |
|
229 | d->m_chart->removeAxis(this); | |
230 | } |
|
230 | } | |
231 |
|
231 | |||
232 | void QValueAxis::setMin(qreal min) |
|
232 | void QValueAxis::setMin(qreal min) | |
233 | { |
|
233 | { | |
234 | Q_D(QValueAxis); |
|
234 | Q_D(QValueAxis); | |
235 | setRange(min, qMax(d->m_max, min)); |
|
235 | setRange(min, qMax(d->m_max, min)); | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | qreal QValueAxis::min() const |
|
238 | qreal QValueAxis::min() const | |
239 | { |
|
239 | { | |
240 | Q_D(const QValueAxis); |
|
240 | Q_D(const QValueAxis); | |
241 | return d->m_min; |
|
241 | return d->m_min; | |
242 | } |
|
242 | } | |
243 |
|
243 | |||
244 | void QValueAxis::setMax(qreal max) |
|
244 | void QValueAxis::setMax(qreal max) | |
245 | { |
|
245 | { | |
246 | Q_D(QValueAxis); |
|
246 | Q_D(QValueAxis); | |
247 | setRange(qMin(d->m_min, max), max); |
|
247 | setRange(qMin(d->m_min, max), max); | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | qreal QValueAxis::max() const |
|
250 | qreal QValueAxis::max() const | |
251 | { |
|
251 | { | |
252 | Q_D(const QValueAxis); |
|
252 | Q_D(const QValueAxis); | |
253 | return d->m_max; |
|
253 | return d->m_max; | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
256 | /*! |
|
256 | /*! | |
257 | Sets range from \a min to \a max on the axis. |
|
257 | Sets range from \a min to \a max on the axis. | |
258 | If min is greater than max then this function returns without making any changes. |
|
258 | If min is greater than max then this function returns without making any changes. | |
259 | */ |
|
259 | */ | |
260 | void QValueAxis::setRange(qreal min, qreal max) |
|
260 | void QValueAxis::setRange(qreal min, qreal max) | |
261 | { |
|
261 | { | |
262 | Q_D(QValueAxis); |
|
262 | Q_D(QValueAxis); | |
263 | d->setRange(min,max); |
|
263 | d->setRange(min,max); | |
264 | } |
|
264 | } | |
265 |
|
265 | |||
266 | void QValueAxis::setTickCount(int count) |
|
266 | void QValueAxis::setTickCount(int count) | |
267 | { |
|
267 | { | |
268 | Q_D(QValueAxis); |
|
268 | Q_D(QValueAxis); | |
269 | if (d->m_tickCount != count && count >= 2) { |
|
269 | if (d->m_tickCount != count && count >= 2) { | |
270 | d->m_tickCount = count; |
|
270 | d->m_tickCount = count; | |
271 | emit tickCountChanged(count); |
|
271 | emit tickCountChanged(count); | |
272 | } |
|
272 | } | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | int QValueAxis::tickCount() const |
|
275 | int QValueAxis::tickCount() const | |
276 | { |
|
276 | { | |
277 | Q_D(const QValueAxis); |
|
277 | Q_D(const QValueAxis); | |
278 | return d->m_tickCount; |
|
278 | return d->m_tickCount; | |
279 | } |
|
279 | } | |
280 |
|
280 | |||
281 | void QValueAxis::setMinorTickCount(int count) |
|
281 | void QValueAxis::setMinorTickCount(int count) | |
282 | { |
|
282 | { | |
283 | Q_D(QValueAxis); |
|
283 | Q_D(QValueAxis); | |
284 | if (d->m_minorTickCount != count && count >= 0) { |
|
284 | if (d->m_minorTickCount != count && count >= 0) { | |
285 | d->m_minorTickCount = count; |
|
285 | d->m_minorTickCount = count; | |
286 | emit minorTickCountChanged(count); |
|
286 | emit minorTickCountChanged(count); | |
287 | } |
|
287 | } | |
288 | } |
|
288 | } | |
289 |
|
289 | |||
290 | int QValueAxis::minorTickCount() const |
|
290 | int QValueAxis::minorTickCount() const | |
291 | { |
|
291 | { | |
292 | Q_D(const QValueAxis); |
|
292 | Q_D(const QValueAxis); | |
293 | return d->m_minorTickCount; |
|
293 | return d->m_minorTickCount; | |
294 | } |
|
294 | } | |
295 |
|
295 | |||
296 | void QValueAxis::setLabelFormat(const QString &format) |
|
296 | void QValueAxis::setLabelFormat(const QString &format) | |
297 | { |
|
297 | { | |
298 | Q_D(QValueAxis); |
|
298 | Q_D(QValueAxis); | |
299 | d->m_format = format; |
|
299 | d->m_format = format; | |
300 | emit labelFormatChanged(format); |
|
300 | emit labelFormatChanged(format); | |
301 | } |
|
301 | } | |
302 |
|
302 | |||
303 | QString QValueAxis::labelFormat() const |
|
303 | QString QValueAxis::labelFormat() const | |
304 | { |
|
304 | { | |
305 | Q_D(const QValueAxis); |
|
305 | Q_D(const QValueAxis); | |
306 | return d->m_format; |
|
306 | return d->m_format; | |
307 | } |
|
307 | } | |
308 |
|
308 | |||
309 | /*! |
|
309 | /*! | |
310 | Returns the type of the axis |
|
310 | Returns the type of the axis | |
311 | */ |
|
311 | */ | |
312 | QAbstractAxis::AxisType QValueAxis::type() const |
|
312 | QAbstractAxis::AxisType QValueAxis::type() const | |
313 | { |
|
313 | { | |
314 | return AxisTypeValue; |
|
314 | return AxisTypeValue; | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | /*! |
|
317 | /*! | |
318 | This method modifies range and number of ticks on the axis to look "nice". Algorithm considers numbers that |
|
318 | This method modifies range and number of ticks on the axis to look "nice". Algorithm considers numbers that | |
319 | can be expressed as form of 1*10^n, 2* 10^n or 5*10^n as a nice numbers. These numbers are used for spacing the ticks. |
|
319 | can be expressed as form of 1*10^n, 2* 10^n or 5*10^n as a nice numbers. These numbers are used for spacing the ticks. | |
320 | This method will modify the current range and number of ticks. |
|
320 | This method will modify the current range and number of ticks. | |
321 | \sa setRange(), setTickCount() |
|
321 | \sa setRange(), setTickCount() | |
322 | */ |
|
322 | */ | |
323 | void QValueAxis::applyNiceNumbers() |
|
323 | void QValueAxis::applyNiceNumbers() | |
324 | { |
|
324 | { | |
325 | Q_D(QValueAxis); |
|
325 | Q_D(QValueAxis); | |
326 | if(d->m_applying) return; |
|
326 | if(d->m_applying) return; | |
327 | qreal min = d->m_min; |
|
327 | qreal min = d->m_min; | |
328 | qreal max = d->m_max; |
|
328 | qreal max = d->m_max; | |
329 | int ticks = d->m_tickCount; |
|
329 | int ticks = d->m_tickCount; | |
330 | AbstractDomain::looseNiceNumbers(min,max,ticks); |
|
330 | AbstractDomain::looseNiceNumbers(min,max,ticks); | |
331 | d->m_applying=true; |
|
331 | d->m_applying=true; | |
332 | d->setRange(min,max); |
|
332 | d->setRange(min,max); | |
333 | setTickCount(ticks); |
|
333 | setTickCount(ticks); | |
334 | d->m_applying=false; |
|
334 | d->m_applying=false; | |
335 | } |
|
335 | } | |
336 |
|
336 | |||
337 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
337 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
338 |
|
338 | |||
339 | QValueAxisPrivate::QValueAxisPrivate(QValueAxis *q) |
|
339 | QValueAxisPrivate::QValueAxisPrivate(QValueAxis *q) | |
340 | : QAbstractAxisPrivate(q), |
|
340 | : QAbstractAxisPrivate(q), | |
341 | m_min(0), |
|
341 | m_min(0), | |
342 | m_max(0), |
|
342 | m_max(0), | |
343 | m_tickCount(5), |
|
343 | m_tickCount(5), | |
344 | m_minorTickCount(0), |
|
344 | m_minorTickCount(0), | |
345 | m_format(QString::null), |
|
345 | m_format(QString::null), | |
346 | m_applying(false) |
|
346 | m_applying(false) | |
347 | { |
|
347 | { | |
348 |
|
348 | |||
349 | } |
|
349 | } | |
350 |
|
350 | |||
351 | QValueAxisPrivate::~QValueAxisPrivate() |
|
351 | QValueAxisPrivate::~QValueAxisPrivate() | |
352 | { |
|
352 | { | |
353 |
|
353 | |||
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | void QValueAxisPrivate::setMin(const QVariant &min) |
|
356 | void QValueAxisPrivate::setMin(const QVariant &min) | |
357 | { |
|
357 | { | |
358 | Q_Q(QValueAxis); |
|
358 | Q_Q(QValueAxis); | |
359 | bool ok; |
|
359 | bool ok; | |
360 | qreal value = min.toReal(&ok); |
|
360 | qreal value = min.toReal(&ok); | |
361 | if (ok) |
|
361 | if (ok) | |
362 | q->setMin(value); |
|
362 | q->setMin(value); | |
363 | } |
|
363 | } | |
364 |
|
364 | |||
365 | void QValueAxisPrivate::setMax(const QVariant &max) |
|
365 | void QValueAxisPrivate::setMax(const QVariant &max) | |
366 | { |
|
366 | { | |
367 | Q_Q(QValueAxis); |
|
367 | Q_Q(QValueAxis); | |
368 | bool ok; |
|
368 | bool ok; | |
369 | qreal value = max.toReal(&ok); |
|
369 | qreal value = max.toReal(&ok); | |
370 | if (ok) |
|
370 | if (ok) | |
371 | q->setMax(value); |
|
371 | q->setMax(value); | |
372 | } |
|
372 | } | |
373 |
|
373 | |||
374 | void QValueAxisPrivate::setRange(const QVariant &min, const QVariant &max) |
|
374 | void QValueAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |
375 | { |
|
375 | { | |
376 | Q_Q(QValueAxis); |
|
376 | Q_Q(QValueAxis); | |
377 | bool ok1; |
|
377 | bool ok1; | |
378 | bool ok2; |
|
378 | bool ok2; | |
379 | qreal value1 = min.toReal(&ok1); |
|
379 | qreal value1 = min.toReal(&ok1); | |
380 | qreal value2 = max.toReal(&ok2); |
|
380 | qreal value2 = max.toReal(&ok2); | |
381 | if (ok1 && ok2) |
|
381 | if (ok1 && ok2) | |
382 | q->setRange(value1, value2); |
|
382 | q->setRange(value1, value2); | |
383 | } |
|
383 | } | |
384 |
|
384 | |||
385 | void QValueAxisPrivate::setRange(qreal min, qreal max) |
|
385 | void QValueAxisPrivate::setRange(qreal min, qreal max) | |
386 | { |
|
386 | { | |
387 | Q_Q(QValueAxis); |
|
387 | Q_Q(QValueAxis); | |
388 | bool changed = false; |
|
388 | bool changed = false; | |
389 |
|
389 | |||
390 | if (min > max) |
|
390 | if (min > max) | |
391 | return; |
|
391 | return; | |
392 |
|
392 | |||
|
393 | if (!isValidValue(min, max)) { | |||
|
394 | qWarning() << "Attempting to set invalid range for value axis: [" | |||
|
395 | << min << " - " << max << "]"; | |||
|
396 | return; | |||
|
397 | } | |||
|
398 | ||||
393 | bool changeMin = false; |
|
399 | bool changeMin = false; | |
394 | if (m_min == 0 || min == 0) |
|
400 | if (m_min == 0 || min == 0) | |
395 | changeMin = !qFuzzyCompare(1 + m_min, 1 + min); |
|
401 | changeMin = !qFuzzyCompare(1 + m_min, 1 + min); | |
396 | else |
|
402 | else | |
397 | changeMin = !qFuzzyCompare(m_min, min); |
|
403 | changeMin = !qFuzzyCompare(m_min, min); | |
398 |
|
404 | |||
399 | bool changeMax = false; |
|
405 | bool changeMax = false; | |
400 | if (m_max == 0 || max == 0) |
|
406 | if (m_max == 0 || max == 0) | |
401 | changeMax = !qFuzzyCompare(1 + m_max, 1 + max); |
|
407 | changeMax = !qFuzzyCompare(1 + m_max, 1 + max); | |
402 | else |
|
408 | else | |
403 | changeMax = !qFuzzyCompare(m_max, max); |
|
409 | changeMax = !qFuzzyCompare(m_max, max); | |
404 |
|
410 | |||
405 | if (changeMin) { |
|
411 | if (changeMin) { | |
406 | m_min = min; |
|
412 | m_min = min; | |
407 | changed = true; |
|
413 | changed = true; | |
408 | emit q->minChanged(min); |
|
414 | emit q->minChanged(min); | |
409 | } |
|
415 | } | |
410 |
|
416 | |||
411 | if (changeMax) { |
|
417 | if (changeMax) { | |
412 | m_max = max; |
|
418 | m_max = max; | |
413 | changed = true; |
|
419 | changed = true; | |
414 | emit q->maxChanged(max); |
|
420 | emit q->maxChanged(max); | |
415 | } |
|
421 | } | |
416 |
|
422 | |||
417 | if (changed) { |
|
423 | if (changed) { | |
418 | emit rangeChanged(min,max); |
|
424 | emit rangeChanged(min,max); | |
419 | emit q->rangeChanged(min, max); |
|
425 | emit q->rangeChanged(min, max); | |
420 | } |
|
426 | } | |
421 | } |
|
427 | } | |
422 |
|
428 | |||
423 | void QValueAxisPrivate::initializeGraphics(QGraphicsItem *parent) |
|
429 | void QValueAxisPrivate::initializeGraphics(QGraphicsItem *parent) | |
424 | { |
|
430 | { | |
425 | Q_Q(QValueAxis); |
|
431 | Q_Q(QValueAxis); | |
426 | ChartAxisElement *axis(0); |
|
432 | ChartAxisElement *axis(0); | |
427 |
|
433 | |||
428 | if (m_chart->chartType() == QChart::ChartTypeCartesian) { |
|
434 | if (m_chart->chartType() == QChart::ChartTypeCartesian) { | |
429 | if (orientation() == Qt::Vertical) |
|
435 | if (orientation() == Qt::Vertical) | |
430 | axis = new ChartValueAxisY(q,parent); |
|
436 | axis = new ChartValueAxisY(q,parent); | |
431 | if (orientation() == Qt::Horizontal) |
|
437 | if (orientation() == Qt::Horizontal) | |
432 | axis = new ChartValueAxisX(q,parent); |
|
438 | axis = new ChartValueAxisX(q,parent); | |
433 | } |
|
439 | } | |
434 |
|
440 | |||
435 | if (m_chart->chartType() == QChart::ChartTypePolar) { |
|
441 | if (m_chart->chartType() == QChart::ChartTypePolar) { | |
436 | if (orientation() == Qt::Vertical) |
|
442 | if (orientation() == Qt::Vertical) | |
437 | axis = new PolarChartValueAxisRadial(q, parent); |
|
443 | axis = new PolarChartValueAxisRadial(q, parent); | |
438 | if (orientation() == Qt::Horizontal) |
|
444 | if (orientation() == Qt::Horizontal) | |
439 | axis = new PolarChartValueAxisAngular(q, parent); |
|
445 | axis = new PolarChartValueAxisAngular(q, parent); | |
440 | } |
|
446 | } | |
441 |
|
447 | |||
442 | m_item.reset(axis); |
|
448 | m_item.reset(axis); | |
443 | QAbstractAxisPrivate::initializeGraphics(parent); |
|
449 | QAbstractAxisPrivate::initializeGraphics(parent); | |
444 | } |
|
450 | } | |
445 |
|
451 | |||
446 |
|
452 | |||
447 | void QValueAxisPrivate::initializeDomain(AbstractDomain *domain) |
|
453 | void QValueAxisPrivate::initializeDomain(AbstractDomain *domain) | |
448 | { |
|
454 | { | |
449 | if (orientation() == Qt::Vertical) { |
|
455 | if (orientation() == Qt::Vertical) { | |
450 | if (!qFuzzyIsNull(m_max - m_min)) |
|
456 | if (!qFuzzyIsNull(m_max - m_min)) | |
451 | domain->setRangeY(m_min, m_max); |
|
457 | domain->setRangeY(m_min, m_max); | |
452 | else |
|
458 | else | |
453 | setRange(domain->minY(), domain->maxY()); |
|
459 | setRange(domain->minY(), domain->maxY()); | |
454 | } |
|
460 | } | |
455 | if (orientation() == Qt::Horizontal) { |
|
461 | if (orientation() == Qt::Horizontal) { | |
456 | if (!qFuzzyIsNull(m_max - m_min)) |
|
462 | if (!qFuzzyIsNull(m_max - m_min)) | |
457 | domain->setRangeX(m_min, m_max); |
|
463 | domain->setRangeX(m_min, m_max); | |
458 | else |
|
464 | else | |
459 | setRange(domain->minX(), domain->maxX()); |
|
465 | setRange(domain->minX(), domain->maxX()); | |
460 | } |
|
466 | } | |
461 | } |
|
467 | } | |
462 |
|
468 | |||
463 | #include "moc_qvalueaxis.cpp" |
|
469 | #include "moc_qvalueaxis.cpp" | |
464 | #include "moc_qvalueaxis_p.cpp" |
|
470 | #include "moc_qvalueaxis_p.cpp" | |
465 |
|
471 | |||
466 | QT_CHARTS_END_NAMESPACE |
|
472 | QT_CHARTS_END_NAMESPACE |
@@ -1,92 +1,92 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QVALUEAXIS_H |
|
30 | #ifndef QVALUEAXIS_H | |
31 | #define QVALUEAXIS_H |
|
31 | #define QVALUEAXIS_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractAxis> |
|
33 | #include <QtCharts/QAbstractAxis> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QValueAxisPrivate; |
|
37 | class QValueAxisPrivate; | |
38 |
|
38 | |||
39 | class QT_CHARTS_EXPORT QValueAxis : public QAbstractAxis |
|
39 | class QT_CHARTS_EXPORT QValueAxis : public QAbstractAxis | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount NOTIFY tickCountChanged) |
|
42 | Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount NOTIFY tickCountChanged) | |
43 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) |
|
43 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) | |
44 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) |
|
44 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) | |
45 | Q_PROPERTY(QString labelFormat READ labelFormat WRITE setLabelFormat NOTIFY labelFormatChanged) |
|
45 | Q_PROPERTY(QString labelFormat READ labelFormat WRITE setLabelFormat NOTIFY labelFormatChanged) | |
46 | Q_PROPERTY(int minorTickCount READ minorTickCount WRITE setMinorTickCount NOTIFY minorTickCountChanged) |
|
46 | Q_PROPERTY(int minorTickCount READ minorTickCount WRITE setMinorTickCount NOTIFY minorTickCountChanged) | |
47 |
|
47 | |||
48 | public: |
|
48 | public: | |
49 |
explicit QValueAxis(QObject *parent = |
|
49 | explicit QValueAxis(QObject *parent = Q_NULLPTR); | |
50 | ~QValueAxis(); |
|
50 | ~QValueAxis(); | |
51 |
|
51 | |||
52 | protected: |
|
52 | protected: | |
53 |
QValueAxis(QValueAxisPrivate &d, QObject *parent = |
|
53 | QValueAxis(QValueAxisPrivate &d, QObject *parent = Q_NULLPTR); | |
54 |
|
54 | |||
55 | public: |
|
55 | public: | |
56 | AxisType type() const; |
|
56 | AxisType type() const; | |
57 |
|
57 | |||
58 | //range handling |
|
58 | //range handling | |
59 | void setMin(qreal min); |
|
59 | void setMin(qreal min); | |
60 | qreal min() const; |
|
60 | qreal min() const; | |
61 | void setMax(qreal max); |
|
61 | void setMax(qreal max); | |
62 | qreal max() const; |
|
62 | qreal max() const; | |
63 | void setRange(qreal min, qreal max); |
|
63 | void setRange(qreal min, qreal max); | |
64 |
|
64 | |||
65 | //ticks handling |
|
65 | //ticks handling | |
66 | void setTickCount(int count); |
|
66 | void setTickCount(int count); | |
67 | int tickCount() const; |
|
67 | int tickCount() const; | |
68 | void setMinorTickCount(int count); |
|
68 | void setMinorTickCount(int count); | |
69 | int minorTickCount() const; |
|
69 | int minorTickCount() const; | |
70 |
|
70 | |||
71 | void setLabelFormat(const QString &format); |
|
71 | void setLabelFormat(const QString &format); | |
72 | QString labelFormat() const; |
|
72 | QString labelFormat() const; | |
73 |
|
73 | |||
74 | public Q_SLOTS: |
|
74 | public Q_SLOTS: | |
75 | void applyNiceNumbers(); |
|
75 | void applyNiceNumbers(); | |
76 |
|
76 | |||
77 | Q_SIGNALS: |
|
77 | Q_SIGNALS: | |
78 | void minChanged(qreal min); |
|
78 | void minChanged(qreal min); | |
79 | void maxChanged(qreal max); |
|
79 | void maxChanged(qreal max); | |
80 | void rangeChanged(qreal min, qreal max); |
|
80 | void rangeChanged(qreal min, qreal max); | |
81 | void tickCountChanged(int tickCount); |
|
81 | void tickCountChanged(int tickCount); | |
82 | void minorTickCountChanged(int tickCount); |
|
82 | void minorTickCountChanged(int tickCount); | |
83 | void labelFormatChanged(const QString &format); |
|
83 | void labelFormatChanged(const QString &format); | |
84 |
|
84 | |||
85 | private: |
|
85 | private: | |
86 | Q_DECLARE_PRIVATE(QValueAxis) |
|
86 | Q_DECLARE_PRIVATE(QValueAxis) | |
87 | Q_DISABLE_COPY(QValueAxis) |
|
87 | Q_DISABLE_COPY(QValueAxis) | |
88 | }; |
|
88 | }; | |
89 |
|
89 | |||
90 | QT_CHARTS_END_NAMESPACE |
|
90 | QT_CHARTS_END_NAMESPACE | |
91 |
|
91 | |||
92 | #endif // QVALUEAXIS_H |
|
92 | #endif // QVALUEAXIS_H |
@@ -1,54 +1,54 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QHORIZONTALBARSERIES_H |
|
30 | #ifndef QHORIZONTALBARSERIES_H | |
31 | #define QHORIZONTALBARSERIES_H |
|
31 | #define QHORIZONTALBARSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractBarSeries> |
|
33 | #include <QtCharts/QAbstractBarSeries> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QHorizontalBarSeriesPrivate; |
|
37 | class QHorizontalBarSeriesPrivate; | |
38 |
|
38 | |||
39 | class QT_CHARTS_EXPORT QHorizontalBarSeries : public QAbstractBarSeries |
|
39 | class QT_CHARTS_EXPORT QHorizontalBarSeries : public QAbstractBarSeries | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 |
explicit QHorizontalBarSeries(QObject *parent = |
|
43 | explicit QHorizontalBarSeries(QObject *parent = Q_NULLPTR); | |
44 | ~QHorizontalBarSeries(); |
|
44 | ~QHorizontalBarSeries(); | |
45 | QAbstractSeries::SeriesType type() const; |
|
45 | QAbstractSeries::SeriesType type() const; | |
46 |
|
46 | |||
47 | private: |
|
47 | private: | |
48 | Q_DECLARE_PRIVATE(QHorizontalBarSeries) |
|
48 | Q_DECLARE_PRIVATE(QHorizontalBarSeries) | |
49 | Q_DISABLE_COPY(QHorizontalBarSeries) |
|
49 | Q_DISABLE_COPY(QHorizontalBarSeries) | |
50 | }; |
|
50 | }; | |
51 |
|
51 | |||
52 | QT_CHARTS_END_NAMESPACE |
|
52 | QT_CHARTS_END_NAMESPACE | |
53 |
|
53 | |||
54 | #endif // QHORIZONTALBARSERIES_H |
|
54 | #endif // QHORIZONTALBARSERIES_H |
@@ -1,54 +1,54 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QHORIZONTALPERCENTBARSERIES_H |
|
30 | #ifndef QHORIZONTALPERCENTBARSERIES_H | |
31 | #define QHORIZONTALPERCENTBARSERIES_H |
|
31 | #define QHORIZONTALPERCENTBARSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractBarSeries> |
|
33 | #include <QtCharts/QAbstractBarSeries> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QHorizontalPercentBarSeriesPrivate; |
|
37 | class QHorizontalPercentBarSeriesPrivate; | |
38 |
|
38 | |||
39 | class QT_CHARTS_EXPORT QHorizontalPercentBarSeries : public QAbstractBarSeries |
|
39 | class QT_CHARTS_EXPORT QHorizontalPercentBarSeries : public QAbstractBarSeries | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 |
explicit QHorizontalPercentBarSeries(QObject *parent = |
|
43 | explicit QHorizontalPercentBarSeries(QObject *parent = Q_NULLPTR); | |
44 | ~QHorizontalPercentBarSeries(); |
|
44 | ~QHorizontalPercentBarSeries(); | |
45 | QAbstractSeries::SeriesType type() const; |
|
45 | QAbstractSeries::SeriesType type() const; | |
46 |
|
46 | |||
47 | private: |
|
47 | private: | |
48 | Q_DECLARE_PRIVATE(QHorizontalPercentBarSeries) |
|
48 | Q_DECLARE_PRIVATE(QHorizontalPercentBarSeries) | |
49 | Q_DISABLE_COPY(QHorizontalPercentBarSeries) |
|
49 | Q_DISABLE_COPY(QHorizontalPercentBarSeries) | |
50 | }; |
|
50 | }; | |
51 |
|
51 | |||
52 | QT_CHARTS_END_NAMESPACE |
|
52 | QT_CHARTS_END_NAMESPACE | |
53 |
|
53 | |||
54 | #endif // QHORIZONTALPERCENTBARSERIES_H |
|
54 | #endif // QHORIZONTALPERCENTBARSERIES_H |
@@ -1,54 +1,54 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QHORIZONTALSTACKEDBARSERIES_H |
|
30 | #ifndef QHORIZONTALSTACKEDBARSERIES_H | |
31 | #define QHORIZONTALSTACKEDBARSERIES_H |
|
31 | #define QHORIZONTALSTACKEDBARSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractBarSeries> |
|
33 | #include <QtCharts/QAbstractBarSeries> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QHorizontalStackedBarSeriesPrivate; |
|
37 | class QHorizontalStackedBarSeriesPrivate; | |
38 |
|
38 | |||
39 | class QT_CHARTS_EXPORT QHorizontalStackedBarSeries : public QAbstractBarSeries |
|
39 | class QT_CHARTS_EXPORT QHorizontalStackedBarSeries : public QAbstractBarSeries | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 |
explicit QHorizontalStackedBarSeries(QObject *parent = |
|
43 | explicit QHorizontalStackedBarSeries(QObject *parent = Q_NULLPTR); | |
44 | ~QHorizontalStackedBarSeries(); |
|
44 | ~QHorizontalStackedBarSeries(); | |
45 | QAbstractSeries::SeriesType type() const; |
|
45 | QAbstractSeries::SeriesType type() const; | |
46 |
|
46 | |||
47 | private: |
|
47 | private: | |
48 | Q_DECLARE_PRIVATE(QHorizontalStackedBarSeries) |
|
48 | Q_DECLARE_PRIVATE(QHorizontalStackedBarSeries) | |
49 | Q_DISABLE_COPY(QHorizontalStackedBarSeries) |
|
49 | Q_DISABLE_COPY(QHorizontalStackedBarSeries) | |
50 | }; |
|
50 | }; | |
51 |
|
51 | |||
52 | QT_CHARTS_END_NAMESPACE |
|
52 | QT_CHARTS_END_NAMESPACE | |
53 |
|
53 | |||
54 | #endif // QHORIZONTALSTACKEDBARSERIES_H |
|
54 | #endif // QHORIZONTALSTACKEDBARSERIES_H |
@@ -1,121 +1,121 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QABSTRACTBARSERIES_H |
|
30 | #ifndef QABSTRACTBARSERIES_H | |
31 | #define QABSTRACTBARSERIES_H |
|
31 | #define QABSTRACTBARSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractSeries> |
|
33 | #include <QtCharts/QAbstractSeries> | |
34 | #include <QtCore/QStringList> |
|
34 | #include <QtCore/QStringList> | |
35 |
|
35 | |||
36 | QT_CHARTS_BEGIN_NAMESPACE |
|
36 | QT_CHARTS_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QBarSet; |
|
38 | class QBarSet; | |
39 | class QAbstractBarSeriesPrivate; |
|
39 | class QAbstractBarSeriesPrivate; | |
40 |
|
40 | |||
41 | // Container for series |
|
41 | // Container for series | |
42 | class QT_CHARTS_EXPORT QAbstractBarSeries : public QAbstractSeries |
|
42 | class QT_CHARTS_EXPORT QAbstractBarSeries : public QAbstractSeries | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 | Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth) |
|
45 | Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth) | |
46 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
46 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
47 | Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
47 | Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) | |
48 | Q_PROPERTY(QString labelsFormat READ labelsFormat WRITE setLabelsFormat NOTIFY labelsFormatChanged) |
|
48 | Q_PROPERTY(QString labelsFormat READ labelsFormat WRITE setLabelsFormat NOTIFY labelsFormatChanged) | |
49 | Q_PROPERTY(LabelsPosition labelsPosition READ labelsPosition WRITE setLabelsPosition NOTIFY labelsPositionChanged) |
|
49 | Q_PROPERTY(LabelsPosition labelsPosition READ labelsPosition WRITE setLabelsPosition NOTIFY labelsPositionChanged) | |
50 | Q_PROPERTY(qreal labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) |
|
50 | Q_PROPERTY(qreal labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) | |
51 | Q_ENUMS(LabelsPosition) |
|
51 | Q_ENUMS(LabelsPosition) | |
52 |
|
52 | |||
53 | public: |
|
53 | public: | |
54 | enum LabelsPosition { |
|
54 | enum LabelsPosition { | |
55 | LabelsCenter = 0, |
|
55 | LabelsCenter = 0, | |
56 | LabelsInsideEnd, |
|
56 | LabelsInsideEnd, | |
57 | LabelsInsideBase, |
|
57 | LabelsInsideBase, | |
58 | LabelsOutsideEnd |
|
58 | LabelsOutsideEnd | |
59 | }; |
|
59 | }; | |
60 |
|
60 | |||
61 | public: |
|
61 | public: | |
62 | virtual ~QAbstractBarSeries(); |
|
62 | virtual ~QAbstractBarSeries(); | |
63 |
|
63 | |||
64 | void setBarWidth(qreal width); |
|
64 | void setBarWidth(qreal width); | |
65 | qreal barWidth() const; |
|
65 | qreal barWidth() const; | |
66 |
|
66 | |||
67 | bool append(QBarSet *set); |
|
67 | bool append(QBarSet *set); | |
68 | bool remove(QBarSet *set); |
|
68 | bool remove(QBarSet *set); | |
69 | bool take(QBarSet *set); |
|
69 | bool take(QBarSet *set); | |
70 | bool append(QList<QBarSet *> sets); |
|
70 | bool append(QList<QBarSet *> sets); | |
71 | bool insert(int index, QBarSet *set); |
|
71 | bool insert(int index, QBarSet *set); | |
72 | int count() const; |
|
72 | int count() const; | |
73 | QList<QBarSet *> barSets() const; |
|
73 | QList<QBarSet *> barSets() const; | |
74 | void clear(); |
|
74 | void clear(); | |
75 |
|
75 | |||
76 | void setLabelsVisible(bool visible = true); |
|
76 | void setLabelsVisible(bool visible = true); | |
77 | bool isLabelsVisible() const; |
|
77 | bool isLabelsVisible() const; | |
78 |
|
78 | |||
79 | void setLabelsFormat(const QString &format); |
|
79 | void setLabelsFormat(const QString &format); | |
80 | QString labelsFormat() const; |
|
80 | QString labelsFormat() const; | |
81 |
|
81 | |||
82 | void setLabelsAngle(qreal angle); |
|
82 | void setLabelsAngle(qreal angle); | |
83 | qreal labelsAngle() const; |
|
83 | qreal labelsAngle() const; | |
84 |
|
84 | |||
85 | void setLabelsPosition(QAbstractBarSeries::LabelsPosition position); |
|
85 | void setLabelsPosition(QAbstractBarSeries::LabelsPosition position); | |
86 | QAbstractBarSeries::LabelsPosition labelsPosition() const; |
|
86 | QAbstractBarSeries::LabelsPosition labelsPosition() const; | |
87 |
|
87 | |||
88 | protected: |
|
88 | protected: | |
89 |
explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent = |
|
89 | explicit QAbstractBarSeries(QAbstractBarSeriesPrivate &d, QObject *parent = Q_NULLPTR); | |
90 |
|
90 | |||
91 | Q_SIGNALS: |
|
91 | Q_SIGNALS: | |
92 | void clicked(int index, QBarSet *barset); |
|
92 | void clicked(int index, QBarSet *barset); | |
93 | void hovered(bool status, int index, QBarSet *barset); |
|
93 | void hovered(bool status, int index, QBarSet *barset); | |
94 | void pressed(int index, QBarSet *barset); |
|
94 | void pressed(int index, QBarSet *barset); | |
95 | void released(int index, QBarSet *barset); |
|
95 | void released(int index, QBarSet *barset); | |
96 | void doubleClicked(int index, QBarSet *barset); |
|
96 | void doubleClicked(int index, QBarSet *barset); | |
97 | void countChanged(); |
|
97 | void countChanged(); | |
98 | void labelsVisibleChanged(); |
|
98 | void labelsVisibleChanged(); | |
99 | void labelsFormatChanged(const QString &format); |
|
99 | void labelsFormatChanged(const QString &format); | |
100 | void labelsPositionChanged(QAbstractBarSeries::LabelsPosition position); |
|
100 | void labelsPositionChanged(QAbstractBarSeries::LabelsPosition position); | |
101 | void labelsAngleChanged(qreal angle); |
|
101 | void labelsAngleChanged(qreal angle); | |
102 |
|
102 | |||
103 | void barsetsAdded(QList<QBarSet *> sets); |
|
103 | void barsetsAdded(QList<QBarSet *> sets); | |
104 | void barsetsRemoved(QList<QBarSet *> sets); |
|
104 | void barsetsRemoved(QList<QBarSet *> sets); | |
105 |
|
105 | |||
106 | protected: |
|
106 | protected: | |
107 | Q_DECLARE_PRIVATE(QAbstractBarSeries) |
|
107 | Q_DECLARE_PRIVATE(QAbstractBarSeries) | |
108 | friend class AbstractBarChartItem; |
|
108 | friend class AbstractBarChartItem; | |
109 | friend class PercentBarChartItem; |
|
109 | friend class PercentBarChartItem; | |
110 | friend class StackedBarChartItem; |
|
110 | friend class StackedBarChartItem; | |
111 | friend class BoxPlotChartItem; |
|
111 | friend class BoxPlotChartItem; | |
112 | friend class BarChartItem; |
|
112 | friend class BarChartItem; | |
113 | friend class HorizontalBarChartItem; |
|
113 | friend class HorizontalBarChartItem; | |
114 | friend class HorizontalStackedBarChartItem; |
|
114 | friend class HorizontalStackedBarChartItem; | |
115 | friend class HorizontalPercentBarChartItem; |
|
115 | friend class HorizontalPercentBarChartItem; | |
116 | friend class BarSet; |
|
116 | friend class BarSet; | |
117 | }; |
|
117 | }; | |
118 |
|
118 | |||
119 | QT_CHARTS_END_NAMESPACE |
|
119 | QT_CHARTS_END_NAMESPACE | |
120 |
|
120 | |||
121 | #endif // QABSTRACTBARSERIES_H |
|
121 | #endif // QABSTRACTBARSERIES_H |
@@ -1,570 +1,571 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #include <QtCharts/QBarModelMapper> |
|
30 | #include <QtCharts/QBarModelMapper> | |
31 | #include <private/qbarmodelmapper_p.h> |
|
31 | #include <private/qbarmodelmapper_p.h> | |
32 | #include <QtCharts/QAbstractBarSeries> |
|
32 | #include <QtCharts/QAbstractBarSeries> | |
33 | #include <QtCharts/QBarSet> |
|
33 | #include <QtCharts/QBarSet> | |
34 | #include <QtCharts/QChart> |
|
34 | #include <QtCharts/QChart> | |
35 | #include <QtCore/QAbstractItemModel> |
|
35 | #include <QtCore/QAbstractItemModel> | |
36 |
|
36 | |||
37 | QT_CHARTS_BEGIN_NAMESPACE |
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | QBarModelMapper::QBarModelMapper(QObject *parent) : |
|
39 | QBarModelMapper::QBarModelMapper(QObject *parent) : | |
40 | QObject(parent), |
|
40 | QObject(parent), | |
41 | d_ptr(new QBarModelMapperPrivate(this)) |
|
41 | d_ptr(new QBarModelMapperPrivate(this)) | |
42 | { |
|
42 | { | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | QAbstractItemModel *QBarModelMapper::model() const |
|
45 | QAbstractItemModel *QBarModelMapper::model() const | |
46 | { |
|
46 | { | |
47 | Q_D(const QBarModelMapper); |
|
47 | Q_D(const QBarModelMapper); | |
48 | return d->m_model; |
|
48 | return d->m_model; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | void QBarModelMapper::setModel(QAbstractItemModel *model) |
|
51 | void QBarModelMapper::setModel(QAbstractItemModel *model) | |
52 | { |
|
52 | { | |
53 | if (model == 0) |
|
53 | if (model == 0) | |
54 | return; |
|
54 | return; | |
55 |
|
55 | |||
56 | Q_D(QBarModelMapper); |
|
56 | Q_D(QBarModelMapper); | |
57 | if (d->m_model) |
|
57 | if (d->m_model) | |
58 | disconnect(d->m_model, 0, d, 0); |
|
58 | disconnect(d->m_model, 0, d, 0); | |
59 |
|
59 | |||
60 | d->m_model = model; |
|
60 | d->m_model = model; | |
61 | d->initializeBarFromModel(); |
|
61 | d->initializeBarFromModel(); | |
62 | // connect signals from the model |
|
62 | // connect signals from the model | |
|
63 | connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializeBarFromModel())); | |||
63 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
64 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
64 | connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int))); |
|
65 | connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int))); | |
65 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); |
|
66 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
66 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); |
|
67 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
67 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); |
|
68 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
68 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); |
|
69 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
69 | connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); |
|
70 | connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); | |
70 | } |
|
71 | } | |
71 |
|
72 | |||
72 | QAbstractBarSeries *QBarModelMapper::series() const |
|
73 | QAbstractBarSeries *QBarModelMapper::series() const | |
73 | { |
|
74 | { | |
74 | Q_D(const QBarModelMapper); |
|
75 | Q_D(const QBarModelMapper); | |
75 | return d->m_series; |
|
76 | return d->m_series; | |
76 | } |
|
77 | } | |
77 |
|
78 | |||
78 | void QBarModelMapper::setSeries(QAbstractBarSeries *series) |
|
79 | void QBarModelMapper::setSeries(QAbstractBarSeries *series) | |
79 | { |
|
80 | { | |
80 | Q_D(QBarModelMapper); |
|
81 | Q_D(QBarModelMapper); | |
81 | if (d->m_series) |
|
82 | if (d->m_series) | |
82 | disconnect(d->m_series, 0, d, 0); |
|
83 | disconnect(d->m_series, 0, d, 0); | |
83 |
|
84 | |||
84 | if (series == 0) |
|
85 | if (series == 0) | |
85 | return; |
|
86 | return; | |
86 |
|
87 | |||
87 | d->m_series = series; |
|
88 | d->m_series = series; | |
88 | d->initializeBarFromModel(); |
|
89 | d->initializeBarFromModel(); | |
89 | // connect the signals from the series |
|
90 | // connect the signals from the series | |
90 | connect(d->m_series, SIGNAL(barsetsAdded(QList<QBarSet*>)), d, SLOT(barSetsAdded(QList<QBarSet*>))); |
|
91 | connect(d->m_series, SIGNAL(barsetsAdded(QList<QBarSet*>)), d, SLOT(barSetsAdded(QList<QBarSet*>))); | |
91 | connect(d->m_series, SIGNAL(barsetsRemoved(QList<QBarSet*>)), d, SLOT(barSetsRemoved(QList<QBarSet*>))); |
|
92 | connect(d->m_series, SIGNAL(barsetsRemoved(QList<QBarSet*>)), d, SLOT(barSetsRemoved(QList<QBarSet*>))); | |
92 | connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); |
|
93 | connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); | |
93 | } |
|
94 | } | |
94 |
|
95 | |||
95 | /*! |
|
96 | /*! | |
96 | Returns which row/column of the model contains the first values of the QBarSets in the series. |
|
97 | Returns which row/column of the model contains the first values of the QBarSets in the series. | |
97 | The default value is 0. |
|
98 | The default value is 0. | |
98 | */ |
|
99 | */ | |
99 | int QBarModelMapper::first() const |
|
100 | int QBarModelMapper::first() const | |
100 | { |
|
101 | { | |
101 | Q_D(const QBarModelMapper); |
|
102 | Q_D(const QBarModelMapper); | |
102 | return d->m_first; |
|
103 | return d->m_first; | |
103 | } |
|
104 | } | |
104 |
|
105 | |||
105 | /*! |
|
106 | /*! | |
106 | Sets which row of the model contains the \a first values of the QBarSets in the series. |
|
107 | Sets which row of the model contains the \a first values of the QBarSets in the series. | |
107 | The default value is 0. |
|
108 | The default value is 0. | |
108 | */ |
|
109 | */ | |
109 | void QBarModelMapper::setFirst(int first) |
|
110 | void QBarModelMapper::setFirst(int first) | |
110 | { |
|
111 | { | |
111 | Q_D(QBarModelMapper); |
|
112 | Q_D(QBarModelMapper); | |
112 | d->m_first = qMax(first, 0); |
|
113 | d->m_first = qMax(first, 0); | |
113 | d->initializeBarFromModel(); |
|
114 | d->initializeBarFromModel(); | |
114 | } |
|
115 | } | |
115 |
|
116 | |||
116 | /*! |
|
117 | /*! | |
117 | Returns the number of rows/columns of the model that are mapped as the data for QAbstractBarSeries |
|
118 | Returns the number of rows/columns of the model that are mapped as the data for QAbstractBarSeries | |
118 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) |
|
119 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) | |
119 | */ |
|
120 | */ | |
120 | int QBarModelMapper::count() const |
|
121 | int QBarModelMapper::count() const | |
121 | { |
|
122 | { | |
122 | Q_D(const QBarModelMapper); |
|
123 | Q_D(const QBarModelMapper); | |
123 | return d->m_count; |
|
124 | return d->m_count; | |
124 | } |
|
125 | } | |
125 |
|
126 | |||
126 | /*! |
|
127 | /*! | |
127 | Sets the \a count of rows/columns of the model that are mapped as the data for QAbstractBarSeries |
|
128 | Sets the \a count of rows/columns of the model that are mapped as the data for QAbstractBarSeries | |
128 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) |
|
129 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) | |
129 | */ |
|
130 | */ | |
130 | void QBarModelMapper::setCount(int count) |
|
131 | void QBarModelMapper::setCount(int count) | |
131 | { |
|
132 | { | |
132 | Q_D(QBarModelMapper); |
|
133 | Q_D(QBarModelMapper); | |
133 | d->m_count = qMax(count, -1); |
|
134 | d->m_count = qMax(count, -1); | |
134 | d->initializeBarFromModel(); |
|
135 | d->initializeBarFromModel(); | |
135 | } |
|
136 | } | |
136 |
|
137 | |||
137 | /*! |
|
138 | /*! | |
138 | Returns the orientation that is used when QBarModelMapper accesses the model. |
|
139 | Returns the orientation that is used when QBarModelMapper accesses the model. | |
139 | This mean whether the consecutive values of the bar set are read from row (Qt::Horizontal) |
|
140 | This mean whether the consecutive values of the bar set are read from row (Qt::Horizontal) | |
140 | or from columns (Qt::Vertical) |
|
141 | or from columns (Qt::Vertical) | |
141 | */ |
|
142 | */ | |
142 | Qt::Orientation QBarModelMapper::orientation() const |
|
143 | Qt::Orientation QBarModelMapper::orientation() const | |
143 | { |
|
144 | { | |
144 | Q_D(const QBarModelMapper); |
|
145 | Q_D(const QBarModelMapper); | |
145 | return d->m_orientation; |
|
146 | return d->m_orientation; | |
146 | } |
|
147 | } | |
147 |
|
148 | |||
148 | /*! |
|
149 | /*! | |
149 | Returns the \a orientation that is used when QBarModelMapper accesses the model. |
|
150 | Returns the \a orientation that is used when QBarModelMapper accesses the model. | |
150 | This mean whether the consecutive values of the pie are read from row (Qt::Horizontal) |
|
151 | This mean whether the consecutive values of the pie are read from row (Qt::Horizontal) | |
151 | or from columns (Qt::Vertical) |
|
152 | or from columns (Qt::Vertical) | |
152 | */ |
|
153 | */ | |
153 | void QBarModelMapper::setOrientation(Qt::Orientation orientation) |
|
154 | void QBarModelMapper::setOrientation(Qt::Orientation orientation) | |
154 | { |
|
155 | { | |
155 | Q_D(QBarModelMapper); |
|
156 | Q_D(QBarModelMapper); | |
156 | d->m_orientation = orientation; |
|
157 | d->m_orientation = orientation; | |
157 | d->initializeBarFromModel(); |
|
158 | d->initializeBarFromModel(); | |
158 | } |
|
159 | } | |
159 |
|
160 | |||
160 | /*! |
|
161 | /*! | |
161 | Returns which section of the model is used as the data source for the first bar set |
|
162 | Returns which section of the model is used as the data source for the first bar set | |
162 | */ |
|
163 | */ | |
163 | int QBarModelMapper::firstBarSetSection() const |
|
164 | int QBarModelMapper::firstBarSetSection() const | |
164 | { |
|
165 | { | |
165 | Q_D(const QBarModelMapper); |
|
166 | Q_D(const QBarModelMapper); | |
166 | return d->m_firstBarSetSection; |
|
167 | return d->m_firstBarSetSection; | |
167 | } |
|
168 | } | |
168 |
|
169 | |||
169 | /*! |
|
170 | /*! | |
170 | Sets the model section that is used as the data source for the first bar set |
|
171 | Sets the model section that is used as the data source for the first bar set | |
171 | Parameter \a firstBarSetSection specifies the section of the model. |
|
172 | Parameter \a firstBarSetSection specifies the section of the model. | |
172 | */ |
|
173 | */ | |
173 | void QBarModelMapper::setFirstBarSetSection(int firstBarSetSection) |
|
174 | void QBarModelMapper::setFirstBarSetSection(int firstBarSetSection) | |
174 | { |
|
175 | { | |
175 | Q_D(QBarModelMapper); |
|
176 | Q_D(QBarModelMapper); | |
176 | d->m_firstBarSetSection = qMax(-1, firstBarSetSection); |
|
177 | d->m_firstBarSetSection = qMax(-1, firstBarSetSection); | |
177 | d->initializeBarFromModel(); |
|
178 | d->initializeBarFromModel(); | |
178 | } |
|
179 | } | |
179 |
|
180 | |||
180 | /*! |
|
181 | /*! | |
181 | Returns which section of the model is used as the data source for the last bar set |
|
182 | Returns which section of the model is used as the data source for the last bar set | |
182 | */ |
|
183 | */ | |
183 | int QBarModelMapper::lastBarSetSection() const |
|
184 | int QBarModelMapper::lastBarSetSection() const | |
184 | { |
|
185 | { | |
185 | Q_D(const QBarModelMapper); |
|
186 | Q_D(const QBarModelMapper); | |
186 | return d->m_lastBarSetSection; |
|
187 | return d->m_lastBarSetSection; | |
187 | } |
|
188 | } | |
188 |
|
189 | |||
189 | /*! |
|
190 | /*! | |
190 | Sets the model section that is used as the data source for the last bar set |
|
191 | Sets the model section that is used as the data source for the last bar set | |
191 | Parameter \a lastBarSetSection specifies the section of the model. |
|
192 | Parameter \a lastBarSetSection specifies the section of the model. | |
192 | */ |
|
193 | */ | |
193 | void QBarModelMapper::setLastBarSetSection(int lastBarSetSection) |
|
194 | void QBarModelMapper::setLastBarSetSection(int lastBarSetSection) | |
194 | { |
|
195 | { | |
195 | Q_D(QBarModelMapper); |
|
196 | Q_D(QBarModelMapper); | |
196 | d->m_lastBarSetSection = qMax(-1, lastBarSetSection); |
|
197 | d->m_lastBarSetSection = qMax(-1, lastBarSetSection); | |
197 | d->initializeBarFromModel(); |
|
198 | d->initializeBarFromModel(); | |
198 | } |
|
199 | } | |
199 |
|
200 | |||
200 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
201 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
201 |
|
202 | |||
202 | QBarModelMapperPrivate::QBarModelMapperPrivate(QBarModelMapper *q) : |
|
203 | QBarModelMapperPrivate::QBarModelMapperPrivate(QBarModelMapper *q) : | |
203 | QObject(q), |
|
204 | QObject(q), | |
204 | m_series(0), |
|
205 | m_series(0), | |
205 | m_model(0), |
|
206 | m_model(0), | |
206 | m_first(0), |
|
207 | m_first(0), | |
207 | m_count(-1), |
|
208 | m_count(-1), | |
208 | m_orientation(Qt::Vertical), |
|
209 | m_orientation(Qt::Vertical), | |
209 | m_firstBarSetSection(-1), |
|
210 | m_firstBarSetSection(-1), | |
210 | m_lastBarSetSection(-1), |
|
211 | m_lastBarSetSection(-1), | |
211 | m_seriesSignalsBlock(false), |
|
212 | m_seriesSignalsBlock(false), | |
212 | m_modelSignalsBlock(false), |
|
213 | m_modelSignalsBlock(false), | |
213 | q_ptr(q) |
|
214 | q_ptr(q) | |
214 | { |
|
215 | { | |
215 | } |
|
216 | } | |
216 |
|
217 | |||
217 | void QBarModelMapperPrivate::blockModelSignals(bool block) |
|
218 | void QBarModelMapperPrivate::blockModelSignals(bool block) | |
218 | { |
|
219 | { | |
219 | m_modelSignalsBlock = block; |
|
220 | m_modelSignalsBlock = block; | |
220 | } |
|
221 | } | |
221 |
|
222 | |||
222 | void QBarModelMapperPrivate::blockSeriesSignals(bool block) |
|
223 | void QBarModelMapperPrivate::blockSeriesSignals(bool block) | |
223 | { |
|
224 | { | |
224 | m_seriesSignalsBlock = block; |
|
225 | m_seriesSignalsBlock = block; | |
225 | } |
|
226 | } | |
226 |
|
227 | |||
227 | QBarSet *QBarModelMapperPrivate::barSet(QModelIndex index) |
|
228 | QBarSet *QBarModelMapperPrivate::barSet(QModelIndex index) | |
228 | { |
|
229 | { | |
229 | if (!index.isValid()) |
|
230 | if (!index.isValid()) | |
230 | return 0; |
|
231 | return 0; | |
231 |
|
232 | |||
232 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) { |
|
233 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) { | |
233 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { |
|
234 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { | |
234 | return m_series->barSets().at(index.column() - m_firstBarSetSection); |
|
235 | return m_series->barSets().at(index.column() - m_firstBarSetSection); | |
235 | } |
|
236 | } | |
236 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) { |
|
237 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) { | |
237 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) |
|
238 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) | |
238 | return m_series->barSets().at(index.row() - m_firstBarSetSection); |
|
239 | return m_series->barSets().at(index.row() - m_firstBarSetSection); | |
239 | } |
|
240 | } | |
240 | return 0; // This part of model has not been mapped to any slice |
|
241 | return 0; // This part of model has not been mapped to any slice | |
241 | } |
|
242 | } | |
242 |
|
243 | |||
243 | QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar) |
|
244 | QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar) | |
244 | { |
|
245 | { | |
245 | if (m_count != -1 && posInBar >= m_count) |
|
246 | if (m_count != -1 && posInBar >= m_count) | |
246 | return QModelIndex(); // invalid |
|
247 | return QModelIndex(); // invalid | |
247 |
|
248 | |||
248 | if (barSection < m_firstBarSetSection || barSection > m_lastBarSetSection) |
|
249 | if (barSection < m_firstBarSetSection || barSection > m_lastBarSetSection) | |
249 | return QModelIndex(); // invalid |
|
250 | return QModelIndex(); // invalid | |
250 |
|
251 | |||
251 | if (m_orientation == Qt::Vertical) |
|
252 | if (m_orientation == Qt::Vertical) | |
252 | return m_model->index(posInBar + m_first, barSection); |
|
253 | return m_model->index(posInBar + m_first, barSection); | |
253 | else |
|
254 | else | |
254 | return m_model->index(barSection, posInBar + m_first); |
|
255 | return m_model->index(barSection, posInBar + m_first); | |
255 | } |
|
256 | } | |
256 |
|
257 | |||
257 | void QBarModelMapperPrivate::handleSeriesDestroyed() |
|
258 | void QBarModelMapperPrivate::handleSeriesDestroyed() | |
258 | { |
|
259 | { | |
259 | m_series = 0; |
|
260 | m_series = 0; | |
260 | } |
|
261 | } | |
261 |
|
262 | |||
262 | void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
263 | void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
263 | { |
|
264 | { | |
264 | Q_UNUSED(topLeft) |
|
265 | Q_UNUSED(topLeft) | |
265 | Q_UNUSED(bottomRight) |
|
266 | Q_UNUSED(bottomRight) | |
266 |
|
267 | |||
267 | if (m_model == 0 || m_series == 0) |
|
268 | if (m_model == 0 || m_series == 0) | |
268 | return; |
|
269 | return; | |
269 |
|
270 | |||
270 | if (m_modelSignalsBlock) |
|
271 | if (m_modelSignalsBlock) | |
271 | return; |
|
272 | return; | |
272 |
|
273 | |||
273 | blockSeriesSignals(); |
|
274 | blockSeriesSignals(); | |
274 | QModelIndex index; |
|
275 | QModelIndex index; | |
275 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { |
|
276 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
276 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { |
|
277 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { | |
277 | index = topLeft.sibling(row, column); |
|
278 | index = topLeft.sibling(row, column); | |
278 | QBarSet *bar = barSet(index); |
|
279 | QBarSet *bar = barSet(index); | |
279 | if (bar) { |
|
280 | if (bar) { | |
280 | if (m_orientation == Qt::Vertical) |
|
281 | if (m_orientation == Qt::Vertical) | |
281 | bar->replace(row - m_first, m_model->data(index).toReal()); |
|
282 | bar->replace(row - m_first, m_model->data(index).toReal()); | |
282 | else |
|
283 | else | |
283 | bar->replace(column - m_first, m_model->data(index).toReal()); |
|
284 | bar->replace(column - m_first, m_model->data(index).toReal()); | |
284 | } |
|
285 | } | |
285 | } |
|
286 | } | |
286 | } |
|
287 | } | |
287 | blockSeriesSignals(false); |
|
288 | blockSeriesSignals(false); | |
288 | } |
|
289 | } | |
289 |
|
290 | |||
290 | void QBarModelMapperPrivate::modelHeaderDataUpdated(Qt::Orientation orientation, int first, int last) |
|
291 | void QBarModelMapperPrivate::modelHeaderDataUpdated(Qt::Orientation orientation, int first, int last) | |
291 | { |
|
292 | { | |
292 | if (m_model == 0 || m_series == 0) |
|
293 | if (m_model == 0 || m_series == 0) | |
293 | return; |
|
294 | return; | |
294 |
|
295 | |||
295 | if (m_modelSignalsBlock) |
|
296 | if (m_modelSignalsBlock) | |
296 | return; |
|
297 | return; | |
297 |
|
298 | |||
298 | blockSeriesSignals(); |
|
299 | blockSeriesSignals(); | |
299 | if (orientation != m_orientation) { |
|
300 | if (orientation != m_orientation) { | |
300 | for (int section = first; section <= last; section++) { |
|
301 | for (int section = first; section <= last; section++) { | |
301 | if (section >= m_firstBarSetSection && section <= m_lastBarSetSection) { |
|
302 | if (section >= m_firstBarSetSection && section <= m_lastBarSetSection) { | |
302 | QBarSet *bar = m_series->barSets().at(section - m_firstBarSetSection); |
|
303 | QBarSet *bar = m_series->barSets().at(section - m_firstBarSetSection); | |
303 | if (bar) |
|
304 | if (bar) | |
304 | bar->setLabel(m_model->headerData(section, orientation).toString()); |
|
305 | bar->setLabel(m_model->headerData(section, orientation).toString()); | |
305 | } |
|
306 | } | |
306 | } |
|
307 | } | |
307 | } |
|
308 | } | |
308 | blockSeriesSignals(false); |
|
309 | blockSeriesSignals(false); | |
309 | } |
|
310 | } | |
310 |
|
311 | |||
311 | void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) |
|
312 | void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) | |
312 | { |
|
313 | { | |
313 | Q_UNUSED(parent) |
|
314 | Q_UNUSED(parent) | |
314 | if (m_modelSignalsBlock) |
|
315 | if (m_modelSignalsBlock) | |
315 | return; |
|
316 | return; | |
316 |
|
317 | |||
317 | blockSeriesSignals(); |
|
318 | blockSeriesSignals(); | |
318 | if (m_orientation == Qt::Vertical) |
|
319 | if (m_orientation == Qt::Vertical) | |
319 | insertData(start, end); |
|
320 | insertData(start, end); | |
320 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
321 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
321 | initializeBarFromModel(); |
|
322 | initializeBarFromModel(); | |
322 | blockSeriesSignals(false); |
|
323 | blockSeriesSignals(false); | |
323 | } |
|
324 | } | |
324 |
|
325 | |||
325 | void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) |
|
326 | void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) | |
326 | { |
|
327 | { | |
327 | Q_UNUSED(parent) |
|
328 | Q_UNUSED(parent) | |
328 | if (m_modelSignalsBlock) |
|
329 | if (m_modelSignalsBlock) | |
329 | return; |
|
330 | return; | |
330 |
|
331 | |||
331 | blockSeriesSignals(); |
|
332 | blockSeriesSignals(); | |
332 | if (m_orientation == Qt::Vertical) |
|
333 | if (m_orientation == Qt::Vertical) | |
333 | removeData(start, end); |
|
334 | removeData(start, end); | |
334 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
335 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
335 | initializeBarFromModel(); |
|
336 | initializeBarFromModel(); | |
336 | blockSeriesSignals(false); |
|
337 | blockSeriesSignals(false); | |
337 | } |
|
338 | } | |
338 |
|
339 | |||
339 | void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) |
|
340 | void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) | |
340 | { |
|
341 | { | |
341 | Q_UNUSED(parent) |
|
342 | Q_UNUSED(parent) | |
342 | if (m_modelSignalsBlock) |
|
343 | if (m_modelSignalsBlock) | |
343 | return; |
|
344 | return; | |
344 |
|
345 | |||
345 | blockSeriesSignals(); |
|
346 | blockSeriesSignals(); | |
346 | if (m_orientation == Qt::Horizontal) |
|
347 | if (m_orientation == Qt::Horizontal) | |
347 | insertData(start, end); |
|
348 | insertData(start, end); | |
348 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
349 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
349 | initializeBarFromModel(); |
|
350 | initializeBarFromModel(); | |
350 | blockSeriesSignals(false); |
|
351 | blockSeriesSignals(false); | |
351 | } |
|
352 | } | |
352 |
|
353 | |||
353 | void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) |
|
354 | void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) | |
354 | { |
|
355 | { | |
355 | Q_UNUSED(parent) |
|
356 | Q_UNUSED(parent) | |
356 | if (m_modelSignalsBlock) |
|
357 | if (m_modelSignalsBlock) | |
357 | return; |
|
358 | return; | |
358 |
|
359 | |||
359 | blockSeriesSignals(); |
|
360 | blockSeriesSignals(); | |
360 | if (m_orientation == Qt::Horizontal) |
|
361 | if (m_orientation == Qt::Horizontal) | |
361 | removeData(start, end); |
|
362 | removeData(start, end); | |
362 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
363 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
363 | initializeBarFromModel(); |
|
364 | initializeBarFromModel(); | |
364 | blockSeriesSignals(false); |
|
365 | blockSeriesSignals(false); | |
365 | } |
|
366 | } | |
366 |
|
367 | |||
367 | void QBarModelMapperPrivate::handleModelDestroyed() |
|
368 | void QBarModelMapperPrivate::handleModelDestroyed() | |
368 | { |
|
369 | { | |
369 | m_model = 0; |
|
370 | m_model = 0; | |
370 | } |
|
371 | } | |
371 |
|
372 | |||
372 | void QBarModelMapperPrivate::insertData(int start, int end) |
|
373 | void QBarModelMapperPrivate::insertData(int start, int end) | |
373 | { |
|
374 | { | |
374 | Q_UNUSED(end) |
|
375 | Q_UNUSED(end) | |
375 | Q_UNUSED(start) |
|
376 | Q_UNUSED(start) | |
376 | Q_UNUSED(end) |
|
377 | Q_UNUSED(end) | |
377 | // Currently barchart needs to be fully recalculated when change is made. |
|
378 | // Currently barchart needs to be fully recalculated when change is made. | |
378 | // Re-initialize |
|
379 | // Re-initialize | |
379 | initializeBarFromModel(); |
|
380 | initializeBarFromModel(); | |
380 | } |
|
381 | } | |
381 |
|
382 | |||
382 | void QBarModelMapperPrivate::removeData(int start, int end) |
|
383 | void QBarModelMapperPrivate::removeData(int start, int end) | |
383 | { |
|
384 | { | |
384 | Q_UNUSED(end) |
|
385 | Q_UNUSED(end) | |
385 | Q_UNUSED(start) |
|
386 | Q_UNUSED(start) | |
386 | Q_UNUSED(end) |
|
387 | Q_UNUSED(end) | |
387 | // Currently barchart needs to be fully recalculated when change is made. |
|
388 | // Currently barchart needs to be fully recalculated when change is made. | |
388 | // Re-initialize |
|
389 | // Re-initialize | |
389 | initializeBarFromModel(); |
|
390 | initializeBarFromModel(); | |
390 | } |
|
391 | } | |
391 |
|
392 | |||
392 | void QBarModelMapperPrivate::barSetsAdded(QList<QBarSet *> sets) |
|
393 | void QBarModelMapperPrivate::barSetsAdded(QList<QBarSet *> sets) | |
393 | { |
|
394 | { | |
394 | if (m_seriesSignalsBlock) |
|
395 | if (m_seriesSignalsBlock) | |
395 | return; |
|
396 | return; | |
396 |
|
397 | |||
397 | if (sets.count() == 0) |
|
398 | if (sets.count() == 0) | |
398 | return; |
|
399 | return; | |
399 |
|
400 | |||
400 | int firstIndex = m_series->barSets().indexOf(sets.at(0)); |
|
401 | int firstIndex = m_series->barSets().indexOf(sets.at(0)); | |
401 | if (firstIndex == -1) |
|
402 | if (firstIndex == -1) | |
402 | return; |
|
403 | return; | |
403 |
|
404 | |||
404 | int maxCount = 0; |
|
405 | int maxCount = 0; | |
405 | for (int i = 0; i < sets.count(); i++) { |
|
406 | for (int i = 0; i < sets.count(); i++) { | |
406 | if (sets.at(i)->count() > m_count) |
|
407 | if (sets.at(i)->count() > m_count) | |
407 | maxCount = sets.at(i)->count(); |
|
408 | maxCount = sets.at(i)->count(); | |
408 | } |
|
409 | } | |
409 |
|
410 | |||
410 | if (m_count != -1 && m_count < maxCount) |
|
411 | if (m_count != -1 && m_count < maxCount) | |
411 | m_count = maxCount; |
|
412 | m_count = maxCount; | |
412 |
|
413 | |||
413 | m_lastBarSetSection += sets.count(); |
|
414 | m_lastBarSetSection += sets.count(); | |
414 |
|
415 | |||
415 | blockModelSignals(); |
|
416 | blockModelSignals(); | |
416 | int modelCapacity = m_orientation == Qt::Vertical ? m_model->rowCount() - m_first : m_model->columnCount() - m_first; |
|
417 | int modelCapacity = m_orientation == Qt::Vertical ? m_model->rowCount() - m_first : m_model->columnCount() - m_first; | |
417 | if (maxCount > modelCapacity) { |
|
418 | if (maxCount > modelCapacity) { | |
418 | if (m_orientation == Qt::Vertical) |
|
419 | if (m_orientation == Qt::Vertical) | |
419 | m_model->insertRows(m_model->rowCount(), maxCount - modelCapacity); |
|
420 | m_model->insertRows(m_model->rowCount(), maxCount - modelCapacity); | |
420 | else |
|
421 | else | |
421 | m_model->insertColumns(m_model->columnCount(), maxCount - modelCapacity); |
|
422 | m_model->insertColumns(m_model->columnCount(), maxCount - modelCapacity); | |
422 | } |
|
423 | } | |
423 |
|
424 | |||
424 | if (m_orientation == Qt::Vertical) |
|
425 | if (m_orientation == Qt::Vertical) | |
425 | m_model->insertColumns(firstIndex + m_firstBarSetSection, sets.count()); |
|
426 | m_model->insertColumns(firstIndex + m_firstBarSetSection, sets.count()); | |
426 | else |
|
427 | else | |
427 | m_model->insertRows(firstIndex + m_firstBarSetSection, sets.count()); |
|
428 | m_model->insertRows(firstIndex + m_firstBarSetSection, sets.count()); | |
428 |
|
429 | |||
429 |
|
430 | |||
430 | for (int i = firstIndex + m_firstBarSetSection; i < firstIndex + m_firstBarSetSection + sets.count(); i++) { |
|
431 | for (int i = firstIndex + m_firstBarSetSection; i < firstIndex + m_firstBarSetSection + sets.count(); i++) { | |
431 | m_model->setHeaderData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, sets.at(i - firstIndex - m_firstBarSetSection)->label()); |
|
432 | m_model->setHeaderData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, sets.at(i - firstIndex - m_firstBarSetSection)->label()); | |
432 | for (int j = 0; j < sets.at(i - firstIndex - m_firstBarSetSection)->count(); j++) |
|
433 | for (int j = 0; j < sets.at(i - firstIndex - m_firstBarSetSection)->count(); j++) | |
433 | m_model->setData(barModelIndex(i, j), sets.at(i - firstIndex - m_firstBarSetSection)->at(j)); |
|
434 | m_model->setData(barModelIndex(i, j), sets.at(i - firstIndex - m_firstBarSetSection)->at(j)); | |
434 | } |
|
435 | } | |
435 | blockModelSignals(false); |
|
436 | blockModelSignals(false); | |
436 | initializeBarFromModel(); |
|
437 | initializeBarFromModel(); | |
437 | } |
|
438 | } | |
438 |
|
439 | |||
439 | void QBarModelMapperPrivate::barSetsRemoved(QList<QBarSet *> sets) |
|
440 | void QBarModelMapperPrivate::barSetsRemoved(QList<QBarSet *> sets) | |
440 | { |
|
441 | { | |
441 | if (m_seriesSignalsBlock) |
|
442 | if (m_seriesSignalsBlock) | |
442 | return; |
|
443 | return; | |
443 |
|
444 | |||
444 | if (sets.count() == 0) |
|
445 | if (sets.count() == 0) | |
445 | return; |
|
446 | return; | |
446 |
|
447 | |||
447 | int firstIndex = m_barSets.indexOf(sets.at(0)); |
|
448 | int firstIndex = m_barSets.indexOf(sets.at(0)); | |
448 | if (firstIndex == -1) |
|
449 | if (firstIndex == -1) | |
449 | return; |
|
450 | return; | |
450 |
|
451 | |||
451 | m_lastBarSetSection -= sets.count(); |
|
452 | m_lastBarSetSection -= sets.count(); | |
452 |
|
453 | |||
453 | for (int i = firstIndex + sets.count() - 1; i >= firstIndex; i--) |
|
454 | for (int i = firstIndex + sets.count() - 1; i >= firstIndex; i--) | |
454 | m_barSets.removeAt(i); |
|
455 | m_barSets.removeAt(i); | |
455 |
|
456 | |||
456 | blockModelSignals(); |
|
457 | blockModelSignals(); | |
457 | if (m_orientation == Qt::Vertical) |
|
458 | if (m_orientation == Qt::Vertical) | |
458 | m_model->removeColumns(firstIndex + m_firstBarSetSection, sets.count()); |
|
459 | m_model->removeColumns(firstIndex + m_firstBarSetSection, sets.count()); | |
459 | else |
|
460 | else | |
460 | m_model->removeRows(firstIndex + m_firstBarSetSection, sets.count()); |
|
461 | m_model->removeRows(firstIndex + m_firstBarSetSection, sets.count()); | |
461 | blockModelSignals(false); |
|
462 | blockModelSignals(false); | |
462 | initializeBarFromModel(); |
|
463 | initializeBarFromModel(); | |
463 | } |
|
464 | } | |
464 |
|
465 | |||
465 | void QBarModelMapperPrivate::valuesAdded(int index, int count) |
|
466 | void QBarModelMapperPrivate::valuesAdded(int index, int count) | |
466 | { |
|
467 | { | |
467 | if (m_seriesSignalsBlock) |
|
468 | if (m_seriesSignalsBlock) | |
468 | return; |
|
469 | return; | |
469 |
|
470 | |||
470 | if (m_count != -1) |
|
471 | if (m_count != -1) | |
471 | m_count += count; |
|
472 | m_count += count; | |
472 |
|
473 | |||
473 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); |
|
474 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); | |
474 |
|
475 | |||
475 | blockModelSignals(); |
|
476 | blockModelSignals(); | |
476 | if (m_orientation == Qt::Vertical) |
|
477 | if (m_orientation == Qt::Vertical) | |
477 | m_model->insertRows(index + m_first, count); |
|
478 | m_model->insertRows(index + m_first, count); | |
478 | else |
|
479 | else | |
479 | m_model->insertColumns(index + m_first, count); |
|
480 | m_model->insertColumns(index + m_first, count); | |
480 |
|
481 | |||
481 | for (int j = index; j < index + count; j++) |
|
482 | for (int j = index; j < index + count; j++) | |
482 | m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, j), m_barSets.at(barSetIndex)->at(j)); |
|
483 | m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, j), m_barSets.at(barSetIndex)->at(j)); | |
483 |
|
484 | |||
484 | blockModelSignals(false); |
|
485 | blockModelSignals(false); | |
485 | initializeBarFromModel(); |
|
486 | initializeBarFromModel(); | |
486 | } |
|
487 | } | |
487 |
|
488 | |||
488 | void QBarModelMapperPrivate::valuesRemoved(int index, int count) |
|
489 | void QBarModelMapperPrivate::valuesRemoved(int index, int count) | |
489 | { |
|
490 | { | |
490 | if (m_seriesSignalsBlock) |
|
491 | if (m_seriesSignalsBlock) | |
491 | return; |
|
492 | return; | |
492 |
|
493 | |||
493 | if (m_count != -1) |
|
494 | if (m_count != -1) | |
494 | m_count -= count; |
|
495 | m_count -= count; | |
495 |
|
496 | |||
496 | blockModelSignals(); |
|
497 | blockModelSignals(); | |
497 | if (m_orientation == Qt::Vertical) |
|
498 | if (m_orientation == Qt::Vertical) | |
498 | m_model->removeRows(index + m_first, count); |
|
499 | m_model->removeRows(index + m_first, count); | |
499 | else |
|
500 | else | |
500 | m_model->removeColumns(index + m_first, count); |
|
501 | m_model->removeColumns(index + m_first, count); | |
501 |
|
502 | |||
502 | blockModelSignals(false); |
|
503 | blockModelSignals(false); | |
503 | initializeBarFromModel(); |
|
504 | initializeBarFromModel(); | |
504 | } |
|
505 | } | |
505 |
|
506 | |||
506 | void QBarModelMapperPrivate::barLabelChanged() |
|
507 | void QBarModelMapperPrivate::barLabelChanged() | |
507 | { |
|
508 | { | |
508 | if (m_seriesSignalsBlock) |
|
509 | if (m_seriesSignalsBlock) | |
509 | return; |
|
510 | return; | |
510 |
|
511 | |||
511 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); |
|
512 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); | |
512 |
|
513 | |||
513 | blockModelSignals(); |
|
514 | blockModelSignals(); | |
514 | m_model->setHeaderData(barSetIndex + m_firstBarSetSection, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, m_barSets.at(barSetIndex)->label()); |
|
515 | m_model->setHeaderData(barSetIndex + m_firstBarSetSection, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, m_barSets.at(barSetIndex)->label()); | |
515 | blockModelSignals(false); |
|
516 | blockModelSignals(false); | |
516 | initializeBarFromModel(); |
|
517 | initializeBarFromModel(); | |
517 | } |
|
518 | } | |
518 |
|
519 | |||
519 | void QBarModelMapperPrivate::barValueChanged(int index) |
|
520 | void QBarModelMapperPrivate::barValueChanged(int index) | |
520 | { |
|
521 | { | |
521 | if (m_seriesSignalsBlock) |
|
522 | if (m_seriesSignalsBlock) | |
522 | return; |
|
523 | return; | |
523 |
|
524 | |||
524 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); |
|
525 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); | |
525 |
|
526 | |||
526 | blockModelSignals(); |
|
527 | blockModelSignals(); | |
527 | m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, index), m_barSets.at(barSetIndex)->at(index)); |
|
528 | m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, index), m_barSets.at(barSetIndex)->at(index)); | |
528 | blockModelSignals(false); |
|
529 | blockModelSignals(false); | |
529 | initializeBarFromModel(); |
|
530 | initializeBarFromModel(); | |
530 | } |
|
531 | } | |
531 |
|
532 | |||
532 | void QBarModelMapperPrivate::initializeBarFromModel() |
|
533 | void QBarModelMapperPrivate::initializeBarFromModel() | |
533 | { |
|
534 | { | |
534 | if (m_model == 0 || m_series == 0) |
|
535 | if (m_model == 0 || m_series == 0) | |
535 | return; |
|
536 | return; | |
536 |
|
537 | |||
537 | blockSeriesSignals(); |
|
538 | blockSeriesSignals(); | |
538 | // clear current content |
|
539 | // clear current content | |
539 | m_series->clear(); |
|
540 | m_series->clear(); | |
540 | m_barSets.clear(); |
|
541 | m_barSets.clear(); | |
541 |
|
542 | |||
542 | // create the initial bar sets |
|
543 | // create the initial bar sets | |
543 | for (int i = m_firstBarSetSection; i <= m_lastBarSetSection; i++) { |
|
544 | for (int i = m_firstBarSetSection; i <= m_lastBarSetSection; i++) { | |
544 | int posInBar = 0; |
|
545 | int posInBar = 0; | |
545 | QModelIndex barIndex = barModelIndex(i, posInBar); |
|
546 | QModelIndex barIndex = barModelIndex(i, posInBar); | |
546 | // check if there is such model index |
|
547 | // check if there is such model index | |
547 | if (barIndex.isValid()) { |
|
548 | if (barIndex.isValid()) { | |
548 | QBarSet *barSet = new QBarSet(m_model->headerData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical).toString()); |
|
549 | QBarSet *barSet = new QBarSet(m_model->headerData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical).toString()); | |
549 | while (barIndex.isValid()) { |
|
550 | while (barIndex.isValid()) { | |
550 | barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble()); |
|
551 | barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble()); | |
551 | posInBar++; |
|
552 | posInBar++; | |
552 | barIndex = barModelIndex(i, posInBar); |
|
553 | barIndex = barModelIndex(i, posInBar); | |
553 | } |
|
554 | } | |
554 | connect(barSet, SIGNAL(valuesAdded(int,int)), this, SLOT(valuesAdded(int,int))); |
|
555 | connect(barSet, SIGNAL(valuesAdded(int,int)), this, SLOT(valuesAdded(int,int))); | |
555 | connect(barSet, SIGNAL(valuesRemoved(int,int)), this, SLOT(valuesRemoved(int,int))); |
|
556 | connect(barSet, SIGNAL(valuesRemoved(int,int)), this, SLOT(valuesRemoved(int,int))); | |
556 | connect(barSet, SIGNAL(valueChanged(int)), this, SLOT(barValueChanged(int))); |
|
557 | connect(barSet, SIGNAL(valueChanged(int)), this, SLOT(barValueChanged(int))); | |
557 | connect(barSet, SIGNAL(labelChanged()), this, SLOT(barLabelChanged())); |
|
558 | connect(barSet, SIGNAL(labelChanged()), this, SLOT(barLabelChanged())); | |
558 | m_series->append(barSet); |
|
559 | m_series->append(barSet); | |
559 | m_barSets.append(barSet); |
|
560 | m_barSets.append(barSet); | |
560 | } else { |
|
561 | } else { | |
561 | break; |
|
562 | break; | |
562 | } |
|
563 | } | |
563 | } |
|
564 | } | |
564 | blockSeriesSignals(false); |
|
565 | blockSeriesSignals(false); | |
565 | } |
|
566 | } | |
566 |
|
567 | |||
567 | #include "moc_qbarmodelmapper.cpp" |
|
568 | #include "moc_qbarmodelmapper.cpp" | |
568 | #include "moc_qbarmodelmapper_p.cpp" |
|
569 | #include "moc_qbarmodelmapper_p.cpp" | |
569 |
|
570 | |||
570 | QT_CHARTS_END_NAMESPACE |
|
571 | QT_CHARTS_END_NAMESPACE |
@@ -1,80 +1,80 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QBARMODELMAPPER_H |
|
30 | #ifndef QBARMODELMAPPER_H | |
31 | #define QBARMODELMAPPER_H |
|
31 | #define QBARMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCore/QObject> |
|
34 | #include <QtCore/QObject> | |
35 |
|
35 | |||
36 | QT_BEGIN_NAMESPACE |
|
36 | QT_BEGIN_NAMESPACE | |
37 | class QAbstractItemModel; |
|
37 | class QAbstractItemModel; | |
38 | QT_END_NAMESPACE |
|
38 | QT_END_NAMESPACE | |
39 |
|
39 | |||
40 | QT_CHARTS_BEGIN_NAMESPACE |
|
40 | QT_CHARTS_BEGIN_NAMESPACE | |
41 |
|
41 | |||
42 | class QBarModelMapperPrivate; |
|
42 | class QBarModelMapperPrivate; | |
43 | class QAbstractBarSeries; |
|
43 | class QAbstractBarSeries; | |
44 |
|
44 | |||
45 | class QT_CHARTS_EXPORT QBarModelMapper : public QObject |
|
45 | class QT_CHARTS_EXPORT QBarModelMapper : public QObject | |
46 | { |
|
46 | { | |
47 | Q_OBJECT |
|
47 | Q_OBJECT | |
48 |
|
48 | |||
49 | protected: |
|
49 | protected: | |
50 |
explicit QBarModelMapper(QObject *parent = |
|
50 | explicit QBarModelMapper(QObject *parent = Q_NULLPTR); | |
51 |
|
51 | |||
52 | QAbstractItemModel *model() const; |
|
52 | QAbstractItemModel *model() const; | |
53 | void setModel(QAbstractItemModel *model); |
|
53 | void setModel(QAbstractItemModel *model); | |
54 |
|
54 | |||
55 | QAbstractBarSeries *series() const; |
|
55 | QAbstractBarSeries *series() const; | |
56 | void setSeries(QAbstractBarSeries *series); |
|
56 | void setSeries(QAbstractBarSeries *series); | |
57 |
|
57 | |||
58 | int first() const; |
|
58 | int first() const; | |
59 | void setFirst(int first); |
|
59 | void setFirst(int first); | |
60 |
|
60 | |||
61 | int count() const; |
|
61 | int count() const; | |
62 | void setCount(int count); |
|
62 | void setCount(int count); | |
63 |
|
63 | |||
64 | int firstBarSetSection() const; |
|
64 | int firstBarSetSection() const; | |
65 | void setFirstBarSetSection(int firstBarSetSection); |
|
65 | void setFirstBarSetSection(int firstBarSetSection); | |
66 |
|
66 | |||
67 | int lastBarSetSection() const; |
|
67 | int lastBarSetSection() const; | |
68 | void setLastBarSetSection(int lastBarSetSection); |
|
68 | void setLastBarSetSection(int lastBarSetSection); | |
69 |
|
69 | |||
70 | Qt::Orientation orientation() const; |
|
70 | Qt::Orientation orientation() const; | |
71 | void setOrientation(Qt::Orientation orientation); |
|
71 | void setOrientation(Qt::Orientation orientation); | |
72 |
|
72 | |||
73 | protected: |
|
73 | protected: | |
74 | QBarModelMapperPrivate * const d_ptr; |
|
74 | QBarModelMapperPrivate * const d_ptr; | |
75 | Q_DECLARE_PRIVATE(QBarModelMapper) |
|
75 | Q_DECLARE_PRIVATE(QBarModelMapper) | |
76 | }; |
|
76 | }; | |
77 |
|
77 | |||
78 | QT_CHARTS_END_NAMESPACE |
|
78 | QT_CHARTS_END_NAMESPACE | |
79 |
|
79 | |||
80 | #endif // QBARMODELMAPPER_H |
|
80 | #endif // QBARMODELMAPPER_H |
@@ -1,131 +1,131 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QBARSET_H |
|
30 | #ifndef QBARSET_H | |
31 | #define QBARSET_H |
|
31 | #define QBARSET_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtGui/QPen> |
|
34 | #include <QtGui/QPen> | |
35 | #include <QtGui/QBrush> |
|
35 | #include <QtGui/QBrush> | |
36 | #include <QtGui/QFont> |
|
36 | #include <QtGui/QFont> | |
37 |
|
37 | |||
38 | QT_CHARTS_BEGIN_NAMESPACE |
|
38 | QT_CHARTS_BEGIN_NAMESPACE | |
39 | class QBarSetPrivate; |
|
39 | class QBarSetPrivate; | |
40 |
|
40 | |||
41 | class QT_CHARTS_EXPORT QBarSet : public QObject |
|
41 | class QT_CHARTS_EXPORT QBarSet : public QObject | |
42 | { |
|
42 | { | |
43 | Q_OBJECT |
|
43 | Q_OBJECT | |
44 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
|
44 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) | |
45 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
45 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
46 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
|
46 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |
47 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) |
|
47 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) | |
48 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) |
|
48 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) | |
49 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
49 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
50 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
50 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
51 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) |
|
51 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) | |
52 |
|
52 | |||
53 | public: |
|
53 | public: | |
54 |
explicit QBarSet(const QString label, QObject *parent = |
|
54 | explicit QBarSet(const QString label, QObject *parent = Q_NULLPTR); | |
55 | virtual ~QBarSet(); |
|
55 | virtual ~QBarSet(); | |
56 |
|
56 | |||
57 | void setLabel(const QString label); |
|
57 | void setLabel(const QString label); | |
58 | QString label() const; |
|
58 | QString label() const; | |
59 |
|
59 | |||
60 | void append(const qreal value); |
|
60 | void append(const qreal value); | |
61 | void append(const QList<qreal> &values); |
|
61 | void append(const QList<qreal> &values); | |
62 |
|
62 | |||
63 | QBarSet &operator << (const qreal &value); |
|
63 | QBarSet &operator << (const qreal &value); | |
64 |
|
64 | |||
65 | void insert(const int index, const qreal value); |
|
65 | void insert(const int index, const qreal value); | |
66 | void remove(const int index, const int count = 1); |
|
66 | void remove(const int index, const int count = 1); | |
67 | void replace(const int index, const qreal value); |
|
67 | void replace(const int index, const qreal value); | |
68 | qreal at(const int index) const; |
|
68 | qreal at(const int index) const; | |
69 | qreal operator [](const int index) const; |
|
69 | qreal operator [](const int index) const; | |
70 | int count() const; |
|
70 | int count() const; | |
71 | qreal sum() const; |
|
71 | qreal sum() const; | |
72 |
|
72 | |||
73 | void setPen(const QPen &pen); |
|
73 | void setPen(const QPen &pen); | |
74 | QPen pen() const; |
|
74 | QPen pen() const; | |
75 |
|
75 | |||
76 | void setBrush(const QBrush &brush); |
|
76 | void setBrush(const QBrush &brush); | |
77 | QBrush brush() const; |
|
77 | QBrush brush() const; | |
78 |
|
78 | |||
79 | void setLabelBrush(const QBrush &brush); |
|
79 | void setLabelBrush(const QBrush &brush); | |
80 | QBrush labelBrush() const; |
|
80 | QBrush labelBrush() const; | |
81 |
|
81 | |||
82 | void setLabelFont(const QFont &font); |
|
82 | void setLabelFont(const QFont &font); | |
83 | QFont labelFont() const; |
|
83 | QFont labelFont() const; | |
84 |
|
84 | |||
85 | QColor color(); |
|
85 | QColor color(); | |
86 | void setColor(QColor color); |
|
86 | void setColor(QColor color); | |
87 |
|
87 | |||
88 | QColor borderColor(); |
|
88 | QColor borderColor(); | |
89 | void setBorderColor(QColor color); |
|
89 | void setBorderColor(QColor color); | |
90 |
|
90 | |||
91 | QColor labelColor(); |
|
91 | QColor labelColor(); | |
92 | void setLabelColor(QColor color); |
|
92 | void setLabelColor(QColor color); | |
93 |
|
93 | |||
94 | Q_SIGNALS: |
|
94 | Q_SIGNALS: | |
95 | void clicked(int index); |
|
95 | void clicked(int index); | |
96 | void hovered(bool status, int index); |
|
96 | void hovered(bool status, int index); | |
97 | void pressed(int index); |
|
97 | void pressed(int index); | |
98 | void released(int index); |
|
98 | void released(int index); | |
99 | void doubleClicked(int index); |
|
99 | void doubleClicked(int index); | |
100 | void penChanged(); |
|
100 | void penChanged(); | |
101 | void brushChanged(); |
|
101 | void brushChanged(); | |
102 | void labelChanged(); |
|
102 | void labelChanged(); | |
103 | void labelBrushChanged(); |
|
103 | void labelBrushChanged(); | |
104 | void labelFontChanged(); |
|
104 | void labelFontChanged(); | |
105 | void colorChanged(QColor color); |
|
105 | void colorChanged(QColor color); | |
106 | void borderColorChanged(QColor color); |
|
106 | void borderColorChanged(QColor color); | |
107 | void labelColorChanged(QColor color); |
|
107 | void labelColorChanged(QColor color); | |
108 |
|
108 | |||
109 | void valuesAdded(int index, int count); |
|
109 | void valuesAdded(int index, int count); | |
110 | void valuesRemoved(int index, int count); |
|
110 | void valuesRemoved(int index, int count); | |
111 | void valueChanged(int index); |
|
111 | void valueChanged(int index); | |
112 |
|
112 | |||
113 | private: |
|
113 | private: | |
114 | QScopedPointer<QBarSetPrivate> d_ptr; |
|
114 | QScopedPointer<QBarSetPrivate> d_ptr; | |
115 | Q_DISABLE_COPY(QBarSet) |
|
115 | Q_DISABLE_COPY(QBarSet) | |
116 | friend class QAbstractBarSeries; |
|
116 | friend class QAbstractBarSeries; | |
117 | friend class BarLegendMarker; |
|
117 | friend class BarLegendMarker; | |
118 | friend class AbstractBarChartItem; |
|
118 | friend class AbstractBarChartItem; | |
119 | friend class QAbstractBarSeriesPrivate; |
|
119 | friend class QAbstractBarSeriesPrivate; | |
120 | friend class StackedBarChartItem; |
|
120 | friend class StackedBarChartItem; | |
121 | friend class PercentBarChartItem; |
|
121 | friend class PercentBarChartItem; | |
122 | friend class BarChartItem; |
|
122 | friend class BarChartItem; | |
123 | friend class HorizontalBarChartItem; |
|
123 | friend class HorizontalBarChartItem; | |
124 | friend class HorizontalStackedBarChartItem; |
|
124 | friend class HorizontalStackedBarChartItem; | |
125 | friend class HorizontalPercentBarChartItem; |
|
125 | friend class HorizontalPercentBarChartItem; | |
126 | friend class BoxPlotChartItem; |
|
126 | friend class BoxPlotChartItem; | |
127 | }; |
|
127 | }; | |
128 |
|
128 | |||
129 | QT_CHARTS_END_NAMESPACE |
|
129 | QT_CHARTS_END_NAMESPACE | |
130 |
|
130 | |||
131 | #endif // QBARSET_H |
|
131 | #endif // QBARSET_H |
@@ -1,79 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QHBARMODELMAPPER_H |
|
30 | #ifndef QHBARMODELMAPPER_H | |
31 | #define QHBARMODELMAPPER_H |
|
31 | #define QHBARMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QBarModelMapper> |
|
33 | #include <QtCharts/QBarModelMapper> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ |
|
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ | |
37 | class QT_CHARTS_EXPORT QHBarModelMapper : public QBarModelMapper |
|
37 | class QT_CHARTS_EXPORT QHBarModelMapper : public QBarModelMapper | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | Q_PROPERTY(QAbstractBarSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) |
|
40 | Q_PROPERTY(QAbstractBarSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) | |
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) |
|
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) | |
42 | Q_PROPERTY(int firstBarSetRow READ firstBarSetRow WRITE setFirstBarSetRow NOTIFY firstBarSetRowChanged) |
|
42 | Q_PROPERTY(int firstBarSetRow READ firstBarSetRow WRITE setFirstBarSetRow NOTIFY firstBarSetRowChanged) | |
43 | Q_PROPERTY(int lastBarSetRow READ lastBarSetRow WRITE setLastBarSetRow NOTIFY lastBarSetRowChanged) |
|
43 | Q_PROPERTY(int lastBarSetRow READ lastBarSetRow WRITE setLastBarSetRow NOTIFY lastBarSetRowChanged) | |
44 | Q_PROPERTY(int firstColumn READ firstColumn WRITE setFirstColumn NOTIFY firstColumnChanged) |
|
44 | Q_PROPERTY(int firstColumn READ firstColumn WRITE setFirstColumn NOTIFY firstColumnChanged) | |
45 | Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) |
|
45 | Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 |
explicit QHBarModelMapper(QObject *parent = |
|
48 | explicit QHBarModelMapper(QObject *parent = Q_NULLPTR); | |
49 |
|
49 | |||
50 | QAbstractItemModel *model() const; |
|
50 | QAbstractItemModel *model() const; | |
51 | void setModel(QAbstractItemModel *model); |
|
51 | void setModel(QAbstractItemModel *model); | |
52 |
|
52 | |||
53 | QAbstractBarSeries *series() const; |
|
53 | QAbstractBarSeries *series() const; | |
54 | void setSeries(QAbstractBarSeries *series); |
|
54 | void setSeries(QAbstractBarSeries *series); | |
55 |
|
55 | |||
56 | int firstBarSetRow() const; |
|
56 | int firstBarSetRow() const; | |
57 | void setFirstBarSetRow(int firstBarSetRow); |
|
57 | void setFirstBarSetRow(int firstBarSetRow); | |
58 |
|
58 | |||
59 | int lastBarSetRow() const; |
|
59 | int lastBarSetRow() const; | |
60 | void setLastBarSetRow(int lastBarSetRow); |
|
60 | void setLastBarSetRow(int lastBarSetRow); | |
61 |
|
61 | |||
62 | int firstColumn() const; |
|
62 | int firstColumn() const; | |
63 | void setFirstColumn(int firstColumn); |
|
63 | void setFirstColumn(int firstColumn); | |
64 |
|
64 | |||
65 | int columnCount() const; |
|
65 | int columnCount() const; | |
66 | void setColumnCount(int columnCount); |
|
66 | void setColumnCount(int columnCount); | |
67 |
|
67 | |||
68 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
69 | void seriesReplaced(); |
|
69 | void seriesReplaced(); | |
70 | void modelReplaced(); |
|
70 | void modelReplaced(); | |
71 | void firstBarSetRowChanged(); |
|
71 | void firstBarSetRowChanged(); | |
72 | void lastBarSetRowChanged(); |
|
72 | void lastBarSetRowChanged(); | |
73 | void firstColumnChanged(); |
|
73 | void firstColumnChanged(); | |
74 | void columnCountChanged(); |
|
74 | void columnCountChanged(); | |
75 | }; |
|
75 | }; | |
76 |
|
76 | |||
77 | QT_CHARTS_END_NAMESPACE |
|
77 | QT_CHARTS_END_NAMESPACE | |
78 |
|
78 | |||
79 | #endif // QHBARMODELMAPPER_H |
|
79 | #endif // QHBARMODELMAPPER_H |
@@ -1,79 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QVBARMODELMAPPER_H |
|
30 | #ifndef QVBARMODELMAPPER_H | |
31 | #define QVBARMODELMAPPER_H |
|
31 | #define QVBARMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QBarModelMapper> |
|
33 | #include <QtCharts/QBarModelMapper> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ |
|
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ | |
37 | class QT_CHARTS_EXPORT QVBarModelMapper : public QBarModelMapper |
|
37 | class QT_CHARTS_EXPORT QVBarModelMapper : public QBarModelMapper | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | Q_PROPERTY(QAbstractBarSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) |
|
40 | Q_PROPERTY(QAbstractBarSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) | |
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) |
|
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) | |
42 | Q_PROPERTY(int firstBarSetColumn READ firstBarSetColumn WRITE setFirstBarSetColumn NOTIFY firstBarSetColumnChanged) |
|
42 | Q_PROPERTY(int firstBarSetColumn READ firstBarSetColumn WRITE setFirstBarSetColumn NOTIFY firstBarSetColumnChanged) | |
43 | Q_PROPERTY(int lastBarSetColumn READ lastBarSetColumn WRITE setLastBarSetColumn NOTIFY lastBarSetColumnChanged) |
|
43 | Q_PROPERTY(int lastBarSetColumn READ lastBarSetColumn WRITE setLastBarSetColumn NOTIFY lastBarSetColumnChanged) | |
44 | Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged) |
|
44 | Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged) | |
45 | Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) |
|
45 | Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 |
explicit QVBarModelMapper(QObject *parent = |
|
48 | explicit QVBarModelMapper(QObject *parent = Q_NULLPTR); | |
49 |
|
49 | |||
50 | QAbstractItemModel *model() const; |
|
50 | QAbstractItemModel *model() const; | |
51 | void setModel(QAbstractItemModel *model); |
|
51 | void setModel(QAbstractItemModel *model); | |
52 |
|
52 | |||
53 | QAbstractBarSeries *series() const; |
|
53 | QAbstractBarSeries *series() const; | |
54 | void setSeries(QAbstractBarSeries *series); |
|
54 | void setSeries(QAbstractBarSeries *series); | |
55 |
|
55 | |||
56 | int firstBarSetColumn() const; |
|
56 | int firstBarSetColumn() const; | |
57 | void setFirstBarSetColumn(int firstBarSetColumn); |
|
57 | void setFirstBarSetColumn(int firstBarSetColumn); | |
58 |
|
58 | |||
59 | int lastBarSetColumn() const; |
|
59 | int lastBarSetColumn() const; | |
60 | void setLastBarSetColumn(int lastBarSetColumn); |
|
60 | void setLastBarSetColumn(int lastBarSetColumn); | |
61 |
|
61 | |||
62 | int firstRow() const; |
|
62 | int firstRow() const; | |
63 | void setFirstRow(int firstRow); |
|
63 | void setFirstRow(int firstRow); | |
64 |
|
64 | |||
65 | int rowCount() const; |
|
65 | int rowCount() const; | |
66 | void setRowCount(int rowCount); |
|
66 | void setRowCount(int rowCount); | |
67 |
|
67 | |||
68 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
69 | void seriesReplaced(); |
|
69 | void seriesReplaced(); | |
70 | void modelReplaced(); |
|
70 | void modelReplaced(); | |
71 | void firstBarSetColumnChanged(); |
|
71 | void firstBarSetColumnChanged(); | |
72 | void lastBarSetColumnChanged(); |
|
72 | void lastBarSetColumnChanged(); | |
73 | void firstRowChanged(); |
|
73 | void firstRowChanged(); | |
74 | void rowCountChanged(); |
|
74 | void rowCountChanged(); | |
75 | }; |
|
75 | }; | |
76 |
|
76 | |||
77 | QT_CHARTS_END_NAMESPACE |
|
77 | QT_CHARTS_END_NAMESPACE | |
78 |
|
78 | |||
79 | #endif // QVBARMODELMAPPER_H |
|
79 | #endif // QVBARMODELMAPPER_H |
@@ -1,54 +1,54 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QBARSERIES_H |
|
30 | #ifndef QBARSERIES_H | |
31 | #define QBARSERIES_H |
|
31 | #define QBARSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractBarSeries> |
|
33 | #include <QtCharts/QAbstractBarSeries> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QBarSeriesPrivate; |
|
37 | class QBarSeriesPrivate; | |
38 |
|
38 | |||
39 | class QT_CHARTS_EXPORT QBarSeries : public QAbstractBarSeries |
|
39 | class QT_CHARTS_EXPORT QBarSeries : public QAbstractBarSeries | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 |
explicit QBarSeries(QObject *parent = |
|
43 | explicit QBarSeries(QObject *parent = Q_NULLPTR); | |
44 | ~QBarSeries(); |
|
44 | ~QBarSeries(); | |
45 | QAbstractSeries::SeriesType type() const; |
|
45 | QAbstractSeries::SeriesType type() const; | |
46 |
|
46 | |||
47 | private: |
|
47 | private: | |
48 | Q_DECLARE_PRIVATE(QBarSeries) |
|
48 | Q_DECLARE_PRIVATE(QBarSeries) | |
49 | Q_DISABLE_COPY(QBarSeries) |
|
49 | Q_DISABLE_COPY(QBarSeries) | |
50 | }; |
|
50 | }; | |
51 |
|
51 | |||
52 | QT_CHARTS_END_NAMESPACE |
|
52 | QT_CHARTS_END_NAMESPACE | |
53 |
|
53 | |||
54 | #endif // QBARSERIES_H |
|
54 | #endif // QBARSERIES_H |
@@ -1,55 +1,55 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QPERCENTBARSERIES_H |
|
30 | #ifndef QPERCENTBARSERIES_H | |
31 | #define QPERCENTBARSERIES_H |
|
31 | #define QPERCENTBARSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCore/QStringList> |
|
33 | #include <QtCore/QStringList> | |
34 | #include <QtCharts/QAbstractBarSeries> |
|
34 | #include <QtCharts/QAbstractBarSeries> | |
35 |
|
35 | |||
36 | QT_CHARTS_BEGIN_NAMESPACE |
|
36 | QT_CHARTS_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QPercentBarSeriesPrivate; |
|
38 | class QPercentBarSeriesPrivate; | |
39 |
|
39 | |||
40 | class QT_CHARTS_EXPORT QPercentBarSeries : public QAbstractBarSeries |
|
40 | class QT_CHARTS_EXPORT QPercentBarSeries : public QAbstractBarSeries | |
41 | { |
|
41 | { | |
42 | Q_OBJECT |
|
42 | Q_OBJECT | |
43 | public: |
|
43 | public: | |
44 |
explicit QPercentBarSeries(QObject *parent = |
|
44 | explicit QPercentBarSeries(QObject *parent = Q_NULLPTR); | |
45 | ~QPercentBarSeries(); |
|
45 | ~QPercentBarSeries(); | |
46 | QAbstractSeries::SeriesType type() const; |
|
46 | QAbstractSeries::SeriesType type() const; | |
47 |
|
47 | |||
48 | private: |
|
48 | private: | |
49 | Q_DECLARE_PRIVATE(QPercentBarSeries) |
|
49 | Q_DECLARE_PRIVATE(QPercentBarSeries) | |
50 | Q_DISABLE_COPY(QPercentBarSeries) |
|
50 | Q_DISABLE_COPY(QPercentBarSeries) | |
51 | }; |
|
51 | }; | |
52 |
|
52 | |||
53 | QT_CHARTS_END_NAMESPACE |
|
53 | QT_CHARTS_END_NAMESPACE | |
54 |
|
54 | |||
55 | #endif // QPERCENTBARSERIES_H |
|
55 | #endif // QPERCENTBARSERIES_H |
@@ -1,55 +1,55 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QSTACKEDBARSERIES_H |
|
30 | #ifndef QSTACKEDBARSERIES_H | |
31 | #define QSTACKEDBARSERIES_H |
|
31 | #define QSTACKEDBARSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCore/QStringList> |
|
33 | #include <QtCore/QStringList> | |
34 | #include <QtCharts/QAbstractBarSeries> |
|
34 | #include <QtCharts/QAbstractBarSeries> | |
35 |
|
35 | |||
36 | QT_CHARTS_BEGIN_NAMESPACE |
|
36 | QT_CHARTS_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QStackedBarSeriesPrivate; |
|
38 | class QStackedBarSeriesPrivate; | |
39 |
|
39 | |||
40 | class QT_CHARTS_EXPORT QStackedBarSeries : public QAbstractBarSeries |
|
40 | class QT_CHARTS_EXPORT QStackedBarSeries : public QAbstractBarSeries | |
41 | { |
|
41 | { | |
42 | Q_OBJECT |
|
42 | Q_OBJECT | |
43 | public: |
|
43 | public: | |
44 |
explicit QStackedBarSeries(QObject *parent = |
|
44 | explicit QStackedBarSeries(QObject *parent = Q_NULLPTR); | |
45 | ~QStackedBarSeries(); |
|
45 | ~QStackedBarSeries(); | |
46 | QAbstractSeries::SeriesType type() const; |
|
46 | QAbstractSeries::SeriesType type() const; | |
47 |
|
47 | |||
48 | private: |
|
48 | private: | |
49 | Q_DECLARE_PRIVATE(QStackedBarSeries) |
|
49 | Q_DECLARE_PRIVATE(QStackedBarSeries) | |
50 | Q_DISABLE_COPY(QStackedBarSeries) |
|
50 | Q_DISABLE_COPY(QStackedBarSeries) | |
51 | }; |
|
51 | }; | |
52 |
|
52 | |||
53 | QT_CHARTS_END_NAMESPACE |
|
53 | QT_CHARTS_END_NAMESPACE | |
54 |
|
54 | |||
55 | #endif // QSTACKEDBARSERIES_H |
|
55 | #endif // QSTACKEDBARSERIES_H |
@@ -1,498 +1,499 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #include <QtCharts/QBoxPlotModelMapper> |
|
30 | #include <QtCharts/QBoxPlotModelMapper> | |
31 | #include <private/qboxplotmodelmapper_p.h> |
|
31 | #include <private/qboxplotmodelmapper_p.h> | |
32 | #include <QtCharts/QBoxPlotSeries> |
|
32 | #include <QtCharts/QBoxPlotSeries> | |
33 | #include <QtCharts/QBoxSet> |
|
33 | #include <QtCharts/QBoxSet> | |
34 | #include <QtCharts/QChart> |
|
34 | #include <QtCharts/QChart> | |
35 | #include <QtCore/QAbstractItemModel> |
|
35 | #include <QtCore/QAbstractItemModel> | |
36 |
|
36 | |||
37 | QT_CHARTS_BEGIN_NAMESPACE |
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | QBoxPlotModelMapper::QBoxPlotModelMapper(QObject *parent) : |
|
39 | QBoxPlotModelMapper::QBoxPlotModelMapper(QObject *parent) : | |
40 | QObject(parent), |
|
40 | QObject(parent), | |
41 | d_ptr(new QBoxPlotModelMapperPrivate(this)) |
|
41 | d_ptr(new QBoxPlotModelMapperPrivate(this)) | |
42 | { |
|
42 | { | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | QAbstractItemModel *QBoxPlotModelMapper::model() const |
|
45 | QAbstractItemModel *QBoxPlotModelMapper::model() const | |
46 | { |
|
46 | { | |
47 | Q_D(const QBoxPlotModelMapper); |
|
47 | Q_D(const QBoxPlotModelMapper); | |
48 | return d->m_model; |
|
48 | return d->m_model; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | void QBoxPlotModelMapper::setModel(QAbstractItemModel *model) |
|
51 | void QBoxPlotModelMapper::setModel(QAbstractItemModel *model) | |
52 | { |
|
52 | { | |
53 | if (model == 0) |
|
53 | if (model == 0) | |
54 | return; |
|
54 | return; | |
55 |
|
55 | |||
56 | Q_D(QBoxPlotModelMapper); |
|
56 | Q_D(QBoxPlotModelMapper); | |
57 | if (d->m_model) |
|
57 | if (d->m_model) | |
58 | disconnect(d->m_model, 0, d, 0); |
|
58 | disconnect(d->m_model, 0, d, 0); | |
59 |
|
59 | |||
60 | d->m_model = model; |
|
60 | d->m_model = model; | |
61 | d->initializeBoxFromModel(); |
|
61 | d->initializeBoxFromModel(); | |
62 | // connect signals from the model |
|
62 | // connect signals from the model | |
|
63 | connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializeBoxFromModel())); | |||
63 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
64 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
64 | connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int))); |
|
65 | connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int))); | |
65 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); |
|
66 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
66 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); |
|
67 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
67 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); |
|
68 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
68 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); |
|
69 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
69 | connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); |
|
70 | connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); | |
70 | } |
|
71 | } | |
71 |
|
72 | |||
72 | QBoxPlotSeries *QBoxPlotModelMapper::series() const |
|
73 | QBoxPlotSeries *QBoxPlotModelMapper::series() const | |
73 | { |
|
74 | { | |
74 | Q_D(const QBoxPlotModelMapper); |
|
75 | Q_D(const QBoxPlotModelMapper); | |
75 | return d->m_series; |
|
76 | return d->m_series; | |
76 | } |
|
77 | } | |
77 |
|
78 | |||
78 | void QBoxPlotModelMapper::setSeries(QBoxPlotSeries *series) |
|
79 | void QBoxPlotModelMapper::setSeries(QBoxPlotSeries *series) | |
79 | { |
|
80 | { | |
80 | Q_D(QBoxPlotModelMapper); |
|
81 | Q_D(QBoxPlotModelMapper); | |
81 | if (d->m_series) |
|
82 | if (d->m_series) | |
82 | disconnect(d->m_series, 0, d, 0); |
|
83 | disconnect(d->m_series, 0, d, 0); | |
83 |
|
84 | |||
84 | if (series == 0) |
|
85 | if (series == 0) | |
85 | return; |
|
86 | return; | |
86 |
|
87 | |||
87 | d->m_series = series; |
|
88 | d->m_series = series; | |
88 | d->initializeBoxFromModel(); |
|
89 | d->initializeBoxFromModel(); | |
89 | // connect the signals from the series |
|
90 | // connect the signals from the series | |
90 | connect(d->m_series, SIGNAL(boxsetsAdded(QList<QBoxSet *>)), d, SLOT(boxSetsAdded(QList<QBoxSet *>))); |
|
91 | connect(d->m_series, SIGNAL(boxsetsAdded(QList<QBoxSet *>)), d, SLOT(boxSetsAdded(QList<QBoxSet *>))); | |
91 | connect(d->m_series, SIGNAL(boxsetsRemoved(QList<QBoxSet *>)), d, SLOT(boxSetsRemoved(QList<QBoxSet *>))); |
|
92 | connect(d->m_series, SIGNAL(boxsetsRemoved(QList<QBoxSet *>)), d, SLOT(boxSetsRemoved(QList<QBoxSet *>))); | |
92 | connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); |
|
93 | connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); | |
93 | } |
|
94 | } | |
94 |
|
95 | |||
95 | /*! |
|
96 | /*! | |
96 | Returns which row/column of the model contains the first values of the QBoxSets in the series. |
|
97 | Returns which row/column of the model contains the first values of the QBoxSets in the series. | |
97 | The default value is 0. |
|
98 | The default value is 0. | |
98 | */ |
|
99 | */ | |
99 | int QBoxPlotModelMapper::first() const |
|
100 | int QBoxPlotModelMapper::first() const | |
100 | { |
|
101 | { | |
101 | Q_D(const QBoxPlotModelMapper); |
|
102 | Q_D(const QBoxPlotModelMapper); | |
102 | return d->m_first; |
|
103 | return d->m_first; | |
103 | } |
|
104 | } | |
104 |
|
105 | |||
105 | /*! |
|
106 | /*! | |
106 | Sets which row/column of the model contains the \a first values of the QBoxSets in the series. |
|
107 | Sets which row/column of the model contains the \a first values of the QBoxSets in the series. | |
107 | The default value is 0. |
|
108 | The default value is 0. | |
108 | */ |
|
109 | */ | |
109 | void QBoxPlotModelMapper::setFirst(int first) |
|
110 | void QBoxPlotModelMapper::setFirst(int first) | |
110 | { |
|
111 | { | |
111 | Q_D(QBoxPlotModelMapper); |
|
112 | Q_D(QBoxPlotModelMapper); | |
112 | d->m_first = qMax(first, 0); |
|
113 | d->m_first = qMax(first, 0); | |
113 | d->initializeBoxFromModel(); |
|
114 | d->initializeBoxFromModel(); | |
114 | } |
|
115 | } | |
115 |
|
116 | |||
116 | /*! |
|
117 | /*! | |
117 | Returns the number of rows/columns of the model that are mapped as the data for QBoxPlotSeries |
|
118 | Returns the number of rows/columns of the model that are mapped as the data for QBoxPlotSeries | |
118 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) |
|
119 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) | |
119 | */ |
|
120 | */ | |
120 | int QBoxPlotModelMapper::count() const |
|
121 | int QBoxPlotModelMapper::count() const | |
121 | { |
|
122 | { | |
122 | Q_D(const QBoxPlotModelMapper); |
|
123 | Q_D(const QBoxPlotModelMapper); | |
123 | return d->m_count; |
|
124 | return d->m_count; | |
124 | } |
|
125 | } | |
125 |
|
126 | |||
126 | /*! |
|
127 | /*! | |
127 | Sets the \a count of rows/columns of the model that are mapped as the data for QBoxPlotSeries |
|
128 | Sets the \a count of rows/columns of the model that are mapped as the data for QBoxPlotSeries | |
128 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) |
|
129 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) | |
129 | */ |
|
130 | */ | |
130 | void QBoxPlotModelMapper::setCount(int count) |
|
131 | void QBoxPlotModelMapper::setCount(int count) | |
131 | { |
|
132 | { | |
132 | Q_D(QBoxPlotModelMapper); |
|
133 | Q_D(QBoxPlotModelMapper); | |
133 | d->m_count = qMax(count, -1); |
|
134 | d->m_count = qMax(count, -1); | |
134 | d->initializeBoxFromModel(); |
|
135 | d->initializeBoxFromModel(); | |
135 | } |
|
136 | } | |
136 |
|
137 | |||
137 | /*! |
|
138 | /*! | |
138 | Returns the orientation that is used when QBoxPlotModelMapper accesses the model. |
|
139 | Returns the orientation that is used when QBoxPlotModelMapper accesses the model. | |
139 | This means whether the consecutive values of the box-and-whiskers set are read from row (Qt::Horizontal) |
|
140 | This means whether the consecutive values of the box-and-whiskers set are read from row (Qt::Horizontal) | |
140 | or from columns (Qt::Vertical) |
|
141 | or from columns (Qt::Vertical) | |
141 | */ |
|
142 | */ | |
142 | Qt::Orientation QBoxPlotModelMapper::orientation() const |
|
143 | Qt::Orientation QBoxPlotModelMapper::orientation() const | |
143 | { |
|
144 | { | |
144 | Q_D(const QBoxPlotModelMapper); |
|
145 | Q_D(const QBoxPlotModelMapper); | |
145 | return d->m_orientation; |
|
146 | return d->m_orientation; | |
146 | } |
|
147 | } | |
147 |
|
148 | |||
148 | /*! |
|
149 | /*! | |
149 | Returns the \a orientation that is used when QBoxPlotModelMapper accesses the model. |
|
150 | Returns the \a orientation that is used when QBoxPlotModelMapper accesses the model. | |
150 | This mean whether the consecutive values of the box-and-whiskers set are read from row (Qt::Horizontal) |
|
151 | This mean whether the consecutive values of the box-and-whiskers set are read from row (Qt::Horizontal) | |
151 | or from columns (Qt::Vertical) |
|
152 | or from columns (Qt::Vertical) | |
152 | */ |
|
153 | */ | |
153 | void QBoxPlotModelMapper::setOrientation(Qt::Orientation orientation) |
|
154 | void QBoxPlotModelMapper::setOrientation(Qt::Orientation orientation) | |
154 | { |
|
155 | { | |
155 | Q_D(QBoxPlotModelMapper); |
|
156 | Q_D(QBoxPlotModelMapper); | |
156 | d->m_orientation = orientation; |
|
157 | d->m_orientation = orientation; | |
157 | d->initializeBoxFromModel(); |
|
158 | d->initializeBoxFromModel(); | |
158 | } |
|
159 | } | |
159 |
|
160 | |||
160 | /*! |
|
161 | /*! | |
161 | Returns which section of the model is used as the data source for the first box set |
|
162 | Returns which section of the model is used as the data source for the first box set | |
162 | */ |
|
163 | */ | |
163 | int QBoxPlotModelMapper::firstBoxSetSection() const |
|
164 | int QBoxPlotModelMapper::firstBoxSetSection() const | |
164 | { |
|
165 | { | |
165 | Q_D(const QBoxPlotModelMapper); |
|
166 | Q_D(const QBoxPlotModelMapper); | |
166 | return d->m_firstBoxSetSection; |
|
167 | return d->m_firstBoxSetSection; | |
167 | } |
|
168 | } | |
168 |
|
169 | |||
169 | /*! |
|
170 | /*! | |
170 | Sets the model section that is used as the data source for the first box set |
|
171 | Sets the model section that is used as the data source for the first box set | |
171 | Parameter \a firstBoxSetSection specifies the section of the model. |
|
172 | Parameter \a firstBoxSetSection specifies the section of the model. | |
172 | */ |
|
173 | */ | |
173 | void QBoxPlotModelMapper::setFirstBoxSetSection(int firstBoxSetSection) |
|
174 | void QBoxPlotModelMapper::setFirstBoxSetSection(int firstBoxSetSection) | |
174 | { |
|
175 | { | |
175 | Q_D(QBoxPlotModelMapper); |
|
176 | Q_D(QBoxPlotModelMapper); | |
176 | d->m_firstBoxSetSection = qMax(-1, firstBoxSetSection); |
|
177 | d->m_firstBoxSetSection = qMax(-1, firstBoxSetSection); | |
177 | d->initializeBoxFromModel(); |
|
178 | d->initializeBoxFromModel(); | |
178 | } |
|
179 | } | |
179 |
|
180 | |||
180 | /*! |
|
181 | /*! | |
181 | Returns which section of the model is used as the data source for the last box set |
|
182 | Returns which section of the model is used as the data source for the last box set | |
182 | */ |
|
183 | */ | |
183 | int QBoxPlotModelMapper::lastBoxSetSection() const |
|
184 | int QBoxPlotModelMapper::lastBoxSetSection() const | |
184 | { |
|
185 | { | |
185 | Q_D(const QBoxPlotModelMapper); |
|
186 | Q_D(const QBoxPlotModelMapper); | |
186 | return d->m_lastBoxSetSection; |
|
187 | return d->m_lastBoxSetSection; | |
187 | } |
|
188 | } | |
188 |
|
189 | |||
189 | /*! |
|
190 | /*! | |
190 | Sets the model section that is used as the data source for the last box set |
|
191 | Sets the model section that is used as the data source for the last box set | |
191 | Parameter \a lastBoxSetSection specifies the section of the model. |
|
192 | Parameter \a lastBoxSetSection specifies the section of the model. | |
192 | */ |
|
193 | */ | |
193 | void QBoxPlotModelMapper::setLastBoxSetSection(int lastBoxSetSection) |
|
194 | void QBoxPlotModelMapper::setLastBoxSetSection(int lastBoxSetSection) | |
194 | { |
|
195 | { | |
195 | Q_D(QBoxPlotModelMapper); |
|
196 | Q_D(QBoxPlotModelMapper); | |
196 | d->m_lastBoxSetSection = qMax(-1, lastBoxSetSection); |
|
197 | d->m_lastBoxSetSection = qMax(-1, lastBoxSetSection); | |
197 | d->initializeBoxFromModel(); |
|
198 | d->initializeBoxFromModel(); | |
198 | } |
|
199 | } | |
199 |
|
200 | |||
200 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
201 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
201 |
|
202 | |||
202 | QBoxPlotModelMapperPrivate::QBoxPlotModelMapperPrivate(QBoxPlotModelMapper *q) : |
|
203 | QBoxPlotModelMapperPrivate::QBoxPlotModelMapperPrivate(QBoxPlotModelMapper *q) : | |
203 | QObject(q), |
|
204 | QObject(q), | |
204 | m_series(0), |
|
205 | m_series(0), | |
205 | m_model(0), |
|
206 | m_model(0), | |
206 | m_first(0), |
|
207 | m_first(0), | |
207 | m_count(-1), |
|
208 | m_count(-1), | |
208 | m_orientation(Qt::Vertical), |
|
209 | m_orientation(Qt::Vertical), | |
209 | m_firstBoxSetSection(-1), |
|
210 | m_firstBoxSetSection(-1), | |
210 | m_lastBoxSetSection(-1), |
|
211 | m_lastBoxSetSection(-1), | |
211 | m_seriesSignalsBlock(false), |
|
212 | m_seriesSignalsBlock(false), | |
212 | m_modelSignalsBlock(false), |
|
213 | m_modelSignalsBlock(false), | |
213 | q_ptr(q) |
|
214 | q_ptr(q) | |
214 | { |
|
215 | { | |
215 | } |
|
216 | } | |
216 |
|
217 | |||
217 | void QBoxPlotModelMapperPrivate::blockModelSignals(bool block) |
|
218 | void QBoxPlotModelMapperPrivate::blockModelSignals(bool block) | |
218 | { |
|
219 | { | |
219 | m_modelSignalsBlock = block; |
|
220 | m_modelSignalsBlock = block; | |
220 | } |
|
221 | } | |
221 |
|
222 | |||
222 | void QBoxPlotModelMapperPrivate::blockSeriesSignals(bool block) |
|
223 | void QBoxPlotModelMapperPrivate::blockSeriesSignals(bool block) | |
223 | { |
|
224 | { | |
224 | m_seriesSignalsBlock = block; |
|
225 | m_seriesSignalsBlock = block; | |
225 | } |
|
226 | } | |
226 |
|
227 | |||
227 | QBoxSet *QBoxPlotModelMapperPrivate::boxSet(QModelIndex index) |
|
228 | QBoxSet *QBoxPlotModelMapperPrivate::boxSet(QModelIndex index) | |
228 | { |
|
229 | { | |
229 | if (!index.isValid()) |
|
230 | if (!index.isValid()) | |
230 | return 0; |
|
231 | return 0; | |
231 |
|
232 | |||
232 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBoxSetSection && index.column() <= m_lastBoxSetSection) { |
|
233 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBoxSetSection && index.column() <= m_lastBoxSetSection) { | |
233 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) |
|
234 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) | |
234 | return m_series->boxSets().at(index.column() - m_firstBoxSetSection); |
|
235 | return m_series->boxSets().at(index.column() - m_firstBoxSetSection); | |
235 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBoxSetSection && index.row() <= m_lastBoxSetSection) { |
|
236 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBoxSetSection && index.row() <= m_lastBoxSetSection) { | |
236 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) |
|
237 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) | |
237 | return m_series->boxSets().at(index.row() - m_firstBoxSetSection); |
|
238 | return m_series->boxSets().at(index.row() - m_firstBoxSetSection); | |
238 | } |
|
239 | } | |
239 | return 0; // This part of model has not been mapped to any boxset |
|
240 | return 0; // This part of model has not been mapped to any boxset | |
240 | } |
|
241 | } | |
241 |
|
242 | |||
242 | QModelIndex QBoxPlotModelMapperPrivate::boxModelIndex(int boxSection, int posInBar) |
|
243 | QModelIndex QBoxPlotModelMapperPrivate::boxModelIndex(int boxSection, int posInBar) | |
243 | { |
|
244 | { | |
244 | if (m_count != -1 && posInBar >= m_count) |
|
245 | if (m_count != -1 && posInBar >= m_count) | |
245 | return QModelIndex(); // invalid |
|
246 | return QModelIndex(); // invalid | |
246 |
|
247 | |||
247 | if (boxSection < m_firstBoxSetSection || boxSection > m_lastBoxSetSection) |
|
248 | if (boxSection < m_firstBoxSetSection || boxSection > m_lastBoxSetSection) | |
248 | return QModelIndex(); // invalid |
|
249 | return QModelIndex(); // invalid | |
249 |
|
250 | |||
250 | if (m_orientation == Qt::Vertical) |
|
251 | if (m_orientation == Qt::Vertical) | |
251 | return m_model->index(posInBar + m_first, boxSection); |
|
252 | return m_model->index(posInBar + m_first, boxSection); | |
252 | else |
|
253 | else | |
253 | return m_model->index(boxSection, posInBar + m_first); |
|
254 | return m_model->index(boxSection, posInBar + m_first); | |
254 | } |
|
255 | } | |
255 |
|
256 | |||
256 | void QBoxPlotModelMapperPrivate::handleSeriesDestroyed() |
|
257 | void QBoxPlotModelMapperPrivate::handleSeriesDestroyed() | |
257 | { |
|
258 | { | |
258 | m_series = 0; |
|
259 | m_series = 0; | |
259 | } |
|
260 | } | |
260 |
|
261 | |||
261 | void QBoxPlotModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
262 | void QBoxPlotModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
262 | { |
|
263 | { | |
263 | Q_UNUSED(topLeft) |
|
264 | Q_UNUSED(topLeft) | |
264 | Q_UNUSED(bottomRight) |
|
265 | Q_UNUSED(bottomRight) | |
265 |
|
266 | |||
266 | if (m_model == 0 || m_series == 0) |
|
267 | if (m_model == 0 || m_series == 0) | |
267 | return; |
|
268 | return; | |
268 |
|
269 | |||
269 | if (m_modelSignalsBlock) |
|
270 | if (m_modelSignalsBlock) | |
270 | return; |
|
271 | return; | |
271 |
|
272 | |||
272 | blockSeriesSignals(); |
|
273 | blockSeriesSignals(); | |
273 | QModelIndex index; |
|
274 | QModelIndex index; | |
274 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { |
|
275 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
275 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { |
|
276 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { | |
276 | index = topLeft.sibling(row, column); |
|
277 | index = topLeft.sibling(row, column); | |
277 | QBoxSet *box = boxSet(index); |
|
278 | QBoxSet *box = boxSet(index); | |
278 | if (box) { |
|
279 | if (box) { | |
279 | if (m_orientation == Qt::Vertical) |
|
280 | if (m_orientation == Qt::Vertical) | |
280 | box->setValue(row - m_first, m_model->data(index).toReal()); |
|
281 | box->setValue(row - m_first, m_model->data(index).toReal()); | |
281 | else |
|
282 | else | |
282 | box->setValue(column - m_first, m_model->data(index).toReal()); |
|
283 | box->setValue(column - m_first, m_model->data(index).toReal()); | |
283 | } |
|
284 | } | |
284 | } |
|
285 | } | |
285 | } |
|
286 | } | |
286 | blockSeriesSignals(false); |
|
287 | blockSeriesSignals(false); | |
287 | } |
|
288 | } | |
288 |
|
289 | |||
289 | void QBoxPlotModelMapperPrivate::modelHeaderDataUpdated(Qt::Orientation orientation, int first, int last) |
|
290 | void QBoxPlotModelMapperPrivate::modelHeaderDataUpdated(Qt::Orientation orientation, int first, int last) | |
290 | { |
|
291 | { | |
291 | Q_UNUSED(orientation); |
|
292 | Q_UNUSED(orientation); | |
292 | Q_UNUSED(first); |
|
293 | Q_UNUSED(first); | |
293 | Q_UNUSED(last); |
|
294 | Q_UNUSED(last); | |
294 | } |
|
295 | } | |
295 |
|
296 | |||
296 | void QBoxPlotModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) |
|
297 | void QBoxPlotModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) | |
297 | { |
|
298 | { | |
298 | Q_UNUSED(parent) |
|
299 | Q_UNUSED(parent) | |
299 | if (m_modelSignalsBlock) |
|
300 | if (m_modelSignalsBlock) | |
300 | return; |
|
301 | return; | |
301 |
|
302 | |||
302 | blockSeriesSignals(); |
|
303 | blockSeriesSignals(); | |
303 | if (m_orientation == Qt::Vertical) |
|
304 | if (m_orientation == Qt::Vertical) | |
304 | insertData(start, end); |
|
305 | insertData(start, end); | |
305 | else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize |
|
306 | else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize | |
306 | initializeBoxFromModel(); |
|
307 | initializeBoxFromModel(); | |
307 | blockSeriesSignals(false); |
|
308 | blockSeriesSignals(false); | |
308 | } |
|
309 | } | |
309 |
|
310 | |||
310 | void QBoxPlotModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) |
|
311 | void QBoxPlotModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) | |
311 | { |
|
312 | { | |
312 | Q_UNUSED(parent) |
|
313 | Q_UNUSED(parent) | |
313 | if (m_modelSignalsBlock) |
|
314 | if (m_modelSignalsBlock) | |
314 | return; |
|
315 | return; | |
315 |
|
316 | |||
316 | blockSeriesSignals(); |
|
317 | blockSeriesSignals(); | |
317 | if (m_orientation == Qt::Vertical) |
|
318 | if (m_orientation == Qt::Vertical) | |
318 | removeData(start, end); |
|
319 | removeData(start, end); | |
319 | else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize |
|
320 | else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize | |
320 | initializeBoxFromModel(); |
|
321 | initializeBoxFromModel(); | |
321 | blockSeriesSignals(false); |
|
322 | blockSeriesSignals(false); | |
322 | } |
|
323 | } | |
323 |
|
324 | |||
324 | void QBoxPlotModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) |
|
325 | void QBoxPlotModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) | |
325 | { |
|
326 | { | |
326 | Q_UNUSED(parent) |
|
327 | Q_UNUSED(parent) | |
327 | if (m_modelSignalsBlock) |
|
328 | if (m_modelSignalsBlock) | |
328 | return; |
|
329 | return; | |
329 |
|
330 | |||
330 | blockSeriesSignals(); |
|
331 | blockSeriesSignals(); | |
331 | if (m_orientation == Qt::Horizontal) |
|
332 | if (m_orientation == Qt::Horizontal) | |
332 | insertData(start, end); |
|
333 | insertData(start, end); | |
333 | else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize |
|
334 | else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize | |
334 | initializeBoxFromModel(); |
|
335 | initializeBoxFromModel(); | |
335 | blockSeriesSignals(false); |
|
336 | blockSeriesSignals(false); | |
336 | } |
|
337 | } | |
337 |
|
338 | |||
338 | void QBoxPlotModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) |
|
339 | void QBoxPlotModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) | |
339 | { |
|
340 | { | |
340 | Q_UNUSED(parent) |
|
341 | Q_UNUSED(parent) | |
341 | if (m_modelSignalsBlock) |
|
342 | if (m_modelSignalsBlock) | |
342 | return; |
|
343 | return; | |
343 |
|
344 | |||
344 | blockSeriesSignals(); |
|
345 | blockSeriesSignals(); | |
345 | if (m_orientation == Qt::Horizontal) |
|
346 | if (m_orientation == Qt::Horizontal) | |
346 | removeData(start, end); |
|
347 | removeData(start, end); | |
347 | else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize |
|
348 | else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize | |
348 | initializeBoxFromModel(); |
|
349 | initializeBoxFromModel(); | |
349 | blockSeriesSignals(false); |
|
350 | blockSeriesSignals(false); | |
350 | } |
|
351 | } | |
351 |
|
352 | |||
352 | void QBoxPlotModelMapperPrivate::handleModelDestroyed() |
|
353 | void QBoxPlotModelMapperPrivate::handleModelDestroyed() | |
353 | { |
|
354 | { | |
354 | m_model = 0; |
|
355 | m_model = 0; | |
355 | } |
|
356 | } | |
356 |
|
357 | |||
357 | void QBoxPlotModelMapperPrivate::insertData(int start, int end) |
|
358 | void QBoxPlotModelMapperPrivate::insertData(int start, int end) | |
358 | { |
|
359 | { | |
359 | Q_UNUSED(end) |
|
360 | Q_UNUSED(end) | |
360 | Q_UNUSED(start) |
|
361 | Q_UNUSED(start) | |
361 | Q_UNUSED(end) |
|
362 | Q_UNUSED(end) | |
362 | // Currently boxplotchart needs to be fully recalculated when change is made. |
|
363 | // Currently boxplotchart needs to be fully recalculated when change is made. | |
363 | // Re-initialize |
|
364 | // Re-initialize | |
364 | initializeBoxFromModel(); |
|
365 | initializeBoxFromModel(); | |
365 | } |
|
366 | } | |
366 |
|
367 | |||
367 | void QBoxPlotModelMapperPrivate::removeData(int start, int end) |
|
368 | void QBoxPlotModelMapperPrivate::removeData(int start, int end) | |
368 | { |
|
369 | { | |
369 | Q_UNUSED(end) |
|
370 | Q_UNUSED(end) | |
370 | Q_UNUSED(start) |
|
371 | Q_UNUSED(start) | |
371 | Q_UNUSED(end) |
|
372 | Q_UNUSED(end) | |
372 | // Currently boxplotchart needs to be fully recalculated when change is made. |
|
373 | // Currently boxplotchart needs to be fully recalculated when change is made. | |
373 | // Re-initialize |
|
374 | // Re-initialize | |
374 | initializeBoxFromModel(); |
|
375 | initializeBoxFromModel(); | |
375 | } |
|
376 | } | |
376 |
|
377 | |||
377 | void QBoxPlotModelMapperPrivate::boxSetsAdded(QList<QBoxSet *> sets) |
|
378 | void QBoxPlotModelMapperPrivate::boxSetsAdded(QList<QBoxSet *> sets) | |
378 | { |
|
379 | { | |
379 | if (m_seriesSignalsBlock) |
|
380 | if (m_seriesSignalsBlock) | |
380 | return; |
|
381 | return; | |
381 |
|
382 | |||
382 | if (sets.count() == 0) |
|
383 | if (sets.count() == 0) | |
383 | return; |
|
384 | return; | |
384 |
|
385 | |||
385 | int firstIndex = m_series->boxSets().indexOf(sets.at(0)); |
|
386 | int firstIndex = m_series->boxSets().indexOf(sets.at(0)); | |
386 | if (firstIndex == -1) |
|
387 | if (firstIndex == -1) | |
387 | return; |
|
388 | return; | |
388 |
|
389 | |||
389 | int maxCount = 0; |
|
390 | int maxCount = 0; | |
390 | for (int i = 0; i < sets.count(); i++) { |
|
391 | for (int i = 0; i < sets.count(); i++) { | |
391 | if (sets.at(i)->count() > m_count) |
|
392 | if (sets.at(i)->count() > m_count) | |
392 | maxCount = sets.at(i)->count(); |
|
393 | maxCount = sets.at(i)->count(); | |
393 | } |
|
394 | } | |
394 |
|
395 | |||
395 | if (m_count != -1 && m_count < maxCount) |
|
396 | if (m_count != -1 && m_count < maxCount) | |
396 | m_count = maxCount; |
|
397 | m_count = maxCount; | |
397 |
|
398 | |||
398 | m_lastBoxSetSection += sets.count(); |
|
399 | m_lastBoxSetSection += sets.count(); | |
399 |
|
400 | |||
400 | blockModelSignals(); |
|
401 | blockModelSignals(); | |
401 | int modelCapacity = m_orientation == Qt::Vertical ? m_model->rowCount() - m_first : m_model->columnCount() - m_first; |
|
402 | int modelCapacity = m_orientation == Qt::Vertical ? m_model->rowCount() - m_first : m_model->columnCount() - m_first; | |
402 | if (maxCount > modelCapacity) { |
|
403 | if (maxCount > modelCapacity) { | |
403 | if (m_orientation == Qt::Vertical) |
|
404 | if (m_orientation == Qt::Vertical) | |
404 | m_model->insertRows(m_model->rowCount(), maxCount - modelCapacity); |
|
405 | m_model->insertRows(m_model->rowCount(), maxCount - modelCapacity); | |
405 | else |
|
406 | else | |
406 | m_model->insertColumns(m_model->columnCount(), maxCount - modelCapacity); |
|
407 | m_model->insertColumns(m_model->columnCount(), maxCount - modelCapacity); | |
407 | } |
|
408 | } | |
408 |
|
409 | |||
409 | if (m_orientation == Qt::Vertical) |
|
410 | if (m_orientation == Qt::Vertical) | |
410 | m_model->insertColumns(firstIndex + m_firstBoxSetSection, sets.count()); |
|
411 | m_model->insertColumns(firstIndex + m_firstBoxSetSection, sets.count()); | |
411 | else |
|
412 | else | |
412 | m_model->insertRows(firstIndex + m_firstBoxSetSection, sets.count()); |
|
413 | m_model->insertRows(firstIndex + m_firstBoxSetSection, sets.count()); | |
413 |
|
414 | |||
414 |
|
415 | |||
415 | for (int i = firstIndex + m_firstBoxSetSection; i < firstIndex + m_firstBoxSetSection + sets.count(); i++) { |
|
416 | for (int i = firstIndex + m_firstBoxSetSection; i < firstIndex + m_firstBoxSetSection + sets.count(); i++) { | |
416 | for (int j = 0; j < sets.at(i - firstIndex - m_firstBoxSetSection)->count(); j++) |
|
417 | for (int j = 0; j < sets.at(i - firstIndex - m_firstBoxSetSection)->count(); j++) | |
417 | m_model->setData(boxModelIndex(i, j), sets.at(i - firstIndex - m_firstBoxSetSection)->at(j)); |
|
418 | m_model->setData(boxModelIndex(i, j), sets.at(i - firstIndex - m_firstBoxSetSection)->at(j)); | |
418 | } |
|
419 | } | |
419 | blockModelSignals(false); |
|
420 | blockModelSignals(false); | |
420 | initializeBoxFromModel(); |
|
421 | initializeBoxFromModel(); | |
421 | } |
|
422 | } | |
422 |
|
423 | |||
423 | void QBoxPlotModelMapperPrivate::boxSetsRemoved(QList<QBoxSet *> sets) |
|
424 | void QBoxPlotModelMapperPrivate::boxSetsRemoved(QList<QBoxSet *> sets) | |
424 | { |
|
425 | { | |
425 | if (m_seriesSignalsBlock) |
|
426 | if (m_seriesSignalsBlock) | |
426 | return; |
|
427 | return; | |
427 |
|
428 | |||
428 | if (sets.count() == 0) |
|
429 | if (sets.count() == 0) | |
429 | return; |
|
430 | return; | |
430 |
|
431 | |||
431 | int firstIndex = m_boxSets.indexOf(sets.at(0)); |
|
432 | int firstIndex = m_boxSets.indexOf(sets.at(0)); | |
432 | if (firstIndex == -1) |
|
433 | if (firstIndex == -1) | |
433 | return; |
|
434 | return; | |
434 |
|
435 | |||
435 | m_lastBoxSetSection -= sets.count(); |
|
436 | m_lastBoxSetSection -= sets.count(); | |
436 |
|
437 | |||
437 | for (int i = firstIndex + sets.count() - 1; i >= firstIndex; i--) |
|
438 | for (int i = firstIndex + sets.count() - 1; i >= firstIndex; i--) | |
438 | m_boxSets.removeAt(i); |
|
439 | m_boxSets.removeAt(i); | |
439 |
|
440 | |||
440 | blockModelSignals(); |
|
441 | blockModelSignals(); | |
441 | if (m_orientation == Qt::Vertical) |
|
442 | if (m_orientation == Qt::Vertical) | |
442 | m_model->removeColumns(firstIndex + m_firstBoxSetSection, sets.count()); |
|
443 | m_model->removeColumns(firstIndex + m_firstBoxSetSection, sets.count()); | |
443 | else |
|
444 | else | |
444 | m_model->removeRows(firstIndex + m_firstBoxSetSection, sets.count()); |
|
445 | m_model->removeRows(firstIndex + m_firstBoxSetSection, sets.count()); | |
445 | blockModelSignals(false); |
|
446 | blockModelSignals(false); | |
446 | initializeBoxFromModel(); |
|
447 | initializeBoxFromModel(); | |
447 | } |
|
448 | } | |
448 |
|
449 | |||
449 | void QBoxPlotModelMapperPrivate::boxValueChanged(int index) |
|
450 | void QBoxPlotModelMapperPrivate::boxValueChanged(int index) | |
450 | { |
|
451 | { | |
451 | if (m_seriesSignalsBlock) |
|
452 | if (m_seriesSignalsBlock) | |
452 | return; |
|
453 | return; | |
453 |
|
454 | |||
454 | int boxSetIndex = m_boxSets.indexOf(qobject_cast<QBoxSet *>(QObject::sender())); |
|
455 | int boxSetIndex = m_boxSets.indexOf(qobject_cast<QBoxSet *>(QObject::sender())); | |
455 |
|
456 | |||
456 | blockModelSignals(); |
|
457 | blockModelSignals(); | |
457 | m_model->setData(boxModelIndex(boxSetIndex + m_firstBoxSetSection, index), m_boxSets.at(boxSetIndex)->at(index)); |
|
458 | m_model->setData(boxModelIndex(boxSetIndex + m_firstBoxSetSection, index), m_boxSets.at(boxSetIndex)->at(index)); | |
458 | blockModelSignals(false); |
|
459 | blockModelSignals(false); | |
459 | initializeBoxFromModel(); |
|
460 | initializeBoxFromModel(); | |
460 | } |
|
461 | } | |
461 |
|
462 | |||
462 | void QBoxPlotModelMapperPrivate::initializeBoxFromModel() |
|
463 | void QBoxPlotModelMapperPrivate::initializeBoxFromModel() | |
463 | { |
|
464 | { | |
464 | if (m_model == 0 || m_series == 0) |
|
465 | if (m_model == 0 || m_series == 0) | |
465 | return; |
|
466 | return; | |
466 |
|
467 | |||
467 | blockSeriesSignals(); |
|
468 | blockSeriesSignals(); | |
468 | // clear current content |
|
469 | // clear current content | |
469 | m_series->clear(); |
|
470 | m_series->clear(); | |
470 | m_boxSets.clear(); |
|
471 | m_boxSets.clear(); | |
471 |
|
472 | |||
472 | // create the initial box-and-whiskers sets |
|
473 | // create the initial box-and-whiskers sets | |
473 | for (int i = m_firstBoxSetSection; i <= m_lastBoxSetSection; i++) { |
|
474 | for (int i = m_firstBoxSetSection; i <= m_lastBoxSetSection; i++) { | |
474 | int posInBar = 0; |
|
475 | int posInBar = 0; | |
475 | QModelIndex boxIndex = boxModelIndex(i, posInBar); |
|
476 | QModelIndex boxIndex = boxModelIndex(i, posInBar); | |
476 | // check if there is such model index |
|
477 | // check if there is such model index | |
477 | if (boxIndex.isValid()) { |
|
478 | if (boxIndex.isValid()) { | |
478 | QBoxSet *boxSet = new QBoxSet(); |
|
479 | QBoxSet *boxSet = new QBoxSet(); | |
479 | while (boxIndex.isValid()) { |
|
480 | while (boxIndex.isValid()) { | |
480 | boxSet->append(m_model->data(boxIndex, Qt::DisplayRole).toDouble()); |
|
481 | boxSet->append(m_model->data(boxIndex, Qt::DisplayRole).toDouble()); | |
481 | posInBar++; |
|
482 | posInBar++; | |
482 | boxIndex = boxModelIndex(i, posInBar); |
|
483 | boxIndex = boxModelIndex(i, posInBar); | |
483 | } |
|
484 | } | |
484 | connect(boxSet, SIGNAL(valueChanged(int)), this, SLOT(boxValueChanged(int))); |
|
485 | connect(boxSet, SIGNAL(valueChanged(int)), this, SLOT(boxValueChanged(int))); | |
485 | m_series->append(boxSet); |
|
486 | m_series->append(boxSet); | |
486 | m_boxSets.append(boxSet); |
|
487 | m_boxSets.append(boxSet); | |
487 | } else { |
|
488 | } else { | |
488 | break; |
|
489 | break; | |
489 | } |
|
490 | } | |
490 | } |
|
491 | } | |
491 | blockSeriesSignals(false); |
|
492 | blockSeriesSignals(false); | |
492 | } |
|
493 | } | |
493 |
|
494 | |||
494 | #include "moc_qboxplotmodelmapper.cpp" |
|
495 | #include "moc_qboxplotmodelmapper.cpp" | |
495 | #include "moc_qboxplotmodelmapper_p.cpp" |
|
496 | #include "moc_qboxplotmodelmapper_p.cpp" | |
496 |
|
497 | |||
497 | QT_CHARTS_END_NAMESPACE |
|
498 | QT_CHARTS_END_NAMESPACE | |
498 |
|
499 |
@@ -1,80 +1,80 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QBOXPLOTMODELMAPPER_H |
|
30 | #ifndef QBOXPLOTMODELMAPPER_H | |
31 | #define QBOXPLOTMODELMAPPER_H |
|
31 | #define QBOXPLOTMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCore/QObject> |
|
34 | #include <QtCore/QObject> | |
35 |
|
35 | |||
36 | QT_BEGIN_NAMESPACE |
|
36 | QT_BEGIN_NAMESPACE | |
37 | class QAbstractItemModel; |
|
37 | class QAbstractItemModel; | |
38 | QT_END_NAMESPACE |
|
38 | QT_END_NAMESPACE | |
39 |
|
39 | |||
40 | QT_CHARTS_BEGIN_NAMESPACE |
|
40 | QT_CHARTS_BEGIN_NAMESPACE | |
41 |
|
41 | |||
42 | class QBoxPlotModelMapperPrivate; |
|
42 | class QBoxPlotModelMapperPrivate; | |
43 | class QBoxPlotSeries; |
|
43 | class QBoxPlotSeries; | |
44 |
|
44 | |||
45 | class QT_CHARTS_EXPORT QBoxPlotModelMapper : public QObject |
|
45 | class QT_CHARTS_EXPORT QBoxPlotModelMapper : public QObject | |
46 | { |
|
46 | { | |
47 | Q_OBJECT |
|
47 | Q_OBJECT | |
48 |
|
48 | |||
49 | protected: |
|
49 | protected: | |
50 |
explicit QBoxPlotModelMapper(QObject *parent = |
|
50 | explicit QBoxPlotModelMapper(QObject *parent = Q_NULLPTR); | |
51 |
|
51 | |||
52 | QAbstractItemModel *model() const; |
|
52 | QAbstractItemModel *model() const; | |
53 | void setModel(QAbstractItemModel *model); |
|
53 | void setModel(QAbstractItemModel *model); | |
54 |
|
54 | |||
55 | QBoxPlotSeries *series() const; |
|
55 | QBoxPlotSeries *series() const; | |
56 | void setSeries(QBoxPlotSeries *series); |
|
56 | void setSeries(QBoxPlotSeries *series); | |
57 |
|
57 | |||
58 | int first() const; |
|
58 | int first() const; | |
59 | void setFirst(int first); |
|
59 | void setFirst(int first); | |
60 |
|
60 | |||
61 | int count() const; |
|
61 | int count() const; | |
62 | void setCount(int count); |
|
62 | void setCount(int count); | |
63 |
|
63 | |||
64 | int firstBoxSetSection() const; |
|
64 | int firstBoxSetSection() const; | |
65 | void setFirstBoxSetSection(int firstBoxSetSection); |
|
65 | void setFirstBoxSetSection(int firstBoxSetSection); | |
66 |
|
66 | |||
67 | int lastBoxSetSection() const; |
|
67 | int lastBoxSetSection() const; | |
68 | void setLastBoxSetSection(int lastBoxSetSection); |
|
68 | void setLastBoxSetSection(int lastBoxSetSection); | |
69 |
|
69 | |||
70 | Qt::Orientation orientation() const; |
|
70 | Qt::Orientation orientation() const; | |
71 | void setOrientation(Qt::Orientation orientation); |
|
71 | void setOrientation(Qt::Orientation orientation); | |
72 |
|
72 | |||
73 | protected: |
|
73 | protected: | |
74 | QBoxPlotModelMapperPrivate * const d_ptr; |
|
74 | QBoxPlotModelMapperPrivate * const d_ptr; | |
75 | Q_DECLARE_PRIVATE(QBoxPlotModelMapper) |
|
75 | Q_DECLARE_PRIVATE(QBoxPlotModelMapper) | |
76 | }; |
|
76 | }; | |
77 |
|
77 | |||
78 | QT_CHARTS_END_NAMESPACE |
|
78 | QT_CHARTS_END_NAMESPACE | |
79 |
|
79 | |||
80 | #endif // QBOXPLOTMODELMAPPER_H |
|
80 | #endif // QBOXPLOTMODELMAPPER_H |
@@ -1,97 +1,97 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QBOXPLOTSERIES_H |
|
30 | #ifndef QBOXPLOTSERIES_H | |
31 | #define QBOXPLOTSERIES_H |
|
31 | #define QBOXPLOTSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/QBoxSet> |
|
34 | #include <QtCharts/QBoxSet> | |
35 | #include <QtCharts/QAbstractSeries> |
|
35 | #include <QtCharts/QAbstractSeries> | |
36 |
|
36 | |||
37 | QT_CHARTS_BEGIN_NAMESPACE |
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class QBoxPlotSeriesPrivate; |
|
39 | class QBoxPlotSeriesPrivate; | |
40 |
|
40 | |||
41 | class QT_CHARTS_EXPORT QBoxPlotSeries : public QAbstractSeries |
|
41 | class QT_CHARTS_EXPORT QBoxPlotSeries : public QAbstractSeries | |
42 | { |
|
42 | { | |
43 | Q_OBJECT |
|
43 | Q_OBJECT | |
44 | Q_PROPERTY(bool boxOutlineVisible READ boxOutlineVisible WRITE setBoxOutlineVisible NOTIFY boxOutlineVisibilityChanged) |
|
44 | Q_PROPERTY(bool boxOutlineVisible READ boxOutlineVisible WRITE setBoxOutlineVisible NOTIFY boxOutlineVisibilityChanged) | |
45 | Q_PROPERTY(qreal boxWidth READ boxWidth WRITE setBoxWidth NOTIFY boxWidthChanged) |
|
45 | Q_PROPERTY(qreal boxWidth READ boxWidth WRITE setBoxWidth NOTIFY boxWidthChanged) | |
46 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
46 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
47 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
|
47 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |
48 | Q_PROPERTY(int count READ count NOTIFY countChanged REVISION 1) |
|
48 | Q_PROPERTY(int count READ count NOTIFY countChanged REVISION 1) | |
49 | public: |
|
49 | public: | |
50 |
explicit QBoxPlotSeries(QObject *parent = |
|
50 | explicit QBoxPlotSeries(QObject *parent = Q_NULLPTR); | |
51 | ~QBoxPlotSeries(); |
|
51 | ~QBoxPlotSeries(); | |
52 |
|
52 | |||
53 | bool append(QBoxSet *box); |
|
53 | bool append(QBoxSet *box); | |
54 | bool remove(QBoxSet *box); |
|
54 | bool remove(QBoxSet *box); | |
55 | bool take(QBoxSet *box); |
|
55 | bool take(QBoxSet *box); | |
56 | bool append(QList<QBoxSet *> boxes); |
|
56 | bool append(QList<QBoxSet *> boxes); | |
57 | bool insert(int index, QBoxSet *box); |
|
57 | bool insert(int index, QBoxSet *box); | |
58 | int count() const; |
|
58 | int count() const; | |
59 | QList<QBoxSet *> boxSets() const; |
|
59 | QList<QBoxSet *> boxSets() const; | |
60 | void clear(); |
|
60 | void clear(); | |
61 |
|
61 | |||
62 | QAbstractSeries::SeriesType type() const; |
|
62 | QAbstractSeries::SeriesType type() const; | |
63 |
|
63 | |||
64 | void setBoxOutlineVisible(bool visible); |
|
64 | void setBoxOutlineVisible(bool visible); | |
65 | bool boxOutlineVisible(); |
|
65 | bool boxOutlineVisible(); | |
66 | void setBoxWidth(qreal width); |
|
66 | void setBoxWidth(qreal width); | |
67 | qreal boxWidth(); |
|
67 | qreal boxWidth(); | |
68 | void setBrush(const QBrush &brush); |
|
68 | void setBrush(const QBrush &brush); | |
69 | QBrush brush() const; |
|
69 | QBrush brush() const; | |
70 | void setPen(const QPen &pen); |
|
70 | void setPen(const QPen &pen); | |
71 | QPen pen() const; |
|
71 | QPen pen() const; | |
72 |
|
72 | |||
73 | Q_SIGNALS: |
|
73 | Q_SIGNALS: | |
74 | void clicked(QBoxSet *boxset); |
|
74 | void clicked(QBoxSet *boxset); | |
75 | void hovered(bool status, QBoxSet *boxset); |
|
75 | void hovered(bool status, QBoxSet *boxset); | |
76 | void pressed(QBoxSet *boxset); |
|
76 | void pressed(QBoxSet *boxset); | |
77 | void released(QBoxSet *boxset); |
|
77 | void released(QBoxSet *boxset); | |
78 | void doubleClicked(QBoxSet *boxset); |
|
78 | void doubleClicked(QBoxSet *boxset); | |
79 | void countChanged(); |
|
79 | void countChanged(); | |
80 | void penChanged(); |
|
80 | void penChanged(); | |
81 | void brushChanged(); |
|
81 | void brushChanged(); | |
82 | void boxOutlineVisibilityChanged(); |
|
82 | void boxOutlineVisibilityChanged(); | |
83 | void boxWidthChanged(); |
|
83 | void boxWidthChanged(); | |
84 |
|
84 | |||
85 | void boxsetsAdded(QList<QBoxSet *> sets); |
|
85 | void boxsetsAdded(QList<QBoxSet *> sets); | |
86 | void boxsetsRemoved(QList<QBoxSet *> sets); |
|
86 | void boxsetsRemoved(QList<QBoxSet *> sets); | |
87 |
|
87 | |||
88 | private: |
|
88 | private: | |
89 | Q_DECLARE_PRIVATE(QBoxPlotSeries) |
|
89 | Q_DECLARE_PRIVATE(QBoxPlotSeries) | |
90 | Q_DISABLE_COPY(QBoxPlotSeries) |
|
90 | Q_DISABLE_COPY(QBoxPlotSeries) | |
91 | friend class BoxPlotChartItem; |
|
91 | friend class BoxPlotChartItem; | |
92 | friend class QBoxPlotLegendMarkerPrivate; |
|
92 | friend class QBoxPlotLegendMarkerPrivate; | |
93 | }; |
|
93 | }; | |
94 |
|
94 | |||
95 | QT_CHARTS_END_NAMESPACE |
|
95 | QT_CHARTS_END_NAMESPACE | |
96 |
|
96 | |||
97 | #endif // QBOXPLOTSERIES_H |
|
97 | #endif // QBOXPLOTSERIES_H |
@@ -1,106 +1,106 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QBOXSET_H |
|
30 | #ifndef QBOXSET_H | |
31 | #define QBOXSET_H |
|
31 | #define QBOXSET_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtGui/QPen> |
|
34 | #include <QtGui/QPen> | |
35 | #include <QtGui/QBrush> |
|
35 | #include <QtGui/QBrush> | |
36 | #include <QtGui/QFont> |
|
36 | #include <QtGui/QFont> | |
37 |
|
37 | |||
38 | QT_CHARTS_BEGIN_NAMESPACE |
|
38 | QT_CHARTS_BEGIN_NAMESPACE | |
39 | class QBoxSetPrivate; |
|
39 | class QBoxSetPrivate; | |
40 |
|
40 | |||
41 | class QT_CHARTS_EXPORT QBoxSet : public QObject |
|
41 | class QT_CHARTS_EXPORT QBoxSet : public QObject | |
42 | { |
|
42 | { | |
43 | Q_OBJECT |
|
43 | Q_OBJECT | |
44 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
44 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
45 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
|
45 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 | enum ValuePositions { |
|
48 | enum ValuePositions { | |
49 | LowerExtreme, |
|
49 | LowerExtreme, | |
50 | LowerQuartile, |
|
50 | LowerQuartile, | |
51 | Median, |
|
51 | Median, | |
52 | UpperQuartile, |
|
52 | UpperQuartile, | |
53 | UpperExtreme |
|
53 | UpperExtreme | |
54 | }; |
|
54 | }; | |
55 |
|
55 | |||
56 | public: |
|
56 | public: | |
57 |
explicit QBoxSet(const QString label = QString(), QObject *parent = |
|
57 | explicit QBoxSet(const QString label = QString(), QObject *parent = Q_NULLPTR); | |
58 |
explicit QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label = QString(), QObject *parent = |
|
58 | explicit QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label = QString(), QObject *parent = Q_NULLPTR); | |
59 | virtual ~QBoxSet(); |
|
59 | virtual ~QBoxSet(); | |
60 |
|
60 | |||
61 | void append(const qreal value); |
|
61 | void append(const qreal value); | |
62 | void append(const QList<qreal> &values); |
|
62 | void append(const QList<qreal> &values); | |
63 |
|
63 | |||
64 | void clear(); |
|
64 | void clear(); | |
65 |
|
65 | |||
66 | void setLabel(const QString label); |
|
66 | void setLabel(const QString label); | |
67 | QString label() const; |
|
67 | QString label() const; | |
68 |
|
68 | |||
69 | QBoxSet &operator << (const qreal &value); |
|
69 | QBoxSet &operator << (const qreal &value); | |
70 |
|
70 | |||
71 | void setValue(const int index, const qreal value); |
|
71 | void setValue(const int index, const qreal value); | |
72 | qreal at(const int index) const; |
|
72 | qreal at(const int index) const; | |
73 | qreal operator [](const int index) const; |
|
73 | qreal operator [](const int index) const; | |
74 | int count() const; |
|
74 | int count() const; | |
75 |
|
75 | |||
76 | void setPen(const QPen &pen); |
|
76 | void setPen(const QPen &pen); | |
77 | QPen pen() const; |
|
77 | QPen pen() const; | |
78 |
|
78 | |||
79 | void setBrush(const QBrush &brush); |
|
79 | void setBrush(const QBrush &brush); | |
80 | QBrush brush() const; |
|
80 | QBrush brush() const; | |
81 |
|
81 | |||
82 | Q_SIGNALS: |
|
82 | Q_SIGNALS: | |
83 | void clicked(); |
|
83 | void clicked(); | |
84 | void hovered(bool status); |
|
84 | void hovered(bool status); | |
85 | void pressed(); |
|
85 | void pressed(); | |
86 | void released(); |
|
86 | void released(); | |
87 | void doubleClicked(); |
|
87 | void doubleClicked(); | |
88 | void penChanged(); |
|
88 | void penChanged(); | |
89 | void brushChanged(); |
|
89 | void brushChanged(); | |
90 |
|
90 | |||
91 | void valuesChanged(); |
|
91 | void valuesChanged(); | |
92 | void valueChanged(int index); |
|
92 | void valueChanged(int index); | |
93 | void cleared(); |
|
93 | void cleared(); | |
94 |
|
94 | |||
95 | private: |
|
95 | private: | |
96 | QScopedPointer<QBoxSetPrivate> d_ptr; |
|
96 | QScopedPointer<QBoxSetPrivate> d_ptr; | |
97 | Q_DISABLE_COPY(QBoxSet) |
|
97 | Q_DISABLE_COPY(QBoxSet) | |
98 | friend class BarLegendMarker; |
|
98 | friend class BarLegendMarker; | |
99 | friend class BarChartItem; |
|
99 | friend class BarChartItem; | |
100 | friend class BoxPlotChartItem; |
|
100 | friend class BoxPlotChartItem; | |
101 | friend class QBoxPlotSeriesPrivate; |
|
101 | friend class QBoxPlotSeriesPrivate; | |
102 | }; |
|
102 | }; | |
103 |
|
103 | |||
104 | QT_CHARTS_END_NAMESPACE |
|
104 | QT_CHARTS_END_NAMESPACE | |
105 |
|
105 | |||
106 | #endif // QBOXSET_H |
|
106 | #endif // QBOXSET_H |
@@ -1,79 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QVBOXPLOTMODELMAPPER_H |
|
30 | #ifndef QVBOXPLOTMODELMAPPER_H | |
31 | #define QVBOXPLOTMODELMAPPER_H |
|
31 | #define QVBOXPLOTMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QBoxPlotModelMapper> |
|
33 | #include <QtCharts/QBoxPlotModelMapper> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ |
|
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ | |
37 | class QT_CHARTS_EXPORT QVBoxPlotModelMapper : public QBoxPlotModelMapper |
|
37 | class QT_CHARTS_EXPORT QVBoxPlotModelMapper : public QBoxPlotModelMapper | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | Q_PROPERTY(QBoxPlotSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) |
|
40 | Q_PROPERTY(QBoxPlotSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) | |
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) |
|
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) | |
42 | Q_PROPERTY(int firstBoxSetColumn READ firstBoxSetColumn WRITE setFirstBoxSetColumn NOTIFY firstBoxSetColumnChanged) |
|
42 | Q_PROPERTY(int firstBoxSetColumn READ firstBoxSetColumn WRITE setFirstBoxSetColumn NOTIFY firstBoxSetColumnChanged) | |
43 | Q_PROPERTY(int lastBoxSetColumn READ lastBoxSetColumn WRITE setLastBoxSetColumn NOTIFY lastBoxSetColumnChanged) |
|
43 | Q_PROPERTY(int lastBoxSetColumn READ lastBoxSetColumn WRITE setLastBoxSetColumn NOTIFY lastBoxSetColumnChanged) | |
44 | Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged) |
|
44 | Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged) | |
45 | Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) |
|
45 | Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 |
explicit QVBoxPlotModelMapper(QObject *parent = |
|
48 | explicit QVBoxPlotModelMapper(QObject *parent = Q_NULLPTR); | |
49 |
|
49 | |||
50 | QAbstractItemModel *model() const; |
|
50 | QAbstractItemModel *model() const; | |
51 | void setModel(QAbstractItemModel *model); |
|
51 | void setModel(QAbstractItemModel *model); | |
52 |
|
52 | |||
53 | QBoxPlotSeries *series() const; |
|
53 | QBoxPlotSeries *series() const; | |
54 | void setSeries(QBoxPlotSeries *series); |
|
54 | void setSeries(QBoxPlotSeries *series); | |
55 |
|
55 | |||
56 | int firstBoxSetColumn() const; |
|
56 | int firstBoxSetColumn() const; | |
57 | void setFirstBoxSetColumn(int firstBoxSetColumn); |
|
57 | void setFirstBoxSetColumn(int firstBoxSetColumn); | |
58 |
|
58 | |||
59 | int lastBoxSetColumn() const; |
|
59 | int lastBoxSetColumn() const; | |
60 | void setLastBoxSetColumn(int lastBoxSetColumn); |
|
60 | void setLastBoxSetColumn(int lastBoxSetColumn); | |
61 |
|
61 | |||
62 | int firstRow() const; |
|
62 | int firstRow() const; | |
63 | void setFirstRow(int firstRow); |
|
63 | void setFirstRow(int firstRow); | |
64 |
|
64 | |||
65 | int rowCount() const; |
|
65 | int rowCount() const; | |
66 | void setRowCount(int rowCount); |
|
66 | void setRowCount(int rowCount); | |
67 |
|
67 | |||
68 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
69 | void seriesReplaced(); |
|
69 | void seriesReplaced(); | |
70 | void modelReplaced(); |
|
70 | void modelReplaced(); | |
71 | void firstBoxSetColumnChanged(); |
|
71 | void firstBoxSetColumnChanged(); | |
72 | void lastBoxSetColumnChanged(); |
|
72 | void lastBoxSetColumnChanged(); | |
73 | void firstRowChanged(); |
|
73 | void firstRowChanged(); | |
74 | void rowCountChanged(); |
|
74 | void rowCountChanged(); | |
75 | }; |
|
75 | }; | |
76 |
|
76 | |||
77 | QT_CHARTS_END_NAMESPACE |
|
77 | QT_CHARTS_END_NAMESPACE | |
78 |
|
78 | |||
79 | #endif // QVBOXPLOTMODELMAPPER_H |
|
79 | #endif // QVBOXPLOTMODELMAPPER_H |
@@ -1,100 +1,105 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #include <private/charttitle_p.h> |
|
30 | #include <private/charttitle_p.h> | |
31 | #include <private/chartpresenter_p.h> |
|
31 | #include <private/chartpresenter_p.h> | |
32 | #include <QtGui/QFont> |
|
32 | #include <QtGui/QFont> | |
33 | #include <QtGui/QFontMetrics> |
|
33 | #include <QtGui/QFontMetrics> | |
34 | #include <QtCore/QDebug> |
|
34 | #include <QtCore/QDebug> | |
35 | #include <QtGui/QTextDocument> |
|
35 | #include <QtGui/QTextDocument> | |
36 |
|
36 | |||
37 | QT_CHARTS_BEGIN_NAMESPACE |
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | ChartTitle::ChartTitle(QGraphicsItem *parent) |
|
39 | ChartTitle::ChartTitle(QGraphicsItem *parent) | |
40 | : QGraphicsTextItem(parent) |
|
40 | : QGraphicsTextItem(parent) | |
41 | { |
|
41 | { | |
42 | document()->setDocumentMargin(ChartPresenter::textMargin()); |
|
42 | document()->setDocumentMargin(ChartPresenter::textMargin()); | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | ChartTitle::~ChartTitle() |
|
45 | ChartTitle::~ChartTitle() | |
46 | { |
|
46 | { | |
47 |
|
47 | |||
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | void ChartTitle::setText(const QString &text) |
|
50 | void ChartTitle::setText(const QString &text) | |
51 | { |
|
51 | { | |
52 | m_text = text; |
|
52 | m_text = text; | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | QString ChartTitle::text() const |
|
55 | QString ChartTitle::text() const | |
56 | { |
|
56 | { | |
57 | return m_text; |
|
57 | return m_text; | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | void ChartTitle::setGeometry(const QRectF &rect) |
|
60 | void ChartTitle::setGeometry(const QRectF &rect) | |
61 | { |
|
61 | { | |
62 | QRectF truncatedRect; |
|
62 | QRectF truncatedRect; | |
|
63 | if (m_text.isEmpty()) { | |||
|
64 | QGraphicsTextItem::setHtml(m_text); | |||
|
65 | QGraphicsTextItem::setTextWidth(0.0); | |||
|
66 | } else { | |||
63 | QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0), |
|
67 | QGraphicsTextItem::setHtml(ChartPresenter::truncatedText(font(), m_text, qreal(0.0), | |
64 | rect.width(), rect.height(), |
|
68 | rect.width(), rect.height(), | |
65 | truncatedRect)); |
|
69 | truncatedRect)); | |
66 | QGraphicsTextItem::setTextWidth(truncatedRect.width()); |
|
70 | QGraphicsTextItem::setTextWidth(truncatedRect.width()); | |
|
71 | } | |||
67 | setPos(rect.topLeft()); |
|
72 | setPos(rect.topLeft()); | |
68 | } |
|
73 | } | |
69 |
|
74 | |||
70 |
|
75 | |||
71 | QSizeF ChartTitle::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
76 | QSizeF ChartTitle::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |
72 | { |
|
77 | { | |
73 | Q_UNUSED(constraint); |
|
78 | Q_UNUSED(constraint); | |
74 | QSizeF sh; |
|
79 | QSizeF sh; | |
75 |
|
80 | |||
76 | switch (which) { |
|
81 | switch (which) { | |
77 | case Qt::MinimumSize: { |
|
82 | case Qt::MinimumSize: { | |
78 | QRectF titleRect = ChartPresenter::textBoundingRect(font(), QStringLiteral("...")); |
|
83 | QRectF titleRect = ChartPresenter::textBoundingRect(font(), QStringLiteral("...")); | |
79 | sh = QSizeF(titleRect.width(), titleRect.height()); |
|
84 | sh = QSizeF(titleRect.width(), titleRect.height()); | |
80 | break; |
|
85 | break; | |
81 | } |
|
86 | } | |
82 | case Qt::PreferredSize: |
|
87 | case Qt::PreferredSize: | |
83 | case Qt::MaximumSize: { |
|
88 | case Qt::MaximumSize: { | |
84 | QRectF titleRect = ChartPresenter::textBoundingRect(font(), m_text); |
|
89 | QRectF titleRect = ChartPresenter::textBoundingRect(font(), m_text); | |
85 | sh = QSizeF(titleRect.width(), titleRect.height()); |
|
90 | sh = QSizeF(titleRect.width(), titleRect.height()); | |
86 | break; |
|
91 | break; | |
87 | } |
|
92 | } | |
88 | case Qt::MinimumDescent: { |
|
93 | case Qt::MinimumDescent: { | |
89 | QFontMetrics fn(font()); |
|
94 | QFontMetrics fn(font()); | |
90 | sh = QSizeF(0, fn.descent()); |
|
95 | sh = QSizeF(0, fn.descent()); | |
91 | break; |
|
96 | break; | |
92 | } |
|
97 | } | |
93 | default: |
|
98 | default: | |
94 | break; |
|
99 | break; | |
95 | } |
|
100 | } | |
96 |
|
101 | |||
97 | return sh; |
|
102 | return sh; | |
98 | } |
|
103 | } | |
99 |
|
104 | |||
100 | QT_CHARTS_END_NAMESPACE |
|
105 | QT_CHARTS_END_NAMESPACE |
@@ -1,214 +1,218 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #include <private/abstractchartlayout_p.h> |
|
30 | #include <private/abstractchartlayout_p.h> | |
31 | #include <private/chartpresenter_p.h> |
|
31 | #include <private/chartpresenter_p.h> | |
32 | #include <private/qlegend_p.h> |
|
32 | #include <private/qlegend_p.h> | |
33 | #include <private/chartaxiselement_p.h> |
|
33 | #include <private/chartaxiselement_p.h> | |
34 | #include <private/charttitle_p.h> |
|
34 | #include <private/charttitle_p.h> | |
35 | #include <private/chartbackground_p.h> |
|
35 | #include <private/chartbackground_p.h> | |
36 | #include <QtCore/QDebug> |
|
36 | #include <QtCore/QDebug> | |
37 |
|
37 | |||
38 | QT_CHARTS_BEGIN_NAMESPACE |
|
38 | QT_CHARTS_BEGIN_NAMESPACE | |
39 |
|
39 | |||
40 | static const qreal golden_ratio = 0.4; |
|
40 | static const qreal golden_ratio = 0.4; | |
41 |
|
41 | |||
42 | AbstractChartLayout::AbstractChartLayout(ChartPresenter *presenter) |
|
42 | AbstractChartLayout::AbstractChartLayout(ChartPresenter *presenter) | |
43 | : m_presenter(presenter), |
|
43 | : m_presenter(presenter), | |
44 | m_margins(20, 20, 20, 20), |
|
44 | m_margins(20, 20, 20, 20), | |
45 | m_minChartRect(0, 0, 200, 200) |
|
45 | m_minChartRect(0, 0, 200, 200) | |
46 | { |
|
46 | { | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | AbstractChartLayout::~AbstractChartLayout() |
|
49 | AbstractChartLayout::~AbstractChartLayout() | |
50 | { |
|
50 | { | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | void AbstractChartLayout::setGeometry(const QRectF &rect) |
|
53 | void AbstractChartLayout::setGeometry(const QRectF &rect) | |
54 | { |
|
54 | { | |
55 | if (!rect.isValid()) |
|
55 | if (!rect.isValid()) | |
56 | return; |
|
56 | return; | |
57 |
|
57 | |||
58 | if (m_presenter->chart()->isVisible()) { |
|
58 | if (m_presenter->chart()->isVisible()) { | |
59 | QList<ChartAxisElement *> axes = m_presenter->axisItems(); |
|
59 | QList<ChartAxisElement *> axes = m_presenter->axisItems(); | |
60 | ChartTitle *title = m_presenter->titleElement(); |
|
60 | ChartTitle *title = m_presenter->titleElement(); | |
61 | QLegend *legend = m_presenter->legend(); |
|
61 | QLegend *legend = m_presenter->legend(); | |
62 | ChartBackground *background = m_presenter->backgroundElement(); |
|
62 | ChartBackground *background = m_presenter->backgroundElement(); | |
63 |
|
63 | |||
64 | QRectF contentGeometry = calculateBackgroundGeometry(rect, background); |
|
64 | QRectF contentGeometry = calculateBackgroundGeometry(rect, background); | |
65 |
|
65 | |||
66 | contentGeometry = calculateContentGeometry(contentGeometry); |
|
66 | contentGeometry = calculateContentGeometry(contentGeometry); | |
67 |
|
67 | |||
68 |
if (title && title->isVisible() |
|
68 | if (title && title->isVisible()) | |
69 | contentGeometry = calculateTitleGeometry(contentGeometry, title); |
|
69 | contentGeometry = calculateTitleGeometry(contentGeometry, title); | |
70 |
|
70 | |||
71 | if (legend->isAttachedToChart() && legend->isVisible()) |
|
71 | if (legend->isAttachedToChart() && legend->isVisible()) | |
72 | contentGeometry = calculateLegendGeometry(contentGeometry, legend); |
|
72 | contentGeometry = calculateLegendGeometry(contentGeometry, legend); | |
73 |
|
73 | |||
74 | contentGeometry = calculateAxisGeometry(contentGeometry, axes); |
|
74 | contentGeometry = calculateAxisGeometry(contentGeometry, axes); | |
75 |
|
75 | |||
76 | m_presenter->setGeometry(contentGeometry); |
|
76 | m_presenter->setGeometry(contentGeometry); | |
77 | if (m_presenter->chart()->chartType() == QChart::ChartTypeCartesian) |
|
77 | if (m_presenter->chart()->chartType() == QChart::ChartTypeCartesian) | |
78 | static_cast<QGraphicsRectItem *>(m_presenter->plotAreaElement())->setRect(contentGeometry); |
|
78 | static_cast<QGraphicsRectItem *>(m_presenter->plotAreaElement())->setRect(contentGeometry); | |
79 | else |
|
79 | else | |
80 | static_cast<QGraphicsEllipseItem *>(m_presenter->plotAreaElement())->setRect(contentGeometry); |
|
80 | static_cast<QGraphicsEllipseItem *>(m_presenter->plotAreaElement())->setRect(contentGeometry); | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | QGraphicsLayout::setGeometry(rect); |
|
83 | QGraphicsLayout::setGeometry(rect); | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | QRectF AbstractChartLayout::calculateContentGeometry(const QRectF &geometry) const |
|
86 | QRectF AbstractChartLayout::calculateContentGeometry(const QRectF &geometry) const | |
87 | { |
|
87 | { | |
88 | return geometry.adjusted(m_margins.left(), m_margins.top(), -m_margins.right(), -m_margins.bottom()); |
|
88 | return geometry.adjusted(m_margins.left(), m_margins.top(), -m_margins.right(), -m_margins.bottom()); | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | QRectF AbstractChartLayout::calculateContentMinimum(const QRectF &minimum) const |
|
91 | QRectF AbstractChartLayout::calculateContentMinimum(const QRectF &minimum) const | |
92 | { |
|
92 | { | |
93 | return minimum.adjusted(0, 0, m_margins.left() + m_margins.right(), m_margins.top() + m_margins.bottom()); |
|
93 | return minimum.adjusted(0, 0, m_margins.left() + m_margins.right(), m_margins.top() + m_margins.bottom()); | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 |
|
96 | |||
97 | QRectF AbstractChartLayout::calculateBackgroundGeometry(const QRectF &geometry, ChartBackground *background) const |
|
97 | QRectF AbstractChartLayout::calculateBackgroundGeometry(const QRectF &geometry, ChartBackground *background) const | |
98 | { |
|
98 | { | |
99 | qreal left; |
|
99 | qreal left; | |
100 | qreal top; |
|
100 | qreal top; | |
101 | qreal right; |
|
101 | qreal right; | |
102 | qreal bottom; |
|
102 | qreal bottom; | |
103 | getContentsMargins(&left, &top, &right, &bottom); |
|
103 | getContentsMargins(&left, &top, &right, &bottom); | |
104 | QRectF backgroundGeometry = geometry.adjusted(left, top, -right, -bottom); |
|
104 | QRectF backgroundGeometry = geometry.adjusted(left, top, -right, -bottom); | |
105 | if (background) |
|
105 | if (background) | |
106 | background->setRect(backgroundGeometry); |
|
106 | background->setRect(backgroundGeometry); | |
107 | return backgroundGeometry; |
|
107 | return backgroundGeometry; | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | QRectF AbstractChartLayout::calculateBackgroundMinimum(const QRectF &minimum) const |
|
110 | QRectF AbstractChartLayout::calculateBackgroundMinimum(const QRectF &minimum) const | |
111 | { |
|
111 | { | |
112 | qreal left; |
|
112 | qreal left; | |
113 | qreal top; |
|
113 | qreal top; | |
114 | qreal right; |
|
114 | qreal right; | |
115 | qreal bottom; |
|
115 | qreal bottom; | |
116 | getContentsMargins(&left, &top, &right, &bottom); |
|
116 | getContentsMargins(&left, &top, &right, &bottom); | |
117 | return minimum.adjusted(0, 0, left + right, top + bottom); |
|
117 | return minimum.adjusted(0, 0, left + right, top + bottom); | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | QRectF AbstractChartLayout::calculateLegendGeometry(const QRectF &geometry, QLegend *legend) const |
|
120 | QRectF AbstractChartLayout::calculateLegendGeometry(const QRectF &geometry, QLegend *legend) const | |
121 | { |
|
121 | { | |
122 | QSizeF size = legend->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)); |
|
122 | QSizeF size = legend->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)); | |
123 | QRectF legendRect; |
|
123 | QRectF legendRect; | |
124 | QRectF result; |
|
124 | QRectF result; | |
125 |
|
125 | |||
126 | switch (legend->alignment()) { |
|
126 | switch (legend->alignment()) { | |
127 | case Qt::AlignTop: { |
|
127 | case Qt::AlignTop: { | |
128 | legendRect = QRectF(geometry.topLeft(), QSizeF(geometry.width(), size.height())); |
|
128 | legendRect = QRectF(geometry.topLeft(), QSizeF(geometry.width(), size.height())); | |
129 | result = geometry.adjusted(0, legendRect.height(), 0, 0); |
|
129 | result = geometry.adjusted(0, legendRect.height(), 0, 0); | |
130 | break; |
|
130 | break; | |
131 | } |
|
131 | } | |
132 | case Qt::AlignBottom: { |
|
132 | case Qt::AlignBottom: { | |
133 | legendRect = QRectF(QPointF(geometry.left(), geometry.bottom() - size.height()), QSizeF(geometry.width(), size.height())); |
|
133 | legendRect = QRectF(QPointF(geometry.left(), geometry.bottom() - size.height()), QSizeF(geometry.width(), size.height())); | |
134 | result = geometry.adjusted(0, 0, 0, -legendRect.height()); |
|
134 | result = geometry.adjusted(0, 0, 0, -legendRect.height()); | |
135 | break; |
|
135 | break; | |
136 | } |
|
136 | } | |
137 | case Qt::AlignLeft: { |
|
137 | case Qt::AlignLeft: { | |
138 | qreal width = qMin(size.width(), geometry.width() * golden_ratio); |
|
138 | qreal width = qMin(size.width(), geometry.width() * golden_ratio); | |
139 | legendRect = QRectF(geometry.topLeft(), QSizeF(width, geometry.height())); |
|
139 | legendRect = QRectF(geometry.topLeft(), QSizeF(width, geometry.height())); | |
140 | result = geometry.adjusted(width, 0, 0, 0); |
|
140 | result = geometry.adjusted(width, 0, 0, 0); | |
141 | break; |
|
141 | break; | |
142 | } |
|
142 | } | |
143 | case Qt::AlignRight: { |
|
143 | case Qt::AlignRight: { | |
144 | qreal width = qMin(size.width(), geometry.width() * golden_ratio); |
|
144 | qreal width = qMin(size.width(), geometry.width() * golden_ratio); | |
145 | legendRect = QRectF(QPointF(geometry.right() - width, geometry.top()), QSizeF(width, geometry.height())); |
|
145 | legendRect = QRectF(QPointF(geometry.right() - width, geometry.top()), QSizeF(width, geometry.height())); | |
146 | result = geometry.adjusted(0, 0, -width, 0); |
|
146 | result = geometry.adjusted(0, 0, -width, 0); | |
147 | break; |
|
147 | break; | |
148 | } |
|
148 | } | |
149 | default: { |
|
149 | default: { | |
150 | legendRect = QRectF(0, 0, 0, 0); |
|
150 | legendRect = QRectF(0, 0, 0, 0); | |
151 | result = geometry; |
|
151 | result = geometry; | |
152 | break; |
|
152 | break; | |
153 | } |
|
153 | } | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | legend->setGeometry(legendRect); |
|
156 | legend->setGeometry(legendRect); | |
157 |
|
157 | |||
158 | return result; |
|
158 | return result; | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | QRectF AbstractChartLayout::calculateLegendMinimum(const QRectF &geometry, QLegend *legend) const |
|
161 | QRectF AbstractChartLayout::calculateLegendMinimum(const QRectF &geometry, QLegend *legend) const | |
162 | { |
|
162 | { | |
163 | QSizeF minSize = legend->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)); |
|
163 | QSizeF minSize = legend->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)); | |
164 | return geometry.adjusted(0, 0, minSize.width(), minSize.height()); |
|
164 | return geometry.adjusted(0, 0, minSize.width(), minSize.height()); | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | QRectF AbstractChartLayout::calculateTitleGeometry(const QRectF &geometry, ChartTitle *title) const |
|
167 | QRectF AbstractChartLayout::calculateTitleGeometry(const QRectF &geometry, ChartTitle *title) const | |
168 | { |
|
168 | { | |
169 | title->setGeometry(geometry); |
|
169 | title->setGeometry(geometry); | |
|
170 | if (title->text().isEmpty()) { | |||
|
171 | return geometry; | |||
|
172 | } else { | |||
170 | // Round to full pixel via QPoint to avoid one pixel clipping on the edge in some cases |
|
173 | // Round to full pixel via QPoint to avoid one pixel clipping on the edge in some cases | |
171 | QPointF center((geometry.center() - title->boundingRect().center()).toPoint()); |
|
174 | QPointF center((geometry.center() - title->boundingRect().center()).toPoint()); | |
172 |
|
175 | |||
173 | title->setPos(center.x(), title->pos().y()); |
|
176 | title->setPos(center.x(), title->pos().y()); | |
174 | return geometry.adjusted(0, title->boundingRect().height()+1, 0, 0); |
|
177 | return geometry.adjusted(0, title->boundingRect().height() + 1, 0, 0); | |
175 | } |
|
178 | } | |
|
179 | } | |||
176 |
|
180 | |||
177 | QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const |
|
181 | QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const | |
178 | { |
|
182 | { | |
179 | QSizeF min = title->sizeHint(Qt::MinimumSize); |
|
183 | QSizeF min = title->sizeHint(Qt::MinimumSize); | |
180 | return minimum.adjusted(0, 0, min.width(), min.height()); |
|
184 | return minimum.adjusted(0, 0, min.width(), min.height()); | |
181 | } |
|
185 | } | |
182 |
|
186 | |||
183 | QSizeF AbstractChartLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
187 | QSizeF AbstractChartLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |
184 | { |
|
188 | { | |
185 | Q_UNUSED(constraint); |
|
189 | Q_UNUSED(constraint); | |
186 | if (which == Qt::MinimumSize) { |
|
190 | if (which == Qt::MinimumSize) { | |
187 | QList<ChartAxisElement *> axes = m_presenter->axisItems(); |
|
191 | QList<ChartAxisElement *> axes = m_presenter->axisItems(); | |
188 | ChartTitle *title = m_presenter->titleElement(); |
|
192 | ChartTitle *title = m_presenter->titleElement(); | |
189 | QLegend *legend = m_presenter->legend(); |
|
193 | QLegend *legend = m_presenter->legend(); | |
190 | QRectF minimumRect(0, 0, 0, 0); |
|
194 | QRectF minimumRect(0, 0, 0, 0); | |
191 | minimumRect = calculateBackgroundMinimum(minimumRect); |
|
195 | minimumRect = calculateBackgroundMinimum(minimumRect); | |
192 | minimumRect = calculateContentMinimum(minimumRect); |
|
196 | minimumRect = calculateContentMinimum(minimumRect); | |
193 | minimumRect = calculateTitleMinimum(minimumRect, title); |
|
197 | minimumRect = calculateTitleMinimum(minimumRect, title); | |
194 | minimumRect = calculateLegendMinimum(minimumRect, legend); |
|
198 | minimumRect = calculateLegendMinimum(minimumRect, legend); | |
195 | minimumRect = calculateAxisMinimum(minimumRect, axes); |
|
199 | minimumRect = calculateAxisMinimum(minimumRect, axes); | |
196 | return minimumRect.united(m_minChartRect).size().toSize(); |
|
200 | return minimumRect.united(m_minChartRect).size().toSize(); | |
197 | } |
|
201 | } | |
198 | return QSize(-1, -1); |
|
202 | return QSize(-1, -1); | |
199 | } |
|
203 | } | |
200 |
|
204 | |||
201 | void AbstractChartLayout::setMargins(const QMargins &margins) |
|
205 | void AbstractChartLayout::setMargins(const QMargins &margins) | |
202 | { |
|
206 | { | |
203 | if (m_margins != margins) { |
|
207 | if (m_margins != margins) { | |
204 | m_margins = margins; |
|
208 | m_margins = margins; | |
205 | updateGeometry(); |
|
209 | updateGeometry(); | |
206 | } |
|
210 | } | |
207 | } |
|
211 | } | |
208 |
|
212 | |||
209 | QMargins AbstractChartLayout::margins() const |
|
213 | QMargins AbstractChartLayout::margins() const | |
210 | { |
|
214 | { | |
211 | return m_margins; |
|
215 | return m_margins; | |
212 | } |
|
216 | } | |
213 |
|
217 | |||
214 | QT_CHARTS_END_NAMESPACE |
|
218 | QT_CHARTS_END_NAMESPACE |
@@ -1,65 +1,65 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QAREALEGENDMARKER_H |
|
30 | #ifndef QAREALEGENDMARKER_H | |
31 | #define QAREALEGENDMARKER_H |
|
31 | #define QAREALEGENDMARKER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/QLegendMarker> |
|
34 | #include <QtCharts/QLegendMarker> | |
35 | #include <QtCharts/QAreaSeries> |
|
35 | #include <QtCharts/QAreaSeries> | |
36 |
|
36 | |||
37 | QT_CHARTS_BEGIN_NAMESPACE |
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class QAreaLegendMarkerPrivate; |
|
39 | class QAreaLegendMarkerPrivate; | |
40 |
|
40 | |||
41 | class QT_CHARTS_EXPORT QAreaLegendMarker : public QLegendMarker |
|
41 | class QT_CHARTS_EXPORT QAreaLegendMarker : public QLegendMarker | |
42 | { |
|
42 | { | |
43 | Q_OBJECT |
|
43 | Q_OBJECT | |
44 |
|
44 | |||
45 | public: |
|
45 | public: | |
46 |
explicit QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent = |
|
46 | explicit QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent = Q_NULLPTR); | |
47 | virtual ~QAreaLegendMarker(); |
|
47 | virtual ~QAreaLegendMarker(); | |
48 |
|
48 | |||
49 | virtual LegendMarkerType type() { return LegendMarkerTypeArea; } |
|
49 | virtual LegendMarkerType type() { return LegendMarkerTypeArea; } | |
50 |
|
50 | |||
51 | // Related series |
|
51 | // Related series | |
52 | virtual QAreaSeries* series(); |
|
52 | virtual QAreaSeries* series(); | |
53 |
|
53 | |||
54 | protected: |
|
54 | protected: | |
55 |
QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent = |
|
55 | QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); | |
56 |
|
56 | |||
57 | private: |
|
57 | private: | |
58 | Q_DECLARE_PRIVATE(QAreaLegendMarker) |
|
58 | Q_DECLARE_PRIVATE(QAreaLegendMarker) | |
59 | Q_DISABLE_COPY(QAreaLegendMarker) |
|
59 | Q_DISABLE_COPY(QAreaLegendMarker) | |
60 |
|
60 | |||
61 | }; |
|
61 | }; | |
62 |
|
62 | |||
63 | QT_CHARTS_END_NAMESPACE |
|
63 | QT_CHARTS_END_NAMESPACE | |
64 |
|
64 | |||
65 | #endif // QAREALEGENDMARKER_H |
|
65 | #endif // QAREALEGENDMARKER_H |
@@ -1,66 +1,66 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 | #ifndef QBARLEGENDMARKER_H |
|
29 | #ifndef QBARLEGENDMARKER_H | |
30 | #define QBARLEGENDMARKER_H |
|
30 | #define QBARLEGENDMARKER_H | |
31 |
|
31 | |||
32 | #include <QtCharts/QChartGlobal> |
|
32 | #include <QtCharts/QChartGlobal> | |
33 | #include <QtCharts/QLegendMarker> |
|
33 | #include <QtCharts/QLegendMarker> | |
34 | #include <QtCharts/QAbstractBarSeries> |
|
34 | #include <QtCharts/QAbstractBarSeries> | |
35 | #include <QtCharts/QBarSet> |
|
35 | #include <QtCharts/QBarSet> | |
36 |
|
36 | |||
37 | QT_CHARTS_BEGIN_NAMESPACE |
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class QLegend; |
|
39 | class QLegend; | |
40 | class QBarLegendMarkerPrivate; |
|
40 | class QBarLegendMarkerPrivate; | |
41 |
|
41 | |||
42 | class QT_CHARTS_EXPORT QBarLegendMarker : public QLegendMarker |
|
42 | class QT_CHARTS_EXPORT QBarLegendMarker : public QLegendMarker | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 | public: |
|
45 | public: | |
46 |
explicit QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent = |
|
46 | explicit QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent = Q_NULLPTR); | |
47 | virtual ~QBarLegendMarker(); |
|
47 | virtual ~QBarLegendMarker(); | |
48 |
|
48 | |||
49 | virtual LegendMarkerType type() { return LegendMarkerTypeBar; } |
|
49 | virtual LegendMarkerType type() { return LegendMarkerTypeBar; } | |
50 |
|
50 | |||
51 | // Related series and barset |
|
51 | // Related series and barset | |
52 | virtual QAbstractBarSeries* series(); |
|
52 | virtual QAbstractBarSeries* series(); | |
53 | QBarSet* barset(); |
|
53 | QBarSet* barset(); | |
54 |
|
54 | |||
55 | protected: |
|
55 | protected: | |
56 |
QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent = |
|
56 | QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); | |
57 |
|
57 | |||
58 | private: |
|
58 | private: | |
59 | Q_DECLARE_PRIVATE(QBarLegendMarker) |
|
59 | Q_DECLARE_PRIVATE(QBarLegendMarker) | |
60 | Q_DISABLE_COPY(QBarLegendMarker) |
|
60 | Q_DISABLE_COPY(QBarLegendMarker) | |
61 |
|
61 | |||
62 | }; |
|
62 | }; | |
63 |
|
63 | |||
64 | QT_CHARTS_END_NAMESPACE |
|
64 | QT_CHARTS_END_NAMESPACE | |
65 |
|
65 | |||
66 | #endif // QBARLEGENDMARKER_H |
|
66 | #endif // QBARLEGENDMARKER_H |
@@ -1,64 +1,64 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QBOXPLOTLEGENDMARKER_H |
|
30 | #ifndef QBOXPLOTLEGENDMARKER_H | |
31 | #define QBOXPLOTLEGENDMARKER_H |
|
31 | #define QBOXPLOTLEGENDMARKER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/QLegendMarker> |
|
34 | #include <QtCharts/QLegendMarker> | |
35 | #include <QtCharts/QBoxPlotSeries> |
|
35 | #include <QtCharts/QBoxPlotSeries> | |
36 |
|
36 | |||
37 | QT_CHARTS_BEGIN_NAMESPACE |
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class QBoxPlotLegendMarkerPrivate; |
|
39 | class QBoxPlotLegendMarkerPrivate; | |
40 |
|
40 | |||
41 | class QT_CHARTS_EXPORT QBoxPlotLegendMarker : public QLegendMarker |
|
41 | class QT_CHARTS_EXPORT QBoxPlotLegendMarker : public QLegendMarker | |
42 | { |
|
42 | { | |
43 | Q_OBJECT |
|
43 | Q_OBJECT | |
44 |
|
44 | |||
45 | public: |
|
45 | public: | |
46 |
explicit QBoxPlotLegendMarker(QBoxPlotSeries *series, QLegend *legend, QObject *parent = |
|
46 | explicit QBoxPlotLegendMarker(QBoxPlotSeries *series, QLegend *legend, QObject *parent = Q_NULLPTR); | |
47 | virtual ~QBoxPlotLegendMarker(); |
|
47 | virtual ~QBoxPlotLegendMarker(); | |
48 |
|
48 | |||
49 | virtual LegendMarkerType type() { return LegendMarkerTypeBoxPlot; } |
|
49 | virtual LegendMarkerType type() { return LegendMarkerTypeBoxPlot; } | |
50 |
|
50 | |||
51 | // Related series |
|
51 | // Related series | |
52 | virtual QBoxPlotSeries* series(); |
|
52 | virtual QBoxPlotSeries* series(); | |
53 |
|
53 | |||
54 | protected: |
|
54 | protected: | |
55 |
QBoxPlotLegendMarker(QBoxPlotLegendMarkerPrivate &d, QObject *parent = |
|
55 | QBoxPlotLegendMarker(QBoxPlotLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); | |
56 |
|
56 | |||
57 | private: |
|
57 | private: | |
58 | Q_DECLARE_PRIVATE(QBoxPlotLegendMarker) |
|
58 | Q_DECLARE_PRIVATE(QBoxPlotLegendMarker) | |
59 | Q_DISABLE_COPY(QBoxPlotLegendMarker) |
|
59 | Q_DISABLE_COPY(QBoxPlotLegendMarker) | |
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
62 | QT_CHARTS_END_NAMESPACE |
|
62 | QT_CHARTS_END_NAMESPACE | |
63 |
|
63 | |||
64 | #endif // QBOXPLOTLEGENDMARKER_H |
|
64 | #endif // QBOXPLOTLEGENDMARKER_H |
@@ -1,125 +1,125 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QLEGEND_H |
|
30 | #ifndef QLEGEND_H | |
31 | #define QLEGEND_H |
|
31 | #define QLEGEND_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtWidgets/QGraphicsWidget> |
|
34 | #include <QtWidgets/QGraphicsWidget> | |
35 | #include <QtGui/QPen> |
|
35 | #include <QtGui/QPen> | |
36 | #include <QtGui/QBrush> |
|
36 | #include <QtGui/QBrush> | |
37 |
|
37 | |||
38 | QT_CHARTS_BEGIN_NAMESPACE |
|
38 | QT_CHARTS_BEGIN_NAMESPACE | |
39 |
|
39 | |||
40 | class QChart; |
|
40 | class QChart; | |
41 | class QLegendPrivate; |
|
41 | class QLegendPrivate; | |
42 | class QLegendMarker; |
|
42 | class QLegendMarker; | |
43 | class QAbstractSeries; |
|
43 | class QAbstractSeries; | |
44 |
|
44 | |||
45 | class QT_CHARTS_EXPORT QLegend : public QGraphicsWidget |
|
45 | class QT_CHARTS_EXPORT QLegend : public QGraphicsWidget | |
46 | { |
|
46 | { | |
47 | Q_OBJECT |
|
47 | Q_OBJECT | |
48 | Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) |
|
48 | Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) | |
49 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged) |
|
49 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged) | |
50 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
50 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
51 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
51 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
52 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) |
|
52 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) | |
53 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) |
|
53 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) | |
54 | Q_PROPERTY(bool reverseMarkers READ reverseMarkers WRITE setReverseMarkers NOTIFY reverseMarkersChanged) |
|
54 | Q_PROPERTY(bool reverseMarkers READ reverseMarkers WRITE setReverseMarkers NOTIFY reverseMarkersChanged) | |
55 | Q_PROPERTY(bool showToolTips READ showToolTips WRITE setShowToolTips NOTIFY showToolTipsChanged) |
|
55 | Q_PROPERTY(bool showToolTips READ showToolTips WRITE setShowToolTips NOTIFY showToolTipsChanged) | |
56 |
|
56 | |||
57 | private: |
|
57 | private: | |
58 | explicit QLegend(QChart *chart); |
|
58 | explicit QLegend(QChart *chart); | |
59 |
|
59 | |||
60 | public: |
|
60 | public: | |
61 | ~QLegend(); |
|
61 | ~QLegend(); | |
62 |
|
62 | |||
63 |
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = |
|
63 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR); | |
64 |
|
64 | |||
65 | void setBrush(const QBrush &brush); |
|
65 | void setBrush(const QBrush &brush); | |
66 | QBrush brush() const; |
|
66 | QBrush brush() const; | |
67 | void setColor(QColor color); |
|
67 | void setColor(QColor color); | |
68 | QColor color(); |
|
68 | QColor color(); | |
69 |
|
69 | |||
70 | void setPen(const QPen &pen); |
|
70 | void setPen(const QPen &pen); | |
71 | QPen pen() const; |
|
71 | QPen pen() const; | |
72 | void setBorderColor(QColor color); |
|
72 | void setBorderColor(QColor color); | |
73 | QColor borderColor(); |
|
73 | QColor borderColor(); | |
74 |
|
74 | |||
75 | void setFont(const QFont &font); |
|
75 | void setFont(const QFont &font); | |
76 | QFont font() const; |
|
76 | QFont font() const; | |
77 | void setLabelBrush(const QBrush &brush); |
|
77 | void setLabelBrush(const QBrush &brush); | |
78 | QBrush labelBrush() const; |
|
78 | QBrush labelBrush() const; | |
79 |
|
79 | |||
80 | void setLabelColor(QColor color); |
|
80 | void setLabelColor(QColor color); | |
81 | QColor labelColor() const; |
|
81 | QColor labelColor() const; | |
82 |
|
82 | |||
83 | void setAlignment(Qt::Alignment alignment); |
|
83 | void setAlignment(Qt::Alignment alignment); | |
84 | Qt::Alignment alignment() const; |
|
84 | Qt::Alignment alignment() const; | |
85 |
|
85 | |||
86 | void detachFromChart(); |
|
86 | void detachFromChart(); | |
87 | void attachToChart(); |
|
87 | void attachToChart(); | |
88 | bool isAttachedToChart(); |
|
88 | bool isAttachedToChart(); | |
89 |
|
89 | |||
90 | void setBackgroundVisible(bool visible = true); |
|
90 | void setBackgroundVisible(bool visible = true); | |
91 | bool isBackgroundVisible() const; |
|
91 | bool isBackgroundVisible() const; | |
92 |
|
92 | |||
93 |
QList <QLegendMarker*> markers(QAbstractSeries *series = |
|
93 | QList <QLegendMarker*> markers(QAbstractSeries *series = Q_NULLPTR) const; | |
94 |
|
94 | |||
95 | bool reverseMarkers(); |
|
95 | bool reverseMarkers(); | |
96 | void setReverseMarkers(bool reverseMarkers = true); |
|
96 | void setReverseMarkers(bool reverseMarkers = true); | |
97 |
|
97 | |||
98 | bool showToolTips() const; |
|
98 | bool showToolTips() const; | |
99 | void setShowToolTips(bool show); |
|
99 | void setShowToolTips(bool show); | |
100 | protected: |
|
100 | protected: | |
101 | void hideEvent(QHideEvent *event); |
|
101 | void hideEvent(QHideEvent *event); | |
102 | void showEvent(QShowEvent *event); |
|
102 | void showEvent(QShowEvent *event); | |
103 |
|
103 | |||
104 | Q_SIGNALS: |
|
104 | Q_SIGNALS: | |
105 | void backgroundVisibleChanged(bool visible); |
|
105 | void backgroundVisibleChanged(bool visible); | |
106 | void colorChanged(QColor color); |
|
106 | void colorChanged(QColor color); | |
107 | void borderColorChanged(QColor color); |
|
107 | void borderColorChanged(QColor color); | |
108 | void fontChanged(QFont font); |
|
108 | void fontChanged(QFont font); | |
109 | void labelColorChanged(QColor color); |
|
109 | void labelColorChanged(QColor color); | |
110 | void reverseMarkersChanged(bool reverseMarkers); |
|
110 | void reverseMarkersChanged(bool reverseMarkers); | |
111 | void showToolTipsChanged(bool showToolTips); |
|
111 | void showToolTipsChanged(bool showToolTips); | |
112 |
|
112 | |||
113 | private: |
|
113 | private: | |
114 | QScopedPointer<QLegendPrivate> d_ptr; |
|
114 | QScopedPointer<QLegendPrivate> d_ptr; | |
115 | Q_DISABLE_COPY(QLegend) |
|
115 | Q_DISABLE_COPY(QLegend) | |
116 | friend class LegendScroller; |
|
116 | friend class LegendScroller; | |
117 | friend class LegendLayout; |
|
117 | friend class LegendLayout; | |
118 | friend class ChartLayout; |
|
118 | friend class ChartLayout; | |
119 | friend class LegendMarkerItem; |
|
119 | friend class LegendMarkerItem; | |
120 | friend class QLegendMarkerPrivate; |
|
120 | friend class QLegendMarkerPrivate; | |
121 | }; |
|
121 | }; | |
122 |
|
122 | |||
123 | QT_CHARTS_END_NAMESPACE |
|
123 | QT_CHARTS_END_NAMESPACE | |
124 |
|
124 | |||
125 | #endif // QLEGEND_H |
|
125 | #endif // QLEGEND_H |
@@ -1,116 +1,116 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QLEGENDMARKER_H |
|
30 | #ifndef QLEGENDMARKER_H | |
31 | #define QLEGENDMARKER_H |
|
31 | #define QLEGENDMARKER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCore/QObject> |
|
34 | #include <QtCore/QObject> | |
35 | #include <QtGui/QPen> |
|
35 | #include <QtGui/QPen> | |
36 | #include <QtGui/QBrush> |
|
36 | #include <QtGui/QBrush> | |
37 | #include <QtGui/QFont> |
|
37 | #include <QtGui/QFont> | |
38 |
|
38 | |||
39 | QT_CHARTS_BEGIN_NAMESPACE |
|
39 | QT_CHARTS_BEGIN_NAMESPACE | |
40 |
|
40 | |||
41 | class QLegendMarkerPrivate; |
|
41 | class QLegendMarkerPrivate; | |
42 | class QAbstractSeries; |
|
42 | class QAbstractSeries; | |
43 | class QLegend; |
|
43 | class QLegend; | |
44 |
|
44 | |||
45 | class QT_CHARTS_EXPORT QLegendMarker : public QObject |
|
45 | class QT_CHARTS_EXPORT QLegendMarker : public QObject | |
46 | { |
|
46 | { | |
47 | Q_OBJECT |
|
47 | Q_OBJECT | |
48 |
|
48 | |||
49 | public: |
|
49 | public: | |
50 | enum LegendMarkerType { |
|
50 | enum LegendMarkerType { | |
51 | LegendMarkerTypeArea, |
|
51 | LegendMarkerTypeArea, | |
52 | LegendMarkerTypeBar, |
|
52 | LegendMarkerTypeBar, | |
53 | LegendMarkerTypePie, |
|
53 | LegendMarkerTypePie, | |
54 | LegendMarkerTypeXY, |
|
54 | LegendMarkerTypeXY, | |
55 | LegendMarkerTypeBoxPlot |
|
55 | LegendMarkerTypeBoxPlot | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
|
58 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) | |
59 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) |
|
59 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) | |
60 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) |
|
60 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) | |
61 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
61 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
62 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
|
62 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |
63 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
|
63 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) | |
64 | Q_ENUMS(LegendMarkerType) |
|
64 | Q_ENUMS(LegendMarkerType) | |
65 |
|
65 | |||
66 | public: |
|
66 | public: | |
67 | virtual ~QLegendMarker(); |
|
67 | virtual ~QLegendMarker(); | |
68 | virtual LegendMarkerType type() = 0; |
|
68 | virtual LegendMarkerType type() = 0; | |
69 |
|
69 | |||
70 | QString label() const; |
|
70 | QString label() const; | |
71 | void setLabel(const QString &label); |
|
71 | void setLabel(const QString &label); | |
72 |
|
72 | |||
73 | QBrush labelBrush() const; |
|
73 | QBrush labelBrush() const; | |
74 | void setLabelBrush(const QBrush &brush); |
|
74 | void setLabelBrush(const QBrush &brush); | |
75 |
|
75 | |||
76 | QFont font() const; |
|
76 | QFont font() const; | |
77 | void setFont(const QFont &font); |
|
77 | void setFont(const QFont &font); | |
78 |
|
78 | |||
79 | QPen pen() const; |
|
79 | QPen pen() const; | |
80 | void setPen(const QPen &pen); |
|
80 | void setPen(const QPen &pen); | |
81 |
|
81 | |||
82 | QBrush brush() const; |
|
82 | QBrush brush() const; | |
83 | void setBrush(const QBrush &brush); |
|
83 | void setBrush(const QBrush &brush); | |
84 |
|
84 | |||
85 | bool isVisible() const; |
|
85 | bool isVisible() const; | |
86 | void setVisible(bool visible); |
|
86 | void setVisible(bool visible); | |
87 |
|
87 | |||
88 | virtual QAbstractSeries* series() = 0; |
|
88 | virtual QAbstractSeries* series() = 0; | |
89 |
|
89 | |||
90 | Q_SIGNALS: |
|
90 | Q_SIGNALS: | |
91 | void clicked(); |
|
91 | void clicked(); | |
92 | void hovered(bool status); |
|
92 | void hovered(bool status); | |
93 | void labelChanged(); |
|
93 | void labelChanged(); | |
94 | void labelBrushChanged(); |
|
94 | void labelBrushChanged(); | |
95 | void fontChanged(); |
|
95 | void fontChanged(); | |
96 | void penChanged(); |
|
96 | void penChanged(); | |
97 | void brushChanged(); |
|
97 | void brushChanged(); | |
98 | void visibleChanged(); |
|
98 | void visibleChanged(); | |
99 |
|
99 | |||
100 | protected: |
|
100 | protected: | |
101 |
explicit QLegendMarker(QLegendMarkerPrivate &d, QObject *parent = |
|
101 | explicit QLegendMarker(QLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); | |
102 |
|
102 | |||
103 | QScopedPointer<QLegendMarkerPrivate> d_ptr; |
|
103 | QScopedPointer<QLegendMarkerPrivate> d_ptr; | |
104 | friend class QLegendPrivate; |
|
104 | friend class QLegendPrivate; | |
105 | friend class QLegendMarkerPrivate; |
|
105 | friend class QLegendMarkerPrivate; | |
106 | friend class LegendMarkerItem; |
|
106 | friend class LegendMarkerItem; | |
107 | friend class LegendLayout; |
|
107 | friend class LegendLayout; | |
108 | friend class LegendScroller; |
|
108 | friend class LegendScroller; | |
109 |
|
109 | |||
110 | private: |
|
110 | private: | |
111 | Q_DISABLE_COPY(QLegendMarker) |
|
111 | Q_DISABLE_COPY(QLegendMarker) | |
112 | }; |
|
112 | }; | |
113 |
|
113 | |||
114 | QT_CHARTS_END_NAMESPACE |
|
114 | QT_CHARTS_END_NAMESPACE | |
115 |
|
115 | |||
116 | #endif // QLEGENDMARKER_H |
|
116 | #endif // QLEGENDMARKER_H |
@@ -1,66 +1,66 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QPIELEGENDMARKER_H |
|
30 | #ifndef QPIELEGENDMARKER_H | |
31 | #define QPIELEGENDMARKER_H |
|
31 | #define QPIELEGENDMARKER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/QLegendMarker> |
|
34 | #include <QtCharts/QLegendMarker> | |
35 | #include <QtCharts/QPieSeries> |
|
35 | #include <QtCharts/QPieSeries> | |
36 | #include <QtCharts/QPieSlice> |
|
36 | #include <QtCharts/QPieSlice> | |
37 |
|
37 | |||
38 | QT_CHARTS_BEGIN_NAMESPACE |
|
38 | QT_CHARTS_BEGIN_NAMESPACE | |
39 |
|
39 | |||
40 | class QPieLegendMarkerPrivate; |
|
40 | class QPieLegendMarkerPrivate; | |
41 |
|
41 | |||
42 | class QT_CHARTS_EXPORT QPieLegendMarker : public QLegendMarker |
|
42 | class QT_CHARTS_EXPORT QPieLegendMarker : public QLegendMarker | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 |
explicit QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent = |
|
47 | explicit QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent = Q_NULLPTR); | |
48 | virtual ~QPieLegendMarker(); |
|
48 | virtual ~QPieLegendMarker(); | |
49 |
|
49 | |||
50 | virtual LegendMarkerType type() { return LegendMarkerTypePie; } |
|
50 | virtual LegendMarkerType type() { return LegendMarkerTypePie; } | |
51 |
|
51 | |||
52 | // Related series and slice |
|
52 | // Related series and slice | |
53 | virtual QPieSeries* series(); |
|
53 | virtual QPieSeries* series(); | |
54 | QPieSlice* slice(); |
|
54 | QPieSlice* slice(); | |
55 |
|
55 | |||
56 | protected: |
|
56 | protected: | |
57 |
QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent = |
|
57 | QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); | |
58 |
|
58 | |||
59 | private: |
|
59 | private: | |
60 | Q_DECLARE_PRIVATE(QPieLegendMarker) |
|
60 | Q_DECLARE_PRIVATE(QPieLegendMarker) | |
61 | Q_DISABLE_COPY(QPieLegendMarker) |
|
61 | Q_DISABLE_COPY(QPieLegendMarker) | |
62 |
|
62 | |||
63 | }; |
|
63 | }; | |
64 |
|
64 | |||
65 | QT_CHARTS_END_NAMESPACE |
|
65 | QT_CHARTS_END_NAMESPACE | |
66 | #endif // QPIELEGENDMARKER_H |
|
66 | #endif // QPIELEGENDMARKER_H |
@@ -1,64 +1,64 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QXYLEGENDMARKER_H |
|
30 | #ifndef QXYLEGENDMARKER_H | |
31 | #define QXYLEGENDMARKER_H |
|
31 | #define QXYLEGENDMARKER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/QLegendMarker> |
|
34 | #include <QtCharts/QLegendMarker> | |
35 | #include <QtCharts/QXYSeries> |
|
35 | #include <QtCharts/QXYSeries> | |
36 |
|
36 | |||
37 | QT_CHARTS_BEGIN_NAMESPACE |
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class QXYLegendMarkerPrivate; |
|
39 | class QXYLegendMarkerPrivate; | |
40 |
|
40 | |||
41 | class QT_CHARTS_EXPORT QXYLegendMarker : public QLegendMarker |
|
41 | class QT_CHARTS_EXPORT QXYLegendMarker : public QLegendMarker | |
42 | { |
|
42 | { | |
43 | Q_OBJECT |
|
43 | Q_OBJECT | |
44 | public: |
|
44 | public: | |
45 |
explicit QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent = |
|
45 | explicit QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent = Q_NULLPTR); | |
46 | virtual ~QXYLegendMarker(); |
|
46 | virtual ~QXYLegendMarker(); | |
47 |
|
47 | |||
48 | virtual LegendMarkerType type() { return LegendMarkerTypeXY; } |
|
48 | virtual LegendMarkerType type() { return LegendMarkerTypeXY; } | |
49 |
|
49 | |||
50 | // Related series |
|
50 | // Related series | |
51 | virtual QXYSeries* series(); |
|
51 | virtual QXYSeries* series(); | |
52 |
|
52 | |||
53 | protected: |
|
53 | protected: | |
54 |
QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent = |
|
54 | QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); | |
55 |
|
55 | |||
56 | private: |
|
56 | private: | |
57 | Q_DECLARE_PRIVATE(QXYLegendMarker) |
|
57 | Q_DECLARE_PRIVATE(QXYLegendMarker) | |
58 | Q_DISABLE_COPY(QXYLegendMarker) |
|
58 | Q_DISABLE_COPY(QXYLegendMarker) | |
59 |
|
59 | |||
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
62 | QT_CHARTS_END_NAMESPACE |
|
62 | QT_CHARTS_END_NAMESPACE | |
63 |
|
63 | |||
64 | #endif // QXYLEGENDMARKER_H |
|
64 | #endif // QXYLEGENDMARKER_H |
@@ -1,61 +1,61 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QLINESERIES_H |
|
30 | #ifndef QLINESERIES_H | |
31 | #define QLINESERIES_H |
|
31 | #define QLINESERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/QXYSeries> |
|
34 | #include <QtCharts/QXYSeries> | |
35 | #include <QtGui/QPen> |
|
35 | #include <QtGui/QPen> | |
36 |
|
36 | |||
37 | QT_CHARTS_BEGIN_NAMESPACE |
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class QLineSeriesPrivate; |
|
39 | class QLineSeriesPrivate; | |
40 |
|
40 | |||
41 | class QT_CHARTS_EXPORT QLineSeries : public QXYSeries |
|
41 | class QT_CHARTS_EXPORT QLineSeries : public QXYSeries | |
42 | { |
|
42 | { | |
43 | Q_OBJECT |
|
43 | Q_OBJECT | |
44 |
|
44 | |||
45 | public: |
|
45 | public: | |
46 |
explicit QLineSeries(QObject *parent = |
|
46 | explicit QLineSeries(QObject *parent = Q_NULLPTR); | |
47 | ~QLineSeries(); |
|
47 | ~QLineSeries(); | |
48 | QAbstractSeries::SeriesType type() const; |
|
48 | QAbstractSeries::SeriesType type() const; | |
49 |
|
49 | |||
50 | protected: |
|
50 | protected: | |
51 |
QLineSeries(QLineSeriesPrivate &d, QObject *parent = |
|
51 | QLineSeries(QLineSeriesPrivate &d, QObject *parent = Q_NULLPTR); | |
52 |
|
52 | |||
53 | private: |
|
53 | private: | |
54 | Q_DECLARE_PRIVATE(QLineSeries) |
|
54 | Q_DECLARE_PRIVATE(QLineSeries) | |
55 | Q_DISABLE_COPY(QLineSeries) |
|
55 | Q_DISABLE_COPY(QLineSeries) | |
56 | friend class LineChartItem; |
|
56 | friend class LineChartItem; | |
57 | }; |
|
57 | }; | |
58 |
|
58 | |||
59 | QT_CHARTS_END_NAMESPACE |
|
59 | QT_CHARTS_END_NAMESPACE | |
60 |
|
60 | |||
61 | #endif // QLINESERIES_H |
|
61 | #endif // QLINESERIES_H |
@@ -1,79 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QHPIEMODELMAPPER_H |
|
30 | #ifndef QHPIEMODELMAPPER_H | |
31 | #define QHPIEMODELMAPPER_H |
|
31 | #define QHPIEMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QPieModelMapper> |
|
33 | #include <QtCharts/QPieModelMapper> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ |
|
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ | |
37 | class QT_CHARTS_EXPORT QHPieModelMapper : public QPieModelMapper |
|
37 | class QT_CHARTS_EXPORT QHPieModelMapper : public QPieModelMapper | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | Q_PROPERTY(QPieSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) |
|
40 | Q_PROPERTY(QPieSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) | |
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) |
|
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) | |
42 | Q_PROPERTY(int valuesRow READ valuesRow WRITE setValuesRow NOTIFY valuesRowChanged) |
|
42 | Q_PROPERTY(int valuesRow READ valuesRow WRITE setValuesRow NOTIFY valuesRowChanged) | |
43 | Q_PROPERTY(int labelsRow READ labelsRow WRITE setLabelsRow NOTIFY labelsRowChanged) |
|
43 | Q_PROPERTY(int labelsRow READ labelsRow WRITE setLabelsRow NOTIFY labelsRowChanged) | |
44 | Q_PROPERTY(int firstColumn READ firstColumn WRITE setFirstColumn NOTIFY firstColumnChanged) |
|
44 | Q_PROPERTY(int firstColumn READ firstColumn WRITE setFirstColumn NOTIFY firstColumnChanged) | |
45 | Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) |
|
45 | Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 |
explicit QHPieModelMapper(QObject *parent = |
|
48 | explicit QHPieModelMapper(QObject *parent = Q_NULLPTR); | |
49 |
|
49 | |||
50 | QAbstractItemModel *model() const; |
|
50 | QAbstractItemModel *model() const; | |
51 | void setModel(QAbstractItemModel *model); |
|
51 | void setModel(QAbstractItemModel *model); | |
52 |
|
52 | |||
53 | QPieSeries *series() const; |
|
53 | QPieSeries *series() const; | |
54 | void setSeries(QPieSeries *series); |
|
54 | void setSeries(QPieSeries *series); | |
55 |
|
55 | |||
56 | int valuesRow() const; |
|
56 | int valuesRow() const; | |
57 | void setValuesRow(int valuesRow); |
|
57 | void setValuesRow(int valuesRow); | |
58 |
|
58 | |||
59 | int labelsRow() const; |
|
59 | int labelsRow() const; | |
60 | void setLabelsRow(int labelsRow); |
|
60 | void setLabelsRow(int labelsRow); | |
61 |
|
61 | |||
62 | int firstColumn() const; |
|
62 | int firstColumn() const; | |
63 | void setFirstColumn(int firstColumn); |
|
63 | void setFirstColumn(int firstColumn); | |
64 |
|
64 | |||
65 | int columnCount() const; |
|
65 | int columnCount() const; | |
66 | void setColumnCount(int columnCount); |
|
66 | void setColumnCount(int columnCount); | |
67 |
|
67 | |||
68 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
69 | void seriesReplaced(); |
|
69 | void seriesReplaced(); | |
70 | void modelReplaced(); |
|
70 | void modelReplaced(); | |
71 | void valuesRowChanged(); |
|
71 | void valuesRowChanged(); | |
72 | void labelsRowChanged(); |
|
72 | void labelsRowChanged(); | |
73 | void firstColumnChanged(); |
|
73 | void firstColumnChanged(); | |
74 | void columnCountChanged(); |
|
74 | void columnCountChanged(); | |
75 | }; |
|
75 | }; | |
76 |
|
76 | |||
77 | QT_CHARTS_END_NAMESPACE |
|
77 | QT_CHARTS_END_NAMESPACE | |
78 |
|
78 | |||
79 | #endif // QHPIEMODELMAPPER_H |
|
79 | #endif // QHPIEMODELMAPPER_H |
@@ -1,577 +1,578 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #include <QtCharts/QPieModelMapper> |
|
30 | #include <QtCharts/QPieModelMapper> | |
31 | #include <private/qpiemodelmapper_p.h> |
|
31 | #include <private/qpiemodelmapper_p.h> | |
32 | #include <QtCharts/QPieSeries> |
|
32 | #include <QtCharts/QPieSeries> | |
33 | #include <QtCharts/QPieSlice> |
|
33 | #include <QtCharts/QPieSlice> | |
34 | #include <QtCore/QAbstractItemModel> |
|
34 | #include <QtCore/QAbstractItemModel> | |
35 |
|
35 | |||
36 | QT_CHARTS_BEGIN_NAMESPACE |
|
36 | QT_CHARTS_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | QPieModelMapper::QPieModelMapper(QObject *parent) |
|
38 | QPieModelMapper::QPieModelMapper(QObject *parent) | |
39 | : QObject(parent), |
|
39 | : QObject(parent), | |
40 | d_ptr(new QPieModelMapperPrivate(this)) |
|
40 | d_ptr(new QPieModelMapperPrivate(this)) | |
41 | { |
|
41 | { | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | QAbstractItemModel *QPieModelMapper::model() const |
|
44 | QAbstractItemModel *QPieModelMapper::model() const | |
45 | { |
|
45 | { | |
46 | Q_D(const QPieModelMapper); |
|
46 | Q_D(const QPieModelMapper); | |
47 | return d->m_model; |
|
47 | return d->m_model; | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | void QPieModelMapper::setModel(QAbstractItemModel *model) |
|
50 | void QPieModelMapper::setModel(QAbstractItemModel *model) | |
51 | { |
|
51 | { | |
52 | if (model == 0) |
|
52 | if (model == 0) | |
53 | return; |
|
53 | return; | |
54 |
|
54 | |||
55 | Q_D(QPieModelMapper); |
|
55 | Q_D(QPieModelMapper); | |
56 | if (d->m_model) { |
|
56 | if (d->m_model) { | |
57 | disconnect(d->m_model, 0, d, 0); |
|
57 | disconnect(d->m_model, 0, d, 0); | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | d->m_model = model; |
|
60 | d->m_model = model; | |
61 | d->initializePieFromModel(); |
|
61 | d->initializePieFromModel(); | |
62 | // connect signals from the model |
|
62 | // connect signals from the model | |
|
63 | connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializePieFromModel())); | |||
63 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
64 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
64 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); |
|
65 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
65 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); |
|
66 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
66 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); |
|
67 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
67 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); |
|
68 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
68 | connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); |
|
69 | connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); | |
69 | } |
|
70 | } | |
70 |
|
71 | |||
71 | QPieSeries *QPieModelMapper::series() const |
|
72 | QPieSeries *QPieModelMapper::series() const | |
72 | { |
|
73 | { | |
73 | Q_D(const QPieModelMapper); |
|
74 | Q_D(const QPieModelMapper); | |
74 | return d->m_series; |
|
75 | return d->m_series; | |
75 | } |
|
76 | } | |
76 |
|
77 | |||
77 | void QPieModelMapper::setSeries(QPieSeries *series) |
|
78 | void QPieModelMapper::setSeries(QPieSeries *series) | |
78 | { |
|
79 | { | |
79 | Q_D(QPieModelMapper); |
|
80 | Q_D(QPieModelMapper); | |
80 | if (d->m_series) { |
|
81 | if (d->m_series) { | |
81 | disconnect(d->m_series, 0, d, 0); |
|
82 | disconnect(d->m_series, 0, d, 0); | |
82 | } |
|
83 | } | |
83 |
|
84 | |||
84 | if (series == 0) |
|
85 | if (series == 0) | |
85 | return; |
|
86 | return; | |
86 |
|
87 | |||
87 | d->m_series = series; |
|
88 | d->m_series = series; | |
88 | d->initializePieFromModel(); |
|
89 | d->initializePieFromModel(); | |
89 | // connect the signals from the series |
|
90 | // connect the signals from the series | |
90 | connect(d->m_series, SIGNAL(added(QList<QPieSlice*>)), d, SLOT(slicesAdded(QList<QPieSlice*>))); |
|
91 | connect(d->m_series, SIGNAL(added(QList<QPieSlice*>)), d, SLOT(slicesAdded(QList<QPieSlice*>))); | |
91 | connect(d->m_series, SIGNAL(removed(QList<QPieSlice*>)), d, SLOT(slicesRemoved(QList<QPieSlice*>))); |
|
92 | connect(d->m_series, SIGNAL(removed(QList<QPieSlice*>)), d, SLOT(slicesRemoved(QList<QPieSlice*>))); | |
92 | connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); |
|
93 | connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); | |
93 | } |
|
94 | } | |
94 |
|
95 | |||
95 | /*! |
|
96 | /*! | |
96 | Defines which row/column of the model contains the first slice value. |
|
97 | Defines which row/column of the model contains the first slice value. | |
97 | Minimal and default value is: 0 |
|
98 | Minimal and default value is: 0 | |
98 | */ |
|
99 | */ | |
99 | int QPieModelMapper::first() const |
|
100 | int QPieModelMapper::first() const | |
100 | { |
|
101 | { | |
101 | Q_D(const QPieModelMapper); |
|
102 | Q_D(const QPieModelMapper); | |
102 | return d->m_first; |
|
103 | return d->m_first; | |
103 | } |
|
104 | } | |
104 |
|
105 | |||
105 | /*! |
|
106 | /*! | |
106 | Sets which row/column of the model contains the \a first slice value. |
|
107 | Sets which row/column of the model contains the \a first slice value. | |
107 | Minimal and default value is: 0 |
|
108 | Minimal and default value is: 0 | |
108 | */ |
|
109 | */ | |
109 | void QPieModelMapper::setFirst(int first) |
|
110 | void QPieModelMapper::setFirst(int first) | |
110 | { |
|
111 | { | |
111 | Q_D(QPieModelMapper); |
|
112 | Q_D(QPieModelMapper); | |
112 | d->m_first = qMax(first, 0); |
|
113 | d->m_first = qMax(first, 0); | |
113 | d->initializePieFromModel(); |
|
114 | d->initializePieFromModel(); | |
114 | } |
|
115 | } | |
115 |
|
116 | |||
116 | /*! |
|
117 | /*! | |
117 | Defines the number of rows/columns of the model that are mapped as the data for QPieSeries |
|
118 | Defines the number of rows/columns of the model that are mapped as the data for QPieSeries | |
118 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) |
|
119 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) | |
119 | */ |
|
120 | */ | |
120 | int QPieModelMapper::count() const |
|
121 | int QPieModelMapper::count() const | |
121 | { |
|
122 | { | |
122 | Q_D(const QPieModelMapper); |
|
123 | Q_D(const QPieModelMapper); | |
123 | return d->m_count; |
|
124 | return d->m_count; | |
124 | } |
|
125 | } | |
125 |
|
126 | |||
126 | /*! |
|
127 | /*! | |
127 | Defines the \a count of rows/columns of the model that are mapped as the data for QPieSeries |
|
128 | Defines the \a count of rows/columns of the model that are mapped as the data for QPieSeries | |
128 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) |
|
129 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) | |
129 | */ |
|
130 | */ | |
130 | void QPieModelMapper::setCount(int count) |
|
131 | void QPieModelMapper::setCount(int count) | |
131 | { |
|
132 | { | |
132 | Q_D(QPieModelMapper); |
|
133 | Q_D(QPieModelMapper); | |
133 | d->m_count = qMax(count, -1); |
|
134 | d->m_count = qMax(count, -1); | |
134 | d->initializePieFromModel(); |
|
135 | d->initializePieFromModel(); | |
135 | } |
|
136 | } | |
136 |
|
137 | |||
137 | /*! |
|
138 | /*! | |
138 | Returns the orientation that is used when QPieModelMapper accesses the model. |
|
139 | Returns the orientation that is used when QPieModelMapper accesses the model. | |
139 | This mean whether the consecutive values/labels of the pie are read from row (Qt::Horizontal) |
|
140 | This mean whether the consecutive values/labels of the pie are read from row (Qt::Horizontal) | |
140 | or from columns (Qt::Vertical) |
|
141 | or from columns (Qt::Vertical) | |
141 | */ |
|
142 | */ | |
142 | Qt::Orientation QPieModelMapper::orientation() const |
|
143 | Qt::Orientation QPieModelMapper::orientation() const | |
143 | { |
|
144 | { | |
144 | Q_D(const QPieModelMapper); |
|
145 | Q_D(const QPieModelMapper); | |
145 | return d->m_orientation; |
|
146 | return d->m_orientation; | |
146 | } |
|
147 | } | |
147 |
|
148 | |||
148 | /*! |
|
149 | /*! | |
149 | Returns the \a orientation that is used when QPieModelMapper accesses the model. |
|
150 | Returns the \a orientation that is used when QPieModelMapper accesses the model. | |
150 | This mean whether the consecutive values/labels of the pie are read from row (Qt::Horizontal) |
|
151 | This mean whether the consecutive values/labels of the pie are read from row (Qt::Horizontal) | |
151 | or from columns (Qt::Vertical) |
|
152 | or from columns (Qt::Vertical) | |
152 | */ |
|
153 | */ | |
153 | void QPieModelMapper::setOrientation(Qt::Orientation orientation) |
|
154 | void QPieModelMapper::setOrientation(Qt::Orientation orientation) | |
154 | { |
|
155 | { | |
155 | Q_D(QPieModelMapper); |
|
156 | Q_D(QPieModelMapper); | |
156 | d->m_orientation = orientation; |
|
157 | d->m_orientation = orientation; | |
157 | d->initializePieFromModel(); |
|
158 | d->initializePieFromModel(); | |
158 | } |
|
159 | } | |
159 |
|
160 | |||
160 | /*! |
|
161 | /*! | |
161 | Returns which section of the model is kept in sync with the values of the pie's slices |
|
162 | Returns which section of the model is kept in sync with the values of the pie's slices | |
162 | */ |
|
163 | */ | |
163 | int QPieModelMapper::valuesSection() const |
|
164 | int QPieModelMapper::valuesSection() const | |
164 | { |
|
165 | { | |
165 | Q_D(const QPieModelMapper); |
|
166 | Q_D(const QPieModelMapper); | |
166 | return d->m_valuesSection; |
|
167 | return d->m_valuesSection; | |
167 | } |
|
168 | } | |
168 |
|
169 | |||
169 | /*! |
|
170 | /*! | |
170 | Sets the model section that is kept in sync with the pie slices values. |
|
171 | Sets the model section that is kept in sync with the pie slices values. | |
171 | Parameter \a valuesSection specifies the section of the model. |
|
172 | Parameter \a valuesSection specifies the section of the model. | |
172 | */ |
|
173 | */ | |
173 | void QPieModelMapper::setValuesSection(int valuesSection) |
|
174 | void QPieModelMapper::setValuesSection(int valuesSection) | |
174 | { |
|
175 | { | |
175 | Q_D(QPieModelMapper); |
|
176 | Q_D(QPieModelMapper); | |
176 | d->m_valuesSection = qMax(-1, valuesSection); |
|
177 | d->m_valuesSection = qMax(-1, valuesSection); | |
177 | d->initializePieFromModel(); |
|
178 | d->initializePieFromModel(); | |
178 | } |
|
179 | } | |
179 |
|
180 | |||
180 | /*! |
|
181 | /*! | |
181 | Returns which section of the model is kept in sync with the labels of the pie's slices |
|
182 | Returns which section of the model is kept in sync with the labels of the pie's slices | |
182 | */ |
|
183 | */ | |
183 | int QPieModelMapper::labelsSection() const |
|
184 | int QPieModelMapper::labelsSection() const | |
184 | { |
|
185 | { | |
185 | Q_D(const QPieModelMapper); |
|
186 | Q_D(const QPieModelMapper); | |
186 | return d->m_labelsSection; |
|
187 | return d->m_labelsSection; | |
187 | } |
|
188 | } | |
188 |
|
189 | |||
189 | /*! |
|
190 | /*! | |
190 | Sets the model section that is kept in sync with the pie slices labels. |
|
191 | Sets the model section that is kept in sync with the pie slices labels. | |
191 | Parameter \a labelsSection specifies the section of the model. |
|
192 | Parameter \a labelsSection specifies the section of the model. | |
192 | */ |
|
193 | */ | |
193 | void QPieModelMapper::setLabelsSection(int labelsSection) |
|
194 | void QPieModelMapper::setLabelsSection(int labelsSection) | |
194 | { |
|
195 | { | |
195 | Q_D(QPieModelMapper); |
|
196 | Q_D(QPieModelMapper); | |
196 | d->m_labelsSection = qMax(-1, labelsSection); |
|
197 | d->m_labelsSection = qMax(-1, labelsSection); | |
197 | d->initializePieFromModel(); |
|
198 | d->initializePieFromModel(); | |
198 | } |
|
199 | } | |
199 |
|
200 | |||
200 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
201 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
201 |
|
202 | |||
202 | QPieModelMapperPrivate::QPieModelMapperPrivate(QPieModelMapper *q) : |
|
203 | QPieModelMapperPrivate::QPieModelMapperPrivate(QPieModelMapper *q) : | |
203 | QObject(q), |
|
204 | QObject(q), | |
204 | m_series(0), |
|
205 | m_series(0), | |
205 | m_model(0), |
|
206 | m_model(0), | |
206 | m_first(0), |
|
207 | m_first(0), | |
207 | m_count(-1), |
|
208 | m_count(-1), | |
208 | m_orientation(Qt::Vertical), |
|
209 | m_orientation(Qt::Vertical), | |
209 | m_valuesSection(-1), |
|
210 | m_valuesSection(-1), | |
210 | m_labelsSection(-1), |
|
211 | m_labelsSection(-1), | |
211 | m_seriesSignalsBlock(false), |
|
212 | m_seriesSignalsBlock(false), | |
212 | m_modelSignalsBlock(false), |
|
213 | m_modelSignalsBlock(false), | |
213 | q_ptr(q) |
|
214 | q_ptr(q) | |
214 | { |
|
215 | { | |
215 | } |
|
216 | } | |
216 |
|
217 | |||
217 | void QPieModelMapperPrivate::blockModelSignals(bool block) |
|
218 | void QPieModelMapperPrivate::blockModelSignals(bool block) | |
218 | { |
|
219 | { | |
219 | m_modelSignalsBlock = block; |
|
220 | m_modelSignalsBlock = block; | |
220 | } |
|
221 | } | |
221 |
|
222 | |||
222 | void QPieModelMapperPrivate::blockSeriesSignals(bool block) |
|
223 | void QPieModelMapperPrivate::blockSeriesSignals(bool block) | |
223 | { |
|
224 | { | |
224 | m_seriesSignalsBlock = block; |
|
225 | m_seriesSignalsBlock = block; | |
225 | } |
|
226 | } | |
226 |
|
227 | |||
227 |
|
228 | |||
228 | QPieSlice *QPieModelMapperPrivate::pieSlice(QModelIndex index) const |
|
229 | QPieSlice *QPieModelMapperPrivate::pieSlice(QModelIndex index) const | |
229 | { |
|
230 | { | |
230 | if (!index.isValid()) |
|
231 | if (!index.isValid()) | |
231 | return 0; // index is invalid |
|
232 | return 0; // index is invalid | |
232 |
|
233 | |||
233 | if (m_orientation == Qt::Vertical && (index.column() == m_valuesSection || index.column() == m_labelsSection)) { |
|
234 | if (m_orientation == Qt::Vertical && (index.column() == m_valuesSection || index.column() == m_labelsSection)) { | |
234 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { |
|
235 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { | |
235 | if (m_model->index(index.row(), m_valuesSection).isValid() && m_model->index(index.row(), m_labelsSection).isValid()) |
|
236 | if (m_model->index(index.row(), m_valuesSection).isValid() && m_model->index(index.row(), m_labelsSection).isValid()) | |
236 | return m_series->slices().at(index.row() - m_first); |
|
237 | return m_series->slices().at(index.row() - m_first); | |
237 | else |
|
238 | else | |
238 | return 0; |
|
239 | return 0; | |
239 | } |
|
240 | } | |
240 | } else if (m_orientation == Qt::Horizontal && (index.row() == m_valuesSection || index.row() == m_labelsSection)) { |
|
241 | } else if (m_orientation == Qt::Horizontal && (index.row() == m_valuesSection || index.row() == m_labelsSection)) { | |
241 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) { |
|
242 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) { | |
242 | if (m_model->index(m_valuesSection, index.column()).isValid() && m_model->index(m_labelsSection, index.column()).isValid()) |
|
243 | if (m_model->index(m_valuesSection, index.column()).isValid() && m_model->index(m_labelsSection, index.column()).isValid()) | |
243 | return m_series->slices().at(index.column() - m_first); |
|
244 | return m_series->slices().at(index.column() - m_first); | |
244 | else |
|
245 | else | |
245 | return 0; |
|
246 | return 0; | |
246 | } |
|
247 | } | |
247 | } |
|
248 | } | |
248 | return 0; // This part of model has not been mapped to any slice |
|
249 | return 0; // This part of model has not been mapped to any slice | |
249 | } |
|
250 | } | |
250 |
|
251 | |||
251 | QModelIndex QPieModelMapperPrivate::valueModelIndex(int slicePos) |
|
252 | QModelIndex QPieModelMapperPrivate::valueModelIndex(int slicePos) | |
252 | { |
|
253 | { | |
253 | if (m_count != -1 && slicePos >= m_count) |
|
254 | if (m_count != -1 && slicePos >= m_count) | |
254 | return QModelIndex(); // invalid |
|
255 | return QModelIndex(); // invalid | |
255 |
|
256 | |||
256 | if (m_orientation == Qt::Vertical) |
|
257 | if (m_orientation == Qt::Vertical) | |
257 | return m_model->index(slicePos + m_first, m_valuesSection); |
|
258 | return m_model->index(slicePos + m_first, m_valuesSection); | |
258 | else |
|
259 | else | |
259 | return m_model->index(m_valuesSection, slicePos + m_first); |
|
260 | return m_model->index(m_valuesSection, slicePos + m_first); | |
260 | } |
|
261 | } | |
261 |
|
262 | |||
262 | QModelIndex QPieModelMapperPrivate::labelModelIndex(int slicePos) |
|
263 | QModelIndex QPieModelMapperPrivate::labelModelIndex(int slicePos) | |
263 | { |
|
264 | { | |
264 | if (m_count != -1 && slicePos >= m_count) |
|
265 | if (m_count != -1 && slicePos >= m_count) | |
265 | return QModelIndex(); // invalid |
|
266 | return QModelIndex(); // invalid | |
266 |
|
267 | |||
267 | if (m_orientation == Qt::Vertical) |
|
268 | if (m_orientation == Qt::Vertical) | |
268 | return m_model->index(slicePos + m_first, m_labelsSection); |
|
269 | return m_model->index(slicePos + m_first, m_labelsSection); | |
269 | else |
|
270 | else | |
270 | return m_model->index(m_labelsSection, slicePos + m_first); |
|
271 | return m_model->index(m_labelsSection, slicePos + m_first); | |
271 | } |
|
272 | } | |
272 |
|
273 | |||
273 | bool QPieModelMapperPrivate::isLabelIndex(QModelIndex index) const |
|
274 | bool QPieModelMapperPrivate::isLabelIndex(QModelIndex index) const | |
274 | { |
|
275 | { | |
275 | if (m_orientation == Qt::Vertical && index.column() == m_labelsSection) |
|
276 | if (m_orientation == Qt::Vertical && index.column() == m_labelsSection) | |
276 | return true; |
|
277 | return true; | |
277 | else if (m_orientation == Qt::Horizontal && index.row() == m_labelsSection) |
|
278 | else if (m_orientation == Qt::Horizontal && index.row() == m_labelsSection) | |
278 | return true; |
|
279 | return true; | |
279 |
|
280 | |||
280 | return false; |
|
281 | return false; | |
281 | } |
|
282 | } | |
282 |
|
283 | |||
283 | bool QPieModelMapperPrivate::isValueIndex(QModelIndex index) const |
|
284 | bool QPieModelMapperPrivate::isValueIndex(QModelIndex index) const | |
284 | { |
|
285 | { | |
285 | if (m_orientation == Qt::Vertical && index.column() == m_valuesSection) |
|
286 | if (m_orientation == Qt::Vertical && index.column() == m_valuesSection) | |
286 | return true; |
|
287 | return true; | |
287 | else if (m_orientation == Qt::Horizontal && index.row() == m_valuesSection) |
|
288 | else if (m_orientation == Qt::Horizontal && index.row() == m_valuesSection) | |
288 | return true; |
|
289 | return true; | |
289 |
|
290 | |||
290 | return false; |
|
291 | return false; | |
291 | } |
|
292 | } | |
292 |
|
293 | |||
293 | void QPieModelMapperPrivate::slicesAdded(QList<QPieSlice *> slices) |
|
294 | void QPieModelMapperPrivate::slicesAdded(QList<QPieSlice *> slices) | |
294 | { |
|
295 | { | |
295 | if (m_seriesSignalsBlock) |
|
296 | if (m_seriesSignalsBlock) | |
296 | return; |
|
297 | return; | |
297 |
|
298 | |||
298 | if (slices.count() == 0) |
|
299 | if (slices.count() == 0) | |
299 | return; |
|
300 | return; | |
300 |
|
301 | |||
301 | int firstIndex = m_series->slices().indexOf(slices.at(0)); |
|
302 | int firstIndex = m_series->slices().indexOf(slices.at(0)); | |
302 | if (firstIndex == -1) |
|
303 | if (firstIndex == -1) | |
303 | return; |
|
304 | return; | |
304 |
|
305 | |||
305 | if (m_count != -1) |
|
306 | if (m_count != -1) | |
306 | m_count += slices.count(); |
|
307 | m_count += slices.count(); | |
307 |
|
308 | |||
308 | for (int i = firstIndex; i < firstIndex + slices.count(); i++) { |
|
309 | for (int i = firstIndex; i < firstIndex + slices.count(); i++) { | |
309 | m_slices.insert(i, slices.at(i - firstIndex)); |
|
310 | m_slices.insert(i, slices.at(i - firstIndex)); | |
310 | connect(slices.at(i - firstIndex), SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged())); |
|
311 | connect(slices.at(i - firstIndex), SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged())); | |
311 | connect(slices.at(i - firstIndex), SIGNAL(valueChanged()), this, SLOT(sliceValueChanged())); |
|
312 | connect(slices.at(i - firstIndex), SIGNAL(valueChanged()), this, SLOT(sliceValueChanged())); | |
312 | } |
|
313 | } | |
313 |
|
314 | |||
314 | blockModelSignals(); |
|
315 | blockModelSignals(); | |
315 | if (m_orientation == Qt::Vertical) |
|
316 | if (m_orientation == Qt::Vertical) | |
316 | m_model->insertRows(firstIndex + m_first, slices.count()); |
|
317 | m_model->insertRows(firstIndex + m_first, slices.count()); | |
317 | else |
|
318 | else | |
318 | m_model->insertColumns(firstIndex + m_first, slices.count()); |
|
319 | m_model->insertColumns(firstIndex + m_first, slices.count()); | |
319 |
|
320 | |||
320 | for (int i = firstIndex; i < firstIndex + slices.count(); i++) { |
|
321 | for (int i = firstIndex; i < firstIndex + slices.count(); i++) { | |
321 | m_model->setData(valueModelIndex(i), slices.at(i - firstIndex)->value()); |
|
322 | m_model->setData(valueModelIndex(i), slices.at(i - firstIndex)->value()); | |
322 | m_model->setData(labelModelIndex(i), slices.at(i - firstIndex)->label()); |
|
323 | m_model->setData(labelModelIndex(i), slices.at(i - firstIndex)->label()); | |
323 | } |
|
324 | } | |
324 | blockModelSignals(false); |
|
325 | blockModelSignals(false); | |
325 | } |
|
326 | } | |
326 |
|
327 | |||
327 | void QPieModelMapperPrivate::slicesRemoved(QList<QPieSlice *> slices) |
|
328 | void QPieModelMapperPrivate::slicesRemoved(QList<QPieSlice *> slices) | |
328 | { |
|
329 | { | |
329 | if (m_seriesSignalsBlock) |
|
330 | if (m_seriesSignalsBlock) | |
330 | return; |
|
331 | return; | |
331 |
|
332 | |||
332 | if (slices.count() == 0) |
|
333 | if (slices.count() == 0) | |
333 | return; |
|
334 | return; | |
334 |
|
335 | |||
335 | int firstIndex = m_slices.indexOf(slices.at(0)); |
|
336 | int firstIndex = m_slices.indexOf(slices.at(0)); | |
336 | if (firstIndex == -1) |
|
337 | if (firstIndex == -1) | |
337 | return; |
|
338 | return; | |
338 |
|
339 | |||
339 | if (m_count != -1) |
|
340 | if (m_count != -1) | |
340 | m_count -= slices.count(); |
|
341 | m_count -= slices.count(); | |
341 |
|
342 | |||
342 | for (int i = firstIndex + slices.count() - 1; i >= firstIndex; i--) |
|
343 | for (int i = firstIndex + slices.count() - 1; i >= firstIndex; i--) | |
343 | m_slices.removeAt(i); |
|
344 | m_slices.removeAt(i); | |
344 |
|
345 | |||
345 | blockModelSignals(); |
|
346 | blockModelSignals(); | |
346 | if (m_orientation == Qt::Vertical) |
|
347 | if (m_orientation == Qt::Vertical) | |
347 | m_model->removeRows(firstIndex + m_first, slices.count()); |
|
348 | m_model->removeRows(firstIndex + m_first, slices.count()); | |
348 | else |
|
349 | else | |
349 | m_model->removeColumns(firstIndex + m_first, slices.count()); |
|
350 | m_model->removeColumns(firstIndex + m_first, slices.count()); | |
350 | blockModelSignals(false); |
|
351 | blockModelSignals(false); | |
351 | } |
|
352 | } | |
352 |
|
353 | |||
353 | void QPieModelMapperPrivate::sliceLabelChanged() |
|
354 | void QPieModelMapperPrivate::sliceLabelChanged() | |
354 | { |
|
355 | { | |
355 | if (m_seriesSignalsBlock) |
|
356 | if (m_seriesSignalsBlock) | |
356 | return; |
|
357 | return; | |
357 |
|
358 | |||
358 | blockModelSignals(); |
|
359 | blockModelSignals(); | |
359 | QPieSlice *slice = qobject_cast<QPieSlice *>(QObject::sender()); |
|
360 | QPieSlice *slice = qobject_cast<QPieSlice *>(QObject::sender()); | |
360 | m_model->setData(labelModelIndex(m_series->slices().indexOf(slice)), slice->label()); |
|
361 | m_model->setData(labelModelIndex(m_series->slices().indexOf(slice)), slice->label()); | |
361 | blockModelSignals(false); |
|
362 | blockModelSignals(false); | |
362 | } |
|
363 | } | |
363 |
|
364 | |||
364 | void QPieModelMapperPrivate::sliceValueChanged() |
|
365 | void QPieModelMapperPrivate::sliceValueChanged() | |
365 | { |
|
366 | { | |
366 | if (m_seriesSignalsBlock) |
|
367 | if (m_seriesSignalsBlock) | |
367 | return; |
|
368 | return; | |
368 |
|
369 | |||
369 | blockModelSignals(); |
|
370 | blockModelSignals(); | |
370 | QPieSlice *slice = qobject_cast<QPieSlice *>(QObject::sender()); |
|
371 | QPieSlice *slice = qobject_cast<QPieSlice *>(QObject::sender()); | |
371 | m_model->setData(valueModelIndex(m_series->slices().indexOf(slice)), slice->value()); |
|
372 | m_model->setData(valueModelIndex(m_series->slices().indexOf(slice)), slice->value()); | |
372 | blockModelSignals(false); |
|
373 | blockModelSignals(false); | |
373 | } |
|
374 | } | |
374 |
|
375 | |||
375 | void QPieModelMapperPrivate::handleSeriesDestroyed() |
|
376 | void QPieModelMapperPrivate::handleSeriesDestroyed() | |
376 | { |
|
377 | { | |
377 | m_series = 0; |
|
378 | m_series = 0; | |
378 | } |
|
379 | } | |
379 |
|
380 | |||
380 | void QPieModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
381 | void QPieModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
381 | { |
|
382 | { | |
382 | if (m_model == 0 || m_series == 0) |
|
383 | if (m_model == 0 || m_series == 0) | |
383 | return; |
|
384 | return; | |
384 |
|
385 | |||
385 | if (m_modelSignalsBlock) |
|
386 | if (m_modelSignalsBlock) | |
386 | return; |
|
387 | return; | |
387 |
|
388 | |||
388 | blockSeriesSignals(); |
|
389 | blockSeriesSignals(); | |
389 | QModelIndex index; |
|
390 | QModelIndex index; | |
390 | QPieSlice *slice; |
|
391 | QPieSlice *slice; | |
391 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { |
|
392 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
392 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { |
|
393 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { | |
393 | index = topLeft.sibling(row, column); |
|
394 | index = topLeft.sibling(row, column); | |
394 | slice = pieSlice(index); |
|
395 | slice = pieSlice(index); | |
395 | if (slice) { |
|
396 | if (slice) { | |
396 | if (isValueIndex(index)) |
|
397 | if (isValueIndex(index)) | |
397 | slice->setValue(m_model->data(index, Qt::DisplayRole).toReal()); |
|
398 | slice->setValue(m_model->data(index, Qt::DisplayRole).toReal()); | |
398 | if (isLabelIndex(index)) |
|
399 | if (isLabelIndex(index)) | |
399 | slice->setLabel(m_model->data(index, Qt::DisplayRole).toString()); |
|
400 | slice->setLabel(m_model->data(index, Qt::DisplayRole).toString()); | |
400 | } |
|
401 | } | |
401 | } |
|
402 | } | |
402 | } |
|
403 | } | |
403 | blockSeriesSignals(false); |
|
404 | blockSeriesSignals(false); | |
404 | } |
|
405 | } | |
405 |
|
406 | |||
406 |
|
407 | |||
407 | void QPieModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) |
|
408 | void QPieModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) | |
408 | { |
|
409 | { | |
409 | Q_UNUSED(parent); |
|
410 | Q_UNUSED(parent); | |
410 | if (m_modelSignalsBlock) |
|
411 | if (m_modelSignalsBlock) | |
411 | return; |
|
412 | return; | |
412 |
|
413 | |||
413 | blockSeriesSignals(); |
|
414 | blockSeriesSignals(); | |
414 | if (m_orientation == Qt::Vertical) |
|
415 | if (m_orientation == Qt::Vertical) | |
415 | insertData(start, end); |
|
416 | insertData(start, end); | |
416 | else if (start <= m_valuesSection || start <= m_labelsSection) // if the changes affect the map - reinitialize the pie |
|
417 | else if (start <= m_valuesSection || start <= m_labelsSection) // if the changes affect the map - reinitialize the pie | |
417 | initializePieFromModel(); |
|
418 | initializePieFromModel(); | |
418 | blockSeriesSignals(false); |
|
419 | blockSeriesSignals(false); | |
419 | } |
|
420 | } | |
420 |
|
421 | |||
421 | void QPieModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) |
|
422 | void QPieModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) | |
422 | { |
|
423 | { | |
423 | Q_UNUSED(parent); |
|
424 | Q_UNUSED(parent); | |
424 | if (m_modelSignalsBlock) |
|
425 | if (m_modelSignalsBlock) | |
425 | return; |
|
426 | return; | |
426 |
|
427 | |||
427 | blockSeriesSignals(); |
|
428 | blockSeriesSignals(); | |
428 | if (m_orientation == Qt::Vertical) |
|
429 | if (m_orientation == Qt::Vertical) | |
429 | removeData(start, end); |
|
430 | removeData(start, end); | |
430 | else if (start <= m_valuesSection || start <= m_labelsSection) // if the changes affect the map - reinitialize the pie |
|
431 | else if (start <= m_valuesSection || start <= m_labelsSection) // if the changes affect the map - reinitialize the pie | |
431 | initializePieFromModel(); |
|
432 | initializePieFromModel(); | |
432 | blockSeriesSignals(false); |
|
433 | blockSeriesSignals(false); | |
433 | } |
|
434 | } | |
434 |
|
435 | |||
435 | void QPieModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) |
|
436 | void QPieModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) | |
436 | { |
|
437 | { | |
437 | Q_UNUSED(parent); |
|
438 | Q_UNUSED(parent); | |
438 | if (m_modelSignalsBlock) |
|
439 | if (m_modelSignalsBlock) | |
439 | return; |
|
440 | return; | |
440 |
|
441 | |||
441 | blockSeriesSignals(); |
|
442 | blockSeriesSignals(); | |
442 | if (m_orientation == Qt::Horizontal) |
|
443 | if (m_orientation == Qt::Horizontal) | |
443 | insertData(start, end); |
|
444 | insertData(start, end); | |
444 | else if (start <= m_valuesSection || start <= m_labelsSection) // if the changes affect the map - reinitialize the pie |
|
445 | else if (start <= m_valuesSection || start <= m_labelsSection) // if the changes affect the map - reinitialize the pie | |
445 | initializePieFromModel(); |
|
446 | initializePieFromModel(); | |
446 | blockSeriesSignals(false); |
|
447 | blockSeriesSignals(false); | |
447 | } |
|
448 | } | |
448 |
|
449 | |||
449 | void QPieModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) |
|
450 | void QPieModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) | |
450 | { |
|
451 | { | |
451 | Q_UNUSED(parent); |
|
452 | Q_UNUSED(parent); | |
452 | if (m_modelSignalsBlock) |
|
453 | if (m_modelSignalsBlock) | |
453 | return; |
|
454 | return; | |
454 |
|
455 | |||
455 | blockSeriesSignals(); |
|
456 | blockSeriesSignals(); | |
456 | if (m_orientation == Qt::Horizontal) |
|
457 | if (m_orientation == Qt::Horizontal) | |
457 | removeData(start, end); |
|
458 | removeData(start, end); | |
458 | else if (start <= m_valuesSection || start <= m_labelsSection) // if the changes affect the map - reinitialize the pie |
|
459 | else if (start <= m_valuesSection || start <= m_labelsSection) // if the changes affect the map - reinitialize the pie | |
459 | initializePieFromModel(); |
|
460 | initializePieFromModel(); | |
460 | blockSeriesSignals(false); |
|
461 | blockSeriesSignals(false); | |
461 | } |
|
462 | } | |
462 |
|
463 | |||
463 | void QPieModelMapperPrivate::handleModelDestroyed() |
|
464 | void QPieModelMapperPrivate::handleModelDestroyed() | |
464 | { |
|
465 | { | |
465 | m_model = 0; |
|
466 | m_model = 0; | |
466 | } |
|
467 | } | |
467 |
|
468 | |||
468 | void QPieModelMapperPrivate::insertData(int start, int end) |
|
469 | void QPieModelMapperPrivate::insertData(int start, int end) | |
469 | { |
|
470 | { | |
470 | if (m_model == 0 || m_series == 0) |
|
471 | if (m_model == 0 || m_series == 0) | |
471 | return; |
|
472 | return; | |
472 |
|
473 | |||
473 | if (m_count != -1 && start >= m_first + m_count) { |
|
474 | if (m_count != -1 && start >= m_first + m_count) { | |
474 | return; |
|
475 | return; | |
475 | } else { |
|
476 | } else { | |
476 | int addedCount = end - start + 1; |
|
477 | int addedCount = end - start + 1; | |
477 | if (m_count != -1 && addedCount > m_count) |
|
478 | if (m_count != -1 && addedCount > m_count) | |
478 | addedCount = m_count; |
|
479 | addedCount = m_count; | |
479 | int first = qMax(start, m_first); |
|
480 | int first = qMax(start, m_first); | |
480 | int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); |
|
481 | int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); | |
481 | for (int i = first; i <= last; i++) { |
|
482 | for (int i = first; i <= last; i++) { | |
482 | QModelIndex valueIndex = valueModelIndex(i - m_first); |
|
483 | QModelIndex valueIndex = valueModelIndex(i - m_first); | |
483 | QModelIndex labelIndex = labelModelIndex(i - m_first); |
|
484 | QModelIndex labelIndex = labelModelIndex(i - m_first); | |
484 | if (valueIndex.isValid() && labelIndex.isValid()) { |
|
485 | if (valueIndex.isValid() && labelIndex.isValid()) { | |
485 | QPieSlice *slice = new QPieSlice; |
|
486 | QPieSlice *slice = new QPieSlice; | |
486 | slice->setValue(m_model->data(valueIndex, Qt::DisplayRole).toDouble()); |
|
487 | slice->setValue(m_model->data(valueIndex, Qt::DisplayRole).toDouble()); | |
487 | slice->setLabel(m_model->data(labelIndex, Qt::DisplayRole).toString()); |
|
488 | slice->setLabel(m_model->data(labelIndex, Qt::DisplayRole).toString()); | |
488 | connect(slice, SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged())); |
|
489 | connect(slice, SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged())); | |
489 | connect(slice, SIGNAL(valueChanged()), this, SLOT(sliceValueChanged())); |
|
490 | connect(slice, SIGNAL(valueChanged()), this, SLOT(sliceValueChanged())); | |
490 | m_series->insert(i - m_first, slice); |
|
491 | m_series->insert(i - m_first, slice); | |
491 | m_slices.insert(i - m_first, slice); |
|
492 | m_slices.insert(i - m_first, slice); | |
492 | } |
|
493 | } | |
493 | } |
|
494 | } | |
494 |
|
495 | |||
495 | // remove excess of slices (abouve m_count) |
|
496 | // remove excess of slices (abouve m_count) | |
496 | if (m_count != -1 && m_series->slices().size() > m_count) |
|
497 | if (m_count != -1 && m_series->slices().size() > m_count) | |
497 | for (int i = m_series->slices().size() - 1; i >= m_count; i--) { |
|
498 | for (int i = m_series->slices().size() - 1; i >= m_count; i--) { | |
498 | m_series->remove(m_series->slices().at(i)); |
|
499 | m_series->remove(m_series->slices().at(i)); | |
499 | m_slices.removeAt(i); |
|
500 | m_slices.removeAt(i); | |
500 | } |
|
501 | } | |
501 | } |
|
502 | } | |
502 | } |
|
503 | } | |
503 |
|
504 | |||
504 | void QPieModelMapperPrivate::removeData(int start, int end) |
|
505 | void QPieModelMapperPrivate::removeData(int start, int end) | |
505 | { |
|
506 | { | |
506 | if (m_model == 0 || m_series == 0) |
|
507 | if (m_model == 0 || m_series == 0) | |
507 | return; |
|
508 | return; | |
508 |
|
509 | |||
509 | int removedCount = end - start + 1; |
|
510 | int removedCount = end - start + 1; | |
510 | if (m_count != -1 && start >= m_first + m_count) { |
|
511 | if (m_count != -1 && start >= m_first + m_count) { | |
511 | return; |
|
512 | return; | |
512 | } else { |
|
513 | } else { | |
513 | int toRemove = qMin(m_series->slices().size(), removedCount); // first find how many items can actually be removed |
|
514 | int toRemove = qMin(m_series->slices().size(), removedCount); // first find how many items can actually be removed | |
514 | int first = qMax(start, m_first); // get the index of the first item that will be removed. |
|
515 | int first = qMax(start, m_first); // get the index of the first item that will be removed. | |
515 | int last = qMin(first + toRemove - 1, m_series->slices().size() + m_first - 1); // get the index of the last item that will be removed. |
|
516 | int last = qMin(first + toRemove - 1, m_series->slices().size() + m_first - 1); // get the index of the last item that will be removed. | |
516 | for (int i = last; i >= first; i--) { |
|
517 | for (int i = last; i >= first; i--) { | |
517 | m_series->remove(m_series->slices().at(i - m_first)); |
|
518 | m_series->remove(m_series->slices().at(i - m_first)); | |
518 | m_slices.removeAt(i - m_first); |
|
519 | m_slices.removeAt(i - m_first); | |
519 | } |
|
520 | } | |
520 |
|
521 | |||
521 | if (m_count != -1) { |
|
522 | if (m_count != -1) { | |
522 | int itemsAvailable; // check how many are available to be added |
|
523 | int itemsAvailable; // check how many are available to be added | |
523 | if (m_orientation == Qt::Vertical) |
|
524 | if (m_orientation == Qt::Vertical) | |
524 | itemsAvailable = m_model->rowCount() - m_first - m_series->slices().size(); |
|
525 | itemsAvailable = m_model->rowCount() - m_first - m_series->slices().size(); | |
525 | else |
|
526 | else | |
526 | itemsAvailable = m_model->columnCount() - m_first - m_series->slices().size(); |
|
527 | itemsAvailable = m_model->columnCount() - m_first - m_series->slices().size(); | |
527 | int toBeAdded = qMin(itemsAvailable, m_count - m_series->slices().size()); // add not more items than there is space left to be filled. |
|
528 | int toBeAdded = qMin(itemsAvailable, m_count - m_series->slices().size()); // add not more items than there is space left to be filled. | |
528 | int currentSize = m_series->slices().size(); |
|
529 | int currentSize = m_series->slices().size(); | |
529 | if (toBeAdded > 0) |
|
530 | if (toBeAdded > 0) | |
530 | for (int i = m_series->slices().size(); i < currentSize + toBeAdded; i++) { |
|
531 | for (int i = m_series->slices().size(); i < currentSize + toBeAdded; i++) { | |
531 | QModelIndex valueIndex = valueModelIndex(i - m_first); |
|
532 | QModelIndex valueIndex = valueModelIndex(i - m_first); | |
532 | QModelIndex labelIndex = labelModelIndex(i - m_first); |
|
533 | QModelIndex labelIndex = labelModelIndex(i - m_first); | |
533 | if (valueIndex.isValid() && labelIndex.isValid()) { |
|
534 | if (valueIndex.isValid() && labelIndex.isValid()) { | |
534 | QPieSlice *slice = new QPieSlice; |
|
535 | QPieSlice *slice = new QPieSlice; | |
535 | slice->setValue(m_model->data(valueIndex, Qt::DisplayRole).toDouble()); |
|
536 | slice->setValue(m_model->data(valueIndex, Qt::DisplayRole).toDouble()); | |
536 | slice->setLabel(m_model->data(labelIndex, Qt::DisplayRole).toString()); |
|
537 | slice->setLabel(m_model->data(labelIndex, Qt::DisplayRole).toString()); | |
537 | m_series->insert(i, slice); |
|
538 | m_series->insert(i, slice); | |
538 | m_slices.insert(i, slice); |
|
539 | m_slices.insert(i, slice); | |
539 | } |
|
540 | } | |
540 | } |
|
541 | } | |
541 | } |
|
542 | } | |
542 | } |
|
543 | } | |
543 | } |
|
544 | } | |
544 |
|
545 | |||
545 | void QPieModelMapperPrivate::initializePieFromModel() |
|
546 | void QPieModelMapperPrivate::initializePieFromModel() | |
546 | { |
|
547 | { | |
547 | if (m_model == 0 || m_series == 0) |
|
548 | if (m_model == 0 || m_series == 0) | |
548 | return; |
|
549 | return; | |
549 |
|
550 | |||
550 | blockSeriesSignals(); |
|
551 | blockSeriesSignals(); | |
551 | // clear current content |
|
552 | // clear current content | |
552 | m_series->clear(); |
|
553 | m_series->clear(); | |
553 | m_slices.clear(); |
|
554 | m_slices.clear(); | |
554 |
|
555 | |||
555 | // create the initial slices set |
|
556 | // create the initial slices set | |
556 | int slicePos = 0; |
|
557 | int slicePos = 0; | |
557 | QModelIndex valueIndex = valueModelIndex(slicePos); |
|
558 | QModelIndex valueIndex = valueModelIndex(slicePos); | |
558 | QModelIndex labelIndex = labelModelIndex(slicePos); |
|
559 | QModelIndex labelIndex = labelModelIndex(slicePos); | |
559 | while (valueIndex.isValid() && labelIndex.isValid()) { |
|
560 | while (valueIndex.isValid() && labelIndex.isValid()) { | |
560 | QPieSlice *slice = new QPieSlice; |
|
561 | QPieSlice *slice = new QPieSlice; | |
561 | slice->setLabel(m_model->data(labelIndex, Qt::DisplayRole).toString()); |
|
562 | slice->setLabel(m_model->data(labelIndex, Qt::DisplayRole).toString()); | |
562 | slice->setValue(m_model->data(valueIndex, Qt::DisplayRole).toDouble()); |
|
563 | slice->setValue(m_model->data(valueIndex, Qt::DisplayRole).toDouble()); | |
563 | connect(slice, SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged())); |
|
564 | connect(slice, SIGNAL(labelChanged()), this, SLOT(sliceLabelChanged())); | |
564 | connect(slice, SIGNAL(valueChanged()), this, SLOT(sliceValueChanged())); |
|
565 | connect(slice, SIGNAL(valueChanged()), this, SLOT(sliceValueChanged())); | |
565 | m_series->append(slice); |
|
566 | m_series->append(slice); | |
566 | m_slices.append(slice); |
|
567 | m_slices.append(slice); | |
567 | slicePos++; |
|
568 | slicePos++; | |
568 | valueIndex = valueModelIndex(slicePos); |
|
569 | valueIndex = valueModelIndex(slicePos); | |
569 | labelIndex = labelModelIndex(slicePos); |
|
570 | labelIndex = labelModelIndex(slicePos); | |
570 | } |
|
571 | } | |
571 | blockSeriesSignals(false); |
|
572 | blockSeriesSignals(false); | |
572 | } |
|
573 | } | |
573 |
|
574 | |||
574 | #include "moc_qpiemodelmapper_p.cpp" |
|
575 | #include "moc_qpiemodelmapper_p.cpp" | |
575 | #include "moc_qpiemodelmapper.cpp" |
|
576 | #include "moc_qpiemodelmapper.cpp" | |
576 |
|
577 | |||
577 | QT_CHARTS_END_NAMESPACE |
|
578 | QT_CHARTS_END_NAMESPACE |
@@ -1,80 +1,80 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QPIEMODELMAPPER_H |
|
30 | #ifndef QPIEMODELMAPPER_H | |
31 | #define QPIEMODELMAPPER_H |
|
31 | #define QPIEMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCore/QObject> |
|
34 | #include <QtCore/QObject> | |
35 |
|
35 | |||
36 | QT_BEGIN_NAMESPACE |
|
36 | QT_BEGIN_NAMESPACE | |
37 | class QAbstractItemModel; |
|
37 | class QAbstractItemModel; | |
38 | QT_END_NAMESPACE |
|
38 | QT_END_NAMESPACE | |
39 |
|
39 | |||
40 | QT_CHARTS_BEGIN_NAMESPACE |
|
40 | QT_CHARTS_BEGIN_NAMESPACE | |
41 |
|
41 | |||
42 | class QPieModelMapperPrivate; |
|
42 | class QPieModelMapperPrivate; | |
43 | class QPieSeries; |
|
43 | class QPieSeries; | |
44 |
|
44 | |||
45 | class QT_CHARTS_EXPORT QPieModelMapper : public QObject |
|
45 | class QT_CHARTS_EXPORT QPieModelMapper : public QObject | |
46 | { |
|
46 | { | |
47 | Q_OBJECT |
|
47 | Q_OBJECT | |
48 |
|
48 | |||
49 | protected: |
|
49 | protected: | |
50 |
explicit QPieModelMapper(QObject *parent = |
|
50 | explicit QPieModelMapper(QObject *parent = Q_NULLPTR); | |
51 |
|
51 | |||
52 | QAbstractItemModel *model() const; |
|
52 | QAbstractItemModel *model() const; | |
53 | void setModel(QAbstractItemModel *model); |
|
53 | void setModel(QAbstractItemModel *model); | |
54 |
|
54 | |||
55 | QPieSeries *series() const; |
|
55 | QPieSeries *series() const; | |
56 | void setSeries(QPieSeries *series); |
|
56 | void setSeries(QPieSeries *series); | |
57 |
|
57 | |||
58 | int first() const; |
|
58 | int first() const; | |
59 | void setFirst(int first); |
|
59 | void setFirst(int first); | |
60 |
|
60 | |||
61 | int count() const; |
|
61 | int count() const; | |
62 | void setCount(int count); |
|
62 | void setCount(int count); | |
63 |
|
63 | |||
64 | int valuesSection() const; |
|
64 | int valuesSection() const; | |
65 | void setValuesSection(int valuesSection); |
|
65 | void setValuesSection(int valuesSection); | |
66 |
|
66 | |||
67 | int labelsSection() const; |
|
67 | int labelsSection() const; | |
68 | void setLabelsSection(int labelsSection); |
|
68 | void setLabelsSection(int labelsSection); | |
69 |
|
69 | |||
70 | Qt::Orientation orientation() const; |
|
70 | Qt::Orientation orientation() const; | |
71 | void setOrientation(Qt::Orientation orientation); |
|
71 | void setOrientation(Qt::Orientation orientation); | |
72 |
|
72 | |||
73 | protected: |
|
73 | protected: | |
74 | QPieModelMapperPrivate * const d_ptr; |
|
74 | QPieModelMapperPrivate * const d_ptr; | |
75 | Q_DECLARE_PRIVATE(QPieModelMapper) |
|
75 | Q_DECLARE_PRIVATE(QPieModelMapper) | |
76 | }; |
|
76 | }; | |
77 |
|
77 | |||
78 | QT_CHARTS_END_NAMESPACE |
|
78 | QT_CHARTS_END_NAMESPACE | |
79 |
|
79 | |||
80 | #endif // QPIEMODELMAPPER_H |
|
80 | #endif // QPIEMODELMAPPER_H |
@@ -1,115 +1,115 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QPIESERIES_H |
|
30 | #ifndef QPIESERIES_H | |
31 | #define QPIESERIES_H |
|
31 | #define QPIESERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractSeries> |
|
33 | #include <QtCharts/QAbstractSeries> | |
34 | #include <QtCharts/QPieSlice> |
|
34 | #include <QtCharts/QPieSlice> | |
35 |
|
35 | |||
36 | QT_CHARTS_BEGIN_NAMESPACE |
|
36 | QT_CHARTS_BEGIN_NAMESPACE | |
37 | class QPieSeriesPrivate; |
|
37 | class QPieSeriesPrivate; | |
38 |
|
38 | |||
39 | class QT_CHARTS_EXPORT QPieSeries : public QAbstractSeries |
|
39 | class QT_CHARTS_EXPORT QPieSeries : public QAbstractSeries | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | Q_PROPERTY(qreal horizontalPosition READ horizontalPosition WRITE setHorizontalPosition) |
|
42 | Q_PROPERTY(qreal horizontalPosition READ horizontalPosition WRITE setHorizontalPosition) | |
43 | Q_PROPERTY(qreal verticalPosition READ verticalPosition WRITE setVerticalPosition) |
|
43 | Q_PROPERTY(qreal verticalPosition READ verticalPosition WRITE setVerticalPosition) | |
44 | Q_PROPERTY(qreal size READ pieSize WRITE setPieSize) |
|
44 | Q_PROPERTY(qreal size READ pieSize WRITE setPieSize) | |
45 | Q_PROPERTY(qreal startAngle READ pieStartAngle WRITE setPieStartAngle) |
|
45 | Q_PROPERTY(qreal startAngle READ pieStartAngle WRITE setPieStartAngle) | |
46 | Q_PROPERTY(qreal endAngle READ pieEndAngle WRITE setPieEndAngle) |
|
46 | Q_PROPERTY(qreal endAngle READ pieEndAngle WRITE setPieEndAngle) | |
47 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
47 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
48 | Q_PROPERTY(qreal sum READ sum NOTIFY sumChanged) |
|
48 | Q_PROPERTY(qreal sum READ sum NOTIFY sumChanged) | |
49 | Q_PROPERTY(qreal holeSize READ holeSize WRITE setHoleSize) |
|
49 | Q_PROPERTY(qreal holeSize READ holeSize WRITE setHoleSize) | |
50 |
|
50 | |||
51 | public: |
|
51 | public: | |
52 |
explicit QPieSeries(QObject *parent = |
|
52 | explicit QPieSeries(QObject *parent = Q_NULLPTR); | |
53 | virtual ~QPieSeries(); |
|
53 | virtual ~QPieSeries(); | |
54 |
|
54 | |||
55 | QAbstractSeries::SeriesType type() const; |
|
55 | QAbstractSeries::SeriesType type() const; | |
56 |
|
56 | |||
57 | bool append(QPieSlice *slice); |
|
57 | bool append(QPieSlice *slice); | |
58 | bool append(QList<QPieSlice *> slices); |
|
58 | bool append(QList<QPieSlice *> slices); | |
59 | QPieSeries &operator << (QPieSlice *slice); |
|
59 | QPieSeries &operator << (QPieSlice *slice); | |
60 | QPieSlice *append(QString label, qreal value); |
|
60 | QPieSlice *append(QString label, qreal value); | |
61 |
|
61 | |||
62 | bool insert(int index, QPieSlice *slice); |
|
62 | bool insert(int index, QPieSlice *slice); | |
63 |
|
63 | |||
64 | bool remove(QPieSlice *slice); |
|
64 | bool remove(QPieSlice *slice); | |
65 | bool take(QPieSlice *slice); |
|
65 | bool take(QPieSlice *slice); | |
66 | void clear(); |
|
66 | void clear(); | |
67 |
|
67 | |||
68 | QList<QPieSlice *> slices() const; |
|
68 | QList<QPieSlice *> slices() const; | |
69 | int count() const; |
|
69 | int count() const; | |
70 |
|
70 | |||
71 | bool isEmpty() const; |
|
71 | bool isEmpty() const; | |
72 |
|
72 | |||
73 | qreal sum() const; |
|
73 | qreal sum() const; | |
74 |
|
74 | |||
75 | void setHoleSize(qreal holeSize); |
|
75 | void setHoleSize(qreal holeSize); | |
76 | qreal holeSize() const; |
|
76 | qreal holeSize() const; | |
77 |
|
77 | |||
78 | void setHorizontalPosition(qreal relativePosition); |
|
78 | void setHorizontalPosition(qreal relativePosition); | |
79 | qreal horizontalPosition() const; |
|
79 | qreal horizontalPosition() const; | |
80 |
|
80 | |||
81 | void setVerticalPosition(qreal relativePosition); |
|
81 | void setVerticalPosition(qreal relativePosition); | |
82 | qreal verticalPosition() const; |
|
82 | qreal verticalPosition() const; | |
83 |
|
83 | |||
84 | void setPieSize(qreal relativeSize); |
|
84 | void setPieSize(qreal relativeSize); | |
85 | qreal pieSize() const; |
|
85 | qreal pieSize() const; | |
86 |
|
86 | |||
87 | void setPieStartAngle(qreal startAngle); |
|
87 | void setPieStartAngle(qreal startAngle); | |
88 | qreal pieStartAngle() const; |
|
88 | qreal pieStartAngle() const; | |
89 |
|
89 | |||
90 | void setPieEndAngle(qreal endAngle); |
|
90 | void setPieEndAngle(qreal endAngle); | |
91 | qreal pieEndAngle() const; |
|
91 | qreal pieEndAngle() const; | |
92 |
|
92 | |||
93 | void setLabelsVisible(bool visible = true); |
|
93 | void setLabelsVisible(bool visible = true); | |
94 | void setLabelsPosition(QPieSlice::LabelPosition position); |
|
94 | void setLabelsPosition(QPieSlice::LabelPosition position); | |
95 |
|
95 | |||
96 | Q_SIGNALS: |
|
96 | Q_SIGNALS: | |
97 | void added(QList<QPieSlice *> slices); |
|
97 | void added(QList<QPieSlice *> slices); | |
98 | void removed(QList<QPieSlice *> slices); |
|
98 | void removed(QList<QPieSlice *> slices); | |
99 | void clicked(QPieSlice *slice); |
|
99 | void clicked(QPieSlice *slice); | |
100 | void hovered(QPieSlice *slice, bool state); |
|
100 | void hovered(QPieSlice *slice, bool state); | |
101 | void pressed(QPieSlice *slice); |
|
101 | void pressed(QPieSlice *slice); | |
102 | void released(QPieSlice *slice); |
|
102 | void released(QPieSlice *slice); | |
103 | void doubleClicked(QPieSlice *slice); |
|
103 | void doubleClicked(QPieSlice *slice); | |
104 | void countChanged(); |
|
104 | void countChanged(); | |
105 | void sumChanged(); |
|
105 | void sumChanged(); | |
106 |
|
106 | |||
107 | private: |
|
107 | private: | |
108 | Q_DECLARE_PRIVATE(QPieSeries) |
|
108 | Q_DECLARE_PRIVATE(QPieSeries) | |
109 | Q_DISABLE_COPY(QPieSeries) |
|
109 | Q_DISABLE_COPY(QPieSeries) | |
110 | friend class PieChartItem; |
|
110 | friend class PieChartItem; | |
111 | }; |
|
111 | }; | |
112 |
|
112 | |||
113 | QT_CHARTS_END_NAMESPACE |
|
113 | QT_CHARTS_END_NAMESPACE | |
114 |
|
114 | |||
115 | #endif // QPIESERIES_H |
|
115 | #endif // QPIESERIES_H |
@@ -1,159 +1,159 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QPIESLICE_H |
|
30 | #ifndef QPIESLICE_H | |
31 | #define QPIESLICE_H |
|
31 | #define QPIESLICE_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCore/QObject> |
|
34 | #include <QtCore/QObject> | |
35 | #include <QtGui/QPen> |
|
35 | #include <QtGui/QPen> | |
36 | #include <QtGui/QBrush> |
|
36 | #include <QtGui/QBrush> | |
37 | #include <QtGui/QFont> |
|
37 | #include <QtGui/QFont> | |
38 |
|
38 | |||
39 | QT_CHARTS_BEGIN_NAMESPACE |
|
39 | QT_CHARTS_BEGIN_NAMESPACE | |
40 | class QPieSlicePrivate; |
|
40 | class QPieSlicePrivate; | |
41 | class QPieSeries; |
|
41 | class QPieSeries; | |
42 |
|
42 | |||
43 | class QT_CHARTS_EXPORT QPieSlice : public QObject |
|
43 | class QT_CHARTS_EXPORT QPieSlice : public QObject | |
44 | { |
|
44 | { | |
45 | Q_OBJECT |
|
45 | Q_OBJECT | |
46 | Q_ENUMS(LabelPosition) |
|
46 | Q_ENUMS(LabelPosition) | |
47 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
|
47 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) | |
48 | Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) |
|
48 | Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) | |
49 | Q_PROPERTY(bool labelVisible READ isLabelVisible WRITE setLabelVisible NOTIFY labelVisibleChanged) |
|
49 | Q_PROPERTY(bool labelVisible READ isLabelVisible WRITE setLabelVisible NOTIFY labelVisibleChanged) | |
50 | Q_PROPERTY(LabelPosition labelPosition READ labelPosition WRITE setLabelPosition) |
|
50 | Q_PROPERTY(LabelPosition labelPosition READ labelPosition WRITE setLabelPosition) | |
51 | Q_PROPERTY(bool exploded READ isExploded WRITE setExploded) |
|
51 | Q_PROPERTY(bool exploded READ isExploded WRITE setExploded) | |
52 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
52 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
53 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
53 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
54 | Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged) |
|
54 | Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged) | |
55 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
|
55 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |
56 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
56 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
57 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) |
|
57 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) | |
58 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) |
|
58 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) | |
59 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) |
|
59 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) | |
60 | Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor) |
|
60 | Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor) | |
61 | Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor) |
|
61 | Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor) | |
62 | Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged) |
|
62 | Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged) | |
63 | Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged) |
|
63 | Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged) | |
64 | Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged) |
|
64 | Q_PROPERTY(qreal angleSpan READ angleSpan NOTIFY angleSpanChanged) | |
65 |
|
65 | |||
66 | public: |
|
66 | public: | |
67 | enum LabelPosition { |
|
67 | enum LabelPosition { | |
68 | LabelOutside, |
|
68 | LabelOutside, | |
69 | LabelInsideHorizontal, |
|
69 | LabelInsideHorizontal, | |
70 | LabelInsideTangential, |
|
70 | LabelInsideTangential, | |
71 | LabelInsideNormal |
|
71 | LabelInsideNormal | |
72 | }; |
|
72 | }; | |
73 |
|
73 | |||
74 | public: |
|
74 | public: | |
75 |
explicit QPieSlice(QObject *parent = |
|
75 | explicit QPieSlice(QObject *parent = Q_NULLPTR); | |
76 |
QPieSlice(QString label, qreal value, QObject *parent = |
|
76 | QPieSlice(QString label, qreal value, QObject *parent = Q_NULLPTR); | |
77 | virtual ~QPieSlice(); |
|
77 | virtual ~QPieSlice(); | |
78 |
|
78 | |||
79 | void setLabel(QString label); |
|
79 | void setLabel(QString label); | |
80 | QString label() const; |
|
80 | QString label() const; | |
81 |
|
81 | |||
82 | void setValue(qreal value); |
|
82 | void setValue(qreal value); | |
83 | qreal value() const; |
|
83 | qreal value() const; | |
84 |
|
84 | |||
85 | void setLabelVisible(bool visible = true); |
|
85 | void setLabelVisible(bool visible = true); | |
86 | bool isLabelVisible() const; |
|
86 | bool isLabelVisible() const; | |
87 |
|
87 | |||
88 | LabelPosition labelPosition(); |
|
88 | LabelPosition labelPosition(); | |
89 | void setLabelPosition(LabelPosition position); |
|
89 | void setLabelPosition(LabelPosition position); | |
90 |
|
90 | |||
91 | void setExploded(bool exploded = true); |
|
91 | void setExploded(bool exploded = true); | |
92 | bool isExploded() const; |
|
92 | bool isExploded() const; | |
93 |
|
93 | |||
94 | void setPen(const QPen &pen); |
|
94 | void setPen(const QPen &pen); | |
95 | QPen pen() const; |
|
95 | QPen pen() const; | |
96 |
|
96 | |||
97 | QColor borderColor(); |
|
97 | QColor borderColor(); | |
98 | void setBorderColor(QColor color); |
|
98 | void setBorderColor(QColor color); | |
99 |
|
99 | |||
100 | int borderWidth(); |
|
100 | int borderWidth(); | |
101 | void setBorderWidth(int width); |
|
101 | void setBorderWidth(int width); | |
102 |
|
102 | |||
103 | void setBrush(const QBrush &brush); |
|
103 | void setBrush(const QBrush &brush); | |
104 | QBrush brush() const; |
|
104 | QBrush brush() const; | |
105 |
|
105 | |||
106 | QColor color(); |
|
106 | QColor color(); | |
107 | void setColor(QColor color); |
|
107 | void setColor(QColor color); | |
108 |
|
108 | |||
109 | void setLabelBrush(const QBrush &brush); |
|
109 | void setLabelBrush(const QBrush &brush); | |
110 | QBrush labelBrush() const; |
|
110 | QBrush labelBrush() const; | |
111 |
|
111 | |||
112 | QColor labelColor(); |
|
112 | QColor labelColor(); | |
113 | void setLabelColor(QColor color); |
|
113 | void setLabelColor(QColor color); | |
114 |
|
114 | |||
115 | void setLabelFont(const QFont &font); |
|
115 | void setLabelFont(const QFont &font); | |
116 | QFont labelFont() const; |
|
116 | QFont labelFont() const; | |
117 |
|
117 | |||
118 | void setLabelArmLengthFactor(qreal factor); |
|
118 | void setLabelArmLengthFactor(qreal factor); | |
119 | qreal labelArmLengthFactor() const; |
|
119 | qreal labelArmLengthFactor() const; | |
120 |
|
120 | |||
121 | void setExplodeDistanceFactor(qreal factor); |
|
121 | void setExplodeDistanceFactor(qreal factor); | |
122 | qreal explodeDistanceFactor() const; |
|
122 | qreal explodeDistanceFactor() const; | |
123 |
|
123 | |||
124 | qreal percentage() const; |
|
124 | qreal percentage() const; | |
125 | qreal startAngle() const; |
|
125 | qreal startAngle() const; | |
126 | qreal angleSpan() const; |
|
126 | qreal angleSpan() const; | |
127 |
|
127 | |||
128 | QPieSeries *series() const; |
|
128 | QPieSeries *series() const; | |
129 |
|
129 | |||
130 | Q_SIGNALS: |
|
130 | Q_SIGNALS: | |
131 | void clicked(); |
|
131 | void clicked(); | |
132 | void hovered(bool state); |
|
132 | void hovered(bool state); | |
133 | void pressed(); |
|
133 | void pressed(); | |
134 | void released(); |
|
134 | void released(); | |
135 | void doubleClicked(); |
|
135 | void doubleClicked(); | |
136 | void labelChanged(); |
|
136 | void labelChanged(); | |
137 | void valueChanged(); |
|
137 | void valueChanged(); | |
138 | void labelVisibleChanged(); |
|
138 | void labelVisibleChanged(); | |
139 | void penChanged(); |
|
139 | void penChanged(); | |
140 | void brushChanged(); |
|
140 | void brushChanged(); | |
141 | void labelBrushChanged(); |
|
141 | void labelBrushChanged(); | |
142 | void labelFontChanged(); |
|
142 | void labelFontChanged(); | |
143 | void percentageChanged(); |
|
143 | void percentageChanged(); | |
144 | void startAngleChanged(); |
|
144 | void startAngleChanged(); | |
145 | void angleSpanChanged(); |
|
145 | void angleSpanChanged(); | |
146 | void colorChanged(); |
|
146 | void colorChanged(); | |
147 | void borderColorChanged(); |
|
147 | void borderColorChanged(); | |
148 | void borderWidthChanged(); |
|
148 | void borderWidthChanged(); | |
149 | void labelColorChanged(); |
|
149 | void labelColorChanged(); | |
150 |
|
150 | |||
151 | private: |
|
151 | private: | |
152 | QPieSlicePrivate * const d_ptr; |
|
152 | QPieSlicePrivate * const d_ptr; | |
153 | Q_DECLARE_PRIVATE(QPieSlice) |
|
153 | Q_DECLARE_PRIVATE(QPieSlice) | |
154 | Q_DISABLE_COPY(QPieSlice) |
|
154 | Q_DISABLE_COPY(QPieSlice) | |
155 | }; |
|
155 | }; | |
156 |
|
156 | |||
157 | QT_CHARTS_END_NAMESPACE |
|
157 | QT_CHARTS_END_NAMESPACE | |
158 |
|
158 | |||
159 | #endif // QPIESLICE_H |
|
159 | #endif // QPIESLICE_H |
@@ -1,79 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QVPIEMODELMAPPER_H |
|
30 | #ifndef QVPIEMODELMAPPER_H | |
31 | #define QVPIEMODELMAPPER_H |
|
31 | #define QVPIEMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QPieModelMapper> |
|
33 | #include <QtCharts/QPieModelMapper> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ |
|
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ | |
37 | class QT_CHARTS_EXPORT QVPieModelMapper : public QPieModelMapper |
|
37 | class QT_CHARTS_EXPORT QVPieModelMapper : public QPieModelMapper | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | Q_PROPERTY(QPieSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) |
|
40 | Q_PROPERTY(QPieSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) | |
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) |
|
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) | |
42 | Q_PROPERTY(int valuesColumn READ valuesColumn WRITE setValuesColumn NOTIFY valuesColumnChanged) |
|
42 | Q_PROPERTY(int valuesColumn READ valuesColumn WRITE setValuesColumn NOTIFY valuesColumnChanged) | |
43 | Q_PROPERTY(int labelsColumn READ labelsColumn WRITE setLabelsColumn NOTIFY labelsColumnChanged) |
|
43 | Q_PROPERTY(int labelsColumn READ labelsColumn WRITE setLabelsColumn NOTIFY labelsColumnChanged) | |
44 | Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged) |
|
44 | Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged) | |
45 | Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) |
|
45 | Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 |
explicit QVPieModelMapper(QObject *parent = |
|
48 | explicit QVPieModelMapper(QObject *parent = Q_NULLPTR); | |
49 |
|
49 | |||
50 | QAbstractItemModel *model() const; |
|
50 | QAbstractItemModel *model() const; | |
51 | void setModel(QAbstractItemModel *model); |
|
51 | void setModel(QAbstractItemModel *model); | |
52 |
|
52 | |||
53 | QPieSeries *series() const; |
|
53 | QPieSeries *series() const; | |
54 | void setSeries(QPieSeries *series); |
|
54 | void setSeries(QPieSeries *series); | |
55 |
|
55 | |||
56 | int valuesColumn() const; |
|
56 | int valuesColumn() const; | |
57 | void setValuesColumn(int valuesColumn); |
|
57 | void setValuesColumn(int valuesColumn); | |
58 |
|
58 | |||
59 | int labelsColumn() const; |
|
59 | int labelsColumn() const; | |
60 | void setLabelsColumn(int labelsColumn); |
|
60 | void setLabelsColumn(int labelsColumn); | |
61 |
|
61 | |||
62 | int firstRow() const; |
|
62 | int firstRow() const; | |
63 | void setFirstRow(int firstRow); |
|
63 | void setFirstRow(int firstRow); | |
64 |
|
64 | |||
65 | int rowCount() const; |
|
65 | int rowCount() const; | |
66 | void setRowCount(int rowCount); |
|
66 | void setRowCount(int rowCount); | |
67 |
|
67 | |||
68 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
69 | void seriesReplaced(); |
|
69 | void seriesReplaced(); | |
70 | void modelReplaced(); |
|
70 | void modelReplaced(); | |
71 | void valuesColumnChanged(); |
|
71 | void valuesColumnChanged(); | |
72 | void labelsColumnChanged(); |
|
72 | void labelsColumnChanged(); | |
73 | void firstRowChanged(); |
|
73 | void firstRowChanged(); | |
74 | void rowCountChanged(); |
|
74 | void rowCountChanged(); | |
75 | }; |
|
75 | }; | |
76 |
|
76 | |||
77 | QT_CHARTS_END_NAMESPACE |
|
77 | QT_CHARTS_END_NAMESPACE | |
78 |
|
78 | |||
79 | #endif // QVPIEMODELMAPPER_H |
|
79 | #endif // QVPIEMODELMAPPER_H |
@@ -1,112 +1,112 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QABSTRACTSERIES_H |
|
30 | #ifndef QABSTRACTSERIES_H | |
31 | #define QABSTRACTSERIES_H |
|
31 | #define QABSTRACTSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/QAbstractAxis> |
|
34 | #include <QtCharts/QAbstractAxis> | |
35 | #include <QtCore/QObject> |
|
35 | #include <QtCore/QObject> | |
36 | #include <QtGui/QPen> |
|
36 | #include <QtGui/QPen> | |
37 |
|
37 | |||
38 | QT_CHARTS_BEGIN_NAMESPACE |
|
38 | QT_CHARTS_BEGIN_NAMESPACE | |
39 |
|
39 | |||
40 | class QAbstractSeriesPrivate; |
|
40 | class QAbstractSeriesPrivate; | |
41 | class QChart; |
|
41 | class QChart; | |
42 |
|
42 | |||
43 | class QT_CHARTS_EXPORT QAbstractSeries : public QObject |
|
43 | class QT_CHARTS_EXPORT QAbstractSeries : public QObject | |
44 | { |
|
44 | { | |
45 | Q_OBJECT |
|
45 | Q_OBJECT | |
46 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) |
|
46 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) | |
47 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
|
47 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) | |
48 | Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) |
|
48 | Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) | |
49 | Q_PROPERTY(SeriesType type READ type) |
|
49 | Q_PROPERTY(SeriesType type READ type) | |
50 | Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL NOTIFY useOpenGLChanged) |
|
50 | Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL NOTIFY useOpenGLChanged) | |
51 | Q_ENUMS(SeriesType) |
|
51 | Q_ENUMS(SeriesType) | |
52 |
|
52 | |||
53 | public: |
|
53 | public: | |
54 | enum SeriesType { |
|
54 | enum SeriesType { | |
55 | SeriesTypeLine, |
|
55 | SeriesTypeLine, | |
56 | SeriesTypeArea, |
|
56 | SeriesTypeArea, | |
57 | SeriesTypeBar, |
|
57 | SeriesTypeBar, | |
58 | SeriesTypeStackedBar, |
|
58 | SeriesTypeStackedBar, | |
59 | SeriesTypePercentBar, |
|
59 | SeriesTypePercentBar, | |
60 | SeriesTypePie, |
|
60 | SeriesTypePie, | |
61 | SeriesTypeScatter, |
|
61 | SeriesTypeScatter, | |
62 | SeriesTypeSpline, |
|
62 | SeriesTypeSpline, | |
63 | SeriesTypeHorizontalBar, |
|
63 | SeriesTypeHorizontalBar, | |
64 | SeriesTypeHorizontalStackedBar, |
|
64 | SeriesTypeHorizontalStackedBar, | |
65 | SeriesTypeHorizontalPercentBar, |
|
65 | SeriesTypeHorizontalPercentBar, | |
66 | SeriesTypeBoxPlot |
|
66 | SeriesTypeBoxPlot | |
67 | }; |
|
67 | }; | |
68 |
|
68 | |||
69 | protected: |
|
69 | protected: | |
70 |
QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent = |
|
70 | QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent = Q_NULLPTR); | |
71 |
|
71 | |||
72 | public: |
|
72 | public: | |
73 | ~QAbstractSeries(); |
|
73 | ~QAbstractSeries(); | |
74 | virtual SeriesType type() const = 0; |
|
74 | virtual SeriesType type() const = 0; | |
75 |
|
75 | |||
76 | void setName(const QString &name); |
|
76 | void setName(const QString &name); | |
77 | QString name() const; |
|
77 | QString name() const; | |
78 | void setVisible(bool visible = true); |
|
78 | void setVisible(bool visible = true); | |
79 | bool isVisible() const; |
|
79 | bool isVisible() const; | |
80 | qreal opacity() const; |
|
80 | qreal opacity() const; | |
81 | void setOpacity(qreal opacity); |
|
81 | void setOpacity(qreal opacity); | |
82 | void setUseOpenGL(bool enable = true); |
|
82 | void setUseOpenGL(bool enable = true); | |
83 | bool useOpenGL() const; |
|
83 | bool useOpenGL() const; | |
84 |
|
84 | |||
85 | QChart *chart() const; |
|
85 | QChart *chart() const; | |
86 |
|
86 | |||
87 | bool attachAxis(QAbstractAxis *axis); |
|
87 | bool attachAxis(QAbstractAxis *axis); | |
88 | bool detachAxis(QAbstractAxis *axis); |
|
88 | bool detachAxis(QAbstractAxis *axis); | |
89 | QList<QAbstractAxis*> attachedAxes(); |
|
89 | QList<QAbstractAxis*> attachedAxes(); | |
90 |
|
90 | |||
91 | void show(); |
|
91 | void show(); | |
92 | void hide(); |
|
92 | void hide(); | |
93 |
|
93 | |||
94 | Q_SIGNALS: |
|
94 | Q_SIGNALS: | |
95 | void nameChanged(); |
|
95 | void nameChanged(); | |
96 | void visibleChanged(); |
|
96 | void visibleChanged(); | |
97 | void opacityChanged(); |
|
97 | void opacityChanged(); | |
98 | void useOpenGLChanged(); |
|
98 | void useOpenGLChanged(); | |
99 |
|
99 | |||
100 | protected: |
|
100 | protected: | |
101 | QScopedPointer<QAbstractSeriesPrivate> d_ptr; |
|
101 | QScopedPointer<QAbstractSeriesPrivate> d_ptr; | |
102 | friend class ChartDataSet; |
|
102 | friend class ChartDataSet; | |
103 | friend class ChartPresenter; |
|
103 | friend class ChartPresenter; | |
104 | friend class ChartThemeManager; |
|
104 | friend class ChartThemeManager; | |
105 | friend class QLegendPrivate; |
|
105 | friend class QLegendPrivate; | |
106 | friend class DeclarativeChart; |
|
106 | friend class DeclarativeChart; | |
107 | friend class QAreaSeries; |
|
107 | friend class QAreaSeries; | |
108 | }; |
|
108 | }; | |
109 |
|
109 | |||
110 | QT_CHARTS_END_NAMESPACE |
|
110 | QT_CHARTS_END_NAMESPACE | |
111 |
|
111 | |||
112 | #endif // QABSTRACTSERIES_H |
|
112 | #endif // QABSTRACTSERIES_H |
@@ -1,203 +1,203 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QCHART_H |
|
30 | #ifndef QCHART_H | |
31 | #define QCHART_H |
|
31 | #define QCHART_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractSeries> |
|
33 | #include <QtCharts/QAbstractSeries> | |
34 | #include <QtCharts/QLegend> |
|
34 | #include <QtCharts/QLegend> | |
35 | #include <QtWidgets/QGraphicsWidget> |
|
35 | #include <QtWidgets/QGraphicsWidget> | |
36 | #include <QtCore/QMargins> |
|
36 | #include <QtCore/QMargins> | |
37 |
|
37 | |||
38 | QT_BEGIN_NAMESPACE |
|
38 | QT_BEGIN_NAMESPACE | |
39 | class QGraphicsSceneResizeEvent; |
|
39 | class QGraphicsSceneResizeEvent; | |
40 | QT_END_NAMESPACE |
|
40 | QT_END_NAMESPACE | |
41 |
|
41 | |||
42 | QT_CHARTS_BEGIN_NAMESPACE |
|
42 | QT_CHARTS_BEGIN_NAMESPACE | |
43 |
|
43 | |||
44 | class QAbstractSeries; |
|
44 | class QAbstractSeries; | |
45 | class QAbstractAxis; |
|
45 | class QAbstractAxis; | |
46 | class QLegend; |
|
46 | class QLegend; | |
47 | class QChartPrivate; |
|
47 | class QChartPrivate; | |
48 | class QBoxPlotSeries; |
|
48 | class QBoxPlotSeries; | |
49 |
|
49 | |||
50 | class QT_CHARTS_EXPORT QChart : public QGraphicsWidget |
|
50 | class QT_CHARTS_EXPORT QChart : public QGraphicsWidget | |
51 | { |
|
51 | { | |
52 | Q_OBJECT |
|
52 | Q_OBJECT | |
53 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) |
|
53 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) | |
54 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
54 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
55 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) |
|
55 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) | |
56 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) |
|
56 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) | |
57 | Q_PROPERTY(qreal backgroundRoundness READ backgroundRoundness WRITE setBackgroundRoundness) |
|
57 | Q_PROPERTY(qreal backgroundRoundness READ backgroundRoundness WRITE setBackgroundRoundness) | |
58 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) |
|
58 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) | |
59 | Q_PROPERTY(int animationDuration READ animationDuration WRITE setAnimationDuration) |
|
59 | Q_PROPERTY(int animationDuration READ animationDuration WRITE setAnimationDuration) | |
60 | Q_PROPERTY(QEasingCurve animationEasingCurve READ animationEasingCurve WRITE setAnimationEasingCurve) |
|
60 | Q_PROPERTY(QEasingCurve animationEasingCurve READ animationEasingCurve WRITE setAnimationEasingCurve) | |
61 | Q_PROPERTY(QMargins margins READ margins WRITE setMargins) |
|
61 | Q_PROPERTY(QMargins margins READ margins WRITE setMargins) | |
62 | Q_PROPERTY(QChart::ChartType chartType READ chartType) |
|
62 | Q_PROPERTY(QChart::ChartType chartType READ chartType) | |
63 | Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible) |
|
63 | Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible) | |
64 | Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers) |
|
64 | Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers) | |
65 | Q_PROPERTY(QLocale locale READ locale WRITE setLocale) |
|
65 | Q_PROPERTY(QLocale locale READ locale WRITE setLocale) | |
66 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged) |
|
66 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged) | |
67 | Q_ENUMS(ChartTheme) |
|
67 | Q_ENUMS(ChartTheme) | |
68 | Q_ENUMS(AnimationOption) |
|
68 | Q_ENUMS(AnimationOption) | |
69 | Q_ENUMS(ChartType) |
|
69 | Q_ENUMS(ChartType) | |
70 |
|
70 | |||
71 | public: |
|
71 | public: | |
72 | enum ChartType { |
|
72 | enum ChartType { | |
73 | ChartTypeUndefined = 0, |
|
73 | ChartTypeUndefined = 0, | |
74 | ChartTypeCartesian, |
|
74 | ChartTypeCartesian, | |
75 | ChartTypePolar |
|
75 | ChartTypePolar | |
76 | }; |
|
76 | }; | |
77 |
|
77 | |||
78 | enum ChartTheme { |
|
78 | enum ChartTheme { | |
79 | ChartThemeLight = 0, |
|
79 | ChartThemeLight = 0, | |
80 | ChartThemeBlueCerulean, |
|
80 | ChartThemeBlueCerulean, | |
81 | ChartThemeDark, |
|
81 | ChartThemeDark, | |
82 | ChartThemeBrownSand, |
|
82 | ChartThemeBrownSand, | |
83 | ChartThemeBlueNcs, |
|
83 | ChartThemeBlueNcs, | |
84 | ChartThemeHighContrast, |
|
84 | ChartThemeHighContrast, | |
85 | ChartThemeBlueIcy, |
|
85 | ChartThemeBlueIcy, | |
86 | ChartThemeQt |
|
86 | ChartThemeQt | |
87 | }; |
|
87 | }; | |
88 |
|
88 | |||
89 | enum AnimationOption { |
|
89 | enum AnimationOption { | |
90 | NoAnimation = 0x0, |
|
90 | NoAnimation = 0x0, | |
91 | GridAxisAnimations = 0x1, |
|
91 | GridAxisAnimations = 0x1, | |
92 | SeriesAnimations = 0x2, |
|
92 | SeriesAnimations = 0x2, | |
93 | AllAnimations = 0x3 |
|
93 | AllAnimations = 0x3 | |
94 | }; |
|
94 | }; | |
95 |
|
95 | |||
96 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) |
|
96 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) | |
97 |
|
97 | |||
98 | public: |
|
98 | public: | |
99 |
explicit QChart(QGraphicsItem *parent = |
|
99 | explicit QChart(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags()); | |
100 | ~QChart(); |
|
100 | ~QChart(); | |
101 |
|
101 | |||
102 | void addSeries(QAbstractSeries *series); |
|
102 | void addSeries(QAbstractSeries *series); | |
103 | void removeSeries(QAbstractSeries *series); |
|
103 | void removeSeries(QAbstractSeries *series); | |
104 | void removeAllSeries(); |
|
104 | void removeAllSeries(); | |
105 | QList<QAbstractSeries *> series() const; |
|
105 | QList<QAbstractSeries *> series() const; | |
106 |
|
106 | |||
107 | // *** deprecated *** |
|
107 | // *** deprecated *** | |
108 |
void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = |
|
108 | void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR); | |
109 |
void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = |
|
109 | void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = Q_NULLPTR); | |
110 |
QAbstractAxis *axisX(QAbstractSeries *series = |
|
110 | QAbstractAxis *axisX(QAbstractSeries *series = Q_NULLPTR) const; | |
111 |
QAbstractAxis *axisY(QAbstractSeries *series = |
|
111 | QAbstractAxis *axisY(QAbstractSeries *series = Q_NULLPTR) const; | |
112 | // ****************** |
|
112 | // ****************** | |
113 |
|
113 | |||
114 | void addAxis(QAbstractAxis *axis, Qt::Alignment alignment); |
|
114 | void addAxis(QAbstractAxis *axis, Qt::Alignment alignment); | |
115 | void removeAxis(QAbstractAxis *axis); |
|
115 | void removeAxis(QAbstractAxis *axis); | |
116 |
QList<QAbstractAxis*> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = |
|
116 | QList<QAbstractAxis*> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = Q_NULLPTR) const; | |
117 |
|
117 | |||
118 | void createDefaultAxes(); |
|
118 | void createDefaultAxes(); | |
119 |
|
119 | |||
120 | void setTheme(QChart::ChartTheme theme); |
|
120 | void setTheme(QChart::ChartTheme theme); | |
121 | QChart::ChartTheme theme() const; |
|
121 | QChart::ChartTheme theme() const; | |
122 |
|
122 | |||
123 | void setTitle(const QString &title); |
|
123 | void setTitle(const QString &title); | |
124 | QString title() const; |
|
124 | QString title() const; | |
125 | void setTitleFont(const QFont &font); |
|
125 | void setTitleFont(const QFont &font); | |
126 | QFont titleFont() const; |
|
126 | QFont titleFont() const; | |
127 | void setTitleBrush(const QBrush &brush); |
|
127 | void setTitleBrush(const QBrush &brush); | |
128 | QBrush titleBrush() const; |
|
128 | QBrush titleBrush() const; | |
129 |
|
129 | |||
130 | void setBackgroundBrush(const QBrush &brush); |
|
130 | void setBackgroundBrush(const QBrush &brush); | |
131 | QBrush backgroundBrush() const; |
|
131 | QBrush backgroundBrush() const; | |
132 | void setBackgroundPen(const QPen &pen); |
|
132 | void setBackgroundPen(const QPen &pen); | |
133 | QPen backgroundPen() const; |
|
133 | QPen backgroundPen() const; | |
134 | void setBackgroundVisible(bool visible = true); |
|
134 | void setBackgroundVisible(bool visible = true); | |
135 | bool isBackgroundVisible() const; |
|
135 | bool isBackgroundVisible() const; | |
136 |
|
136 | |||
137 | void setDropShadowEnabled(bool enabled = true); |
|
137 | void setDropShadowEnabled(bool enabled = true); | |
138 | bool isDropShadowEnabled() const; |
|
138 | bool isDropShadowEnabled() const; | |
139 | void setBackgroundRoundness(qreal diameter); |
|
139 | void setBackgroundRoundness(qreal diameter); | |
140 | qreal backgroundRoundness() const; |
|
140 | qreal backgroundRoundness() const; | |
141 |
|
141 | |||
142 | void setAnimationOptions(AnimationOptions options); |
|
142 | void setAnimationOptions(AnimationOptions options); | |
143 | AnimationOptions animationOptions() const; |
|
143 | AnimationOptions animationOptions() const; | |
144 | void setAnimationDuration(int msecs); |
|
144 | void setAnimationDuration(int msecs); | |
145 | int animationDuration() const; |
|
145 | int animationDuration() const; | |
146 | void setAnimationEasingCurve(const QEasingCurve &curve); |
|
146 | void setAnimationEasingCurve(const QEasingCurve &curve); | |
147 | QEasingCurve animationEasingCurve() const; |
|
147 | QEasingCurve animationEasingCurve() const; | |
148 |
|
148 | |||
149 | void zoomIn(); |
|
149 | void zoomIn(); | |
150 | void zoomOut(); |
|
150 | void zoomOut(); | |
151 |
|
151 | |||
152 | void zoomIn(const QRectF &rect); |
|
152 | void zoomIn(const QRectF &rect); | |
153 | void zoom(qreal factor); |
|
153 | void zoom(qreal factor); | |
154 | void zoomReset(); |
|
154 | void zoomReset(); | |
155 | bool isZoomed(); |
|
155 | bool isZoomed(); | |
156 |
|
156 | |||
157 | void scroll(qreal dx, qreal dy); |
|
157 | void scroll(qreal dx, qreal dy); | |
158 |
|
158 | |||
159 | QLegend *legend() const; |
|
159 | QLegend *legend() const; | |
160 |
|
160 | |||
161 | void setMargins(const QMargins &margins); |
|
161 | void setMargins(const QMargins &margins); | |
162 | QMargins margins() const; |
|
162 | QMargins margins() const; | |
163 |
|
163 | |||
164 | QRectF plotArea() const; |
|
164 | QRectF plotArea() const; | |
165 | void setPlotAreaBackgroundBrush(const QBrush &brush); |
|
165 | void setPlotAreaBackgroundBrush(const QBrush &brush); | |
166 | QBrush plotAreaBackgroundBrush() const; |
|
166 | QBrush plotAreaBackgroundBrush() const; | |
167 | void setPlotAreaBackgroundPen(const QPen &pen); |
|
167 | void setPlotAreaBackgroundPen(const QPen &pen); | |
168 | QPen plotAreaBackgroundPen() const; |
|
168 | QPen plotAreaBackgroundPen() const; | |
169 | void setPlotAreaBackgroundVisible(bool visible = true); |
|
169 | void setPlotAreaBackgroundVisible(bool visible = true); | |
170 | bool isPlotAreaBackgroundVisible() const; |
|
170 | bool isPlotAreaBackgroundVisible() const; | |
171 | void setLocalizeNumbers(bool localize); |
|
171 | void setLocalizeNumbers(bool localize); | |
172 | bool localizeNumbers() const; |
|
172 | bool localizeNumbers() const; | |
173 | void setLocale(const QLocale &locale); |
|
173 | void setLocale(const QLocale &locale); | |
174 | QLocale locale() const; |
|
174 | QLocale locale() const; | |
175 |
|
175 | |||
176 |
QPointF mapToValue(const QPointF &position, QAbstractSeries *series = |
|
176 | QPointF mapToValue(const QPointF &position, QAbstractSeries *series = Q_NULLPTR); | |
177 |
QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = |
|
177 | QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = Q_NULLPTR); | |
178 |
|
178 | |||
179 | ChartType chartType() const; |
|
179 | ChartType chartType() const; | |
180 |
|
180 | |||
181 | Q_SIGNALS: |
|
181 | Q_SIGNALS: | |
182 | void plotAreaChanged(const QRectF &plotArea); |
|
182 | void plotAreaChanged(const QRectF &plotArea); | |
183 |
|
183 | |||
184 | protected: |
|
184 | protected: | |
185 | explicit QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags); |
|
185 | explicit QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags); | |
186 | QScopedPointer<QChartPrivate> d_ptr; |
|
186 | QScopedPointer<QChartPrivate> d_ptr; | |
187 | friend class QLegend; |
|
187 | friend class QLegend; | |
188 | friend class DeclarativeChart; |
|
188 | friend class DeclarativeChart; | |
189 | friend class ChartDataSet; |
|
189 | friend class ChartDataSet; | |
190 | friend class ChartPresenter; |
|
190 | friend class ChartPresenter; | |
191 | friend class ChartThemeManager; |
|
191 | friend class ChartThemeManager; | |
192 | friend class QAbstractSeries; |
|
192 | friend class QAbstractSeries; | |
193 | friend class QBoxPlotSeriesPrivate; |
|
193 | friend class QBoxPlotSeriesPrivate; | |
194 |
|
194 | |||
195 | private: |
|
195 | private: | |
196 | Q_DISABLE_COPY(QChart) |
|
196 | Q_DISABLE_COPY(QChart) | |
197 | }; |
|
197 | }; | |
198 |
|
198 | |||
199 | QT_CHARTS_END_NAMESPACE |
|
199 | QT_CHARTS_END_NAMESPACE | |
200 |
|
200 | |||
201 | Q_DECLARE_OPERATORS_FOR_FLAGS(QT_CHARTS_NAMESPACE::QChart::AnimationOptions) |
|
201 | Q_DECLARE_OPERATORS_FOR_FLAGS(QT_CHARTS_NAMESPACE::QChart::AnimationOptions) | |
202 |
|
202 | |||
203 | #endif // QCHART_H |
|
203 | #endif // QCHART_H |
@@ -1,86 +1,86 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QCHARTVIEW_H |
|
30 | #ifndef QCHARTVIEW_H | |
31 | #define QCHARTVIEW_H |
|
31 | #define QCHARTVIEW_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QAbstractAxis> |
|
33 | #include <QtCharts/QAbstractAxis> | |
34 | #include <QtCharts/QAbstractSeries> |
|
34 | #include <QtCharts/QAbstractSeries> | |
35 | #include <QtCharts/QChart> |
|
35 | #include <QtCharts/QChart> | |
36 | #include <QtWidgets/QGraphicsView> |
|
36 | #include <QtWidgets/QGraphicsView> | |
37 |
|
37 | |||
38 | QT_BEGIN_NAMESPACE |
|
38 | QT_BEGIN_NAMESPACE | |
39 | class QGraphicsScene; |
|
39 | class QGraphicsScene; | |
40 | class QRubberBand; |
|
40 | class QRubberBand; | |
41 | QT_END_NAMESPACE |
|
41 | QT_END_NAMESPACE | |
42 |
|
42 | |||
43 | QT_CHARTS_BEGIN_NAMESPACE |
|
43 | QT_CHARTS_BEGIN_NAMESPACE | |
44 |
|
44 | |||
45 | class QChartViewPrivate; |
|
45 | class QChartViewPrivate; | |
46 |
|
46 | |||
47 | class QT_CHARTS_EXPORT QChartView : public QGraphicsView |
|
47 | class QT_CHARTS_EXPORT QChartView : public QGraphicsView | |
48 | { |
|
48 | { | |
49 | Q_OBJECT |
|
49 | Q_OBJECT | |
50 | Q_ENUMS(RubberBand) |
|
50 | Q_ENUMS(RubberBand) | |
51 | public: |
|
51 | public: | |
52 |
|
52 | |||
53 | enum RubberBand { |
|
53 | enum RubberBand { | |
54 | NoRubberBand = 0x0, |
|
54 | NoRubberBand = 0x0, | |
55 | VerticalRubberBand = 0x1, |
|
55 | VerticalRubberBand = 0x1, | |
56 | HorizontalRubberBand = 0x2, |
|
56 | HorizontalRubberBand = 0x2, | |
57 | RectangleRubberBand = 0x3 |
|
57 | RectangleRubberBand = 0x3 | |
58 | }; |
|
58 | }; | |
59 |
|
59 | |||
60 | Q_DECLARE_FLAGS(RubberBands, RubberBand) |
|
60 | Q_DECLARE_FLAGS(RubberBands, RubberBand) | |
61 |
|
61 | |||
62 |
explicit QChartView(QWidget *parent = |
|
62 | explicit QChartView(QWidget *parent = Q_NULLPTR); | |
63 |
explicit QChartView(QChart *chart, QWidget *parent = |
|
63 | explicit QChartView(QChart *chart, QWidget *parent = Q_NULLPTR); | |
64 | ~QChartView(); |
|
64 | ~QChartView(); | |
65 |
|
65 | |||
66 | void setRubberBand(const RubberBands &rubberBands); |
|
66 | void setRubberBand(const RubberBands &rubberBands); | |
67 | RubberBands rubberBand() const; |
|
67 | RubberBands rubberBand() const; | |
68 |
|
68 | |||
69 | QChart *chart() const; |
|
69 | QChart *chart() const; | |
70 | void setChart(QChart *chart); |
|
70 | void setChart(QChart *chart); | |
71 |
|
71 | |||
72 | protected: |
|
72 | protected: | |
73 | void resizeEvent(QResizeEvent *event); |
|
73 | void resizeEvent(QResizeEvent *event); | |
74 | void mousePressEvent(QMouseEvent *event); |
|
74 | void mousePressEvent(QMouseEvent *event); | |
75 | void mouseMoveEvent(QMouseEvent *event); |
|
75 | void mouseMoveEvent(QMouseEvent *event); | |
76 | void mouseReleaseEvent(QMouseEvent *event); |
|
76 | void mouseReleaseEvent(QMouseEvent *event); | |
77 |
|
77 | |||
78 | QScopedPointer<QChartViewPrivate> d_ptr; |
|
78 | QScopedPointer<QChartViewPrivate> d_ptr; | |
79 |
|
79 | |||
80 | private: |
|
80 | private: | |
81 | Q_DISABLE_COPY(QChartView) |
|
81 | Q_DISABLE_COPY(QChartView) | |
82 | }; |
|
82 | }; | |
83 |
|
83 | |||
84 | QT_CHARTS_END_NAMESPACE |
|
84 | QT_CHARTS_END_NAMESPACE | |
85 |
|
85 | |||
86 | #endif // QCHARTVIEW_H |
|
86 | #endif // QCHARTVIEW_H |
@@ -1,69 +1,69 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QPOLARCHART_H |
|
30 | #ifndef QPOLARCHART_H | |
31 | #define QPOLARCHART_H |
|
31 | #define QPOLARCHART_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChart> |
|
33 | #include <QtCharts/QChart> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QAbstractSeries; |
|
37 | class QAbstractSeries; | |
38 | class QAbstractAxis; |
|
38 | class QAbstractAxis; | |
39 |
|
39 | |||
40 | class QT_CHARTS_EXPORT QPolarChart : public QChart |
|
40 | class QT_CHARTS_EXPORT QPolarChart : public QChart | |
41 | { |
|
41 | { | |
42 | Q_OBJECT |
|
42 | Q_OBJECT | |
43 | Q_ENUMS(PolarOrientation) |
|
43 | Q_ENUMS(PolarOrientation) | |
44 | Q_FLAGS(PolarOrientations) |
|
44 | Q_FLAGS(PolarOrientations) | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 | enum PolarOrientation { |
|
47 | enum PolarOrientation { | |
48 | PolarOrientationRadial = 0x1, |
|
48 | PolarOrientationRadial = 0x1, | |
49 | PolarOrientationAngular = 0x2 |
|
49 | PolarOrientationAngular = 0x2 | |
50 | }; |
|
50 | }; | |
51 | Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation) |
|
51 | Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation) | |
52 |
|
52 | |||
53 | public: |
|
53 | public: | |
54 |
explicit QPolarChart(QGraphicsItem *parent = |
|
54 | explicit QPolarChart(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags()); | |
55 | ~QPolarChart(); |
|
55 | ~QPolarChart(); | |
56 |
|
56 | |||
57 | void addAxis(QAbstractAxis *axis, PolarOrientation polarOrientation); |
|
57 | void addAxis(QAbstractAxis *axis, PolarOrientation polarOrientation); | |
58 |
|
58 | |||
59 |
QList<QAbstractAxis*> axes(PolarOrientations polarOrientation = PolarOrientations(PolarOrientationRadial | PolarOrientationAngular), QAbstractSeries *series = |
|
59 | QList<QAbstractAxis*> axes(PolarOrientations polarOrientation = PolarOrientations(PolarOrientationRadial | PolarOrientationAngular), QAbstractSeries *series = Q_NULLPTR) const; | |
60 |
|
60 | |||
61 | static PolarOrientation axisPolarOrientation(QAbstractAxis *axis); |
|
61 | static PolarOrientation axisPolarOrientation(QAbstractAxis *axis); | |
62 |
|
62 | |||
63 | private: |
|
63 | private: | |
64 | Q_DISABLE_COPY(QPolarChart) |
|
64 | Q_DISABLE_COPY(QPolarChart) | |
65 | }; |
|
65 | }; | |
66 |
|
66 | |||
67 | QT_CHARTS_END_NAMESPACE |
|
67 | QT_CHARTS_END_NAMESPACE | |
68 |
|
68 | |||
69 | #endif // QCHART_H |
|
69 | #endif // QCHART_H |
@@ -1,86 +1,86 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QSCATTERSERIES_H |
|
30 | #ifndef QSCATTERSERIES_H | |
31 | #define QSCATTERSERIES_H |
|
31 | #define QSCATTERSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/qxyseries.h> |
|
34 | #include <QtCharts/qxyseries.h> | |
35 |
|
35 | |||
36 | QT_CHARTS_BEGIN_NAMESPACE |
|
36 | QT_CHARTS_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QScatterSeriesPrivate; |
|
38 | class QScatterSeriesPrivate; | |
39 |
|
39 | |||
40 | class QT_CHARTS_EXPORT QScatterSeries : public QXYSeries |
|
40 | class QT_CHARTS_EXPORT QScatterSeries : public QXYSeries | |
41 | { |
|
41 | { | |
42 | Q_OBJECT |
|
42 | Q_OBJECT | |
43 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
43 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
44 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
44 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
45 | Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape NOTIFY markerShapeChanged) |
|
45 | Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape NOTIFY markerShapeChanged) | |
46 | Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize NOTIFY markerSizeChanged) |
|
46 | Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize NOTIFY markerSizeChanged) | |
47 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush) |
|
47 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush) | |
48 | Q_ENUMS(MarkerShape) |
|
48 | Q_ENUMS(MarkerShape) | |
49 |
|
49 | |||
50 | public: |
|
50 | public: | |
51 | enum MarkerShape { |
|
51 | enum MarkerShape { | |
52 | MarkerShapeCircle, |
|
52 | MarkerShapeCircle, | |
53 | MarkerShapeRectangle |
|
53 | MarkerShapeRectangle | |
54 | }; |
|
54 | }; | |
55 |
|
55 | |||
56 | public: |
|
56 | public: | |
57 |
explicit QScatterSeries(QObject *parent = |
|
57 | explicit QScatterSeries(QObject *parent = Q_NULLPTR); | |
58 | ~QScatterSeries(); |
|
58 | ~QScatterSeries(); | |
59 | QAbstractSeries::SeriesType type() const; |
|
59 | QAbstractSeries::SeriesType type() const; | |
60 | void setPen(const QPen &pen); |
|
60 | void setPen(const QPen &pen); | |
61 | void setBrush(const QBrush &brush); |
|
61 | void setBrush(const QBrush &brush); | |
62 | QBrush brush() const; |
|
62 | QBrush brush() const; | |
63 | void setColor(const QColor &color); |
|
63 | void setColor(const QColor &color); | |
64 | QColor color() const; |
|
64 | QColor color() const; | |
65 | void setBorderColor(const QColor &color); |
|
65 | void setBorderColor(const QColor &color); | |
66 | QColor borderColor() const; |
|
66 | QColor borderColor() const; | |
67 | MarkerShape markerShape() const; |
|
67 | MarkerShape markerShape() const; | |
68 | void setMarkerShape(MarkerShape shape); |
|
68 | void setMarkerShape(MarkerShape shape); | |
69 | qreal markerSize() const; |
|
69 | qreal markerSize() const; | |
70 | void setMarkerSize(qreal size); |
|
70 | void setMarkerSize(qreal size); | |
71 |
|
71 | |||
72 | Q_SIGNALS: |
|
72 | Q_SIGNALS: | |
73 | void colorChanged(QColor color); |
|
73 | void colorChanged(QColor color); | |
74 | void borderColorChanged(QColor color); |
|
74 | void borderColorChanged(QColor color); | |
75 | void markerShapeChanged(MarkerShape shape); |
|
75 | void markerShapeChanged(MarkerShape shape); | |
76 | void markerSizeChanged(qreal size); |
|
76 | void markerSizeChanged(qreal size); | |
77 |
|
77 | |||
78 | private: |
|
78 | private: | |
79 | Q_DECLARE_PRIVATE(QScatterSeries) |
|
79 | Q_DECLARE_PRIVATE(QScatterSeries) | |
80 | Q_DISABLE_COPY(QScatterSeries) |
|
80 | Q_DISABLE_COPY(QScatterSeries) | |
81 | friend class ScatterChartItem; |
|
81 | friend class ScatterChartItem; | |
82 | }; |
|
82 | }; | |
83 |
|
83 | |||
84 | QT_CHARTS_END_NAMESPACE |
|
84 | QT_CHARTS_END_NAMESPACE | |
85 |
|
85 | |||
86 | #endif // QSCATTERSERIES_H |
|
86 | #endif // QSCATTERSERIES_H |
@@ -1,60 +1,60 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QSPLINESERIES_H |
|
30 | #ifndef QSPLINESERIES_H | |
31 | #define QSPLINESERIES_H |
|
31 | #define QSPLINESERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/qlineseries.h> |
|
34 | #include <QtCharts/qlineseries.h> | |
35 | #include <QtCore/QList> |
|
35 | #include <QtCore/QList> | |
36 | #include <QtCore/QPointF> |
|
36 | #include <QtCore/QPointF> | |
37 | #include <QtCore/QtGlobal> |
|
37 | #include <QtCore/QtGlobal> | |
38 |
|
38 | |||
39 | QT_CHARTS_BEGIN_NAMESPACE |
|
39 | QT_CHARTS_BEGIN_NAMESPACE | |
40 |
|
40 | |||
41 | class QSplineSeriesPrivate; |
|
41 | class QSplineSeriesPrivate; | |
42 |
|
42 | |||
43 | class QT_CHARTS_EXPORT QSplineSeries : public QLineSeries |
|
43 | class QT_CHARTS_EXPORT QSplineSeries : public QLineSeries | |
44 | { |
|
44 | { | |
45 | Q_OBJECT |
|
45 | Q_OBJECT | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 |
explicit QSplineSeries(QObject *parent = |
|
48 | explicit QSplineSeries(QObject *parent = Q_NULLPTR); | |
49 | ~QSplineSeries(); |
|
49 | ~QSplineSeries(); | |
50 | QAbstractSeries::SeriesType type() const; |
|
50 | QAbstractSeries::SeriesType type() const; | |
51 |
|
51 | |||
52 | private: |
|
52 | private: | |
53 | Q_DECLARE_PRIVATE(QSplineSeries) |
|
53 | Q_DECLARE_PRIVATE(QSplineSeries) | |
54 | Q_DISABLE_COPY(QSplineSeries) |
|
54 | Q_DISABLE_COPY(QSplineSeries) | |
55 | friend class SplineChartItem; |
|
55 | friend class SplineChartItem; | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QT_CHARTS_END_NAMESPACE |
|
58 | QT_CHARTS_END_NAMESPACE | |
59 |
|
59 | |||
60 | #endif // QSPLINESERIES_H |
|
60 | #endif // QSPLINESERIES_H |
@@ -1,79 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QHXYMODELMAPPER_H |
|
30 | #ifndef QHXYMODELMAPPER_H | |
31 | #define QHXYMODELMAPPER_H |
|
31 | #define QHXYMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QXYModelMapper> |
|
33 | #include <QtCharts/QXYModelMapper> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ |
|
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ | |
37 | class QT_CHARTS_EXPORT QHXYModelMapper : public QXYModelMapper |
|
37 | class QT_CHARTS_EXPORT QHXYModelMapper : public QXYModelMapper | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | Q_PROPERTY(QXYSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) |
|
40 | Q_PROPERTY(QXYSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) | |
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) |
|
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) | |
42 | Q_PROPERTY(int xRow READ xRow WRITE setXRow NOTIFY xRowChanged) |
|
42 | Q_PROPERTY(int xRow READ xRow WRITE setXRow NOTIFY xRowChanged) | |
43 | Q_PROPERTY(int yRow READ yRow WRITE setYRow NOTIFY yRowChanged) |
|
43 | Q_PROPERTY(int yRow READ yRow WRITE setYRow NOTIFY yRowChanged) | |
44 | Q_PROPERTY(int firstColumn READ firstColumn WRITE setFirstColumn NOTIFY firstColumnChanged) |
|
44 | Q_PROPERTY(int firstColumn READ firstColumn WRITE setFirstColumn NOTIFY firstColumnChanged) | |
45 | Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) |
|
45 | Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 |
explicit QHXYModelMapper(QObject *parent = |
|
48 | explicit QHXYModelMapper(QObject *parent = Q_NULLPTR); | |
49 |
|
49 | |||
50 | QAbstractItemModel *model() const; |
|
50 | QAbstractItemModel *model() const; | |
51 | void setModel(QAbstractItemModel *model); |
|
51 | void setModel(QAbstractItemModel *model); | |
52 |
|
52 | |||
53 | QXYSeries *series() const; |
|
53 | QXYSeries *series() const; | |
54 | void setSeries(QXYSeries *series); |
|
54 | void setSeries(QXYSeries *series); | |
55 |
|
55 | |||
56 | int xRow() const; |
|
56 | int xRow() const; | |
57 | void setXRow(int xRow); |
|
57 | void setXRow(int xRow); | |
58 |
|
58 | |||
59 | int yRow() const; |
|
59 | int yRow() const; | |
60 | void setYRow(int yRow); |
|
60 | void setYRow(int yRow); | |
61 |
|
61 | |||
62 | int firstColumn() const; |
|
62 | int firstColumn() const; | |
63 | void setFirstColumn(int firstColumn); |
|
63 | void setFirstColumn(int firstColumn); | |
64 |
|
64 | |||
65 | int columnCount() const; |
|
65 | int columnCount() const; | |
66 | void setColumnCount(int columnCount); |
|
66 | void setColumnCount(int columnCount); | |
67 |
|
67 | |||
68 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
69 | void seriesReplaced(); |
|
69 | void seriesReplaced(); | |
70 | void modelReplaced(); |
|
70 | void modelReplaced(); | |
71 | void xRowChanged(); |
|
71 | void xRowChanged(); | |
72 | void yRowChanged(); |
|
72 | void yRowChanged(); | |
73 | void firstColumnChanged(); |
|
73 | void firstColumnChanged(); | |
74 | void columnCountChanged(); |
|
74 | void columnCountChanged(); | |
75 | }; |
|
75 | }; | |
76 |
|
76 | |||
77 | QT_CHARTS_END_NAMESPACE |
|
77 | QT_CHARTS_END_NAMESPACE | |
78 |
|
78 | |||
79 | #endif // QHXYMODELMAPPER_H |
|
79 | #endif // QHXYMODELMAPPER_H |
@@ -1,79 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QVXYMODELMAPPER_H |
|
30 | #ifndef QVXYMODELMAPPER_H | |
31 | #define QVXYMODELMAPPER_H |
|
31 | #define QVXYMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QXYModelMapper> |
|
33 | #include <QtCharts/QXYModelMapper> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ |
|
36 | /* Comment line for syncqt to generate the fwd-include correctly, due to QTBUG-22432 */ | |
37 | class QT_CHARTS_EXPORT QVXYModelMapper : public QXYModelMapper |
|
37 | class QT_CHARTS_EXPORT QVXYModelMapper : public QXYModelMapper | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | Q_PROPERTY(QXYSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) |
|
40 | Q_PROPERTY(QXYSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) | |
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) |
|
41 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) | |
42 | Q_PROPERTY(int xColumn READ xColumn WRITE setXColumn NOTIFY xColumnChanged) |
|
42 | Q_PROPERTY(int xColumn READ xColumn WRITE setXColumn NOTIFY xColumnChanged) | |
43 | Q_PROPERTY(int yColumn READ yColumn WRITE setYColumn NOTIFY yColumnChanged) |
|
43 | Q_PROPERTY(int yColumn READ yColumn WRITE setYColumn NOTIFY yColumnChanged) | |
44 | Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged) |
|
44 | Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged) | |
45 | Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) |
|
45 | Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 |
explicit QVXYModelMapper(QObject *parent = |
|
48 | explicit QVXYModelMapper(QObject *parent = Q_NULLPTR); | |
49 |
|
49 | |||
50 | QAbstractItemModel *model() const; |
|
50 | QAbstractItemModel *model() const; | |
51 | void setModel(QAbstractItemModel *model); |
|
51 | void setModel(QAbstractItemModel *model); | |
52 |
|
52 | |||
53 | QXYSeries *series() const; |
|
53 | QXYSeries *series() const; | |
54 | void setSeries(QXYSeries *series); |
|
54 | void setSeries(QXYSeries *series); | |
55 |
|
55 | |||
56 | int xColumn() const; |
|
56 | int xColumn() const; | |
57 | void setXColumn(int xColumn); |
|
57 | void setXColumn(int xColumn); | |
58 |
|
58 | |||
59 | int yColumn() const; |
|
59 | int yColumn() const; | |
60 | void setYColumn(int yColumn); |
|
60 | void setYColumn(int yColumn); | |
61 |
|
61 | |||
62 | int firstRow() const; |
|
62 | int firstRow() const; | |
63 | void setFirstRow(int firstRow); |
|
63 | void setFirstRow(int firstRow); | |
64 |
|
64 | |||
65 | int rowCount() const; |
|
65 | int rowCount() const; | |
66 | void setRowCount(int rowCount); |
|
66 | void setRowCount(int rowCount); | |
67 |
|
67 | |||
68 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
69 | void seriesReplaced(); |
|
69 | void seriesReplaced(); | |
70 | void modelReplaced(); |
|
70 | void modelReplaced(); | |
71 | void xColumnChanged(); |
|
71 | void xColumnChanged(); | |
72 | void yColumnChanged(); |
|
72 | void yColumnChanged(); | |
73 | void firstRowChanged(); |
|
73 | void firstRowChanged(); | |
74 | void rowCountChanged(); |
|
74 | void rowCountChanged(); | |
75 | }; |
|
75 | }; | |
76 |
|
76 | |||
77 | QT_CHARTS_END_NAMESPACE |
|
77 | QT_CHARTS_END_NAMESPACE | |
78 |
|
78 | |||
79 | #endif // QVXYMODELMAPPER_H |
|
79 | #endif // QVXYMODELMAPPER_H |
@@ -1,80 +1,80 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QXYMODELMAPPER_H |
|
30 | #ifndef QXYMODELMAPPER_H | |
31 | #define QXYMODELMAPPER_H |
|
31 | #define QXYMODELMAPPER_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCore/QObject> |
|
34 | #include <QtCore/QObject> | |
35 |
|
35 | |||
36 | QT_BEGIN_NAMESPACE |
|
36 | QT_BEGIN_NAMESPACE | |
37 | class QAbstractItemModel; |
|
37 | class QAbstractItemModel; | |
38 | QT_END_NAMESPACE |
|
38 | QT_END_NAMESPACE | |
39 |
|
39 | |||
40 | QT_CHARTS_BEGIN_NAMESPACE |
|
40 | QT_CHARTS_BEGIN_NAMESPACE | |
41 |
|
41 | |||
42 | class QXYModelMapperPrivate; |
|
42 | class QXYModelMapperPrivate; | |
43 | class QXYSeries; |
|
43 | class QXYSeries; | |
44 |
|
44 | |||
45 | class QT_CHARTS_EXPORT QXYModelMapper : public QObject |
|
45 | class QT_CHARTS_EXPORT QXYModelMapper : public QObject | |
46 | { |
|
46 | { | |
47 | Q_OBJECT |
|
47 | Q_OBJECT | |
48 |
|
48 | |||
49 | protected: |
|
49 | protected: | |
50 |
explicit QXYModelMapper(QObject *parent = |
|
50 | explicit QXYModelMapper(QObject *parent = Q_NULLPTR); | |
51 |
|
51 | |||
52 | QAbstractItemModel *model() const; |
|
52 | QAbstractItemModel *model() const; | |
53 | void setModel(QAbstractItemModel *model); |
|
53 | void setModel(QAbstractItemModel *model); | |
54 |
|
54 | |||
55 | QXYSeries *series() const; |
|
55 | QXYSeries *series() const; | |
56 | void setSeries(QXYSeries *series); |
|
56 | void setSeries(QXYSeries *series); | |
57 |
|
57 | |||
58 | int first() const; |
|
58 | int first() const; | |
59 | void setFirst(int first); |
|
59 | void setFirst(int first); | |
60 |
|
60 | |||
61 | int count() const; |
|
61 | int count() const; | |
62 | void setCount(int count); |
|
62 | void setCount(int count); | |
63 |
|
63 | |||
64 | Qt::Orientation orientation() const; |
|
64 | Qt::Orientation orientation() const; | |
65 | void setOrientation(Qt::Orientation orientation); |
|
65 | void setOrientation(Qt::Orientation orientation); | |
66 |
|
66 | |||
67 | int xSection() const; |
|
67 | int xSection() const; | |
68 | void setXSection(int xSection); |
|
68 | void setXSection(int xSection); | |
69 |
|
69 | |||
70 | int ySection() const; |
|
70 | int ySection() const; | |
71 | void setYSection(int ySection); |
|
71 | void setYSection(int ySection); | |
72 |
|
72 | |||
73 | protected: |
|
73 | protected: | |
74 | QXYModelMapperPrivate *const d_ptr; |
|
74 | QXYModelMapperPrivate *const d_ptr; | |
75 | Q_DECLARE_PRIVATE(QXYModelMapper) |
|
75 | Q_DECLARE_PRIVATE(QXYModelMapper) | |
76 | }; |
|
76 | }; | |
77 |
|
77 | |||
78 | QT_CHARTS_END_NAMESPACE |
|
78 | QT_CHARTS_END_NAMESPACE | |
79 |
|
79 | |||
80 | #endif // QXYMODELMAPPER_H |
|
80 | #endif // QXYMODELMAPPER_H |
@@ -1,144 +1,144 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #ifndef QXYSERIES_H |
|
30 | #ifndef QXYSERIES_H | |
31 | #define QXYSERIES_H |
|
31 | #define QXYSERIES_H | |
32 |
|
32 | |||
33 | #include <QtCharts/QChartGlobal> |
|
33 | #include <QtCharts/QChartGlobal> | |
34 | #include <QtCharts/QAbstractSeries> |
|
34 | #include <QtCharts/QAbstractSeries> | |
35 | #include <QtGui/QPen> |
|
35 | #include <QtGui/QPen> | |
36 | #include <QtGui/QBrush> |
|
36 | #include <QtGui/QBrush> | |
37 |
|
37 | |||
38 | QT_BEGIN_NAMESPACE |
|
38 | QT_BEGIN_NAMESPACE | |
39 | class QModelIndex; |
|
39 | class QModelIndex; | |
40 | QT_END_NAMESPACE |
|
40 | QT_END_NAMESPACE | |
41 |
|
41 | |||
42 | QT_CHARTS_BEGIN_NAMESPACE |
|
42 | QT_CHARTS_BEGIN_NAMESPACE | |
43 |
|
43 | |||
44 | class QXYSeriesPrivate; |
|
44 | class QXYSeriesPrivate; | |
45 | class QXYModelMapper; |
|
45 | class QXYModelMapper; | |
46 |
|
46 | |||
47 | class QT_CHARTS_EXPORT QXYSeries : public QAbstractSeries |
|
47 | class QT_CHARTS_EXPORT QXYSeries : public QAbstractSeries | |
48 | { |
|
48 | { | |
49 | Q_OBJECT |
|
49 | Q_OBJECT | |
50 | Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) |
|
50 | Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) | |
51 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
51 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
52 | Q_PROPERTY(QString pointLabelsFormat READ pointLabelsFormat WRITE setPointLabelsFormat NOTIFY pointLabelsFormatChanged) |
|
52 | Q_PROPERTY(QString pointLabelsFormat READ pointLabelsFormat WRITE setPointLabelsFormat NOTIFY pointLabelsFormatChanged) | |
53 | Q_PROPERTY(bool pointLabelsVisible READ pointLabelsVisible WRITE setPointLabelsVisible NOTIFY pointLabelsVisibilityChanged) |
|
53 | Q_PROPERTY(bool pointLabelsVisible READ pointLabelsVisible WRITE setPointLabelsVisible NOTIFY pointLabelsVisibilityChanged) | |
54 | Q_PROPERTY(QFont pointLabelsFont READ pointLabelsFont WRITE setPointLabelsFont NOTIFY pointLabelsFontChanged) |
|
54 | Q_PROPERTY(QFont pointLabelsFont READ pointLabelsFont WRITE setPointLabelsFont NOTIFY pointLabelsFontChanged) | |
55 | Q_PROPERTY(QColor pointLabelsColor READ pointLabelsColor WRITE setPointLabelsColor NOTIFY pointLabelsColorChanged) |
|
55 | Q_PROPERTY(QColor pointLabelsColor READ pointLabelsColor WRITE setPointLabelsColor NOTIFY pointLabelsColorChanged) | |
56 | Q_PROPERTY(bool pointLabelsClipping READ pointLabelsClipping WRITE setPointLabelsClipping NOTIFY pointLabelsClippingChanged) |
|
56 | Q_PROPERTY(bool pointLabelsClipping READ pointLabelsClipping WRITE setPointLabelsClipping NOTIFY pointLabelsClippingChanged) | |
57 |
|
57 | |||
58 | protected: |
|
58 | protected: | |
59 |
explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = |
|
59 | explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = Q_NULLPTR); | |
60 |
|
60 | |||
61 | public: |
|
61 | public: | |
62 | ~QXYSeries(); |
|
62 | ~QXYSeries(); | |
63 | void append(qreal x, qreal y); |
|
63 | void append(qreal x, qreal y); | |
64 | void append(const QPointF &point); |
|
64 | void append(const QPointF &point); | |
65 | void append(const QList<QPointF> &points); |
|
65 | void append(const QList<QPointF> &points); | |
66 | void replace(qreal oldX, qreal oldY, qreal newX, qreal newY); |
|
66 | void replace(qreal oldX, qreal oldY, qreal newX, qreal newY); | |
67 | void replace(const QPointF &oldPoint, const QPointF &newPoint); |
|
67 | void replace(const QPointF &oldPoint, const QPointF &newPoint); | |
68 | void replace(int index, qreal newX, qreal newY); |
|
68 | void replace(int index, qreal newX, qreal newY); | |
69 | void replace(int index, const QPointF &newPoint); |
|
69 | void replace(int index, const QPointF &newPoint); | |
70 | void remove(qreal x, qreal y); |
|
70 | void remove(qreal x, qreal y); | |
71 | void remove(const QPointF &point); |
|
71 | void remove(const QPointF &point); | |
72 | void remove(int index); |
|
72 | void remove(int index); | |
73 | void removePoints(int index, int count); |
|
73 | void removePoints(int index, int count); | |
74 | void insert(int index, const QPointF &point); |
|
74 | void insert(int index, const QPointF &point); | |
75 | void clear(); |
|
75 | void clear(); | |
76 |
|
76 | |||
77 | int count() const; |
|
77 | int count() const; | |
78 | QList<QPointF> points() const; |
|
78 | QList<QPointF> points() const; | |
79 | QVector<QPointF> pointsVector() const; |
|
79 | QVector<QPointF> pointsVector() const; | |
80 | const QPointF &at(int index) const; |
|
80 | const QPointF &at(int index) const; | |
81 |
|
81 | |||
82 | QXYSeries &operator << (const QPointF &point); |
|
82 | QXYSeries &operator << (const QPointF &point); | |
83 | QXYSeries &operator << (const QList<QPointF> &points); |
|
83 | QXYSeries &operator << (const QList<QPointF> &points); | |
84 |
|
84 | |||
85 | virtual void setPen(const QPen &pen); |
|
85 | virtual void setPen(const QPen &pen); | |
86 | QPen pen() const; |
|
86 | QPen pen() const; | |
87 |
|
87 | |||
88 | virtual void setBrush(const QBrush &brush); |
|
88 | virtual void setBrush(const QBrush &brush); | |
89 | QBrush brush() const; |
|
89 | QBrush brush() const; | |
90 |
|
90 | |||
91 | virtual void setColor(const QColor &color); |
|
91 | virtual void setColor(const QColor &color); | |
92 | virtual QColor color() const; |
|
92 | virtual QColor color() const; | |
93 |
|
93 | |||
94 | void setPointsVisible(bool visible = true); |
|
94 | void setPointsVisible(bool visible = true); | |
95 | bool pointsVisible() const; |
|
95 | bool pointsVisible() const; | |
96 |
|
96 | |||
97 | void setPointLabelsFormat(const QString &format); |
|
97 | void setPointLabelsFormat(const QString &format); | |
98 | QString pointLabelsFormat() const; |
|
98 | QString pointLabelsFormat() const; | |
99 |
|
99 | |||
100 | void setPointLabelsVisible(bool visible = true); |
|
100 | void setPointLabelsVisible(bool visible = true); | |
101 | bool pointLabelsVisible() const; |
|
101 | bool pointLabelsVisible() const; | |
102 |
|
102 | |||
103 | void setPointLabelsFont(const QFont &font); |
|
103 | void setPointLabelsFont(const QFont &font); | |
104 | QFont pointLabelsFont() const; |
|
104 | QFont pointLabelsFont() const; | |
105 |
|
105 | |||
106 | void setPointLabelsColor(const QColor &color); |
|
106 | void setPointLabelsColor(const QColor &color); | |
107 | QColor pointLabelsColor() const; |
|
107 | QColor pointLabelsColor() const; | |
108 |
|
108 | |||
109 | void setPointLabelsClipping(bool enabled = true); |
|
109 | void setPointLabelsClipping(bool enabled = true); | |
110 | bool pointLabelsClipping() const; |
|
110 | bool pointLabelsClipping() const; | |
111 |
|
111 | |||
112 | void replace(QList<QPointF> points); |
|
112 | void replace(QList<QPointF> points); | |
113 | void replace(QVector<QPointF> points); |
|
113 | void replace(QVector<QPointF> points); | |
114 |
|
114 | |||
115 | Q_SIGNALS: |
|
115 | Q_SIGNALS: | |
116 | void clicked(const QPointF &point); |
|
116 | void clicked(const QPointF &point); | |
117 | void hovered(const QPointF &point, bool state); |
|
117 | void hovered(const QPointF &point, bool state); | |
118 | void pressed(const QPointF &point); |
|
118 | void pressed(const QPointF &point); | |
119 | void released(const QPointF &point); |
|
119 | void released(const QPointF &point); | |
120 | void doubleClicked(const QPointF &point); |
|
120 | void doubleClicked(const QPointF &point); | |
121 | void pointReplaced(int index); |
|
121 | void pointReplaced(int index); | |
122 | void pointRemoved(int index); |
|
122 | void pointRemoved(int index); | |
123 | void pointAdded(int index); |
|
123 | void pointAdded(int index); | |
124 | void colorChanged(QColor color); |
|
124 | void colorChanged(QColor color); | |
125 | void pointsReplaced(); |
|
125 | void pointsReplaced(); | |
126 | void pointLabelsFormatChanged(const QString &format); |
|
126 | void pointLabelsFormatChanged(const QString &format); | |
127 | void pointLabelsVisibilityChanged(bool visible); |
|
127 | void pointLabelsVisibilityChanged(bool visible); | |
128 | void pointLabelsFontChanged(const QFont &font); |
|
128 | void pointLabelsFontChanged(const QFont &font); | |
129 | void pointLabelsColorChanged(const QColor &color); |
|
129 | void pointLabelsColorChanged(const QColor &color); | |
130 | void pointLabelsClippingChanged(bool clipping); |
|
130 | void pointLabelsClippingChanged(bool clipping); | |
131 | void pointsRemoved(int index, int count); |
|
131 | void pointsRemoved(int index, int count); | |
132 | void penChanged(const QPen &pen); |
|
132 | void penChanged(const QPen &pen); | |
133 |
|
133 | |||
134 | private: |
|
134 | private: | |
135 | Q_DECLARE_PRIVATE(QXYSeries) |
|
135 | Q_DECLARE_PRIVATE(QXYSeries) | |
136 | Q_DISABLE_COPY(QXYSeries) |
|
136 | Q_DISABLE_COPY(QXYSeries) | |
137 | friend class QXYLegendMarkerPrivate; |
|
137 | friend class QXYLegendMarkerPrivate; | |
138 | friend class XYLegendMarker; |
|
138 | friend class XYLegendMarker; | |
139 | friend class XYChart; |
|
139 | friend class XYChart; | |
140 | }; |
|
140 | }; | |
141 |
|
141 | |||
142 | QT_CHARTS_END_NAMESPACE |
|
142 | QT_CHARTS_END_NAMESPACE | |
143 |
|
143 | |||
144 | #endif // QXYSERIES_H |
|
144 | #endif // QXYSERIES_H |
@@ -1,518 +1,518 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #include "declarativebarseries.h" |
|
30 | #include "declarativebarseries.h" | |
31 | #include <QtCharts/QBarSet> |
|
31 | #include <QtCharts/QBarSet> | |
32 | #include <QtCharts/QVBarModelMapper> |
|
32 | #include <QtCharts/QVBarModelMapper> | |
33 | #include <QtCharts/QHBarModelMapper> |
|
33 | #include <QtCharts/QHBarModelMapper> | |
34 |
|
34 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) |
|
37 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) | |
38 | : QBarSet("", parent) |
|
38 | : QBarSet("", parent) | |
39 | { |
|
39 | { | |
40 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int))); |
|
40 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int))); | |
41 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int))); |
|
41 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int))); | |
42 | connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); |
|
42 | connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | void DeclarativeBarSet::handleCountChanged(int index, int count) |
|
45 | void DeclarativeBarSet::handleCountChanged(int index, int count) | |
46 | { |
|
46 | { | |
47 | Q_UNUSED(index) |
|
47 | Q_UNUSED(index) | |
48 | Q_UNUSED(count) |
|
48 | Q_UNUSED(count) | |
49 | emit countChanged(QBarSet::count()); |
|
49 | emit countChanged(QBarSet::count()); | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | qreal DeclarativeBarSet::borderWidth() const |
|
52 | qreal DeclarativeBarSet::borderWidth() const | |
53 | { |
|
53 | { | |
54 | return pen().widthF(); |
|
54 | return pen().widthF(); | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | void DeclarativeBarSet::setBorderWidth(qreal width) |
|
57 | void DeclarativeBarSet::setBorderWidth(qreal width) | |
58 | { |
|
58 | { | |
59 | if (width != pen().widthF()) { |
|
59 | if (width != pen().widthF()) { | |
60 | QPen p = pen(); |
|
60 | QPen p = pen(); | |
61 | p.setWidthF(width); |
|
61 | p.setWidthF(width); | |
62 | setPen(p); |
|
62 | setPen(p); | |
63 | emit borderWidthChanged(width); |
|
63 | emit borderWidthChanged(width); | |
64 | } |
|
64 | } | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | QVariantList DeclarativeBarSet::values() |
|
67 | QVariantList DeclarativeBarSet::values() | |
68 | { |
|
68 | { | |
69 | QVariantList values; |
|
69 | QVariantList values; | |
70 | for (int i(0); i < count(); i++) |
|
70 | for (int i(0); i < count(); i++) | |
71 | values.append(QVariant(QBarSet::at(i))); |
|
71 | values.append(QVariant(QBarSet::at(i))); | |
72 | return values; |
|
72 | return values; | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | void DeclarativeBarSet::setValues(QVariantList values) |
|
75 | void DeclarativeBarSet::setValues(QVariantList values) | |
76 | { |
|
76 | { | |
77 | while (count()) |
|
77 | while (count()) | |
78 | remove(count() - 1); |
|
78 | remove(count() - 1); | |
79 |
|
79 | |||
80 | if (values.at(0).canConvert(QVariant::Point)) { |
|
80 | if (values.count() > 0 && values.at(0).canConvert(QVariant::Point)) { | |
81 | // Create list of values for appending if the first item is Qt.point |
|
81 | // Create list of values for appending if the first item is Qt.point | |
82 | int maxValue = 0; |
|
82 | int maxValue = 0; | |
83 | for (int i = 0; i < values.count(); i++) { |
|
83 | for (int i = 0; i < values.count(); i++) { | |
84 | if (values.at(i).canConvert(QVariant::Point) && |
|
84 | if (values.at(i).canConvert(QVariant::Point) && | |
85 | values.at(i).toPoint().x() > maxValue) { |
|
85 | values.at(i).toPoint().x() > maxValue) { | |
86 | maxValue = values.at(i).toPoint().x(); |
|
86 | maxValue = values.at(i).toPoint().x(); | |
87 | } |
|
87 | } | |
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | QVector<int> indexValueList; |
|
90 | QVector<int> indexValueList; | |
91 | indexValueList.resize(maxValue + 1); |
|
91 | indexValueList.resize(maxValue + 1); | |
92 |
|
92 | |||
93 | for (int i = 0; i < values.count(); i++) { |
|
93 | for (int i = 0; i < values.count(); i++) { | |
94 | if (values.at(i).canConvert(QVariant::Point)) { |
|
94 | if (values.at(i).canConvert(QVariant::Point)) { | |
95 | indexValueList.replace(values.at(i).toPoint().x(), values.at(i).toPoint().y()); |
|
95 | indexValueList.replace(values.at(i).toPoint().x(), values.at(i).toPoint().y()); | |
96 | } |
|
96 | } | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | for (int i = 0; i < indexValueList.count(); i++) |
|
99 | for (int i = 0; i < indexValueList.count(); i++) | |
100 | QBarSet::append(indexValueList.at(i)); |
|
100 | QBarSet::append(indexValueList.at(i)); | |
101 |
|
101 | |||
102 | } else { |
|
102 | } else { | |
103 | for (int i(0); i < values.count(); i++) { |
|
103 | for (int i(0); i < values.count(); i++) { | |
104 | if (values.at(i).canConvert(QVariant::Double)) |
|
104 | if (values.at(i).canConvert(QVariant::Double)) | |
105 | QBarSet::append(values[i].toDouble()); |
|
105 | QBarSet::append(values[i].toDouble()); | |
106 | } |
|
106 | } | |
107 | } |
|
107 | } | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | QString DeclarativeBarSet::brushFilename() const |
|
110 | QString DeclarativeBarSet::brushFilename() const | |
111 | { |
|
111 | { | |
112 | return m_brushFilename; |
|
112 | return m_brushFilename; | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | void DeclarativeBarSet::setBrushFilename(const QString &brushFilename) |
|
115 | void DeclarativeBarSet::setBrushFilename(const QString &brushFilename) | |
116 | { |
|
116 | { | |
117 | QImage brushImage(brushFilename); |
|
117 | QImage brushImage(brushFilename); | |
118 | if (QBarSet::brush().textureImage() != brushImage) { |
|
118 | if (QBarSet::brush().textureImage() != brushImage) { | |
119 | QBrush brush = QBarSet::brush(); |
|
119 | QBrush brush = QBarSet::brush(); | |
120 | brush.setTextureImage(brushImage); |
|
120 | brush.setTextureImage(brushImage); | |
121 | QBarSet::setBrush(brush); |
|
121 | QBarSet::setBrush(brush); | |
122 | m_brushFilename = brushFilename; |
|
122 | m_brushFilename = brushFilename; | |
123 | m_brushImage = brushImage; |
|
123 | m_brushImage = brushImage; | |
124 | emit brushFilenameChanged(brushFilename); |
|
124 | emit brushFilenameChanged(brushFilename); | |
125 | } |
|
125 | } | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | void DeclarativeBarSet::handleBrushChanged() |
|
128 | void DeclarativeBarSet::handleBrushChanged() | |
129 | { |
|
129 | { | |
130 | // If the texture image of the brush has changed along the brush |
|
130 | // If the texture image of the brush has changed along the brush | |
131 | // the brush file name needs to be cleared. |
|
131 | // the brush file name needs to be cleared. | |
132 | if (!m_brushFilename.isEmpty() && QBarSet::brush().textureImage() != m_brushImage) { |
|
132 | if (!m_brushFilename.isEmpty() && QBarSet::brush().textureImage() != m_brushImage) { | |
133 | m_brushFilename.clear(); |
|
133 | m_brushFilename.clear(); | |
134 | emit brushFilenameChanged(QString("")); |
|
134 | emit brushFilenameChanged(QString("")); | |
135 | } |
|
135 | } | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | // Declarative bar series ====================================================================================== |
|
138 | // Declarative bar series ====================================================================================== | |
139 | DeclarativeBarSeries::DeclarativeBarSeries(QQuickItem *parent) : |
|
139 | DeclarativeBarSeries::DeclarativeBarSeries(QQuickItem *parent) : | |
140 | QBarSeries(parent), |
|
140 | QBarSeries(parent), | |
141 | m_axes(new DeclarativeAxes(this)) |
|
141 | m_axes(new DeclarativeAxes(this)) | |
142 | { |
|
142 | { | |
143 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
143 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
144 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
144 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
145 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
145 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
146 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
146 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
147 | } |
|
147 | } | |
148 |
|
148 | |||
149 | void DeclarativeBarSeries::classBegin() |
|
149 | void DeclarativeBarSeries::classBegin() | |
150 | { |
|
150 | { | |
151 | } |
|
151 | } | |
152 |
|
152 | |||
153 | void DeclarativeBarSeries::componentComplete() |
|
153 | void DeclarativeBarSeries::componentComplete() | |
154 | { |
|
154 | { | |
155 | foreach (QObject *child, children()) { |
|
155 | foreach (QObject *child, children()) { | |
156 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
156 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
157 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
157 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
158 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
158 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
159 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
159 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
160 | mapper->setSeries(this); |
|
160 | mapper->setSeries(this); | |
161 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
161 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
162 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
162 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
163 | mapper->setSeries(this); |
|
163 | mapper->setSeries(this); | |
164 | } |
|
164 | } | |
165 | } |
|
165 | } | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | QQmlListProperty<QObject> DeclarativeBarSeries::seriesChildren() |
|
168 | QQmlListProperty<QObject> DeclarativeBarSeries::seriesChildren() | |
169 | { |
|
169 | { | |
170 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); |
|
170 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | void DeclarativeBarSeries::appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element) |
|
173 | void DeclarativeBarSeries::appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element) | |
174 | { |
|
174 | { | |
175 | // Empty implementation; the children are parsed in componentComplete instead |
|
175 | // Empty implementation; the children are parsed in componentComplete instead | |
176 | Q_UNUSED(list); |
|
176 | Q_UNUSED(list); | |
177 | Q_UNUSED(element); |
|
177 | Q_UNUSED(element); | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) |
|
180 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) | |
181 | { |
|
181 | { | |
182 | QList<QBarSet *> setList = barSets(); |
|
182 | QList<QBarSet *> setList = barSets(); | |
183 | if (index >= 0 && index < setList.count()) |
|
183 | if (index >= 0 && index < setList.count()) | |
184 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
184 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
185 |
|
185 | |||
186 | return 0; |
|
186 | return 0; | |
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) |
|
189 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) | |
190 | { |
|
190 | { | |
191 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
191 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
192 | barset->setLabel(label); |
|
192 | barset->setLabel(label); | |
193 | barset->setValues(values); |
|
193 | barset->setValues(values); | |
194 | if (QBarSeries::insert(index, barset)) |
|
194 | if (QBarSeries::insert(index, barset)) | |
195 | return barset; |
|
195 | return barset; | |
196 | delete barset; |
|
196 | delete barset; | |
197 | return 0; |
|
197 | return 0; | |
198 | } |
|
198 | } | |
199 |
|
199 | |||
200 | // Declarative stacked bar series ============================================================================== |
|
200 | // Declarative stacked bar series ============================================================================== | |
201 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QQuickItem *parent) : |
|
201 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QQuickItem *parent) : | |
202 | QStackedBarSeries(parent), |
|
202 | QStackedBarSeries(parent), | |
203 | m_axes(0) |
|
203 | m_axes(0) | |
204 | { |
|
204 | { | |
205 | m_axes = new DeclarativeAxes(this); |
|
205 | m_axes = new DeclarativeAxes(this); | |
206 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
206 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
207 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
207 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
208 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
208 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
209 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
209 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
210 | } |
|
210 | } | |
211 |
|
211 | |||
212 | void DeclarativeStackedBarSeries::classBegin() |
|
212 | void DeclarativeStackedBarSeries::classBegin() | |
213 | { |
|
213 | { | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | void DeclarativeStackedBarSeries::componentComplete() |
|
216 | void DeclarativeStackedBarSeries::componentComplete() | |
217 | { |
|
217 | { | |
218 | foreach (QObject *child, children()) { |
|
218 | foreach (QObject *child, children()) { | |
219 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
219 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
220 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
220 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
221 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
221 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
222 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
222 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
223 | mapper->setSeries(this); |
|
223 | mapper->setSeries(this); | |
224 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
224 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
225 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
225 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
226 | mapper->setSeries(this); |
|
226 | mapper->setSeries(this); | |
227 | } |
|
227 | } | |
228 | } |
|
228 | } | |
229 | } |
|
229 | } | |
230 |
|
230 | |||
231 |
|
231 | |||
232 | QQmlListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() |
|
232 | QQmlListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() | |
233 | { |
|
233 | { | |
234 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); |
|
234 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); | |
235 | } |
|
235 | } | |
236 |
|
236 | |||
237 | void DeclarativeStackedBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) |
|
237 | void DeclarativeStackedBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | |
238 | { |
|
238 | { | |
239 | // Empty implementation; the children are parsed in componentComplete instead |
|
239 | // Empty implementation; the children are parsed in componentComplete instead | |
240 | Q_UNUSED(list); |
|
240 | Q_UNUSED(list); | |
241 | Q_UNUSED(element); |
|
241 | Q_UNUSED(element); | |
242 | } |
|
242 | } | |
243 |
|
243 | |||
244 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) |
|
244 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) | |
245 | { |
|
245 | { | |
246 | QList<QBarSet *> setList = barSets(); |
|
246 | QList<QBarSet *> setList = barSets(); | |
247 | if (index >= 0 && index < setList.count()) |
|
247 | if (index >= 0 && index < setList.count()) | |
248 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
248 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
249 |
|
249 | |||
250 | return 0; |
|
250 | return 0; | |
251 | } |
|
251 | } | |
252 |
|
252 | |||
253 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) |
|
253 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) | |
254 | { |
|
254 | { | |
255 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
255 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
256 | barset->setLabel(label); |
|
256 | barset->setLabel(label); | |
257 | barset->setValues(values); |
|
257 | barset->setValues(values); | |
258 | if (QStackedBarSeries::insert(index, barset)) |
|
258 | if (QStackedBarSeries::insert(index, barset)) | |
259 | return barset; |
|
259 | return barset; | |
260 | delete barset; |
|
260 | delete barset; | |
261 | return 0; |
|
261 | return 0; | |
262 | } |
|
262 | } | |
263 |
|
263 | |||
264 | // Declarative percent bar series ============================================================================== |
|
264 | // Declarative percent bar series ============================================================================== | |
265 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QQuickItem *parent) : |
|
265 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QQuickItem *parent) : | |
266 | QPercentBarSeries(parent), |
|
266 | QPercentBarSeries(parent), | |
267 | m_axes(0) |
|
267 | m_axes(0) | |
268 | { |
|
268 | { | |
269 | m_axes = new DeclarativeAxes(this); |
|
269 | m_axes = new DeclarativeAxes(this); | |
270 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
270 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
271 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
271 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
272 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
272 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
273 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
273 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
274 | } |
|
274 | } | |
275 |
|
275 | |||
276 | void DeclarativePercentBarSeries::classBegin() |
|
276 | void DeclarativePercentBarSeries::classBegin() | |
277 | { |
|
277 | { | |
278 | } |
|
278 | } | |
279 |
|
279 | |||
280 | void DeclarativePercentBarSeries::componentComplete() |
|
280 | void DeclarativePercentBarSeries::componentComplete() | |
281 | { |
|
281 | { | |
282 | foreach (QObject *child, children()) { |
|
282 | foreach (QObject *child, children()) { | |
283 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
283 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
284 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
284 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
285 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
285 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
286 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
286 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
287 | mapper->setSeries(this); |
|
287 | mapper->setSeries(this); | |
288 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
288 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
289 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
289 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
290 | mapper->setSeries(this); |
|
290 | mapper->setSeries(this); | |
291 | } |
|
291 | } | |
292 | } |
|
292 | } | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 | QQmlListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() |
|
295 | QQmlListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() | |
296 | { |
|
296 | { | |
297 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); |
|
297 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren ,0,0,0); | |
298 | } |
|
298 | } | |
299 |
|
299 | |||
300 | void DeclarativePercentBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) |
|
300 | void DeclarativePercentBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | |
301 | { |
|
301 | { | |
302 | // Empty implementation; the children are parsed in componentComplete instead |
|
302 | // Empty implementation; the children are parsed in componentComplete instead | |
303 | Q_UNUSED(list); |
|
303 | Q_UNUSED(list); | |
304 | Q_UNUSED(element); |
|
304 | Q_UNUSED(element); | |
305 | } |
|
305 | } | |
306 |
|
306 | |||
307 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) |
|
307 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) | |
308 | { |
|
308 | { | |
309 | QList<QBarSet *> setList = barSets(); |
|
309 | QList<QBarSet *> setList = barSets(); | |
310 | if (index >= 0 && index < setList.count()) |
|
310 | if (index >= 0 && index < setList.count()) | |
311 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
311 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
312 |
|
312 | |||
313 | return 0; |
|
313 | return 0; | |
314 | } |
|
314 | } | |
315 |
|
315 | |||
316 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) |
|
316 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) | |
317 | { |
|
317 | { | |
318 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
318 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
319 | barset->setLabel(label); |
|
319 | barset->setLabel(label); | |
320 | barset->setValues(values); |
|
320 | barset->setValues(values); | |
321 | if (QPercentBarSeries::insert(index, barset)) |
|
321 | if (QPercentBarSeries::insert(index, barset)) | |
322 | return barset; |
|
322 | return barset; | |
323 | delete barset; |
|
323 | delete barset; | |
324 | return 0; |
|
324 | return 0; | |
325 | } |
|
325 | } | |
326 |
|
326 | |||
327 | // Declarative horizontal bar series =========================================================================== |
|
327 | // Declarative horizontal bar series =========================================================================== | |
328 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QQuickItem *parent) : |
|
328 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QQuickItem *parent) : | |
329 | QHorizontalBarSeries(parent), |
|
329 | QHorizontalBarSeries(parent), | |
330 | m_axes(0) |
|
330 | m_axes(0) | |
331 | { |
|
331 | { | |
332 | m_axes = new DeclarativeAxes(this); |
|
332 | m_axes = new DeclarativeAxes(this); | |
333 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
333 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
334 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
334 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
335 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
335 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
336 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
336 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
337 | } |
|
337 | } | |
338 |
|
338 | |||
339 | void DeclarativeHorizontalBarSeries::classBegin() |
|
339 | void DeclarativeHorizontalBarSeries::classBegin() | |
340 | { |
|
340 | { | |
341 | } |
|
341 | } | |
342 |
|
342 | |||
343 | void DeclarativeHorizontalBarSeries::componentComplete() |
|
343 | void DeclarativeHorizontalBarSeries::componentComplete() | |
344 | { |
|
344 | { | |
345 | foreach (QObject *child, children()) { |
|
345 | foreach (QObject *child, children()) { | |
346 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
346 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
347 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
347 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
348 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
348 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
349 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
349 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
350 | mapper->setSeries(this); |
|
350 | mapper->setSeries(this); | |
351 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
351 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
352 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
352 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
353 | mapper->setSeries(this); |
|
353 | mapper->setSeries(this); | |
354 | } |
|
354 | } | |
355 | } |
|
355 | } | |
356 | } |
|
356 | } | |
357 |
|
357 | |||
358 | QQmlListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren() |
|
358 | QQmlListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren() | |
359 | { |
|
359 | { | |
360 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren ,0,0,0); |
|
360 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren ,0,0,0); | |
361 | } |
|
361 | } | |
362 |
|
362 | |||
363 | void DeclarativeHorizontalBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) |
|
363 | void DeclarativeHorizontalBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | |
364 | { |
|
364 | { | |
365 | // Empty implementation; the children are parsed in componentComplete instead |
|
365 | // Empty implementation; the children are parsed in componentComplete instead | |
366 | Q_UNUSED(list); |
|
366 | Q_UNUSED(list); | |
367 | Q_UNUSED(element); |
|
367 | Q_UNUSED(element); | |
368 | } |
|
368 | } | |
369 |
|
369 | |||
370 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index) |
|
370 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index) | |
371 | { |
|
371 | { | |
372 | QList<QBarSet *> setList = barSets(); |
|
372 | QList<QBarSet *> setList = barSets(); | |
373 | if (index >= 0 && index < setList.count()) |
|
373 | if (index >= 0 && index < setList.count()) | |
374 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
374 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
375 |
|
375 | |||
376 | return 0; |
|
376 | return 0; | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values) |
|
379 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values) | |
380 | { |
|
380 | { | |
381 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
381 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
382 | barset->setLabel(label); |
|
382 | barset->setLabel(label); | |
383 | barset->setValues(values); |
|
383 | barset->setValues(values); | |
384 | if (QHorizontalBarSeries::insert(index, barset)) |
|
384 | if (QHorizontalBarSeries::insert(index, barset)) | |
385 | return barset; |
|
385 | return barset; | |
386 | delete barset; |
|
386 | delete barset; | |
387 | return 0; |
|
387 | return 0; | |
388 | } |
|
388 | } | |
389 |
|
389 | |||
390 | // Declarative horizontal stacked bar series =================================================================== |
|
390 | // Declarative horizontal stacked bar series =================================================================== | |
391 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QQuickItem *parent) : |
|
391 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QQuickItem *parent) : | |
392 | QHorizontalStackedBarSeries(parent), |
|
392 | QHorizontalStackedBarSeries(parent), | |
393 | m_axes(0) |
|
393 | m_axes(0) | |
394 | { |
|
394 | { | |
395 | m_axes = new DeclarativeAxes(this); |
|
395 | m_axes = new DeclarativeAxes(this); | |
396 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
396 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
397 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
397 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
398 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
398 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
399 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
399 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
400 | } |
|
400 | } | |
401 |
|
401 | |||
402 | void DeclarativeHorizontalStackedBarSeries::classBegin() |
|
402 | void DeclarativeHorizontalStackedBarSeries::classBegin() | |
403 | { |
|
403 | { | |
404 | } |
|
404 | } | |
405 |
|
405 | |||
406 | void DeclarativeHorizontalStackedBarSeries::componentComplete() |
|
406 | void DeclarativeHorizontalStackedBarSeries::componentComplete() | |
407 | { |
|
407 | { | |
408 | foreach (QObject *child, children()) { |
|
408 | foreach (QObject *child, children()) { | |
409 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
409 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
410 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
410 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
411 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
411 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
412 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
412 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
413 | mapper->setSeries(this); |
|
413 | mapper->setSeries(this); | |
414 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
414 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
415 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
415 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
416 | mapper->setSeries(this); |
|
416 | mapper->setSeries(this); | |
417 | } |
|
417 | } | |
418 | } |
|
418 | } | |
419 | } |
|
419 | } | |
420 |
|
420 | |||
421 | QQmlListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren() |
|
421 | QQmlListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren() | |
422 | { |
|
422 | { | |
423 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren ,0,0,0); |
|
423 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren ,0,0,0); | |
424 | } |
|
424 | } | |
425 |
|
425 | |||
426 | void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) |
|
426 | void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | |
427 | { |
|
427 | { | |
428 | // Empty implementation; the children are parsed in componentComplete instead |
|
428 | // Empty implementation; the children are parsed in componentComplete instead | |
429 | Q_UNUSED(list); |
|
429 | Q_UNUSED(list); | |
430 | Q_UNUSED(element); |
|
430 | Q_UNUSED(element); | |
431 | } |
|
431 | } | |
432 |
|
432 | |||
433 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index) |
|
433 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index) | |
434 | { |
|
434 | { | |
435 | QList<QBarSet *> setList = barSets(); |
|
435 | QList<QBarSet *> setList = barSets(); | |
436 | if (index >= 0 && index < setList.count()) |
|
436 | if (index >= 0 && index < setList.count()) | |
437 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
437 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
438 |
|
438 | |||
439 | return 0; |
|
439 | return 0; | |
440 | } |
|
440 | } | |
441 |
|
441 | |||
442 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values) |
|
442 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values) | |
443 | { |
|
443 | { | |
444 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
444 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
445 | barset->setLabel(label); |
|
445 | barset->setLabel(label); | |
446 | barset->setValues(values); |
|
446 | barset->setValues(values); | |
447 | if (QHorizontalStackedBarSeries::insert(index, barset)) |
|
447 | if (QHorizontalStackedBarSeries::insert(index, barset)) | |
448 | return barset; |
|
448 | return barset; | |
449 | delete barset; |
|
449 | delete barset; | |
450 | return 0; |
|
450 | return 0; | |
451 | } |
|
451 | } | |
452 |
|
452 | |||
453 | // Declarative horizontal percent bar series =================================================================== |
|
453 | // Declarative horizontal percent bar series =================================================================== | |
454 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QQuickItem *parent) : |
|
454 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QQuickItem *parent) : | |
455 | QHorizontalPercentBarSeries(parent), |
|
455 | QHorizontalPercentBarSeries(parent), | |
456 | m_axes(0) |
|
456 | m_axes(0) | |
457 | { |
|
457 | { | |
458 | m_axes = new DeclarativeAxes(this); |
|
458 | m_axes = new DeclarativeAxes(this); | |
459 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
459 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); | |
460 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
460 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); | |
461 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
461 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); | |
462 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
462 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); | |
463 | } |
|
463 | } | |
464 |
|
464 | |||
465 | void DeclarativeHorizontalPercentBarSeries::classBegin() |
|
465 | void DeclarativeHorizontalPercentBarSeries::classBegin() | |
466 | { |
|
466 | { | |
467 | } |
|
467 | } | |
468 |
|
468 | |||
469 | void DeclarativeHorizontalPercentBarSeries::componentComplete() |
|
469 | void DeclarativeHorizontalPercentBarSeries::componentComplete() | |
470 | { |
|
470 | { | |
471 | foreach (QObject *child, children()) { |
|
471 | foreach (QObject *child, children()) { | |
472 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
472 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
473 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
473 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
474 | } else if (qobject_cast<QVBarModelMapper *>(child)) { |
|
474 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
475 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
475 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
476 | mapper->setSeries(this); |
|
476 | mapper->setSeries(this); | |
477 | } else if (qobject_cast<QHBarModelMapper *>(child)) { |
|
477 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
478 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
478 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
479 | mapper->setSeries(this); |
|
479 | mapper->setSeries(this); | |
480 | } |
|
480 | } | |
481 | } |
|
481 | } | |
482 | } |
|
482 | } | |
483 |
|
483 | |||
484 | QQmlListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren() |
|
484 | QQmlListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren() | |
485 | { |
|
485 | { | |
486 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren ,0,0,0); |
|
486 | return QQmlListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren ,0,0,0); | |
487 | } |
|
487 | } | |
488 |
|
488 | |||
489 | void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) |
|
489 | void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QQmlListProperty<QObject> * list, QObject *element) | |
490 | { |
|
490 | { | |
491 | // Empty implementation; the children are parsed in componentComplete instead |
|
491 | // Empty implementation; the children are parsed in componentComplete instead | |
492 | Q_UNUSED(list); |
|
492 | Q_UNUSED(list); | |
493 | Q_UNUSED(element); |
|
493 | Q_UNUSED(element); | |
494 | } |
|
494 | } | |
495 |
|
495 | |||
496 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index) |
|
496 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index) | |
497 | { |
|
497 | { | |
498 | QList<QBarSet *> setList = barSets(); |
|
498 | QList<QBarSet *> setList = barSets(); | |
499 | if (index >= 0 && index < setList.count()) |
|
499 | if (index >= 0 && index < setList.count()) | |
500 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
500 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
501 |
|
501 | |||
502 | return 0; |
|
502 | return 0; | |
503 | } |
|
503 | } | |
504 |
|
504 | |||
505 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values) |
|
505 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values) | |
506 | { |
|
506 | { | |
507 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
507 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
508 | barset->setLabel(label); |
|
508 | barset->setLabel(label); | |
509 | barset->setValues(values); |
|
509 | barset->setValues(values); | |
510 | if (QHorizontalPercentBarSeries::insert(index, barset)) |
|
510 | if (QHorizontalPercentBarSeries::insert(index, barset)) | |
511 | return barset; |
|
511 | return barset; | |
512 | delete barset; |
|
512 | delete barset; | |
513 | return 0; |
|
513 | return 0; | |
514 | } |
|
514 | } | |
515 |
|
515 | |||
516 | #include "moc_declarativebarseries.cpp" |
|
516 | #include "moc_declarativebarseries.cpp" | |
517 |
|
517 | |||
518 | QT_CHARTS_END_NAMESPACE |
|
518 | QT_CHARTS_END_NAMESPACE |
@@ -1,1250 +1,1252 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #include "declarativechart.h" |
|
30 | #include "declarativechart.h" | |
31 | #include <QtGui/QPainter> |
|
31 | #include <QtGui/QPainter> | |
32 | #include "declarativelineseries.h" |
|
32 | #include "declarativelineseries.h" | |
33 | #include "declarativeareaseries.h" |
|
33 | #include "declarativeareaseries.h" | |
34 | #include "declarativebarseries.h" |
|
34 | #include "declarativebarseries.h" | |
35 | #include "declarativepieseries.h" |
|
35 | #include "declarativepieseries.h" | |
36 | #include "declarativesplineseries.h" |
|
36 | #include "declarativesplineseries.h" | |
37 | #include "declarativeboxplotseries.h" |
|
37 | #include "declarativeboxplotseries.h" | |
38 | #include "declarativescatterseries.h" |
|
38 | #include "declarativescatterseries.h" | |
39 | #include "declarativechartnode.h" |
|
39 | #include "declarativechartnode.h" | |
40 | #include "declarativerendernode.h" |
|
40 | #include "declarativerendernode.h" | |
41 | #include <QtCharts/QBarCategoryAxis> |
|
41 | #include <QtCharts/QBarCategoryAxis> | |
42 | #include <QtCharts/QValueAxis> |
|
42 | #include <QtCharts/QValueAxis> | |
43 | #include <QtCharts/QLogValueAxis> |
|
43 | #include <QtCharts/QLogValueAxis> | |
44 | #include <QtCharts/QCategoryAxis> |
|
44 | #include <QtCharts/QCategoryAxis> | |
45 | #include <private/qabstractseries_p.h> |
|
45 | #include <private/qabstractseries_p.h> | |
46 | #include "declarativemargins.h" |
|
46 | #include "declarativemargins.h" | |
47 | #include <private/chartdataset_p.h> |
|
47 | #include <private/chartdataset_p.h> | |
48 | #include "declarativeaxes.h" |
|
48 | #include "declarativeaxes.h" | |
49 | #include <private/qchart_p.h> |
|
49 | #include <private/qchart_p.h> | |
50 | #include <private/chartpresenter_p.h> |
|
50 | #include <private/chartpresenter_p.h> | |
51 | #include <QtCharts/QPolarChart> |
|
51 | #include <QtCharts/QPolarChart> | |
52 |
|
52 | |||
53 | #ifndef QT_QREAL_IS_FLOAT |
|
53 | #ifndef QT_QREAL_IS_FLOAT | |
54 | #include <QtCharts/QDateTimeAxis> |
|
54 | #include <QtCharts/QDateTimeAxis> | |
55 | #endif |
|
55 | #endif | |
56 |
|
56 | |||
57 | #include <QtWidgets/QGraphicsSceneMouseEvent> |
|
57 | #include <QtWidgets/QGraphicsSceneMouseEvent> | |
58 | #include <QtWidgets/QGraphicsSceneHoverEvent> |
|
58 | #include <QtWidgets/QGraphicsSceneHoverEvent> | |
59 | #include <QtWidgets/QApplication> |
|
59 | #include <QtWidgets/QApplication> | |
60 | #include <QtCore/QTimer> |
|
60 | #include <QtCore/QTimer> | |
61 | #include <QtCore/QThread> |
|
61 | #include <QtCore/QThread> | |
62 |
|
62 | |||
63 | QT_CHARTS_BEGIN_NAMESPACE |
|
63 | QT_CHARTS_BEGIN_NAMESPACE | |
64 |
|
64 | |||
65 | /*! |
|
65 | /*! | |
66 | \qmltype ChartView |
|
66 | \qmltype ChartView | |
67 | \instantiates DeclarativeChart |
|
67 | \instantiates DeclarativeChart | |
68 | \inqmlmodule QtCharts |
|
68 | \inqmlmodule QtCharts | |
69 |
|
69 | |||
70 | \brief Chart element. |
|
70 | \brief Chart element. | |
71 |
|
71 | |||
72 | ChartView element is the parent that is responsible for showing different chart series types. |
|
72 | ChartView element is the parent that is responsible for showing different chart series types. | |
73 |
|
73 | |||
74 | The following QML shows how to create a simple chart with one pie series: |
|
74 | The following QML shows how to create a simple chart with one pie series: | |
75 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
75 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 1 | |
76 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
76 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 2 | |
77 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
77 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 3 | |
78 |
|
78 | |||
79 | \beginfloatleft |
|
79 | \beginfloatleft | |
80 | \image examples_qmlpiechart.png |
|
80 | \image examples_qmlpiechart.png | |
81 | \endfloat |
|
81 | \endfloat | |
82 | \clearfloat |
|
82 | \clearfloat | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | /*! |
|
85 | /*! | |
86 | \qmlproperty Theme ChartView::theme |
|
86 | \qmlproperty Theme ChartView::theme | |
87 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
87 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
88 | widths and chart background. |
|
88 | widths and chart background. | |
89 | */ |
|
89 | */ | |
90 |
|
90 | |||
91 | /*! |
|
91 | /*! | |
92 | \qmlproperty Animation ChartView::animationOptions |
|
92 | \qmlproperty Animation ChartView::animationOptions | |
93 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
93 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
94 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
94 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
95 | */ |
|
95 | */ | |
96 |
|
96 | |||
97 | /*! |
|
97 | /*! | |
98 | \qmlproperty int ChartView::animationDuration |
|
98 | \qmlproperty int ChartView::animationDuration | |
99 | The duration of the animation for the chart. |
|
99 | The duration of the animation for the chart. | |
100 | */ |
|
100 | */ | |
101 |
|
101 | |||
102 | /*! |
|
102 | /*! | |
103 | \qmlproperty easing ChartView::animationEasingCurve |
|
103 | \qmlproperty easing ChartView::animationEasingCurve | |
104 | The easing curve of the animation for the chart. |
|
104 | The easing curve of the animation for the chart. | |
105 | */ |
|
105 | */ | |
106 |
|
106 | |||
107 | /*! |
|
107 | /*! | |
108 | \qmlproperty Font ChartView::titleFont |
|
108 | \qmlproperty Font ChartView::titleFont | |
109 | The title font of the chart. |
|
109 | The title font of the chart. | |
110 |
|
110 | |||
111 | See the Qt documentation for more details of Font. |
|
111 | See the Qt documentation for more details of Font. | |
112 | */ |
|
112 | */ | |
113 |
|
113 | |||
114 | /*! |
|
114 | /*! | |
115 | \qmlproperty string ChartView::title |
|
115 | \qmlproperty string ChartView::title | |
116 | The title of the chart, shown on top of the chart. |
|
116 | The title of the chart, shown on top of the chart. | |
117 | \sa ChartView::titleColor |
|
117 | \sa ChartView::titleColor | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \qmlproperty color ChartView::titleColor |
|
121 | \qmlproperty color ChartView::titleColor | |
122 | The color of the title text. |
|
122 | The color of the title text. | |
123 | */ |
|
123 | */ | |
124 |
|
124 | |||
125 | /*! |
|
125 | /*! | |
126 | \qmlproperty Legend ChartView::legend |
|
126 | \qmlproperty Legend ChartView::legend | |
127 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
127 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
128 | */ |
|
128 | */ | |
129 |
|
129 | |||
130 | /*! |
|
130 | /*! | |
131 | \qmlproperty int ChartView::count |
|
131 | \qmlproperty int ChartView::count | |
132 | The count of series added to the chart. |
|
132 | The count of series added to the chart. | |
133 | */ |
|
133 | */ | |
134 |
|
134 | |||
135 | /*! |
|
135 | /*! | |
136 | \qmlproperty color ChartView::backgroundColor |
|
136 | \qmlproperty color ChartView::backgroundColor | |
137 | The color of the chart's background. By default background color is defined by chart theme. |
|
137 | The color of the chart's background. By default background color is defined by chart theme. | |
138 | \sa ChartView::theme |
|
138 | \sa ChartView::theme | |
139 | */ |
|
139 | */ | |
140 |
|
140 | |||
141 | /*! |
|
141 | /*! | |
142 | \qmlproperty real ChartView::backgroundRoundness |
|
142 | \qmlproperty real ChartView::backgroundRoundness | |
143 | The diameter of the rounding circle at the corners of the chart background. |
|
143 | The diameter of the rounding circle at the corners of the chart background. | |
144 | */ |
|
144 | */ | |
145 |
|
145 | |||
146 | /*! |
|
146 | /*! | |
147 | \qmlproperty color ChartView::plotAreaColor |
|
147 | \qmlproperty color ChartView::plotAreaColor | |
148 | The color of the background of the chart's plot area. By default plot area background uses chart's |
|
148 | The color of the background of the chart's plot area. By default plot area background uses chart's | |
149 | background color. |
|
149 | background color. | |
150 | \sa ChartView::backgroundColor |
|
150 | \sa ChartView::backgroundColor | |
151 | */ |
|
151 | */ | |
152 |
|
152 | |||
153 | /*! |
|
153 | /*! | |
154 | \qmlproperty list<AbstractAxis> ChartView::axes |
|
154 | \qmlproperty list<AbstractAxis> ChartView::axes | |
155 | The axes of the ChartView. |
|
155 | The axes of the ChartView. | |
156 | */ |
|
156 | */ | |
157 |
|
157 | |||
158 | /*! |
|
158 | /*! | |
159 | \qmlproperty bool ChartView::dropShadowEnabled |
|
159 | \qmlproperty bool ChartView::dropShadowEnabled | |
160 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
160 | The chart's border drop shadow. Set to true to enable drop shadow. | |
161 | */ |
|
161 | */ | |
162 |
|
162 | |||
163 | /*! |
|
163 | /*! | |
164 | \qmlproperty rect ChartView::plotArea |
|
164 | \qmlproperty rect ChartView::plotArea | |
165 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the |
|
165 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the | |
166 | margins. |
|
166 | margins. | |
167 | \sa ChartView::margins |
|
167 | \sa ChartView::margins | |
168 | */ |
|
168 | */ | |
169 |
|
169 | |||
170 | /*! |
|
170 | /*! | |
171 | \qmlproperty Margins ChartView::margins |
|
171 | \qmlproperty Margins ChartView::margins | |
172 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins |
|
172 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins | |
173 | area of ChartView is used for drawing title, axes and legend. |
|
173 | area of ChartView is used for drawing title, axes and legend. | |
174 | */ |
|
174 | */ | |
175 |
|
175 | |||
176 | /*! |
|
176 | /*! | |
177 | \qmlproperty bool ChartView::localizeNumbers |
|
177 | \qmlproperty bool ChartView::localizeNumbers | |
178 | \since QtCharts 2.0 |
|
178 | \since QtCharts 2.0 | |
179 | When \c{true}, all generated numbers appearing in various series and axis labels will be |
|
179 | When \c{true}, all generated numbers appearing in various series and axis labels will be | |
180 | localized using the default QLocale of the application, which defaults to the system locale. |
|
180 | localized using the default QLocale of the application, which defaults to the system locale. | |
181 | When \c{false}, the "C" locale is always used. |
|
181 | When \c{false}, the "C" locale is always used. | |
182 | Defaults to \c{false}. |
|
182 | Defaults to \c{false}. | |
183 |
|
183 | |||
184 | \sa locale |
|
184 | \sa locale | |
185 | */ |
|
185 | */ | |
186 |
|
186 | |||
187 | /*! |
|
187 | /*! | |
188 | \qmlproperty locale ChartView::locale |
|
188 | \qmlproperty locale ChartView::locale | |
189 | \since QtCharts 2.0 |
|
189 | \since QtCharts 2.0 | |
190 | Sets the locale used to format various chart labels when localizeNumbers is \c{true}. |
|
190 | Sets the locale used to format various chart labels when localizeNumbers is \c{true}. | |
191 | This also determines the locale used to format DateTimeAxis labels regardless of |
|
191 | This also determines the locale used to format DateTimeAxis labels regardless of | |
192 | localizeNumbers property. |
|
192 | localizeNumbers property. | |
193 | Defaults to application default locale at the time the chart is constructed. |
|
193 | Defaults to application default locale at the time the chart is constructed. | |
194 |
|
194 | |||
195 | \sa localizeNumbers |
|
195 | \sa localizeNumbers | |
196 | */ |
|
196 | */ | |
197 |
|
197 | |||
198 | /*! |
|
198 | /*! | |
199 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
199 | \qmlmethod AbstractSeries ChartView::series(int index) | |
200 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with |
|
200 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with | |
201 | the count property of the chart. |
|
201 | the count property of the chart. | |
202 | */ |
|
202 | */ | |
203 |
|
203 | |||
204 | /*! |
|
204 | /*! | |
205 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
205 | \qmlmethod AbstractSeries ChartView::series(string name) | |
206 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. |
|
206 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. | |
207 | */ |
|
207 | */ | |
208 |
|
208 | |||
209 | /*! |
|
209 | /*! | |
210 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) |
|
210 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) | |
211 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and |
|
211 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and | |
212 | optional axis \a axisY. For example: |
|
212 | optional axis \a axisY. For example: | |
213 | \code |
|
213 | \code | |
214 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes |
|
214 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes | |
215 | var myAxisX = chartView.axisX(lineSeries); |
|
215 | var myAxisX = chartView.axisX(lineSeries); | |
216 | var myAxisY = chartView.axisY(lineSeries); |
|
216 | var myAxisY = chartView.axisY(lineSeries); | |
217 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); |
|
217 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); | |
218 | \endcode |
|
218 | \endcode | |
219 | */ |
|
219 | */ | |
220 |
|
220 | |||
221 | /*! |
|
221 | /*! | |
222 | \qmlmethod ChartView::removeSeries(AbstractSeries series) |
|
222 | \qmlmethod ChartView::removeSeries(AbstractSeries series) | |
223 | Removes the \a series from the chart. The series object is also destroyed. |
|
223 | Removes the \a series from the chart. The series object is also destroyed. | |
224 | */ |
|
224 | */ | |
225 |
|
225 | |||
226 | /*! |
|
226 | /*! | |
227 | \qmlmethod ChartView::removeAllSeries() |
|
227 | \qmlmethod ChartView::removeAllSeries() | |
228 | Removes all series from the chart. All the series objects are also destroyed. |
|
228 | Removes all series from the chart. All the series objects are also destroyed. | |
229 | */ |
|
229 | */ | |
230 |
|
230 | |||
231 | /*! |
|
231 | /*! | |
232 | \qmlmethod Axis ChartView::axisX(AbstractSeries series) |
|
232 | \qmlmethod Axis ChartView::axisX(AbstractSeries series) | |
233 | The x-axis of the series. |
|
233 | The x-axis of the series. | |
234 | */ |
|
234 | */ | |
235 |
|
235 | |||
236 | /*! |
|
236 | /*! | |
237 | \qmlmethod ChartView::setAxisX(AbstractAxis axis, AbstractSeries series) |
|
237 | \qmlmethod ChartView::setAxisX(AbstractAxis axis, AbstractSeries series) | |
238 | Set the x-axis of the series. |
|
238 | Set the x-axis of the series. | |
239 | */ |
|
239 | */ | |
240 |
|
240 | |||
241 | /*! |
|
241 | /*! | |
242 | \qmlmethod Axis ChartView::axisY(AbstractSeries series) |
|
242 | \qmlmethod Axis ChartView::axisY(AbstractSeries series) | |
243 | The y-axis of the series. |
|
243 | The y-axis of the series. | |
244 | */ |
|
244 | */ | |
245 |
|
245 | |||
246 | /*! |
|
246 | /*! | |
247 | \qmlmethod ChartView::setAxisY(AbstractAxis axis, AbstractSeries series) |
|
247 | \qmlmethod ChartView::setAxisY(AbstractAxis axis, AbstractSeries series) | |
248 | Set the y-axis of the series. |
|
248 | Set the y-axis of the series. | |
249 | */ |
|
249 | */ | |
250 |
|
250 | |||
251 | /*! |
|
251 | /*! | |
252 | \qmlmethod ChartView::zoom(real factor) |
|
252 | \qmlmethod ChartView::zoom(real factor) | |
253 | Zooms in by \a factor on the center of the chart. |
|
253 | Zooms in by \a factor on the center of the chart. | |
254 |
|
254 | |||
255 | A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out. |
|
255 | A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out. | |
256 | */ |
|
256 | */ | |
257 |
|
257 | |||
258 | /*! |
|
258 | /*! | |
259 | \qmlmethod ChartView::zoomIn() |
|
259 | \qmlmethod ChartView::zoomIn() | |
260 | Zooms in the view by a factor of two. |
|
260 | Zooms in the view by a factor of two. | |
261 | */ |
|
261 | */ | |
262 |
|
262 | |||
263 | /*! |
|
263 | /*! | |
264 | \qmlmethod ChartView::zoomIn(rect rectangle) |
|
264 | \qmlmethod ChartView::zoomIn(rect rectangle) | |
265 | Zooms in the view to a maximum level at which \a rectangle is still fully visible. |
|
265 | Zooms in the view to a maximum level at which \a rectangle is still fully visible. | |
266 | \note This is not supported for polar charts. |
|
266 | \note This is not supported for polar charts. | |
267 | */ |
|
267 | */ | |
268 |
|
268 | |||
269 | /*! |
|
269 | /*! | |
270 | \qmlmethod ChartView::zoomOut() |
|
270 | \qmlmethod ChartView::zoomOut() | |
271 | Zooms out the view by a factor of two. |
|
271 | Zooms out the view by a factor of two. | |
272 | */ |
|
272 | */ | |
273 |
|
273 | |||
274 | /*! |
|
274 | /*! | |
275 | \qmlmethod ChartView::zoomReset() |
|
275 | \qmlmethod ChartView::zoomReset() | |
276 | Resets the series domains to what they were before any zoom method was called. |
|
276 | Resets the series domains to what they were before any zoom method was called. | |
277 | Note that this will also reset any scrolls and explicit axis range settings done between |
|
277 | Note that this will also reset any scrolls and explicit axis range settings done between | |
278 | the first zoom operation and calling this method. If no zoom operation has been |
|
278 | the first zoom operation and calling this method. If no zoom operation has been | |
279 | done, this method does nothing. |
|
279 | done, this method does nothing. | |
280 | */ |
|
280 | */ | |
281 |
|
281 | |||
282 | /*! |
|
282 | /*! | |
283 | \qmlmethod ChartView::isZoomed() |
|
283 | \qmlmethod ChartView::isZoomed() | |
284 | Returns true if any series has a zoomed domain. |
|
284 | Returns true if any series has a zoomed domain. | |
285 | */ |
|
285 | */ | |
286 |
|
286 | |||
287 | /*! |
|
287 | /*! | |
288 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
288 | \qmlmethod ChartView::scrollLeft(real pixels) | |
289 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
289 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
290 | */ |
|
290 | */ | |
291 |
|
291 | |||
292 | /*! |
|
292 | /*! | |
293 | \qmlmethod ChartView::scrollRight(real pixels) |
|
293 | \qmlmethod ChartView::scrollRight(real pixels) | |
294 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
294 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
295 | */ |
|
295 | */ | |
296 |
|
296 | |||
297 | /*! |
|
297 | /*! | |
298 | \qmlmethod ChartView::scrollUp(real pixels) |
|
298 | \qmlmethod ChartView::scrollUp(real pixels) | |
299 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
299 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
300 | */ |
|
300 | */ | |
301 |
|
301 | |||
302 | /*! |
|
302 | /*! | |
303 | \qmlmethod ChartView::scrollDown(real pixels) |
|
303 | \qmlmethod ChartView::scrollDown(real pixels) | |
304 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
304 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
305 | */ |
|
305 | */ | |
306 |
|
306 | |||
307 | /*! |
|
307 | /*! | |
308 | \qmlmethod point ChartView::mapToValue(point position, AbstractSeries series) |
|
308 | \qmlmethod point ChartView::mapToValue(point position, AbstractSeries series) | |
309 | Returns the value in the \a series domain that corresponds to the \a position relative to the |
|
309 | Returns the value in the \a series domain that corresponds to the \a position relative to the | |
310 | chart. |
|
310 | chart. | |
311 | */ |
|
311 | */ | |
312 |
|
312 | |||
313 | /*! |
|
313 | /*! | |
314 | \qmlmethod point ChartView::mapToPosition(point value, AbstractSeries series) |
|
314 | \qmlmethod point ChartView::mapToPosition(point value, AbstractSeries series) | |
315 | Returns the position on the chart that corresponds to the \a value in the \a series domain. |
|
315 | Returns the position on the chart that corresponds to the \a value in the \a series domain. | |
316 | */ |
|
316 | */ | |
317 |
|
317 | |||
318 | /*! |
|
318 | /*! | |
319 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) |
|
319 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) | |
320 | The \a series has been added to the chart. |
|
320 | The \a series has been added to the chart. | |
321 | */ |
|
321 | */ | |
322 |
|
322 | |||
323 | /*! |
|
323 | /*! | |
324 | \qmlsignal ChartView::seriesRemoved(AbstractSeries series) |
|
324 | \qmlsignal ChartView::seriesRemoved(AbstractSeries series) | |
325 | The \a series has been removed from the chart. Please note that \a series is no longer a valid |
|
325 | The \a series has been removed from the chart. Please note that \a series is no longer a valid | |
326 | object after the signal handler has completed. |
|
326 | object after the signal handler has completed. | |
327 | */ |
|
327 | */ | |
328 |
|
328 | |||
329 | DeclarativeChart::DeclarativeChart(QQuickItem *parent) |
|
329 | DeclarativeChart::DeclarativeChart(QQuickItem *parent) | |
330 | : QQuickItem(parent) |
|
330 | : QQuickItem(parent) | |
331 | { |
|
331 | { | |
332 | initChart(QChart::ChartTypeCartesian); |
|
332 | initChart(QChart::ChartTypeCartesian); | |
333 | } |
|
333 | } | |
334 |
|
334 | |||
335 | DeclarativeChart::DeclarativeChart(QChart::ChartType type, QQuickItem *parent) |
|
335 | DeclarativeChart::DeclarativeChart(QChart::ChartType type, QQuickItem *parent) | |
336 | : QQuickItem(parent) |
|
336 | : QQuickItem(parent) | |
337 | { |
|
337 | { | |
338 | initChart(type); |
|
338 | initChart(type); | |
339 | } |
|
339 | } | |
340 |
|
340 | |||
341 | void DeclarativeChart::initChart(QChart::ChartType type) |
|
341 | void DeclarativeChart::initChart(QChart::ChartType type) | |
342 | { |
|
342 | { | |
343 | m_sceneImage = 0; |
|
343 | m_sceneImage = 0; | |
344 | m_sceneImageDirty = false; |
|
344 | m_sceneImageDirty = false; | |
345 | m_sceneImageNeedsClear = false; |
|
345 | m_sceneImageNeedsClear = false; | |
346 | m_guiThreadId = QThread::currentThreadId(); |
|
346 | m_guiThreadId = QThread::currentThreadId(); | |
347 | m_paintThreadId = 0; |
|
347 | m_paintThreadId = 0; | |
348 | m_updatePending = false; |
|
348 | m_updatePending = false; | |
349 |
|
349 | |||
350 | setFlag(ItemHasContents, true); |
|
350 | setFlag(ItemHasContents, true); | |
351 |
|
351 | |||
352 | if (type == QChart::ChartTypePolar) |
|
352 | if (type == QChart::ChartTypePolar) | |
353 | m_chart = new QPolarChart(); |
|
353 | m_chart = new QPolarChart(); | |
354 | else |
|
354 | else | |
355 | m_chart = new QChart(); |
|
355 | m_chart = new QChart(); | |
356 |
|
356 | |||
357 | m_chart->d_ptr->m_presenter->glSetUseWidget(false); |
|
357 | m_chart->d_ptr->m_presenter->glSetUseWidget(false); | |
358 | m_glXYDataManager = m_chart->d_ptr->m_dataset->glXYSeriesDataManager(); |
|
358 | m_glXYDataManager = m_chart->d_ptr->m_dataset->glXYSeriesDataManager(); | |
359 |
|
359 | |||
360 | m_scene = new QGraphicsScene(this); |
|
360 | m_scene = new QGraphicsScene(this); | |
361 | m_scene->addItem(m_chart); |
|
361 | m_scene->addItem(m_chart); | |
362 |
|
362 | |||
363 | setAntialiasing(QQuickItem::antialiasing()); |
|
363 | setAntialiasing(QQuickItem::antialiasing()); | |
364 | connect(m_scene, &QGraphicsScene::changed, this, &DeclarativeChart::sceneChanged); |
|
364 | connect(m_scene, &QGraphicsScene::changed, this, &DeclarativeChart::sceneChanged); | |
365 | connect(this, &DeclarativeChart::needRender, this, &DeclarativeChart::renderScene, |
|
365 | connect(this, &DeclarativeChart::needRender, this, &DeclarativeChart::renderScene, | |
366 | Qt::QueuedConnection); |
|
366 | Qt::QueuedConnection); | |
367 | connect(this, SIGNAL(antialiasingChanged(bool)), this, SLOT(handleAntialiasingChanged(bool))); |
|
367 | connect(this, SIGNAL(antialiasingChanged(bool)), this, SLOT(handleAntialiasingChanged(bool))); | |
368 |
|
368 | |||
369 | setAcceptedMouseButtons(Qt::AllButtons); |
|
369 | setAcceptedMouseButtons(Qt::AllButtons); | |
370 | setAcceptHoverEvents(true); |
|
370 | setAcceptHoverEvents(true); | |
371 |
|
371 | |||
372 | m_margins = new DeclarativeMargins(this); |
|
372 | m_margins = new DeclarativeMargins(this); | |
373 | m_margins->setTop(m_chart->margins().top()); |
|
373 | m_margins->setTop(m_chart->margins().top()); | |
374 | m_margins->setLeft(m_chart->margins().left()); |
|
374 | m_margins->setLeft(m_chart->margins().left()); | |
375 | m_margins->setRight(m_chart->margins().right()); |
|
375 | m_margins->setRight(m_chart->margins().right()); | |
376 | m_margins->setBottom(m_chart->margins().bottom()); |
|
376 | m_margins->setBottom(m_chart->margins().bottom()); | |
377 | connect(m_margins, SIGNAL(topChanged(int,int,int,int)), |
|
377 | connect(m_margins, SIGNAL(topChanged(int,int,int,int)), | |
378 | this, SLOT(changeMargins(int,int,int,int))); |
|
378 | this, SLOT(changeMargins(int,int,int,int))); | |
379 | connect(m_margins, SIGNAL(bottomChanged(int,int,int,int)), |
|
379 | connect(m_margins, SIGNAL(bottomChanged(int,int,int,int)), | |
380 | this, SLOT(changeMargins(int,int,int,int))); |
|
380 | this, SLOT(changeMargins(int,int,int,int))); | |
381 | connect(m_margins, SIGNAL(leftChanged(int,int,int,int)), |
|
381 | connect(m_margins, SIGNAL(leftChanged(int,int,int,int)), | |
382 | this, SLOT(changeMargins(int,int,int,int))); |
|
382 | this, SLOT(changeMargins(int,int,int,int))); | |
383 | connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), |
|
383 | connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), | |
384 | this, SLOT(changeMargins(int,int,int,int))); |
|
384 | this, SLOT(changeMargins(int,int,int,int))); | |
385 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*))); |
|
385 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*))); | |
386 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
386 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
387 | connect(m_chart, &QChart::plotAreaChanged, this, &DeclarativeChart::plotAreaChanged); |
|
387 | connect(m_chart, &QChart::plotAreaChanged, this, &DeclarativeChart::plotAreaChanged); | |
388 | } |
|
388 | } | |
389 |
|
389 | |||
390 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series) |
|
390 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series) | |
391 | { |
|
391 | { | |
392 | emit seriesAdded(series); |
|
392 | emit seriesAdded(series); | |
393 | } |
|
393 | } | |
394 |
|
394 | |||
395 | void DeclarativeChart::changeMargins(int top, int bottom, int left, int right) |
|
395 | void DeclarativeChart::changeMargins(int top, int bottom, int left, int right) | |
396 | { |
|
396 | { | |
397 | m_chart->setMargins(QMargins(left, top, right, bottom)); |
|
397 | m_chart->setMargins(QMargins(left, top, right, bottom)); | |
398 | emit marginsChanged(); |
|
398 | emit marginsChanged(); | |
399 | } |
|
399 | } | |
400 |
|
400 | |||
401 | DeclarativeChart::~DeclarativeChart() |
|
401 | DeclarativeChart::~DeclarativeChart() | |
402 | { |
|
402 | { | |
403 | delete m_chart; |
|
403 | delete m_chart; | |
404 | delete m_sceneImage; |
|
404 | delete m_sceneImage; | |
405 | } |
|
405 | } | |
406 |
|
406 | |||
407 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
407 | void DeclarativeChart::childEvent(QChildEvent *event) | |
408 | { |
|
408 | { | |
409 | if (event->type() == QEvent::ChildAdded) { |
|
409 | if (event->type() == QEvent::ChildAdded) { | |
410 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
410 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
411 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
411 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
412 | } |
|
412 | } | |
413 | } |
|
413 | } | |
414 | } |
|
414 | } | |
415 |
|
415 | |||
416 | void DeclarativeChart::componentComplete() |
|
416 | void DeclarativeChart::componentComplete() | |
417 | { |
|
417 | { | |
418 | foreach (QObject *child, children()) { |
|
418 | foreach (QObject *child, children()) { | |
419 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
419 | if (qobject_cast<QAbstractSeries *>(child)) { | |
420 | // Add series to the chart |
|
420 | // Add series to the chart | |
421 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); |
|
421 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); | |
422 | m_chart->addSeries(series); |
|
422 | m_chart->addSeries(series); | |
423 |
|
423 | |||
424 | // Connect to axis changed signals (unless this is a pie series) |
|
424 | // Connect to axis changed signals (unless this is a pie series) | |
425 | if (!qobject_cast<DeclarativePieSeries *>(series)) { |
|
425 | if (!qobject_cast<DeclarativePieSeries *>(series)) { | |
426 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
426 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
427 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXTopSet(QAbstractAxis*))); |
|
427 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXTopSet(QAbstractAxis*))); | |
428 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
428 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
429 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); |
|
429 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); | |
430 | } |
|
430 | } | |
431 |
|
431 | |||
432 | initializeAxes(series); |
|
432 | initializeAxes(series); | |
433 | } |
|
433 | } | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | QQuickItem::componentComplete(); |
|
436 | QQuickItem::componentComplete(); | |
437 | } |
|
437 | } | |
438 |
|
438 | |||
439 | void DeclarativeChart::seriesAxisAttachHelper(QAbstractSeries *series, QAbstractAxis *axis, |
|
439 | void DeclarativeChart::seriesAxisAttachHelper(QAbstractSeries *series, QAbstractAxis *axis, | |
440 | Qt::Orientations orientation, |
|
440 | Qt::Orientations orientation, | |
441 | Qt::Alignment alignment) |
|
441 | Qt::Alignment alignment) | |
442 | { |
|
442 | { | |
443 | if (!series->attachedAxes().contains(axis)) { |
|
443 | if (!series->attachedAxes().contains(axis)) { | |
444 | // Remove & delete old axes that are not attached to any other series |
|
444 | // Remove & delete old axes that are not attached to any other series | |
445 | foreach (QAbstractAxis* oldAxis, m_chart->axes(orientation, series)) { |
|
445 | foreach (QAbstractAxis* oldAxis, m_chart->axes(orientation, series)) { | |
446 | bool otherAttachments = false; |
|
446 | bool otherAttachments = false; | |
447 | if (oldAxis != axis) { |
|
447 | if (oldAxis != axis) { | |
448 | foreach (QAbstractSeries *oldSeries, m_chart->series()) { |
|
448 | foreach (QAbstractSeries *oldSeries, m_chart->series()) { | |
449 | if (oldSeries != series && oldSeries->attachedAxes().contains(oldAxis)) { |
|
449 | if (oldSeries != series && oldSeries->attachedAxes().contains(oldAxis)) { | |
450 | otherAttachments = true; |
|
450 | otherAttachments = true; | |
451 | break; |
|
451 | break; | |
452 | } |
|
452 | } | |
453 | } |
|
453 | } | |
454 | if (!otherAttachments) { |
|
454 | if (!otherAttachments) { | |
455 | m_chart->removeAxis(oldAxis); |
|
455 | m_chart->removeAxis(oldAxis); | |
456 | delete oldAxis; |
|
456 | delete oldAxis; | |
457 | } |
|
457 | } | |
458 | } |
|
458 | } | |
459 | } |
|
459 | } | |
460 | if (!m_chart->axes(orientation).contains(axis)) |
|
460 | if (!m_chart->axes(orientation).contains(axis)) | |
461 | m_chart->addAxis(axis, alignment); |
|
461 | m_chart->addAxis(axis, alignment); | |
462 |
|
462 | |||
463 | series->attachAxis(axis); |
|
463 | series->attachAxis(axis); | |
464 | } |
|
464 | } | |
465 | } |
|
465 | } | |
466 |
|
466 | |||
467 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) |
|
467 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) | |
468 | { |
|
468 | { | |
469 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
469 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
470 | if (axis && s) { |
|
470 | if (axis && s) { | |
471 | seriesAxisAttachHelper(s, axis, Qt::Horizontal, Qt::AlignBottom); |
|
471 | seriesAxisAttachHelper(s, axis, Qt::Horizontal, Qt::AlignBottom); | |
472 | } else { |
|
472 | } else { | |
473 | qWarning() << "Trying to set axisX to null."; |
|
473 | qWarning() << "Trying to set axisX to null."; | |
474 | } |
|
474 | } | |
475 | } |
|
475 | } | |
476 |
|
476 | |||
477 | void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis) |
|
477 | void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis) | |
478 | { |
|
478 | { | |
479 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
479 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
480 | if (axis && s) { |
|
480 | if (axis && s) { | |
481 | seriesAxisAttachHelper(s, axis, Qt::Horizontal, Qt::AlignTop); |
|
481 | seriesAxisAttachHelper(s, axis, Qt::Horizontal, Qt::AlignTop); | |
482 | } else { |
|
482 | } else { | |
483 | qWarning() << "Trying to set axisXTop to null."; |
|
483 | qWarning() << "Trying to set axisXTop to null."; | |
484 | } |
|
484 | } | |
485 | } |
|
485 | } | |
486 |
|
486 | |||
487 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) |
|
487 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) | |
488 | { |
|
488 | { | |
489 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
489 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
490 | if (axis && s) { |
|
490 | if (axis && s) { | |
491 | seriesAxisAttachHelper(s, axis, Qt::Vertical, Qt::AlignLeft); |
|
491 | seriesAxisAttachHelper(s, axis, Qt::Vertical, Qt::AlignLeft); | |
492 | } else { |
|
492 | } else { | |
493 | qWarning() << "Trying to set axisY to null."; |
|
493 | qWarning() << "Trying to set axisY to null."; | |
494 | } |
|
494 | } | |
495 | } |
|
495 | } | |
496 |
|
496 | |||
497 | void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis) |
|
497 | void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis) | |
498 | { |
|
498 | { | |
499 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
499 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
500 | if (axis && s) { |
|
500 | if (axis && s) { | |
501 | seriesAxisAttachHelper(s, axis, Qt::Vertical, Qt::AlignRight); |
|
501 | seriesAxisAttachHelper(s, axis, Qt::Vertical, Qt::AlignRight); | |
502 | } else { |
|
502 | } else { | |
503 | qWarning() << "Trying to set axisYRight to null."; |
|
503 | qWarning() << "Trying to set axisYRight to null."; | |
504 | } |
|
504 | } | |
505 | } |
|
505 | } | |
506 |
|
506 | |||
507 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
507 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
508 | { |
|
508 | { | |
509 | if (newGeometry.isValid()) { |
|
509 | if (newGeometry.isValid()) { | |
510 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
510 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
511 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
511 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
512 | } |
|
512 | } | |
513 | } |
|
513 | } | |
514 | QQuickItem::geometryChanged(newGeometry, oldGeometry); |
|
514 | QQuickItem::geometryChanged(newGeometry, oldGeometry); | |
515 | } |
|
515 | } | |
516 |
|
516 | |||
517 | QSGNode *DeclarativeChart::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) |
|
517 | QSGNode *DeclarativeChart::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) | |
518 | { |
|
518 | { | |
519 | DeclarativeChartNode *node = static_cast<DeclarativeChartNode *>(oldNode); |
|
519 | DeclarativeChartNode *node = static_cast<DeclarativeChartNode *>(oldNode); | |
520 |
|
520 | |||
521 | if (!node) { |
|
521 | if (!node) { | |
522 | node = new DeclarativeChartNode(window()); |
|
522 | node = new DeclarativeChartNode(window()); | |
|
523 | if (node->glRenderNode()) { | |||
523 | connect(window(), &QQuickWindow::beforeRendering, |
|
524 | connect(window(), &QQuickWindow::beforeRendering, | |
524 | node->glRenderNode(), &DeclarativeRenderNode::render); |
|
525 | node->glRenderNode(), &DeclarativeRenderNode::render); | |
525 | } |
|
526 | } | |
|
527 | } | |||
526 |
|
528 | |||
527 | const QRectF &bRect = boundingRect(); |
|
529 | const QRectF &bRect = boundingRect(); | |
528 |
|
530 | |||
529 | // Update GL data |
|
531 | // Update GL data | |
530 | if (m_glXYDataManager->dataMap().size() || m_glXYDataManager->mapDirty()) { |
|
532 | if (node->glRenderNode() && (m_glXYDataManager->dataMap().size() || m_glXYDataManager->mapDirty())) { | |
531 | const QRectF &plotArea = m_chart->plotArea(); |
|
533 | const QRectF &plotArea = m_chart->plotArea(); | |
532 | const QSizeF &chartAreaSize = m_chart->size(); |
|
534 | const QSizeF &chartAreaSize = m_chart->size(); | |
533 |
|
535 | |||
534 | // We can't use chart's plot area directly, as graphicscene has some internal minimum size |
|
536 | // We can't use chart's plot area directly, as graphicscene has some internal minimum size | |
535 | const qreal normalizedX = plotArea.x() / chartAreaSize.width(); |
|
537 | const qreal normalizedX = plotArea.x() / chartAreaSize.width(); | |
536 | const qreal normalizedY = plotArea.y() / chartAreaSize.height(); |
|
538 | const qreal normalizedY = plotArea.y() / chartAreaSize.height(); | |
537 | const qreal normalizedWidth = plotArea.width() / chartAreaSize.width(); |
|
539 | const qreal normalizedWidth = plotArea.width() / chartAreaSize.width(); | |
538 | const qreal normalizedHeight = plotArea.height() / chartAreaSize.height(); |
|
540 | const qreal normalizedHeight = plotArea.height() / chartAreaSize.height(); | |
539 |
|
541 | |||
540 | QRectF adjustedPlotArea(normalizedX * bRect.width(), |
|
542 | QRectF adjustedPlotArea(normalizedX * bRect.width(), | |
541 | normalizedY * bRect.height(), |
|
543 | normalizedY * bRect.height(), | |
542 | normalizedWidth * bRect.width(), |
|
544 | normalizedWidth * bRect.width(), | |
543 | normalizedHeight * bRect.height()); |
|
545 | normalizedHeight * bRect.height()); | |
544 |
|
546 | |||
545 | const QSize &adjustedPlotSize = adjustedPlotArea.size().toSize(); |
|
547 | const QSize &adjustedPlotSize = adjustedPlotArea.size().toSize(); | |
546 | if (adjustedPlotSize != node->glRenderNode()->textureSize()) |
|
548 | if (adjustedPlotSize != node->glRenderNode()->textureSize()) | |
547 | node->glRenderNode()->setTextureSize(adjustedPlotSize); |
|
549 | node->glRenderNode()->setTextureSize(adjustedPlotSize); | |
548 |
|
550 | |||
549 | node->glRenderNode()->setRect(adjustedPlotArea); |
|
551 | node->glRenderNode()->setRect(adjustedPlotArea); | |
550 | node->glRenderNode()->setSeriesData(m_glXYDataManager->mapDirty(), |
|
552 | node->glRenderNode()->setSeriesData(m_glXYDataManager->mapDirty(), | |
551 | m_glXYDataManager->dataMap()); |
|
553 | m_glXYDataManager->dataMap()); | |
552 |
|
554 | |||
553 | // Clear dirty flags from original xy data |
|
555 | // Clear dirty flags from original xy data | |
554 | m_glXYDataManager->clearAllDirty(); |
|
556 | m_glXYDataManager->clearAllDirty(); | |
555 | } |
|
557 | } | |
556 |
|
558 | |||
557 | // Copy chart (if dirty) to chart node |
|
559 | // Copy chart (if dirty) to chart node | |
558 | if (m_sceneImageDirty) { |
|
560 | if (m_sceneImageDirty) { | |
559 | node->createTextureFromImage(*m_sceneImage); |
|
561 | node->createTextureFromImage(*m_sceneImage); | |
560 | m_sceneImageDirty = false; |
|
562 | m_sceneImageDirty = false; | |
561 | } |
|
563 | } | |
562 |
|
564 | |||
563 | node->setRect(bRect); |
|
565 | node->setRect(bRect); | |
564 |
|
566 | |||
565 | return node; |
|
567 | return node; | |
566 | } |
|
568 | } | |
567 |
|
569 | |||
568 | void DeclarativeChart::sceneChanged(QList<QRectF> region) |
|
570 | void DeclarativeChart::sceneChanged(QList<QRectF> region) | |
569 | { |
|
571 | { | |
570 | const int count = region.size(); |
|
572 | const int count = region.size(); | |
571 | const qreal limitSize = 0.01; |
|
573 | const qreal limitSize = 0.01; | |
572 | if (count && !m_updatePending) { |
|
574 | if (count && !m_updatePending) { | |
573 | qreal totalSize = 0.0; |
|
575 | qreal totalSize = 0.0; | |
574 | for (int i = 0; i < count; i++) { |
|
576 | for (int i = 0; i < count; i++) { | |
575 | const QRectF ® = region.at(i); |
|
577 | const QRectF ® = region.at(i); | |
576 | totalSize += (reg.height() * reg.width()); |
|
578 | totalSize += (reg.height() * reg.width()); | |
577 | if (totalSize >= limitSize) |
|
579 | if (totalSize >= limitSize) | |
578 | break; |
|
580 | break; | |
579 | } |
|
581 | } | |
580 | // Ignore region updates that change less than small fraction of a pixel, as there is |
|
582 | // Ignore region updates that change less than small fraction of a pixel, as there is | |
581 | // little point regenerating the image in these cases. These are typically cases |
|
583 | // little point regenerating the image in these cases. These are typically cases | |
582 | // where OpenGL series are drawn to otherwise static chart. |
|
584 | // where OpenGL series are drawn to otherwise static chart. | |
583 | if (totalSize >= limitSize) { |
|
585 | if (totalSize >= limitSize) { | |
584 | m_updatePending = true; |
|
586 | m_updatePending = true; | |
585 | // Do async render to avoid some unnecessary renders. |
|
587 | // Do async render to avoid some unnecessary renders. | |
586 | emit needRender(); |
|
588 | emit needRender(); | |
587 | } else { |
|
589 | } else { | |
588 | // We do want to call update to trigger possible gl series updates. |
|
590 | // We do want to call update to trigger possible gl series updates. | |
589 | update(); |
|
591 | update(); | |
590 | } |
|
592 | } | |
591 | } |
|
593 | } | |
592 | } |
|
594 | } | |
593 |
|
595 | |||
594 | void DeclarativeChart::renderScene() |
|
596 | void DeclarativeChart::renderScene() | |
595 | { |
|
597 | { | |
596 | m_updatePending = false; |
|
598 | m_updatePending = false; | |
597 | m_sceneImageDirty = true; |
|
599 | m_sceneImageDirty = true; | |
598 | QSize chartSize = m_chart->size().toSize(); |
|
600 | QSize chartSize = m_chart->size().toSize(); | |
599 | if (!m_sceneImage || chartSize != m_sceneImage->size()) { |
|
601 | if (!m_sceneImage || chartSize != m_sceneImage->size()) { | |
600 | delete m_sceneImage; |
|
602 | delete m_sceneImage; | |
601 | qreal dpr = window() ? window()->devicePixelRatio() : 1.0; |
|
603 | qreal dpr = window() ? window()->devicePixelRatio() : 1.0; | |
602 | m_sceneImage = new QImage(chartSize * dpr, QImage::Format_ARGB32); |
|
604 | m_sceneImage = new QImage(chartSize * dpr, QImage::Format_ARGB32); | |
603 | m_sceneImage->setDevicePixelRatio(dpr); |
|
605 | m_sceneImage->setDevicePixelRatio(dpr); | |
604 | m_sceneImageNeedsClear = true; |
|
606 | m_sceneImageNeedsClear = true; | |
605 | } |
|
607 | } | |
606 |
|
608 | |||
607 | if (m_sceneImageNeedsClear) { |
|
609 | if (m_sceneImageNeedsClear) { | |
608 | m_sceneImage->fill(Qt::transparent); |
|
610 | m_sceneImage->fill(Qt::transparent); | |
609 | // Don't clear the flag if chart background has any transparent element to it |
|
611 | // Don't clear the flag if chart background has any transparent element to it | |
610 | if (m_chart->backgroundBrush().color().alpha() == 0xff && !m_chart->isDropShadowEnabled()) |
|
612 | if (m_chart->backgroundBrush().color().alpha() == 0xff && !m_chart->isDropShadowEnabled()) | |
611 | m_sceneImageNeedsClear = false; |
|
613 | m_sceneImageNeedsClear = false; | |
612 | } |
|
614 | } | |
613 | QPainter painter(m_sceneImage); |
|
615 | QPainter painter(m_sceneImage); | |
614 | if (antialiasing()) { |
|
616 | if (antialiasing()) { | |
615 | painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing |
|
617 | painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | |
616 | | QPainter::SmoothPixmapTransform); |
|
618 | | QPainter::SmoothPixmapTransform); | |
617 | } |
|
619 | } | |
618 | QRect renderRect(QPoint(0, 0), chartSize); |
|
620 | QRect renderRect(QPoint(0, 0), chartSize); | |
619 | m_scene->render(&painter, renderRect, renderRect); |
|
621 | m_scene->render(&painter, renderRect, renderRect); | |
620 | update(); |
|
622 | update(); | |
621 | } |
|
623 | } | |
622 |
|
624 | |||
623 | void DeclarativeChart::mousePressEvent(QMouseEvent *event) |
|
625 | void DeclarativeChart::mousePressEvent(QMouseEvent *event) | |
624 | { |
|
626 | { | |
625 | m_mousePressScenePoint = event->pos(); |
|
627 | m_mousePressScenePoint = event->pos(); | |
626 | m_mousePressScreenPoint = event->globalPos(); |
|
628 | m_mousePressScreenPoint = event->globalPos(); | |
627 | m_lastMouseMoveScenePoint = m_mousePressScenePoint; |
|
629 | m_lastMouseMoveScenePoint = m_mousePressScenePoint; | |
628 | m_lastMouseMoveScreenPoint = m_mousePressScreenPoint; |
|
630 | m_lastMouseMoveScreenPoint = m_mousePressScreenPoint; | |
629 | m_mousePressButton = event->button(); |
|
631 | m_mousePressButton = event->button(); | |
630 | m_mousePressButtons = event->buttons(); |
|
632 | m_mousePressButtons = event->buttons(); | |
631 |
|
633 | |||
632 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMousePress); |
|
634 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMousePress); | |
633 | mouseEvent.setWidget(0); |
|
635 | mouseEvent.setWidget(0); | |
634 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); |
|
636 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); | |
635 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); |
|
637 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); | |
636 | mouseEvent.setScenePos(m_mousePressScenePoint); |
|
638 | mouseEvent.setScenePos(m_mousePressScenePoint); | |
637 | mouseEvent.setScreenPos(m_mousePressScreenPoint); |
|
639 | mouseEvent.setScreenPos(m_mousePressScreenPoint); | |
638 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); |
|
640 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); | |
639 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); |
|
641 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); | |
640 | mouseEvent.setButtons(m_mousePressButtons); |
|
642 | mouseEvent.setButtons(m_mousePressButtons); | |
641 | mouseEvent.setButton(m_mousePressButton); |
|
643 | mouseEvent.setButton(m_mousePressButton); | |
642 | mouseEvent.setModifiers(event->modifiers()); |
|
644 | mouseEvent.setModifiers(event->modifiers()); | |
643 | mouseEvent.setAccepted(false); |
|
645 | mouseEvent.setAccepted(false); | |
644 |
|
646 | |||
645 | QApplication::sendEvent(m_scene, &mouseEvent); |
|
647 | QApplication::sendEvent(m_scene, &mouseEvent); | |
646 | } |
|
648 | } | |
647 |
|
649 | |||
648 | void DeclarativeChart::mouseReleaseEvent(QMouseEvent *event) |
|
650 | void DeclarativeChart::mouseReleaseEvent(QMouseEvent *event) | |
649 | { |
|
651 | { | |
650 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseRelease); |
|
652 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseRelease); | |
651 | mouseEvent.setWidget(0); |
|
653 | mouseEvent.setWidget(0); | |
652 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); |
|
654 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); | |
653 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); |
|
655 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); | |
654 | mouseEvent.setScenePos(event->pos()); |
|
656 | mouseEvent.setScenePos(event->pos()); | |
655 | mouseEvent.setScreenPos(event->globalPos()); |
|
657 | mouseEvent.setScreenPos(event->globalPos()); | |
656 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); |
|
658 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); | |
657 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); |
|
659 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); | |
658 | mouseEvent.setButtons(event->buttons()); |
|
660 | mouseEvent.setButtons(event->buttons()); | |
659 | mouseEvent.setButton(event->button()); |
|
661 | mouseEvent.setButton(event->button()); | |
660 | mouseEvent.setModifiers(event->modifiers()); |
|
662 | mouseEvent.setModifiers(event->modifiers()); | |
661 | mouseEvent.setAccepted(false); |
|
663 | mouseEvent.setAccepted(false); | |
662 |
|
664 | |||
663 | QApplication::sendEvent(m_scene, &mouseEvent); |
|
665 | QApplication::sendEvent(m_scene, &mouseEvent); | |
664 |
|
666 | |||
665 | m_mousePressButtons = event->buttons(); |
|
667 | m_mousePressButtons = event->buttons(); | |
666 | m_mousePressButton = Qt::NoButton; |
|
668 | m_mousePressButton = Qt::NoButton; | |
667 | } |
|
669 | } | |
668 |
|
670 | |||
669 | void DeclarativeChart::hoverMoveEvent(QHoverEvent *event) |
|
671 | void DeclarativeChart::hoverMoveEvent(QHoverEvent *event) | |
670 | { |
|
672 | { | |
671 | // Convert hover move to mouse move, since we don't seem to get actual mouse move events. |
|
673 | // Convert hover move to mouse move, since we don't seem to get actual mouse move events. | |
672 | // QGraphicsScene generates hover events from mouse move events, so we don't need |
|
674 | // QGraphicsScene generates hover events from mouse move events, so we don't need | |
673 | // to pass hover events there. |
|
675 | // to pass hover events there. | |
674 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); |
|
676 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); | |
675 | mouseEvent.setWidget(0); |
|
677 | mouseEvent.setWidget(0); | |
676 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); |
|
678 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); | |
677 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); |
|
679 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); | |
678 | mouseEvent.setScenePos(event->pos()); |
|
680 | mouseEvent.setScenePos(event->pos()); | |
679 | // Hover events do not have global pos in them, and the screen position doesn't seem to |
|
681 | // Hover events do not have global pos in them, and the screen position doesn't seem to | |
680 | // matter anyway in this use case, so just pass event pos instead of trying to |
|
682 | // matter anyway in this use case, so just pass event pos instead of trying to | |
681 | // calculate the real screen position. |
|
683 | // calculate the real screen position. | |
682 | mouseEvent.setScreenPos(event->pos()); |
|
684 | mouseEvent.setScreenPos(event->pos()); | |
683 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); |
|
685 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); | |
684 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); |
|
686 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); | |
685 | mouseEvent.setButtons(m_mousePressButtons); |
|
687 | mouseEvent.setButtons(m_mousePressButtons); | |
686 | mouseEvent.setButton(m_mousePressButton); |
|
688 | mouseEvent.setButton(m_mousePressButton); | |
687 | mouseEvent.setModifiers(event->modifiers()); |
|
689 | mouseEvent.setModifiers(event->modifiers()); | |
688 | m_lastMouseMoveScenePoint = mouseEvent.scenePos(); |
|
690 | m_lastMouseMoveScenePoint = mouseEvent.scenePos(); | |
689 | m_lastMouseMoveScreenPoint = mouseEvent.screenPos(); |
|
691 | m_lastMouseMoveScreenPoint = mouseEvent.screenPos(); | |
690 | mouseEvent.setAccepted(false); |
|
692 | mouseEvent.setAccepted(false); | |
691 |
|
693 | |||
692 | QApplication::sendEvent(m_scene, &mouseEvent); |
|
694 | QApplication::sendEvent(m_scene, &mouseEvent); | |
693 | } |
|
695 | } | |
694 |
|
696 | |||
695 | void DeclarativeChart::mouseDoubleClickEvent(QMouseEvent *event) |
|
697 | void DeclarativeChart::mouseDoubleClickEvent(QMouseEvent *event) | |
696 | { |
|
698 | { | |
697 | m_mousePressScenePoint = event->pos(); |
|
699 | m_mousePressScenePoint = event->pos(); | |
698 | m_mousePressScreenPoint = event->globalPos(); |
|
700 | m_mousePressScreenPoint = event->globalPos(); | |
699 | m_lastMouseMoveScenePoint = m_mousePressScenePoint; |
|
701 | m_lastMouseMoveScenePoint = m_mousePressScenePoint; | |
700 | m_lastMouseMoveScreenPoint = m_mousePressScreenPoint; |
|
702 | m_lastMouseMoveScreenPoint = m_mousePressScreenPoint; | |
701 | m_mousePressButton = event->button(); |
|
703 | m_mousePressButton = event->button(); | |
702 | m_mousePressButtons = event->buttons(); |
|
704 | m_mousePressButtons = event->buttons(); | |
703 |
|
705 | |||
704 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseDoubleClick); |
|
706 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseDoubleClick); | |
705 | mouseEvent.setWidget(0); |
|
707 | mouseEvent.setWidget(0); | |
706 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); |
|
708 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); | |
707 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); |
|
709 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); | |
708 | mouseEvent.setScenePos(m_mousePressScenePoint); |
|
710 | mouseEvent.setScenePos(m_mousePressScenePoint); | |
709 | mouseEvent.setScreenPos(m_mousePressScreenPoint); |
|
711 | mouseEvent.setScreenPos(m_mousePressScreenPoint); | |
710 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); |
|
712 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); | |
711 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); |
|
713 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); | |
712 | mouseEvent.setButtons(m_mousePressButtons); |
|
714 | mouseEvent.setButtons(m_mousePressButtons); | |
713 | mouseEvent.setButton(m_mousePressButton); |
|
715 | mouseEvent.setButton(m_mousePressButton); | |
714 | mouseEvent.setModifiers(event->modifiers()); |
|
716 | mouseEvent.setModifiers(event->modifiers()); | |
715 | mouseEvent.setAccepted(false); |
|
717 | mouseEvent.setAccepted(false); | |
716 |
|
718 | |||
717 | QApplication::sendEvent(m_scene, &mouseEvent); |
|
719 | QApplication::sendEvent(m_scene, &mouseEvent); | |
718 | } |
|
720 | } | |
719 |
|
721 | |||
720 | void DeclarativeChart::handleAntialiasingChanged(bool enable) |
|
722 | void DeclarativeChart::handleAntialiasingChanged(bool enable) | |
721 | { |
|
723 | { | |
722 | setAntialiasing(enable); |
|
724 | setAntialiasing(enable); | |
723 | } |
|
725 | } | |
724 |
|
726 | |||
725 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
727 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
726 | { |
|
728 | { | |
727 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
729 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
728 | if (chartTheme != m_chart->theme()) |
|
730 | if (chartTheme != m_chart->theme()) | |
729 | m_chart->setTheme(chartTheme); |
|
731 | m_chart->setTheme(chartTheme); | |
730 | } |
|
732 | } | |
731 |
|
733 | |||
732 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
734 | DeclarativeChart::Theme DeclarativeChart::theme() | |
733 | { |
|
735 | { | |
734 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
736 | return (DeclarativeChart::Theme) m_chart->theme(); | |
735 | } |
|
737 | } | |
736 |
|
738 | |||
737 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
739 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
738 | { |
|
740 | { | |
739 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
741 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
740 | if (animationOptions != m_chart->animationOptions()) |
|
742 | if (animationOptions != m_chart->animationOptions()) | |
741 | m_chart->setAnimationOptions(animationOptions); |
|
743 | m_chart->setAnimationOptions(animationOptions); | |
742 | } |
|
744 | } | |
743 |
|
745 | |||
744 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
746 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
745 | { |
|
747 | { | |
746 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
748 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
747 | return DeclarativeChart::AllAnimations; |
|
749 | return DeclarativeChart::AllAnimations; | |
748 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
750 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
749 | return DeclarativeChart::GridAxisAnimations; |
|
751 | return DeclarativeChart::GridAxisAnimations; | |
750 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
752 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
751 | return DeclarativeChart::SeriesAnimations; |
|
753 | return DeclarativeChart::SeriesAnimations; | |
752 | else |
|
754 | else | |
753 | return DeclarativeChart::NoAnimation; |
|
755 | return DeclarativeChart::NoAnimation; | |
754 | } |
|
756 | } | |
755 |
|
757 | |||
756 | void DeclarativeChart::setAnimationDuration(int msecs) |
|
758 | void DeclarativeChart::setAnimationDuration(int msecs) | |
757 | { |
|
759 | { | |
758 | if (msecs != m_chart->animationDuration()) { |
|
760 | if (msecs != m_chart->animationDuration()) { | |
759 | m_chart->setAnimationDuration(msecs); |
|
761 | m_chart->setAnimationDuration(msecs); | |
760 | emit animationDurationChanged(msecs); |
|
762 | emit animationDurationChanged(msecs); | |
761 | } |
|
763 | } | |
762 | } |
|
764 | } | |
763 |
|
765 | |||
764 | int DeclarativeChart::animationDuration() const |
|
766 | int DeclarativeChart::animationDuration() const | |
765 | { |
|
767 | { | |
766 | return m_chart->animationDuration(); |
|
768 | return m_chart->animationDuration(); | |
767 | } |
|
769 | } | |
768 |
|
770 | |||
769 | void DeclarativeChart::setAnimationEasingCurve(const QEasingCurve &curve) |
|
771 | void DeclarativeChart::setAnimationEasingCurve(const QEasingCurve &curve) | |
770 | { |
|
772 | { | |
771 | if (curve != m_chart->animationEasingCurve()) { |
|
773 | if (curve != m_chart->animationEasingCurve()) { | |
772 | m_chart->setAnimationEasingCurve(curve); |
|
774 | m_chart->setAnimationEasingCurve(curve); | |
773 | emit animationEasingCurveChanged(curve); |
|
775 | emit animationEasingCurveChanged(curve); | |
774 | } |
|
776 | } | |
775 | } |
|
777 | } | |
776 |
|
778 | |||
777 | QEasingCurve DeclarativeChart::animationEasingCurve() const |
|
779 | QEasingCurve DeclarativeChart::animationEasingCurve() const | |
778 | { |
|
780 | { | |
779 | return m_chart->animationEasingCurve(); |
|
781 | return m_chart->animationEasingCurve(); | |
780 | } |
|
782 | } | |
781 |
|
783 | |||
782 | void DeclarativeChart::setTitle(QString title) |
|
784 | void DeclarativeChart::setTitle(QString title) | |
783 | { |
|
785 | { | |
784 | if (title != m_chart->title()) |
|
786 | if (title != m_chart->title()) | |
785 | m_chart->setTitle(title); |
|
787 | m_chart->setTitle(title); | |
786 | } |
|
788 | } | |
787 | QString DeclarativeChart::title() |
|
789 | QString DeclarativeChart::title() | |
788 | { |
|
790 | { | |
789 | return m_chart->title(); |
|
791 | return m_chart->title(); | |
790 | } |
|
792 | } | |
791 |
|
793 | |||
792 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
794 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) | |
793 | { |
|
795 | { | |
794 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series); |
|
796 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series); | |
795 | if (axes.count()) |
|
797 | if (axes.count()) | |
796 | return axes[0]; |
|
798 | return axes[0]; | |
797 | return 0; |
|
799 | return 0; | |
798 | } |
|
800 | } | |
799 |
|
801 | |||
800 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
802 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
801 | { |
|
803 | { | |
802 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series); |
|
804 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series); | |
803 | if (axes.count()) |
|
805 | if (axes.count()) | |
804 | return axes[0]; |
|
806 | return axes[0]; | |
805 | return 0; |
|
807 | return 0; | |
806 | } |
|
808 | } | |
807 |
|
809 | |||
808 | QLegend *DeclarativeChart::legend() |
|
810 | QLegend *DeclarativeChart::legend() | |
809 | { |
|
811 | { | |
810 | return m_chart->legend(); |
|
812 | return m_chart->legend(); | |
811 | } |
|
813 | } | |
812 |
|
814 | |||
813 | void DeclarativeChart::setTitleColor(QColor color) |
|
815 | void DeclarativeChart::setTitleColor(QColor color) | |
814 | { |
|
816 | { | |
815 | QBrush b = m_chart->titleBrush(); |
|
817 | QBrush b = m_chart->titleBrush(); | |
816 | if (color != b.color()) { |
|
818 | if (color != b.color()) { | |
817 | b.setColor(color); |
|
819 | b.setColor(color); | |
818 | m_chart->setTitleBrush(b); |
|
820 | m_chart->setTitleBrush(b); | |
819 | emit titleColorChanged(color); |
|
821 | emit titleColorChanged(color); | |
820 | } |
|
822 | } | |
821 | } |
|
823 | } | |
822 |
|
824 | |||
823 | QFont DeclarativeChart::titleFont() const |
|
825 | QFont DeclarativeChart::titleFont() const | |
824 | { |
|
826 | { | |
825 | return m_chart->titleFont(); |
|
827 | return m_chart->titleFont(); | |
826 | } |
|
828 | } | |
827 |
|
829 | |||
828 | void DeclarativeChart::setTitleFont(const QFont &font) |
|
830 | void DeclarativeChart::setTitleFont(const QFont &font) | |
829 | { |
|
831 | { | |
830 | m_chart->setTitleFont(font); |
|
832 | m_chart->setTitleFont(font); | |
831 | } |
|
833 | } | |
832 |
|
834 | |||
833 | QColor DeclarativeChart::titleColor() |
|
835 | QColor DeclarativeChart::titleColor() | |
834 | { |
|
836 | { | |
835 | return m_chart->titleBrush().color(); |
|
837 | return m_chart->titleBrush().color(); | |
836 | } |
|
838 | } | |
837 |
|
839 | |||
838 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
840 | void DeclarativeChart::setBackgroundColor(QColor color) | |
839 | { |
|
841 | { | |
840 | QBrush b = m_chart->backgroundBrush(); |
|
842 | QBrush b = m_chart->backgroundBrush(); | |
841 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
843 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
842 | if (color.alpha() < 0xff) |
|
844 | if (color.alpha() < 0xff) | |
843 | m_sceneImageNeedsClear = true; |
|
845 | m_sceneImageNeedsClear = true; | |
844 | b.setStyle(Qt::SolidPattern); |
|
846 | b.setStyle(Qt::SolidPattern); | |
845 | b.setColor(color); |
|
847 | b.setColor(color); | |
846 | m_chart->setBackgroundBrush(b); |
|
848 | m_chart->setBackgroundBrush(b); | |
847 | emit backgroundColorChanged(); |
|
849 | emit backgroundColorChanged(); | |
848 | } |
|
850 | } | |
849 | } |
|
851 | } | |
850 |
|
852 | |||
851 | QColor DeclarativeChart::backgroundColor() |
|
853 | QColor DeclarativeChart::backgroundColor() | |
852 | { |
|
854 | { | |
853 | return m_chart->backgroundBrush().color(); |
|
855 | return m_chart->backgroundBrush().color(); | |
854 | } |
|
856 | } | |
855 |
|
857 | |||
856 | void QtCharts::DeclarativeChart::setPlotAreaColor(QColor color) |
|
858 | void QtCharts::DeclarativeChart::setPlotAreaColor(QColor color) | |
857 | { |
|
859 | { | |
858 | QBrush b = m_chart->plotAreaBackgroundBrush(); |
|
860 | QBrush b = m_chart->plotAreaBackgroundBrush(); | |
859 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
861 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
860 | b.setStyle(Qt::SolidPattern); |
|
862 | b.setStyle(Qt::SolidPattern); | |
861 | b.setColor(color); |
|
863 | b.setColor(color); | |
862 | m_chart->setPlotAreaBackgroundBrush(b); |
|
864 | m_chart->setPlotAreaBackgroundBrush(b); | |
863 | m_chart->setPlotAreaBackgroundVisible(true); |
|
865 | m_chart->setPlotAreaBackgroundVisible(true); | |
864 | emit plotAreaColorChanged(); |
|
866 | emit plotAreaColorChanged(); | |
865 | } |
|
867 | } | |
866 | } |
|
868 | } | |
867 |
|
869 | |||
868 | QColor QtCharts::DeclarativeChart::plotAreaColor() |
|
870 | QColor QtCharts::DeclarativeChart::plotAreaColor() | |
869 | { |
|
871 | { | |
870 | return m_chart->plotAreaBackgroundBrush().color(); |
|
872 | return m_chart->plotAreaBackgroundBrush().color(); | |
871 | } |
|
873 | } | |
872 |
|
874 | |||
873 | void DeclarativeChart::setLocalizeNumbers(bool localize) |
|
875 | void DeclarativeChart::setLocalizeNumbers(bool localize) | |
874 | { |
|
876 | { | |
875 | if (m_chart->localizeNumbers() != localize) { |
|
877 | if (m_chart->localizeNumbers() != localize) { | |
876 | m_chart->setLocalizeNumbers(localize); |
|
878 | m_chart->setLocalizeNumbers(localize); | |
877 | emit localizeNumbersChanged(); |
|
879 | emit localizeNumbersChanged(); | |
878 | } |
|
880 | } | |
879 | } |
|
881 | } | |
880 |
|
882 | |||
881 | bool DeclarativeChart::localizeNumbers() const |
|
883 | bool DeclarativeChart::localizeNumbers() const | |
882 | { |
|
884 | { | |
883 | return m_chart->localizeNumbers(); |
|
885 | return m_chart->localizeNumbers(); | |
884 | } |
|
886 | } | |
885 |
|
887 | |||
886 | void QtCharts::DeclarativeChart::setLocale(const QLocale &locale) |
|
888 | void QtCharts::DeclarativeChart::setLocale(const QLocale &locale) | |
887 | { |
|
889 | { | |
888 | if (m_chart->locale() != locale) { |
|
890 | if (m_chart->locale() != locale) { | |
889 | m_chart->setLocale(locale); |
|
891 | m_chart->setLocale(locale); | |
890 | emit localeChanged(); |
|
892 | emit localeChanged(); | |
891 | } |
|
893 | } | |
892 | } |
|
894 | } | |
893 |
|
895 | |||
894 | QLocale QtCharts::DeclarativeChart::locale() const |
|
896 | QLocale QtCharts::DeclarativeChart::locale() const | |
895 | { |
|
897 | { | |
896 | return m_chart->locale(); |
|
898 | return m_chart->locale(); | |
897 | } |
|
899 | } | |
898 |
|
900 | |||
899 | int DeclarativeChart::count() |
|
901 | int DeclarativeChart::count() | |
900 | { |
|
902 | { | |
901 | return m_chart->series().count(); |
|
903 | return m_chart->series().count(); | |
902 | } |
|
904 | } | |
903 |
|
905 | |||
904 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
906 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
905 | { |
|
907 | { | |
906 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
908 | if (enabled != m_chart->isDropShadowEnabled()) { | |
907 | m_sceneImageNeedsClear = true; |
|
909 | m_sceneImageNeedsClear = true; | |
908 | m_chart->setDropShadowEnabled(enabled); |
|
910 | m_chart->setDropShadowEnabled(enabled); | |
909 | dropShadowEnabledChanged(enabled); |
|
911 | dropShadowEnabledChanged(enabled); | |
910 | } |
|
912 | } | |
911 | } |
|
913 | } | |
912 |
|
914 | |||
913 | bool DeclarativeChart::dropShadowEnabled() |
|
915 | bool DeclarativeChart::dropShadowEnabled() | |
914 | { |
|
916 | { | |
915 | return m_chart->isDropShadowEnabled(); |
|
917 | return m_chart->isDropShadowEnabled(); | |
916 | } |
|
918 | } | |
917 |
|
919 | |||
918 | qreal DeclarativeChart::backgroundRoundness() const |
|
920 | qreal DeclarativeChart::backgroundRoundness() const | |
919 | { |
|
921 | { | |
920 | return m_chart->backgroundRoundness(); |
|
922 | return m_chart->backgroundRoundness(); | |
921 | } |
|
923 | } | |
922 |
|
924 | |||
923 | void DeclarativeChart::setBackgroundRoundness(qreal diameter) |
|
925 | void DeclarativeChart::setBackgroundRoundness(qreal diameter) | |
924 | { |
|
926 | { | |
925 | if (m_chart->backgroundRoundness() != diameter) { |
|
927 | if (m_chart->backgroundRoundness() != diameter) { | |
926 | m_sceneImageNeedsClear = true; |
|
928 | m_sceneImageNeedsClear = true; | |
927 | m_chart->setBackgroundRoundness(diameter); |
|
929 | m_chart->setBackgroundRoundness(diameter); | |
928 | emit backgroundRoundnessChanged(diameter); |
|
930 | emit backgroundRoundnessChanged(diameter); | |
929 | } |
|
931 | } | |
930 | } |
|
932 | } | |
931 |
|
933 | |||
932 | void DeclarativeChart::zoom(qreal factor) |
|
934 | void DeclarativeChart::zoom(qreal factor) | |
933 | { |
|
935 | { | |
934 | m_chart->zoom(factor); |
|
936 | m_chart->zoom(factor); | |
935 | } |
|
937 | } | |
936 |
|
938 | |||
937 | void DeclarativeChart::zoomIn() |
|
939 | void DeclarativeChart::zoomIn() | |
938 | { |
|
940 | { | |
939 | m_chart->zoomIn(); |
|
941 | m_chart->zoomIn(); | |
940 | } |
|
942 | } | |
941 |
|
943 | |||
942 | void DeclarativeChart::zoomIn(const QRectF &rectangle) |
|
944 | void DeclarativeChart::zoomIn(const QRectF &rectangle) | |
943 | { |
|
945 | { | |
944 | m_chart->zoomIn(rectangle); |
|
946 | m_chart->zoomIn(rectangle); | |
945 | } |
|
947 | } | |
946 |
|
948 | |||
947 | void DeclarativeChart::zoomOut() |
|
949 | void DeclarativeChart::zoomOut() | |
948 | { |
|
950 | { | |
949 | m_chart->zoomOut(); |
|
951 | m_chart->zoomOut(); | |
950 | } |
|
952 | } | |
951 |
|
953 | |||
952 | void DeclarativeChart::zoomReset() |
|
954 | void DeclarativeChart::zoomReset() | |
953 | { |
|
955 | { | |
954 | m_chart->zoomReset(); |
|
956 | m_chart->zoomReset(); | |
955 | } |
|
957 | } | |
956 |
|
958 | |||
957 | bool DeclarativeChart::isZoomed() |
|
959 | bool DeclarativeChart::isZoomed() | |
958 | { |
|
960 | { | |
959 | return m_chart->isZoomed(); |
|
961 | return m_chart->isZoomed(); | |
960 | } |
|
962 | } | |
961 |
|
963 | |||
962 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
964 | void DeclarativeChart::scrollLeft(qreal pixels) | |
963 | { |
|
965 | { | |
964 | m_chart->scroll(-pixels, 0); |
|
966 | m_chart->scroll(-pixels, 0); | |
965 | } |
|
967 | } | |
966 |
|
968 | |||
967 | void DeclarativeChart::scrollRight(qreal pixels) |
|
969 | void DeclarativeChart::scrollRight(qreal pixels) | |
968 | { |
|
970 | { | |
969 | m_chart->scroll(pixels, 0); |
|
971 | m_chart->scroll(pixels, 0); | |
970 | } |
|
972 | } | |
971 |
|
973 | |||
972 | void DeclarativeChart::scrollUp(qreal pixels) |
|
974 | void DeclarativeChart::scrollUp(qreal pixels) | |
973 | { |
|
975 | { | |
974 | m_chart->scroll(0, pixels); |
|
976 | m_chart->scroll(0, pixels); | |
975 | } |
|
977 | } | |
976 |
|
978 | |||
977 | void DeclarativeChart::scrollDown(qreal pixels) |
|
979 | void DeclarativeChart::scrollDown(qreal pixels) | |
978 | { |
|
980 | { | |
979 | m_chart->scroll(0, -pixels); |
|
981 | m_chart->scroll(0, -pixels); | |
980 | } |
|
982 | } | |
981 |
|
983 | |||
982 | QQmlListProperty<QAbstractAxis> DeclarativeChart::axes() |
|
984 | QQmlListProperty<QAbstractAxis> DeclarativeChart::axes() | |
983 | { |
|
985 | { | |
984 | return QQmlListProperty<QAbstractAxis>(this, 0, |
|
986 | return QQmlListProperty<QAbstractAxis>(this, 0, | |
985 | &DeclarativeChart::axesAppendFunc, |
|
987 | &DeclarativeChart::axesAppendFunc, | |
986 | &DeclarativeChart::axesCountFunc, |
|
988 | &DeclarativeChart::axesCountFunc, | |
987 | &DeclarativeChart::axesAtFunc, |
|
989 | &DeclarativeChart::axesAtFunc, | |
988 | &DeclarativeChart::axesClearFunc); |
|
990 | &DeclarativeChart::axesClearFunc); | |
989 | } |
|
991 | } | |
990 |
|
992 | |||
991 | void DeclarativeChart::axesAppendFunc(QQmlListProperty<QAbstractAxis> *list, QAbstractAxis *element) |
|
993 | void DeclarativeChart::axesAppendFunc(QQmlListProperty<QAbstractAxis> *list, QAbstractAxis *element) | |
992 | { |
|
994 | { | |
993 | // Empty implementation |
|
995 | // Empty implementation | |
994 | Q_UNUSED(list); |
|
996 | Q_UNUSED(list); | |
995 | Q_UNUSED(element); |
|
997 | Q_UNUSED(element); | |
996 | } |
|
998 | } | |
997 |
|
999 | |||
998 | int DeclarativeChart::axesCountFunc(QQmlListProperty<QAbstractAxis> *list) |
|
1000 | int DeclarativeChart::axesCountFunc(QQmlListProperty<QAbstractAxis> *list) | |
999 | { |
|
1001 | { | |
1000 | if (qobject_cast<DeclarativeChart *>(list->object)) { |
|
1002 | if (qobject_cast<DeclarativeChart *>(list->object)) { | |
1001 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); |
|
1003 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); | |
1002 | return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count(); |
|
1004 | return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count(); | |
1003 | } |
|
1005 | } | |
1004 | return 0; |
|
1006 | return 0; | |
1005 | } |
|
1007 | } | |
1006 |
|
1008 | |||
1007 | QAbstractAxis *DeclarativeChart::axesAtFunc(QQmlListProperty<QAbstractAxis> *list, int index) |
|
1009 | QAbstractAxis *DeclarativeChart::axesAtFunc(QQmlListProperty<QAbstractAxis> *list, int index) | |
1008 | { |
|
1010 | { | |
1009 | if (qobject_cast<DeclarativeChart *>(list->object)) { |
|
1011 | if (qobject_cast<DeclarativeChart *>(list->object)) { | |
1010 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); |
|
1012 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); | |
1011 | QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]); |
|
1013 | QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]); | |
1012 | return axes.at(index); |
|
1014 | return axes.at(index); | |
1013 | } |
|
1015 | } | |
1014 | return 0; |
|
1016 | return 0; | |
1015 | } |
|
1017 | } | |
1016 |
|
1018 | |||
1017 | void DeclarativeChart::axesClearFunc(QQmlListProperty<QAbstractAxis> *list) |
|
1019 | void DeclarativeChart::axesClearFunc(QQmlListProperty<QAbstractAxis> *list) | |
1018 | { |
|
1020 | { | |
1019 | // Empty implementation |
|
1021 | // Empty implementation | |
1020 | Q_UNUSED(list); |
|
1022 | Q_UNUSED(list); | |
1021 | } |
|
1023 | } | |
1022 |
|
1024 | |||
1023 |
|
1025 | |||
1024 | QAbstractSeries *DeclarativeChart::series(int index) |
|
1026 | QAbstractSeries *DeclarativeChart::series(int index) | |
1025 | { |
|
1027 | { | |
1026 | if (index < m_chart->series().count()) { |
|
1028 | if (index < m_chart->series().count()) { | |
1027 | return m_chart->series().at(index); |
|
1029 | return m_chart->series().at(index); | |
1028 | } |
|
1030 | } | |
1029 | return 0; |
|
1031 | return 0; | |
1030 | } |
|
1032 | } | |
1031 |
|
1033 | |||
1032 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
1034 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
1033 | { |
|
1035 | { | |
1034 | foreach (QAbstractSeries *series, m_chart->series()) { |
|
1036 | foreach (QAbstractSeries *series, m_chart->series()) { | |
1035 | if (series->name() == seriesName) |
|
1037 | if (series->name() == seriesName) | |
1036 | return series; |
|
1038 | return series; | |
1037 | } |
|
1039 | } | |
1038 | return 0; |
|
1040 | return 0; | |
1039 | } |
|
1041 | } | |
1040 |
|
1042 | |||
1041 | QAbstractSeries *DeclarativeChart::createSeries(int type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) |
|
1043 | QAbstractSeries *DeclarativeChart::createSeries(int type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) | |
1042 | { |
|
1044 | { | |
1043 | QAbstractSeries *series = 0; |
|
1045 | QAbstractSeries *series = 0; | |
1044 |
|
1046 | |||
1045 | switch (type) { |
|
1047 | switch (type) { | |
1046 | case DeclarativeChart::SeriesTypeLine: |
|
1048 | case DeclarativeChart::SeriesTypeLine: | |
1047 | series = new DeclarativeLineSeries(); |
|
1049 | series = new DeclarativeLineSeries(); | |
1048 | break; |
|
1050 | break; | |
1049 | case DeclarativeChart::SeriesTypeArea: { |
|
1051 | case DeclarativeChart::SeriesTypeArea: { | |
1050 | DeclarativeAreaSeries *area = new DeclarativeAreaSeries(); |
|
1052 | DeclarativeAreaSeries *area = new DeclarativeAreaSeries(); | |
1051 | DeclarativeLineSeries *line = new DeclarativeLineSeries(); |
|
1053 | DeclarativeLineSeries *line = new DeclarativeLineSeries(); | |
1052 | line->setParent(area); |
|
1054 | line->setParent(area); | |
1053 | area->setUpperSeries(line); |
|
1055 | area->setUpperSeries(line); | |
1054 | series = area; |
|
1056 | series = area; | |
1055 | break; |
|
1057 | break; | |
1056 | } |
|
1058 | } | |
1057 | case DeclarativeChart::SeriesTypeStackedBar: |
|
1059 | case DeclarativeChart::SeriesTypeStackedBar: | |
1058 | series = new DeclarativeStackedBarSeries(); |
|
1060 | series = new DeclarativeStackedBarSeries(); | |
1059 | break; |
|
1061 | break; | |
1060 | case DeclarativeChart::SeriesTypePercentBar: |
|
1062 | case DeclarativeChart::SeriesTypePercentBar: | |
1061 | series = new DeclarativePercentBarSeries(); |
|
1063 | series = new DeclarativePercentBarSeries(); | |
1062 | break; |
|
1064 | break; | |
1063 | case DeclarativeChart::SeriesTypeBar: |
|
1065 | case DeclarativeChart::SeriesTypeBar: | |
1064 | series = new DeclarativeBarSeries(); |
|
1066 | series = new DeclarativeBarSeries(); | |
1065 | break; |
|
1067 | break; | |
1066 | case DeclarativeChart::SeriesTypeHorizontalBar: |
|
1068 | case DeclarativeChart::SeriesTypeHorizontalBar: | |
1067 | series = new DeclarativeHorizontalBarSeries(); |
|
1069 | series = new DeclarativeHorizontalBarSeries(); | |
1068 | break; |
|
1070 | break; | |
1069 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: |
|
1071 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: | |
1070 | series = new DeclarativeHorizontalPercentBarSeries(); |
|
1072 | series = new DeclarativeHorizontalPercentBarSeries(); | |
1071 | break; |
|
1073 | break; | |
1072 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: |
|
1074 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: | |
1073 | series = new DeclarativeHorizontalStackedBarSeries(); |
|
1075 | series = new DeclarativeHorizontalStackedBarSeries(); | |
1074 | break; |
|
1076 | break; | |
1075 | case DeclarativeChart::SeriesTypeBoxPlot: |
|
1077 | case DeclarativeChart::SeriesTypeBoxPlot: | |
1076 | series = new DeclarativeBoxPlotSeries(); |
|
1078 | series = new DeclarativeBoxPlotSeries(); | |
1077 | break; |
|
1079 | break; | |
1078 | case DeclarativeChart::SeriesTypePie: |
|
1080 | case DeclarativeChart::SeriesTypePie: | |
1079 | series = new DeclarativePieSeries(); |
|
1081 | series = new DeclarativePieSeries(); | |
1080 | break; |
|
1082 | break; | |
1081 | case DeclarativeChart::SeriesTypeScatter: |
|
1083 | case DeclarativeChart::SeriesTypeScatter: | |
1082 | series = new DeclarativeScatterSeries(); |
|
1084 | series = new DeclarativeScatterSeries(); | |
1083 | break; |
|
1085 | break; | |
1084 | case DeclarativeChart::SeriesTypeSpline: |
|
1086 | case DeclarativeChart::SeriesTypeSpline: | |
1085 | series = new DeclarativeSplineSeries(); |
|
1087 | series = new DeclarativeSplineSeries(); | |
1086 | break; |
|
1088 | break; | |
1087 | default: |
|
1089 | default: | |
1088 | qWarning() << "Illegal series type"; |
|
1090 | qWarning() << "Illegal series type"; | |
1089 | } |
|
1091 | } | |
1090 |
|
1092 | |||
1091 | if (series) { |
|
1093 | if (series) { | |
1092 | // Connect to axis changed signals (unless this is a pie series) |
|
1094 | // Connect to axis changed signals (unless this is a pie series) | |
1093 | if (!qobject_cast<DeclarativePieSeries *>(series)) { |
|
1095 | if (!qobject_cast<DeclarativePieSeries *>(series)) { | |
1094 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
1096 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
1095 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
1097 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
1096 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
1098 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
1097 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); |
|
1099 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); | |
1098 | } |
|
1100 | } | |
1099 |
|
1101 | |||
1100 | series->setName(name); |
|
1102 | series->setName(name); | |
1101 | m_chart->addSeries(series); |
|
1103 | m_chart->addSeries(series); | |
1102 |
|
1104 | |||
1103 | if (!axisX || !axisY) |
|
1105 | if (!axisX || !axisY) | |
1104 | initializeAxes(series); |
|
1106 | initializeAxes(series); | |
1105 |
|
1107 | |||
1106 | if (axisX) |
|
1108 | if (axisX) | |
1107 | setAxisX(axisX, series); |
|
1109 | setAxisX(axisX, series); | |
1108 | if (axisY) |
|
1110 | if (axisY) | |
1109 | setAxisY(axisY, series); |
|
1111 | setAxisY(axisY, series); | |
1110 | } |
|
1112 | } | |
1111 |
|
1113 | |||
1112 | return series; |
|
1114 | return series; | |
1113 | } |
|
1115 | } | |
1114 |
|
1116 | |||
1115 | void DeclarativeChart::removeSeries(QAbstractSeries *series) |
|
1117 | void DeclarativeChart::removeSeries(QAbstractSeries *series) | |
1116 | { |
|
1118 | { | |
1117 | if (series) |
|
1119 | if (series) | |
1118 | m_chart->removeSeries(series); |
|
1120 | m_chart->removeSeries(series); | |
1119 | else |
|
1121 | else | |
1120 | qWarning("removeSeries: cannot remove null"); |
|
1122 | qWarning("removeSeries: cannot remove null"); | |
1121 | } |
|
1123 | } | |
1122 |
|
1124 | |||
1123 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) |
|
1125 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) | |
1124 | { |
|
1126 | { | |
1125 | if (axis && series) |
|
1127 | if (axis && series) | |
1126 | seriesAxisAttachHelper(series, axis, Qt::Horizontal, Qt::AlignBottom); |
|
1128 | seriesAxisAttachHelper(series, axis, Qt::Horizontal, Qt::AlignBottom); | |
1127 | } |
|
1129 | } | |
1128 |
|
1130 | |||
1129 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) |
|
1131 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) | |
1130 | { |
|
1132 | { | |
1131 | if (axis && series) |
|
1133 | if (axis && series) | |
1132 | seriesAxisAttachHelper(series, axis, Qt::Vertical, Qt::AlignLeft); |
|
1134 | seriesAxisAttachHelper(series, axis, Qt::Vertical, Qt::AlignLeft); | |
1133 | } |
|
1135 | } | |
1134 |
|
1136 | |||
1135 | QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series) |
|
1137 | QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series) | |
1136 | { |
|
1138 | { | |
1137 | if (!series) { |
|
1139 | if (!series) { | |
1138 | qWarning() << "No axis type defined for null series"; |
|
1140 | qWarning() << "No axis type defined for null series"; | |
1139 | return 0; |
|
1141 | return 0; | |
1140 | } |
|
1142 | } | |
1141 |
|
1143 | |||
1142 | foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) { |
|
1144 | foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) { | |
1143 | if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation)) |
|
1145 | if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation)) | |
1144 | return existingAxis; |
|
1146 | return existingAxis; | |
1145 | } |
|
1147 | } | |
1146 |
|
1148 | |||
1147 | switch (series->d_ptr->defaultAxisType(orientation)) { |
|
1149 | switch (series->d_ptr->defaultAxisType(orientation)) { | |
1148 | case QAbstractAxis::AxisTypeValue: |
|
1150 | case QAbstractAxis::AxisTypeValue: | |
1149 | return new QValueAxis(this); |
|
1151 | return new QValueAxis(this); | |
1150 | case QAbstractAxis::AxisTypeBarCategory: |
|
1152 | case QAbstractAxis::AxisTypeBarCategory: | |
1151 | return new QBarCategoryAxis(this); |
|
1153 | return new QBarCategoryAxis(this); | |
1152 | case QAbstractAxis::AxisTypeCategory: |
|
1154 | case QAbstractAxis::AxisTypeCategory: | |
1153 | return new QCategoryAxis(this); |
|
1155 | return new QCategoryAxis(this); | |
1154 | #ifndef QT_QREAL_IS_FLOAT |
|
1156 | #ifndef QT_QREAL_IS_FLOAT | |
1155 | case QAbstractAxis::AxisTypeDateTime: |
|
1157 | case QAbstractAxis::AxisTypeDateTime: | |
1156 | return new QDateTimeAxis(this); |
|
1158 | return new QDateTimeAxis(this); | |
1157 | #endif |
|
1159 | #endif | |
1158 | case QAbstractAxis::AxisTypeLogValue: |
|
1160 | case QAbstractAxis::AxisTypeLogValue: | |
1159 | return new QLogValueAxis(this); |
|
1161 | return new QLogValueAxis(this); | |
1160 | default: |
|
1162 | default: | |
1161 | // assume AxisTypeNoAxis |
|
1163 | // assume AxisTypeNoAxis | |
1162 | return 0; |
|
1164 | return 0; | |
1163 | } |
|
1165 | } | |
1164 | } |
|
1166 | } | |
1165 |
|
1167 | |||
1166 | void DeclarativeChart::initializeAxes(QAbstractSeries *series) |
|
1168 | void DeclarativeChart::initializeAxes(QAbstractSeries *series) | |
1167 | { |
|
1169 | { | |
1168 | if (qobject_cast<DeclarativeLineSeries *>(series)) |
|
1170 | if (qobject_cast<DeclarativeLineSeries *>(series)) | |
1169 | doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes); |
|
1171 | doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes); | |
1170 | else if (qobject_cast<DeclarativeScatterSeries *>(series)) |
|
1172 | else if (qobject_cast<DeclarativeScatterSeries *>(series)) | |
1171 | doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes); |
|
1173 | doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes); | |
1172 | else if (qobject_cast<DeclarativeSplineSeries *>(series)) |
|
1174 | else if (qobject_cast<DeclarativeSplineSeries *>(series)) | |
1173 | doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes); |
|
1175 | doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes); | |
1174 | else if (qobject_cast<DeclarativeAreaSeries *>(series)) |
|
1176 | else if (qobject_cast<DeclarativeAreaSeries *>(series)) | |
1175 | doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes); |
|
1177 | doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes); | |
1176 | else if (qobject_cast<DeclarativeBarSeries *>(series)) |
|
1178 | else if (qobject_cast<DeclarativeBarSeries *>(series)) | |
1177 | doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes); |
|
1179 | doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes); | |
1178 | else if (qobject_cast<DeclarativeStackedBarSeries *>(series)) |
|
1180 | else if (qobject_cast<DeclarativeStackedBarSeries *>(series)) | |
1179 | doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes); |
|
1181 | doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes); | |
1180 | else if (qobject_cast<DeclarativePercentBarSeries *>(series)) |
|
1182 | else if (qobject_cast<DeclarativePercentBarSeries *>(series)) | |
1181 | doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes); |
|
1183 | doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes); | |
1182 | else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series)) |
|
1184 | else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series)) | |
1183 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes); |
|
1185 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes); | |
1184 | else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)) |
|
1186 | else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)) | |
1185 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes); |
|
1187 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes); | |
1186 | else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)) |
|
1188 | else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)) | |
1187 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes); |
|
1189 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes); | |
1188 | else if (qobject_cast<DeclarativeBoxPlotSeries *>(series)) |
|
1190 | else if (qobject_cast<DeclarativeBoxPlotSeries *>(series)) | |
1189 | doInitializeAxes(series, qobject_cast<DeclarativeBoxPlotSeries *>(series)->m_axes); |
|
1191 | doInitializeAxes(series, qobject_cast<DeclarativeBoxPlotSeries *>(series)->m_axes); | |
1190 | // else: do nothing |
|
1192 | // else: do nothing | |
1191 | } |
|
1193 | } | |
1192 |
|
1194 | |||
1193 | void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes) |
|
1195 | void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes) | |
1194 | { |
|
1196 | { | |
1195 | qreal min; |
|
1197 | qreal min; | |
1196 | qreal max; |
|
1198 | qreal max; | |
1197 | // Initialize axis X |
|
1199 | // Initialize axis X | |
1198 | if (axes->axisX()) { |
|
1200 | if (axes->axisX()) { | |
1199 | axes->emitAxisXChanged(); |
|
1201 | axes->emitAxisXChanged(); | |
1200 | } else if (axes->axisXTop()) { |
|
1202 | } else if (axes->axisXTop()) { | |
1201 | axes->emitAxisXTopChanged(); |
|
1203 | axes->emitAxisXTopChanged(); | |
1202 | } else { |
|
1204 | } else { | |
1203 | axes->setAxisX(defaultAxis(Qt::Horizontal, series)); |
|
1205 | axes->setAxisX(defaultAxis(Qt::Horizontal, series)); | |
1204 | findMinMaxForSeries(series, Qt::Horizontal, min, max); |
|
1206 | findMinMaxForSeries(series, Qt::Horizontal, min, max); | |
1205 | axes->axisX()->setRange(min, max); |
|
1207 | axes->axisX()->setRange(min, max); | |
1206 | } |
|
1208 | } | |
1207 |
|
1209 | |||
1208 | // Initialize axis Y |
|
1210 | // Initialize axis Y | |
1209 | if (axes->axisY()) { |
|
1211 | if (axes->axisY()) { | |
1210 | axes->emitAxisYChanged(); |
|
1212 | axes->emitAxisYChanged(); | |
1211 | } else if (axes->axisYRight()) { |
|
1213 | } else if (axes->axisYRight()) { | |
1212 | axes->emitAxisYRightChanged(); |
|
1214 | axes->emitAxisYRightChanged(); | |
1213 | } else { |
|
1215 | } else { | |
1214 | axes->setAxisY(defaultAxis(Qt::Vertical, series)); |
|
1216 | axes->setAxisY(defaultAxis(Qt::Vertical, series)); | |
1215 | findMinMaxForSeries(series, Qt::Vertical, min, max); |
|
1217 | findMinMaxForSeries(series, Qt::Vertical, min, max); | |
1216 | axes->axisY()->setRange(min, max); |
|
1218 | axes->axisY()->setRange(min, max); | |
1217 | } |
|
1219 | } | |
1218 | } |
|
1220 | } | |
1219 |
|
1221 | |||
1220 | void DeclarativeChart::findMinMaxForSeries(QAbstractSeries *series, Qt::Orientations orientation, |
|
1222 | void DeclarativeChart::findMinMaxForSeries(QAbstractSeries *series, Qt::Orientations orientation, | |
1221 | qreal &min, qreal &max) |
|
1223 | qreal &min, qreal &max) | |
1222 | { |
|
1224 | { | |
1223 | if (!series) { |
|
1225 | if (!series) { | |
1224 | min = 0.5; |
|
1226 | min = 0.5; | |
1225 | max = 0.5; |
|
1227 | max = 0.5; | |
1226 | } else { |
|
1228 | } else { | |
1227 | AbstractDomain *domain = series->d_ptr->domain(); |
|
1229 | AbstractDomain *domain = series->d_ptr->domain(); | |
1228 | min = (orientation == Qt::Vertical) ? domain->minY() : domain->minX(); |
|
1230 | min = (orientation == Qt::Vertical) ? domain->minY() : domain->minX(); | |
1229 | max = (orientation == Qt::Vertical) ? domain->maxY() : domain->maxX(); |
|
1231 | max = (orientation == Qt::Vertical) ? domain->maxY() : domain->maxX(); | |
1230 |
|
1232 | |||
1231 | if (min == max) { |
|
1233 | if (min == max) { | |
1232 | min -= 0.5; |
|
1234 | min -= 0.5; | |
1233 | max += 0.5; |
|
1235 | max += 0.5; | |
1234 | } |
|
1236 | } | |
1235 | } |
|
1237 | } | |
1236 | } |
|
1238 | } | |
1237 |
|
1239 | |||
1238 | QPointF DeclarativeChart::mapToValue(const QPointF &position, QAbstractSeries *series) |
|
1240 | QPointF DeclarativeChart::mapToValue(const QPointF &position, QAbstractSeries *series) | |
1239 | { |
|
1241 | { | |
1240 | return m_chart->mapToValue(position, series); |
|
1242 | return m_chart->mapToValue(position, series); | |
1241 | } |
|
1243 | } | |
1242 |
|
1244 | |||
1243 | QPointF DeclarativeChart::mapToPosition(const QPointF &value, QAbstractSeries *series) |
|
1245 | QPointF DeclarativeChart::mapToPosition(const QPointF &value, QAbstractSeries *series) | |
1244 | { |
|
1246 | { | |
1245 | return m_chart->mapToPosition(value, series); |
|
1247 | return m_chart->mapToPosition(value, series); | |
1246 | } |
|
1248 | } | |
1247 |
|
1249 | |||
1248 | #include "moc_declarativechart.cpp" |
|
1250 | #include "moc_declarativechart.cpp" | |
1249 |
|
1251 | |||
1250 | QT_CHARTS_END_NAMESPACE |
|
1252 | QT_CHARTS_END_NAMESPACE |
@@ -1,89 +1,89 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #include "declarativechartnode.h" |
|
30 | #include "declarativechartnode.h" | |
31 | #include "declarativerendernode.h" |
|
31 | #include "declarativerendernode.h" | |
32 | #include <QtGui/QOpenGLContext> |
|
32 | #include <QtGui/QOpenGLContext> | |
33 | #include <QtGui/QOpenGLFunctions> |
|
33 | #include <QtGui/QOpenGLFunctions> | |
34 | #include <QtGui/QOpenGLFramebufferObjectFormat> |
|
34 | #include <QtGui/QOpenGLFramebufferObjectFormat> | |
35 | #include <QtGui/QOpenGLFramebufferObject> |
|
35 | #include <QtGui/QOpenGLFramebufferObject> | |
36 | #include <QOpenGLShaderProgram> |
|
36 | #include <QOpenGLShaderProgram> | |
37 | #include <QtGui/QOpenGLBuffer> |
|
37 | #include <QtGui/QOpenGLBuffer> | |
38 |
|
38 | |||
39 | QT_CHARTS_BEGIN_NAMESPACE |
|
39 | QT_CHARTS_BEGIN_NAMESPACE | |
40 |
|
40 | |||
41 | // This node handles displaying of the chart itself |
|
41 | // This node handles displaying of the chart itself | |
42 | DeclarativeChartNode::DeclarativeChartNode(QQuickWindow *window) : |
|
42 | DeclarativeChartNode::DeclarativeChartNode(QQuickWindow *window) : | |
43 | QSGSimpleTextureNode(), |
|
43 | QSGSimpleTextureNode(), | |
44 | m_texture(0), |
|
44 | m_texture(0), | |
45 | m_window(window), |
|
45 | m_window(window), | |
46 | m_textureOptions(0), |
|
46 | m_textureOptions(0), | |
47 | m_textureSize(1, 1), |
|
47 | m_textureSize(1, 1), | |
48 | m_glRenderNode(0) |
|
48 | m_glRenderNode(0) | |
49 | { |
|
49 | { | |
50 | initializeOpenGLFunctions(); |
|
|||
51 |
|
||||
52 | // Our texture node must have a texture, so use a default one pixel texture |
|
50 | // Our texture node must have a texture, so use a default one pixel texture | |
53 | GLuint defaultTexture = 0; |
|
51 | QImage dummyImage(QSize(1, 1), QImage::Format_ARGB32); | |
54 | glGenTextures(1, &defaultTexture); |
|
52 | uchar *imageData = dummyImage.bits(); | |
55 | glBindTexture(GL_TEXTURE_2D, defaultTexture); |
|
53 | imageData[0] = 0; | |
56 | uchar buf[4] = { 0, 0, 0, 0 }; |
|
54 | imageData[1] = 0; | |
57 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &buf); |
|
55 | imageData[2] = 0; | |
58 |
|
56 | imageData[3] = 0; | ||
59 | QQuickWindow::CreateTextureOptions defaultTextureOptions = QQuickWindow::CreateTextureOptions( |
|
57 | QQuickWindow::CreateTextureOptions defaultTextureOptions = QQuickWindow::CreateTextureOptions( | |
60 | QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture); |
|
58 | QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture); | |
61 |
m_texture = m_window->createTextureFromI |
|
59 | m_texture = m_window->createTextureFromImage(dummyImage, defaultTextureOptions); | |
62 |
|
60 | |||
63 | setTexture(m_texture); |
|
61 | setTexture(m_texture); | |
64 | setFiltering(QSGTexture::Linear); |
|
62 | setFiltering(QSGTexture::Linear); | |
65 |
|
63 | |||
|
64 | if (QOpenGLContext::currentContext()) { | |||
66 | // Create child node for rendering GL graphics |
|
65 | // Create child node for rendering GL graphics | |
67 | m_glRenderNode = new DeclarativeRenderNode(m_window); |
|
66 | m_glRenderNode = new DeclarativeRenderNode(m_window); | |
68 | m_glRenderNode->setFlag(OwnedByParent); |
|
67 | m_glRenderNode->setFlag(OwnedByParent); | |
69 | appendChildNode(m_glRenderNode); |
|
68 | appendChildNode(m_glRenderNode); | |
70 | m_glRenderNode->setRect(0, 0, 0, 0); // Hide child node by default |
|
69 | m_glRenderNode->setRect(0, 0, 0, 0); // Hide child node by default | |
71 | } |
|
70 | } | |
|
71 | } | |||
72 |
|
72 | |||
73 | DeclarativeChartNode::~DeclarativeChartNode() |
|
73 | DeclarativeChartNode::~DeclarativeChartNode() | |
74 | { |
|
74 | { | |
75 | delete m_texture; |
|
75 | delete m_texture; | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | // Must be called on render thread and in context |
|
78 | // Must be called on render thread and in context | |
79 | void DeclarativeChartNode::createTextureFromImage(const QImage &chartImage) |
|
79 | void DeclarativeChartNode::createTextureFromImage(const QImage &chartImage) | |
80 | { |
|
80 | { | |
81 | if (chartImage.size() != m_textureSize) |
|
81 | if (chartImage.size() != m_textureSize) | |
82 | m_textureSize = chartImage.size(); |
|
82 | m_textureSize = chartImage.size(); | |
83 |
|
83 | |||
84 | delete m_texture; |
|
84 | delete m_texture; | |
85 | m_texture = m_window->createTextureFromImage(chartImage, m_textureOptions); |
|
85 | m_texture = m_window->createTextureFromImage(chartImage, m_textureOptions); | |
86 | setTexture(m_texture); |
|
86 | setTexture(m_texture); | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | QT_CHARTS_END_NAMESPACE |
|
89 | QT_CHARTS_END_NAMESPACE |
@@ -1,388 +1,388 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2016 The Qt Company Ltd. | |
4 | ** Contact: https://www.qt.io/licensing/ |
|
4 | ** Contact: https://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
8 | ** $QT_BEGIN_LICENSE:GPL$ | |
9 | ** Commercial License Usage |
|
9 | ** Commercial License Usage | |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
10 | ** Licensees holding valid commercial Qt licenses may use this file in | |
11 | ** accordance with the commercial license agreement provided with the |
|
11 | ** accordance with the commercial license agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
|
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 |
|
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. |
|
15 | ** information use the contact form at https://www.qt.io/contact-us. | |
16 | ** |
|
16 | ** | |
17 | ** GNU General Public License Usage |
|
17 | ** GNU General Public License Usage | |
18 | ** Alternatively, this file may be used under the terms of the GNU |
|
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 |
|
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 |
|
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 |
|
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | |
22 | ** included in the packaging of this file. Please review the following |
|
22 | ** included in the packaging of this file. Please review the following | |
23 | ** information to ensure the GNU General Public License requirements will |
|
23 | ** information to ensure the GNU General Public License requirements will | |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | |
25 | ** |
|
25 | ** | |
26 | ** $QT_END_LICENSE$ |
|
26 | ** $QT_END_LICENSE$ | |
27 | ** |
|
27 | ** | |
28 | ****************************************************************************/ |
|
28 | ****************************************************************************/ | |
29 |
|
29 | |||
30 | #include "mainwidget.h" |
|
30 | #include "mainwidget.h" | |
31 | #include "dataseriedialog.h" |
|
31 | #include "dataseriedialog.h" | |
32 | #include <QtCharts/QChartView> |
|
32 | #include <QtCharts/QChartView> | |
33 | #include <QtCharts/QPieSeries> |
|
33 | #include <QtCharts/QPieSeries> | |
34 | #include <QtCharts/QScatterSeries> |
|
34 | #include <QtCharts/QScatterSeries> | |
35 | #include <QtCharts/QLineSeries> |
|
35 | #include <QtCharts/QLineSeries> | |
36 | #include <QtCharts/QAreaSeries> |
|
36 | #include <QtCharts/QAreaSeries> | |
37 | #include <QtCharts/QSplineSeries> |
|
37 | #include <QtCharts/QSplineSeries> | |
38 | #include <QtCharts/QBarSet> |
|
38 | #include <QtCharts/QBarSet> | |
39 | #include <QtCharts/QBarSeries> |
|
39 | #include <QtCharts/QBarSeries> | |
40 | #include <QtCharts/QStackedBarSeries> |
|
40 | #include <QtCharts/QStackedBarSeries> | |
41 | #include <QtCharts/QPercentBarSeries> |
|
41 | #include <QtCharts/QPercentBarSeries> | |
42 | #include <QtWidgets/QPushButton> |
|
42 | #include <QtWidgets/QPushButton> | |
43 | #include <QtWidgets/QComboBox> |
|
43 | #include <QtWidgets/QComboBox> | |
44 | #include <QtWidgets/QSpinBox> |
|
44 | #include <QtWidgets/QSpinBox> | |
45 | #include <QtWidgets/QCheckBox> |
|
45 | #include <QtWidgets/QCheckBox> | |
46 | #include <QtWidgets/QGridLayout> |
|
46 | #include <QtWidgets/QGridLayout> | |
47 | #include <QtWidgets/QHBoxLayout> |
|
47 | #include <QtWidgets/QHBoxLayout> | |
48 | #include <QtWidgets/QLabel> |
|
48 | #include <QtWidgets/QLabel> | |
49 | #include <QtWidgets/QSpacerItem> |
|
49 | #include <QtWidgets/QSpacerItem> | |
50 | #include <QtWidgets/QMessageBox> |
|
50 | #include <QtWidgets/QMessageBox> | |
51 | #include <cmath> |
|
51 | #include <cmath> | |
52 | #include <QtCore/QDebug> |
|
52 | #include <QtCore/QDebug> | |
53 | #include <QtGui/QStandardItemModel> |
|
53 | #include <QtGui/QStandardItemModel> | |
54 | #include <QtCharts/QBarCategoryAxis> |
|
54 | #include <QtCharts/QBarCategoryAxis> | |
55 | #include <QtWidgets/QOpenGLWidget> |
|
55 | #include <QtWidgets/QOpenGLWidget> | |
56 |
|
56 | |||
57 | QT_CHARTS_USE_NAMESPACE |
|
57 | QT_CHARTS_USE_NAMESPACE | |
58 |
|
58 | |||
59 | MainWidget::MainWidget(QWidget *parent) : |
|
59 | MainWidget::MainWidget(QWidget *parent) : | |
60 | QWidget(parent), |
|
60 | QWidget(parent), | |
61 | m_addSerieDialog(0), |
|
61 | m_addSerieDialog(0), | |
62 | m_chart(0) |
|
62 | m_chart(0) | |
63 | { |
|
63 | { | |
64 | m_chart = new QChart(); |
|
64 | m_chart = new QChart(); | |
65 |
|
65 | |||
66 | // Grid layout for the controls for configuring the chart widget |
|
66 | // Grid layout for the controls for configuring the chart widget | |
67 | QGridLayout *grid = new QGridLayout(); |
|
67 | QGridLayout *grid = new QGridLayout(); | |
68 | QPushButton *addSeriesButton = new QPushButton("Add series"); |
|
68 | QPushButton *addSeriesButton = new QPushButton("Add series"); | |
69 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); |
|
69 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); | |
70 | grid->addWidget(addSeriesButton, 0, 1); |
|
70 | grid->addWidget(addSeriesButton, 0, 1); | |
71 | initBackroundCombo(grid); |
|
71 | initBackroundCombo(grid); | |
72 | initScaleControls(grid); |
|
72 | initScaleControls(grid); | |
73 | initThemeCombo(grid); |
|
73 | initThemeCombo(grid); | |
74 | initCheckboxes(grid); |
|
74 | initCheckboxes(grid); | |
75 |
|
75 | |||
76 | // add row with empty label to make all the other rows static |
|
76 | // add row with empty label to make all the other rows static | |
77 | grid->addWidget(new QLabel(""), grid->rowCount(), 0); |
|
77 | grid->addWidget(new QLabel(""), grid->rowCount(), 0); | |
78 | grid->setRowStretch(grid->rowCount() - 1, 1); |
|
78 | grid->setRowStretch(grid->rowCount() - 1, 1); | |
79 |
|
79 | |||
80 | // Create chart view with the chart |
|
80 | // Create chart view with the chart | |
81 | m_chartView = new QChartView(m_chart, this); |
|
81 | m_chartView = new QChartView(m_chart, this); | |
82 | m_chartView->setRubberBand(QChartView::HorizontalRubberBand); |
|
82 | m_chartView->setRubberBand(QChartView::HorizontalRubberBand); | |
83 |
|
83 | |||
84 | // Another grid layout as a main layout |
|
84 | // Another grid layout as a main layout | |
85 | QGridLayout *mainLayout = new QGridLayout(); |
|
85 | QGridLayout *mainLayout = new QGridLayout(); | |
86 | mainLayout->addLayout(grid, 0, 0); |
|
86 | mainLayout->addLayout(grid, 0, 0); | |
87 | mainLayout->addWidget(m_chartView, 0, 1, 3, 1); |
|
87 | mainLayout->addWidget(m_chartView, 0, 1, 3, 1); | |
88 | setLayout(mainLayout); |
|
88 | setLayout(mainLayout); | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | // Combo box for selecting the chart's background |
|
91 | // Combo box for selecting the chart's background | |
92 | void MainWidget::initBackroundCombo(QGridLayout *grid) |
|
92 | void MainWidget::initBackroundCombo(QGridLayout *grid) | |
93 | { |
|
93 | { | |
94 | QComboBox *backgroundCombo = new QComboBox(this); |
|
94 | QComboBox *backgroundCombo = new QComboBox(this); | |
95 | backgroundCombo->addItem("Color"); |
|
95 | backgroundCombo->addItem("Color"); | |
96 | backgroundCombo->addItem("Gradient"); |
|
96 | backgroundCombo->addItem("Gradient"); | |
97 | backgroundCombo->addItem("Image"); |
|
97 | backgroundCombo->addItem("Image"); | |
98 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), |
|
98 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), | |
99 | this, SLOT(backgroundChanged(int))); |
|
99 | this, SLOT(backgroundChanged(int))); | |
100 |
|
100 | |||
101 | grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0); |
|
101 | grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0); | |
102 | grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1); |
|
102 | grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1); | |
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | // Scale related controls (auto-scale vs. manual min-max values) |
|
105 | // Scale related controls (auto-scale vs. manual min-max values) | |
106 | void MainWidget::initScaleControls(QGridLayout *grid) |
|
106 | void MainWidget::initScaleControls(QGridLayout *grid) | |
107 | { |
|
107 | { | |
108 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); |
|
108 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); | |
109 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); |
|
109 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); | |
110 | // Allow setting also non-sense values (like -2147483648 and 2147483647) |
|
110 | // Allow setting also non-sense values (like -2147483648 and 2147483647) | |
111 | m_xMinSpin = new QSpinBox(); |
|
111 | m_xMinSpin = new QSpinBox(); | |
112 | m_xMinSpin->setMinimum(INT_MIN); |
|
112 | m_xMinSpin->setMinimum(INT_MIN); | |
113 | m_xMinSpin->setMaximum(INT_MAX); |
|
113 | m_xMinSpin->setMaximum(INT_MAX); | |
114 | m_xMinSpin->setValue(0); |
|
114 | m_xMinSpin->setValue(0); | |
115 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); |
|
115 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); | |
116 | m_xMaxSpin = new QSpinBox(); |
|
116 | m_xMaxSpin = new QSpinBox(); | |
117 | m_xMaxSpin->setMinimum(INT_MIN); |
|
117 | m_xMaxSpin->setMinimum(INT_MIN); | |
118 | m_xMaxSpin->setMaximum(INT_MAX); |
|
118 | m_xMaxSpin->setMaximum(INT_MAX); | |
119 | m_xMaxSpin->setValue(10); |
|
119 | m_xMaxSpin->setValue(10); | |
120 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); |
|
120 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); | |
121 | m_yMinSpin = new QSpinBox(); |
|
121 | m_yMinSpin = new QSpinBox(); | |
122 | m_yMinSpin->setMinimum(INT_MIN); |
|
122 | m_yMinSpin->setMinimum(INT_MIN); | |
123 | m_yMinSpin->setMaximum(INT_MAX); |
|
123 | m_yMinSpin->setMaximum(INT_MAX); | |
124 | m_yMinSpin->setValue(0); |
|
124 | m_yMinSpin->setValue(0); | |
125 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); |
|
125 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); | |
126 | m_yMaxSpin = new QSpinBox(); |
|
126 | m_yMaxSpin = new QSpinBox(); | |
127 | m_yMaxSpin->setMinimum(INT_MIN); |
|
127 | m_yMaxSpin->setMinimum(INT_MIN); | |
128 | m_yMaxSpin->setMaximum(INT_MAX); |
|
128 | m_yMaxSpin->setMaximum(INT_MAX); | |
129 | m_yMaxSpin->setValue(10); |
|
129 | m_yMaxSpin->setValue(10); | |
130 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); |
|
130 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); | |
131 |
|
131 | |||
132 | grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0); |
|
132 | grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0); | |
133 | grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0); |
|
133 | grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0); | |
134 | grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1); |
|
134 | grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1); | |
135 | grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0); |
|
135 | grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0); | |
136 | grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1); |
|
136 | grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1); | |
137 | grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0); |
|
137 | grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0); | |
138 | grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1); |
|
138 | grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1); | |
139 | grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0); |
|
139 | grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0); | |
140 | grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1); |
|
140 | grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1); | |
141 |
|
141 | |||
142 | m_autoScaleCheck->setChecked(true); |
|
142 | m_autoScaleCheck->setChecked(true); | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | // Combo box for selecting theme |
|
145 | // Combo box for selecting theme | |
146 | void MainWidget::initThemeCombo(QGridLayout *grid) |
|
146 | void MainWidget::initThemeCombo(QGridLayout *grid) | |
147 | { |
|
147 | { | |
148 | QComboBox *chartTheme = new QComboBox(); |
|
148 | QComboBox *chartTheme = new QComboBox(); | |
149 | chartTheme->addItem("Default"); |
|
149 | chartTheme->addItem("Default"); | |
150 | chartTheme->addItem("Light"); |
|
150 | chartTheme->addItem("Light"); | |
151 | chartTheme->addItem("Blue Cerulean"); |
|
151 | chartTheme->addItem("Blue Cerulean"); | |
152 | chartTheme->addItem("Dark"); |
|
152 | chartTheme->addItem("Dark"); | |
153 | chartTheme->addItem("Brown Sand"); |
|
153 | chartTheme->addItem("Brown Sand"); | |
154 | chartTheme->addItem("Blue NCS"); |
|
154 | chartTheme->addItem("Blue NCS"); | |
155 | chartTheme->addItem("High Contrast"); |
|
155 | chartTheme->addItem("High Contrast"); | |
156 | chartTheme->addItem("Blue Icy"); |
|
156 | chartTheme->addItem("Blue Icy"); | |
157 | chartTheme->addItem("Qt"); |
|
157 | chartTheme->addItem("Qt"); | |
158 | connect(chartTheme, SIGNAL(currentIndexChanged(int)), |
|
158 | connect(chartTheme, SIGNAL(currentIndexChanged(int)), | |
159 | this, SLOT(changeChartTheme(int))); |
|
159 | this, SLOT(changeChartTheme(int))); | |
160 | grid->addWidget(new QLabel("Chart theme:"), 8, 0); |
|
160 | grid->addWidget(new QLabel("Chart theme:"), 8, 0); | |
161 | grid->addWidget(chartTheme, 8, 1); |
|
161 | grid->addWidget(chartTheme, 8, 1); | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | // Different check boxes for customizing chart |
|
164 | // Different check boxes for customizing chart | |
165 | void MainWidget::initCheckboxes(QGridLayout *grid) |
|
165 | void MainWidget::initCheckboxes(QGridLayout *grid) | |
166 | { |
|
166 | { | |
167 | // TODO: setZoomEnabled slot has been removed from QChartView -> Re-implement zoom on/off |
|
167 | // TODO: setZoomEnabled slot has been removed from QChartView -> Re-implement zoom on/off | |
168 | QCheckBox *zoomCheckBox = new QCheckBox("Drag'n drop Zoom"); |
|
168 | QCheckBox *zoomCheckBox = new QCheckBox("Drag'n drop Zoom"); | |
169 | // connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartView, SLOT(setZoomEnabled(bool))); |
|
169 | // connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartView, SLOT(setZoomEnabled(bool))); | |
170 | zoomCheckBox->setChecked(true); |
|
170 | zoomCheckBox->setChecked(true); | |
171 | grid->addWidget(zoomCheckBox, grid->rowCount(), 0); |
|
171 | grid->addWidget(zoomCheckBox, grid->rowCount(), 0); | |
172 |
|
172 | |||
173 | QCheckBox *aliasCheckBox = new QCheckBox("Anti-alias"); |
|
173 | QCheckBox *aliasCheckBox = new QCheckBox("Anti-alias"); | |
174 | connect(aliasCheckBox, SIGNAL(toggled(bool)), this, SLOT(antiAliasToggled(bool))); |
|
174 | connect(aliasCheckBox, SIGNAL(toggled(bool)), this, SLOT(antiAliasToggled(bool))); | |
175 | aliasCheckBox->setChecked(false); |
|
175 | aliasCheckBox->setChecked(false); | |
176 | grid->addWidget(aliasCheckBox, grid->rowCount(), 0); |
|
176 | grid->addWidget(aliasCheckBox, grid->rowCount(), 0); | |
177 |
|
177 | |||
178 | QCheckBox *openGLCheckBox = new QCheckBox("Use QOpenGLWidget"); |
|
178 | QCheckBox *openGLCheckBox = new QCheckBox("Use QOpenGLWidget"); | |
179 | connect(openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(openGLToggled(bool))); |
|
179 | connect(openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(openGLToggled(bool))); | |
180 | openGLCheckBox->setChecked(false); |
|
180 | openGLCheckBox->setChecked(false); | |
181 | grid->addWidget(openGLCheckBox, grid->rowCount(), 0); |
|
181 | grid->addWidget(openGLCheckBox, grid->rowCount(), 0); | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | void MainWidget::antiAliasToggled(bool enabled) |
|
184 | void MainWidget::antiAliasToggled(bool enabled) | |
185 | { |
|
185 | { | |
186 | m_chartView->setRenderHint(QPainter::Antialiasing, enabled); |
|
186 | m_chartView->setRenderHint(QPainter::Antialiasing, enabled); | |
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 | void MainWidget::openGLToggled(bool enabled) |
|
189 | void MainWidget::openGLToggled(bool enabled) | |
190 | { |
|
190 | { | |
191 | if (enabled) { |
|
191 | if (enabled) { | |
192 | QSurfaceFormat f = QSurfaceFormat::defaultFormat(); |
|
192 | QSurfaceFormat f = QSurfaceFormat::defaultFormat(); | |
193 | f.setSamples(4); |
|
193 | f.setSamples(4); | |
194 | QSurfaceFormat::setDefaultFormat(f); |
|
194 | QSurfaceFormat::setDefaultFormat(f); | |
195 | QOpenGLWidget *g = new QOpenGLWidget(); |
|
195 | QOpenGLWidget *g = new QOpenGLWidget(); | |
196 | m_chartView->setViewport(g); |
|
196 | m_chartView->setViewport(g); | |
197 | } else { |
|
197 | } else { | |
198 | m_chartView->setViewport(0); |
|
198 | m_chartView->setViewport(0); | |
199 | } |
|
199 | } | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | void MainWidget::addSeries() |
|
202 | void MainWidget::addSeries() | |
203 | { |
|
203 | { | |
204 | if (!m_addSerieDialog) { |
|
204 | if (!m_addSerieDialog) { | |
205 | m_addSerieDialog = new DataSerieDialog(this); |
|
205 | m_addSerieDialog = new DataSerieDialog(this); | |
206 | connect(m_addSerieDialog, SIGNAL(accepted(QString,int,int,QString,bool)), |
|
206 | connect(m_addSerieDialog, SIGNAL(accepted(QString,int,int,QString,bool)), | |
207 | this, SLOT(addSeries(QString,int,int,QString,bool))); |
|
207 | this, SLOT(addSeries(QString,int,int,QString,bool))); | |
208 | } |
|
208 | } | |
209 | m_addSerieDialog->exec(); |
|
209 | m_addSerieDialog->exec(); | |
210 | } |
|
210 | } | |
211 |
|
211 | |||
212 | QList<RealList> MainWidget::generateTestData(int columnCount, int rowCount, QString dataCharacteristics) |
|
212 | QList<RealList> MainWidget::generateTestData(int columnCount, int rowCount, QString dataCharacteristics) | |
213 | { |
|
213 | { | |
214 | QList<RealList> testData; |
|
214 | QList<RealList> testData; | |
215 | for (int j(0); j < columnCount; j++) { |
|
215 | for (int j(0); j < columnCount; j++) { | |
216 | QList <qreal> newColumn; |
|
216 | QList <qreal> newColumn; | |
217 | for (int i(0); i < rowCount; i++) { |
|
217 | for (int i(0); i < rowCount; i++) { | |
218 | if (dataCharacteristics == "Sin") { |
|
218 | if (dataCharacteristics == "Sin") { | |
219 | newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100)); |
|
219 | newColumn.append(std::abs(sin(3.14159265358979 / 50 * i) * 100)); | |
220 | } else if (dataCharacteristics == "Sin + random") { |
|
220 | } else if (dataCharacteristics == "Sin + random") { | |
221 | newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); |
|
221 | newColumn.append(std::abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); | |
222 | } else if (dataCharacteristics == "Random") { |
|
222 | } else if (dataCharacteristics == "Random") { | |
223 | newColumn.append(rand() % 10 + (qreal) rand() / (qreal) RAND_MAX); |
|
223 | newColumn.append(rand() % 10 + (qreal) rand() / (qreal) RAND_MAX); | |
224 | } else if (dataCharacteristics == "Linear") { |
|
224 | } else if (dataCharacteristics == "Linear") { | |
225 | //newColumn.append(i * (j + 1.0)); |
|
225 | //newColumn.append(i * (j + 1.0)); | |
226 | // TODO: temporary hack to make pie work; prevent zero values: |
|
226 | // TODO: temporary hack to make pie work; prevent zero values: | |
227 | newColumn.append(i * (j + 1.0) + 0.1); |
|
227 | newColumn.append(i * (j + 1.0) + 0.1); | |
228 | } else { // "constant" |
|
228 | } else { // "constant" | |
229 | newColumn.append((j + 1.0)); |
|
229 | newColumn.append((j + 1.0)); | |
230 | } |
|
230 | } | |
231 | } |
|
231 | } | |
232 | testData.append(newColumn); |
|
232 | testData.append(newColumn); | |
233 | } |
|
233 | } | |
234 | return testData; |
|
234 | return testData; | |
235 | } |
|
235 | } | |
236 |
|
236 | |||
237 | QStringList MainWidget::generateLabels(int count) |
|
237 | QStringList MainWidget::generateLabels(int count) | |
238 | { |
|
238 | { | |
239 | QStringList result; |
|
239 | QStringList result; | |
240 | for (int i(0); i < count; i++) |
|
240 | for (int i(0); i < count; i++) | |
241 | result.append("label" + QString::number(i)); |
|
241 | result.append("label" + QString::number(i)); | |
242 | return result; |
|
242 | return result; | |
243 | } |
|
243 | } | |
244 |
|
244 | |||
245 | void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QString dataCharacteristics, bool labelsEnabled) |
|
245 | void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QString dataCharacteristics, bool labelsEnabled) | |
246 | { |
|
246 | { | |
247 | qDebug() << "addSeries: " << seriesName |
|
247 | qDebug() << "addSeries: " << seriesName | |
248 | << " columnCount: " << columnCount |
|
248 | << " columnCount: " << columnCount | |
249 | << " rowCount: " << rowCount |
|
249 | << " rowCount: " << rowCount | |
250 | << " dataCharacteristics: " << dataCharacteristics |
|
250 | << " dataCharacteristics: " << dataCharacteristics | |
251 | << " labels enabled: " << labelsEnabled; |
|
251 | << " labels enabled: " << labelsEnabled; | |
252 | m_defaultSeriesName = seriesName; |
|
252 | m_defaultSeriesName = seriesName; | |
253 |
|
253 | |||
254 | QList<RealList> data = generateTestData(columnCount, rowCount, dataCharacteristics); |
|
254 | QList<RealList> data = generateTestData(columnCount, rowCount, dataCharacteristics); | |
255 |
|
255 | |||
256 | // Line series and scatter series use similar data |
|
256 | // Line series and scatter series use similar data | |
257 | if (seriesName == "Line") { |
|
257 | if (seriesName == "Line") { | |
258 | for (int j(0); j < data.count(); j ++) { |
|
258 | for (int j(0); j < data.count(); j ++) { | |
259 | QList<qreal> column = data.at(j); |
|
259 | QList<qreal> column = data.at(j); | |
260 | QLineSeries *series = new QLineSeries(); |
|
260 | QLineSeries *series = new QLineSeries(); | |
261 | series->setName("line" + QString::number(j)); |
|
261 | series->setName("line" + QString::number(j)); | |
262 | for (int i(0); i < column.count(); i++) |
|
262 | for (int i(0); i < column.count(); i++) | |
263 | series->append(i, column.at(i)); |
|
263 | series->append(i, column.at(i)); | |
264 | m_chart->addSeries(series); |
|
264 | m_chart->addSeries(series); | |
265 | } |
|
265 | } | |
266 | } else if (seriesName == "Area") { |
|
266 | } else if (seriesName == "Area") { | |
267 | // TODO: lower series for the area? |
|
267 | // TODO: lower series for the area? | |
268 | for (int j(0); j < data.count(); j ++) { |
|
268 | for (int j(0); j < data.count(); j ++) { | |
269 | QList<qreal> column = data.at(j); |
|
269 | QList<qreal> column = data.at(j); | |
270 | QLineSeries *lineSeries = new QLineSeries(); |
|
270 | QLineSeries *lineSeries = new QLineSeries(); | |
271 | for (int i(0); i < column.count(); i++) |
|
271 | for (int i(0); i < column.count(); i++) | |
272 | lineSeries->append(i, column.at(i)); |
|
272 | lineSeries->append(i, column.at(i)); | |
273 | QAreaSeries *areaSeries = new QAreaSeries(lineSeries); |
|
273 | QAreaSeries *areaSeries = new QAreaSeries(lineSeries); | |
274 | areaSeries->setName("area" + QString::number(j)); |
|
274 | areaSeries->setName("area" + QString::number(j)); | |
275 | m_chart->addSeries(areaSeries); |
|
275 | m_chart->addSeries(areaSeries); | |
276 | } |
|
276 | } | |
277 | } else if (seriesName == "Scatter") { |
|
277 | } else if (seriesName == "Scatter") { | |
278 | for (int j(0); j < data.count(); j++) { |
|
278 | for (int j(0); j < data.count(); j++) { | |
279 | QList<qreal> column = data.at(j); |
|
279 | QList<qreal> column = data.at(j); | |
280 | QScatterSeries *series = new QScatterSeries(); |
|
280 | QScatterSeries *series = new QScatterSeries(); | |
281 | series->setName("scatter" + QString::number(j)); |
|
281 | series->setName("scatter" + QString::number(j)); | |
282 | for (int i(0); i < column.count(); i++) |
|
282 | for (int i(0); i < column.count(); i++) | |
283 | series->append(i, column.at(i)); |
|
283 | series->append(i, column.at(i)); | |
284 | m_chart->addSeries(series); |
|
284 | m_chart->addSeries(series); | |
285 | } |
|
285 | } | |
286 | } else if (seriesName == "Pie") { |
|
286 | } else if (seriesName == "Pie") { | |
287 | QStringList labels = generateLabels(rowCount); |
|
287 | QStringList labels = generateLabels(rowCount); | |
288 | for (int j(0); j < data.count(); j++) { |
|
288 | for (int j(0); j < data.count(); j++) { | |
289 | QPieSeries *series = new QPieSeries(); |
|
289 | QPieSeries *series = new QPieSeries(); | |
290 | QList<qreal> column = data.at(j); |
|
290 | QList<qreal> column = data.at(j); | |
291 | for (int i(0); i < column.count(); i++) |
|
291 | for (int i(0); i < column.count(); i++) | |
292 | series->append(labels.at(i), column.at(i)); |
|
292 | series->append(labels.at(i), column.at(i)); | |
293 | m_chart->addSeries(series); |
|
293 | m_chart->addSeries(series); | |
294 | } |
|
294 | } | |
295 | } else if (seriesName == "Bar" |
|
295 | } else if (seriesName == "Bar" | |
296 | || seriesName == "Stacked bar" |
|
296 | || seriesName == "Stacked bar" | |
297 | || seriesName == "Percent bar") { |
|
297 | || seriesName == "Percent bar") { | |
298 | QStringList category; |
|
298 | QStringList category; | |
299 | QStringList labels = generateLabels(rowCount); |
|
299 | QStringList labels = generateLabels(rowCount); | |
300 | foreach (QString label, labels) |
|
300 | foreach (QString label, labels) | |
301 | category << label; |
|
301 | category << label; | |
302 | QAbstractBarSeries* series = 0; |
|
302 | QAbstractBarSeries* series = 0; | |
303 | if (seriesName == "Bar") { |
|
303 | if (seriesName == "Bar") { | |
304 | series = new QBarSeries(this); |
|
304 | series = new QBarSeries(this); | |
305 | QBarCategoryAxis* axis = new QBarCategoryAxis(); |
|
305 | QBarCategoryAxis* axis = new QBarCategoryAxis(); | |
306 | axis->append(category); |
|
306 | axis->append(category); | |
307 | m_chart->setAxisX(axis,series); |
|
307 | m_chart->setAxisX(axis,series); | |
308 | } else if (seriesName == "Stacked bar") { |
|
308 | } else if (seriesName == "Stacked bar") { | |
309 | series = new QStackedBarSeries(this); |
|
309 | series = new QStackedBarSeries(this); | |
310 | QBarCategoryAxis* axis = new QBarCategoryAxis(); |
|
310 | QBarCategoryAxis* axis = new QBarCategoryAxis(); | |
311 | axis->append(category); |
|
311 | axis->append(category); | |
312 | m_chart->setAxisX(axis,series); |
|
312 | m_chart->setAxisX(axis,series); | |
313 | } else { |
|
313 | } else { | |
314 | series = new QPercentBarSeries(this); |
|
314 | series = new QPercentBarSeries(this); | |
315 | QBarCategoryAxis* axis = new QBarCategoryAxis(); |
|
315 | QBarCategoryAxis* axis = new QBarCategoryAxis(); | |
316 | axis->append(category); |
|
316 | axis->append(category); | |
317 | m_chart->setAxisX(axis,series); |
|
317 | m_chart->setAxisX(axis,series); | |
318 | } |
|
318 | } | |
319 |
|
319 | |||
320 | for (int j(0); j < data.count(); j++) { |
|
320 | for (int j(0); j < data.count(); j++) { | |
321 | QList<qreal> column = data.at(j); |
|
321 | QList<qreal> column = data.at(j); | |
322 | QBarSet *set = new QBarSet("set" + QString::number(j)); |
|
322 | QBarSet *set = new QBarSet("set" + QString::number(j)); | |
323 | for (int i(0); i < column.count(); i++) |
|
323 | for (int i(0); i < column.count(); i++) | |
324 | *set << column.at(i); |
|
324 | *set << column.at(i); | |
325 | series->append(set); |
|
325 | series->append(set); | |
326 | } |
|
326 | } | |
327 |
|
327 | |||
328 | m_chart->addSeries(series); |
|
328 | m_chart->addSeries(series); | |
329 | } else if (seriesName == "Spline") { |
|
329 | } else if (seriesName == "Spline") { | |
330 | for (int j(0); j < data.count(); j ++) { |
|
330 | for (int j(0); j < data.count(); j ++) { | |
331 | QList<qreal> column = data.at(j); |
|
331 | QList<qreal> column = data.at(j); | |
332 | QSplineSeries *series = new QSplineSeries(); |
|
332 | QSplineSeries *series = new QSplineSeries(); | |
333 | series->setName("spline" + QString::number(j)); |
|
333 | series->setName("spline" + QString::number(j)); | |
334 | for (int i(0); i < column.count(); i++) |
|
334 | for (int i(0); i < column.count(); i++) | |
335 | series->append(i, column.at(i)); |
|
335 | series->append(i, column.at(i)); | |
336 | m_chart->addSeries(series); |
|
336 | m_chart->addSeries(series); | |
337 | } |
|
337 | } | |
338 | } |
|
338 | } | |
339 | m_chart->createDefaultAxes(); |
|
339 | m_chart->createDefaultAxes(); | |
340 | } |
|
340 | } | |
341 |
|
341 | |||
342 | void MainWidget::backgroundChanged(int itemIndex) |
|
342 | void MainWidget::backgroundChanged(int itemIndex) | |
343 | { |
|
343 | { | |
344 | qDebug() << "backgroundChanged: " << itemIndex; |
|
344 | qDebug() << "backgroundChanged: " << itemIndex; | |
345 | } |
|
345 | } | |
346 |
|
346 | |||
347 | void MainWidget::autoScaleChanged(int value) |
|
347 | void MainWidget::autoScaleChanged(int value) | |
348 | { |
|
348 | { | |
349 | if (value) { |
|
349 | if (value) { | |
350 | // TODO: enable auto scaling |
|
350 | // TODO: enable auto scaling | |
351 | } else { |
|
351 | } else { | |
352 | // TODO: set scaling manually (and disable auto scaling) |
|
352 | // TODO: set scaling manually (and disable auto scaling) | |
353 | } |
|
353 | } | |
354 |
|
354 | |||
355 | m_xMinSpin->setEnabled(!value); |
|
355 | m_xMinSpin->setEnabled(!value); | |
356 | m_xMaxSpin->setEnabled(!value); |
|
356 | m_xMaxSpin->setEnabled(!value); | |
357 | m_yMinSpin->setEnabled(!value); |
|
357 | m_yMinSpin->setEnabled(!value); | |
358 | m_yMaxSpin->setEnabled(!value); |
|
358 | m_yMaxSpin->setEnabled(!value); | |
359 | } |
|
359 | } | |
360 |
|
360 | |||
361 | void MainWidget::xMinChanged(int value) |
|
361 | void MainWidget::xMinChanged(int value) | |
362 | { |
|
362 | { | |
363 | qDebug() << "xMinChanged: " << value; |
|
363 | qDebug() << "xMinChanged: " << value; | |
364 | } |
|
364 | } | |
365 |
|
365 | |||
366 | void MainWidget::xMaxChanged(int value) |
|
366 | void MainWidget::xMaxChanged(int value) | |
367 | { |
|
367 | { | |
368 | qDebug() << "xMaxChanged: " << value; |
|
368 | qDebug() << "xMaxChanged: " << value; | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | void MainWidget::yMinChanged(int value) |
|
371 | void MainWidget::yMinChanged(int value) | |
372 | { |
|
372 | { | |
373 | qDebug() << "yMinChanged: " << value; |
|
373 | qDebug() << "yMinChanged: " << value; | |
374 | } |
|
374 | } | |
375 |
|
375 | |||
376 | void MainWidget::yMaxChanged(int value) |
|
376 | void MainWidget::yMaxChanged(int value) | |
377 | { |
|
377 | { | |
378 | qDebug() << "yMaxChanged: " << value; |
|
378 | qDebug() << "yMaxChanged: " << value; | |
379 | } |
|
379 | } | |
380 |
|
380 | |||
381 | void MainWidget::changeChartTheme(int themeIndex) |
|
381 | void MainWidget::changeChartTheme(int themeIndex) | |
382 | { |
|
382 | { | |
383 | qDebug() << "changeChartTheme: " << themeIndex; |
|
383 | qDebug() << "changeChartTheme: " << themeIndex; | |
384 | if (themeIndex == 0) |
|
384 | if (themeIndex == 0) | |
385 | m_chart->setTheme(QChart::ChartThemeLight); |
|
385 | m_chart->setTheme(QChart::ChartThemeLight); | |
386 | else |
|
386 | else | |
387 | m_chart->setTheme((QChart::ChartTheme) (themeIndex - 1)); |
|
387 | m_chart->setTheme((QChart::ChartTheme) (themeIndex - 1)); | |
388 | } |
|
388 | } |
General Comments 0
You need to be logged in to leave comments.
Login now