@@ -1,70 +1,70 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativeareaseries.h" |
|
21 | #include "declarativeareaseries.h" | |
22 | #include "declarativelineseries.h" |
|
22 | #include "declarativelineseries.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : |
|
26 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : | |
27 | QAreaSeries(parent), |
|
27 | QAreaSeries(parent), | |
28 | m_axisX(0), |
|
28 | m_axisX(0), | |
29 | m_axisY(0) |
|
29 | m_axisY(0) | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 |
void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* |
|
33 | void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries *series) | |
34 | { |
|
34 | { | |
35 | QAreaSeries::setUpperSeries(series); |
|
35 | QAreaSeries::setUpperSeries(series); | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 |
DeclarativeLineSeries* |
|
38 | DeclarativeLineSeries *DeclarativeAreaSeries::upperSeries() const | |
39 | { |
|
39 | { | |
40 | return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries()); |
|
40 | return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries()); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 |
void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* |
|
43 | void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries *series) | |
44 | { |
|
44 | { | |
45 | QAreaSeries::setLowerSeries(series); |
|
45 | QAreaSeries::setLowerSeries(series); | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 |
DeclarativeLineSeries* |
|
48 | DeclarativeLineSeries *DeclarativeAreaSeries::lowerSeries() const | |
49 | { |
|
49 | { | |
50 | return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries()); |
|
50 | return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries()); | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | qreal DeclarativeAreaSeries::borderWidth() const |
|
53 | qreal DeclarativeAreaSeries::borderWidth() const | |
54 | { |
|
54 | { | |
55 | return pen().widthF(); |
|
55 | return pen().widthF(); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | void DeclarativeAreaSeries::setBorderWidth(qreal width) |
|
58 | void DeclarativeAreaSeries::setBorderWidth(qreal width) | |
59 | { |
|
59 | { | |
60 | if (width != pen().widthF()) { |
|
60 | if (width != pen().widthF()) { | |
61 | QPen p = pen(); |
|
61 | QPen p = pen(); | |
62 | p.setWidthF(width); |
|
62 | p.setWidthF(width); | |
63 | setPen(p); |
|
63 | setPen(p); | |
64 | emit borderWidthChanged(width); |
|
64 | emit borderWidthChanged(width); | |
65 | } |
|
65 | } | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | #include "moc_declarativeareaseries.cpp" |
|
68 | #include "moc_declarativeareaseries.cpp" | |
69 |
|
69 | |||
70 | QTCOMMERCIALCHART_END_NAMESPACE |
|
70 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,63 +1,63 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVEAREASERIES_H |
|
21 | #ifndef DECLARATIVEAREASERIES_H | |
22 | #define DECLARATIVEAREASERIES_H |
|
22 | #define DECLARATIVEAREASERIES_H | |
23 |
|
23 | |||
24 | #include "qareaseries.h" |
|
24 | #include "qareaseries.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 | class DeclarativeLineSeries; |
|
27 | class DeclarativeLineSeries; | |
28 |
|
28 | |||
29 | class DeclarativeAreaSeries : public QAreaSeries |
|
29 | class DeclarativeAreaSeries : public QAreaSeries | |
30 | { |
|
30 | { | |
31 | Q_OBJECT |
|
31 | Q_OBJECT | |
32 | Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries) |
|
32 | Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries) | |
33 | Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) |
|
33 | Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) | |
34 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
34 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
35 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
35 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
36 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) |
|
36 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) | |
37 |
|
37 | |||
38 | public: |
|
38 | public: | |
39 | explicit DeclarativeAreaSeries(QObject *parent = 0); |
|
39 | explicit DeclarativeAreaSeries(QObject *parent = 0); | |
40 |
void setUpperSeries(DeclarativeLineSeries* |
|
40 | void setUpperSeries(DeclarativeLineSeries *series); | |
41 |
DeclarativeLineSeries* |
|
41 | DeclarativeLineSeries *upperSeries() const; | |
42 |
void setLowerSeries(DeclarativeLineSeries* |
|
42 | void setLowerSeries(DeclarativeLineSeries *series); | |
43 |
DeclarativeLineSeries* |
|
43 | DeclarativeLineSeries *lowerSeries() const; | |
44 | QAbstractAxis *axisX() { return m_axisX; } |
|
44 | QAbstractAxis *axisX() { return m_axisX; } | |
45 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
45 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
46 | QAbstractAxis *axisY() { return m_axisY; } |
|
46 | QAbstractAxis *axisY() { return m_axisY; } | |
47 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
47 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
48 | qreal borderWidth() const; |
|
48 | qreal borderWidth() const; | |
49 | void setBorderWidth(qreal borderWidth); |
|
49 | void setBorderWidth(qreal borderWidth); | |
50 |
|
50 | |||
51 | Q_SIGNALS: |
|
51 | Q_SIGNALS: | |
52 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
52 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
53 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
53 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
54 | Q_REVISION(1) void borderWidthChanged(qreal width); |
|
54 | Q_REVISION(1) void borderWidthChanged(qreal width); | |
55 |
|
55 | |||
56 | private: |
|
56 | private: | |
57 | QAbstractAxis *m_axisX; |
|
57 | QAbstractAxis *m_axisX; | |
58 | QAbstractAxis *m_axisY; |
|
58 | QAbstractAxis *m_axisY; | |
59 | }; |
|
59 | }; | |
60 |
|
60 | |||
61 | QTCOMMERCIALCHART_END_NAMESPACE |
|
61 | QTCOMMERCIALCHART_END_NAMESPACE | |
62 |
|
62 | |||
63 | #endif // DECLARATIVEAREASERIES_H |
|
63 | #endif // DECLARATIVEAREASERIES_H |
@@ -1,433 +1,433 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativebarseries.h" |
|
21 | #include "declarativebarseries.h" | |
22 | #include "qbarset.h" |
|
22 | #include "qbarset.h" | |
23 | #include "qvbarmodelmapper.h" |
|
23 | #include "qvbarmodelmapper.h" | |
24 | #include "qhbarmodelmapper.h" |
|
24 | #include "qhbarmodelmapper.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 |
DeclarativeBarSet::DeclarativeBarSet(QObject *parent) |
|
28 | DeclarativeBarSet::DeclarativeBarSet(QObject *parent) | |
29 | QBarSet("", parent) |
|
29 | : QBarSet("", parent) | |
30 | { |
|
30 | { | |
31 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int))); |
|
31 | connect(this, SIGNAL(valuesAdded(int,int)), this, SLOT(handleCountChanged(int,int))); | |
32 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int))); |
|
32 | connect(this, SIGNAL(valuesRemoved(int,int)), this, SLOT(handleCountChanged(int,int))); | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | void DeclarativeBarSet::handleCountChanged(int index, int count) |
|
35 | void DeclarativeBarSet::handleCountChanged(int index, int count) | |
36 | { |
|
36 | { | |
37 | Q_UNUSED(index) |
|
37 | Q_UNUSED(index) | |
38 | Q_UNUSED(count) |
|
38 | Q_UNUSED(count) | |
39 | emit countChanged(QBarSet::count()); |
|
39 | emit countChanged(QBarSet::count()); | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | qreal DeclarativeBarSet::borderWidth() const |
|
42 | qreal DeclarativeBarSet::borderWidth() const | |
43 | { |
|
43 | { | |
44 | return pen().widthF(); |
|
44 | return pen().widthF(); | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | void DeclarativeBarSet::setBorderWidth(qreal width) |
|
47 | void DeclarativeBarSet::setBorderWidth(qreal width) | |
48 | { |
|
48 | { | |
49 | if (width != pen().widthF()) { |
|
49 | if (width != pen().widthF()) { | |
50 | QPen p = pen(); |
|
50 | QPen p = pen(); | |
51 | p.setWidthF(width); |
|
51 | p.setWidthF(width); | |
52 | setPen(p); |
|
52 | setPen(p); | |
53 | emit borderWidthChanged(width); |
|
53 | emit borderWidthChanged(width); | |
54 | } |
|
54 | } | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | QVariantList DeclarativeBarSet::values() |
|
57 | QVariantList DeclarativeBarSet::values() | |
58 | { |
|
58 | { | |
59 | QVariantList values; |
|
59 | QVariantList values; | |
60 | for (int i(0); i < count(); i++) |
|
60 | for (int i(0); i < count(); i++) | |
61 | values.append(QVariant(QBarSet::at(i))); |
|
61 | values.append(QVariant(QBarSet::at(i))); | |
62 | return values; |
|
62 | return values; | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | void DeclarativeBarSet::setValues(QVariantList values) |
|
65 | void DeclarativeBarSet::setValues(QVariantList values) | |
66 | { |
|
66 | { | |
67 | while (count()) |
|
67 | while (count()) | |
68 | remove(count() - 1); |
|
68 | remove(count() - 1); | |
69 |
|
69 | |||
70 | for (int i(0); i < values.count(); i++) { |
|
70 | for (int i(0); i < values.count(); i++) { | |
71 | if (values.at(i).canConvert(QVariant::Double)) |
|
71 | if (values.at(i).canConvert(QVariant::Double)) | |
72 | QBarSet::append(values[i].toDouble()); |
|
72 | QBarSet::append(values[i].toDouble()); | |
73 | } |
|
73 | } | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | // Declarative bar series ====================================================================================== |
|
76 | // Declarative bar series ====================================================================================== | |
77 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
77 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : | |
78 | QBarSeries(parent), |
|
78 | QBarSeries(parent), | |
79 | m_axisX(0), |
|
79 | m_axisX(0), | |
80 | m_axisY(0) |
|
80 | m_axisY(0) | |
81 | { |
|
81 | { | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | void DeclarativeBarSeries::classBegin() |
|
84 | void DeclarativeBarSeries::classBegin() | |
85 | { |
|
85 | { | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | void DeclarativeBarSeries::componentComplete() |
|
88 | void DeclarativeBarSeries::componentComplete() | |
89 | { |
|
89 | { | |
90 | foreach (QObject *child, children()) { |
|
90 | foreach (QObject *child, children()) { | |
91 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
91 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
92 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
92 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
93 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
93 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
94 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
94 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
95 | mapper->setSeries(this); |
|
95 | mapper->setSeries(this); | |
96 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
96 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
97 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
97 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
98 | mapper->setSeries(this); |
|
98 | mapper->setSeries(this); | |
99 | } |
|
99 | } | |
100 | } |
|
100 | } | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren() |
|
103 | QDeclarativeListProperty<QObject> DeclarativeBarSeries::seriesChildren() | |
104 | { |
|
104 | { | |
105 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
105 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
108 | void DeclarativeBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
109 | { |
|
109 | { | |
110 | // Empty implementation; the children are parsed in componentComplete instead |
|
110 | // Empty implementation; the children are parsed in componentComplete instead | |
111 | Q_UNUSED(list); |
|
111 | Q_UNUSED(list); | |
112 | Q_UNUSED(element); |
|
112 | Q_UNUSED(element); | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) |
|
115 | DeclarativeBarSet *DeclarativeBarSeries::at(int index) | |
116 | { |
|
116 | { | |
117 | QList<QBarSet*> setList = barSets(); |
|
117 | QList<QBarSet *> setList = barSets(); | |
118 | if (index >= 0 && index < setList.count()) |
|
118 | if (index >= 0 && index < setList.count()) | |
119 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
119 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
120 |
|
120 | |||
121 | return 0; |
|
121 | return 0; | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) |
|
124 | DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVariantList values) | |
125 | { |
|
125 | { | |
126 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
126 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
127 | barset->setLabel(label); |
|
127 | barset->setLabel(label); | |
128 | barset->setValues(values); |
|
128 | barset->setValues(values); | |
129 | if (QBarSeries::insert(index, barset)) |
|
129 | if (QBarSeries::insert(index, barset)) | |
130 | return barset; |
|
130 | return barset; | |
131 | delete barset; |
|
131 | delete barset; | |
132 | return 0; |
|
132 | return 0; | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | // Declarative stacked bar series ============================================================================== |
|
135 | // Declarative stacked bar series ============================================================================== | |
136 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : |
|
136 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : | |
137 | QStackedBarSeries(parent), |
|
137 | QStackedBarSeries(parent), | |
138 | m_axisX(0), |
|
138 | m_axisX(0), | |
139 | m_axisY(0) |
|
139 | m_axisY(0) | |
140 | { |
|
140 | { | |
141 | } |
|
141 | } | |
142 |
|
142 | |||
143 | void DeclarativeStackedBarSeries::classBegin() |
|
143 | void DeclarativeStackedBarSeries::classBegin() | |
144 | { |
|
144 | { | |
145 | } |
|
145 | } | |
146 |
|
146 | |||
147 | void DeclarativeStackedBarSeries::componentComplete() |
|
147 | void DeclarativeStackedBarSeries::componentComplete() | |
148 | { |
|
148 | { | |
149 | foreach (QObject *child, children()) { |
|
149 | foreach (QObject *child, children()) { | |
150 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
150 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
151 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
151 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
152 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
152 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
153 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
153 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
154 | mapper->setSeries(this); |
|
154 | mapper->setSeries(this); | |
155 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
155 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
156 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
156 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
157 | mapper->setSeries(this); |
|
157 | mapper->setSeries(this); | |
158 | } |
|
158 | } | |
159 | } |
|
159 | } | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 |
|
162 | |||
163 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() |
|
163 | QDeclarativeListProperty<QObject> DeclarativeStackedBarSeries::seriesChildren() | |
164 | { |
|
164 | { | |
165 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
165 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
168 | void DeclarativeStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
169 | { |
|
169 | { | |
170 | // Empty implementation; the children are parsed in componentComplete instead |
|
170 | // Empty implementation; the children are parsed in componentComplete instead | |
171 | Q_UNUSED(list); |
|
171 | Q_UNUSED(list); | |
172 | Q_UNUSED(element); |
|
172 | Q_UNUSED(element); | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) |
|
175 | DeclarativeBarSet *DeclarativeStackedBarSeries::at(int index) | |
176 | { |
|
176 | { | |
177 | QList<QBarSet*> setList = barSets(); |
|
177 | QList<QBarSet *> setList = barSets(); | |
178 | if (index >= 0 && index < setList.count()) |
|
178 | if (index >= 0 && index < setList.count()) | |
179 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
179 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
180 |
|
180 | |||
181 | return 0; |
|
181 | return 0; | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) |
|
184 | DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, QVariantList values) | |
185 | { |
|
185 | { | |
186 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
186 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
187 | barset->setLabel(label); |
|
187 | barset->setLabel(label); | |
188 | barset->setValues(values); |
|
188 | barset->setValues(values); | |
189 | if (QStackedBarSeries::insert(index, barset)) |
|
189 | if (QStackedBarSeries::insert(index, barset)) | |
190 | return barset; |
|
190 | return barset; | |
191 | delete barset; |
|
191 | delete barset; | |
192 | return 0; |
|
192 | return 0; | |
193 | } |
|
193 | } | |
194 |
|
194 | |||
195 | // Declarative percent bar series ============================================================================== |
|
195 | // Declarative percent bar series ============================================================================== | |
196 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : |
|
196 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : | |
197 | QPercentBarSeries(parent), |
|
197 | QPercentBarSeries(parent), | |
198 | m_axisX(0), |
|
198 | m_axisX(0), | |
199 | m_axisY(0) |
|
199 | m_axisY(0) | |
200 | { |
|
200 | { | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | void DeclarativePercentBarSeries::classBegin() |
|
203 | void DeclarativePercentBarSeries::classBegin() | |
204 | { |
|
204 | { | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | void DeclarativePercentBarSeries::componentComplete() |
|
207 | void DeclarativePercentBarSeries::componentComplete() | |
208 | { |
|
208 | { | |
209 | foreach (QObject *child, children()) { |
|
209 | foreach (QObject *child, children()) { | |
210 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
210 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
211 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
211 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
212 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
212 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
213 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
213 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
214 | mapper->setSeries(this); |
|
214 | mapper->setSeries(this); | |
215 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
215 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
216 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
216 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
217 | mapper->setSeries(this); |
|
217 | mapper->setSeries(this); | |
218 | } |
|
218 | } | |
219 | } |
|
219 | } | |
220 | } |
|
220 | } | |
221 |
|
221 | |||
222 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() |
|
222 | QDeclarativeListProperty<QObject> DeclarativePercentBarSeries::seriesChildren() | |
223 | { |
|
223 | { | |
224 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); |
|
224 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeBarSeries::appendSeriesChildren); | |
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
227 | void DeclarativePercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
228 | { |
|
228 | { | |
229 | // Empty implementation; the children are parsed in componentComplete instead |
|
229 | // Empty implementation; the children are parsed in componentComplete instead | |
230 | Q_UNUSED(list); |
|
230 | Q_UNUSED(list); | |
231 | Q_UNUSED(element); |
|
231 | Q_UNUSED(element); | |
232 | } |
|
232 | } | |
233 |
|
233 | |||
234 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) |
|
234 | DeclarativeBarSet *DeclarativePercentBarSeries::at(int index) | |
235 | { |
|
235 | { | |
236 | QList<QBarSet*> setList = barSets(); |
|
236 | QList<QBarSet *> setList = barSets(); | |
237 | if (index >= 0 && index < setList.count()) |
|
237 | if (index >= 0 && index < setList.count()) | |
238 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
238 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
239 |
|
239 | |||
240 | return 0; |
|
240 | return 0; | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) |
|
243 | DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, QVariantList values) | |
244 | { |
|
244 | { | |
245 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
245 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
246 | barset->setLabel(label); |
|
246 | barset->setLabel(label); | |
247 | barset->setValues(values); |
|
247 | barset->setValues(values); | |
248 | if (QPercentBarSeries::insert(index, barset)) |
|
248 | if (QPercentBarSeries::insert(index, barset)) | |
249 | return barset; |
|
249 | return barset; | |
250 | delete barset; |
|
250 | delete barset; | |
251 | return 0; |
|
251 | return 0; | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | // Declarative horizontal bar series =========================================================================== |
|
254 | // Declarative horizontal bar series =========================================================================== | |
255 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) : |
|
255 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) : | |
256 | QHorizontalBarSeries(parent), |
|
256 | QHorizontalBarSeries(parent), | |
257 | m_axisX(0), |
|
257 | m_axisX(0), | |
258 | m_axisY(0) |
|
258 | m_axisY(0) | |
259 | { |
|
259 | { | |
260 | } |
|
260 | } | |
261 |
|
261 | |||
262 | void DeclarativeHorizontalBarSeries::classBegin() |
|
262 | void DeclarativeHorizontalBarSeries::classBegin() | |
263 | { |
|
263 | { | |
264 | } |
|
264 | } | |
265 |
|
265 | |||
266 | void DeclarativeHorizontalBarSeries::componentComplete() |
|
266 | void DeclarativeHorizontalBarSeries::componentComplete() | |
267 | { |
|
267 | { | |
268 | foreach (QObject *child, children()) { |
|
268 | foreach (QObject *child, children()) { | |
269 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
269 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
270 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
270 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
271 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
271 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
272 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
272 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
273 | mapper->setSeries(this); |
|
273 | mapper->setSeries(this); | |
274 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
274 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
275 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
275 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
276 | mapper->setSeries(this); |
|
276 | mapper->setSeries(this); | |
277 | } |
|
277 | } | |
278 | } |
|
278 | } | |
279 | } |
|
279 | } | |
280 |
|
280 | |||
281 | QDeclarativeListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren() |
|
281 | QDeclarativeListProperty<QObject> DeclarativeHorizontalBarSeries::seriesChildren() | |
282 | { |
|
282 | { | |
283 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren); |
|
283 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalBarSeries::appendSeriesChildren); | |
284 | } |
|
284 | } | |
285 |
|
285 | |||
286 | void DeclarativeHorizontalBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
286 | void DeclarativeHorizontalBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
287 | { |
|
287 | { | |
288 | // Empty implementation; the children are parsed in componentComplete instead |
|
288 | // Empty implementation; the children are parsed in componentComplete instead | |
289 | Q_UNUSED(list); |
|
289 | Q_UNUSED(list); | |
290 | Q_UNUSED(element); |
|
290 | Q_UNUSED(element); | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index) |
|
293 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::at(int index) | |
294 | { |
|
294 | { | |
295 | QList<QBarSet*> setList = barSets(); |
|
295 | QList<QBarSet *> setList = barSets(); | |
296 | if (index >= 0 && index < setList.count()) |
|
296 | if (index >= 0 && index < setList.count()) | |
297 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
297 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
298 |
|
298 | |||
299 | return 0; |
|
299 | return 0; | |
300 | } |
|
300 | } | |
301 |
|
301 | |||
302 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values) |
|
302 | DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString label, QVariantList values) | |
303 | { |
|
303 | { | |
304 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
304 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
305 | barset->setLabel(label); |
|
305 | barset->setLabel(label); | |
306 | barset->setValues(values); |
|
306 | barset->setValues(values); | |
307 | if (QHorizontalBarSeries::insert(index, barset)) |
|
307 | if (QHorizontalBarSeries::insert(index, barset)) | |
308 | return barset; |
|
308 | return barset; | |
309 | delete barset; |
|
309 | delete barset; | |
310 | return 0; |
|
310 | return 0; | |
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | // Declarative horizontal stacked bar series =================================================================== |
|
313 | // Declarative horizontal stacked bar series =================================================================== | |
314 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) : |
|
314 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) : | |
315 | QHorizontalStackedBarSeries(parent), |
|
315 | QHorizontalStackedBarSeries(parent), | |
316 | m_axisX(0), |
|
316 | m_axisX(0), | |
317 | m_axisY(0) |
|
317 | m_axisY(0) | |
318 | { |
|
318 | { | |
319 | } |
|
319 | } | |
320 |
|
320 | |||
321 | void DeclarativeHorizontalStackedBarSeries::classBegin() |
|
321 | void DeclarativeHorizontalStackedBarSeries::classBegin() | |
322 | { |
|
322 | { | |
323 | } |
|
323 | } | |
324 |
|
324 | |||
325 | void DeclarativeHorizontalStackedBarSeries::componentComplete() |
|
325 | void DeclarativeHorizontalStackedBarSeries::componentComplete() | |
326 | { |
|
326 | { | |
327 | foreach (QObject *child, children()) { |
|
327 | foreach (QObject *child, children()) { | |
328 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
328 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
329 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
329 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
330 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
330 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
331 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
331 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
332 | mapper->setSeries(this); |
|
332 | mapper->setSeries(this); | |
333 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
333 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
334 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
334 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
335 | mapper->setSeries(this); |
|
335 | mapper->setSeries(this); | |
336 | } |
|
336 | } | |
337 | } |
|
337 | } | |
338 | } |
|
338 | } | |
339 |
|
339 | |||
340 | QDeclarativeListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren() |
|
340 | QDeclarativeListProperty<QObject> DeclarativeHorizontalStackedBarSeries::seriesChildren() | |
341 | { |
|
341 | { | |
342 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren); |
|
342 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalStackedBarSeries::appendSeriesChildren); | |
343 | } |
|
343 | } | |
344 |
|
344 | |||
345 | void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
345 | void DeclarativeHorizontalStackedBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
346 | { |
|
346 | { | |
347 | // Empty implementation; the children are parsed in componentComplete instead |
|
347 | // Empty implementation; the children are parsed in componentComplete instead | |
348 | Q_UNUSED(list); |
|
348 | Q_UNUSED(list); | |
349 | Q_UNUSED(element); |
|
349 | Q_UNUSED(element); | |
350 | } |
|
350 | } | |
351 |
|
351 | |||
352 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index) |
|
352 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::at(int index) | |
353 | { |
|
353 | { | |
354 | QList<QBarSet*> setList = barSets(); |
|
354 | QList<QBarSet *> setList = barSets(); | |
355 | if (index >= 0 && index < setList.count()) |
|
355 | if (index >= 0 && index < setList.count()) | |
356 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
356 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
357 |
|
357 | |||
358 | return 0; |
|
358 | return 0; | |
359 | } |
|
359 | } | |
360 |
|
360 | |||
361 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values) |
|
361 | DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QString label, QVariantList values) | |
362 | { |
|
362 | { | |
363 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
363 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
364 | barset->setLabel(label); |
|
364 | barset->setLabel(label); | |
365 | barset->setValues(values); |
|
365 | barset->setValues(values); | |
366 | if (QHorizontalStackedBarSeries::insert(index, barset)) |
|
366 | if (QHorizontalStackedBarSeries::insert(index, barset)) | |
367 | return barset; |
|
367 | return barset; | |
368 | delete barset; |
|
368 | delete barset; | |
369 | return 0; |
|
369 | return 0; | |
370 | } |
|
370 | } | |
371 |
|
371 | |||
372 | // Declarative horizontal percent bar series =================================================================== |
|
372 | // Declarative horizontal percent bar series =================================================================== | |
373 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) : |
|
373 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) : | |
374 | QHorizontalPercentBarSeries(parent), |
|
374 | QHorizontalPercentBarSeries(parent), | |
375 | m_axisX(0), |
|
375 | m_axisX(0), | |
376 | m_axisY(0) |
|
376 | m_axisY(0) | |
377 | { |
|
377 | { | |
378 | } |
|
378 | } | |
379 |
|
379 | |||
380 | void DeclarativeHorizontalPercentBarSeries::classBegin() |
|
380 | void DeclarativeHorizontalPercentBarSeries::classBegin() | |
381 | { |
|
381 | { | |
382 | } |
|
382 | } | |
383 |
|
383 | |||
384 | void DeclarativeHorizontalPercentBarSeries::componentComplete() |
|
384 | void DeclarativeHorizontalPercentBarSeries::componentComplete() | |
385 | { |
|
385 | { | |
386 | foreach (QObject *child, children()) { |
|
386 | foreach (QObject *child, children()) { | |
387 | if (qobject_cast<DeclarativeBarSet *>(child)) { |
|
387 | if (qobject_cast<DeclarativeBarSet *>(child)) { | |
388 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); |
|
388 | QAbstractBarSeries::append(qobject_cast<DeclarativeBarSet *>(child)); | |
389 | } else if(qobject_cast<QVBarModelMapper *>(child)) { |
|
389 | } else if (qobject_cast<QVBarModelMapper *>(child)) { | |
390 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); |
|
390 | QVBarModelMapper *mapper = qobject_cast<QVBarModelMapper *>(child); | |
391 | mapper->setSeries(this); |
|
391 | mapper->setSeries(this); | |
392 | } else if(qobject_cast<QHBarModelMapper *>(child)) { |
|
392 | } else if (qobject_cast<QHBarModelMapper *>(child)) { | |
393 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); |
|
393 | QHBarModelMapper *mapper = qobject_cast<QHBarModelMapper *>(child); | |
394 | mapper->setSeries(this); |
|
394 | mapper->setSeries(this); | |
395 | } |
|
395 | } | |
396 | } |
|
396 | } | |
397 | } |
|
397 | } | |
398 |
|
398 | |||
399 | QDeclarativeListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren() |
|
399 | QDeclarativeListProperty<QObject> DeclarativeHorizontalPercentBarSeries::seriesChildren() | |
400 | { |
|
400 | { | |
401 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren); |
|
401 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeHorizontalPercentBarSeries::appendSeriesChildren); | |
402 | } |
|
402 | } | |
403 |
|
403 | |||
404 | void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
404 | void DeclarativeHorizontalPercentBarSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
405 | { |
|
405 | { | |
406 | // Empty implementation; the children are parsed in componentComplete instead |
|
406 | // Empty implementation; the children are parsed in componentComplete instead | |
407 | Q_UNUSED(list); |
|
407 | Q_UNUSED(list); | |
408 | Q_UNUSED(element); |
|
408 | Q_UNUSED(element); | |
409 | } |
|
409 | } | |
410 |
|
410 | |||
411 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index) |
|
411 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::at(int index) | |
412 | { |
|
412 | { | |
413 | QList<QBarSet*> setList = barSets(); |
|
413 | QList<QBarSet *> setList = barSets(); | |
414 | if (index >= 0 && index < setList.count()) |
|
414 | if (index >= 0 && index < setList.count()) | |
415 | return qobject_cast<DeclarativeBarSet *>(setList[index]); |
|
415 | return qobject_cast<DeclarativeBarSet *>(setList[index]); | |
416 |
|
416 | |||
417 | return 0; |
|
417 | return 0; | |
418 | } |
|
418 | } | |
419 |
|
419 | |||
420 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values) |
|
420 | DeclarativeBarSet *DeclarativeHorizontalPercentBarSeries::insert(int index, QString label, QVariantList values) | |
421 | { |
|
421 | { | |
422 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); |
|
422 | DeclarativeBarSet *barset = new DeclarativeBarSet(this); | |
423 | barset->setLabel(label); |
|
423 | barset->setLabel(label); | |
424 | barset->setValues(values); |
|
424 | barset->setValues(values); | |
425 | if (QHorizontalPercentBarSeries::insert(index, barset)) |
|
425 | if (QHorizontalPercentBarSeries::insert(index, barset)) | |
426 | return barset; |
|
426 | return barset; | |
427 | delete barset; |
|
427 | delete barset; | |
428 | return 0; |
|
428 | return 0; | |
429 | } |
|
429 | } | |
430 |
|
430 | |||
431 | #include "moc_declarativebarseries.cpp" |
|
431 | #include "moc_declarativebarseries.cpp" | |
432 |
|
432 | |||
433 | QTCOMMERCIALCHART_END_NAMESPACE |
|
433 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,313 +1,313 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVEBARSERIES_H |
|
21 | #ifndef DECLARATIVEBARSERIES_H | |
22 | #define DECLARATIVEBARSERIES_H |
|
22 | #define DECLARATIVEBARSERIES_H | |
23 |
|
23 | |||
24 | #include "qbarseries.h" |
|
24 | #include "qbarseries.h" | |
25 | #include "qstackedbarseries.h" |
|
25 | #include "qstackedbarseries.h" | |
26 | #include "qpercentbarseries.h" |
|
26 | #include "qpercentbarseries.h" | |
27 | #include "qhorizontalbarseries.h" |
|
27 | #include "qhorizontalbarseries.h" | |
28 | #include "qhorizontalstackedbarseries.h" |
|
28 | #include "qhorizontalstackedbarseries.h" | |
29 | #include "qhorizontalpercentbarseries.h" |
|
29 | #include "qhorizontalpercentbarseries.h" | |
30 | #include "qbarset.h" |
|
30 | #include "qbarset.h" | |
31 | #ifdef QT5_QUICK_1 |
|
31 | #ifdef QT5_QUICK_1 | |
32 | #include <QtQuick1/QDeclarativeItem> |
|
32 | #include <QtQuick1/QDeclarativeItem> | |
33 | #include <QtQuick1/QDeclarativeParserStatus> |
|
33 | #include <QtQuick1/QDeclarativeParserStatus> | |
34 | #else |
|
34 | #else | |
35 | #include <QtDeclarative/QDeclarativeItem> |
|
35 | #include <QtDeclarative/QDeclarativeItem> | |
36 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
36 | #include <QtDeclarative/QDeclarativeParserStatus> | |
37 | #endif |
|
37 | #endif | |
38 |
|
38 | |||
39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
40 |
|
40 | |||
41 | class QChart; |
|
41 | class QChart; | |
42 |
|
42 | |||
43 | class DeclarativeBarSet : public QBarSet |
|
43 | class DeclarativeBarSet : public QBarSet | |
44 | { |
|
44 | { | |
45 | Q_OBJECT |
|
45 | Q_OBJECT | |
46 | Q_PROPERTY(QVariantList values READ values WRITE setValues) |
|
46 | Q_PROPERTY(QVariantList values READ values WRITE setValues) | |
47 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) |
|
47 | Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1) | |
48 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
48 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
49 |
|
49 | |||
50 | public: |
|
50 | public: | |
51 | explicit DeclarativeBarSet(QObject *parent = 0); |
|
51 | explicit DeclarativeBarSet(QObject *parent = 0); | |
52 | QVariantList values(); |
|
52 | QVariantList values(); | |
53 | void setValues(QVariantList values); |
|
53 | void setValues(QVariantList values); | |
54 | qreal borderWidth() const; |
|
54 | qreal borderWidth() const; | |
55 | void setBorderWidth(qreal borderWidth); |
|
55 | void setBorderWidth(qreal borderWidth); | |
56 |
|
56 | |||
57 | public: // From QBarSet |
|
57 | public: // From QBarSet | |
58 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } |
|
58 | Q_INVOKABLE void append(qreal value) { QBarSet::append(value); } | |
59 | Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); } |
|
59 | Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); } | |
60 | Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); } |
|
60 | Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); } | |
61 | Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); } |
|
61 | Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); } | |
62 |
|
62 | |||
63 | Q_SIGNALS: |
|
63 | Q_SIGNALS: | |
64 | void countChanged(int count); |
|
64 | void countChanged(int count); | |
65 | Q_REVISION(1) void borderWidthChanged(qreal width); |
|
65 | Q_REVISION(1) void borderWidthChanged(qreal width); | |
66 |
|
66 | |||
67 | private Q_SLOTS: |
|
67 | private Q_SLOTS: | |
68 | void handleCountChanged(int index, int count); |
|
68 | void handleCountChanged(int index, int count); | |
69 | }; |
|
69 | }; | |
70 |
|
70 | |||
71 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus |
|
71 | class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |
72 | { |
|
72 | { | |
73 | Q_OBJECT |
|
73 | Q_OBJECT | |
74 | Q_INTERFACES(QDeclarativeParserStatus) |
|
74 | Q_INTERFACES(QDeclarativeParserStatus) | |
75 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
75 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
76 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
76 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
77 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
77 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
78 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
78 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
79 |
|
79 | |||
80 | public: |
|
80 | public: | |
81 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); |
|
81 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); | |
82 | QAbstractAxis *axisX() { return m_axisX; } |
|
82 | QAbstractAxis *axisX() { return m_axisX; } | |
83 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
83 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
84 | QAbstractAxis *axisY() { return m_axisY; } |
|
84 | QAbstractAxis *axisY() { return m_axisY; } | |
85 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
85 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
86 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
86 | QDeclarativeListProperty<QObject> seriesChildren(); | |
87 |
|
87 | |||
88 | public: |
|
88 | public: | |
89 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
89 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
90 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
90 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
91 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
91 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
92 | Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); } |
|
92 | Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(barset); } | |
93 | Q_INVOKABLE void clear() { return QBarSeries::clear(); } |
|
93 | Q_INVOKABLE void clear() { return QBarSeries::clear(); } | |
94 |
|
94 | |||
95 | public: // from QDeclarativeParserStatus |
|
95 | public: // from QDeclarativeParserStatus | |
96 | void classBegin(); |
|
96 | void classBegin(); | |
97 | void componentComplete(); |
|
97 | void componentComplete(); | |
98 |
|
98 | |||
99 | Q_SIGNALS: |
|
99 | Q_SIGNALS: | |
100 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
100 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
101 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
101 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
102 |
|
102 | |||
103 | public Q_SLOTS: |
|
103 | public Q_SLOTS: | |
104 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
104 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
105 |
|
105 | |||
106 | private: |
|
106 | private: | |
107 |
QAbstractAxis* |
|
107 | QAbstractAxis *m_axisX; | |
108 |
QAbstractAxis* |
|
108 | QAbstractAxis *m_axisY; | |
109 | }; |
|
109 | }; | |
110 |
|
110 | |||
111 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus |
|
111 | class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativeParserStatus | |
112 | { |
|
112 | { | |
113 | Q_OBJECT |
|
113 | Q_OBJECT | |
114 | Q_INTERFACES(QDeclarativeParserStatus) |
|
114 | Q_INTERFACES(QDeclarativeParserStatus) | |
115 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
115 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
116 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
116 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
117 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
117 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
118 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
118 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
119 |
|
119 | |||
120 | public: |
|
120 | public: | |
121 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); |
|
121 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); | |
122 | QAbstractAxis *axisX() { return m_axisX; } |
|
122 | QAbstractAxis *axisX() { return m_axisX; } | |
123 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
123 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
124 | QAbstractAxis *axisY() { return m_axisY; } |
|
124 | QAbstractAxis *axisY() { return m_axisY; } | |
125 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
125 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
126 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
126 | QDeclarativeListProperty<QObject> seriesChildren(); | |
127 |
|
127 | |||
128 | public: |
|
128 | public: | |
129 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
129 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
130 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
130 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
131 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
131 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
132 | Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); } |
|
132 | Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(barset); } | |
133 | Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); } |
|
133 | Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); } | |
134 |
|
134 | |||
135 | public: // from QDeclarativeParserStatus |
|
135 | public: // from QDeclarativeParserStatus | |
136 | void classBegin(); |
|
136 | void classBegin(); | |
137 | void componentComplete(); |
|
137 | void componentComplete(); | |
138 |
|
138 | |||
139 | Q_SIGNALS: |
|
139 | Q_SIGNALS: | |
140 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
140 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
141 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
141 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
142 |
|
142 | |||
143 | public Q_SLOTS: |
|
143 | public Q_SLOTS: | |
144 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
144 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
145 |
|
145 | |||
146 | private: |
|
146 | private: | |
147 |
QAbstractAxis* |
|
147 | QAbstractAxis *m_axisX; | |
148 |
QAbstractAxis* |
|
148 | QAbstractAxis *m_axisY; | |
149 | }; |
|
149 | }; | |
150 |
|
150 | |||
151 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus |
|
151 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus | |
152 | { |
|
152 | { | |
153 | Q_OBJECT |
|
153 | Q_OBJECT | |
154 | Q_INTERFACES(QDeclarativeParserStatus) |
|
154 | Q_INTERFACES(QDeclarativeParserStatus) | |
155 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
155 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
156 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
156 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
157 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
157 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
158 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
158 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
159 |
|
159 | |||
160 | public: |
|
160 | public: | |
161 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); |
|
161 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); | |
162 | QAbstractAxis *axisX() { return m_axisX; } |
|
162 | QAbstractAxis *axisX() { return m_axisX; } | |
163 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
163 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
164 | QAbstractAxis *axisY() { return m_axisY; } |
|
164 | QAbstractAxis *axisY() { return m_axisY; } | |
165 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
165 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
166 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
166 | QDeclarativeListProperty<QObject> seriesChildren(); | |
167 |
|
167 | |||
168 | public: |
|
168 | public: | |
169 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
169 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
170 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
170 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
171 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
171 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
172 | Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); } |
|
172 | Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(barset); } | |
173 | Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); } |
|
173 | Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); } | |
174 |
|
174 | |||
175 | public: // from QDeclarativeParserStatus |
|
175 | public: // from QDeclarativeParserStatus | |
176 | void classBegin(); |
|
176 | void classBegin(); | |
177 | void componentComplete(); |
|
177 | void componentComplete(); | |
178 |
|
178 | |||
179 | Q_SIGNALS: |
|
179 | Q_SIGNALS: | |
180 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
180 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
181 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
181 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
182 |
|
182 | |||
183 | public Q_SLOTS: |
|
183 | public Q_SLOTS: | |
184 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
184 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
185 |
|
185 | |||
186 | private: |
|
186 | private: | |
187 |
QAbstractAxis* |
|
187 | QAbstractAxis *m_axisX; | |
188 |
QAbstractAxis* |
|
188 | QAbstractAxis *m_axisY; | |
189 | }; |
|
189 | }; | |
190 |
|
190 | |||
191 | class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus |
|
191 | class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus | |
192 | { |
|
192 | { | |
193 | Q_OBJECT |
|
193 | Q_OBJECT | |
194 | Q_INTERFACES(QDeclarativeParserStatus) |
|
194 | Q_INTERFACES(QDeclarativeParserStatus) | |
195 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
195 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
196 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
196 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
197 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
197 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
198 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
198 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
199 |
|
199 | |||
200 | public: |
|
200 | public: | |
201 | explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0); |
|
201 | explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0); | |
202 | QAbstractAxis *axisX() { return m_axisX; } |
|
202 | QAbstractAxis *axisX() { return m_axisX; } | |
203 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
203 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
204 | QAbstractAxis *axisY() { return m_axisY; } |
|
204 | QAbstractAxis *axisY() { return m_axisY; } | |
205 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
205 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
206 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
206 | QDeclarativeListProperty<QObject> seriesChildren(); | |
207 |
|
207 | |||
208 | public: |
|
208 | public: | |
209 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
209 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
210 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
210 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
211 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
211 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
212 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalBarSeries::remove(barset); } |
|
212 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalBarSeries::remove(barset); } | |
213 | Q_INVOKABLE void clear() { return QHorizontalBarSeries::clear(); } |
|
213 | Q_INVOKABLE void clear() { return QHorizontalBarSeries::clear(); } | |
214 |
|
214 | |||
215 | public: // from QDeclarativeParserStatus |
|
215 | public: // from QDeclarativeParserStatus | |
216 | void classBegin(); |
|
216 | void classBegin(); | |
217 | void componentComplete(); |
|
217 | void componentComplete(); | |
218 |
|
218 | |||
219 | Q_SIGNALS: |
|
219 | Q_SIGNALS: | |
220 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
220 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
221 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
221 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
222 |
|
222 | |||
223 | public Q_SLOTS: |
|
223 | public Q_SLOTS: | |
224 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
224 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
225 |
|
225 | |||
226 | private: |
|
226 | private: | |
227 |
QAbstractAxis* |
|
227 | QAbstractAxis *m_axisX; | |
228 |
QAbstractAxis* |
|
228 | QAbstractAxis *m_axisY; | |
229 | }; |
|
229 | }; | |
230 |
|
230 | |||
231 | class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus |
|
231 | class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus | |
232 | { |
|
232 | { | |
233 | Q_OBJECT |
|
233 | Q_OBJECT | |
234 | Q_INTERFACES(QDeclarativeParserStatus) |
|
234 | Q_INTERFACES(QDeclarativeParserStatus) | |
235 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
235 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
236 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
236 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
237 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
237 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
238 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
238 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
239 |
|
239 | |||
240 | public: |
|
240 | public: | |
241 | explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0); |
|
241 | explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0); | |
242 | QAbstractAxis *axisX() { return m_axisX; } |
|
242 | QAbstractAxis *axisX() { return m_axisX; } | |
243 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
243 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
244 | QAbstractAxis *axisY() { return m_axisY; } |
|
244 | QAbstractAxis *axisY() { return m_axisY; } | |
245 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
245 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
246 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
246 | QDeclarativeListProperty<QObject> seriesChildren(); | |
247 |
|
247 | |||
248 | public: |
|
248 | public: | |
249 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
249 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
250 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
250 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
251 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
251 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
252 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalStackedBarSeries::remove(barset); } |
|
252 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalStackedBarSeries::remove(barset); } | |
253 | Q_INVOKABLE void clear() { return QHorizontalStackedBarSeries::clear(); } |
|
253 | Q_INVOKABLE void clear() { return QHorizontalStackedBarSeries::clear(); } | |
254 |
|
254 | |||
255 | public: // from QDeclarativeParserStatus |
|
255 | public: // from QDeclarativeParserStatus | |
256 | void classBegin(); |
|
256 | void classBegin(); | |
257 | void componentComplete(); |
|
257 | void componentComplete(); | |
258 |
|
258 | |||
259 | Q_SIGNALS: |
|
259 | Q_SIGNALS: | |
260 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
260 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
261 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
261 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
262 |
|
262 | |||
263 | public Q_SLOTS: |
|
263 | public Q_SLOTS: | |
264 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
264 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
265 |
|
265 | |||
266 | private: |
|
266 | private: | |
267 |
QAbstractAxis* |
|
267 | QAbstractAxis *m_axisX; | |
268 |
QAbstractAxis* |
|
268 | QAbstractAxis *m_axisY; | |
269 | }; |
|
269 | }; | |
270 |
|
270 | |||
271 | class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus |
|
271 | class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus | |
272 | { |
|
272 | { | |
273 | Q_OBJECT |
|
273 | Q_OBJECT | |
274 | Q_INTERFACES(QDeclarativeParserStatus) |
|
274 | Q_INTERFACES(QDeclarativeParserStatus) | |
275 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) |
|
275 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1) | |
276 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) |
|
276 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1) | |
277 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
277 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
278 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
278 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
279 |
|
279 | |||
280 | public: |
|
280 | public: | |
281 | explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0); |
|
281 | explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0); | |
282 | QAbstractAxis *axisX() { return m_axisX; } |
|
282 | QAbstractAxis *axisX() { return m_axisX; } | |
283 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } |
|
283 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |
284 | QAbstractAxis *axisY() { return m_axisY; } |
|
284 | QAbstractAxis *axisY() { return m_axisY; } | |
285 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } |
|
285 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |
286 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
286 | QDeclarativeListProperty<QObject> seriesChildren(); | |
287 |
|
287 | |||
288 | public: |
|
288 | public: | |
289 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
289 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
290 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
290 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
291 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
291 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
292 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalPercentBarSeries::remove(barset); } |
|
292 | Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalPercentBarSeries::remove(barset); } | |
293 | Q_INVOKABLE void clear() { return QHorizontalPercentBarSeries::clear(); } |
|
293 | Q_INVOKABLE void clear() { return QHorizontalPercentBarSeries::clear(); } | |
294 |
|
294 | |||
295 | public: // from QDeclarativeParserStatus |
|
295 | public: // from QDeclarativeParserStatus | |
296 | void classBegin(); |
|
296 | void classBegin(); | |
297 | void componentComplete(); |
|
297 | void componentComplete(); | |
298 |
|
298 | |||
299 | Q_SIGNALS: |
|
299 | Q_SIGNALS: | |
300 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); |
|
300 | Q_REVISION(1) void axisXChanged(QAbstractAxis *axis); | |
301 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); |
|
301 | Q_REVISION(1) void axisYChanged(QAbstractAxis *axis); | |
302 |
|
302 | |||
303 | public Q_SLOTS: |
|
303 | public Q_SLOTS: | |
304 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
304 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
305 |
|
305 | |||
306 | private: |
|
306 | private: | |
307 |
QAbstractAxis* |
|
307 | QAbstractAxis *m_axisX; | |
308 |
QAbstractAxis* |
|
308 | QAbstractAxis *m_axisY; | |
309 | }; |
|
309 | }; | |
310 |
|
310 | |||
311 | QTCOMMERCIALCHART_END_NAMESPACE |
|
311 | QTCOMMERCIALCHART_END_NAMESPACE | |
312 |
|
312 | |||
313 | #endif // DECLARATIVEBARSERIES_H |
|
313 | #endif // DECLARATIVEBARSERIES_H |
@@ -1,98 +1,98 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativecategoryaxis.h" |
|
21 | #include "declarativecategoryaxis.h" | |
22 | #include <QDebug> |
|
22 | #include <QDebug> | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \qmlclass CategoryRange |
|
27 | \qmlclass CategoryRange | |
28 | \brief With CategoryRange you can define a range used by a CategoryAxis. |
|
28 | \brief With CategoryRange you can define a range used by a CategoryAxis. | |
29 | \sa CategoryAxis |
|
29 | \sa CategoryAxis | |
30 | */ |
|
30 | */ | |
31 |
|
31 | |||
32 | DeclarativeCategoryRange::DeclarativeCategoryRange(QObject *parent) : |
|
32 | DeclarativeCategoryRange::DeclarativeCategoryRange(QObject *parent) : | |
33 | QObject(parent), |
|
33 | QObject(parent), | |
34 | m_endValue(0), |
|
34 | m_endValue(0), | |
35 | m_label(QString()) |
|
35 | m_label(QString()) | |
36 | { |
|
36 | { | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | DeclarativeCategoryAxis::DeclarativeCategoryAxis(QObject *parent) : |
|
39 | DeclarativeCategoryAxis::DeclarativeCategoryAxis(QObject *parent) : | |
40 | QCategoryAxis(parent) |
|
40 | QCategoryAxis(parent) | |
41 | { |
|
41 | { | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | void DeclarativeCategoryAxis::classBegin() |
|
44 | void DeclarativeCategoryAxis::classBegin() | |
45 | { |
|
45 | { | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | void DeclarativeCategoryAxis::componentComplete() |
|
48 | void DeclarativeCategoryAxis::componentComplete() | |
49 | { |
|
49 | { | |
50 | QList<QPair<QString, qreal> > ranges; |
|
50 | QList<QPair<QString, qreal> > ranges; | |
51 | foreach (QObject *child, children()) { |
|
51 | foreach (QObject *child, children()) { | |
52 | if (qobject_cast<DeclarativeCategoryRange *>(child)) { |
|
52 | if (qobject_cast<DeclarativeCategoryRange *>(child)) { | |
53 | DeclarativeCategoryRange *range = qobject_cast<DeclarativeCategoryRange *>(child); |
|
53 | DeclarativeCategoryRange *range = qobject_cast<DeclarativeCategoryRange *>(child); | |
54 | ranges.append(QPair<QString, qreal>(range->label(), range->endValue())); |
|
54 | ranges.append(QPair<QString, qreal>(range->label(), range->endValue())); | |
55 | } |
|
55 | } | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | // Sort and append the range objects according to end value |
|
58 | // Sort and append the range objects according to end value | |
59 | qSort(ranges.begin(), ranges.end(), endValueLessThan); |
|
59 | qSort(ranges.begin(), ranges.end(), endValueLessThan); | |
60 | for (int i(0); i < ranges.count(); i++) |
|
60 | for (int i(0); i < ranges.count(); i++) | |
61 | append(ranges.at(i).first, ranges.at(i).second); |
|
61 | append(ranges.at(i).first, ranges.at(i).second); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | bool DeclarativeCategoryAxis::endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2) |
|
64 | bool DeclarativeCategoryAxis::endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2) | |
65 | { |
|
65 | { | |
66 | return value1.second < value2.second; |
|
66 | return value1.second < value2.second; | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | QDeclarativeListProperty<QObject> DeclarativeCategoryAxis::axisChildren() |
|
69 | QDeclarativeListProperty<QObject> DeclarativeCategoryAxis::axisChildren() | |
70 | { |
|
70 | { | |
71 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeCategoryAxis::appendAxisChildren); |
|
71 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativeCategoryAxis::appendAxisChildren); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | void DeclarativeCategoryAxis::append(const QString &label, qreal categoryEndValue) |
|
74 | void DeclarativeCategoryAxis::append(const QString &label, qreal categoryEndValue) | |
75 | { |
|
75 | { | |
76 | QCategoryAxis::append(label, categoryEndValue); |
|
76 | QCategoryAxis::append(label, categoryEndValue); | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | void DeclarativeCategoryAxis::remove(const QString &label) |
|
79 | void DeclarativeCategoryAxis::remove(const QString &label) | |
80 | { |
|
80 | { | |
81 | QCategoryAxis::remove(label); |
|
81 | QCategoryAxis::remove(label); | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 |
void DeclarativeCategoryAxis::replace(const QString& |
|
84 | void DeclarativeCategoryAxis::replace(const QString &oldLabel, const QString &newLabel) | |
85 | { |
|
85 | { | |
86 | QCategoryAxis::replaceLabel(oldLabel, newLabel); |
|
86 | QCategoryAxis::replaceLabel(oldLabel, newLabel); | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | void DeclarativeCategoryAxis::appendAxisChildren(QDeclarativeListProperty<QObject> *list, QObject *element) |
|
89 | void DeclarativeCategoryAxis::appendAxisChildren(QDeclarativeListProperty<QObject> *list, QObject *element) | |
90 | { |
|
90 | { | |
91 | // Empty implementation; the children are parsed in componentComplete instead |
|
91 | // Empty implementation; the children are parsed in componentComplete instead | |
92 | Q_UNUSED(list) |
|
92 | Q_UNUSED(list) | |
93 | Q_UNUSED(element) |
|
93 | Q_UNUSED(element) | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | #include "moc_declarativecategoryaxis.cpp" |
|
96 | #include "moc_declarativecategoryaxis.cpp" | |
97 |
|
97 | |||
98 | QTCOMMERCIALCHART_END_NAMESPACE |
|
98 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,80 +1,80 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVECATEGORYAXIS_H |
|
21 | #ifndef DECLARATIVECATEGORYAXIS_H | |
22 | #define DECLARATIVECATEGORYAXIS_H |
|
22 | #define DECLARATIVECATEGORYAXIS_H | |
23 |
|
23 | |||
24 | #include "qcategoryaxis.h" |
|
24 | #include "qcategoryaxis.h" | |
25 | #ifdef QT5_QUICK_1 |
|
25 | #ifdef QT5_QUICK_1 | |
26 | #include <QtQuick1/QDeclarativeListProperty> |
|
26 | #include <QtQuick1/QDeclarativeListProperty> | |
27 | #include <QtQuick1/QDeclarativeParserStatus> |
|
27 | #include <QtQuick1/QDeclarativeParserStatus> | |
28 | #else |
|
28 | #else | |
29 | #include <QtDeclarative/QDeclarativeListProperty> |
|
29 | #include <QtDeclarative/QDeclarativeListProperty> | |
30 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
30 | #include <QtDeclarative/QDeclarativeParserStatus> | |
31 | #endif |
|
31 | #endif | |
32 |
|
32 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
34 | |||
35 | class DeclarativeCategoryRange : public QObject |
|
35 | class DeclarativeCategoryRange : public QObject | |
36 | { |
|
36 | { | |
37 | Q_OBJECT |
|
37 | Q_OBJECT | |
38 | Q_PROPERTY(qreal endValue READ endValue WRITE setEndValue) |
|
38 | Q_PROPERTY(qreal endValue READ endValue WRITE setEndValue) | |
39 | Q_PROPERTY(QString label READ label WRITE setLabel) |
|
39 | Q_PROPERTY(QString label READ label WRITE setLabel) | |
40 |
|
40 | |||
41 | public: |
|
41 | public: | |
42 | explicit DeclarativeCategoryRange(QObject *parent = 0); |
|
42 | explicit DeclarativeCategoryRange(QObject *parent = 0); | |
43 | qreal endValue() { return m_endValue; } |
|
43 | qreal endValue() { return m_endValue; } | |
44 | void setEndValue(qreal endValue) { m_endValue = endValue; } |
|
44 | void setEndValue(qreal endValue) { m_endValue = endValue; } | |
45 | QString label() { return m_label; } |
|
45 | QString label() { return m_label; } | |
46 | void setLabel(QString label) { m_label = label; } |
|
46 | void setLabel(QString label) { m_label = label; } | |
47 |
|
47 | |||
48 | private: |
|
48 | private: | |
49 | qreal m_endValue; |
|
49 | qreal m_endValue; | |
50 | QString m_label; |
|
50 | QString m_label; | |
51 | }; |
|
51 | }; | |
52 |
|
52 | |||
53 | class DeclarativeCategoryAxis : public QCategoryAxis, public QDeclarativeParserStatus |
|
53 | class DeclarativeCategoryAxis : public QCategoryAxis, public QDeclarativeParserStatus | |
54 | { |
|
54 | { | |
55 | Q_OBJECT |
|
55 | Q_OBJECT | |
56 | Q_INTERFACES(QDeclarativeParserStatus) |
|
56 | Q_INTERFACES(QDeclarativeParserStatus) | |
57 | Q_PROPERTY(QDeclarativeListProperty<QObject> axisChildren READ axisChildren) |
|
57 | Q_PROPERTY(QDeclarativeListProperty<QObject> axisChildren READ axisChildren) | |
58 | Q_CLASSINFO("DefaultProperty", "axisChildren") |
|
58 | Q_CLASSINFO("DefaultProperty", "axisChildren") | |
59 |
|
59 | |||
60 | public: |
|
60 | public: | |
61 | explicit DeclarativeCategoryAxis(QObject *parent = 0); |
|
61 | explicit DeclarativeCategoryAxis(QObject *parent = 0); | |
62 | QDeclarativeListProperty<QObject> axisChildren(); |
|
62 | QDeclarativeListProperty<QObject> axisChildren(); | |
63 |
|
63 | |||
64 | public: // from QDeclarativeParserStatus |
|
64 | public: // from QDeclarativeParserStatus | |
65 | void classBegin(); |
|
65 | void classBegin(); | |
66 | void componentComplete(); |
|
66 | void componentComplete(); | |
67 |
|
67 | |||
68 | public Q_SLOTS: |
|
68 | public Q_SLOTS: | |
69 | Q_INVOKABLE void append(const QString &label, qreal categoryEndValue); |
|
69 | Q_INVOKABLE void append(const QString &label, qreal categoryEndValue); | |
70 | Q_INVOKABLE void remove(const QString &label); |
|
70 | Q_INVOKABLE void remove(const QString &label); | |
71 |
Q_INVOKABLE void replace(const QString& |
|
71 | Q_INVOKABLE void replace(const QString &oldLabel, const QString &newLabel); | |
72 | static void appendAxisChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
72 | static void appendAxisChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
73 |
|
73 | |||
74 | private: |
|
74 | private: | |
75 | static bool endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2); |
|
75 | static bool endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2); | |
76 | }; |
|
76 | }; | |
77 |
|
77 | |||
78 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE | |
79 |
|
79 | |||
80 | #endif // DECLARATIVECATEGORYAXIS_H |
|
80 | #endif // DECLARATIVECATEGORYAXIS_H |
@@ -1,737 +1,737 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativechart.h" |
|
21 | #include "declarativechart.h" | |
22 | #include <QPainter> |
|
22 | #include <QPainter> | |
23 | #include <QDeclarativeEngine> |
|
23 | #include <QDeclarativeEngine> | |
24 | #include "declarativelineseries.h" |
|
24 | #include "declarativelineseries.h" | |
25 | #include "declarativeareaseries.h" |
|
25 | #include "declarativeareaseries.h" | |
26 | #include "declarativebarseries.h" |
|
26 | #include "declarativebarseries.h" | |
27 | #include "declarativepieseries.h" |
|
27 | #include "declarativepieseries.h" | |
28 | #include "declarativesplineseries.h" |
|
28 | #include "declarativesplineseries.h" | |
29 | #include "declarativescatterseries.h" |
|
29 | #include "declarativescatterseries.h" | |
30 | #include "qbarcategoryaxis.h" |
|
30 | #include "qbarcategoryaxis.h" | |
31 | #include "qvalueaxis.h" |
|
31 | #include "qvalueaxis.h" | |
32 | #include "qcategoryaxis.h" |
|
32 | #include "qcategoryaxis.h" | |
33 | #include "qabstractseries_p.h" |
|
33 | #include "qabstractseries_p.h" | |
34 | #include "declarativemargins.h" |
|
34 | #include "declarativemargins.h" | |
35 | #include "qchart_p.h" |
|
35 | #include "qchart_p.h" | |
36 |
|
36 | |||
37 | #ifndef QT_ON_ARM |
|
37 | #ifndef QT_ON_ARM | |
38 | #include "qdatetimeaxis.h" |
|
38 | #include "qdatetimeaxis.h" | |
39 | #endif |
|
39 | #endif | |
40 |
|
40 | |||
41 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
41 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
42 |
|
42 | |||
43 | /*! |
|
43 | /*! | |
44 | \qmlclass ChartView DeclarativeChart |
|
44 | \qmlclass ChartView DeclarativeChart | |
45 |
|
45 | |||
46 | ChartView element is the parent that is responsible for showing different chart series types. |
|
46 | ChartView element is the parent that is responsible for showing different chart series types. | |
47 |
|
47 | |||
48 | The following QML shows how to create a simple chart with one pie series: |
|
48 | The following QML shows how to create a simple chart with one pie series: | |
49 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
49 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 | |
50 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
50 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
51 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
51 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 | |
52 |
|
52 | |||
53 | \beginfloatleft |
|
53 | \beginfloatleft | |
54 | \image examples_qmlpiechart.png |
|
54 | \image examples_qmlpiechart.png | |
55 | \endfloat |
|
55 | \endfloat | |
56 | \clearfloat |
|
56 | \clearfloat | |
57 | */ |
|
57 | */ | |
58 |
|
58 | |||
59 | /*! |
|
59 | /*! | |
60 | \qmlproperty Theme ChartView::theme |
|
60 | \qmlproperty Theme ChartView::theme | |
61 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
61 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
62 | widths and chart background. |
|
62 | widths and chart background. | |
63 | */ |
|
63 | */ | |
64 |
|
64 | |||
65 | /*! |
|
65 | /*! | |
66 | \qmlproperty Animation ChartView::animation |
|
66 | \qmlproperty Animation ChartView::animation | |
67 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
67 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
68 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
68 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
69 | */ |
|
69 | */ | |
70 |
|
70 | |||
71 | /*! |
|
71 | /*! | |
72 | \qmlproperty Font ChartView::titleFont |
|
72 | \qmlproperty Font ChartView::titleFont | |
73 | The title font of the chart |
|
73 | The title font of the chart | |
74 |
|
74 | |||
75 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
75 | See the \l {Font} {QML Font Element} for detailed documentation. | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \qmlproperty string ChartView::title |
|
79 | \qmlproperty string ChartView::title | |
80 | The title of the chart, shown on top of the chart. |
|
80 | The title of the chart, shown on top of the chart. | |
81 | \sa ChartView::titleColor |
|
81 | \sa ChartView::titleColor | |
82 | */ |
|
82 | */ | |
83 |
|
83 | |||
84 | /*! |
|
84 | /*! | |
85 | \qmlproperty string ChartView::titleColor |
|
85 | \qmlproperty string ChartView::titleColor | |
86 | The color of the title text. |
|
86 | The color of the title text. | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \qmlproperty Axis ChartView::axisX |
|
90 | \qmlproperty Axis ChartView::axisX | |
91 | The x-axis of the chart. |
|
91 | The x-axis of the chart. | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \qmlproperty Axis ChartView::axisY |
|
95 | \qmlproperty Axis ChartView::axisY | |
96 | The default y-axis of the chart. |
|
96 | The default y-axis of the chart. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \qmlproperty Legend ChartView::legend |
|
100 | \qmlproperty Legend ChartView::legend | |
101 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
101 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \qmlproperty int ChartView::count |
|
105 | \qmlproperty int ChartView::count | |
106 | The count of series added to the chart. |
|
106 | The count of series added to the chart. | |
107 | */ |
|
107 | */ | |
108 |
|
108 | |||
109 | /*! |
|
109 | /*! | |
110 | \qmlproperty color ChartView::backgroundColor |
|
110 | \qmlproperty color ChartView::backgroundColor | |
111 | The color of the chart's background. By default background color is defined by chart theme. |
|
111 | The color of the chart's background. By default background color is defined by chart theme. | |
112 | \sa ChartView::theme |
|
112 | \sa ChartView::theme | |
113 | */ |
|
113 | */ | |
114 |
|
114 | |||
115 | /*! |
|
115 | /*! | |
116 | \qmlproperty bool ChartView::dropShadowEnabled |
|
116 | \qmlproperty bool ChartView::dropShadowEnabled | |
117 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
117 | The chart's border drop shadow. Set to true to enable drop shadow. | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \qmlproperty real ChartView::topMargin |
|
121 | \qmlproperty real ChartView::topMargin | |
122 | Deprecated. Use minimumMargins and plotArea instead. |
|
122 | Deprecated. Use minimumMargins and plotArea instead. | |
123 | */ |
|
123 | */ | |
124 |
|
124 | |||
125 | /*! |
|
125 | /*! | |
126 | \qmlproperty real ChartView::bottomMargin |
|
126 | \qmlproperty real ChartView::bottomMargin | |
127 | Deprecated. Use minimumMargins and plotArea instead. |
|
127 | Deprecated. Use minimumMargins and plotArea instead. | |
128 | */ |
|
128 | */ | |
129 |
|
129 | |||
130 | /*! |
|
130 | /*! | |
131 | \qmlproperty real ChartView::leftMargin |
|
131 | \qmlproperty real ChartView::leftMargin | |
132 | Deprecated. Use minimumMargins and plotArea instead. |
|
132 | Deprecated. Use minimumMargins and plotArea instead. | |
133 | */ |
|
133 | */ | |
134 |
|
134 | |||
135 | /*! |
|
135 | /*! | |
136 | \qmlproperty real ChartView::rightMargin |
|
136 | \qmlproperty real ChartView::rightMargin | |
137 | Deprecated. Use minimumMargins and plotArea instead. |
|
137 | Deprecated. Use minimumMargins and plotArea instead. | |
138 | */ |
|
138 | */ | |
139 |
|
139 | |||
140 | /*! |
|
140 | /*! | |
141 | \qmlproperty Margins ChartView::minimumMargins |
|
141 | \qmlproperty Margins ChartView::minimumMargins | |
142 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins |
|
142 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins | |
143 | area of ChartView is used for drawing title, axes and legend. Please note that setting the |
|
143 | area of ChartView is used for drawing title, axes and legend. Please note that setting the | |
144 | properties of minimumMargins may be bigger than the defined value, depending on other ChartView |
|
144 | properties of minimumMargins may be bigger than the defined value, depending on other ChartView | |
145 | properties that affect it's layout. If you need to know the actual plotting area used at any |
|
145 | properties that affect it's layout. If you need to know the actual plotting area used at any | |
146 | given time, you can check ChartView::plotArea instead. |
|
146 | given time, you can check ChartView::plotArea instead. | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 | /*! |
|
149 | /*! | |
150 | \qmlproperty rect ChartView::plotArea |
|
150 | \qmlproperty rect ChartView::plotArea | |
151 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the |
|
151 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the | |
152 | margins. |
|
152 | margins. | |
153 | \sa ChartView::minimumMargins |
|
153 | \sa ChartView::minimumMargins | |
154 | */ |
|
154 | */ | |
155 |
|
155 | |||
156 | /*! |
|
156 | /*! | |
157 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
157 | \qmlmethod AbstractSeries ChartView::series(int index) | |
158 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with |
|
158 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with | |
159 | the count property of the chart. |
|
159 | the count property of the chart. | |
160 | */ |
|
160 | */ | |
161 |
|
161 | |||
162 | /*! |
|
162 | /*! | |
163 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
163 | \qmlmethod AbstractSeries ChartView::series(string name) | |
164 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. |
|
164 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. | |
165 | */ |
|
165 | */ | |
166 |
|
166 | |||
167 | /*! |
|
167 | /*! | |
168 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) |
|
168 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) | |
169 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and |
|
169 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and | |
170 | optional axis \a axisY. For example: |
|
170 | optional axis \a axisY. For example: | |
171 | \code |
|
171 | \code | |
172 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes |
|
172 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes | |
173 | var myAxisX = chartView.axisX(lineSeries); |
|
173 | var myAxisX = chartView.axisX(lineSeries); | |
174 | var myAxisY = chartView.axisY(lineSeries); |
|
174 | var myAxisY = chartView.axisY(lineSeries); | |
175 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); |
|
175 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); | |
176 | \endcode |
|
176 | \endcode | |
177 | */ |
|
177 | */ | |
178 |
|
178 | |||
179 | /*! |
|
179 | /*! | |
180 | \qmlmethod ChartView::removeSeries(AbstractSeries series) |
|
180 | \qmlmethod ChartView::removeSeries(AbstractSeries series) | |
181 | Removes the \a series from the chart. The series object is also destroyed. |
|
181 | Removes the \a series from the chart. The series object is also destroyed. | |
182 | */ |
|
182 | */ | |
183 |
|
183 | |||
184 | /*! |
|
184 | /*! | |
185 | \qmlmethod ChartView::removeAllSeries() |
|
185 | \qmlmethod ChartView::removeAllSeries() | |
186 | Removes all series from the chart. All the series objects are also destroyed. |
|
186 | Removes all series from the chart. All the series objects are also destroyed. | |
187 | */ |
|
187 | */ | |
188 |
|
188 | |||
189 | /*! |
|
189 | /*! | |
190 | \qmlmethod Axis ChartView::axisX(AbstractSeries series) |
|
190 | \qmlmethod Axis ChartView::axisX(AbstractSeries series) | |
191 | The x-axis of the series. |
|
191 | The x-axis of the series. | |
192 | */ |
|
192 | */ | |
193 |
|
193 | |||
194 | /*! |
|
194 | /*! | |
195 | \qmlmethod Axis ChartView::axisY(AbstractSeries series) |
|
195 | \qmlmethod Axis ChartView::axisY(AbstractSeries series) | |
196 | The y-axis of the series. |
|
196 | The y-axis of the series. | |
197 | */ |
|
197 | */ | |
198 |
|
198 | |||
199 | /*! |
|
199 | /*! | |
200 | \qmlmethod ChartView::zoomY(real factor) |
|
200 | \qmlmethod ChartView::zoomY(real factor) | |
201 | Zooms in by \a factor on the center of the chart. |
|
201 | Zooms in by \a factor on the center of the chart. | |
202 | */ |
|
202 | */ | |
203 |
|
203 | |||
204 | /*! |
|
204 | /*! | |
205 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
205 | \qmlmethod ChartView::scrollLeft(real pixels) | |
206 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
206 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
207 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max |
|
207 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max | |
208 | */ |
|
208 | */ | |
209 |
|
209 | |||
210 | /*! |
|
210 | /*! | |
211 | \qmlmethod ChartView::scrollRight(real pixels) |
|
211 | \qmlmethod ChartView::scrollRight(real pixels) | |
212 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
212 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
213 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max |
|
213 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max | |
214 | */ |
|
214 | */ | |
215 |
|
215 | |||
216 | /*! |
|
216 | /*! | |
217 | \qmlmethod ChartView::scrollUp(real pixels) |
|
217 | \qmlmethod ChartView::scrollUp(real pixels) | |
218 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
218 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
219 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max |
|
219 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max | |
220 | */ |
|
220 | */ | |
221 |
|
221 | |||
222 | /*! |
|
222 | /*! | |
223 | \qmlmethod ChartView::scrollDown(real pixels) |
|
223 | \qmlmethod ChartView::scrollDown(real pixels) | |
224 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
224 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
225 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max |
|
225 | \sa ValueAxis::min, ValueAxis::max, BarCategoryAxis::min, BarCategoryAxis::max | |
226 | */ |
|
226 | */ | |
227 |
|
227 | |||
228 | /*! |
|
228 | /*! | |
229 | \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) |
|
229 | \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) | |
230 | The plot area of the chart has changed. This may happen for example, if you modify minimumMargins |
|
230 | The plot area of the chart has changed. This may happen for example, if you modify minimumMargins | |
231 | or if you resize the chart, or if you modify font size related properties of the legend or chart |
|
231 | or if you resize the chart, or if you modify font size related properties of the legend or chart | |
232 | title. |
|
232 | title. | |
233 | */ |
|
233 | */ | |
234 |
|
234 | |||
235 | /*! |
|
235 | /*! | |
236 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) |
|
236 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) | |
237 | The \a series has been added to the chart. |
|
237 | The \a series has been added to the chart. | |
238 | */ |
|
238 | */ | |
239 |
|
239 | |||
240 | /*! |
|
240 | /*! | |
241 | \qmlsignal ChartView::seriesRemoved(AbstractSeries series) |
|
241 | \qmlsignal ChartView::seriesRemoved(AbstractSeries series) | |
242 | The \a series has been removed from the chart. Please note that \a series is no longer a valid |
|
242 | The \a series has been removed from the chart. Please note that \a series is no longer a valid | |
243 | object after the signal handler has completed. |
|
243 | object after the signal handler has completed. | |
244 | */ |
|
244 | */ | |
245 |
|
245 | |||
246 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
246 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
247 | : QDeclarativeItem(parent), |
|
247 | : QDeclarativeItem(parent), | |
248 | m_chart(new QChart(this)) |
|
248 | m_chart(new QChart(this)) | |
249 | { |
|
249 | { | |
250 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
250 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
251 | m_margins = new DeclarativeMargins(this); |
|
251 | m_margins = new DeclarativeMargins(this); | |
252 | m_margins->setTop(m_chart->margins().top()); |
|
252 | m_margins->setTop(m_chart->margins().top()); | |
253 | m_margins->setLeft(m_chart->margins().left()); |
|
253 | m_margins->setLeft(m_chart->margins().left()); | |
254 | m_margins->setRight(m_chart->margins().right()); |
|
254 | m_margins->setRight(m_chart->margins().right()); | |
255 | m_margins->setBottom(m_chart->margins().bottom()); |
|
255 | m_margins->setBottom(m_chart->margins().bottom()); | |
256 | connect(m_margins, SIGNAL(topChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); |
|
256 | connect(m_margins, SIGNAL(topChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
257 | connect(m_margins, SIGNAL(bottomChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); |
|
257 | connect(m_margins, SIGNAL(bottomChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
258 | connect(m_margins, SIGNAL(leftChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); |
|
258 | connect(m_margins, SIGNAL(leftChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
259 | connect(m_margins, SIGNAL(rightChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); |
|
259 | connect(m_margins, SIGNAL(rightChanged(int, int, int, int)), this, SLOT(changeMinimumMargins(int, int, int, int))); | |
260 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)), this, SLOT(handleSeriesAdded(QAbstractSeries *, Domain *))); |
|
260 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)), this, SLOT(handleSeriesAdded(QAbstractSeries *, Domain *))); | |
261 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)), this, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
261 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)), this, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
262 | } |
|
262 | } | |
263 |
|
263 | |||
264 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series, Domain *domain) |
|
264 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |
265 | { |
|
265 | { | |
266 | Q_UNUSED(domain) |
|
266 | Q_UNUSED(domain) | |
267 | emit seriesAdded(series); |
|
267 | emit seriesAdded(series); | |
268 | } |
|
268 | } | |
269 |
|
269 | |||
270 | void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) |
|
270 | void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) | |
271 | { |
|
271 | { | |
272 | m_chart->setMargins(QMargins(left, top, right, bottom)); |
|
272 | m_chart->setMargins(QMargins(left, top, right, bottom)); | |
273 | emit minimumMarginsChanged(); |
|
273 | emit minimumMarginsChanged(); | |
274 | emit plotAreaChanged(m_chart->plotArea()); |
|
274 | emit plotAreaChanged(m_chart->plotArea()); | |
275 | } |
|
275 | } | |
276 |
|
276 | |||
277 | DeclarativeChart::~DeclarativeChart() |
|
277 | DeclarativeChart::~DeclarativeChart() | |
278 | { |
|
278 | { | |
279 | delete m_chart; |
|
279 | delete m_chart; | |
280 | } |
|
280 | } | |
281 |
|
281 | |||
282 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
282 | void DeclarativeChart::childEvent(QChildEvent *event) | |
283 | { |
|
283 | { | |
284 | if (event->type() == QEvent::ChildAdded) { |
|
284 | if (event->type() == QEvent::ChildAdded) { | |
285 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
285 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
286 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
286 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
287 | } |
|
287 | } | |
288 | } |
|
288 | } | |
289 | } |
|
289 | } | |
290 |
|
290 | |||
291 | void DeclarativeChart::componentComplete() |
|
291 | void DeclarativeChart::componentComplete() | |
292 | { |
|
292 | { | |
293 | foreach (QObject *child, children()) { |
|
293 | foreach (QObject *child, children()) { | |
294 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
294 | if (qobject_cast<QAbstractSeries *>(child)) { | |
295 | // Add series to the chart |
|
295 | // Add series to the chart | |
296 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); |
|
296 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); | |
297 | m_chart->addSeries(series); |
|
297 | m_chart->addSeries(series); | |
298 |
|
298 | |||
299 | // Set optional user defined axes for the series and connect axis related signals |
|
299 | // Set optional user defined axes for the series and connect axis related signals | |
300 | if (qobject_cast<DeclarativeLineSeries *>(child)) { |
|
300 | if (qobject_cast<DeclarativeLineSeries *>(child)) { | |
301 | DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child); |
|
301 | DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child); | |
302 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
302 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
303 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
303 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
304 | setAxisX(s->axisX(), s); |
|
304 | setAxisX(s->axisX(), s); | |
305 | setAxisY(s->axisY(), s); |
|
305 | setAxisY(s->axisY(), s); | |
306 | } else if (qobject_cast<DeclarativeSplineSeries *>(child)) { |
|
306 | } else if (qobject_cast<DeclarativeSplineSeries *>(child)) { | |
307 | DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child); |
|
307 | DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child); | |
308 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
308 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
309 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
309 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
310 | setAxisX(s->axisX(), s); |
|
310 | setAxisX(s->axisX(), s); | |
311 | setAxisY(s->axisY(), s); |
|
311 | setAxisY(s->axisY(), s); | |
312 | } else if (qobject_cast<DeclarativeScatterSeries *>(child)) { |
|
312 | } else if (qobject_cast<DeclarativeScatterSeries *>(child)) { | |
313 | DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child); |
|
313 | DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child); | |
314 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
314 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
315 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
315 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
316 | setAxisX(s->axisX(), s); |
|
316 | setAxisX(s->axisX(), s); | |
317 | setAxisY(s->axisY(), s); |
|
317 | setAxisY(s->axisY(), s); | |
318 | } else if (qobject_cast<DeclarativeAreaSeries *>(child)) { |
|
318 | } else if (qobject_cast<DeclarativeAreaSeries *>(child)) { | |
319 | DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child); |
|
319 | DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child); | |
320 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
320 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
321 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
321 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
322 | setAxisX(s->axisX(), s); |
|
322 | setAxisX(s->axisX(), s); | |
323 | setAxisY(s->axisY(), s); |
|
323 | setAxisY(s->axisY(), s); | |
324 | } else if (qobject_cast<DeclarativeBarSeries *>(child)) { |
|
324 | } else if (qobject_cast<DeclarativeBarSeries *>(child)) { | |
325 | DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child); |
|
325 | DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child); | |
326 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
326 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
327 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
327 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
328 | setAxisX(s->axisX(), s); |
|
328 | setAxisX(s->axisX(), s); | |
329 | setAxisY(s->axisY(), s); |
|
329 | setAxisY(s->axisY(), s); | |
330 | } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) { |
|
330 | } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) { | |
331 | DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child); |
|
331 | DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child); | |
332 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
332 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
333 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
333 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
334 | setAxisX(s->axisX(), s); |
|
334 | setAxisX(s->axisX(), s); | |
335 | setAxisY(s->axisY(), s); |
|
335 | setAxisY(s->axisY(), s); | |
336 | } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) { |
|
336 | } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) { | |
337 | DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child); |
|
337 | DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child); | |
338 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
338 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
339 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
339 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
340 | setAxisX(s->axisX(), s); |
|
340 | setAxisX(s->axisX(), s); | |
341 | setAxisY(s->axisY(), s); |
|
341 | setAxisY(s->axisY(), s); | |
342 | } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) { |
|
342 | } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) { | |
343 | DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child); |
|
343 | DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child); | |
344 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
344 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
345 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
345 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
346 | setAxisX(s->axisX(), s); |
|
346 | setAxisX(s->axisX(), s); | |
347 | setAxisY(s->axisY(), s); |
|
347 | setAxisY(s->axisY(), s); | |
348 | } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) { |
|
348 | } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) { | |
349 | DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child); |
|
349 | DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child); | |
350 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
350 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
351 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
351 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
352 | setAxisX(s->axisX(), s); |
|
352 | setAxisX(s->axisX(), s); | |
353 | setAxisY(s->axisY(), s); |
|
353 | setAxisY(s->axisY(), s); | |
354 | } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) { |
|
354 | } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) { | |
355 | DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child); |
|
355 | DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child); | |
356 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
356 | connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
357 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
357 | connect(s, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
358 | setAxisX(s->axisX(), s); |
|
358 | setAxisX(s->axisX(), s); | |
359 | setAxisY(s->axisY(), s); |
|
359 | setAxisY(s->axisY(), s); | |
360 | } |
|
360 | } | |
361 | } |
|
361 | } | |
362 | } |
|
362 | } | |
363 |
|
363 | |||
364 | // Create the missing axes for the series that cannot be painted without axes |
|
364 | // Create the missing axes for the series that cannot be painted without axes | |
365 | foreach (QAbstractSeries *chartSeries, m_chart->series()) |
|
365 | foreach (QAbstractSeries *chartSeries, m_chart->series()) | |
366 | createDefaultAxes(chartSeries); |
|
366 | createDefaultAxes(chartSeries); | |
367 |
|
367 | |||
368 | QDeclarativeItem::componentComplete(); |
|
368 | QDeclarativeItem::componentComplete(); | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 |
void DeclarativeChart::handleAxisXSet(QAbstractAxis* |
|
371 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) | |
372 | { |
|
372 | { | |
373 | // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis; |
|
373 | // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis; | |
374 | if (axis && qobject_cast<QAbstractSeries *>(sender())) |
|
374 | if (axis && qobject_cast<QAbstractSeries *>(sender())) | |
375 | m_chart->setAxisX(axis, qobject_cast<QAbstractSeries *>(sender())); |
|
375 | m_chart->setAxisX(axis, qobject_cast<QAbstractSeries *>(sender())); | |
376 | else |
|
376 | else | |
377 | qWarning() << "Trying to set axisX to null."; |
|
377 | qWarning() << "Trying to set axisX to null."; | |
378 | } |
|
378 | } | |
379 |
|
379 | |||
380 |
void DeclarativeChart::handleAxisYSet(QAbstractAxis* |
|
380 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) | |
381 | { |
|
381 | { | |
382 | // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis; |
|
382 | // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis; | |
383 | if (axis && qobject_cast<QAbstractSeries *>(sender())) |
|
383 | if (axis && qobject_cast<QAbstractSeries *>(sender())) | |
384 | m_chart->setAxisY(axis, qobject_cast<QAbstractSeries *>(sender())); |
|
384 | m_chart->setAxisY(axis, qobject_cast<QAbstractSeries *>(sender())); | |
385 | else |
|
385 | else | |
386 | qWarning() << "Trying to set axisY to null."; |
|
386 | qWarning() << "Trying to set axisY to null."; | |
387 | } |
|
387 | } | |
388 |
|
388 | |||
389 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
389 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
390 | { |
|
390 | { | |
391 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
391 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
392 | if (newGeometry.isValid()) { |
|
392 | if (newGeometry.isValid()) { | |
393 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
393 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
394 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
394 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
395 | } |
|
395 | } | |
396 | } |
|
396 | } | |
397 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
397 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |
398 |
|
398 | |||
399 | // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or |
|
399 | // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or | |
400 | // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is |
|
400 | // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is | |
401 | // to implement it here for the QML API purposes. |
|
401 | // to implement it here for the QML API purposes. | |
402 | emit plotAreaChanged(m_chart->plotArea()); |
|
402 | emit plotAreaChanged(m_chart->plotArea()); | |
403 | } |
|
403 | } | |
404 |
|
404 | |||
405 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
405 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
406 | { |
|
406 | { | |
407 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
407 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
408 | if (chartTheme != m_chart->theme()) |
|
408 | if (chartTheme != m_chart->theme()) | |
409 | m_chart->setTheme(chartTheme); |
|
409 | m_chart->setTheme(chartTheme); | |
410 | } |
|
410 | } | |
411 |
|
411 | |||
412 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
412 | DeclarativeChart::Theme DeclarativeChart::theme() | |
413 | { |
|
413 | { | |
414 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
414 | return (DeclarativeChart::Theme) m_chart->theme(); | |
415 | } |
|
415 | } | |
416 |
|
416 | |||
417 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
417 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
418 | { |
|
418 | { | |
419 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
419 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
420 | if (animationOptions != m_chart->animationOptions()) |
|
420 | if (animationOptions != m_chart->animationOptions()) | |
421 | m_chart->setAnimationOptions(animationOptions); |
|
421 | m_chart->setAnimationOptions(animationOptions); | |
422 | } |
|
422 | } | |
423 |
|
423 | |||
424 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
424 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
425 | { |
|
425 | { | |
426 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
426 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
427 | return DeclarativeChart::AllAnimations; |
|
427 | return DeclarativeChart::AllAnimations; | |
428 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
428 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
429 | return DeclarativeChart::GridAxisAnimations; |
|
429 | return DeclarativeChart::GridAxisAnimations; | |
430 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
430 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
431 | return DeclarativeChart::SeriesAnimations; |
|
431 | return DeclarativeChart::SeriesAnimations; | |
432 | else |
|
432 | else | |
433 | return DeclarativeChart::NoAnimation; |
|
433 | return DeclarativeChart::NoAnimation; | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | void DeclarativeChart::setTitle(QString title) |
|
436 | void DeclarativeChart::setTitle(QString title) | |
437 | { |
|
437 | { | |
438 | if (title != m_chart->title()) |
|
438 | if (title != m_chart->title()) | |
439 | m_chart->setTitle(title); |
|
439 | m_chart->setTitle(title); | |
440 | } |
|
440 | } | |
441 | QString DeclarativeChart::title() |
|
441 | QString DeclarativeChart::title() | |
442 | { |
|
442 | { | |
443 | return m_chart->title(); |
|
443 | return m_chart->title(); | |
444 | } |
|
444 | } | |
445 |
|
445 | |||
446 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
446 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) | |
447 | { |
|
447 | { | |
448 | return m_chart->axisX(series); |
|
448 | return m_chart->axisX(series); | |
449 | } |
|
449 | } | |
450 |
|
450 | |||
451 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
451 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
452 | { |
|
452 | { | |
453 | return m_chart->axisY(series); |
|
453 | return m_chart->axisY(series); | |
454 | } |
|
454 | } | |
455 |
|
455 | |||
456 | QLegend *DeclarativeChart::legend() |
|
456 | QLegend *DeclarativeChart::legend() | |
457 | { |
|
457 | { | |
458 | return m_chart->legend(); |
|
458 | return m_chart->legend(); | |
459 | } |
|
459 | } | |
460 |
|
460 | |||
461 | void DeclarativeChart::setTitleColor(QColor color) |
|
461 | void DeclarativeChart::setTitleColor(QColor color) | |
462 | { |
|
462 | { | |
463 | QBrush b = m_chart->titleBrush(); |
|
463 | QBrush b = m_chart->titleBrush(); | |
464 | if (color != b.color()) { |
|
464 | if (color != b.color()) { | |
465 | b.setColor(color); |
|
465 | b.setColor(color); | |
466 | m_chart->setTitleBrush(b); |
|
466 | m_chart->setTitleBrush(b); | |
467 | emit titleColorChanged(color); |
|
467 | emit titleColorChanged(color); | |
468 | } |
|
468 | } | |
469 | } |
|
469 | } | |
470 |
|
470 | |||
471 | QFont DeclarativeChart::titleFont() const |
|
471 | QFont DeclarativeChart::titleFont() const | |
472 | { |
|
472 | { | |
473 | return m_chart->titleFont(); |
|
473 | return m_chart->titleFont(); | |
474 | } |
|
474 | } | |
475 |
|
475 | |||
476 |
void DeclarativeChart::setTitleFont(const QFont& |
|
476 | void DeclarativeChart::setTitleFont(const QFont &font) | |
477 | { |
|
477 | { | |
478 | m_chart->setTitleFont(font); |
|
478 | m_chart->setTitleFont(font); | |
479 | } |
|
479 | } | |
480 |
|
480 | |||
481 | QColor DeclarativeChart::titleColor() |
|
481 | QColor DeclarativeChart::titleColor() | |
482 | { |
|
482 | { | |
483 | return m_chart->titleBrush().color(); |
|
483 | return m_chart->titleBrush().color(); | |
484 | } |
|
484 | } | |
485 |
|
485 | |||
486 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
486 | void DeclarativeChart::setBackgroundColor(QColor color) | |
487 | { |
|
487 | { | |
488 | QBrush b = m_chart->backgroundBrush(); |
|
488 | QBrush b = m_chart->backgroundBrush(); | |
489 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
489 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
490 | b.setStyle(Qt::SolidPattern); |
|
490 | b.setStyle(Qt::SolidPattern); | |
491 | b.setColor(color); |
|
491 | b.setColor(color); | |
492 | m_chart->setBackgroundBrush(b); |
|
492 | m_chart->setBackgroundBrush(b); | |
493 | emit backgroundColorChanged(); |
|
493 | emit backgroundColorChanged(); | |
494 | } |
|
494 | } | |
495 | } |
|
495 | } | |
496 |
|
496 | |||
497 | QColor DeclarativeChart::backgroundColor() |
|
497 | QColor DeclarativeChart::backgroundColor() | |
498 | { |
|
498 | { | |
499 | return m_chart->backgroundBrush().color(); |
|
499 | return m_chart->backgroundBrush().color(); | |
500 | } |
|
500 | } | |
501 |
|
501 | |||
502 | int DeclarativeChart::count() |
|
502 | int DeclarativeChart::count() | |
503 | { |
|
503 | { | |
504 | return m_chart->series().count(); |
|
504 | return m_chart->series().count(); | |
505 | } |
|
505 | } | |
506 |
|
506 | |||
507 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
507 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
508 | { |
|
508 | { | |
509 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
509 | if (enabled != m_chart->isDropShadowEnabled()) { | |
510 | m_chart->setDropShadowEnabled(enabled); |
|
510 | m_chart->setDropShadowEnabled(enabled); | |
511 | dropShadowEnabledChanged(enabled); |
|
511 | dropShadowEnabledChanged(enabled); | |
512 | } |
|
512 | } | |
513 | } |
|
513 | } | |
514 |
|
514 | |||
515 | bool DeclarativeChart::dropShadowEnabled() |
|
515 | bool DeclarativeChart::dropShadowEnabled() | |
516 | { |
|
516 | { | |
517 | return m_chart->isDropShadowEnabled(); |
|
517 | return m_chart->isDropShadowEnabled(); | |
518 | } |
|
518 | } | |
519 |
|
519 | |||
520 | qreal DeclarativeChart::topMargin() |
|
520 | qreal DeclarativeChart::topMargin() | |
521 | { |
|
521 | { | |
522 | qWarning() << "ChartView.topMargin is deprecated. Use minimumMargins and plotArea instead."; |
|
522 | qWarning() << "ChartView.topMargin is deprecated. Use minimumMargins and plotArea instead."; | |
523 | return m_chart->plotArea().top(); |
|
523 | return m_chart->plotArea().top(); | |
524 | } |
|
524 | } | |
525 |
|
525 | |||
526 | qreal DeclarativeChart::bottomMargin() |
|
526 | qreal DeclarativeChart::bottomMargin() | |
527 | { |
|
527 | { | |
528 |
|
528 | |||
529 | qWarning() << "ChartView.bottomMargin is deprecated. Use minimumMargins and plotArea instead."; |
|
529 | qWarning() << "ChartView.bottomMargin is deprecated. Use minimumMargins and plotArea instead."; | |
530 | return m_chart->plotArea().bottom(); |
|
530 | return m_chart->plotArea().bottom(); | |
531 | } |
|
531 | } | |
532 |
|
532 | |||
533 | qreal DeclarativeChart::leftMargin() |
|
533 | qreal DeclarativeChart::leftMargin() | |
534 | { |
|
534 | { | |
535 | qWarning() << "ChartView.leftMargin is deprecated. Use minimumMargins and plotArea instead."; |
|
535 | qWarning() << "ChartView.leftMargin is deprecated. Use minimumMargins and plotArea instead."; | |
536 | return m_chart->plotArea().left(); |
|
536 | return m_chart->plotArea().left(); | |
537 | } |
|
537 | } | |
538 |
|
538 | |||
539 | qreal DeclarativeChart::rightMargin() |
|
539 | qreal DeclarativeChart::rightMargin() | |
540 | { |
|
540 | { | |
541 | qWarning() << "ChartView.rightMargin is deprecated. Use minimumMargins and plotArea instead."; |
|
541 | qWarning() << "ChartView.rightMargin is deprecated. Use minimumMargins and plotArea instead."; | |
542 | return m_chart->plotArea().right(); |
|
542 | return m_chart->plotArea().right(); | |
543 | } |
|
543 | } | |
544 |
|
544 | |||
545 | void DeclarativeChart::zoom(qreal factor) |
|
545 | void DeclarativeChart::zoom(qreal factor) | |
546 | { |
|
546 | { | |
547 | m_chart->zoom(factor); |
|
547 | m_chart->zoom(factor); | |
548 | } |
|
548 | } | |
549 |
|
549 | |||
550 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
550 | void DeclarativeChart::scrollLeft(qreal pixels) | |
551 | { |
|
551 | { | |
552 | m_chart->scroll(-pixels, 0); |
|
552 | m_chart->scroll(-pixels, 0); | |
553 | } |
|
553 | } | |
554 |
|
554 | |||
555 | void DeclarativeChart::scrollRight(qreal pixels) |
|
555 | void DeclarativeChart::scrollRight(qreal pixels) | |
556 | { |
|
556 | { | |
557 | m_chart->scroll(pixels, 0); |
|
557 | m_chart->scroll(pixels, 0); | |
558 | } |
|
558 | } | |
559 |
|
559 | |||
560 | void DeclarativeChart::scrollUp(qreal pixels) |
|
560 | void DeclarativeChart::scrollUp(qreal pixels) | |
561 | { |
|
561 | { | |
562 | m_chart->scroll(0, pixels); |
|
562 | m_chart->scroll(0, pixels); | |
563 | } |
|
563 | } | |
564 |
|
564 | |||
565 | void DeclarativeChart::scrollDown(qreal pixels) |
|
565 | void DeclarativeChart::scrollDown(qreal pixels) | |
566 | { |
|
566 | { | |
567 | m_chart->scroll(0, -pixels); |
|
567 | m_chart->scroll(0, -pixels); | |
568 | } |
|
568 | } | |
569 |
|
569 | |||
570 | QAbstractSeries *DeclarativeChart::series(int index) |
|
570 | QAbstractSeries *DeclarativeChart::series(int index) | |
571 | { |
|
571 | { | |
572 | if (index < m_chart->series().count()) { |
|
572 | if (index < m_chart->series().count()) { | |
573 | return m_chart->series().at(index); |
|
573 | return m_chart->series().at(index); | |
574 | } |
|
574 | } | |
575 | return 0; |
|
575 | return 0; | |
576 | } |
|
576 | } | |
577 |
|
577 | |||
578 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
578 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
579 | { |
|
579 | { | |
580 | foreach (QAbstractSeries *series, m_chart->series()) { |
|
580 | foreach (QAbstractSeries *series, m_chart->series()) { | |
581 | if (series->name() == seriesName) |
|
581 | if (series->name() == seriesName) | |
582 | return series; |
|
582 | return series; | |
583 | } |
|
583 | } | |
584 | return 0; |
|
584 | return 0; | |
585 | } |
|
585 | } | |
586 |
|
586 | |||
587 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
587 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
588 | { |
|
588 | { | |
589 | return createSeries(type, name, 0, 0); |
|
589 | return createSeries(type, name, 0, 0); | |
590 | } |
|
590 | } | |
591 |
|
591 | |||
592 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) |
|
592 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) | |
593 | { |
|
593 | { | |
594 | QAbstractSeries *series = 0; |
|
594 | QAbstractSeries *series = 0; | |
595 |
|
595 | |||
596 | switch (type) { |
|
596 | switch (type) { | |
597 | case DeclarativeChart::SeriesTypeLine: |
|
597 | case DeclarativeChart::SeriesTypeLine: | |
598 | series = new DeclarativeLineSeries(); |
|
598 | series = new DeclarativeLineSeries(); | |
599 | break; |
|
599 | break; | |
600 | case DeclarativeChart::SeriesTypeArea: |
|
600 | case DeclarativeChart::SeriesTypeArea: | |
601 | series = new DeclarativeAreaSeries(); |
|
601 | series = new DeclarativeAreaSeries(); | |
602 | break; |
|
602 | break; | |
603 | case DeclarativeChart::SeriesTypeStackedBar: |
|
603 | case DeclarativeChart::SeriesTypeStackedBar: | |
604 | series = new DeclarativeStackedBarSeries(); |
|
604 | series = new DeclarativeStackedBarSeries(); | |
605 | break; |
|
605 | break; | |
606 | case DeclarativeChart::SeriesTypePercentBar: |
|
606 | case DeclarativeChart::SeriesTypePercentBar: | |
607 | series = new DeclarativePercentBarSeries(); |
|
607 | series = new DeclarativePercentBarSeries(); | |
608 | break; |
|
608 | break; | |
609 | case DeclarativeChart::SeriesTypeBar: |
|
609 | case DeclarativeChart::SeriesTypeBar: | |
610 | series = new DeclarativeBarSeries(); |
|
610 | series = new DeclarativeBarSeries(); | |
611 | break; |
|
611 | break; | |
612 | case DeclarativeChart::SeriesTypeHorizontalBar: |
|
612 | case DeclarativeChart::SeriesTypeHorizontalBar: | |
613 | series = new DeclarativeHorizontalBarSeries(); |
|
613 | series = new DeclarativeHorizontalBarSeries(); | |
614 | break; |
|
614 | break; | |
615 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: |
|
615 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: | |
616 | series = new DeclarativeHorizontalPercentBarSeries(); |
|
616 | series = new DeclarativeHorizontalPercentBarSeries(); | |
617 | break; |
|
617 | break; | |
618 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: |
|
618 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: | |
619 | series = new DeclarativeHorizontalStackedBarSeries(); |
|
619 | series = new DeclarativeHorizontalStackedBarSeries(); | |
620 | break; |
|
620 | break; | |
621 | case DeclarativeChart::SeriesTypePie: |
|
621 | case DeclarativeChart::SeriesTypePie: | |
622 | series = new DeclarativePieSeries(); |
|
622 | series = new DeclarativePieSeries(); | |
623 | break; |
|
623 | break; | |
624 | case DeclarativeChart::SeriesTypeScatter: |
|
624 | case DeclarativeChart::SeriesTypeScatter: | |
625 | series = new DeclarativeScatterSeries(); |
|
625 | series = new DeclarativeScatterSeries(); | |
626 | break; |
|
626 | break; | |
627 | case DeclarativeChart::SeriesTypeSpline: |
|
627 | case DeclarativeChart::SeriesTypeSpline: | |
628 | series = new DeclarativeSplineSeries(); |
|
628 | series = new DeclarativeSplineSeries(); | |
629 | break; |
|
629 | break; | |
630 | default: |
|
630 | default: | |
631 | qWarning() << "Illegal series type"; |
|
631 | qWarning() << "Illegal series type"; | |
632 | } |
|
632 | } | |
633 |
|
633 | |||
634 | if (series) { |
|
634 | if (series) { | |
635 | series->setName(name); |
|
635 | series->setName(name); | |
636 | m_chart->addSeries(series); |
|
636 | m_chart->addSeries(series); | |
637 | // Set possible user defined axes |
|
637 | // Set possible user defined axes | |
638 | setAxisX(axisX, series); |
|
638 | setAxisX(axisX, series); | |
639 | setAxisY(axisY, series); |
|
639 | setAxisY(axisY, series); | |
640 | // Then create the missing axes |
|
640 | // Then create the missing axes | |
641 | createDefaultAxes(series); |
|
641 | createDefaultAxes(series); | |
642 | } |
|
642 | } | |
643 |
|
643 | |||
644 | return series; |
|
644 | return series; | |
645 | } |
|
645 | } | |
646 |
|
646 | |||
647 | void DeclarativeChart::removeSeries(QAbstractSeries *series) |
|
647 | void DeclarativeChart::removeSeries(QAbstractSeries *series) | |
648 | { |
|
648 | { | |
649 | if (series) |
|
649 | if (series) | |
650 | m_chart->removeSeries(series); |
|
650 | m_chart->removeSeries(series); | |
651 | else |
|
651 | else | |
652 | qWarning("removeSeries: cannot remove null"); |
|
652 | qWarning("removeSeries: cannot remove null"); | |
653 | } |
|
653 | } | |
654 |
|
654 | |||
655 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) |
|
655 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) | |
656 | { |
|
656 | { | |
657 | if (axis) |
|
657 | if (axis) | |
658 | m_chart->setAxisX(axis, series); |
|
658 | m_chart->setAxisX(axis, series); | |
659 | } |
|
659 | } | |
660 |
|
660 | |||
661 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) |
|
661 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) | |
662 | { |
|
662 | { | |
663 | if (axis) |
|
663 | if (axis) | |
664 | m_chart->setAxisY(axis, series); |
|
664 | m_chart->setAxisY(axis, series); | |
665 | } |
|
665 | } | |
666 |
|
666 | |||
667 | void DeclarativeChart::createDefaultAxes() |
|
667 | void DeclarativeChart::createDefaultAxes() | |
668 | { |
|
668 | { | |
669 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; |
|
669 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; | |
670 | } |
|
670 | } | |
671 |
|
671 | |||
672 |
void DeclarativeChart::createDefaultAxes(QAbstractSeries* |
|
672 | void DeclarativeChart::createDefaultAxes(QAbstractSeries *series) | |
673 | { |
|
673 | { | |
674 | foreach (QAbstractSeries *s, m_chart->series()) { |
|
674 | foreach (QAbstractSeries *s, m_chart->series()) { | |
675 | // If there is already an x axis of the correct type, re-use it |
|
675 | // If there is already an x axis of the correct type, re-use it | |
676 | if (!m_chart->axisX(series) && s != series && m_chart->axisX(s) |
|
676 | if (!m_chart->axisX(series) && s != series && m_chart->axisX(s) | |
677 |
|
|
677 | && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal)) | |
678 | m_chart->setAxisX(m_chart->axisX(s), series); |
|
678 | m_chart->setAxisX(m_chart->axisX(s), series); | |
679 |
|
679 | |||
680 | // If there is already a y axis of the correct type, re-use it |
|
680 | // If there is already a y axis of the correct type, re-use it | |
681 | if (!m_chart->axisY(series) && s != series && m_chart->axisY(s) |
|
681 | if (!m_chart->axisY(series) && s != series && m_chart->axisY(s) | |
682 |
|
|
682 | && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical)) | |
683 | m_chart->setAxisY(m_chart->axisY(s), series); |
|
683 | m_chart->setAxisY(m_chart->axisY(s), series); | |
684 | } |
|
684 | } | |
685 |
|
685 | |||
686 | // If no x axis of correct type was found, create a new x axis based of default axis type |
|
686 | // If no x axis of correct type was found, create a new x axis based of default axis type | |
687 | if (!m_chart->axisX(series)) { |
|
687 | if (!m_chart->axisX(series)) { | |
688 | switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) { |
|
688 | switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) { | |
689 | case QAbstractAxis::AxisTypeValue: |
|
689 | case QAbstractAxis::AxisTypeValue: | |
690 | m_chart->setAxisX(new QValueAxis(this), series); |
|
690 | m_chart->setAxisX(new QValueAxis(this), series); | |
691 | break; |
|
691 | break; | |
692 | case QAbstractAxis::AxisTypeBarCategory: |
|
692 | case QAbstractAxis::AxisTypeBarCategory: | |
693 | m_chart->setAxisX(new QBarCategoryAxis(this), series); |
|
693 | m_chart->setAxisX(new QBarCategoryAxis(this), series); | |
694 | break; |
|
694 | break; | |
695 | case QAbstractAxis::AxisTypeCategory: |
|
695 | case QAbstractAxis::AxisTypeCategory: | |
696 | m_chart->setAxisX(new QCategoryAxis(this), series); |
|
696 | m_chart->setAxisX(new QCategoryAxis(this), series); | |
697 | break; |
|
697 | break; | |
698 | #ifndef QT_ON_ARM |
|
698 | #ifndef QT_ON_ARM | |
699 | case QAbstractAxis::AxisTypeDateTime: |
|
699 | case QAbstractAxis::AxisTypeDateTime: | |
700 | m_chart->setAxisX(new QDateTimeAxis(this), series); |
|
700 | m_chart->setAxisX(new QDateTimeAxis(this), series); | |
701 | break; |
|
701 | break; | |
702 | #endif |
|
702 | #endif | |
703 | default: |
|
703 | default: | |
704 | // Do nothing, assume AxisTypeNoAxis |
|
704 | // Do nothing, assume AxisTypeNoAxis | |
705 | break; |
|
705 | break; | |
706 | } |
|
706 | } | |
707 | } |
|
707 | } | |
708 |
|
708 | |||
709 | // If no y axis of correct type was found, create a new y axis based of default axis type |
|
709 | // If no y axis of correct type was found, create a new y axis based of default axis type | |
710 | if (!m_chart->axisY(series)) { |
|
710 | if (!m_chart->axisY(series)) { | |
711 | switch (series->d_ptr->defaultAxisType(Qt::Vertical)) { |
|
711 | switch (series->d_ptr->defaultAxisType(Qt::Vertical)) { | |
712 | case QAbstractAxis::AxisTypeValue: |
|
712 | case QAbstractAxis::AxisTypeValue: | |
713 | m_chart->setAxisY(new QValueAxis(this), series); |
|
713 | m_chart->setAxisY(new QValueAxis(this), series); | |
714 | break; |
|
714 | break; | |
715 | case QAbstractAxis::AxisTypeBarCategory: |
|
715 | case QAbstractAxis::AxisTypeBarCategory: | |
716 | m_chart->setAxisY(new QBarCategoryAxis(this), series); |
|
716 | m_chart->setAxisY(new QBarCategoryAxis(this), series); | |
717 | break; |
|
717 | break; | |
718 | case QAbstractAxis::AxisTypeCategory: |
|
718 | case QAbstractAxis::AxisTypeCategory: | |
719 | m_chart->setAxisY(new QCategoryAxis(this), series); |
|
719 | m_chart->setAxisY(new QCategoryAxis(this), series); | |
720 | break; |
|
720 | break; | |
721 | #ifndef QT_ON_ARM |
|
721 | #ifndef QT_ON_ARM | |
722 | case QAbstractAxis::AxisTypeDateTime: |
|
722 | case QAbstractAxis::AxisTypeDateTime: | |
723 | m_chart->setAxisY(new QDateTimeAxis(this), series); |
|
723 | m_chart->setAxisY(new QDateTimeAxis(this), series); | |
724 | break; |
|
724 | break; | |
725 | #endif |
|
725 | #endif | |
726 | default: |
|
726 | default: | |
727 | // Do nothing, assume AxisTypeNoAxis |
|
727 | // Do nothing, assume AxisTypeNoAxis | |
728 | break; |
|
728 | break; | |
729 | } |
|
729 | } | |
730 | } |
|
730 | } | |
731 |
|
731 | |||
732 | //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series); |
|
732 | //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series); | |
733 | } |
|
733 | } | |
734 |
|
734 | |||
735 | #include "moc_declarativechart.cpp" |
|
735 | #include "moc_declarativechart.cpp" | |
736 |
|
736 | |||
737 | QTCOMMERCIALCHART_END_NAMESPACE |
|
737 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,175 +1,175 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVECHART_H |
|
21 | #ifndef DECLARATIVECHART_H | |
22 | #define DECLARATIVECHART_H |
|
22 | #define DECLARATIVECHART_H | |
23 |
|
23 | |||
24 | #include <QtCore/QtGlobal> |
|
24 | #include <QtCore/QtGlobal> | |
25 | #ifdef QT5_QUICK_1 |
|
25 | #ifdef QT5_QUICK_1 | |
26 | #include <QtQuick1/QDeclarativeItem> |
|
26 | #include <QtQuick1/QDeclarativeItem> | |
27 | #else |
|
27 | #else | |
28 | #include <QtDeclarative/QDeclarativeItem> |
|
28 | #include <QtDeclarative/QDeclarativeItem> | |
29 | #endif |
|
29 | #endif | |
30 | #include "qchart.h" |
|
30 | #include "qchart.h" | |
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 | class DeclarativeMargins; |
|
34 | class DeclarativeMargins; | |
35 | class Domain; |
|
35 | class Domain; | |
36 |
|
36 | |||
37 | class DeclarativeChart : public QDeclarativeItem |
|
37 | class DeclarativeChart : public QDeclarativeItem | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) |
|
40 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) | |
41 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) |
|
41 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) | |
42 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
42 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
43 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) |
|
43 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | |
44 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
44 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) | |
45 | Q_PROPERTY(QLegend *legend READ legend) |
|
45 | Q_PROPERTY(QLegend *legend READ legend) | |
46 | Q_PROPERTY(int count READ count) |
|
46 | Q_PROPERTY(int count READ count) | |
47 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
47 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) | |
48 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
48 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) | |
49 | Q_PROPERTY(qreal topMargin READ topMargin) |
|
49 | Q_PROPERTY(qreal topMargin READ topMargin) | |
50 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) |
|
50 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) | |
51 | Q_PROPERTY(qreal leftMargin READ leftMargin) |
|
51 | Q_PROPERTY(qreal leftMargin READ leftMargin) | |
52 | Q_PROPERTY(qreal rightMargin READ rightMargin) |
|
52 | Q_PROPERTY(qreal rightMargin READ rightMargin) | |
53 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) |
|
53 | Q_PROPERTY(DeclarativeMargins *minimumMargins READ minimumMargins NOTIFY minimumMarginsChanged REVISION 1) | |
54 | Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2) |
|
54 | Q_PROPERTY(DeclarativeMargins *margins READ margins NOTIFY marginsChanged REVISION 2) | |
55 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) |
|
55 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged REVISION 1) | |
56 | Q_ENUMS(Animation) |
|
56 | Q_ENUMS(Animation) | |
57 | Q_ENUMS(Theme) |
|
57 | Q_ENUMS(Theme) | |
58 | Q_ENUMS(SeriesType) |
|
58 | Q_ENUMS(SeriesType) | |
59 |
|
59 | |||
60 | public: |
|
60 | public: | |
61 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api |
|
61 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api | |
62 | enum Theme { |
|
62 | enum Theme { | |
63 | ChartThemeLight = 0, |
|
63 | ChartThemeLight = 0, | |
64 | ChartThemeBlueCerulean, |
|
64 | ChartThemeBlueCerulean, | |
65 | ChartThemeDark, |
|
65 | ChartThemeDark, | |
66 | ChartThemeBrownSand, |
|
66 | ChartThemeBrownSand, | |
67 | ChartThemeBlueNcs, |
|
67 | ChartThemeBlueNcs, | |
68 | ChartThemeHighContrast, |
|
68 | ChartThemeHighContrast, | |
69 | ChartThemeBlueIcy |
|
69 | ChartThemeBlueIcy | |
70 | }; |
|
70 | }; | |
71 |
|
71 | |||
72 | enum Animation { |
|
72 | enum Animation { | |
73 | NoAnimation = 0x0, |
|
73 | NoAnimation = 0x0, | |
74 | GridAxisAnimations = 0x1, |
|
74 | GridAxisAnimations = 0x1, | |
75 | SeriesAnimations =0x2, |
|
75 | SeriesAnimations = 0x2, | |
76 | AllAnimations = 0x3 |
|
76 | AllAnimations = 0x3 | |
77 | }; |
|
77 | }; | |
78 |
|
78 | |||
79 | enum SeriesType { |
|
79 | enum SeriesType { | |
80 | SeriesTypeLine, |
|
80 | SeriesTypeLine, | |
81 | SeriesTypeArea, |
|
81 | SeriesTypeArea, | |
82 | SeriesTypeBar, |
|
82 | SeriesTypeBar, | |
83 | SeriesTypeStackedBar, |
|
83 | SeriesTypeStackedBar, | |
84 | SeriesTypePercentBar, |
|
84 | SeriesTypePercentBar, | |
85 | SeriesTypePie, |
|
85 | SeriesTypePie, | |
86 | SeriesTypeScatter, |
|
86 | SeriesTypeScatter, | |
87 | SeriesTypeSpline, |
|
87 | SeriesTypeSpline, | |
88 | SeriesTypeHorizontalBar, |
|
88 | SeriesTypeHorizontalBar, | |
89 | SeriesTypeHorizontalStackedBar, |
|
89 | SeriesTypeHorizontalStackedBar, | |
90 | SeriesTypeHorizontalPercentBar |
|
90 | SeriesTypeHorizontalPercentBar | |
91 | }; |
|
91 | }; | |
92 |
|
92 | |||
93 | public: |
|
93 | public: | |
94 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
94 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
95 | ~DeclarativeChart(); |
|
95 | ~DeclarativeChart(); | |
96 |
|
96 | |||
97 | public: // From QDeclarativeItem/QGraphicsItem |
|
97 | public: // From QDeclarativeItem/QGraphicsItem | |
98 | void childEvent(QChildEvent *event); |
|
98 | void childEvent(QChildEvent *event); | |
99 | void componentComplete(); |
|
99 | void componentComplete(); | |
100 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
100 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
101 |
|
101 | |||
102 | public: |
|
102 | public: | |
103 | void setTheme(DeclarativeChart::Theme theme); |
|
103 | void setTheme(DeclarativeChart::Theme theme); | |
104 | DeclarativeChart::Theme theme(); |
|
104 | DeclarativeChart::Theme theme(); | |
105 | void setAnimationOptions(DeclarativeChart::Animation animations); |
|
105 | void setAnimationOptions(DeclarativeChart::Animation animations); | |
106 | DeclarativeChart::Animation animationOptions(); |
|
106 | DeclarativeChart::Animation animationOptions(); | |
107 | void setTitle(QString title); |
|
107 | void setTitle(QString title); | |
108 | QString title(); |
|
108 | QString title(); | |
109 | QLegend *legend(); |
|
109 | QLegend *legend(); | |
110 | QFont titleFont() const; |
|
110 | QFont titleFont() const; | |
111 |
void setTitleFont(const QFont& |
|
111 | void setTitleFont(const QFont &font); | |
112 | void setTitleColor(QColor color); |
|
112 | void setTitleColor(QColor color); | |
113 | QColor titleColor(); |
|
113 | QColor titleColor(); | |
114 | void setBackgroundColor(QColor color); |
|
114 | void setBackgroundColor(QColor color); | |
115 | QColor backgroundColor(); |
|
115 | QColor backgroundColor(); | |
116 | int count(); |
|
116 | int count(); | |
117 | void setDropShadowEnabled(bool enabled); |
|
117 | void setDropShadowEnabled(bool enabled); | |
118 | bool dropShadowEnabled(); |
|
118 | bool dropShadowEnabled(); | |
119 | qreal topMargin(); |
|
119 | qreal topMargin(); | |
120 | qreal bottomMargin(); |
|
120 | qreal bottomMargin(); | |
121 | qreal leftMargin(); |
|
121 | qreal leftMargin(); | |
122 | qreal rightMargin(); |
|
122 | qreal rightMargin(); | |
123 |
void createDefaultAxes(QAbstractSeries* |
|
123 | void createDefaultAxes(QAbstractSeries *series); | |
124 | //TODO this is depreciated: |
|
124 | //TODO this is depreciated: | |
125 | DeclarativeMargins *minimumMargins() { return m_margins; } |
|
125 | DeclarativeMargins *minimumMargins() { return m_margins; } | |
126 |
|
126 | |||
127 | Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } |
|
127 | Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; } | |
128 | QRectF plotArea() { return m_chart->plotArea(); } |
|
128 | QRectF plotArea() { return m_chart->plotArea(); } | |
129 |
|
129 | |||
130 | public: |
|
130 | public: | |
131 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
131 | Q_INVOKABLE QAbstractSeries *series(int index); | |
132 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
132 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
133 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
133 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
134 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY); |
|
134 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY); | |
135 | Q_INVOKABLE void removeSeries(QAbstractSeries *series); |
|
135 | Q_INVOKABLE void removeSeries(QAbstractSeries *series); | |
136 | Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); } |
|
136 | Q_INVOKABLE void removeAllSeries() { m_chart->removeAllSeries(); } | |
137 | Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); |
|
137 | Q_INVOKABLE void setAxisX(QAbstractAxis *axis, QAbstractSeries *series = 0); | |
138 | Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); |
|
138 | Q_INVOKABLE void setAxisY(QAbstractAxis *axis, QAbstractSeries *series = 0); | |
139 | Q_INVOKABLE void createDefaultAxes(); |
|
139 | Q_INVOKABLE void createDefaultAxes(); | |
140 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); |
|
140 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); | |
141 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); |
|
141 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); | |
142 | Q_INVOKABLE void zoom(qreal factor); |
|
142 | Q_INVOKABLE void zoom(qreal factor); | |
143 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
143 | Q_INVOKABLE void scrollLeft(qreal pixels); | |
144 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
144 | Q_INVOKABLE void scrollRight(qreal pixels); | |
145 | Q_INVOKABLE void scrollUp(qreal pixels); |
|
145 | Q_INVOKABLE void scrollUp(qreal pixels); | |
146 | Q_INVOKABLE void scrollDown(qreal pixels); |
|
146 | Q_INVOKABLE void scrollDown(qreal pixels); | |
147 |
|
147 | |||
148 | Q_SIGNALS: |
|
148 | Q_SIGNALS: | |
149 | void axisLabelsChanged(); |
|
149 | void axisLabelsChanged(); | |
150 | void titleColorChanged(QColor color); |
|
150 | void titleColorChanged(QColor color); | |
151 | void backgroundColorChanged(); |
|
151 | void backgroundColorChanged(); | |
152 | void dropShadowEnabledChanged(bool enabled); |
|
152 | void dropShadowEnabledChanged(bool enabled); | |
153 | void minimumMarginsChanged(); |
|
153 | void minimumMarginsChanged(); | |
154 | Q_REVISION(2) void marginsChanged(); |
|
154 | Q_REVISION(2) void marginsChanged(); | |
155 | void plotAreaChanged(QRectF plotArea); |
|
155 | void plotAreaChanged(QRectF plotArea); | |
156 |
void seriesAdded(QAbstractSeries* |
|
156 | void seriesAdded(QAbstractSeries *series); | |
157 |
void seriesRemoved(QAbstractSeries* |
|
157 | void seriesRemoved(QAbstractSeries *series); | |
158 |
|
158 | |||
159 | public Q_SLOTS: |
|
159 | public Q_SLOTS: | |
160 | void changeMinimumMargins(int top, int bottom, int left, int right); |
|
160 | void changeMinimumMargins(int top, int bottom, int left, int right); | |
161 | void handleAxisXSet(QAbstractAxis *axis); |
|
161 | void handleAxisXSet(QAbstractAxis *axis); | |
162 | void handleAxisYSet(QAbstractAxis *axis); |
|
162 | void handleAxisYSet(QAbstractAxis *axis); | |
163 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); |
|
163 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); | |
164 |
|
164 | |||
165 | private: |
|
165 | private: | |
166 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
166 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
167 | // multi inheritance, so we now have a QChart as a member instead |
|
167 | // multi inheritance, so we now have a QChart as a member instead | |
168 | QChart *m_chart; |
|
168 | QChart *m_chart; | |
169 | //QMargins m_chartMargins; |
|
169 | //QMargins m_chartMargins; | |
170 | DeclarativeMargins *m_margins; |
|
170 | DeclarativeMargins *m_margins; | |
171 | }; |
|
171 | }; | |
172 |
|
172 | |||
173 | QTCOMMERCIALCHART_END_NAMESPACE |
|
173 | QTCOMMERCIALCHART_END_NAMESPACE | |
174 |
|
174 | |||
175 | #endif // DECLARATIVECHART_H |
|
175 | #endif // DECLARATIVECHART_H |
@@ -1,117 +1,117 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativepieseries.h" |
|
21 | #include "declarativepieseries.h" | |
22 | #include "qpieslice.h" |
|
22 | #include "qpieslice.h" | |
23 | #include "qvpiemodelmapper.h" |
|
23 | #include "qvpiemodelmapper.h" | |
24 | #include "qhpiemodelmapper.h" |
|
24 | #include "qhpiemodelmapper.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | DeclarativePieSeries::DeclarativePieSeries(QDeclarativeItem *parent) : |
|
28 | DeclarativePieSeries::DeclarativePieSeries(QDeclarativeItem *parent) : | |
29 | QPieSeries(parent) |
|
29 | QPieSeries(parent) | |
30 | { |
|
30 | { | |
31 | connect(this, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleAdded(QList<QPieSlice*>))); |
|
31 | connect(this, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleAdded(QList<QPieSlice*>))); | |
32 | connect(this, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleRemoved(QList<QPieSlice*>))); |
|
32 | connect(this, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleRemoved(QList<QPieSlice*>))); | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | void DeclarativePieSeries::classBegin() |
|
35 | void DeclarativePieSeries::classBegin() | |
36 | { |
|
36 | { | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | void DeclarativePieSeries::componentComplete() |
|
39 | void DeclarativePieSeries::componentComplete() | |
40 | { |
|
40 | { | |
41 | foreach (QObject *child, children()) { |
|
41 | foreach (QObject *child, children()) { | |
42 | if (qobject_cast<QPieSlice *>(child)) { |
|
42 | if (qobject_cast<QPieSlice *>(child)) { | |
43 | QPieSeries::append(qobject_cast<QPieSlice *>(child)); |
|
43 | QPieSeries::append(qobject_cast<QPieSlice *>(child)); | |
44 | } else if(qobject_cast<QVPieModelMapper *>(child)) { |
|
44 | } else if (qobject_cast<QVPieModelMapper *>(child)) { | |
45 | QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); |
|
45 | QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); | |
46 | mapper->setSeries(this); |
|
46 | mapper->setSeries(this); | |
47 | } else if(qobject_cast<QHPieModelMapper *>(child)) { |
|
47 | } else if (qobject_cast<QHPieModelMapper *>(child)) { | |
48 | QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child); |
|
48 | QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child); | |
49 | mapper->setSeries(this); |
|
49 | mapper->setSeries(this); | |
50 | } |
|
50 | } | |
51 | } |
|
51 | } | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren() |
|
54 | QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren() | |
55 | { |
|
55 | { | |
56 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren); |
|
56 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren); | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
59 | void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) | |
60 | { |
|
60 | { | |
61 | // Empty implementation; the children are parsed in componentComplete instead |
|
61 | // Empty implementation; the children are parsed in componentComplete instead | |
62 | Q_UNUSED(list); |
|
62 | Q_UNUSED(list); | |
63 | Q_UNUSED(element); |
|
63 | Q_UNUSED(element); | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | QPieSlice *DeclarativePieSeries::at(int index) |
|
66 | QPieSlice *DeclarativePieSeries::at(int index) | |
67 | { |
|
67 | { | |
68 | QList<QPieSlice*> sliceList = slices(); |
|
68 | QList<QPieSlice *> sliceList = slices(); | |
69 | if (index >= 0 && index < sliceList.count()) |
|
69 | if (index >= 0 && index < sliceList.count()) | |
70 | return sliceList[index]; |
|
70 | return sliceList[index]; | |
71 |
|
71 | |||
72 | return 0; |
|
72 | return 0; | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 |
QPieSlice* |
|
75 | QPieSlice *DeclarativePieSeries::find(QString label) | |
76 | { |
|
76 | { | |
77 | foreach (QPieSlice *slice, slices()) { |
|
77 | foreach (QPieSlice *slice, slices()) { | |
78 | if (slice->label() == label) |
|
78 | if (slice->label() == label) | |
79 | return slice; |
|
79 | return slice; | |
80 | } |
|
80 | } | |
81 | return 0; |
|
81 | return 0; | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 |
QPieSlice* |
|
84 | QPieSlice *DeclarativePieSeries::append(QString label, qreal value) | |
85 | { |
|
85 | { | |
86 | QPieSlice *slice = new QPieSlice(this); |
|
86 | QPieSlice *slice = new QPieSlice(this); | |
87 | slice->setLabel(label); |
|
87 | slice->setLabel(label); | |
88 | slice->setValue(value); |
|
88 | slice->setValue(value); | |
89 | QPieSeries::append(slice); |
|
89 | QPieSeries::append(slice); | |
90 | return slice; |
|
90 | return slice; | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 | bool DeclarativePieSeries::remove(QPieSlice *slice) |
|
93 | bool DeclarativePieSeries::remove(QPieSlice *slice) | |
94 | { |
|
94 | { | |
95 | return QPieSeries::remove(slice); |
|
95 | return QPieSeries::remove(slice); | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | void DeclarativePieSeries::clear() |
|
98 | void DeclarativePieSeries::clear() | |
99 | { |
|
99 | { | |
100 | QPieSeries::clear(); |
|
100 | QPieSeries::clear(); | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | void DeclarativePieSeries::handleAdded(QList<QPieSlice*> slices) |
|
103 | void DeclarativePieSeries::handleAdded(QList<QPieSlice *> slices) | |
104 | { |
|
104 | { | |
105 | foreach (QPieSlice *slice, slices) |
|
105 | foreach (QPieSlice *slice, slices) | |
106 | emit sliceAdded(slice); |
|
106 | emit sliceAdded(slice); | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | void DeclarativePieSeries::handleRemoved(QList<QPieSlice*> slices) |
|
109 | void DeclarativePieSeries::handleRemoved(QList<QPieSlice *> slices) | |
110 | { |
|
110 | { | |
111 | foreach (QPieSlice *slice, slices) |
|
111 | foreach (QPieSlice *slice, slices) | |
112 | emit sliceRemoved(slice); |
|
112 | emit sliceRemoved(slice); | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | #include "moc_declarativepieseries.cpp" |
|
115 | #include "moc_declarativepieseries.cpp" | |
116 |
|
116 | |||
117 | QTCOMMERCIALCHART_END_NAMESPACE |
|
117 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,68 +1,68 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVEPIESERIES_H |
|
21 | #ifndef DECLARATIVEPIESERIES_H | |
22 | #define DECLARATIVEPIESERIES_H |
|
22 | #define DECLARATIVEPIESERIES_H | |
23 |
|
23 | |||
24 | #include "qpieseries.h" |
|
24 | #include "qpieseries.h" | |
25 | #ifdef QT5_QUICK_1 |
|
25 | #ifdef QT5_QUICK_1 | |
26 | #include <QtQuick1/QDeclarativeItem> |
|
26 | #include <QtQuick1/QDeclarativeItem> | |
27 | #include <QtQuick1/QDeclarativeParserStatus> |
|
27 | #include <QtQuick1/QDeclarativeParserStatus> | |
28 | #else |
|
28 | #else | |
29 | #include <QtDeclarative/QDeclarativeItem> |
|
29 | #include <QtDeclarative/QDeclarativeItem> | |
30 | #include <QtDeclarative/QDeclarativeParserStatus> |
|
30 | #include <QtDeclarative/QDeclarativeParserStatus> | |
31 | #endif |
|
31 | #endif | |
32 |
|
32 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 | class QPieSlice; |
|
34 | class QPieSlice; | |
35 |
|
35 | |||
36 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus |
|
36 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 | Q_INTERFACES(QDeclarativeParserStatus) |
|
39 | Q_INTERFACES(QDeclarativeParserStatus) | |
40 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
40 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
41 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
41 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
42 |
|
42 | |||
43 | public: |
|
43 | public: | |
44 | explicit DeclarativePieSeries(QDeclarativeItem *parent = 0); |
|
44 | explicit DeclarativePieSeries(QDeclarativeItem *parent = 0); | |
45 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
45 | QDeclarativeListProperty<QObject> seriesChildren(); | |
46 | Q_INVOKABLE QPieSlice *at(int index); |
|
46 | Q_INVOKABLE QPieSlice *at(int index); | |
47 | Q_INVOKABLE QPieSlice *find(QString label); |
|
47 | Q_INVOKABLE QPieSlice *find(QString label); | |
48 | Q_INVOKABLE QPieSlice *append(QString label, qreal value); |
|
48 | Q_INVOKABLE QPieSlice *append(QString label, qreal value); | |
49 | Q_INVOKABLE bool remove(QPieSlice *slice); |
|
49 | Q_INVOKABLE bool remove(QPieSlice *slice); | |
50 | Q_INVOKABLE void clear(); |
|
50 | Q_INVOKABLE void clear(); | |
51 |
|
51 | |||
52 | public: |
|
52 | public: | |
53 | void classBegin(); |
|
53 | void classBegin(); | |
54 | void componentComplete(); |
|
54 | void componentComplete(); | |
55 |
|
55 | |||
56 | Q_SIGNALS: |
|
56 | Q_SIGNALS: | |
57 |
void sliceAdded(QPieSlice* |
|
57 | void sliceAdded(QPieSlice *slice); | |
58 |
void sliceRemoved(QPieSlice* |
|
58 | void sliceRemoved(QPieSlice *slice); | |
59 |
|
59 | |||
60 | public Q_SLOTS: |
|
60 | public Q_SLOTS: | |
61 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
61 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
62 | void handleAdded(QList<QPieSlice*> slices); |
|
62 | void handleAdded(QList<QPieSlice *> slices); | |
63 | void handleRemoved(QList<QPieSlice*> slices); |
|
63 | void handleRemoved(QList<QPieSlice *> slices); | |
64 | }; |
|
64 | }; | |
65 |
|
65 | |||
66 | QTCOMMERCIALCHART_END_NAMESPACE |
|
66 | QTCOMMERCIALCHART_END_NAMESPACE | |
67 |
|
67 | |||
68 | #endif // DECLARATIVEPIESERIES_H |
|
68 | #endif // DECLARATIVEPIESERIES_H |
@@ -1,104 +1,104 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
|
21 | |||
22 | #include "declarativexyseries.h" |
|
22 | #include "declarativexyseries.h" | |
23 | #include "declarativexypoint.h" |
|
23 | #include "declarativexypoint.h" | |
24 | #include "qvxymodelmapper.h" |
|
24 | #include "qvxymodelmapper.h" | |
25 | #include "qhxymodelmapper.h" |
|
25 | #include "qhxymodelmapper.h" | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | DeclarativeXySeries::DeclarativeXySeries() |
|
29 | DeclarativeXySeries::DeclarativeXySeries() | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | DeclarativeXySeries::~DeclarativeXySeries() |
|
33 | DeclarativeXySeries::~DeclarativeXySeries() | |
34 | { |
|
34 | { | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | void DeclarativeXySeries::classBegin() |
|
37 | void DeclarativeXySeries::classBegin() | |
38 | { |
|
38 | { | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | void DeclarativeXySeries::componentComplete() |
|
41 | void DeclarativeXySeries::componentComplete() | |
42 | { |
|
42 | { | |
43 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
43 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
44 | Q_ASSERT(series); |
|
44 | Q_ASSERT(series); | |
45 |
|
45 | |||
46 | foreach (QObject *child, series->children()) { |
|
46 | foreach (QObject *child, series->children()) { | |
47 | if (qobject_cast<DeclarativeXYPoint *>(child)) { |
|
47 | if (qobject_cast<DeclarativeXYPoint *>(child)) { | |
48 | DeclarativeXYPoint *point = qobject_cast<DeclarativeXYPoint *>(child); |
|
48 | DeclarativeXYPoint *point = qobject_cast<DeclarativeXYPoint *>(child); | |
49 | series->append(point->x(), point->y()); |
|
49 | series->append(point->x(), point->y()); | |
50 | } else if(qobject_cast<QVXYModelMapper *>(child)) { |
|
50 | } else if (qobject_cast<QVXYModelMapper *>(child)) { | |
51 | QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child); |
|
51 | QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child); | |
52 | mapper->setSeries(series); |
|
52 | mapper->setSeries(series); | |
53 | } else if(qobject_cast<QHXYModelMapper *>(child)) { |
|
53 | } else if (qobject_cast<QHXYModelMapper *>(child)) { | |
54 | QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child); |
|
54 | QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child); | |
55 | mapper->setSeries(series); |
|
55 | mapper->setSeries(series); | |
56 | } |
|
56 | } | |
57 | } |
|
57 | } | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | void DeclarativeXySeries::append(qreal x, qreal y) |
|
60 | void DeclarativeXySeries::append(qreal x, qreal y) | |
61 | { |
|
61 | { | |
62 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
62 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
63 | Q_ASSERT(series); |
|
63 | Q_ASSERT(series); | |
64 | series->append(x, y); |
|
64 | series->append(x, y); | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) |
|
67 | void DeclarativeXySeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) | |
68 | { |
|
68 | { | |
69 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
69 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
70 | Q_ASSERT(series); |
|
70 | Q_ASSERT(series); | |
71 | series->replace(oldX, oldY, newX, newY); |
|
71 | series->replace(oldX, oldY, newX, newY); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | void DeclarativeXySeries::remove(qreal x, qreal y) |
|
74 | void DeclarativeXySeries::remove(qreal x, qreal y) | |
75 | { |
|
75 | { | |
76 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
76 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
77 | Q_ASSERT(series); |
|
77 | Q_ASSERT(series); | |
78 | series->remove(x, y); |
|
78 | series->remove(x, y); | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | void DeclarativeXySeries::insert(int index, qreal x, qreal y) |
|
81 | void DeclarativeXySeries::insert(int index, qreal x, qreal y) | |
82 | { |
|
82 | { | |
83 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
83 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
84 | Q_ASSERT(series); |
|
84 | Q_ASSERT(series); | |
85 | series->insert(index, QPointF(x, y)); |
|
85 | series->insert(index, QPointF(x, y)); | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | void DeclarativeXySeries::clear() |
|
88 | void DeclarativeXySeries::clear() | |
89 | { |
|
89 | { | |
90 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
90 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
91 | Q_ASSERT(series); |
|
91 | Q_ASSERT(series); | |
92 | series->clear(); |
|
92 | series->clear(); | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | QPointF DeclarativeXySeries::at(int index) |
|
95 | QPointF DeclarativeXySeries::at(int index) | |
96 | { |
|
96 | { | |
97 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
97 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
98 | Q_ASSERT(series); |
|
98 | Q_ASSERT(series); | |
99 | if (index >= 0 || index < series->count()) |
|
99 | if (index >= 0 || index < series->count()) | |
100 | return series->points().at(index); |
|
100 | return series->points().at(index); | |
101 | return QPointF(0, 0); |
|
101 | return QPointF(0, 0); | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | QTCOMMERCIALCHART_END_NAMESPACE |
|
104 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,181 +1,181 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifdef QT5_QUICK_1 |
|
21 | #ifdef QT5_QUICK_1 | |
22 | #include <QtQuick1/qdeclarativeextensionplugin.h> |
|
22 | #include <QtQuick1/qdeclarativeextensionplugin.h> | |
23 | #include <QtQuick1/qdeclarative.h> |
|
23 | #include <QtQuick1/qdeclarative.h> | |
24 | #else |
|
24 | #else | |
25 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
25 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |
26 | #include <QtDeclarative/qdeclarative.h> |
|
26 | #include <QtDeclarative/qdeclarative.h> | |
27 | #endif |
|
27 | #endif | |
28 | #include "qchart.h" |
|
28 | #include "qchart.h" | |
29 | #include "qabstractaxis.h" |
|
29 | #include "qabstractaxis.h" | |
30 | #include "qvalueaxis.h" |
|
30 | #include "qvalueaxis.h" | |
31 | #include "declarativecategoryaxis.h" |
|
31 | #include "declarativecategoryaxis.h" | |
32 | #include "qbarcategoryaxis.h" |
|
32 | #include "qbarcategoryaxis.h" | |
33 | #include "declarativechart.h" |
|
33 | #include "declarativechart.h" | |
34 | #include "declarativexypoint.h" |
|
34 | #include "declarativexypoint.h" | |
35 | #include "declarativelineseries.h" |
|
35 | #include "declarativelineseries.h" | |
36 | #include "declarativesplineseries.h" |
|
36 | #include "declarativesplineseries.h" | |
37 | #include "declarativeareaseries.h" |
|
37 | #include "declarativeareaseries.h" | |
38 | #include "declarativescatterseries.h" |
|
38 | #include "declarativescatterseries.h" | |
39 | #include "declarativebarseries.h" |
|
39 | #include "declarativebarseries.h" | |
40 | #include "declarativepieseries.h" |
|
40 | #include "declarativepieseries.h" | |
41 | #include "qvxymodelmapper.h" |
|
41 | #include "qvxymodelmapper.h" | |
42 | #include "qhxymodelmapper.h" |
|
42 | #include "qhxymodelmapper.h" | |
43 | #include "qhpiemodelmapper.h" |
|
43 | #include "qhpiemodelmapper.h" | |
44 | #include "qvpiemodelmapper.h" |
|
44 | #include "qvpiemodelmapper.h" | |
45 | #include "qhbarmodelmapper.h" |
|
45 | #include "qhbarmodelmapper.h" | |
46 | #include "qvbarmodelmapper.h" |
|
46 | #include "qvbarmodelmapper.h" | |
47 | #include "declarativemargins.h" |
|
47 | #include "declarativemargins.h" | |
48 | #include <QAbstractItemModel> |
|
48 | #include <QAbstractItemModel> | |
49 |
|
49 | |||
50 | #ifndef QT_ON_ARM |
|
50 | #ifndef QT_ON_ARM | |
51 | #include "qdatetimeaxis.h" |
|
51 | #include "qdatetimeaxis.h" | |
52 | #endif |
|
52 | #endif | |
53 |
|
53 | |||
54 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
54 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
55 |
|
55 | |||
56 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
56 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | |
57 | { |
|
57 | { | |
58 | Q_OBJECT |
|
58 | Q_OBJECT | |
59 |
|
59 | |||
60 | #ifdef QT5_QUICK_1 |
|
60 | #ifdef QT5_QUICK_1 | |
61 | // TODO: fix the metadata |
|
61 | // TODO: fix the metadata | |
62 | Q_PLUGIN_METADATA(IID "org.qt-project.foo") |
|
62 | Q_PLUGIN_METADATA(IID "org.qt-project.foo") | |
63 | #endif |
|
63 | #endif | |
64 |
|
64 | |||
65 |
|
|
65 | public: | |
66 | virtual void registerTypes(const char *uri) |
|
66 | virtual void registerTypes(const char *uri) | |
67 | { |
|
67 | { | |
68 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
68 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
69 |
|
69 | |||
70 | // QtCommercial.Chart 1.0 |
|
70 | // QtCommercial.Chart 1.0 | |
71 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
71 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | |
72 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); |
|
72 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); | |
73 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
73 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
74 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
74 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
75 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
75 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
76 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
76 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | |
77 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
77 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
78 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); |
|
78 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); | |
79 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); |
|
79 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); | |
80 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
80 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
81 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
81 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
82 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
82 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
83 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); |
|
83 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); | |
84 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); |
|
84 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); | |
85 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); |
|
85 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); | |
86 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); |
|
86 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); | |
87 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); |
|
87 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); | |
88 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); |
|
88 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); | |
89 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); |
|
89 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); | |
90 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); |
|
90 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); | |
91 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", |
|
91 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", | |
92 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
92 | QLatin1String("Trying to create uncreatable: Legend.")); | |
93 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", |
|
93 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", | |
94 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
94 | QLatin1String("Trying to create uncreatable: XYSeries.")); | |
95 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
95 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
96 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
96 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
97 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
97 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
98 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
98 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
99 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
99 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
100 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
100 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
101 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", |
|
101 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", | |
102 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
102 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | |
103 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
103 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | |
104 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
104 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
105 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", |
|
105 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", | |
106 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); |
|
106 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); | |
107 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", |
|
107 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", | |
108 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); |
|
108 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); | |
109 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", |
|
109 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", | |
110 | QLatin1String("Trying to create uncreatable: BarsetBase.")); |
|
110 | QLatin1String("Trying to create uncreatable: BarsetBase.")); | |
111 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
111 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", | |
112 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); |
|
112 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); | |
113 |
|
113 | |||
114 | // QtCommercial.Chart 1.1 |
|
114 | // QtCommercial.Chart 1.1 | |
115 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); |
|
115 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); | |
116 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 1, "XYPoint"); |
|
116 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 1, "XYPoint"); | |
117 | qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries"); |
|
117 | qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries"); | |
118 | qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries"); |
|
118 | qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries"); | |
119 | qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries"); |
|
119 | qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries"); | |
120 | qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries"); |
|
120 | qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries"); | |
121 | qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries"); |
|
121 | qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries"); | |
122 | qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries"); |
|
122 | qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries"); | |
123 | qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries"); |
|
123 | qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries"); | |
124 | qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries"); |
|
124 | qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries"); | |
125 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries"); |
|
125 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries"); | |
126 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries"); |
|
126 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries"); | |
127 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries"); |
|
127 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries"); | |
128 | qmlRegisterType<QPieSlice>(uri, 1, 1, "PieSlice"); |
|
128 | qmlRegisterType<QPieSlice>(uri, 1, 1, "PieSlice"); | |
129 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet"); |
|
129 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet"); | |
130 | qmlRegisterType<QHXYModelMapper>(uri, 1, 1, "HXYModelMapper"); |
|
130 | qmlRegisterType<QHXYModelMapper>(uri, 1, 1, "HXYModelMapper"); | |
131 | qmlRegisterType<QVXYModelMapper>(uri, 1, 1, "VXYModelMapper"); |
|
131 | qmlRegisterType<QVXYModelMapper>(uri, 1, 1, "VXYModelMapper"); | |
132 | qmlRegisterType<QHPieModelMapper>(uri, 1, 1, "HPieModelMapper"); |
|
132 | qmlRegisterType<QHPieModelMapper>(uri, 1, 1, "HPieModelMapper"); | |
133 | qmlRegisterType<QVPieModelMapper>(uri, 1, 1, "VPieModelMapper"); |
|
133 | qmlRegisterType<QVPieModelMapper>(uri, 1, 1, "VPieModelMapper"); | |
134 | qmlRegisterType<QHBarModelMapper>(uri, 1, 1, "HBarModelMapper"); |
|
134 | qmlRegisterType<QHBarModelMapper>(uri, 1, 1, "HBarModelMapper"); | |
135 | qmlRegisterType<QVBarModelMapper>(uri, 1, 1, "VBarModelMapper"); |
|
135 | qmlRegisterType<QVBarModelMapper>(uri, 1, 1, "VBarModelMapper"); | |
136 | qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis"); |
|
136 | qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis"); | |
137 | #ifndef QT_ON_ARM |
|
137 | #ifndef QT_ON_ARM | |
138 | qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); |
|
138 | qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); | |
139 | #endif |
|
139 | #endif | |
140 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); |
|
140 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); | |
141 | qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); |
|
141 | qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); | |
142 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); |
|
142 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); | |
143 | qmlRegisterUncreatableType<QLegend>(uri, 1, 1, "Legend", |
|
143 | qmlRegisterUncreatableType<QLegend>(uri, 1, 1, "Legend", | |
144 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
144 | QLatin1String("Trying to create uncreatable: Legend.")); | |
145 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 1, "XYSeries", |
|
145 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 1, "XYSeries", | |
146 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
146 | QLatin1String("Trying to create uncreatable: XYSeries.")); | |
147 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 1, "AbstractItemModel", |
|
147 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 1, "AbstractItemModel", | |
148 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
148 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
149 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 1, "XYModelMapper", |
|
149 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 1, "XYModelMapper", | |
150 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
150 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
151 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 1, "PieModelMapper", |
|
151 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 1, "PieModelMapper", | |
152 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
152 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
153 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 1, "BarModelMapper", |
|
153 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 1, "BarModelMapper", | |
154 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
154 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | |
155 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 1, "AbstractSeries", |
|
155 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 1, "AbstractSeries", | |
156 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
156 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
157 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 1, "AbstractBarSeries", |
|
157 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 1, "AbstractBarSeries", | |
158 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); |
|
158 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); | |
159 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 1, "AbstractAxis", |
|
159 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 1, "AbstractAxis", | |
160 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); |
|
160 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); | |
161 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 1, "BarSetBase", |
|
161 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 1, "BarSetBase", | |
162 | QLatin1String("Trying to create uncreatable: BarsetBase.")); |
|
162 | QLatin1String("Trying to create uncreatable: BarsetBase.")); | |
163 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 1, "QPieSeries", |
|
163 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 1, "QPieSeries", | |
164 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); |
|
164 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); | |
165 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", |
|
165 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", | |
166 | QLatin1String("Trying to create uncreatable: Margins.")); |
|
166 | QLatin1String("Trying to create uncreatable: Margins.")); | |
167 |
|
167 | |||
168 | // QtCommercial.Chart 1.2 |
|
168 | // QtCommercial.Chart 1.2 | |
169 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); |
|
169 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); | |
170 | } |
|
170 | } | |
171 | }; |
|
171 | }; | |
172 |
|
172 | |||
173 | #include "plugin.moc" |
|
173 | #include "plugin.moc" | |
174 |
|
174 | |||
175 | QTCOMMERCIALCHART_END_NAMESPACE |
|
175 | QTCOMMERCIALCHART_END_NAMESPACE | |
176 |
|
176 | |||
177 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
177 | QTCOMMERCIALCHART_USE_NAMESPACE | |
178 |
|
178 | |||
179 | #ifndef QT5_QUICK_1 |
|
179 | #ifndef QT5_QUICK_1 | |
180 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
180 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) | |
181 | #endif |
|
181 | #endif |
@@ -1,91 +1,90 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qchartsplugin.h" |
|
21 | #include "qchartsplugin.h" | |
22 | #include "qchartview.h" |
|
22 | #include "qchartview.h" | |
23 | #include <QtPlugin> |
|
23 | #include <QtPlugin> | |
24 |
|
24 | |||
25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
25 | QTCOMMERCIALCHART_USE_NAMESPACE | |
26 |
|
26 | |||
27 | QChartsPlugin::QChartsPlugin(QObject *parent) : |
|
27 | QChartsPlugin::QChartsPlugin(QObject *parent) : | |
28 | QObject(parent) |
|
28 | QObject(parent) | |
29 | { |
|
29 | { | |
30 | // TODO Auto-generated constructor stub |
|
30 | // TODO Auto-generated constructor stub | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | QChartsPlugin::~QChartsPlugin() |
|
33 | QChartsPlugin::~QChartsPlugin() | |
34 | { |
|
34 | { | |
35 | // TODO Auto-generated destructor stub |
|
35 | // TODO Auto-generated destructor stub | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | QString QChartsPlugin::name() const |
|
38 | QString QChartsPlugin::name() const | |
39 | { |
|
39 | { | |
40 | return "QChartView"; |
|
40 | return "QChartView"; | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | QString QChartsPlugin::includeFile() const |
|
43 | QString QChartsPlugin::includeFile() const | |
44 | { |
|
44 | { | |
45 |
|
|
45 | #ifdef linux | |
46 | QString myNewLine = "\n"; |
|
46 | QString myNewLine = "\n"; | |
47 |
|
|
47 | #endif | |
48 |
|
|
48 | #ifdef WIN32 | |
49 | QString myNewLine = "\n\r"; |
|
49 | QString myNewLine = "\n\r"; | |
50 |
|
|
50 | #endif | |
51 |
|
|
51 | #ifdef __APPLE__ | |
52 | QString myNewLine = "\n"; |
|
52 | QString myNewLine = "\n"; | |
53 |
|
|
53 | #endif | |
54 |
|
||||
55 | return "<qchartview.h>" + myNewLine + "#include <chartsnamespace.h>"; |
|
54 | return "<qchartview.h>" + myNewLine + "#include <chartsnamespace.h>"; | |
56 | } |
|
55 | } | |
57 |
|
56 | |||
58 | QString QChartsPlugin::group() const |
|
57 | QString QChartsPlugin::group() const | |
59 | { |
|
58 | { | |
60 | return tr("QCharts Widgets"); |
|
59 | return tr("QCharts Widgets"); | |
61 | } |
|
60 | } | |
62 |
|
61 | |||
63 | QIcon QChartsPlugin::icon() const |
|
62 | QIcon QChartsPlugin::icon() const | |
64 | { |
|
63 | { | |
65 | return QIcon(":/images/qcharts.png"); |
|
64 | return QIcon(":/images/qcharts.png"); | |
66 | } |
|
65 | } | |
67 |
|
66 | |||
68 | QString QChartsPlugin::toolTip() const |
|
67 | QString QChartsPlugin::toolTip() const | |
69 | { |
|
68 | { | |
70 | return tr("An qcharts view widget"); |
|
69 | return tr("An qcharts view widget"); | |
71 | } |
|
70 | } | |
72 |
|
71 | |||
73 | QString QChartsPlugin::whatsThis() const |
|
72 | QString QChartsPlugin::whatsThis() const | |
74 | { |
|
73 | { | |
75 | return tr("This widget is presents QChartView widget"); |
|
74 | return tr("This widget is presents QChartView widget"); | |
76 | } |
|
75 | } | |
77 |
|
76 | |||
78 | bool QChartsPlugin::isContainer() const |
|
77 | bool QChartsPlugin::isContainer() const | |
79 | { |
|
78 | { | |
80 | return false; |
|
79 | return false; | |
81 | } |
|
80 | } | |
82 |
|
81 | |||
83 |
QWidget* |
|
82 | QWidget *QChartsPlugin::createWidget(QWidget *parent) | |
84 | { |
|
83 | { | |
85 | return new QChartView(new QChart(), parent); |
|
84 | return new QChartView(new QChart(), parent); | |
86 | } |
|
85 | } | |
87 |
|
86 | |||
88 | #ifndef QT5_QUICK_1 |
|
87 | #ifndef QT5_QUICK_1 | |
89 | Q_EXPORT_PLUGIN2(qtcommercialchart, QChartsPlugin) |
|
88 | Q_EXPORT_PLUGIN2(qtcommercialchart, QChartsPlugin) | |
90 | #endif |
|
89 | #endif | |
91 |
|
90 |
@@ -1,49 +1,49 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt 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 Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QCHARTSPLUGIN_H |
|
21 | #ifndef QCHARTSPLUGIN_H | |
22 | #define QCHARTSPLUGIN_H |
|
22 | #define QCHARTSPLUGIN_H | |
23 |
|
23 | |||
24 | #include <QDesignerCustomWidgetInterface> |
|
24 | #include <QDesignerCustomWidgetInterface> | |
25 |
|
25 | |||
26 | class QChartsPlugin: public QObject,public QDesignerCustomWidgetInterface |
|
26 | class QChartsPlugin: public QObject, public QDesignerCustomWidgetInterface | |
27 | { |
|
27 | { | |
28 |
|
28 | |||
29 | #ifdef QT5_QUICK_1 |
|
29 | #ifdef QT5_QUICK_1 | |
30 | Q_PLUGIN_METADATA(IID "org.qt-project.bar") |
|
30 | Q_PLUGIN_METADATA(IID "org.qt-project.bar") | |
31 | #endif |
|
31 | #endif | |
32 |
|
32 | |||
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_INTERFACES(QDesignerCustomWidgetInterface) |
|
34 | Q_INTERFACES(QDesignerCustomWidgetInterface) | |
35 | public: |
|
35 | public: | |
36 | QChartsPlugin(QObject *parent = 0); |
|
36 | QChartsPlugin(QObject *parent = 0); | |
37 | ~QChartsPlugin(); |
|
37 | ~QChartsPlugin(); | |
38 |
|
38 | |||
39 | QString name() const; |
|
39 | QString name() const; | |
40 | QString includeFile() const; |
|
40 | QString includeFile() const; | |
41 | QString group() const; |
|
41 | QString group() const; | |
42 | QIcon icon() const; |
|
42 | QIcon icon() const; | |
43 | QString toolTip() const; |
|
43 | QString toolTip() const; | |
44 | QString whatsThis() const; |
|
44 | QString whatsThis() const; | |
45 | bool isContainer() const; |
|
45 | bool isContainer() const; | |
46 | QWidget *createWidget(QWidget *parent); |
|
46 | QWidget *createWidget(QWidget *parent); | |
47 | }; |
|
47 | }; | |
48 |
|
48 | |||
49 | #endif /* QCHARTSPLUGIN_H */ |
|
49 | #endif /* QCHARTSPLUGIN_H */ |
General Comments 0
You need to be logged in to leave comments.
Login now