@@ -0,0 +1,114 | |||||
|
1 | /*! | |||
|
2 | \qmlclass Font QFont | |||
|
3 | \brief Defines the font used for drawing text. | |||
|
4 | ||||
|
5 | Font instantiates the C++ class QFont | |||
|
6 | */ | |||
|
7 | ||||
|
8 | // NOTE: This is a copy-paste from: | |||
|
9 | // <qt dir>\src\declarative\graphicsitems\qdeclarativetext.cpp | |||
|
10 | ||||
|
11 | /*! | |||
|
12 | \qmlproperty string Font::family | |||
|
13 | ||||
|
14 | Sets the family name of the font. | |||
|
15 | ||||
|
16 | The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]". | |||
|
17 | If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. | |||
|
18 | If the family isn't available a family will be set using the font matching algorithm. | |||
|
19 | */ | |||
|
20 | ||||
|
21 | /*! | |||
|
22 | \qmlproperty bool Font::bold | |||
|
23 | ||||
|
24 | Sets whether the font weight is bold. | |||
|
25 | */ | |||
|
26 | ||||
|
27 | /*! | |||
|
28 | \qmlproperty enumeration Font::weight | |||
|
29 | ||||
|
30 | Sets the font's weight. | |||
|
31 | ||||
|
32 | The weight can be one of: | |||
|
33 | \list | |||
|
34 | \o Font.Light | |||
|
35 | \o Font.Normal - the default | |||
|
36 | \o Font.DemiBold | |||
|
37 | \o Font.Bold | |||
|
38 | \o Font.Black | |||
|
39 | \endlist | |||
|
40 | ||||
|
41 | \qml | |||
|
42 | Text { text: "Hello"; font.weight: Font.DemiBold } | |||
|
43 | \endqml | |||
|
44 | */ | |||
|
45 | ||||
|
46 | /*! | |||
|
47 | \qmlproperty bool Font::italic | |||
|
48 | ||||
|
49 | Sets whether the font has an italic style. | |||
|
50 | */ | |||
|
51 | ||||
|
52 | /*! | |||
|
53 | \qmlproperty bool Font::underline | |||
|
54 | ||||
|
55 | Sets whether the text is underlined. | |||
|
56 | */ | |||
|
57 | ||||
|
58 | /*! | |||
|
59 | \qmlproperty bool Font::strikeout | |||
|
60 | ||||
|
61 | Sets whether the font has a strikeout style. | |||
|
62 | */ | |||
|
63 | ||||
|
64 | /*! | |||
|
65 | \qmlproperty real Font::pointSize | |||
|
66 | ||||
|
67 | Sets the font size in points. The point size must be greater than zero. | |||
|
68 | */ | |||
|
69 | ||||
|
70 | /*! | |||
|
71 | \qmlproperty int Font::pixelSize | |||
|
72 | ||||
|
73 | Sets the font size in pixels. | |||
|
74 | ||||
|
75 | Using this function makes the font device dependent. | |||
|
76 | Use \c pointSize to set the size of the font in a device independent manner. | |||
|
77 | */ | |||
|
78 | ||||
|
79 | /*! | |||
|
80 | \qmlproperty real Font::letterSpacing | |||
|
81 | ||||
|
82 | Sets the letter spacing for the font. | |||
|
83 | ||||
|
84 | Letter spacing changes the default spacing between individual letters in the font. | |||
|
85 | A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing. | |||
|
86 | */ | |||
|
87 | ||||
|
88 | /*! | |||
|
89 | \qmlproperty real Font::wordSpacing | |||
|
90 | ||||
|
91 | Sets the word spacing for the font. | |||
|
92 | ||||
|
93 | Word spacing changes the default spacing between individual words. | |||
|
94 | A positive value increases the word spacing by a corresponding amount of pixels, | |||
|
95 | while a negative value decreases the inter-word spacing accordingly. | |||
|
96 | */ | |||
|
97 | ||||
|
98 | /*! | |||
|
99 | \qmlproperty enumeration Font::capitalization | |||
|
100 | ||||
|
101 | Sets the capitalization for the text. | |||
|
102 | ||||
|
103 | \list | |||
|
104 | \o Font.MixedCase - This is the normal text rendering option where no capitalization change is applied. | |||
|
105 | \o Font.AllUppercase - This alters the text to be rendered in all uppercase type. | |||
|
106 | \o Font.AllLowercase - This alters the text to be rendered in all lowercase type. | |||
|
107 | \o Font.SmallCaps - This alters the text to be rendered in small-caps type. | |||
|
108 | \o Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character. | |||
|
109 | \endlist | |||
|
110 | ||||
|
111 | \qml | |||
|
112 | Text { text: "Hello"; font.capitalization: Font.AllLowercase } | |||
|
113 | \endqml | |||
|
114 | */ |
@@ -1,375 +1,392 | |||||
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 "declarativelineseries.h" |
|
23 | #include "declarativelineseries.h" | |
24 | #include "declarativeareaseries.h" |
|
24 | #include "declarativeareaseries.h" | |
25 | #include "declarativebarseries.h" |
|
25 | #include "declarativebarseries.h" | |
26 | #include "declarativepieseries.h" |
|
26 | #include "declarativepieseries.h" | |
27 | #include "declarativesplineseries.h" |
|
27 | #include "declarativesplineseries.h" | |
28 | #include "declarativescatterseries.h" |
|
28 | #include "declarativescatterseries.h" | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | /*! |
|
32 | /*! | |
33 | \qmlclass ChartView DeclarativeChart |
|
33 | \qmlclass ChartView DeclarativeChart | |
34 |
|
34 | |||
35 | ChartView element is the parent that is responsible for showing different chart series types. |
|
35 | ChartView element is the parent that is responsible for showing different chart series types. | |
36 |
|
36 | |||
37 | The following QML shows how to create a simple chart with one pie series: |
|
37 | The following QML shows how to create a simple chart with one pie series: | |
38 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
38 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 | |
39 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
39 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
40 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
40 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 | |
41 |
|
41 | |||
42 | \beginfloatleft |
|
42 | \beginfloatleft | |
43 | \image examples_qmlpiechart.png |
|
43 | \image examples_qmlpiechart.png | |
44 | \endfloat |
|
44 | \endfloat | |
45 | \clearfloat |
|
45 | \clearfloat | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | /*! |
|
48 | /*! | |
49 | \qmlproperty Theme ChartView::theme |
|
49 | \qmlproperty Theme ChartView::theme | |
50 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
50 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
51 | widths and chart background. |
|
51 | widths and chart background. | |
52 | */ |
|
52 | */ | |
53 |
|
53 | |||
54 | /*! |
|
54 | /*! | |
55 | \qmlproperty Animation ChartView::animation |
|
55 | \qmlproperty Animation ChartView::animation | |
56 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
56 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
57 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
57 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
58 | */ |
|
58 | */ | |
59 |
|
59 | |||
60 | /*! |
|
60 | /*! | |
|
61 | \qmlproperty Font ChartView::titleFont | |||
|
62 | The title font of the chart | |||
|
63 | ||||
|
64 | See the \l {Font} {QML Font Element} for detailed documentation. | |||
|
65 | */ | |||
|
66 | ||||
|
67 | /*! | |||
61 | \qmlproperty string ChartView::title |
|
68 | \qmlproperty string ChartView::title | |
62 | The title of the chart, shown on top of the chart. |
|
69 | The title of the chart, shown on top of the chart. | |
63 | \sa ChartView::titleColor |
|
70 | \sa ChartView::titleColor | |
64 | */ |
|
71 | */ | |
65 |
|
72 | |||
66 | /*! |
|
73 | /*! | |
67 | \qmlproperty string ChartView::titleColor |
|
74 | \qmlproperty string ChartView::titleColor | |
68 | The color of the title text. |
|
75 | The color of the title text. | |
69 | */ |
|
76 | */ | |
70 |
|
77 | |||
71 | /*! |
|
78 | /*! | |
72 | \qmlproperty Axis ChartView::axisX |
|
79 | \qmlproperty Axis ChartView::axisX | |
73 | The x-axis of the chart. |
|
80 | The x-axis of the chart. | |
74 | */ |
|
81 | */ | |
75 |
|
82 | |||
76 | /*! |
|
83 | /*! | |
77 | \qmlproperty Axis ChartView::axisY |
|
84 | \qmlproperty Axis ChartView::axisY | |
78 | The default y-axis of the chart. |
|
85 | The default y-axis of the chart. | |
79 | */ |
|
86 | */ | |
80 |
|
87 | |||
81 | /*! |
|
88 | /*! | |
82 | \qmlproperty Legend ChartView::legend |
|
89 | \qmlproperty Legend ChartView::legend | |
83 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
90 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
84 | */ |
|
91 | */ | |
85 |
|
92 | |||
86 | /*! |
|
93 | /*! | |
87 | \qmlproperty int ChartView::count |
|
94 | \qmlproperty int ChartView::count | |
88 | The count of series added to the chart. |
|
95 | The count of series added to the chart. | |
89 | */ |
|
96 | */ | |
90 |
|
97 | |||
91 | /*! |
|
98 | /*! | |
92 | \qmlproperty color ChartView::backgroundColor |
|
99 | \qmlproperty color ChartView::backgroundColor | |
93 | The color of the chart's background. By default background color is defined by chart theme. |
|
100 | The color of the chart's background. By default background color is defined by chart theme. | |
94 | \sa ChartView::theme |
|
101 | \sa ChartView::theme | |
95 | */ |
|
102 | */ | |
96 |
|
103 | |||
97 | /*! |
|
104 | /*! | |
98 | \qmlproperty bool ChartView::dropShadowEnabled |
|
105 | \qmlproperty bool ChartView::dropShadowEnabled | |
99 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
106 | The chart's border drop shadow. Set to true to enable drop shadow. | |
100 | */ |
|
107 | */ | |
101 |
|
108 | |||
102 | /*! |
|
109 | /*! | |
103 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) |
|
110 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) | |
104 | The y-axis of the series. This is the same as the default y-axis of the chart, unless you have |
|
111 | The y-axis of the series. This is the same as the default y-axis of the chart, unless you have | |
105 | explicitly defined the series to have a non-default y-axis. |
|
112 | explicitly defined the series to have a non-default y-axis. | |
106 | */ |
|
113 | */ | |
107 |
|
114 | |||
108 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
115 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
109 | : QDeclarativeItem(parent), |
|
116 | : QDeclarativeItem(parent), | |
110 | m_chart(new QChart(this)) |
|
117 | m_chart(new QChart(this)) | |
111 | { |
|
118 | { | |
112 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
119 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
113 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
120 | // m_chart->axisX()->setNiceNumbersEnabled(false); | |
114 | } |
|
121 | } | |
115 |
|
122 | |||
116 | DeclarativeChart::~DeclarativeChart() |
|
123 | DeclarativeChart::~DeclarativeChart() | |
117 | { |
|
124 | { | |
118 | delete m_chart; |
|
125 | delete m_chart; | |
119 | } |
|
126 | } | |
120 |
|
127 | |||
121 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
128 | void DeclarativeChart::childEvent(QChildEvent *event) | |
122 | { |
|
129 | { | |
123 | if (event->type() == QEvent::ChildAdded) { |
|
130 | if (event->type() == QEvent::ChildAdded) { | |
124 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
131 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
125 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
132 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
126 | } |
|
133 | } | |
127 | } |
|
134 | } | |
128 | } |
|
135 | } | |
129 |
|
136 | |||
130 | void DeclarativeChart::componentComplete() |
|
137 | void DeclarativeChart::componentComplete() | |
131 | { |
|
138 | { | |
132 | foreach(QObject *child, children()) { |
|
139 | foreach(QObject *child, children()) { | |
133 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
140 | if (qobject_cast<QAbstractSeries *>(child)) { | |
134 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; |
|
141 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; | |
135 | // TODO: how about optional y-axis? |
|
142 | // TODO: how about optional y-axis? | |
136 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
143 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
137 | } |
|
144 | } | |
138 | } |
|
145 | } | |
139 | QDeclarativeItem::componentComplete(); |
|
146 | QDeclarativeItem::componentComplete(); | |
140 | } |
|
147 | } | |
141 |
|
148 | |||
142 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
149 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
143 | { |
|
150 | { | |
144 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
151 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
145 | if (newGeometry.isValid()) { |
|
152 | if (newGeometry.isValid()) { | |
146 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
153 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
147 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
154 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
148 | } |
|
155 | } | |
149 | } |
|
156 | } | |
150 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
157 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |
151 | } |
|
158 | } | |
152 |
|
159 | |||
153 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
160 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
154 | { |
|
161 | { | |
155 | Q_UNUSED(option) |
|
162 | Q_UNUSED(option) | |
156 | Q_UNUSED(widget) |
|
163 | Q_UNUSED(widget) | |
157 |
|
164 | |||
158 | // TODO: optimized? |
|
165 | // TODO: optimized? | |
159 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
166 | painter->setRenderHint(QPainter::Antialiasing, true); | |
160 | } |
|
167 | } | |
161 |
|
168 | |||
162 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
169 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
163 | { |
|
170 | { | |
164 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
171 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
165 | if (chartTheme != m_chart->theme()) |
|
172 | if (chartTheme != m_chart->theme()) | |
166 | m_chart->setTheme(chartTheme); |
|
173 | m_chart->setTheme(chartTheme); | |
167 | } |
|
174 | } | |
168 |
|
175 | |||
169 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
176 | DeclarativeChart::Theme DeclarativeChart::theme() | |
170 | { |
|
177 | { | |
171 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
178 | return (DeclarativeChart::Theme) m_chart->theme(); | |
172 | } |
|
179 | } | |
173 |
|
180 | |||
174 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
181 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
175 | { |
|
182 | { | |
176 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
183 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
177 | if (animationOptions != m_chart->animationOptions()) |
|
184 | if (animationOptions != m_chart->animationOptions()) | |
178 | m_chart->setAnimationOptions(animationOptions); |
|
185 | m_chart->setAnimationOptions(animationOptions); | |
179 | } |
|
186 | } | |
180 |
|
187 | |||
181 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
188 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
182 | { |
|
189 | { | |
183 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
190 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
184 | return DeclarativeChart::AllAnimations; |
|
191 | return DeclarativeChart::AllAnimations; | |
185 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
192 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
186 | return DeclarativeChart::GridAxisAnimations; |
|
193 | return DeclarativeChart::GridAxisAnimations; | |
187 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
194 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
188 | return DeclarativeChart::SeriesAnimations; |
|
195 | return DeclarativeChart::SeriesAnimations; | |
189 | else |
|
196 | else | |
190 | return DeclarativeChart::NoAnimation; |
|
197 | return DeclarativeChart::NoAnimation; | |
191 | } |
|
198 | } | |
192 |
|
199 | |||
193 | void DeclarativeChart::setTitle(QString title) |
|
200 | void DeclarativeChart::setTitle(QString title) | |
194 | { |
|
201 | { | |
195 | if (title != m_chart->title()) |
|
202 | if (title != m_chart->title()) | |
196 | m_chart->setTitle(title); |
|
203 | m_chart->setTitle(title); | |
197 | } |
|
204 | } | |
198 | QString DeclarativeChart::title() |
|
205 | QString DeclarativeChart::title() | |
199 | { |
|
206 | { | |
200 | return m_chart->title(); |
|
207 | return m_chart->title(); | |
201 | } |
|
208 | } | |
202 |
|
209 | |||
203 | QAxis *DeclarativeChart::axisX() |
|
210 | QAxis *DeclarativeChart::axisX() | |
204 | { |
|
211 | { | |
205 | return m_chart->axisX(); |
|
212 | return m_chart->axisX(); | |
206 | } |
|
213 | } | |
207 |
|
214 | |||
208 | QAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
215 | QAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
209 | { |
|
216 | { | |
210 | return m_chart->axisY(series); |
|
217 | return m_chart->axisY(series); | |
211 | } |
|
218 | } | |
212 |
|
219 | |||
213 | QLegend *DeclarativeChart::legend() |
|
220 | QLegend *DeclarativeChart::legend() | |
214 | { |
|
221 | { | |
215 | return m_chart->legend(); |
|
222 | return m_chart->legend(); | |
216 | } |
|
223 | } | |
217 |
|
224 | |||
218 | QVariantList DeclarativeChart::axisXLabels() |
|
225 | QVariantList DeclarativeChart::axisXLabels() | |
219 | { |
|
226 | { | |
220 | QVariantList labels; |
|
227 | QVariantList labels; | |
221 | foreach (qreal value, m_chart->axisX()->categories()->values()) { |
|
228 | foreach (qreal value, m_chart->axisX()->categories()->values()) { | |
222 | labels.append(value); |
|
229 | labels.append(value); | |
223 | labels.append(m_chart->axisX()->categories()->label(value)); |
|
230 | labels.append(m_chart->axisX()->categories()->label(value)); | |
224 | } |
|
231 | } | |
225 | return labels; |
|
232 | return labels; | |
226 | } |
|
233 | } | |
227 |
|
234 | |||
228 | void DeclarativeChart::setAxisXLabels(QVariantList list) |
|
235 | void DeclarativeChart::setAxisXLabels(QVariantList list) | |
229 | { |
|
236 | { | |
230 | QVariant value(QVariant::Invalid); |
|
237 | QVariant value(QVariant::Invalid); | |
231 | foreach (QVariant element, list) { |
|
238 | foreach (QVariant element, list) { | |
232 | if (value.isValid() && element.type() == QVariant::String) { |
|
239 | if (value.isValid() && element.type() == QVariant::String) { | |
233 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); |
|
240 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); | |
234 | value = QVariant(QVariant::Invalid); |
|
241 | value = QVariant(QVariant::Invalid); | |
235 | } else { |
|
242 | } else { | |
236 | if (element.canConvert(QVariant::Double)) |
|
243 | if (element.canConvert(QVariant::Double)) | |
237 | value = element; |
|
244 | value = element; | |
238 | } |
|
245 | } | |
239 | } |
|
246 | } | |
240 | emit axisLabelsChanged(); |
|
247 | emit axisLabelsChanged(); | |
241 | } |
|
248 | } | |
242 |
|
249 | |||
243 | void DeclarativeChart::setTitleColor(QColor color) |
|
250 | void DeclarativeChart::setTitleColor(QColor color) | |
244 | { |
|
251 | { | |
245 | QBrush b = m_chart->titleBrush(); |
|
252 | QBrush b = m_chart->titleBrush(); | |
246 | if (color != b.color()) { |
|
253 | if (color != b.color()) { | |
247 | b.setColor(color); |
|
254 | b.setColor(color); | |
248 | m_chart->setTitleBrush(b); |
|
255 | m_chart->setTitleBrush(b); | |
249 | emit titleColorChanged(); |
|
256 | emit titleColorChanged(); | |
250 | } |
|
257 | } | |
251 | } |
|
258 | } | |
252 |
|
259 | |||
|
260 | QFont DeclarativeChart::titleFont() const | |||
|
261 | { | |||
|
262 | return m_chart->titleFont(); | |||
|
263 | } | |||
|
264 | ||||
|
265 | void DeclarativeChart::setTitleFont(const QFont& font) | |||
|
266 | { | |||
|
267 | m_chart->setTitleFont(font); | |||
|
268 | } | |||
|
269 | ||||
253 | QColor DeclarativeChart::titleColor() |
|
270 | QColor DeclarativeChart::titleColor() | |
254 | { |
|
271 | { | |
255 | return m_chart->titleBrush().color(); |
|
272 | return m_chart->titleBrush().color(); | |
256 | } |
|
273 | } | |
257 |
|
274 | |||
258 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
275 | void DeclarativeChart::setBackgroundColor(QColor color) | |
259 | { |
|
276 | { | |
260 | QBrush b = m_chart->backgroundBrush(); |
|
277 | QBrush b = m_chart->backgroundBrush(); | |
261 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
278 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
262 | b.setStyle(Qt::SolidPattern); |
|
279 | b.setStyle(Qt::SolidPattern); | |
263 | b.setColor(color); |
|
280 | b.setColor(color); | |
264 | m_chart->setBackgroundBrush(b); |
|
281 | m_chart->setBackgroundBrush(b); | |
265 | emit backgroundColorChanged(); |
|
282 | emit backgroundColorChanged(); | |
266 | } |
|
283 | } | |
267 | } |
|
284 | } | |
268 |
|
285 | |||
269 | QColor DeclarativeChart::backgroundColor() |
|
286 | QColor DeclarativeChart::backgroundColor() | |
270 | { |
|
287 | { | |
271 | return m_chart->backgroundBrush().color(); |
|
288 | return m_chart->backgroundBrush().color(); | |
272 | } |
|
289 | } | |
273 |
|
290 | |||
274 | int DeclarativeChart::count() |
|
291 | int DeclarativeChart::count() | |
275 | { |
|
292 | { | |
276 | return m_chart->series().count(); |
|
293 | return m_chart->series().count(); | |
277 | } |
|
294 | } | |
278 |
|
295 | |||
279 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
296 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
280 | { |
|
297 | { | |
281 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
298 | if (enabled != m_chart->isDropShadowEnabled()) { | |
282 | m_chart->setDropShadowEnabled(enabled); |
|
299 | m_chart->setDropShadowEnabled(enabled); | |
283 | dropShadowEnabledChanged(enabled); |
|
300 | dropShadowEnabledChanged(enabled); | |
284 | } |
|
301 | } | |
285 | } |
|
302 | } | |
286 |
|
303 | |||
287 | bool DeclarativeChart::dropShadowEnabled() |
|
304 | bool DeclarativeChart::dropShadowEnabled() | |
288 | { |
|
305 | { | |
289 | return m_chart->isDropShadowEnabled(); |
|
306 | return m_chart->isDropShadowEnabled(); | |
290 | } |
|
307 | } | |
291 |
|
308 | |||
292 | void DeclarativeChart::zoom(qreal factor) |
|
309 | void DeclarativeChart::zoom(qreal factor) | |
293 | { |
|
310 | { | |
294 | m_chart->zoom(factor); |
|
311 | m_chart->zoom(factor); | |
295 | } |
|
312 | } | |
296 |
|
313 | |||
297 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
314 | void DeclarativeChart::scrollLeft(qreal pixels) | |
298 | { |
|
315 | { | |
299 | m_chart->scroll(QPointF(pixels, 0)); |
|
316 | m_chart->scroll(QPointF(pixels, 0)); | |
300 | } |
|
317 | } | |
301 |
|
318 | |||
302 | void DeclarativeChart::scrollRight(qreal pixels) |
|
319 | void DeclarativeChart::scrollRight(qreal pixels) | |
303 | { |
|
320 | { | |
304 | m_chart->scroll(QPointF(-pixels, 0)); |
|
321 | m_chart->scroll(QPointF(-pixels, 0)); | |
305 | } |
|
322 | } | |
306 |
|
323 | |||
307 | void DeclarativeChart::scrollUp(qreal pixels) |
|
324 | void DeclarativeChart::scrollUp(qreal pixels) | |
308 | { |
|
325 | { | |
309 | m_chart->scroll(QPointF(0, pixels)); |
|
326 | m_chart->scroll(QPointF(0, pixels)); | |
310 | } |
|
327 | } | |
311 |
|
328 | |||
312 | void DeclarativeChart::scrollDown(qreal pixels) |
|
329 | void DeclarativeChart::scrollDown(qreal pixels) | |
313 | { |
|
330 | { | |
314 | m_chart->scroll(QPointF(0, -pixels)); |
|
331 | m_chart->scroll(QPointF(0, -pixels)); | |
315 | } |
|
332 | } | |
316 |
|
333 | |||
317 | QAbstractSeries *DeclarativeChart::series(int index) |
|
334 | QAbstractSeries *DeclarativeChart::series(int index) | |
318 | { |
|
335 | { | |
319 | if (index < m_chart->series().count()) { |
|
336 | if (index < m_chart->series().count()) { | |
320 | return m_chart->series().at(index); |
|
337 | return m_chart->series().at(index); | |
321 | } |
|
338 | } | |
322 | return 0; |
|
339 | return 0; | |
323 | } |
|
340 | } | |
324 |
|
341 | |||
325 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
342 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
326 | { |
|
343 | { | |
327 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
344 | foreach(QAbstractSeries *series, m_chart->series()) { | |
328 | if (series->name() == seriesName) |
|
345 | if (series->name() == seriesName) | |
329 | return series; |
|
346 | return series; | |
330 | } |
|
347 | } | |
331 | return 0; |
|
348 | return 0; | |
332 | } |
|
349 | } | |
333 |
|
350 | |||
334 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
351 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
335 | { |
|
352 | { | |
336 | QAbstractSeries *series = 0; |
|
353 | QAbstractSeries *series = 0; | |
337 | switch (type) { |
|
354 | switch (type) { | |
338 | case DeclarativeChart::SeriesTypeLine: |
|
355 | case DeclarativeChart::SeriesTypeLine: | |
339 | series = new DeclarativeLineSeries(); |
|
356 | series = new DeclarativeLineSeries(); | |
340 | break; |
|
357 | break; | |
341 | case DeclarativeChart::SeriesTypeArea: |
|
358 | case DeclarativeChart::SeriesTypeArea: | |
342 | series = new DeclarativeAreaSeries(); |
|
359 | series = new DeclarativeAreaSeries(); | |
343 | break; |
|
360 | break; | |
344 | case DeclarativeChart::SeriesTypeBar: |
|
361 | case DeclarativeChart::SeriesTypeBar: | |
345 | series = new DeclarativeBarSeries(); |
|
362 | series = new DeclarativeBarSeries(); | |
346 | break; |
|
363 | break; | |
347 | case DeclarativeChart::SeriesTypeStackedBar: |
|
364 | case DeclarativeChart::SeriesTypeStackedBar: | |
348 | // TODO |
|
365 | // TODO | |
349 | break; |
|
366 | break; | |
350 | case DeclarativeChart::SeriesTypePercentBar: |
|
367 | case DeclarativeChart::SeriesTypePercentBar: | |
351 | // TODO |
|
368 | // TODO | |
352 | break; |
|
369 | break; | |
353 | case DeclarativeChart::SeriesTypeGroupedBar: |
|
370 | case DeclarativeChart::SeriesTypeGroupedBar: | |
354 | series = new DeclarativeGroupedBarSeries(); |
|
371 | series = new DeclarativeGroupedBarSeries(); | |
355 | break; |
|
372 | break; | |
356 | case DeclarativeChart::SeriesTypePie: |
|
373 | case DeclarativeChart::SeriesTypePie: | |
357 | series = new DeclarativePieSeries(); |
|
374 | series = new DeclarativePieSeries(); | |
358 | break; |
|
375 | break; | |
359 | case DeclarativeChart::SeriesTypeScatter: |
|
376 | case DeclarativeChart::SeriesTypeScatter: | |
360 | series = new DeclarativeScatterSeries(); |
|
377 | series = new DeclarativeScatterSeries(); | |
361 | break; |
|
378 | break; | |
362 | case DeclarativeChart::SeriesTypeSpline: |
|
379 | case DeclarativeChart::SeriesTypeSpline: | |
363 | series = new DeclarativeSplineSeries(); |
|
380 | series = new DeclarativeSplineSeries(); | |
364 | break; |
|
381 | break; | |
365 | default: |
|
382 | default: | |
366 | qWarning() << "Illegal series type"; |
|
383 | qWarning() << "Illegal series type"; | |
367 | } |
|
384 | } | |
368 | series->setName(name); |
|
385 | series->setName(name); | |
369 | m_chart->addSeries(series); |
|
386 | m_chart->addSeries(series); | |
370 | return series; |
|
387 | return series; | |
371 | } |
|
388 | } | |
372 |
|
389 | |||
373 | #include "moc_declarativechart.cpp" |
|
390 | #include "moc_declarativechart.cpp" | |
374 |
|
391 | |||
375 | QTCOMMERCIALCHART_END_NAMESPACE |
|
392 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,136 +1,139 | |||||
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 | #include <QDeclarativeItem> |
|
25 | #include <QDeclarativeItem> | |
26 | #include <qchart.h> |
|
26 | #include <qchart.h> | |
27 | #include <QAxis> |
|
27 | #include <QAxis> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | // TODO: Derive from QChart for easier definition of properties? |
|
31 | // TODO: Derive from QChart for easier definition of properties? | |
32 | class DeclarativeChart : public QDeclarativeItem |
|
32 | class DeclarativeChart : public QDeclarativeItem | |
33 | // TODO: for QTQUICK2: extend QQuickPainterItem instead |
|
33 | // TODO: for QTQUICK2: extend QQuickPainterItem instead | |
34 | //class DeclarativeChart : public QQuickPaintedItem, public Chart |
|
34 | //class DeclarativeChart : public QQuickPaintedItem, public Chart | |
35 | { |
|
35 | { | |
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
37 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) |
|
37 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) | |
38 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) |
|
38 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) | |
39 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
39 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
|
40 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | |||
40 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
41 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) | |
41 | Q_PROPERTY(QAxis *axisX READ axisX) |
|
42 | Q_PROPERTY(QAxis *axisX READ axisX) | |
42 | Q_PROPERTY(QAxis *axisY READ axisY) |
|
43 | Q_PROPERTY(QAxis *axisY READ axisY) | |
43 | Q_PROPERTY(QLegend *legend READ legend) |
|
44 | Q_PROPERTY(QLegend *legend READ legend) | |
44 | // TODO: how to define axis labels? This is not very convenient |
|
45 | // TODO: how to define axis labels? This is not very convenient | |
45 | Q_PROPERTY(QVariantList axisXLabels READ axisXLabels WRITE setAxisXLabels NOTIFY axisLabelsChanged) |
|
46 | Q_PROPERTY(QVariantList axisXLabels READ axisXLabels WRITE setAxisXLabels NOTIFY axisLabelsChanged) | |
46 | Q_PROPERTY(int count READ count) |
|
47 | Q_PROPERTY(int count READ count) | |
47 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
48 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) | |
48 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
49 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) | |
49 | Q_ENUMS(Animation) |
|
50 | Q_ENUMS(Animation) | |
50 | Q_ENUMS(Theme) |
|
51 | Q_ENUMS(Theme) | |
51 | Q_ENUMS(SeriesType) |
|
52 | Q_ENUMS(SeriesType) | |
52 |
|
53 | |||
53 | public: |
|
54 | public: | |
54 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api |
|
55 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api | |
55 | enum Theme { |
|
56 | enum Theme { | |
56 | ChartThemeLight = 0, |
|
57 | ChartThemeLight = 0, | |
57 | ChartThemeBlueCerulean, |
|
58 | ChartThemeBlueCerulean, | |
58 | ChartThemeDark, |
|
59 | ChartThemeDark, | |
59 | ChartThemeBrownSand, |
|
60 | ChartThemeBrownSand, | |
60 | ChartThemeBlueNcs, |
|
61 | ChartThemeBlueNcs, | |
61 | ChartThemeHighContrast, |
|
62 | ChartThemeHighContrast, | |
62 | ChartThemeBlueIcy |
|
63 | ChartThemeBlueIcy | |
63 | }; |
|
64 | }; | |
64 |
|
65 | |||
65 | enum Animation { |
|
66 | enum Animation { | |
66 | NoAnimation = 0x0, |
|
67 | NoAnimation = 0x0, | |
67 | GridAxisAnimations = 0x1, |
|
68 | GridAxisAnimations = 0x1, | |
68 | SeriesAnimations =0x2, |
|
69 | SeriesAnimations =0x2, | |
69 | AllAnimations = 0x3 |
|
70 | AllAnimations = 0x3 | |
70 | }; |
|
71 | }; | |
71 |
|
72 | |||
72 | enum SeriesType { |
|
73 | enum SeriesType { | |
73 | SeriesTypeLine, |
|
74 | SeriesTypeLine, | |
74 | SeriesTypeArea, |
|
75 | SeriesTypeArea, | |
75 | SeriesTypeBar, |
|
76 | SeriesTypeBar, | |
76 | SeriesTypeStackedBar, |
|
77 | SeriesTypeStackedBar, | |
77 | SeriesTypePercentBar, |
|
78 | SeriesTypePercentBar, | |
78 | SeriesTypeGroupedBar, |
|
79 | SeriesTypeGroupedBar, | |
79 | SeriesTypePie, |
|
80 | SeriesTypePie, | |
80 | SeriesTypeScatter, |
|
81 | SeriesTypeScatter, | |
81 | SeriesTypeSpline |
|
82 | SeriesTypeSpline | |
82 | }; |
|
83 | }; | |
83 |
|
84 | |||
84 | public: |
|
85 | public: | |
85 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
86 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
86 | ~DeclarativeChart(); |
|
87 | ~DeclarativeChart(); | |
87 |
|
88 | |||
88 | public: // From QDeclarativeItem/QGraphicsItem |
|
89 | public: // From QDeclarativeItem/QGraphicsItem | |
89 | void childEvent(QChildEvent *event); |
|
90 | void childEvent(QChildEvent *event); | |
90 | void componentComplete(); |
|
91 | void componentComplete(); | |
91 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
92 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
92 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
93 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
93 |
|
94 | |||
94 | public: |
|
95 | public: | |
95 | void setTheme(DeclarativeChart::Theme theme); |
|
96 | void setTheme(DeclarativeChart::Theme theme); | |
96 | DeclarativeChart::Theme theme(); |
|
97 | DeclarativeChart::Theme theme(); | |
97 | void setAnimationOptions(DeclarativeChart::Animation animations); |
|
98 | void setAnimationOptions(DeclarativeChart::Animation animations); | |
98 | DeclarativeChart::Animation animationOptions(); |
|
99 | DeclarativeChart::Animation animationOptions(); | |
99 | void setTitle(QString title); |
|
100 | void setTitle(QString title); | |
100 | QString title(); |
|
101 | QString title(); | |
101 | QAxis *axisX(); |
|
102 | QAxis *axisX(); | |
102 | Q_INVOKABLE QAxis *axisY(QAbstractSeries *series = 0); |
|
103 | Q_INVOKABLE QAxis *axisY(QAbstractSeries *series = 0); | |
103 | QLegend *legend(); |
|
104 | QLegend *legend(); | |
104 | QVariantList axisXLabels(); |
|
105 | QVariantList axisXLabels(); | |
105 | void setAxisXLabels(QVariantList list); |
|
106 | void setAxisXLabels(QVariantList list); | |
|
107 | QFont titleFont() const; | |||
|
108 | void setTitleFont(const QFont& font); | |||
106 | void setTitleColor(QColor color); |
|
109 | void setTitleColor(QColor color); | |
107 | QColor titleColor(); |
|
110 | QColor titleColor(); | |
108 | void setBackgroundColor(QColor color); |
|
111 | void setBackgroundColor(QColor color); | |
109 | QColor backgroundColor(); |
|
112 | QColor backgroundColor(); | |
110 | int count(); |
|
113 | int count(); | |
111 | void setDropShadowEnabled(bool enabled); |
|
114 | void setDropShadowEnabled(bool enabled); | |
112 | bool dropShadowEnabled(); |
|
115 | bool dropShadowEnabled(); | |
113 | Q_INVOKABLE void zoom(qreal factor); |
|
116 | Q_INVOKABLE void zoom(qreal factor); | |
114 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
117 | Q_INVOKABLE void scrollLeft(qreal pixels); | |
115 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
118 | Q_INVOKABLE void scrollRight(qreal pixels); | |
116 | Q_INVOKABLE void scrollUp(qreal pixels); |
|
119 | Q_INVOKABLE void scrollUp(qreal pixels); | |
117 | Q_INVOKABLE void scrollDown(qreal pixels); |
|
120 | Q_INVOKABLE void scrollDown(qreal pixels); | |
118 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
121 | Q_INVOKABLE QAbstractSeries *series(int index); | |
119 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
122 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
120 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
123 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
121 |
|
124 | |||
122 | Q_SIGNALS: |
|
125 | Q_SIGNALS: | |
123 | void axisLabelsChanged(); |
|
126 | void axisLabelsChanged(); | |
124 | void titleColorChanged(); |
|
127 | void titleColorChanged(); | |
125 | void backgroundColorChanged(); |
|
128 | void backgroundColorChanged(); | |
126 | void dropShadowEnabledChanged(bool enabled); |
|
129 | void dropShadowEnabledChanged(bool enabled); | |
127 |
|
130 | |||
128 | public: |
|
131 | public: | |
129 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
132 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
130 | // multi inheritance, so we now have a QChart as a member instead |
|
133 | // multi inheritance, so we now have a QChart as a member instead | |
131 | QChart *m_chart; |
|
134 | QChart *m_chart; | |
132 | }; |
|
135 | }; | |
133 |
|
136 | |||
134 | QTCOMMERCIALCHART_END_NAMESPACE |
|
137 | QTCOMMERCIALCHART_END_NAMESPACE | |
135 |
|
138 | |||
136 | #endif // DECLARATIVECHART_H |
|
139 | #endif // DECLARATIVECHART_H |
@@ -1,654 +1,665 | |||||
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 "qaxis.h" |
|
21 | #include "qaxis.h" | |
22 | #include "qaxis_p.h" |
|
22 | #include "qaxis_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QAxis |
|
27 | \class QAxis | |
28 | \brief The QAxis class is used for manipulating chart's axis |
|
28 | \brief The QAxis class is used for manipulating chart's axis | |
29 | and for adding optional axes to the chart. |
|
29 | and for adding optional axes to the chart. | |
30 | \mainclass |
|
30 | \mainclass | |
31 |
|
31 | |||
32 | There is only one x Axis, however there can be multiple y axes. |
|
32 | There is only one x Axis, however there can be multiple y axes. | |
33 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
33 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
34 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
34 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
35 | */ |
|
35 | */ | |
36 |
|
36 | |||
37 | /*! |
|
37 | /*! | |
38 | \qmlclass Axis QAxis |
|
38 | \qmlclass Axis QAxis | |
39 | \brief The Axis element is used for manipulating chart's axes |
|
39 | \brief The Axis element is used for manipulating chart's axes | |
40 |
|
40 | |||
41 | There is only one x Axis, however there can be multiple y axes on a ChartView. |
|
41 | There is only one x Axis, however there can be multiple y axes on a ChartView. | |
42 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
42 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
43 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
43 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
44 |
|
44 | |||
45 | To access Axes you can use ChartView API. For example: |
|
45 | To access Axes you can use ChartView API. For example: | |
46 | \code |
|
46 | \code | |
47 | ChartView { |
|
47 | ChartView { | |
48 | axisX.min: 0 |
|
48 | axisX.min: 0 | |
49 | axisX.max: 3 |
|
49 | axisX.max: 3 | |
50 | axisX.ticksCount: 4 |
|
50 | axisX.ticksCount: 4 | |
51 | axisY.min: 0 |
|
51 | axisY.min: 0 | |
52 | axisY.max: 4 |
|
52 | axisY.max: 4 | |
53 | // Add a few series... |
|
53 | // Add a few series... | |
54 | } |
|
54 | } | |
55 | \endcode |
|
55 | \endcode | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \property QAxis::labelsVisible |
|
59 | \property QAxis::labelsVisible | |
60 | Defines if axis labels are visible. |
|
60 | Defines if axis labels are visible. | |
61 | */ |
|
61 | */ | |
62 | /*! |
|
62 | /*! | |
63 | \qmlproperty bool Axis::labelsVisible |
|
63 | \qmlproperty bool Axis::labelsVisible | |
64 | Defines if axis labels are visible. |
|
64 | Defines if axis labels are visible. | |
65 | */ |
|
65 | */ | |
66 |
|
66 | |||
67 | /*! |
|
67 | /*! | |
68 | \property QAxis::min |
|
68 | \property QAxis::min | |
69 | Defines the minimum value on the axis. |
|
69 | Defines the minimum value on the axis. | |
70 | */ |
|
70 | */ | |
71 | /*! |
|
71 | /*! | |
72 | \qmlproperty real Axis::min |
|
72 | \qmlproperty real Axis::min | |
73 | Defines the minimum value on the axis. |
|
73 | Defines the minimum value on the axis. | |
74 | */ |
|
74 | */ | |
75 |
|
75 | |||
76 | /*! |
|
76 | /*! | |
77 | \property QAxis::max |
|
77 | \property QAxis::max | |
78 | Defines the maximum value on the axis. |
|
78 | Defines the maximum value on the axis. | |
79 | */ |
|
79 | */ | |
80 | /*! |
|
80 | /*! | |
81 | \qmlproperty real Axis::max |
|
81 | \qmlproperty real Axis::max | |
82 | Defines the maximum value on the axis. |
|
82 | Defines the maximum value on the axis. | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | /*! |
|
85 | /*! | |
86 | \property QAxis::visible |
|
86 | \property QAxis::visible | |
87 | The visibility of the axis. |
|
87 | The visibility of the axis. | |
88 | */ |
|
88 | */ | |
89 | /*! |
|
89 | /*! | |
90 | \qmlproperty bool Axis::visible |
|
90 | \qmlproperty bool Axis::visible | |
91 | The visibility of the axis. |
|
91 | The visibility of the axis. | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \property QAxis::gridVisible |
|
95 | \property QAxis::gridVisible | |
96 | The visibility of the grid lines. |
|
96 | The visibility of the grid lines. | |
97 | */ |
|
97 | */ | |
98 | /*! |
|
98 | /*! | |
99 | \qmlproperty bool Axis::gridVisible |
|
99 | \qmlproperty bool Axis::gridVisible | |
100 | The visibility of the grid lines. |
|
100 | The visibility of the grid lines. | |
101 | */ |
|
101 | */ | |
102 |
|
102 | |||
103 | /*! |
|
103 | /*! | |
104 | \property QAxis::color |
|
104 | \property QAxis::color | |
105 | The color of the axis and ticks. |
|
105 | The color of the axis and ticks. | |
106 | */ |
|
106 | */ | |
107 | /*! |
|
107 | /*! | |
108 | \qmlproperty color Axis::color |
|
108 | \qmlproperty color Axis::color | |
109 | The color of the axis and ticks. |
|
109 | The color of the axis and ticks. | |
110 | */ |
|
110 | */ | |
111 |
|
111 | |||
112 | /*! |
|
112 | /*! | |
|
113 | \property QAxis::labelsFont | |||
|
114 | The font of the axis labels. | |||
|
115 | */ | |||
|
116 | /*! | |||
|
117 | \qmlproperty Font Axis::labelsFont | |||
|
118 | The font of the axis labels. | |||
|
119 | ||||
|
120 | See the \l {Font} {QML Font Element} for detailed documentation. | |||
|
121 | */ | |||
|
122 | ||||
|
123 | /*! | |||
113 | \property QAxis::labelsColor |
|
124 | \property QAxis::labelsColor | |
114 | The color of the axis labels. |
|
125 | The color of the axis labels. | |
115 | */ |
|
126 | */ | |
116 | /*! |
|
127 | /*! | |
117 | \qmlproperty color Axis::labelsColor |
|
128 | \qmlproperty color Axis::labelsColor | |
118 | The color of the axis labels. |
|
129 | The color of the axis labels. | |
119 | */ |
|
130 | */ | |
120 |
|
131 | |||
121 | /*! |
|
132 | /*! | |
122 | \property QAxis::labelsAngle |
|
133 | \property QAxis::labelsAngle | |
123 | The angle of the axis labels in degrees. |
|
134 | The angle of the axis labels in degrees. | |
124 | */ |
|
135 | */ | |
125 | /*! |
|
136 | /*! | |
126 | \qmlproperty int Axis::labelsAngle |
|
137 | \qmlproperty int Axis::labelsAngle | |
127 | The angle of the axis labels in degrees. |
|
138 | The angle of the axis labels in degrees. | |
128 | */ |
|
139 | */ | |
129 |
|
140 | |||
130 | /*! |
|
141 | /*! | |
131 | \property QAxis::shadesVisible |
|
142 | \property QAxis::shadesVisible | |
132 | The visibility of the axis shades. |
|
143 | The visibility of the axis shades. | |
133 | */ |
|
144 | */ | |
134 | /*! |
|
145 | /*! | |
135 | \qmlproperty bool Axis::shadesVisible |
|
146 | \qmlproperty bool Axis::shadesVisible | |
136 | The visibility of the axis shades. |
|
147 | The visibility of the axis shades. | |
137 | */ |
|
148 | */ | |
138 |
|
149 | |||
139 | /*! |
|
150 | /*! | |
140 | \property QAxis::shadesColor |
|
151 | \property QAxis::shadesColor | |
141 | The fill (brush) color of the axis shades. |
|
152 | The fill (brush) color of the axis shades. | |
142 | */ |
|
153 | */ | |
143 | /*! |
|
154 | /*! | |
144 | \qmlproperty color Axis::shadesColor |
|
155 | \qmlproperty color Axis::shadesColor | |
145 | The fill (brush) color of the axis shades. |
|
156 | The fill (brush) color of the axis shades. | |
146 | */ |
|
157 | */ | |
147 |
|
158 | |||
148 | /*! |
|
159 | /*! | |
149 | \property QAxis::shadesBorderColor |
|
160 | \property QAxis::shadesBorderColor | |
150 | The border (pen) color of the axis shades. |
|
161 | The border (pen) color of the axis shades. | |
151 | */ |
|
162 | */ | |
152 | /*! |
|
163 | /*! | |
153 | \qmlproperty color Axis::shadesBorderColor |
|
164 | \qmlproperty color Axis::shadesBorderColor | |
154 | The border (pen) color of the axis shades. |
|
165 | The border (pen) color of the axis shades. | |
155 | */ |
|
166 | */ | |
156 |
|
167 | |||
157 | /*! |
|
168 | /*! | |
158 | \property QAxis::ticksCount |
|
169 | \property QAxis::ticksCount | |
159 | The number of tick marks for the axis. |
|
170 | The number of tick marks for the axis. | |
160 | */ |
|
171 | */ | |
161 | /*! |
|
172 | /*! | |
162 | \qmlproperty int Axis::ticksCount |
|
173 | \qmlproperty int Axis::ticksCount | |
163 | The number of tick marks for the axis. |
|
174 | The number of tick marks for the axis. | |
164 | */ |
|
175 | */ | |
165 |
|
176 | |||
166 | /*! |
|
177 | /*! | |
167 | \property QAxis::niceNumbersEnabled |
|
178 | \property QAxis::niceNumbersEnabled | |
168 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
179 | Whether the nice numbers algorithm is enabled or not for the axis. | |
169 | */ |
|
180 | */ | |
170 | /*! |
|
181 | /*! | |
171 | \qmlproperty bool Axis::niceNumbersEnabled |
|
182 | \qmlproperty bool Axis::niceNumbersEnabled | |
172 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
183 | Whether the nice numbers algorithm is enabled or not for the axis. | |
173 | */ |
|
184 | */ | |
174 |
|
185 | |||
175 | /*! |
|
186 | /*! | |
176 | \fn void QAxis::visibleChanged(bool) |
|
187 | \fn void QAxis::visibleChanged(bool) | |
177 | Visiblity of the axis has changed to \a visible. |
|
188 | Visiblity of the axis has changed to \a visible. | |
178 | */ |
|
189 | */ | |
179 |
|
190 | |||
180 | /*! |
|
191 | /*! | |
181 | \fn void QAxis::labelsVisibleChanged(bool) |
|
192 | \fn void QAxis::labelsVisibleChanged(bool) | |
182 | Visiblity of the labels of the axis has changed to \a visible. |
|
193 | Visiblity of the labels of the axis has changed to \a visible. | |
183 | */ |
|
194 | */ | |
184 |
|
195 | |||
185 | /*! |
|
196 | /*! | |
186 | \fn void QAxis::gridVisibleChanged(bool) |
|
197 | \fn void QAxis::gridVisibleChanged(bool) | |
187 | Visiblity of the grid lines of the axis has changed to \a visible. |
|
198 | Visiblity of the grid lines of the axis has changed to \a visible. | |
188 | */ |
|
199 | */ | |
189 |
|
200 | |||
190 | /*! |
|
201 | /*! | |
191 | \fn void QAxis::minChanged(qreal min) |
|
202 | \fn void QAxis::minChanged(qreal min) | |
192 | Axis emits signal when \a min of axis has changed. |
|
203 | Axis emits signal when \a min of axis has changed. | |
193 | */ |
|
204 | */ | |
194 |
|
205 | |||
195 | /*! |
|
206 | /*! | |
196 | \fn void QAxis::maxChanged(qreal max) |
|
207 | \fn void QAxis::maxChanged(qreal max) | |
197 | Axis emits signal when \a max of axis has changed. |
|
208 | Axis emits signal when \a max of axis has changed. | |
198 | */ |
|
209 | */ | |
199 |
|
210 | |||
200 | /*! |
|
211 | /*! | |
201 | \fn void QAxis::rangeChanged(qreal min, qreal max) |
|
212 | \fn void QAxis::rangeChanged(qreal min, qreal max) | |
202 | Axis emits signal when \a min or \a max of axis has changed. |
|
213 | Axis emits signal when \a min or \a max of axis has changed. | |
203 | */ |
|
214 | */ | |
204 |
|
215 | |||
205 | /*! |
|
216 | /*! | |
206 | \fn QChartAxisCategories* QAxis::categories() |
|
217 | \fn QChartAxisCategories* QAxis::categories() | |
207 | Returns pointer to the list of categories which correspond to the values on the axis. |
|
218 | Returns pointer to the list of categories which correspond to the values on the axis. | |
208 | */ |
|
219 | */ | |
209 |
|
220 | |||
210 | /*! |
|
221 | /*! | |
211 | \fn void QAxis::colorChanged(QColor) |
|
222 | \fn void QAxis::colorChanged(QColor) | |
212 | Emitted if the \a color of the axis is changed. |
|
223 | Emitted if the \a color of the axis is changed. | |
213 | */ |
|
224 | */ | |
214 |
|
225 | |||
215 | /*! |
|
226 | /*! | |
216 | \fn void QAxis::labelsColorChanged(QColor) |
|
227 | \fn void QAxis::labelsColorChanged(QColor) | |
217 | Emitted if the \a color of the axis labels is changed. |
|
228 | Emitted if the \a color of the axis labels is changed. | |
218 | */ |
|
229 | */ | |
219 |
|
230 | |||
220 | /*! |
|
231 | /*! | |
221 | \fn void QAxis::shadesVisibleChanged(bool) |
|
232 | \fn void QAxis::shadesVisibleChanged(bool) | |
222 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
233 | Emitted if the visibility of the axis shades is changed to \a visible. | |
223 | */ |
|
234 | */ | |
224 |
|
235 | |||
225 | /*! |
|
236 | /*! | |
226 | \fn void QAxis::shadesColorChanged(QColor) |
|
237 | \fn void QAxis::shadesColorChanged(QColor) | |
227 | Emitted if the \a color of the axis shades is changed. |
|
238 | Emitted if the \a color of the axis shades is changed. | |
228 | */ |
|
239 | */ | |
229 |
|
240 | |||
230 | /*! |
|
241 | /*! | |
231 | \fn void QAxis::shadesBorderColorChanged(QColor) |
|
242 | \fn void QAxis::shadesBorderColorChanged(QColor) | |
232 | Emitted if the border \a color of the axis shades is changed. |
|
243 | Emitted if the border \a color of the axis shades is changed. | |
233 | */ |
|
244 | */ | |
234 |
|
245 | |||
235 | /*! |
|
246 | /*! | |
236 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
247 | Constructs new axis object which is a child of \a parent. Ownership is taken by | |
237 | QChart when axis added. |
|
248 | QChart when axis added. | |
238 | */ |
|
249 | */ | |
239 | QAxis::QAxis(QObject *parent) : QObject(parent), |
|
250 | QAxis::QAxis(QObject *parent) : QObject(parent), | |
240 | d_ptr(new QAxisPrivate(this)) |
|
251 | d_ptr(new QAxisPrivate(this)) | |
241 | { |
|
252 | { | |
242 |
|
253 | |||
243 | } |
|
254 | } | |
244 |
|
255 | |||
245 | /*! |
|
256 | /*! | |
246 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
257 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. | |
247 | */ |
|
258 | */ | |
248 |
|
259 | |||
249 | QAxis::~QAxis() |
|
260 | QAxis::~QAxis() | |
250 | { |
|
261 | { | |
251 | } |
|
262 | } | |
252 |
|
263 | |||
253 | /*! |
|
264 | /*! | |
254 | Sets \a pen used to draw axis line and ticks. |
|
265 | Sets \a pen used to draw axis line and ticks. | |
255 | */ |
|
266 | */ | |
256 | void QAxis::setAxisPen(const QPen &pen) |
|
267 | void QAxis::setAxisPen(const QPen &pen) | |
257 | { |
|
268 | { | |
258 | if (d_ptr->m_axisPen!=pen) { |
|
269 | if (d_ptr->m_axisPen!=pen) { | |
259 | d_ptr->m_axisPen = pen; |
|
270 | d_ptr->m_axisPen = pen; | |
260 | emit d_ptr->updated(); |
|
271 | emit d_ptr->updated(); | |
261 | } |
|
272 | } | |
262 | } |
|
273 | } | |
263 |
|
274 | |||
264 | /*! |
|
275 | /*! | |
265 | Returns pen used to draw axis and ticks. |
|
276 | Returns pen used to draw axis and ticks. | |
266 | */ |
|
277 | */ | |
267 | QPen QAxis::axisPen() const |
|
278 | QPen QAxis::axisPen() const | |
268 | { |
|
279 | { | |
269 | return d_ptr->m_axisPen; |
|
280 | return d_ptr->m_axisPen; | |
270 | } |
|
281 | } | |
271 |
|
282 | |||
272 | void QAxis::setAxisPenColor(QColor color) |
|
283 | void QAxis::setAxisPenColor(QColor color) | |
273 | { |
|
284 | { | |
274 | QPen p = d_ptr->m_axisPen; |
|
285 | QPen p = d_ptr->m_axisPen; | |
275 | if (p.color() != color) { |
|
286 | if (p.color() != color) { | |
276 | p.setColor(color); |
|
287 | p.setColor(color); | |
277 | setAxisPen(p); |
|
288 | setAxisPen(p); | |
278 | emit colorChanged(color); |
|
289 | emit colorChanged(color); | |
279 | } |
|
290 | } | |
280 | } |
|
291 | } | |
281 |
|
292 | |||
282 | QColor QAxis::axisPenColor() const |
|
293 | QColor QAxis::axisPenColor() const | |
283 | { |
|
294 | { | |
284 | return d_ptr->m_axisPen.color(); |
|
295 | return d_ptr->m_axisPen.color(); | |
285 | } |
|
296 | } | |
286 |
|
297 | |||
287 | /*! |
|
298 | /*! | |
288 | Sets if axis and ticks are \a visible. |
|
299 | Sets if axis and ticks are \a visible. | |
289 | */ |
|
300 | */ | |
290 | void QAxis::setAxisVisible(bool visible) |
|
301 | void QAxis::setAxisVisible(bool visible) | |
291 | { |
|
302 | { | |
292 | if (d_ptr->m_axisVisible != visible) { |
|
303 | if (d_ptr->m_axisVisible != visible) { | |
293 | d_ptr->m_axisVisible = visible; |
|
304 | d_ptr->m_axisVisible = visible; | |
294 | emit d_ptr->updated(); |
|
305 | emit d_ptr->updated(); | |
295 | emit visibleChanged(visible); |
|
306 | emit visibleChanged(visible); | |
296 | } |
|
307 | } | |
297 | } |
|
308 | } | |
298 |
|
309 | |||
299 | bool QAxis::isAxisVisible() const |
|
310 | bool QAxis::isAxisVisible() const | |
300 | { |
|
311 | { | |
301 | return d_ptr->m_axisVisible; |
|
312 | return d_ptr->m_axisVisible; | |
302 | } |
|
313 | } | |
303 |
|
314 | |||
304 | void QAxis::setGridLineVisible(bool visible) |
|
315 | void QAxis::setGridLineVisible(bool visible) | |
305 | { |
|
316 | { | |
306 | if (d_ptr->m_gridLineVisible != visible) { |
|
317 | if (d_ptr->m_gridLineVisible != visible) { | |
307 | d_ptr->m_gridLineVisible = visible; |
|
318 | d_ptr->m_gridLineVisible = visible; | |
308 | emit d_ptr->updated(); |
|
319 | emit d_ptr->updated(); | |
309 | emit gridVisibleChanged(visible); |
|
320 | emit gridVisibleChanged(visible); | |
310 | } |
|
321 | } | |
311 | } |
|
322 | } | |
312 |
|
323 | |||
313 | bool QAxis::isGridLineVisible() const |
|
324 | bool QAxis::isGridLineVisible() const | |
314 | { |
|
325 | { | |
315 | return d_ptr->m_gridLineVisible; |
|
326 | return d_ptr->m_gridLineVisible; | |
316 | } |
|
327 | } | |
317 |
|
328 | |||
318 | /*! |
|
329 | /*! | |
319 | Sets \a pen used to draw grid line. |
|
330 | Sets \a pen used to draw grid line. | |
320 | */ |
|
331 | */ | |
321 | void QAxis::setGridLinePen(const QPen &pen) |
|
332 | void QAxis::setGridLinePen(const QPen &pen) | |
322 | { |
|
333 | { | |
323 | if (d_ptr->m_gridLinePen != pen) { |
|
334 | if (d_ptr->m_gridLinePen != pen) { | |
324 | d_ptr->m_gridLinePen = pen; |
|
335 | d_ptr->m_gridLinePen = pen; | |
325 | emit d_ptr->updated(); |
|
336 | emit d_ptr->updated(); | |
326 | } |
|
337 | } | |
327 | } |
|
338 | } | |
328 |
|
339 | |||
329 | /*! |
|
340 | /*! | |
330 | Returns pen used to draw grid. |
|
341 | Returns pen used to draw grid. | |
331 | */ |
|
342 | */ | |
332 | QPen QAxis::gridLinePen() const |
|
343 | QPen QAxis::gridLinePen() const | |
333 | { |
|
344 | { | |
334 | return d_ptr->m_gridLinePen; |
|
345 | return d_ptr->m_gridLinePen; | |
335 | } |
|
346 | } | |
336 |
|
347 | |||
337 | void QAxis::setLabelsVisible(bool visible) |
|
348 | void QAxis::setLabelsVisible(bool visible) | |
338 | { |
|
349 | { | |
339 | if (d_ptr->m_labelsVisible != visible) { |
|
350 | if (d_ptr->m_labelsVisible != visible) { | |
340 | d_ptr->m_labelsVisible = visible; |
|
351 | d_ptr->m_labelsVisible = visible; | |
341 | emit d_ptr->updated(); |
|
352 | emit d_ptr->updated(); | |
342 | emit labelsVisibleChanged(visible); |
|
353 | emit labelsVisibleChanged(visible); | |
343 | } |
|
354 | } | |
344 | } |
|
355 | } | |
345 |
|
356 | |||
346 | bool QAxis::labelsVisible() const |
|
357 | bool QAxis::labelsVisible() const | |
347 | { |
|
358 | { | |
348 | return d_ptr->m_labelsVisible; |
|
359 | return d_ptr->m_labelsVisible; | |
349 | } |
|
360 | } | |
350 |
|
361 | |||
351 | /*! |
|
362 | /*! | |
352 | Sets \a pen used to draw labels. |
|
363 | Sets \a pen used to draw labels. | |
353 | */ |
|
364 | */ | |
354 | void QAxis::setLabelsPen(const QPen &pen) |
|
365 | void QAxis::setLabelsPen(const QPen &pen) | |
355 | { |
|
366 | { | |
356 | if (d_ptr->m_labelsPen != pen) { |
|
367 | if (d_ptr->m_labelsPen != pen) { | |
357 | d_ptr->m_labelsPen = pen; |
|
368 | d_ptr->m_labelsPen = pen; | |
358 | emit d_ptr->updated(); |
|
369 | emit d_ptr->updated(); | |
359 | } |
|
370 | } | |
360 | } |
|
371 | } | |
361 |
|
372 | |||
362 | /*! |
|
373 | /*! | |
363 | Returns the pen used to labels. |
|
374 | Returns the pen used to labels. | |
364 | */ |
|
375 | */ | |
365 | QPen QAxis::labelsPen() const |
|
376 | QPen QAxis::labelsPen() const | |
366 | { |
|
377 | { | |
367 | return d_ptr->m_labelsPen; |
|
378 | return d_ptr->m_labelsPen; | |
368 | } |
|
379 | } | |
369 |
|
380 | |||
370 | /*! |
|
381 | /*! | |
371 | Sets \a brush used to draw labels. |
|
382 | Sets \a brush used to draw labels. | |
372 | */ |
|
383 | */ | |
373 | void QAxis::setLabelsBrush(const QBrush &brush) |
|
384 | void QAxis::setLabelsBrush(const QBrush &brush) | |
374 | { |
|
385 | { | |
375 | if (d_ptr->m_labelsBrush != brush) { |
|
386 | if (d_ptr->m_labelsBrush != brush) { | |
376 | d_ptr->m_labelsBrush = brush; |
|
387 | d_ptr->m_labelsBrush = brush; | |
377 | emit d_ptr->updated(); |
|
388 | emit d_ptr->updated(); | |
378 | } |
|
389 | } | |
379 | } |
|
390 | } | |
380 |
|
391 | |||
381 | /*! |
|
392 | /*! | |
382 | Returns brush used to draw labels. |
|
393 | Returns brush used to draw labels. | |
383 | */ |
|
394 | */ | |
384 | QBrush QAxis::labelsBrush() const |
|
395 | QBrush QAxis::labelsBrush() const | |
385 | { |
|
396 | { | |
386 | return d_ptr->m_labelsBrush; |
|
397 | return d_ptr->m_labelsBrush; | |
387 | } |
|
398 | } | |
388 |
|
399 | |||
389 | /*! |
|
400 | /*! | |
390 | Sets \a font used to draw labels. |
|
401 | Sets \a font used to draw labels. | |
391 | */ |
|
402 | */ | |
392 | void QAxis::setLabelsFont(const QFont &font) |
|
403 | void QAxis::setLabelsFont(const QFont &font) | |
393 | { |
|
404 | { | |
394 | if (d_ptr->m_labelsFont != font) { |
|
405 | if (d_ptr->m_labelsFont != font) { | |
395 | d_ptr->m_labelsFont = font; |
|
406 | d_ptr->m_labelsFont = font; | |
396 | emit d_ptr->updated(); |
|
407 | emit d_ptr->updated(); | |
397 | } |
|
408 | } | |
398 | } |
|
409 | } | |
399 |
|
410 | |||
400 | /*! |
|
411 | /*! | |
401 | Returns font used to draw labels. |
|
412 | Returns font used to draw labels. | |
402 | */ |
|
413 | */ | |
403 | QFont QAxis::labelsFont() const |
|
414 | QFont QAxis::labelsFont() const | |
404 | { |
|
415 | { | |
405 | return d_ptr->m_labelsFont; |
|
416 | return d_ptr->m_labelsFont; | |
406 | } |
|
417 | } | |
407 |
|
418 | |||
408 | void QAxis::setLabelsAngle(int angle) |
|
419 | void QAxis::setLabelsAngle(int angle) | |
409 | { |
|
420 | { | |
410 | if (d_ptr->m_labelsAngle != angle) { |
|
421 | if (d_ptr->m_labelsAngle != angle) { | |
411 | d_ptr->m_labelsAngle = angle; |
|
422 | d_ptr->m_labelsAngle = angle; | |
412 | emit d_ptr->updated(); |
|
423 | emit d_ptr->updated(); | |
413 | } |
|
424 | } | |
414 | } |
|
425 | } | |
415 |
|
426 | |||
416 | int QAxis::labelsAngle() const |
|
427 | int QAxis::labelsAngle() const | |
417 | { |
|
428 | { | |
418 | return d_ptr->m_labelsAngle; |
|
429 | return d_ptr->m_labelsAngle; | |
419 | } |
|
430 | } | |
420 |
|
431 | |||
421 | void QAxis::setLabelsColor(QColor color) |
|
432 | void QAxis::setLabelsColor(QColor color) | |
422 | { |
|
433 | { | |
423 | QBrush b = d_ptr->m_labelsBrush; |
|
434 | QBrush b = d_ptr->m_labelsBrush; | |
424 | if (b.color() != color) { |
|
435 | if (b.color() != color) { | |
425 | b.setColor(color); |
|
436 | b.setColor(color); | |
426 | setLabelsBrush(b); |
|
437 | setLabelsBrush(b); | |
427 | emit labelsColorChanged(color); |
|
438 | emit labelsColorChanged(color); | |
428 | } |
|
439 | } | |
429 | } |
|
440 | } | |
430 |
|
441 | |||
431 | QColor QAxis::labelsColor() const |
|
442 | QColor QAxis::labelsColor() const | |
432 | { |
|
443 | { | |
433 | return d_ptr->m_labelsBrush.color(); |
|
444 | return d_ptr->m_labelsBrush.color(); | |
434 | } |
|
445 | } | |
435 |
|
446 | |||
436 | void QAxis::setShadesVisible(bool visible) |
|
447 | void QAxis::setShadesVisible(bool visible) | |
437 | { |
|
448 | { | |
438 | if (d_ptr->m_shadesVisible != visible) { |
|
449 | if (d_ptr->m_shadesVisible != visible) { | |
439 | d_ptr->m_shadesVisible = visible; |
|
450 | d_ptr->m_shadesVisible = visible; | |
440 | emit d_ptr->updated(); |
|
451 | emit d_ptr->updated(); | |
441 | emit shadesVisibleChanged(visible); |
|
452 | emit shadesVisibleChanged(visible); | |
442 | } |
|
453 | } | |
443 | } |
|
454 | } | |
444 |
|
455 | |||
445 | bool QAxis::shadesVisible() const |
|
456 | bool QAxis::shadesVisible() const | |
446 | { |
|
457 | { | |
447 | return d_ptr->m_shadesVisible; |
|
458 | return d_ptr->m_shadesVisible; | |
448 | } |
|
459 | } | |
449 |
|
460 | |||
450 | /*! |
|
461 | /*! | |
451 | Sets \a pen used to draw shades. |
|
462 | Sets \a pen used to draw shades. | |
452 | */ |
|
463 | */ | |
453 | void QAxis::setShadesPen(const QPen &pen) |
|
464 | void QAxis::setShadesPen(const QPen &pen) | |
454 | { |
|
465 | { | |
455 | if (d_ptr->m_shadesPen != pen) { |
|
466 | if (d_ptr->m_shadesPen != pen) { | |
456 | d_ptr->m_shadesPen = pen; |
|
467 | d_ptr->m_shadesPen = pen; | |
457 | emit d_ptr->updated(); |
|
468 | emit d_ptr->updated(); | |
458 | } |
|
469 | } | |
459 | } |
|
470 | } | |
460 |
|
471 | |||
461 | /*! |
|
472 | /*! | |
462 | Returns pen used to draw shades. |
|
473 | Returns pen used to draw shades. | |
463 | */ |
|
474 | */ | |
464 | QPen QAxis::shadesPen() const |
|
475 | QPen QAxis::shadesPen() const | |
465 | { |
|
476 | { | |
466 | return d_ptr->m_shadesPen; |
|
477 | return d_ptr->m_shadesPen; | |
467 | } |
|
478 | } | |
468 |
|
479 | |||
469 | /*! |
|
480 | /*! | |
470 | Sets \a brush used to draw shades. |
|
481 | Sets \a brush used to draw shades. | |
471 | */ |
|
482 | */ | |
472 | void QAxis::setShadesBrush(const QBrush &brush) |
|
483 | void QAxis::setShadesBrush(const QBrush &brush) | |
473 | { |
|
484 | { | |
474 | if (d_ptr->m_shadesBrush != brush) { |
|
485 | if (d_ptr->m_shadesBrush != brush) { | |
475 | d_ptr->m_shadesBrush = brush; |
|
486 | d_ptr->m_shadesBrush = brush; | |
476 | emit d_ptr->updated(); |
|
487 | emit d_ptr->updated(); | |
477 | emit shadesColorChanged(brush.color()); |
|
488 | emit shadesColorChanged(brush.color()); | |
478 | } |
|
489 | } | |
479 | } |
|
490 | } | |
480 |
|
491 | |||
481 | /*! |
|
492 | /*! | |
482 | \brief Returns brush used to draw shades. |
|
493 | \brief Returns brush used to draw shades. | |
483 | */ |
|
494 | */ | |
484 | QBrush QAxis::shadesBrush() const |
|
495 | QBrush QAxis::shadesBrush() const | |
485 | { |
|
496 | { | |
486 | return d_ptr->m_shadesBrush; |
|
497 | return d_ptr->m_shadesBrush; | |
487 | } |
|
498 | } | |
488 |
|
499 | |||
489 | void QAxis::setShadesColor(QColor color) |
|
500 | void QAxis::setShadesColor(QColor color) | |
490 | { |
|
501 | { | |
491 | QBrush b = d_ptr->m_shadesBrush; |
|
502 | QBrush b = d_ptr->m_shadesBrush; | |
492 | b.setColor(color); |
|
503 | b.setColor(color); | |
493 | setShadesBrush(b); |
|
504 | setShadesBrush(b); | |
494 | } |
|
505 | } | |
495 |
|
506 | |||
496 | QColor QAxis::shadesColor() const |
|
507 | QColor QAxis::shadesColor() const | |
497 | { |
|
508 | { | |
498 | return d_ptr->m_shadesBrush.color(); |
|
509 | return d_ptr->m_shadesBrush.color(); | |
499 | } |
|
510 | } | |
500 |
|
511 | |||
501 | void QAxis::setShadesBorderColor(QColor color) |
|
512 | void QAxis::setShadesBorderColor(QColor color) | |
502 | { |
|
513 | { | |
503 | QPen p = d_ptr->m_shadesPen; |
|
514 | QPen p = d_ptr->m_shadesPen; | |
504 | p.setColor(color); |
|
515 | p.setColor(color); | |
505 | setShadesPen(p); |
|
516 | setShadesPen(p); | |
506 | } |
|
517 | } | |
507 |
|
518 | |||
508 | QColor QAxis::shadesBorderColor() const |
|
519 | QColor QAxis::shadesBorderColor() const | |
509 | { |
|
520 | { | |
510 | return d_ptr->m_shadesPen.color(); |
|
521 | return d_ptr->m_shadesPen.color(); | |
511 | } |
|
522 | } | |
512 |
|
523 | |||
513 | void QAxis::setMin(qreal min) |
|
524 | void QAxis::setMin(qreal min) | |
514 | { |
|
525 | { | |
515 | setRange(min,d_ptr->m_max); |
|
526 | setRange(min,d_ptr->m_max); | |
516 | } |
|
527 | } | |
517 |
|
528 | |||
518 | qreal QAxis::min() const |
|
529 | qreal QAxis::min() const | |
519 | { |
|
530 | { | |
520 | return d_ptr->m_min; |
|
531 | return d_ptr->m_min; | |
521 | } |
|
532 | } | |
522 |
|
533 | |||
523 | void QAxis::setMax(qreal max) |
|
534 | void QAxis::setMax(qreal max) | |
524 | { |
|
535 | { | |
525 | setRange(d_ptr->m_min,max); |
|
536 | setRange(d_ptr->m_min,max); | |
526 | } |
|
537 | } | |
527 |
|
538 | |||
528 | qreal QAxis::max() const |
|
539 | qreal QAxis::max() const | |
529 | { |
|
540 | { | |
530 | return d_ptr->m_max; |
|
541 | return d_ptr->m_max; | |
531 | } |
|
542 | } | |
532 |
|
543 | |||
533 | /*! |
|
544 | /*! | |
534 | Sets range from \a min to \a max on the axis. |
|
545 | Sets range from \a min to \a max on the axis. | |
535 | */ |
|
546 | */ | |
536 | void QAxis::setRange(qreal min, qreal max) |
|
547 | void QAxis::setRange(qreal min, qreal max) | |
537 | { |
|
548 | { | |
538 | bool changed = false; |
|
549 | bool changed = false; | |
539 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { |
|
550 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { | |
540 | d_ptr->m_min = min; |
|
551 | d_ptr->m_min = min; | |
541 | changed = true; |
|
552 | changed = true; | |
542 | emit minChanged(min); |
|
553 | emit minChanged(min); | |
543 | } |
|
554 | } | |
544 |
|
555 | |||
545 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { |
|
556 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { | |
546 | d_ptr->m_max = max; |
|
557 | d_ptr->m_max = max; | |
547 | changed = true; |
|
558 | changed = true; | |
548 | emit maxChanged(max); |
|
559 | emit maxChanged(max); | |
549 | } |
|
560 | } | |
550 |
|
561 | |||
551 | if (changed) { |
|
562 | if (changed) { | |
552 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); |
|
563 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); | |
553 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
564 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
554 | } |
|
565 | } | |
555 | } |
|
566 | } | |
556 |
|
567 | |||
557 | /*! |
|
568 | /*! | |
558 | Sets \a count for ticks on the axis. |
|
569 | Sets \a count for ticks on the axis. | |
559 | */ |
|
570 | */ | |
560 | void QAxis::setTicksCount(int count) |
|
571 | void QAxis::setTicksCount(int count) | |
561 | { |
|
572 | { | |
562 | if (d_ptr->m_ticksCount != count) { |
|
573 | if (d_ptr->m_ticksCount != count) { | |
563 | d_ptr->m_ticksCount = count; |
|
574 | d_ptr->m_ticksCount = count; | |
564 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
575 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
565 | } |
|
576 | } | |
566 | } |
|
577 | } | |
567 |
|
578 | |||
568 | /*! |
|
579 | /*! | |
569 | \fn int QAxis::ticksCount() const |
|
580 | \fn int QAxis::ticksCount() const | |
570 | Return number of ticks on the axis |
|
581 | Return number of ticks on the axis | |
571 | */ |
|
582 | */ | |
572 | int QAxis::ticksCount() const |
|
583 | int QAxis::ticksCount() const | |
573 | { |
|
584 | { | |
574 | return d_ptr->m_ticksCount; |
|
585 | return d_ptr->m_ticksCount; | |
575 | } |
|
586 | } | |
576 |
|
587 | |||
577 | /*! |
|
588 | /*! | |
578 | Sets axis, shades, labels and grid lines to be visible. |
|
589 | Sets axis, shades, labels and grid lines to be visible. | |
579 | */ |
|
590 | */ | |
580 | void QAxis::show() |
|
591 | void QAxis::show() | |
581 | { |
|
592 | { | |
582 | d_ptr->m_axisVisible=true; |
|
593 | d_ptr->m_axisVisible=true; | |
583 | d_ptr->m_gridLineVisible=true; |
|
594 | d_ptr->m_gridLineVisible=true; | |
584 | d_ptr->m_labelsVisible=true; |
|
595 | d_ptr->m_labelsVisible=true; | |
585 | d_ptr->m_shadesVisible=true; |
|
596 | d_ptr->m_shadesVisible=true; | |
586 | emit d_ptr->updated(); |
|
597 | emit d_ptr->updated(); | |
587 | } |
|
598 | } | |
588 |
|
599 | |||
589 | /*! |
|
600 | /*! | |
590 | Sets axis, shades, labels and grid lines to not be visible. |
|
601 | Sets axis, shades, labels and grid lines to not be visible. | |
591 | */ |
|
602 | */ | |
592 | void QAxis::hide() |
|
603 | void QAxis::hide() | |
593 | { |
|
604 | { | |
594 | d_ptr->m_axisVisible = false; |
|
605 | d_ptr->m_axisVisible = false; | |
595 | d_ptr->m_gridLineVisible = false; |
|
606 | d_ptr->m_gridLineVisible = false; | |
596 | d_ptr->m_labelsVisible = false; |
|
607 | d_ptr->m_labelsVisible = false; | |
597 | d_ptr->m_shadesVisible = false; |
|
608 | d_ptr->m_shadesVisible = false; | |
598 | emit d_ptr->updated(); |
|
609 | emit d_ptr->updated(); | |
599 | } |
|
610 | } | |
600 |
|
611 | |||
601 | void QAxis::setNiceNumbersEnabled(bool enable) |
|
612 | void QAxis::setNiceNumbersEnabled(bool enable) | |
602 | { |
|
613 | { | |
603 | if (d_ptr->m_niceNumbers != enable){ |
|
614 | if (d_ptr->m_niceNumbers != enable){ | |
604 | d_ptr->m_niceNumbers = enable; |
|
615 | d_ptr->m_niceNumbers = enable; | |
605 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
616 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
606 | } |
|
617 | } | |
607 | } |
|
618 | } | |
608 |
|
619 | |||
609 | bool QAxis::niceNumbersEnabled() const |
|
620 | bool QAxis::niceNumbersEnabled() const | |
610 | { |
|
621 | { | |
611 | return d_ptr->m_niceNumbers; |
|
622 | return d_ptr->m_niceNumbers; | |
612 | } |
|
623 | } | |
613 |
|
624 | |||
614 | QAxisCategories* QAxis::categories() |
|
625 | QAxisCategories* QAxis::categories() | |
615 | { |
|
626 | { | |
616 | return &d_ptr->m_category; |
|
627 | return &d_ptr->m_category; | |
617 | } |
|
628 | } | |
618 |
|
629 | |||
619 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
630 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
620 |
|
631 | |||
621 | QAxisPrivate::QAxisPrivate(QAxis* q): |
|
632 | QAxisPrivate::QAxisPrivate(QAxis* q): | |
622 | q_ptr(q), |
|
633 | q_ptr(q), | |
623 | m_axisVisible(true), |
|
634 | m_axisVisible(true), | |
624 | m_gridLineVisible(true), |
|
635 | m_gridLineVisible(true), | |
625 | m_labelsVisible(true), |
|
636 | m_labelsVisible(true), | |
626 | m_labelsAngle(0), |
|
637 | m_labelsAngle(0), | |
627 | m_shadesVisible(false), |
|
638 | m_shadesVisible(false), | |
628 | m_shadesBrush(Qt::SolidPattern), |
|
639 | m_shadesBrush(Qt::SolidPattern), | |
629 | m_shadesOpacity(1.0), |
|
640 | m_shadesOpacity(1.0), | |
630 | m_min(0), |
|
641 | m_min(0), | |
631 | m_max(0), |
|
642 | m_max(0), | |
632 | m_ticksCount(5), |
|
643 | m_ticksCount(5), | |
633 | m_niceNumbers(false) |
|
644 | m_niceNumbers(false) | |
634 | { |
|
645 | { | |
635 |
|
646 | |||
636 | } |
|
647 | } | |
637 |
|
648 | |||
638 | QAxisPrivate::~QAxisPrivate() |
|
649 | QAxisPrivate::~QAxisPrivate() | |
639 | { |
|
650 | { | |
640 |
|
651 | |||
641 | } |
|
652 | } | |
642 |
|
653 | |||
643 | void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
654 | void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
644 | { |
|
655 | { | |
645 | q_ptr->setRange(min,max); |
|
656 | q_ptr->setRange(min,max); | |
646 | q_ptr->setTicksCount(count); |
|
657 | q_ptr->setTicksCount(count); | |
647 | } |
|
658 | } | |
648 |
|
659 | |||
649 | QTCOMMERCIALCHART_END_NAMESPACE |
|
660 | QTCOMMERCIALCHART_END_NAMESPACE | |
650 |
|
661 | |||
651 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
662 | QTCOMMERCIALCHART_USE_NAMESPACE | |
652 |
|
663 | |||
653 | #include "moc_qaxis.cpp" |
|
664 | #include "moc_qaxis.cpp" | |
654 | #include "moc_qaxis_p.cpp" |
|
665 | #include "moc_qaxis_p.cpp" |
@@ -1,135 +1,136 | |||||
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 QAXIS_H |
|
21 | #ifndef QAXIS_H | |
22 | #define QAXIS_H |
|
22 | #define QAXIS_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qaxiscategories.h> |
|
25 | #include <qaxiscategories.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QFont> |
|
27 | #include <QFont> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QAxisPrivate; |
|
31 | class QAxisPrivate; | |
32 |
|
32 | |||
33 | class QTCOMMERCIALCHART_EXPORT QAxis : public QObject |
|
33 | class QTCOMMERCIALCHART_EXPORT QAxis : public QObject | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged) |
|
36 | Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged) | |
37 | Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged) |
|
37 | Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged) | |
38 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
38 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) | |
39 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle) |
|
39 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle) | |
|
40 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont) | |||
40 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) |
|
41 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) | |
41 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) |
|
42 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) | |
42 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
|
43 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) | |
43 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
|
44 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) | |
44 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
|
45 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) | |
45 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) |
|
46 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) | |
46 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) |
|
47 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) | |
47 | Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount) |
|
48 | Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount) | |
48 | Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled) |
|
49 | Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled) | |
49 |
|
50 | |||
50 | public: |
|
51 | public: | |
51 |
|
52 | |||
52 | QAxis(QObject *parent =0); |
|
53 | QAxis(QObject *parent =0); | |
53 | ~QAxis(); |
|
54 | ~QAxis(); | |
54 |
|
55 | |||
55 | //axis handling |
|
56 | //axis handling | |
56 | bool isAxisVisible() const; |
|
57 | bool isAxisVisible() const; | |
57 | void setAxisVisible(bool visible = true); |
|
58 | void setAxisVisible(bool visible = true); | |
58 | void setAxisPen(const QPen &pen); |
|
59 | void setAxisPen(const QPen &pen); | |
59 | QPen axisPen() const; |
|
60 | QPen axisPen() const; | |
60 | void setAxisPenColor(QColor color); |
|
61 | void setAxisPenColor(QColor color); | |
61 | QColor axisPenColor() const; |
|
62 | QColor axisPenColor() const; | |
62 |
|
63 | |||
63 | //grid handling |
|
64 | //grid handling | |
64 | bool isGridLineVisible() const; |
|
65 | bool isGridLineVisible() const; | |
65 | void setGridLineVisible(bool visible = true); |
|
66 | void setGridLineVisible(bool visible = true); | |
66 | void setGridLinePen(const QPen &pen); |
|
67 | void setGridLinePen(const QPen &pen); | |
67 | QPen gridLinePen() const; |
|
68 | QPen gridLinePen() const; | |
68 |
|
69 | |||
69 | //labels handling |
|
70 | //labels handling | |
70 | bool labelsVisible() const; |
|
71 | bool labelsVisible() const; | |
71 | void setLabelsVisible(bool visible = true); |
|
72 | void setLabelsVisible(bool visible = true); | |
72 | void setLabelsPen(const QPen &pen); |
|
73 | void setLabelsPen(const QPen &pen); | |
73 | QPen labelsPen() const; |
|
74 | QPen labelsPen() const; | |
74 | void setLabelsBrush(const QBrush &brush); |
|
75 | void setLabelsBrush(const QBrush &brush); | |
75 | QBrush labelsBrush() const; |
|
76 | QBrush labelsBrush() const; | |
76 | void setLabelsFont(const QFont &font); |
|
77 | void setLabelsFont(const QFont &font); | |
77 | QFont labelsFont() const; |
|
78 | QFont labelsFont() const; | |
78 | void setLabelsAngle(int angle); |
|
79 | void setLabelsAngle(int angle); | |
79 | int labelsAngle() const; |
|
80 | int labelsAngle() const; | |
80 | void setLabelsColor(QColor color); |
|
81 | void setLabelsColor(QColor color); | |
81 | QColor labelsColor() const; |
|
82 | QColor labelsColor() const; | |
82 |
|
83 | |||
83 | //shades handling |
|
84 | //shades handling | |
84 | bool shadesVisible() const; |
|
85 | bool shadesVisible() const; | |
85 | void setShadesVisible(bool visible = true); |
|
86 | void setShadesVisible(bool visible = true); | |
86 | void setShadesPen(const QPen &pen); |
|
87 | void setShadesPen(const QPen &pen); | |
87 | QPen shadesPen() const; |
|
88 | QPen shadesPen() const; | |
88 | void setShadesBrush(const QBrush &brush); |
|
89 | void setShadesBrush(const QBrush &brush); | |
89 | QBrush shadesBrush() const; |
|
90 | QBrush shadesBrush() const; | |
90 | void setShadesColor(QColor color); |
|
91 | void setShadesColor(QColor color); | |
91 | QColor shadesColor() const; |
|
92 | QColor shadesColor() const; | |
92 | void setShadesBorderColor(QColor color); |
|
93 | void setShadesBorderColor(QColor color); | |
93 | QColor shadesBorderColor() const; |
|
94 | QColor shadesBorderColor() const; | |
94 |
|
95 | |||
95 | //range handling |
|
96 | //range handling | |
96 | void setMin(qreal min); |
|
97 | void setMin(qreal min); | |
97 | qreal min() const; |
|
98 | qreal min() const; | |
98 | void setMax(qreal max); |
|
99 | void setMax(qreal max); | |
99 | qreal max() const; |
|
100 | qreal max() const; | |
100 | void setRange(qreal min, qreal max); |
|
101 | void setRange(qreal min, qreal max); | |
101 |
|
102 | |||
102 | //ticks handling |
|
103 | //ticks handling | |
103 | void setTicksCount(int count); |
|
104 | void setTicksCount(int count); | |
104 | int ticksCount() const; |
|
105 | int ticksCount() const; | |
105 |
|
106 | |||
106 | void setNiceNumbersEnabled(bool enable = true); |
|
107 | void setNiceNumbersEnabled(bool enable = true); | |
107 | bool niceNumbersEnabled() const; |
|
108 | bool niceNumbersEnabled() const; | |
108 |
|
109 | |||
109 | QAxisCategories* categories(); |
|
110 | QAxisCategories* categories(); | |
110 |
|
111 | |||
111 | void show(); |
|
112 | void show(); | |
112 | void hide(); |
|
113 | void hide(); | |
113 |
|
114 | |||
114 | Q_SIGNALS: |
|
115 | Q_SIGNALS: | |
115 | void visibleChanged(bool visible); |
|
116 | void visibleChanged(bool visible); | |
116 | void labelsVisibleChanged(bool visible); |
|
117 | void labelsVisibleChanged(bool visible); | |
117 | void gridVisibleChanged(bool visible); |
|
118 | void gridVisibleChanged(bool visible); | |
118 | void rangeChanged(qreal min, qreal max); |
|
119 | void rangeChanged(qreal min, qreal max); | |
119 | void colorChanged(QColor color); |
|
120 | void colorChanged(QColor color); | |
120 | void labelsColorChanged(QColor color); |
|
121 | void labelsColorChanged(QColor color); | |
121 | void shadesVisibleChanged(bool visible); |
|
122 | void shadesVisibleChanged(bool visible); | |
122 | void shadesColorChanged(QColor color); |
|
123 | void shadesColorChanged(QColor color); | |
123 | void shadesBorderColorChanged(QColor color); |
|
124 | void shadesBorderColorChanged(QColor color); | |
124 | void minChanged(qreal min); |
|
125 | void minChanged(qreal min); | |
125 | void maxChanged(qreal max); |
|
126 | void maxChanged(qreal max); | |
126 |
|
127 | |||
127 | private: |
|
128 | private: | |
128 | QScopedPointer<QAxisPrivate> d_ptr; |
|
129 | QScopedPointer<QAxisPrivate> d_ptr; | |
129 | Q_DISABLE_COPY(QAxis) |
|
130 | Q_DISABLE_COPY(QAxis) | |
130 | friend class ChartDataSet; |
|
131 | friend class ChartDataSet; | |
131 | friend class ChartAxis; |
|
132 | friend class ChartAxis; | |
132 | }; |
|
133 | }; | |
133 |
|
134 | |||
134 | QTCOMMERCIALCHART_END_NAMESPACE |
|
135 | QTCOMMERCIALCHART_END_NAMESPACE | |
135 | #endif /* QCHARTAXIS_H_ */ |
|
136 | #endif /* QCHARTAXIS_H_ */ |
@@ -1,648 +1,655 | |||||
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 "qbarset.h" |
|
21 | #include "qbarset.h" | |
22 | #include "qbarset_p.h" |
|
22 | #include "qbarset_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QBarSet |
|
27 | \class QBarSet | |
28 | \brief Building block for different bar charts |
|
28 | \brief Building block for different bar charts | |
29 |
|
29 | |||
30 | QBarSet represents one set of bars. Set of bars contains one data value for each category. |
|
30 | QBarSet represents one set of bars. Set of bars contains one data value for each category. | |
31 | First value of set is assumed to belong to first category, second to second category and so on. |
|
31 | First value of set is assumed to belong to first category, second to second category and so on. | |
32 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
32 | If set has fewer values than there are categories, then the missing values are assumed to be | |
33 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
33 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
34 |
|
34 | |||
35 | \mainclass |
|
35 | \mainclass | |
36 |
|
36 | |||
37 | \sa QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries |
|
37 | \sa QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries | |
38 | */ |
|
38 | */ | |
39 | /*! |
|
39 | /*! | |
40 | \qmlclass BarSet QBarSet |
|
40 | \qmlclass BarSet QBarSet | |
41 |
|
41 | |||
42 | BarSet represents one set of bars. Set of bars contains one data value for each category. |
|
42 | BarSet represents one set of bars. Set of bars contains one data value for each category. | |
43 | First value of set is assumed to belong to first category, second to second category and so on. |
|
43 | First value of set is assumed to belong to first category, second to second category and so on. | |
44 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
44 | If set has fewer values than there are categories, then the missing values are assumed to be | |
45 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
45 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
46 | \sa BarSeries, GroupedBarSeries, StackedBarSeries, PercentBarSeries |
|
46 | \sa BarSeries, GroupedBarSeries, StackedBarSeries, PercentBarSeries | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \property QBarSet::label |
|
50 | \property QBarSet::label | |
51 | Defines the label of the barSet. |
|
51 | Defines the label of the barSet. | |
52 | */ |
|
52 | */ | |
53 | /*! |
|
53 | /*! | |
54 | \qmlproperty string BarSet::label |
|
54 | \qmlproperty string BarSet::label | |
55 | Defines the label of the barSet. |
|
55 | Defines the label of the barSet. | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \property QBarSet::pen |
|
59 | \property QBarSet::pen | |
60 | \brief Defines the pen used by the barSet. |
|
60 | \brief Defines the pen used by the barSet. | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \property QBarSet::brush |
|
64 | \property QBarSet::brush | |
65 | \brief Defines the brush used by the barSet. |
|
65 | \brief Defines the brush used by the barSet. | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \property QBarSet::labelBrush |
|
69 | \property QBarSet::labelBrush | |
70 | \brief Defines the brush used by the barSet's label. |
|
70 | \brief Defines the brush used by the barSet's label. | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \property QBarSet::labelFont |
|
74 | \property QBarSet::labelFont | |
75 | \brief Defines the font used by the barSet's label. |
|
75 | \brief Defines the font used by the barSet's label. | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
|
79 | \qmlproperty Font BarSet::labelFont | |||
|
80 | Defines the font used by the barSet's label. | |||
|
81 | ||||
|
82 | See the \l {Font} {QML Font Element} for detailed documentation. | |||
|
83 | */ | |||
|
84 | ||||
|
85 | /*! | |||
79 | \property QBarSet::color |
|
86 | \property QBarSet::color | |
80 | The fill (brush) color of the bar set. |
|
87 | The fill (brush) color of the bar set. | |
81 | */ |
|
88 | */ | |
82 | /*! |
|
89 | /*! | |
83 | \qmlproperty color BarSet::color |
|
90 | \qmlproperty color BarSet::color | |
84 | The fill (brush) color of the bar set. |
|
91 | The fill (brush) color of the bar set. | |
85 | */ |
|
92 | */ | |
86 |
|
93 | |||
87 | /*! |
|
94 | /*! | |
88 | \property QBarSet::borderColor |
|
95 | \property QBarSet::borderColor | |
89 | The line (pen) color of the bar set. |
|
96 | The line (pen) color of the bar set. | |
90 | */ |
|
97 | */ | |
91 | /*! |
|
98 | /*! | |
92 | \qmlproperty color BarSet::borderColor |
|
99 | \qmlproperty color BarSet::borderColor | |
93 | The line (pen) color of the bar set. |
|
100 | The line (pen) color of the bar set. | |
94 | */ |
|
101 | */ | |
95 |
|
102 | |||
96 | /*! |
|
103 | /*! | |
97 | \property QBarSet::labelColor |
|
104 | \property QBarSet::labelColor | |
98 | The text (label) color of the bar set. |
|
105 | The text (label) color of the bar set. | |
99 | */ |
|
106 | */ | |
100 | /*! |
|
107 | /*! | |
101 | \qmlproperty color BarSet::labelColor |
|
108 | \qmlproperty color BarSet::labelColor | |
102 | The text (label) color of the bar set. |
|
109 | The text (label) color of the bar set. | |
103 | */ |
|
110 | */ | |
104 |
|
111 | |||
105 | /*! |
|
112 | /*! | |
106 | \fn void QBarSet::clicked(int index) |
|
113 | \fn void QBarSet::clicked(int index) | |
107 |
|
114 | |||
108 | The signal is emitted if the user clicks with a mouse on top of barset. |
|
115 | The signal is emitted if the user clicks with a mouse on top of barset. | |
109 | Clicked bar inside set is indexed by \a index |
|
116 | Clicked bar inside set is indexed by \a index | |
110 | */ |
|
117 | */ | |
111 |
|
118 | |||
112 | /*! |
|
119 | /*! | |
113 | \fn void QBarSet::hovered(bool status) |
|
120 | \fn void QBarSet::hovered(bool status) | |
114 |
|
121 | |||
115 | The signal is emitted if mouse is hovered on top of barset. |
|
122 | The signal is emitted if mouse is hovered on top of barset. | |
116 | Parameter \a status is true, if mouse entered on top of barset, false if mouse left from top of barset. |
|
123 | Parameter \a status is true, if mouse entered on top of barset, false if mouse left from top of barset. | |
117 | */ |
|
124 | */ | |
118 |
|
125 | |||
119 |
|
126 | |||
120 | /*! |
|
127 | /*! | |
121 | \fn void QBarSet::labelChanged() |
|
128 | \fn void QBarSet::labelChanged() | |
122 | This signal is emitted when the label of the barSet has changed. |
|
129 | This signal is emitted when the label of the barSet has changed. | |
123 | \sa label |
|
130 | \sa label | |
124 | */ |
|
131 | */ | |
125 |
|
132 | |||
126 | /*! |
|
133 | /*! | |
127 | \fn void QBarSet::penChanged() |
|
134 | \fn void QBarSet::penChanged() | |
128 | This signal is emitted when the pen of the barSet has changed. |
|
135 | This signal is emitted when the pen of the barSet has changed. | |
129 | \sa pen |
|
136 | \sa pen | |
130 | */ |
|
137 | */ | |
131 |
|
138 | |||
132 | /*! |
|
139 | /*! | |
133 | \fn void QBarSet::brushChanged() |
|
140 | \fn void QBarSet::brushChanged() | |
134 | This signal is emitted when the brush of the barSet has changed. |
|
141 | This signal is emitted when the brush of the barSet has changed. | |
135 | \sa brush |
|
142 | \sa brush | |
136 | */ |
|
143 | */ | |
137 |
|
144 | |||
138 | /*! |
|
145 | /*! | |
139 | \fn void QBarSet::labelBrushChanged() |
|
146 | \fn void QBarSet::labelBrushChanged() | |
140 | This signal is emitted when the brush of the barSet's label has changed. |
|
147 | This signal is emitted when the brush of the barSet's label has changed. | |
141 | \sa labelBrush |
|
148 | \sa labelBrush | |
142 | */ |
|
149 | */ | |
143 |
|
150 | |||
144 | /*! |
|
151 | /*! | |
145 | \fn void QBarSet::labelFontChanged() |
|
152 | \fn void QBarSet::labelFontChanged() | |
146 | This signal is emitted when the font of the barSet's label has changed. |
|
153 | This signal is emitted when the font of the barSet's label has changed. | |
147 | \sa labelBrush |
|
154 | \sa labelBrush | |
148 | */ |
|
155 | */ | |
149 |
|
156 | |||
150 | /*! |
|
157 | /*! | |
151 | \fn void QBarSet::colorChanged(QColor) |
|
158 | \fn void QBarSet::colorChanged(QColor) | |
152 | This signal is emitted when the fill (brush) color of the set has changed to \a color. |
|
159 | This signal is emitted when the fill (brush) color of the set has changed to \a color. | |
153 | */ |
|
160 | */ | |
154 | /*! |
|
161 | /*! | |
155 | \qmlsignal BarSet::onColorChanged(color color) |
|
162 | \qmlsignal BarSet::onColorChanged(color color) | |
156 | This signal is emitted when the fill (brush) color of the set has changed to \a color. |
|
163 | This signal is emitted when the fill (brush) color of the set has changed to \a color. | |
157 | */ |
|
164 | */ | |
158 |
|
165 | |||
159 | /*! |
|
166 | /*! | |
160 | \fn void QBarSet::borderColorChanged(QColor) |
|
167 | \fn void QBarSet::borderColorChanged(QColor) | |
161 | This signal is emitted when the line (pen) color of the set has changed to \a color. |
|
168 | This signal is emitted when the line (pen) color of the set has changed to \a color. | |
162 | */ |
|
169 | */ | |
163 | /*! |
|
170 | /*! | |
164 | \qmlsignal BarSet::onBorderColorChanged(color color) |
|
171 | \qmlsignal BarSet::onBorderColorChanged(color color) | |
165 | This signal is emitted when the line (pen) color of the set has changed to \a color. |
|
172 | This signal is emitted when the line (pen) color of the set has changed to \a color. | |
166 | */ |
|
173 | */ | |
167 |
|
174 | |||
168 | /*! |
|
175 | /*! | |
169 | \fn void QBarSet::labelColorChanged(QColor) |
|
176 | \fn void QBarSet::labelColorChanged(QColor) | |
170 | This signal is emitted when the text (label) color of the set has changed to \a color. |
|
177 | This signal is emitted when the text (label) color of the set has changed to \a color. | |
171 | */ |
|
178 | */ | |
172 | /*! |
|
179 | /*! | |
173 | \qmlsignal BarSet::onLabelColorChanged(color color) |
|
180 | \qmlsignal BarSet::onLabelColorChanged(color color) | |
174 | This signal is emitted when the text (label) color of the set has changed to \a color. |
|
181 | This signal is emitted when the text (label) color of the set has changed to \a color. | |
175 | */ |
|
182 | */ | |
176 |
|
183 | |||
177 | /*! |
|
184 | /*! | |
178 | \fn void QBarSet::valuesAdded(int index, int count) |
|
185 | \fn void QBarSet::valuesAdded(int index, int count) | |
179 | This signal is emitted when new values have been added to the set. |
|
186 | This signal is emitted when new values have been added to the set. | |
180 | Parameter \a index indicates the position of the first inserted value. |
|
187 | Parameter \a index indicates the position of the first inserted value. | |
181 | Parameter \a count is the number of iserted values. |
|
188 | Parameter \a count is the number of iserted values. | |
182 | \sa append(), insert() |
|
189 | \sa append(), insert() | |
183 | */ |
|
190 | */ | |
184 | /*! |
|
191 | /*! | |
185 | \qmlsignal BarSet::onValuesAdded(int index, int count) |
|
192 | \qmlsignal BarSet::onValuesAdded(int index, int count) | |
186 | This signal is emitted when new values have been added to the set. |
|
193 | This signal is emitted when new values have been added to the set. | |
187 | Parameter \a index indicates the position of the first inserted value. |
|
194 | Parameter \a index indicates the position of the first inserted value. | |
188 | Parameter \a count is the number of iserted values. |
|
195 | Parameter \a count is the number of iserted values. | |
189 | */ |
|
196 | */ | |
190 |
|
197 | |||
191 | /*! |
|
198 | /*! | |
192 | \fn void QBarSet::valuesRemoved(int index, int count) |
|
199 | \fn void QBarSet::valuesRemoved(int index, int count) | |
193 | This signal is emitted values have been removed from the set. |
|
200 | This signal is emitted values have been removed from the set. | |
194 | Parameter \a index indicates the position of the first removed value. |
|
201 | Parameter \a index indicates the position of the first removed value. | |
195 | Parameter \a count is the number of removed values. |
|
202 | Parameter \a count is the number of removed values. | |
196 | \sa remove() |
|
203 | \sa remove() | |
197 | */ |
|
204 | */ | |
198 | /*! |
|
205 | /*! | |
199 | \qmlsignal BarSet::onValuesRemoved(int index, int count) |
|
206 | \qmlsignal BarSet::onValuesRemoved(int index, int count) | |
200 | This signal is emitted values have been removed from the set. |
|
207 | This signal is emitted values have been removed from the set. | |
201 | Parameter \a index indicates the position of the first removed value. |
|
208 | Parameter \a index indicates the position of the first removed value. | |
202 | Parameter \a count is the number of removed values. |
|
209 | Parameter \a count is the number of removed values. | |
203 | */ |
|
210 | */ | |
204 |
|
211 | |||
205 | /*! |
|
212 | /*! | |
206 | \fn void QBarSet::valueChanged(int index) |
|
213 | \fn void QBarSet::valueChanged(int index) | |
207 | This signal is emitted values the value in the set has been modified. |
|
214 | This signal is emitted values the value in the set has been modified. | |
208 | Parameter \a index indicates the position of the modified value. |
|
215 | Parameter \a index indicates the position of the modified value. | |
209 | \sa at() |
|
216 | \sa at() | |
210 | */ |
|
217 | */ | |
211 | /*! |
|
218 | /*! | |
212 | \qmlsignal BarSet::onValueChanged(int index) |
|
219 | \qmlsignal BarSet::onValueChanged(int index) | |
213 | This signal is emitted values the value in the set has been modified. |
|
220 | This signal is emitted values the value in the set has been modified. | |
214 | Parameter \a index indicates the position of the modified value. |
|
221 | Parameter \a index indicates the position of the modified value. | |
215 | */ |
|
222 | */ | |
216 |
|
223 | |||
217 | /*! |
|
224 | /*! | |
218 | Constructs QBarSet with a label of \a label and with parent of \a parent |
|
225 | Constructs QBarSet with a label of \a label and with parent of \a parent | |
219 | */ |
|
226 | */ | |
220 | QBarSet::QBarSet(const QString label, QObject *parent) |
|
227 | QBarSet::QBarSet(const QString label, QObject *parent) | |
221 | : QObject(parent) |
|
228 | : QObject(parent) | |
222 | ,d_ptr(new QBarSetPrivate(label,this)) |
|
229 | ,d_ptr(new QBarSetPrivate(label,this)) | |
223 | { |
|
230 | { | |
224 | } |
|
231 | } | |
225 |
|
232 | |||
226 | /*! |
|
233 | /*! | |
227 | Destroys the barset |
|
234 | Destroys the barset | |
228 | */ |
|
235 | */ | |
229 | QBarSet::~QBarSet() |
|
236 | QBarSet::~QBarSet() | |
230 | { |
|
237 | { | |
231 | // NOTE: d_ptr destroyed by QObject |
|
238 | // NOTE: d_ptr destroyed by QObject | |
232 | } |
|
239 | } | |
233 |
|
240 | |||
234 | /*! |
|
241 | /*! | |
235 | Sets new \a label for set. |
|
242 | Sets new \a label for set. | |
236 | */ |
|
243 | */ | |
237 | void QBarSet::setLabel(const QString label) |
|
244 | void QBarSet::setLabel(const QString label) | |
238 | { |
|
245 | { | |
239 | d_ptr->m_label = label; |
|
246 | d_ptr->m_label = label; | |
240 | emit labelChanged(); |
|
247 | emit labelChanged(); | |
241 | } |
|
248 | } | |
242 |
|
249 | |||
243 | /*! |
|
250 | /*! | |
244 | Returns label of the set. |
|
251 | Returns label of the set. | |
245 | */ |
|
252 | */ | |
246 | QString QBarSet::label() const |
|
253 | QString QBarSet::label() const | |
247 | { |
|
254 | { | |
248 | return d_ptr->m_label; |
|
255 | return d_ptr->m_label; | |
249 | } |
|
256 | } | |
250 |
|
257 | |||
251 | /*! |
|
258 | /*! | |
252 | Appends a point to set. Parameter \a value x coordinate defines the |
|
259 | Appends a point to set. Parameter \a value x coordinate defines the | |
253 | position in x-axis and y coordinate defines the height of bar. |
|
260 | position in x-axis and y coordinate defines the height of bar. | |
254 | Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries) |
|
261 | Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries) | |
255 | the x values are used or ignored. |
|
262 | the x values are used or ignored. | |
256 | */ |
|
263 | */ | |
257 | void QBarSet::append(const QPointF value) |
|
264 | void QBarSet::append(const QPointF value) | |
258 | { |
|
265 | { | |
259 | int index = d_ptr->m_values.count(); |
|
266 | int index = d_ptr->m_values.count(); | |
260 | d_ptr->append(value); |
|
267 | d_ptr->append(value); | |
261 | emit valuesAdded(index, 1); |
|
268 | emit valuesAdded(index, 1); | |
262 | } |
|
269 | } | |
263 |
|
270 | |||
264 | /*! |
|
271 | /*! | |
265 | Appends a list of \a values to set. Works like append with single point. |
|
272 | Appends a list of \a values to set. Works like append with single point. | |
266 | \sa append() |
|
273 | \sa append() | |
267 | */ |
|
274 | */ | |
268 | void QBarSet::append(const QList<QPointF> &values) |
|
275 | void QBarSet::append(const QList<QPointF> &values) | |
269 | { |
|
276 | { | |
270 | int index = d_ptr->m_values.count(); |
|
277 | int index = d_ptr->m_values.count(); | |
271 | d_ptr->append(values); |
|
278 | d_ptr->append(values); | |
272 | emit valuesAdded(index, values.count()); |
|
279 | emit valuesAdded(index, values.count()); | |
273 | } |
|
280 | } | |
274 |
|
281 | |||
275 | /*! |
|
282 | /*! | |
276 | Appends new value \a value to the end of set. Internally the value is converted to QPointF, |
|
283 | Appends new value \a value to the end of set. Internally the value is converted to QPointF, | |
277 | with x coordinate being the index of appended value and y coordinate is the value. |
|
284 | with x coordinate being the index of appended value and y coordinate is the value. | |
278 | */ |
|
285 | */ | |
279 | void QBarSet::append(const qreal value) |
|
286 | void QBarSet::append(const qreal value) | |
280 | { |
|
287 | { | |
281 | // Convert to QPointF and use other append(QPointF) method. |
|
288 | // Convert to QPointF and use other append(QPointF) method. | |
282 | append(QPointF(d_ptr->m_values.count(), value)); |
|
289 | append(QPointF(d_ptr->m_values.count(), value)); | |
283 | } |
|
290 | } | |
284 |
|
291 | |||
285 | /*! |
|
292 | /*! | |
286 | Appends a list of reals to set. Works like append with single real value. The \a values in list |
|
293 | Appends a list of reals to set. Works like append with single real value. The \a values in list | |
287 | are converted to QPointF, where x coordinate is the index of point and y coordinate is the value. |
|
294 | are converted to QPointF, where x coordinate is the index of point and y coordinate is the value. | |
288 | \sa append() |
|
295 | \sa append() | |
289 | */ |
|
296 | */ | |
290 | void QBarSet::append(const QList<qreal> &values) |
|
297 | void QBarSet::append(const QList<qreal> &values) | |
291 | { |
|
298 | { | |
292 | int index = d_ptr->m_values.count(); |
|
299 | int index = d_ptr->m_values.count(); | |
293 | d_ptr->append(values); |
|
300 | d_ptr->append(values); | |
294 | emit valuesAdded(index, values.count()); |
|
301 | emit valuesAdded(index, values.count()); | |
295 | } |
|
302 | } | |
296 |
|
303 | |||
297 | /*! |
|
304 | /*! | |
298 | Convinience operator. Same as append, with real \a value. |
|
305 | Convinience operator. Same as append, with real \a value. | |
299 | \sa append() |
|
306 | \sa append() | |
300 | */ |
|
307 | */ | |
301 | QBarSet& QBarSet::operator << (const qreal &value) |
|
308 | QBarSet& QBarSet::operator << (const qreal &value) | |
302 | { |
|
309 | { | |
303 | append(value); |
|
310 | append(value); | |
304 | return *this; |
|
311 | return *this; | |
305 | } |
|
312 | } | |
306 |
|
313 | |||
307 | /*! |
|
314 | /*! | |
308 | Convinience operator. Same as append, with QPointF \a value. |
|
315 | Convinience operator. Same as append, with QPointF \a value. | |
309 | \sa append() |
|
316 | \sa append() | |
310 | */ |
|
317 | */ | |
311 | QBarSet& QBarSet::operator << (const QPointF &value) |
|
318 | QBarSet& QBarSet::operator << (const QPointF &value) | |
312 | { |
|
319 | { | |
313 | append(value); |
|
320 | append(value); | |
314 | return *this; |
|
321 | return *this; | |
315 | } |
|
322 | } | |
316 |
|
323 | |||
317 | /*! |
|
324 | /*! | |
318 | Inserts new \a value on the \a index position. |
|
325 | Inserts new \a value on the \a index position. | |
319 | The value that is currently at this postion is moved to postion index + 1 |
|
326 | The value that is currently at this postion is moved to postion index + 1 | |
320 | \sa remove() |
|
327 | \sa remove() | |
321 | */ |
|
328 | */ | |
322 | void QBarSet::insert(const int index, const qreal value) |
|
329 | void QBarSet::insert(const int index, const qreal value) | |
323 | { |
|
330 | { | |
324 | d_ptr->insert(index, value); |
|
331 | d_ptr->insert(index, value); | |
325 | emit valuesAdded(index,1); |
|
332 | emit valuesAdded(index,1); | |
326 | } |
|
333 | } | |
327 |
|
334 | |||
328 | /*! |
|
335 | /*! | |
329 | Inserts new \a value on the \a index position. |
|
336 | Inserts new \a value on the \a index position. | |
330 | The value that is currently at this postion is moved to postion index + 1 |
|
337 | The value that is currently at this postion is moved to postion index + 1 | |
331 | \sa remove() |
|
338 | \sa remove() | |
332 | */ |
|
339 | */ | |
333 | void QBarSet::insert(const int index, const QPointF value) |
|
340 | void QBarSet::insert(const int index, const QPointF value) | |
334 | { |
|
341 | { | |
335 | d_ptr->insert(index,value); |
|
342 | d_ptr->insert(index,value); | |
336 | emit valuesAdded(index,1); |
|
343 | emit valuesAdded(index,1); | |
337 | } |
|
344 | } | |
338 |
|
345 | |||
339 | /*! |
|
346 | /*! | |
340 | Removes \a count number of values from the set starting at \a index. |
|
347 | Removes \a count number of values from the set starting at \a index. | |
341 | \sa insert() |
|
348 | \sa insert() | |
342 | */ |
|
349 | */ | |
343 | void QBarSet::remove(const int index, const int count) |
|
350 | void QBarSet::remove(const int index, const int count) | |
344 | { |
|
351 | { | |
345 | int removedCount = d_ptr->remove(index,count); |
|
352 | int removedCount = d_ptr->remove(index,count); | |
346 | if (removedCount > 0) { |
|
353 | if (removedCount > 0) { | |
347 | emit valuesRemoved(index,removedCount); |
|
354 | emit valuesRemoved(index,removedCount); | |
348 | } |
|
355 | } | |
349 | return; |
|
356 | return; | |
350 | } |
|
357 | } | |
351 |
|
358 | |||
352 | /*! |
|
359 | /*! | |
353 | Sets a new value \a value to set, indexed by \a index |
|
360 | Sets a new value \a value to set, indexed by \a index | |
354 | */ |
|
361 | */ | |
355 | void QBarSet::replace(const int index, const qreal value) |
|
362 | void QBarSet::replace(const int index, const qreal value) | |
356 | { |
|
363 | { | |
357 | if (index >= 0 && index < d_ptr->m_values.count()) { |
|
364 | if (index >= 0 && index < d_ptr->m_values.count()) { | |
358 | d_ptr->replace(index,value); |
|
365 | d_ptr->replace(index,value); | |
359 | emit valueChanged(index); |
|
366 | emit valueChanged(index); | |
360 | } |
|
367 | } | |
361 | } |
|
368 | } | |
362 |
|
369 | |||
363 | /*! |
|
370 | /*! | |
364 | Sets a new value \a value to set, indexed by \a index |
|
371 | Sets a new value \a value to set, indexed by \a index | |
365 | */ |
|
372 | */ | |
366 | void QBarSet::replace(const int index, const QPointF value) |
|
373 | void QBarSet::replace(const int index, const QPointF value) | |
367 | { |
|
374 | { | |
368 | if (index >= 0 && index < d_ptr->m_values.count()) { |
|
375 | if (index >= 0 && index < d_ptr->m_values.count()) { | |
369 | d_ptr->replace(index,value); |
|
376 | d_ptr->replace(index,value); | |
370 | emit valueChanged(index); |
|
377 | emit valueChanged(index); | |
371 | } |
|
378 | } | |
372 | } |
|
379 | } | |
373 |
|
380 | |||
374 | /*! |
|
381 | /*! | |
375 | Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF. |
|
382 | Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF. | |
376 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value |
|
383 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value | |
377 | of the QPointF (if appended with QPointF append). |
|
384 | of the QPointF (if appended with QPointF append). | |
378 | If the index is out of bounds QPointF(0, 0.0) is returned. |
|
385 | If the index is out of bounds QPointF(0, 0.0) is returned. | |
379 | */ |
|
386 | */ | |
380 | QPointF QBarSet::at(const int index) const |
|
387 | QPointF QBarSet::at(const int index) const | |
381 | { |
|
388 | { | |
382 | if (index < 0 || index >= d_ptr->m_values.count()) { |
|
389 | if (index < 0 || index >= d_ptr->m_values.count()) { | |
383 | return QPointF(index, 0.0); |
|
390 | return QPointF(index, 0.0); | |
384 | } |
|
391 | } | |
385 |
|
392 | |||
386 | return d_ptr->m_values.at(index); |
|
393 | return d_ptr->m_values.at(index); | |
387 | } |
|
394 | } | |
388 |
|
395 | |||
389 | /*! |
|
396 | /*! | |
390 | Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF. |
|
397 | Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF. | |
391 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value |
|
398 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value | |
392 | of the QPointF (if appended with QPointF append). |
|
399 | of the QPointF (if appended with QPointF append). | |
393 | */ |
|
400 | */ | |
394 | QPointF QBarSet::operator [](const int index) const |
|
401 | QPointF QBarSet::operator [](const int index) const | |
395 | { |
|
402 | { | |
396 | return d_ptr->m_values.at(index); |
|
403 | return d_ptr->m_values.at(index); | |
397 | } |
|
404 | } | |
398 |
|
405 | |||
399 | /*! |
|
406 | /*! | |
400 | Returns count of values in set. |
|
407 | Returns count of values in set. | |
401 | */ |
|
408 | */ | |
402 | int QBarSet::count() const |
|
409 | int QBarSet::count() const | |
403 | { |
|
410 | { | |
404 | return d_ptr->m_values.count(); |
|
411 | return d_ptr->m_values.count(); | |
405 | } |
|
412 | } | |
406 |
|
413 | |||
407 | /*! |
|
414 | /*! | |
408 | Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation. |
|
415 | Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation. | |
409 | */ |
|
416 | */ | |
410 | qreal QBarSet::sum() const |
|
417 | qreal QBarSet::sum() const | |
411 | { |
|
418 | { | |
412 | qreal total(0); |
|
419 | qreal total(0); | |
413 | for (int i=0; i < d_ptr->m_values.count(); i++) { |
|
420 | for (int i=0; i < d_ptr->m_values.count(); i++) { | |
414 | //total += d_ptr->m_values.at(i); |
|
421 | //total += d_ptr->m_values.at(i); | |
415 | total += d_ptr->m_values.at(i).y(); |
|
422 | total += d_ptr->m_values.at(i).y(); | |
416 | } |
|
423 | } | |
417 | return total; |
|
424 | return total; | |
418 | } |
|
425 | } | |
419 |
|
426 | |||
420 | /*! |
|
427 | /*! | |
421 | Sets pen for set. Bars of this set are drawn using \a pen |
|
428 | Sets pen for set. Bars of this set are drawn using \a pen | |
422 | */ |
|
429 | */ | |
423 | void QBarSet::setPen(const QPen &pen) |
|
430 | void QBarSet::setPen(const QPen &pen) | |
424 | { |
|
431 | { | |
425 | if(d_ptr->m_pen!=pen){ |
|
432 | if(d_ptr->m_pen!=pen){ | |
426 | d_ptr->m_pen = pen; |
|
433 | d_ptr->m_pen = pen; | |
427 | emit d_ptr->updatedBars(); |
|
434 | emit d_ptr->updatedBars(); | |
428 | emit penChanged(); |
|
435 | emit penChanged(); | |
429 | } |
|
436 | } | |
430 | } |
|
437 | } | |
431 |
|
438 | |||
432 | /*! |
|
439 | /*! | |
433 | Returns pen of the set. |
|
440 | Returns pen of the set. | |
434 | */ |
|
441 | */ | |
435 | QPen QBarSet::pen() const |
|
442 | QPen QBarSet::pen() const | |
436 | { |
|
443 | { | |
437 | return d_ptr->m_pen; |
|
444 | return d_ptr->m_pen; | |
438 | } |
|
445 | } | |
439 |
|
446 | |||
440 | /*! |
|
447 | /*! | |
441 | Sets brush for the set. Bars of this set are drawn using \a brush |
|
448 | Sets brush for the set. Bars of this set are drawn using \a brush | |
442 | */ |
|
449 | */ | |
443 | void QBarSet::setBrush(const QBrush &brush) |
|
450 | void QBarSet::setBrush(const QBrush &brush) | |
444 | { |
|
451 | { | |
445 | if(d_ptr->m_brush!=brush){ |
|
452 | if(d_ptr->m_brush!=brush){ | |
446 | d_ptr->m_brush = brush; |
|
453 | d_ptr->m_brush = brush; | |
447 | emit d_ptr->updatedBars(); |
|
454 | emit d_ptr->updatedBars(); | |
448 | emit brushChanged(); |
|
455 | emit brushChanged(); | |
449 | } |
|
456 | } | |
450 | } |
|
457 | } | |
451 |
|
458 | |||
452 | /*! |
|
459 | /*! | |
453 | Returns brush of the set. |
|
460 | Returns brush of the set. | |
454 | */ |
|
461 | */ | |
455 | QBrush QBarSet::brush() const |
|
462 | QBrush QBarSet::brush() const | |
456 | { |
|
463 | { | |
457 | return d_ptr->m_brush; |
|
464 | return d_ptr->m_brush; | |
458 | } |
|
465 | } | |
459 |
|
466 | |||
460 | /*! |
|
467 | /*! | |
461 | Sets \a brush of the values that are drawn on top of this barset |
|
468 | Sets \a brush of the values that are drawn on top of this barset | |
462 | */ |
|
469 | */ | |
463 | void QBarSet::setLabelBrush(const QBrush &brush) |
|
470 | void QBarSet::setLabelBrush(const QBrush &brush) | |
464 | { |
|
471 | { | |
465 | if(d_ptr->m_labelBrush!=brush){ |
|
472 | if(d_ptr->m_labelBrush!=brush){ | |
466 | d_ptr->m_labelBrush = brush; |
|
473 | d_ptr->m_labelBrush = brush; | |
467 | emit d_ptr->updatedBars(); |
|
474 | emit d_ptr->updatedBars(); | |
468 | emit labelBrushChanged(); |
|
475 | emit labelBrushChanged(); | |
469 | } |
|
476 | } | |
470 | } |
|
477 | } | |
471 |
|
478 | |||
472 | /*! |
|
479 | /*! | |
473 | Returns brush of the values that are drawn on top of this barset |
|
480 | Returns brush of the values that are drawn on top of this barset | |
474 | */ |
|
481 | */ | |
475 | QBrush QBarSet::labelBrush() const |
|
482 | QBrush QBarSet::labelBrush() const | |
476 | { |
|
483 | { | |
477 | return d_ptr->m_labelBrush; |
|
484 | return d_ptr->m_labelBrush; | |
478 | } |
|
485 | } | |
479 |
|
486 | |||
480 | /*! |
|
487 | /*! | |
481 | Sets the \a font for values that are drawn on top of this barset |
|
488 | Sets the \a font for values that are drawn on top of this barset | |
482 | */ |
|
489 | */ | |
483 | void QBarSet::setLabelFont(const QFont &font) |
|
490 | void QBarSet::setLabelFont(const QFont &font) | |
484 | { |
|
491 | { | |
485 | if(d_ptr->m_labelFont!=font) { |
|
492 | if(d_ptr->m_labelFont!=font) { | |
486 | d_ptr->m_labelFont = font; |
|
493 | d_ptr->m_labelFont = font; | |
487 | emit d_ptr->updatedBars(); |
|
494 | emit d_ptr->updatedBars(); | |
488 | emit labelFontChanged(); |
|
495 | emit labelFontChanged(); | |
489 | } |
|
496 | } | |
490 |
|
497 | |||
491 | } |
|
498 | } | |
492 |
|
499 | |||
493 | /*! |
|
500 | /*! | |
494 | Returns the pen for values that are drawn on top of this barset |
|
501 | Returns the pen for values that are drawn on top of this barset | |
495 | */ |
|
502 | */ | |
496 | QFont QBarSet::labelFont() const |
|
503 | QFont QBarSet::labelFont() const | |
497 | { |
|
504 | { | |
498 | return d_ptr->m_labelFont; |
|
505 | return d_ptr->m_labelFont; | |
499 | } |
|
506 | } | |
500 |
|
507 | |||
501 | /*! |
|
508 | /*! | |
502 | Returns the color of the brush of barset. |
|
509 | Returns the color of the brush of barset. | |
503 | */ |
|
510 | */ | |
504 | QColor QBarSet::color() |
|
511 | QColor QBarSet::color() | |
505 | { |
|
512 | { | |
506 | return brush().color(); |
|
513 | return brush().color(); | |
507 | } |
|
514 | } | |
508 |
|
515 | |||
509 | /*! |
|
516 | /*! | |
510 | Sets the \a color of brush for this barset |
|
517 | Sets the \a color of brush for this barset | |
511 | */ |
|
518 | */ | |
512 | void QBarSet::setColor(QColor color) |
|
519 | void QBarSet::setColor(QColor color) | |
513 | { |
|
520 | { | |
514 | QBrush b = brush(); |
|
521 | QBrush b = brush(); | |
515 | if (b.color() != color) { |
|
522 | if (b.color() != color) { | |
516 | b.setColor(color); |
|
523 | b.setColor(color); | |
517 | setBrush(b); |
|
524 | setBrush(b); | |
518 | emit colorChanged(color); |
|
525 | emit colorChanged(color); | |
519 | } |
|
526 | } | |
520 | } |
|
527 | } | |
521 |
|
528 | |||
522 | /*! |
|
529 | /*! | |
523 | Returns the color of pen of this barset |
|
530 | Returns the color of pen of this barset | |
524 | */ |
|
531 | */ | |
525 | QColor QBarSet::borderColor() |
|
532 | QColor QBarSet::borderColor() | |
526 | { |
|
533 | { | |
527 | return pen().color(); |
|
534 | return pen().color(); | |
528 | } |
|
535 | } | |
529 |
|
536 | |||
530 | /*! |
|
537 | /*! | |
531 | Sets the color of pen for this barset |
|
538 | Sets the color of pen for this barset | |
532 | */ |
|
539 | */ | |
533 | void QBarSet::setBorderColor(QColor color) |
|
540 | void QBarSet::setBorderColor(QColor color) | |
534 | { |
|
541 | { | |
535 | QPen p = pen(); |
|
542 | QPen p = pen(); | |
536 | if (p.color() != color) { |
|
543 | if (p.color() != color) { | |
537 | p.setColor(color); |
|
544 | p.setColor(color); | |
538 | setPen(p); |
|
545 | setPen(p); | |
539 | emit borderColorChanged(color); |
|
546 | emit borderColorChanged(color); | |
540 | } |
|
547 | } | |
541 | } |
|
548 | } | |
542 |
|
549 | |||
543 | /*! |
|
550 | /*! | |
544 | Returns the color of labels of this barset |
|
551 | Returns the color of labels of this barset | |
545 | */ |
|
552 | */ | |
546 | QColor QBarSet::labelColor() |
|
553 | QColor QBarSet::labelColor() | |
547 | { |
|
554 | { | |
548 | return labelBrush().color(); |
|
555 | return labelBrush().color(); | |
549 | } |
|
556 | } | |
550 |
|
557 | |||
551 | /*! |
|
558 | /*! | |
552 | Sets the color of labels for this barset |
|
559 | Sets the color of labels for this barset | |
553 | */ |
|
560 | */ | |
554 | void QBarSet::setLabelColor(QColor color) |
|
561 | void QBarSet::setLabelColor(QColor color) | |
555 | { |
|
562 | { | |
556 | QBrush b = labelBrush(); |
|
563 | QBrush b = labelBrush(); | |
557 | if (b.color() != color) { |
|
564 | if (b.color() != color) { | |
558 | b.setColor(color); |
|
565 | b.setColor(color); | |
559 | setLabelBrush(b); |
|
566 | setLabelBrush(b); | |
560 | emit labelColorChanged(color); |
|
567 | emit labelColorChanged(color); | |
561 | } |
|
568 | } | |
562 | } |
|
569 | } | |
563 |
|
570 | |||
564 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
571 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
565 |
|
572 | |||
566 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), |
|
573 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), | |
567 | q_ptr(parent), |
|
574 | q_ptr(parent), | |
568 | m_label(label) |
|
575 | m_label(label) | |
569 | { |
|
576 | { | |
570 | } |
|
577 | } | |
571 |
|
578 | |||
572 | QBarSetPrivate::~QBarSetPrivate() |
|
579 | QBarSetPrivate::~QBarSetPrivate() | |
573 | { |
|
580 | { | |
574 | } |
|
581 | } | |
575 |
|
582 | |||
576 | void QBarSetPrivate::append(QPointF value) |
|
583 | void QBarSetPrivate::append(QPointF value) | |
577 | { |
|
584 | { | |
578 | m_values.append(value); |
|
585 | m_values.append(value); | |
579 | emit restructuredBars(); |
|
586 | emit restructuredBars(); | |
580 | } |
|
587 | } | |
581 |
|
588 | |||
582 | void QBarSetPrivate::append(QList<QPointF> values) |
|
589 | void QBarSetPrivate::append(QList<QPointF> values) | |
583 | { |
|
590 | { | |
584 | for (int i=0; i<values.count(); i++) { |
|
591 | for (int i=0; i<values.count(); i++) { | |
585 | m_values.append(values.at(i)); |
|
592 | m_values.append(values.at(i)); | |
586 | } |
|
593 | } | |
587 | emit restructuredBars(); |
|
594 | emit restructuredBars(); | |
588 | } |
|
595 | } | |
589 |
|
596 | |||
590 | void QBarSetPrivate::append(QList<qreal> values) |
|
597 | void QBarSetPrivate::append(QList<qreal> values) | |
591 | { |
|
598 | { | |
592 | int index = m_values.count(); |
|
599 | int index = m_values.count(); | |
593 | for (int i=0; i<values.count(); i++) { |
|
600 | for (int i=0; i<values.count(); i++) { | |
594 | m_values.append(QPointF(index,values.at(i))); |
|
601 | m_values.append(QPointF(index,values.at(i))); | |
595 | index++; |
|
602 | index++; | |
596 | } |
|
603 | } | |
597 | emit restructuredBars(); |
|
604 | emit restructuredBars(); | |
598 | } |
|
605 | } | |
599 |
|
606 | |||
600 | void QBarSetPrivate::insert(const int index, const qreal value) |
|
607 | void QBarSetPrivate::insert(const int index, const qreal value) | |
601 | { |
|
608 | { | |
602 | m_values.insert(index, QPointF(index, value)); |
|
609 | m_values.insert(index, QPointF(index, value)); | |
603 | emit restructuredBars(); |
|
610 | emit restructuredBars(); | |
604 | } |
|
611 | } | |
605 |
|
612 | |||
606 | void QBarSetPrivate::insert(const int index, const QPointF value) |
|
613 | void QBarSetPrivate::insert(const int index, const QPointF value) | |
607 | { |
|
614 | { | |
608 | m_values.insert(index, value); |
|
615 | m_values.insert(index, value); | |
609 | emit restructuredBars(); |
|
616 | emit restructuredBars(); | |
610 | } |
|
617 | } | |
611 |
|
618 | |||
612 | int QBarSetPrivate::remove(const int index, const int count) |
|
619 | int QBarSetPrivate::remove(const int index, const int count) | |
613 | { |
|
620 | { | |
614 | int removeCount = count; |
|
621 | int removeCount = count; | |
615 |
|
622 | |||
616 | if ((index <0) || (m_values.count() == 0)) { |
|
623 | if ((index <0) || (m_values.count() == 0)) { | |
617 | // Invalid index or not values in list, remove nothing. |
|
624 | // Invalid index or not values in list, remove nothing. | |
618 | return 0; |
|
625 | return 0; | |
619 | } else if ((index + count) > m_values.count()) { |
|
626 | } else if ((index + count) > m_values.count()) { | |
620 | // Trying to remove more items than list has. Limit amount to be removed. |
|
627 | // Trying to remove more items than list has. Limit amount to be removed. | |
621 | removeCount = m_values.count() - index; |
|
628 | removeCount = m_values.count() - index; | |
622 | } |
|
629 | } | |
623 |
|
630 | |||
624 | int c = 0; |
|
631 | int c = 0; | |
625 | while (c < removeCount) { |
|
632 | while (c < removeCount) { | |
626 | m_values.removeAt(index); |
|
633 | m_values.removeAt(index); | |
627 | c++; |
|
634 | c++; | |
628 | } |
|
635 | } | |
629 | emit restructuredBars(); |
|
636 | emit restructuredBars(); | |
630 | return removeCount; |
|
637 | return removeCount; | |
631 | } |
|
638 | } | |
632 |
|
639 | |||
633 | void QBarSetPrivate::replace(const int index, const qreal value) |
|
640 | void QBarSetPrivate::replace(const int index, const qreal value) | |
634 | { |
|
641 | { | |
635 | m_values.replace(index,QPointF(index,value)); |
|
642 | m_values.replace(index,QPointF(index,value)); | |
636 | emit updatedBars(); |
|
643 | emit updatedBars(); | |
637 | } |
|
644 | } | |
638 |
|
645 | |||
639 | void QBarSetPrivate::replace(const int index, const QPointF value) |
|
646 | void QBarSetPrivate::replace(const int index, const QPointF value) | |
640 | { |
|
647 | { | |
641 | m_values.replace(index,value); |
|
648 | m_values.replace(index,value); | |
642 | emit updatedBars(); |
|
649 | emit updatedBars(); | |
643 | } |
|
650 | } | |
644 |
|
651 | |||
645 | #include "moc_qbarset.cpp" |
|
652 | #include "moc_qbarset.cpp" | |
646 | #include "moc_qbarset_p.cpp" |
|
653 | #include "moc_qbarset_p.cpp" | |
647 |
|
654 | |||
648 | QTCOMMERCIALCHART_END_NAMESPACE |
|
655 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,769 +1,779 | |||||
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 "qpieslice.h" |
|
21 | #include "qpieslice.h" | |
22 | #include "qpieslice_p.h" |
|
22 | #include "qpieslice_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QPieSlice |
|
27 | \class QPieSlice | |
28 | \brief Defines a slice in pie series. |
|
28 | \brief Defines a slice in pie series. | |
29 |
|
29 | |||
30 | This object defines the properties of a single slice in a QPieSeries. |
|
30 | This object defines the properties of a single slice in a QPieSeries. | |
31 |
|
31 | |||
32 | In addition to the obvious value and label properties the user can also control |
|
32 | In addition to the obvious value and label properties the user can also control | |
33 | the visual appearance of a slice. By modifying the visual appearance also means that |
|
33 | the visual appearance of a slice. By modifying the visual appearance also means that | |
34 | the user is overriding the default appearance set by the theme. |
|
34 | the user is overriding the default appearance set by the theme. | |
35 |
|
35 | |||
36 | Note that if the user has customized slices and theme is changed all customizations will be lost. |
|
36 | Note that if the user has customized slices and theme is changed all customizations will be lost. | |
37 |
|
37 | |||
38 | To enable user interaction with the pie some basic signals are provided about clicking and hovering. |
|
38 | To enable user interaction with the pie some basic signals are provided about clicking and hovering. | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
42 | \qmlclass PieSlice QPieSlice |
|
42 | \qmlclass PieSlice QPieSlice | |
43 | PieSlice defines the properties of a single slice in a PieSeries. The element should be used |
|
43 | PieSlice defines the properties of a single slice in a PieSeries. The element should be used | |
44 | as a child for a PieSeries. For example: |
|
44 | as a child for a PieSeries. For example: | |
45 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
45 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
46 |
|
46 | |||
47 | An alternative (dynamic) method for adding slices to a PieSeries is using PieSeries.append |
|
47 | An alternative (dynamic) method for adding slices to a PieSeries is using PieSeries.append | |
48 | method. |
|
48 | method. | |
49 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 4 |
|
49 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 4 | |
50 |
|
50 | |||
51 | In that case you may want to use PieSeries.at or PieSeries.find to access the properties of |
|
51 | In that case you may want to use PieSeries.at or PieSeries.find to access the properties of | |
52 | an individual PieSlice instance. |
|
52 | an individual PieSlice instance. | |
53 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 5 |
|
53 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 5 | |
54 | \sa PieSeries |
|
54 | \sa PieSeries | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \enum QPieSlice::LabelPosition |
|
58 | \enum QPieSlice::LabelPosition | |
59 |
|
59 | |||
60 | This enum describes the position of the slice label. |
|
60 | This enum describes the position of the slice label. | |
61 |
|
61 | |||
62 | \value LabelOutside Label is outside the slice with an arm. |
|
62 | \value LabelOutside Label is outside the slice with an arm. | |
63 | \value LabelInside Label is centered inside the slice. |
|
63 | \value LabelInside Label is centered inside the slice. | |
64 |
|
64 | |||
65 | */ |
|
65 | */ | |
66 |
|
66 | |||
67 | /*! |
|
67 | /*! | |
68 | \property QPieSlice::label |
|
68 | \property QPieSlice::label | |
69 | Label of the slice. |
|
69 | Label of the slice. | |
70 | \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor |
|
70 | \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor | |
71 | */ |
|
71 | */ | |
72 | /*! |
|
72 | /*! | |
73 | \qmlproperty string PieSlice::label |
|
73 | \qmlproperty string PieSlice::label | |
74 | Label (text) of the slice. |
|
74 | Label (text) of the slice. | |
75 | */ |
|
75 | */ | |
76 |
|
76 | |||
77 | /*! |
|
77 | /*! | |
78 | \fn void QPieSlice::labelChanged() |
|
78 | \fn void QPieSlice::labelChanged() | |
79 | This signal emitted when the slice label has been changed. |
|
79 | This signal emitted when the slice label has been changed. | |
80 | \sa label |
|
80 | \sa label | |
81 | */ |
|
81 | */ | |
82 | /*! |
|
82 | /*! | |
83 | \qmlsignal PieSlice::labelChanged() |
|
83 | \qmlsignal PieSlice::labelChanged() | |
84 | This signal emitted when the slice label has been changed. |
|
84 | This signal emitted when the slice label has been changed. | |
85 | \sa label |
|
85 | \sa label | |
86 | */ |
|
86 | */ | |
87 |
|
87 | |||
88 | /*! |
|
88 | /*! | |
89 | \property QPieSlice::value |
|
89 | \property QPieSlice::value | |
90 | Value of the slice. |
|
90 | Value of the slice. | |
91 | Note that if users sets a negative value it is converted to a positive value. |
|
91 | Note that if users sets a negative value it is converted to a positive value. | |
92 | \sa percentage(), QPieSeries::sum() |
|
92 | \sa percentage(), QPieSeries::sum() | |
93 | */ |
|
93 | */ | |
94 | /*! |
|
94 | /*! | |
95 | \qmlproperty real PieSlice::value |
|
95 | \qmlproperty real PieSlice::value | |
96 | Value of the slice. Note that if users sets a negative value it is converted to a positive value. |
|
96 | Value of the slice. Note that if users sets a negative value it is converted to a positive value. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \fn void QPieSlice::valueChanged() |
|
100 | \fn void QPieSlice::valueChanged() | |
101 | This signal is emitted when the slice value changes. |
|
101 | This signal is emitted when the slice value changes. | |
102 | \sa value |
|
102 | \sa value | |
103 | */ |
|
103 | */ | |
104 | /*! |
|
104 | /*! | |
105 | \qmlsignal PieSlice::valueChanged() |
|
105 | \qmlsignal PieSlice::valueChanged() | |
106 | This signal is emitted when the slice value changes. |
|
106 | This signal is emitted when the slice value changes. | |
107 | \sa value |
|
107 | \sa value | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | \property QPieSlice::labelVisible |
|
111 | \property QPieSlice::labelVisible | |
112 | Defines the visibility of slice label. By default the label is not visible. |
|
112 | Defines the visibility of slice label. By default the label is not visible. | |
113 | \sa label, labelBrush, labelFont, labelArmLengthFactor |
|
113 | \sa label, labelBrush, labelFont, labelArmLengthFactor | |
114 | */ |
|
114 | */ | |
115 | /*! |
|
115 | /*! | |
116 | \qmlproperty bool PieSlice::labelVisible |
|
116 | \qmlproperty bool PieSlice::labelVisible | |
117 | Defines the visibility of slice label. By default the label is not visible. |
|
117 | Defines the visibility of slice label. By default the label is not visible. | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \fn void QPieSlice::labelVisibleChanged() |
|
121 | \fn void QPieSlice::labelVisibleChanged() | |
122 | This signal emitted when visibility of the slice label has changed. |
|
122 | This signal emitted when visibility of the slice label has changed. | |
123 | \sa labelVisible |
|
123 | \sa labelVisible | |
124 | */ |
|
124 | */ | |
125 | /*! |
|
125 | /*! | |
126 | \qmlsignal PieSlice::labelVisibleChanged() |
|
126 | \qmlsignal PieSlice::labelVisibleChanged() | |
127 | This signal emitted when visibility of the slice label has changed. |
|
127 | This signal emitted when visibility of the slice label has changed. | |
128 | \sa labelVisible |
|
128 | \sa labelVisible | |
129 | */ |
|
129 | */ | |
130 |
|
130 | |||
131 | /*! |
|
131 | /*! | |
132 | \property QPieSlice::exploded |
|
132 | \property QPieSlice::exploded | |
133 | If set to true the slice is "exploded" away from the pie. |
|
133 | If set to true the slice is "exploded" away from the pie. | |
134 | \sa explodeDistanceFactor |
|
134 | \sa explodeDistanceFactor | |
135 | */ |
|
135 | */ | |
136 | /*! |
|
136 | /*! | |
137 | \qmlproperty bool PieSlice::exploded |
|
137 | \qmlproperty bool PieSlice::exploded | |
138 | If set to true the slice is "exploded" away from the pie. |
|
138 | If set to true the slice is "exploded" away from the pie. | |
139 | \sa explodeDistanceFactor |
|
139 | \sa explodeDistanceFactor | |
140 | */ |
|
140 | */ | |
141 |
|
141 | |||
142 | /*! |
|
142 | /*! | |
143 | \property QPieSlice::pen |
|
143 | \property QPieSlice::pen | |
144 | Pen used to draw the slice border. |
|
144 | Pen used to draw the slice border. | |
145 | */ |
|
145 | */ | |
146 |
|
146 | |||
147 | /*! |
|
147 | /*! | |
148 | \fn void QPieSlice::penChanged() |
|
148 | \fn void QPieSlice::penChanged() | |
149 | This signal is emitted when the pen of the slice has changed. |
|
149 | This signal is emitted when the pen of the slice has changed. | |
150 | \sa pen |
|
150 | \sa pen | |
151 | */ |
|
151 | */ | |
152 |
|
152 | |||
153 | /*! |
|
153 | /*! | |
154 | \property QPieSlice::borderColor |
|
154 | \property QPieSlice::borderColor | |
155 | Color used to draw the slice border. |
|
155 | Color used to draw the slice border. | |
156 | This is a convenience property for modifying the slice pen. |
|
156 | This is a convenience property for modifying the slice pen. | |
157 | \sa pen, borderWidth |
|
157 | \sa pen, borderWidth | |
158 | */ |
|
158 | */ | |
159 | /*! |
|
159 | /*! | |
160 | \qmlproperty color PieSlice::borderColor |
|
160 | \qmlproperty color PieSlice::borderColor | |
161 | Color used to draw the slice border (pen color). |
|
161 | Color used to draw the slice border (pen color). | |
162 | \sa borderWidth |
|
162 | \sa borderWidth | |
163 | */ |
|
163 | */ | |
164 |
|
164 | |||
165 | /*! |
|
165 | /*! | |
166 | \fn void QPieSlice::borderColorChanged() |
|
166 | \fn void QPieSlice::borderColorChanged() | |
167 | This signal is emitted when slice border color changes. |
|
167 | This signal is emitted when slice border color changes. | |
168 | \sa pen, borderColor |
|
168 | \sa pen, borderColor | |
169 | */ |
|
169 | */ | |
170 | /*! |
|
170 | /*! | |
171 | \qmlsignal PieSlice::borderColorChanged() |
|
171 | \qmlsignal PieSlice::borderColorChanged() | |
172 | This signal is emitted when slice border color changes. |
|
172 | This signal is emitted when slice border color changes. | |
173 | \sa borderColor |
|
173 | \sa borderColor | |
174 | */ |
|
174 | */ | |
175 |
|
175 | |||
176 | /*! |
|
176 | /*! | |
177 | \property QPieSlice::borderWidth |
|
177 | \property QPieSlice::borderWidth | |
178 | Width of the slice border. |
|
178 | Width of the slice border. | |
179 | This is a convenience property for modifying the slice pen. |
|
179 | This is a convenience property for modifying the slice pen. | |
180 | \sa pen, borderColor |
|
180 | \sa pen, borderColor | |
181 | */ |
|
181 | */ | |
182 | /*! |
|
182 | /*! | |
183 | \qmlproperty int PieSlice::borderWidth |
|
183 | \qmlproperty int PieSlice::borderWidth | |
184 | Width of the slice border. |
|
184 | Width of the slice border. | |
185 | This is a convenience property for modifying the slice pen. |
|
185 | This is a convenience property for modifying the slice pen. | |
186 | \sa borderColor |
|
186 | \sa borderColor | |
187 | */ |
|
187 | */ | |
188 |
|
188 | |||
189 | /*! |
|
189 | /*! | |
190 | \fn void QPieSlice::borderWidthChanged() |
|
190 | \fn void QPieSlice::borderWidthChanged() | |
191 | This signal is emitted when slice border width changes. |
|
191 | This signal is emitted when slice border width changes. | |
192 | \sa pen, borderWidth |
|
192 | \sa pen, borderWidth | |
193 | */ |
|
193 | */ | |
194 | /*! |
|
194 | /*! | |
195 | \qmlsignal PieSlice::borderWidthChanged() |
|
195 | \qmlsignal PieSlice::borderWidthChanged() | |
196 | This signal is emitted when slice border width changes. |
|
196 | This signal is emitted when slice border width changes. | |
197 | \sa borderWidth |
|
197 | \sa borderWidth | |
198 | */ |
|
198 | */ | |
199 |
|
199 | |||
200 | /*! |
|
200 | /*! | |
201 | \property QPieSlice::brush |
|
201 | \property QPieSlice::brush | |
202 | Brush used to draw the slice. |
|
202 | Brush used to draw the slice. | |
203 | */ |
|
203 | */ | |
204 |
|
204 | |||
205 | /*! |
|
205 | /*! | |
206 | \fn void QPieSlice::brushChanged() |
|
206 | \fn void QPieSlice::brushChanged() | |
207 | This signal is emitted when the brush of the slice has changed. |
|
207 | This signal is emitted when the brush of the slice has changed. | |
208 | \sa brush |
|
208 | \sa brush | |
209 | */ |
|
209 | */ | |
210 |
|
210 | |||
211 | /*! |
|
211 | /*! | |
212 | \property QPieSlice::color |
|
212 | \property QPieSlice::color | |
213 | Fill (brush) color of the slice. |
|
213 | Fill (brush) color of the slice. | |
214 | This is a convenience property for modifying the slice brush. |
|
214 | This is a convenience property for modifying the slice brush. | |
215 | \sa brush |
|
215 | \sa brush | |
216 | */ |
|
216 | */ | |
217 | /*! |
|
217 | /*! | |
218 | \qmlproperty color PieSlice::color |
|
218 | \qmlproperty color PieSlice::color | |
219 | Fill (brush) color of the slice. |
|
219 | Fill (brush) color of the slice. | |
220 | */ |
|
220 | */ | |
221 |
|
221 | |||
222 | /*! |
|
222 | /*! | |
223 | \fn void QPieSlice::colorChanged() |
|
223 | \fn void QPieSlice::colorChanged() | |
224 | This signal is emitted when slice color changes. |
|
224 | This signal is emitted when slice color changes. | |
225 | \sa brush |
|
225 | \sa brush | |
226 | */ |
|
226 | */ | |
227 | /*! |
|
227 | /*! | |
228 | \qmlsignal PieSlice::colorChanged() |
|
228 | \qmlsignal PieSlice::colorChanged() | |
229 | This signal is emitted when slice color changes. |
|
229 | This signal is emitted when slice color changes. | |
230 | */ |
|
230 | */ | |
231 |
|
231 | |||
232 | /*! |
|
232 | /*! | |
233 | \property QPieSlice::labelBrush |
|
233 | \property QPieSlice::labelBrush | |
234 | Brush used to draw label and label arm of the slice. |
|
234 | Brush used to draw label and label arm of the slice. | |
235 | \sa label, labelVisible, labelFont, labelArmLengthFactor |
|
235 | \sa label, labelVisible, labelFont, labelArmLengthFactor | |
236 | */ |
|
236 | */ | |
237 |
|
237 | |||
238 | /*! |
|
238 | /*! | |
239 | \fn void QPieSlice::labelBrushChanged() |
|
239 | \fn void QPieSlice::labelBrushChanged() | |
240 | This signal is emitted when the label pen of the slice has changed. |
|
240 | This signal is emitted when the label pen of the slice has changed. | |
241 | \sa labelBrush |
|
241 | \sa labelBrush | |
242 | */ |
|
242 | */ | |
243 |
|
243 | |||
244 | /*! |
|
244 | /*! | |
245 | \property QPieSlice::labelColor |
|
245 | \property QPieSlice::labelColor | |
246 | Color used to draw the slice label. |
|
246 | Color used to draw the slice label. | |
247 | This is a convenience property for modifying the slice label brush. |
|
247 | This is a convenience property for modifying the slice label brush. | |
248 | \sa labelBrush |
|
248 | \sa labelBrush | |
249 | */ |
|
249 | */ | |
250 | /*! |
|
250 | /*! | |
251 | \qmlproperty color PieSlice::labelColor |
|
251 | \qmlproperty color PieSlice::labelColor | |
252 | Color used to draw the slice label. |
|
252 | Color used to draw the slice label. | |
253 | */ |
|
253 | */ | |
254 |
|
254 | |||
255 | /*! |
|
255 | /*! | |
256 | \fn void QPieSlice::labelColorChanged() |
|
256 | \fn void QPieSlice::labelColorChanged() | |
257 | This signal is emitted when slice label color changes. |
|
257 | This signal is emitted when slice label color changes. | |
258 | \sa labelColor |
|
258 | \sa labelColor | |
259 | */ |
|
259 | */ | |
260 | /*! |
|
260 | /*! | |
261 | \qmlsignal PieSlice::labelColorChanged() |
|
261 | \qmlsignal PieSlice::labelColorChanged() | |
262 | This signal is emitted when slice label color changes. |
|
262 | This signal is emitted when slice label color changes. | |
263 | \sa labelColor |
|
263 | \sa labelColor | |
264 | */ |
|
264 | */ | |
265 |
|
265 | |||
266 | /*! |
|
266 | /*! | |
267 | \property QPieSlice::labelFont |
|
267 | \property QPieSlice::labelFont | |
268 | Font used for drawing label text. |
|
268 | Font used for drawing label text. | |
269 | \sa label, labelVisible, labelArmLengthFactor |
|
269 | \sa label, labelVisible, labelArmLengthFactor | |
270 | */ |
|
270 | */ | |
271 |
|
271 | |||
272 | /*! |
|
272 | /*! | |
273 | \fn void QPieSlice::labelFontChanged() |
|
273 | \fn void QPieSlice::labelFontChanged() | |
274 | This signal is emitted when the label font of the slice has changed. |
|
274 | This signal is emitted when the label font of the slice has changed. | |
275 | \sa labelFont |
|
275 | \sa labelFont | |
276 | */ |
|
276 | */ | |
277 |
|
277 | |||
278 | /*! |
|
278 | /*! | |
|
279 | \qmlproperty Font PieSlice::labelFont | |||
|
280 | ||||
|
281 | Defines the font used for slice label. | |||
|
282 | ||||
|
283 | See the \l {Font} {QML Font Element} for detailed documentation. | |||
|
284 | ||||
|
285 | \sa labelVisible, labelPosition | |||
|
286 | */ | |||
|
287 | ||||
|
288 | /*! | |||
279 | \property QPieSlice::labelPosition |
|
289 | \property QPieSlice::labelPosition | |
280 | Position of the slice label. |
|
290 | Position of the slice label. | |
281 | \sa label, labelVisible |
|
291 | \sa label, labelVisible | |
282 | */ |
|
292 | */ | |
283 | /*! |
|
293 | /*! | |
284 | \qmlproperty LabelPosition PieSlice::labelPosition |
|
294 | \qmlproperty LabelPosition PieSlice::labelPosition | |
285 | Position of the slice label. One of PieSlice.LabelOutside or PieSlice.LabelInside. |
|
295 | Position of the slice label. One of PieSlice.LabelOutside or PieSlice.LabelInside. | |
286 | \sa labelVisible |
|
296 | \sa labelVisible | |
287 | */ |
|
297 | */ | |
288 |
|
298 | |||
289 | /*! |
|
299 | /*! | |
290 | \property QPieSlice::labelArmLengthFactor |
|
300 | \property QPieSlice::labelArmLengthFactor | |
291 | Defines the length of the label arm. |
|
301 | Defines the length of the label arm. | |
292 | The factor is relative to pie radius. For example: |
|
302 | The factor is relative to pie radius. For example: | |
293 | 1.0 means the length is the same as the radius. |
|
303 | 1.0 means the length is the same as the radius. | |
294 | 0.5 means the length is half of the radius. |
|
304 | 0.5 means the length is half of the radius. | |
295 | By default the arm length is 0.15 |
|
305 | By default the arm length is 0.15 | |
296 | \sa label, labelVisible, labelBrush, labelFont |
|
306 | \sa label, labelVisible, labelBrush, labelFont | |
297 | */ |
|
307 | */ | |
298 | /*! |
|
308 | /*! | |
299 | \qmlproperty real PieSlice::labelArmLengthFactor |
|
309 | \qmlproperty real PieSlice::labelArmLengthFactor | |
300 | Defines the length of the label arm. |
|
310 | Defines the length of the label arm. | |
301 | The factor is relative to pie radius. For example: |
|
311 | The factor is relative to pie radius. For example: | |
302 | 1.0 means the length is the same as the radius. |
|
312 | 1.0 means the length is the same as the radius. | |
303 | 0.5 means the length is half of the radius. |
|
313 | 0.5 means the length is half of the radius. | |
304 | By default the arm length is 0.15 |
|
314 | By default the arm length is 0.15 | |
305 | \sa labelVisible |
|
315 | \sa labelVisible | |
306 | */ |
|
316 | */ | |
307 |
|
317 | |||
308 | /*! |
|
318 | /*! | |
309 | \property QPieSlice::explodeDistanceFactor |
|
319 | \property QPieSlice::explodeDistanceFactor | |
310 | When the slice is exploded this factor defines how far the slice is exploded away from the pie. |
|
320 | When the slice is exploded this factor defines how far the slice is exploded away from the pie. | |
311 | The factor is relative to pie radius. For example: |
|
321 | The factor is relative to pie radius. For example: | |
312 | 1.0 means the distance is the same as the radius. |
|
322 | 1.0 means the distance is the same as the radius. | |
313 | 0.5 means the distance is half of the radius. |
|
323 | 0.5 means the distance is half of the radius. | |
314 | By default the distance is is 0.15 |
|
324 | By default the distance is is 0.15 | |
315 | \sa exploded |
|
325 | \sa exploded | |
316 | */ |
|
326 | */ | |
317 | /*! |
|
327 | /*! | |
318 | \qmlproperty real PieSlice::explodeDistanceFactor |
|
328 | \qmlproperty real PieSlice::explodeDistanceFactor | |
319 | When the slice is exploded this factor defines how far the slice is exploded away from the pie. |
|
329 | When the slice is exploded this factor defines how far the slice is exploded away from the pie. | |
320 | The factor is relative to pie radius. For example: |
|
330 | The factor is relative to pie radius. For example: | |
321 | 1.0 means the distance is the same as the radius. |
|
331 | 1.0 means the distance is the same as the radius. | |
322 | 0.5 means the distance is half of the radius. |
|
332 | 0.5 means the distance is half of the radius. | |
323 | By default the distance is is 0.15 |
|
333 | By default the distance is is 0.15 | |
324 | \sa exploded |
|
334 | \sa exploded | |
325 | */ |
|
335 | */ | |
326 |
|
336 | |||
327 | /*! |
|
337 | /*! | |
328 | \property QPieSlice::percentage |
|
338 | \property QPieSlice::percentage | |
329 | Percentage of the slice compared to the sum of all slices in the series. |
|
339 | Percentage of the slice compared to the sum of all slices in the series. | |
330 | The actual value ranges from 0.0 to 1.0. |
|
340 | The actual value ranges from 0.0 to 1.0. | |
331 | Updated automatically once the slice is added to the series. |
|
341 | Updated automatically once the slice is added to the series. | |
332 | \sa value, QPieSeries::sum |
|
342 | \sa value, QPieSeries::sum | |
333 | */ |
|
343 | */ | |
334 | /*! |
|
344 | /*! | |
335 | \qmlproperty real PieSlice::percentage |
|
345 | \qmlproperty real PieSlice::percentage | |
336 | Percentage of the slice compared to the sum of all slices in the series. |
|
346 | Percentage of the slice compared to the sum of all slices in the series. | |
337 | The actual value ranges from 0.0 to 1.0. |
|
347 | The actual value ranges from 0.0 to 1.0. | |
338 | Updated automatically once the slice is added to the series. |
|
348 | Updated automatically once the slice is added to the series. | |
339 | */ |
|
349 | */ | |
340 |
|
350 | |||
341 | /*! |
|
351 | /*! | |
342 | \fn void QPieSlice::percentageChanged() |
|
352 | \fn void QPieSlice::percentageChanged() | |
343 | This signal is emitted when the percentage of the slice has changed. |
|
353 | This signal is emitted when the percentage of the slice has changed. | |
344 | \sa percentage |
|
354 | \sa percentage | |
345 | */ |
|
355 | */ | |
346 | /*! |
|
356 | /*! | |
347 | \qmlsignal void PieSlice::percentageChanged() |
|
357 | \qmlsignal void PieSlice::percentageChanged() | |
348 | This signal is emitted when the percentage of the slice has changed. |
|
358 | This signal is emitted when the percentage of the slice has changed. | |
349 | \sa percentage |
|
359 | \sa percentage | |
350 | */ |
|
360 | */ | |
351 |
|
361 | |||
352 | /*! |
|
362 | /*! | |
353 | \property QPieSlice::startAngle |
|
363 | \property QPieSlice::startAngle | |
354 | Defines the starting angle of this slice in the series it belongs to. |
|
364 | Defines the starting angle of this slice in the series it belongs to. | |
355 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
365 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
356 | Updated automatically once the slice is added to the series. |
|
366 | Updated automatically once the slice is added to the series. | |
357 | */ |
|
367 | */ | |
358 | /*! |
|
368 | /*! | |
359 | \qmlproperty real PieSlice::startAngle |
|
369 | \qmlproperty real PieSlice::startAngle | |
360 | Defines the starting angle of this slice in the series it belongs to. |
|
370 | Defines the starting angle of this slice in the series it belongs to. | |
361 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
371 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
362 | Updated automatically once the slice is added to the series. |
|
372 | Updated automatically once the slice is added to the series. | |
363 | */ |
|
373 | */ | |
364 |
|
374 | |||
365 | /*! |
|
375 | /*! | |
366 | \fn void QPieSlice::startAngleChanged() |
|
376 | \fn void QPieSlice::startAngleChanged() | |
367 | This signal is emitted when the starting angle f the slice has changed. |
|
377 | This signal is emitted when the starting angle f the slice has changed. | |
368 | \sa startAngle |
|
378 | \sa startAngle | |
369 | */ |
|
379 | */ | |
370 | /*! |
|
380 | /*! | |
371 | \qmlsignal PieSlice::startAngleChanged() |
|
381 | \qmlsignal PieSlice::startAngleChanged() | |
372 | This signal is emitted when the starting angle f the slice has changed. |
|
382 | This signal is emitted when the starting angle f the slice has changed. | |
373 | \sa startAngle |
|
383 | \sa startAngle | |
374 | */ |
|
384 | */ | |
375 |
|
385 | |||
376 | /*! |
|
386 | /*! | |
377 | \property QPieSlice::angleSpan |
|
387 | \property QPieSlice::angleSpan | |
378 | Span of the slice in degrees. |
|
388 | Span of the slice in degrees. | |
379 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
389 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
380 | Updated automatically once the slice is added to the series. |
|
390 | Updated automatically once the slice is added to the series. | |
381 | */ |
|
391 | */ | |
382 | /*! |
|
392 | /*! | |
383 | \qmlproperty real PieSlice::angleSpan |
|
393 | \qmlproperty real PieSlice::angleSpan | |
384 | Span of the slice in degrees. |
|
394 | Span of the slice in degrees. | |
385 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
395 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
386 | Updated automatically once the slice is added to the series. |
|
396 | Updated automatically once the slice is added to the series. | |
387 | */ |
|
397 | */ | |
388 |
|
398 | |||
389 | /*! |
|
399 | /*! | |
390 | \fn void QPieSlice::angleSpanChanged() |
|
400 | \fn void QPieSlice::angleSpanChanged() | |
391 | This signal is emitted when the angle span of the slice has changed. |
|
401 | This signal is emitted when the angle span of the slice has changed. | |
392 | \sa angleSpan |
|
402 | \sa angleSpan | |
393 | */ |
|
403 | */ | |
394 | /*! |
|
404 | /*! | |
395 | \qmlsignal PieSlice::angleSpanChanged() |
|
405 | \qmlsignal PieSlice::angleSpanChanged() | |
396 | This signal is emitted when the angle span of the slice has changed. |
|
406 | This signal is emitted when the angle span of the slice has changed. | |
397 | \sa angleSpan |
|
407 | \sa angleSpan | |
398 | */ |
|
408 | */ | |
399 |
|
409 | |||
400 | /*! |
|
410 | /*! | |
401 | \fn void QPieSlice::clicked() |
|
411 | \fn void QPieSlice::clicked() | |
402 | This signal is emitted when user has clicked the slice. |
|
412 | This signal is emitted when user has clicked the slice. | |
403 | \sa QPieSeries::clicked() |
|
413 | \sa QPieSeries::clicked() | |
404 | */ |
|
414 | */ | |
405 | /*! |
|
415 | /*! | |
406 | \qmlsignal PieSlice::onClicked() |
|
416 | \qmlsignal PieSlice::onClicked() | |
407 | This signal is emitted when user has clicked the slice. |
|
417 | This signal is emitted when user has clicked the slice. | |
408 | */ |
|
418 | */ | |
409 |
|
419 | |||
410 | /*! |
|
420 | /*! | |
411 | \fn void QPieSlice::hovered(bool state) |
|
421 | \fn void QPieSlice::hovered(bool state) | |
412 | This signal is emitted when user has hovered over or away from the slice. |
|
422 | This signal is emitted when user has hovered over or away from the slice. | |
413 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. |
|
423 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. | |
414 | \sa QPieSeries::hovered() |
|
424 | \sa QPieSeries::hovered() | |
415 | */ |
|
425 | */ | |
416 | /*! |
|
426 | /*! | |
417 | \qmlsignal PieSlice::onHovered(bool state) |
|
427 | \qmlsignal PieSlice::onHovered(bool state) | |
418 | This signal is emitted when user has hovered over or away from the slice. |
|
428 | This signal is emitted when user has hovered over or away from the slice. | |
419 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. |
|
429 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. | |
420 | */ |
|
430 | */ | |
421 |
|
431 | |||
422 | /*! |
|
432 | /*! | |
423 | Constructs an empty slice with a \a parent. |
|
433 | Constructs an empty slice with a \a parent. | |
424 | \sa QPieSeries::append(), QPieSeries::insert() |
|
434 | \sa QPieSeries::append(), QPieSeries::insert() | |
425 | */ |
|
435 | */ | |
426 | QPieSlice::QPieSlice(QObject *parent) |
|
436 | QPieSlice::QPieSlice(QObject *parent) | |
427 | :QObject(parent), |
|
437 | :QObject(parent), | |
428 | d_ptr(new QPieSlicePrivate(this)) |
|
438 | d_ptr(new QPieSlicePrivate(this)) | |
429 | { |
|
439 | { | |
430 |
|
440 | |||
431 | } |
|
441 | } | |
432 |
|
442 | |||
433 | /*! |
|
443 | /*! | |
434 | Constructs an empty slice with given \a value, \a label and a \a parent. |
|
444 | Constructs an empty slice with given \a value, \a label and a \a parent. | |
435 | \sa QPieSeries::append(), QPieSeries::insert() |
|
445 | \sa QPieSeries::append(), QPieSeries::insert() | |
436 | */ |
|
446 | */ | |
437 | QPieSlice::QPieSlice(QString label, qreal value, QObject *parent) |
|
447 | QPieSlice::QPieSlice(QString label, qreal value, QObject *parent) | |
438 | :QObject(parent), |
|
448 | :QObject(parent), | |
439 | d_ptr(new QPieSlicePrivate(this)) |
|
449 | d_ptr(new QPieSlicePrivate(this)) | |
440 | { |
|
450 | { | |
441 | setValue(value); |
|
451 | setValue(value); | |
442 | setLabel(label); |
|
452 | setLabel(label); | |
443 | } |
|
453 | } | |
444 |
|
454 | |||
445 | /*! |
|
455 | /*! | |
446 | Destroys the slice. |
|
456 | Destroys the slice. | |
447 | User should not delete the slice if it has been added to the series. |
|
457 | User should not delete the slice if it has been added to the series. | |
448 | */ |
|
458 | */ | |
449 | QPieSlice::~QPieSlice() |
|
459 | QPieSlice::~QPieSlice() | |
450 | { |
|
460 | { | |
451 |
|
461 | |||
452 | } |
|
462 | } | |
453 |
|
463 | |||
454 | void QPieSlice::setLabel(QString label) |
|
464 | void QPieSlice::setLabel(QString label) | |
455 | { |
|
465 | { | |
456 | if (d_ptr->m_data.m_labelText != label) { |
|
466 | if (d_ptr->m_data.m_labelText != label) { | |
457 | d_ptr->m_data.m_labelText = label; |
|
467 | d_ptr->m_data.m_labelText = label; | |
458 | emit labelChanged(); |
|
468 | emit labelChanged(); | |
459 | } |
|
469 | } | |
460 | } |
|
470 | } | |
461 |
|
471 | |||
462 | QString QPieSlice::label() const |
|
472 | QString QPieSlice::label() const | |
463 | { |
|
473 | { | |
464 | return d_ptr->m_data.m_labelText; |
|
474 | return d_ptr->m_data.m_labelText; | |
465 | } |
|
475 | } | |
466 |
|
476 | |||
467 | void QPieSlice::setValue(qreal value) |
|
477 | void QPieSlice::setValue(qreal value) | |
468 | { |
|
478 | { | |
469 | value = qAbs(value); // negative values not allowed |
|
479 | value = qAbs(value); // negative values not allowed | |
470 | if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) { |
|
480 | if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) { | |
471 | d_ptr->m_data.m_value = value; |
|
481 | d_ptr->m_data.m_value = value; | |
472 | emit valueChanged(); |
|
482 | emit valueChanged(); | |
473 | } |
|
483 | } | |
474 | } |
|
484 | } | |
475 |
|
485 | |||
476 | qreal QPieSlice::value() const |
|
486 | qreal QPieSlice::value() const | |
477 | { |
|
487 | { | |
478 | return d_ptr->m_data.m_value; |
|
488 | return d_ptr->m_data.m_value; | |
479 | } |
|
489 | } | |
480 |
|
490 | |||
481 | void QPieSlice::setLabelVisible(bool visible) |
|
491 | void QPieSlice::setLabelVisible(bool visible) | |
482 | { |
|
492 | { | |
483 | if (d_ptr->m_data.m_isLabelVisible != visible) { |
|
493 | if (d_ptr->m_data.m_isLabelVisible != visible) { | |
484 | d_ptr->m_data.m_isLabelVisible = visible; |
|
494 | d_ptr->m_data.m_isLabelVisible = visible; | |
485 | emit labelVisibleChanged(); |
|
495 | emit labelVisibleChanged(); | |
486 | } |
|
496 | } | |
487 | } |
|
497 | } | |
488 |
|
498 | |||
489 | bool QPieSlice::isLabelVisible() const |
|
499 | bool QPieSlice::isLabelVisible() const | |
490 | { |
|
500 | { | |
491 | return d_ptr->m_data.m_isLabelVisible; |
|
501 | return d_ptr->m_data.m_isLabelVisible; | |
492 | } |
|
502 | } | |
493 |
|
503 | |||
494 | void QPieSlice::setExploded(bool exploded) |
|
504 | void QPieSlice::setExploded(bool exploded) | |
495 | { |
|
505 | { | |
496 | if (d_ptr->m_data.m_isExploded != exploded) { |
|
506 | if (d_ptr->m_data.m_isExploded != exploded) { | |
497 | d_ptr->m_data.m_isExploded = exploded; |
|
507 | d_ptr->m_data.m_isExploded = exploded; | |
498 | emit d_ptr->explodedChanged(); |
|
508 | emit d_ptr->explodedChanged(); | |
499 | } |
|
509 | } | |
500 | } |
|
510 | } | |
501 |
|
511 | |||
502 | QPieSlice::LabelPosition QPieSlice::labelPosition() |
|
512 | QPieSlice::LabelPosition QPieSlice::labelPosition() | |
503 | { |
|
513 | { | |
504 | return d_ptr->m_data.m_labelPosition; |
|
514 | return d_ptr->m_data.m_labelPosition; | |
505 | } |
|
515 | } | |
506 |
|
516 | |||
507 | void QPieSlice::setLabelPosition(LabelPosition position) |
|
517 | void QPieSlice::setLabelPosition(LabelPosition position) | |
508 | { |
|
518 | { | |
509 | if (d_ptr->m_data.m_labelPosition != position) { |
|
519 | if (d_ptr->m_data.m_labelPosition != position) { | |
510 | d_ptr->m_data.m_labelPosition = position; |
|
520 | d_ptr->m_data.m_labelPosition = position; | |
511 | emit d_ptr->labelPositionChanged(); |
|
521 | emit d_ptr->labelPositionChanged(); | |
512 | } |
|
522 | } | |
513 | } |
|
523 | } | |
514 |
|
524 | |||
515 | bool QPieSlice::isExploded() const |
|
525 | bool QPieSlice::isExploded() const | |
516 | { |
|
526 | { | |
517 | return d_ptr->m_data.m_isExploded; |
|
527 | return d_ptr->m_data.m_isExploded; | |
518 | } |
|
528 | } | |
519 |
|
529 | |||
520 | void QPieSlice::setPen(const QPen &pen) |
|
530 | void QPieSlice::setPen(const QPen &pen) | |
521 | { |
|
531 | { | |
522 | d_ptr->setPen(pen, false); |
|
532 | d_ptr->setPen(pen, false); | |
523 | } |
|
533 | } | |
524 |
|
534 | |||
525 | QPen QPieSlice::pen() const |
|
535 | QPen QPieSlice::pen() const | |
526 | { |
|
536 | { | |
527 | return d_ptr->m_data.m_slicePen; |
|
537 | return d_ptr->m_data.m_slicePen; | |
528 | } |
|
538 | } | |
529 |
|
539 | |||
530 | QColor QPieSlice::borderColor() |
|
540 | QColor QPieSlice::borderColor() | |
531 | { |
|
541 | { | |
532 | return pen().color(); |
|
542 | return pen().color(); | |
533 | } |
|
543 | } | |
534 |
|
544 | |||
535 | void QPieSlice::setBorderColor(QColor color) |
|
545 | void QPieSlice::setBorderColor(QColor color) | |
536 | { |
|
546 | { | |
537 | QPen p = pen(); |
|
547 | QPen p = pen(); | |
538 | if (color != p.color()) { |
|
548 | if (color != p.color()) { | |
539 | p.setColor(color); |
|
549 | p.setColor(color); | |
540 | setPen(p); |
|
550 | setPen(p); | |
541 | } |
|
551 | } | |
542 | } |
|
552 | } | |
543 |
|
553 | |||
544 | int QPieSlice::borderWidth() |
|
554 | int QPieSlice::borderWidth() | |
545 | { |
|
555 | { | |
546 | return pen().width(); |
|
556 | return pen().width(); | |
547 | } |
|
557 | } | |
548 |
|
558 | |||
549 | void QPieSlice::setBorderWidth(int width) |
|
559 | void QPieSlice::setBorderWidth(int width) | |
550 | { |
|
560 | { | |
551 | QPen p = pen(); |
|
561 | QPen p = pen(); | |
552 | if (width != p.width()) { |
|
562 | if (width != p.width()) { | |
553 | p.setWidth(width); |
|
563 | p.setWidth(width); | |
554 | setPen(p); |
|
564 | setPen(p); | |
555 | } |
|
565 | } | |
556 | } |
|
566 | } | |
557 |
|
567 | |||
558 | void QPieSlice::setBrush(const QBrush &brush) |
|
568 | void QPieSlice::setBrush(const QBrush &brush) | |
559 | { |
|
569 | { | |
560 | d_ptr->setBrush(brush, false); |
|
570 | d_ptr->setBrush(brush, false); | |
561 | } |
|
571 | } | |
562 |
|
572 | |||
563 | QBrush QPieSlice::brush() const |
|
573 | QBrush QPieSlice::brush() const | |
564 | { |
|
574 | { | |
565 | return d_ptr->m_data.m_sliceBrush; |
|
575 | return d_ptr->m_data.m_sliceBrush; | |
566 | } |
|
576 | } | |
567 |
|
577 | |||
568 | QColor QPieSlice::color() |
|
578 | QColor QPieSlice::color() | |
569 | { |
|
579 | { | |
570 | return brush().color(); |
|
580 | return brush().color(); | |
571 | } |
|
581 | } | |
572 |
|
582 | |||
573 | void QPieSlice::setColor(QColor color) |
|
583 | void QPieSlice::setColor(QColor color) | |
574 | { |
|
584 | { | |
575 | QBrush b = brush(); |
|
585 | QBrush b = brush(); | |
576 | if (color != b.color()) { |
|
586 | if (color != b.color()) { | |
577 | b.setColor(color); |
|
587 | b.setColor(color); | |
578 | setBrush(b); |
|
588 | setBrush(b); | |
579 | } |
|
589 | } | |
580 | } |
|
590 | } | |
581 |
|
591 | |||
582 | void QPieSlice::setLabelBrush(const QBrush &brush) |
|
592 | void QPieSlice::setLabelBrush(const QBrush &brush) | |
583 | { |
|
593 | { | |
584 | d_ptr->setLabelBrush(brush, false); |
|
594 | d_ptr->setLabelBrush(brush, false); | |
585 | } |
|
595 | } | |
586 |
|
596 | |||
587 | QBrush QPieSlice::labelBrush() const |
|
597 | QBrush QPieSlice::labelBrush() const | |
588 | { |
|
598 | { | |
589 | return d_ptr->m_data.m_labelBrush; |
|
599 | return d_ptr->m_data.m_labelBrush; | |
590 | } |
|
600 | } | |
591 |
|
601 | |||
592 | QColor QPieSlice::labelColor() |
|
602 | QColor QPieSlice::labelColor() | |
593 | { |
|
603 | { | |
594 | return labelBrush().color(); |
|
604 | return labelBrush().color(); | |
595 | } |
|
605 | } | |
596 |
|
606 | |||
597 | void QPieSlice::setLabelColor(QColor color) |
|
607 | void QPieSlice::setLabelColor(QColor color) | |
598 | { |
|
608 | { | |
599 | QBrush b = labelBrush(); |
|
609 | QBrush b = labelBrush(); | |
600 | if (color != b.color()) { |
|
610 | if (color != b.color()) { | |
601 | b.setColor(color); |
|
611 | b.setColor(color); | |
602 | setLabelBrush(b); |
|
612 | setLabelBrush(b); | |
603 | } |
|
613 | } | |
604 | } |
|
614 | } | |
605 |
|
615 | |||
606 | void QPieSlice::setLabelFont(const QFont &font) |
|
616 | void QPieSlice::setLabelFont(const QFont &font) | |
607 | { |
|
617 | { | |
608 | d_ptr->setLabelFont(font, false); |
|
618 | d_ptr->setLabelFont(font, false); | |
609 | } |
|
619 | } | |
610 |
|
620 | |||
611 | QFont QPieSlice::labelFont() const |
|
621 | QFont QPieSlice::labelFont() const | |
612 | { |
|
622 | { | |
613 | return d_ptr->m_data.m_labelFont; |
|
623 | return d_ptr->m_data.m_labelFont; | |
614 | } |
|
624 | } | |
615 |
|
625 | |||
616 | void QPieSlice::setLabelArmLengthFactor(qreal factor) |
|
626 | void QPieSlice::setLabelArmLengthFactor(qreal factor) | |
617 | { |
|
627 | { | |
618 | if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) { |
|
628 | if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) { | |
619 | d_ptr->m_data.m_labelArmLengthFactor = factor; |
|
629 | d_ptr->m_data.m_labelArmLengthFactor = factor; | |
620 | emit d_ptr->labelArmLengthFactorChanged(); |
|
630 | emit d_ptr->labelArmLengthFactorChanged(); | |
621 | } |
|
631 | } | |
622 | } |
|
632 | } | |
623 |
|
633 | |||
624 | qreal QPieSlice::labelArmLengthFactor() const |
|
634 | qreal QPieSlice::labelArmLengthFactor() const | |
625 | { |
|
635 | { | |
626 | return d_ptr->m_data.m_labelArmLengthFactor; |
|
636 | return d_ptr->m_data.m_labelArmLengthFactor; | |
627 | } |
|
637 | } | |
628 |
|
638 | |||
629 | void QPieSlice::setExplodeDistanceFactor(qreal factor) |
|
639 | void QPieSlice::setExplodeDistanceFactor(qreal factor) | |
630 | { |
|
640 | { | |
631 | if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) { |
|
641 | if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) { | |
632 | d_ptr->m_data.m_explodeDistanceFactor = factor; |
|
642 | d_ptr->m_data.m_explodeDistanceFactor = factor; | |
633 | emit d_ptr->explodeDistanceFactorChanged(); |
|
643 | emit d_ptr->explodeDistanceFactorChanged(); | |
634 | } |
|
644 | } | |
635 | } |
|
645 | } | |
636 |
|
646 | |||
637 | qreal QPieSlice::explodeDistanceFactor() const |
|
647 | qreal QPieSlice::explodeDistanceFactor() const | |
638 | { |
|
648 | { | |
639 | return d_ptr->m_data.m_explodeDistanceFactor; |
|
649 | return d_ptr->m_data.m_explodeDistanceFactor; | |
640 | } |
|
650 | } | |
641 |
|
651 | |||
642 | qreal QPieSlice::percentage() const |
|
652 | qreal QPieSlice::percentage() const | |
643 | { |
|
653 | { | |
644 | return d_ptr->m_data.m_percentage; |
|
654 | return d_ptr->m_data.m_percentage; | |
645 | } |
|
655 | } | |
646 |
|
656 | |||
647 | qreal QPieSlice::startAngle() const |
|
657 | qreal QPieSlice::startAngle() const | |
648 | { |
|
658 | { | |
649 | return d_ptr->m_data.m_startAngle; |
|
659 | return d_ptr->m_data.m_startAngle; | |
650 | } |
|
660 | } | |
651 |
|
661 | |||
652 | qreal QPieSlice::angleSpan() const |
|
662 | qreal QPieSlice::angleSpan() const | |
653 | { |
|
663 | { | |
654 | return d_ptr->m_data.m_angleSpan; |
|
664 | return d_ptr->m_data.m_angleSpan; | |
655 | } |
|
665 | } | |
656 |
|
666 | |||
657 | /*! |
|
667 | /*! | |
658 | Returns the series that this slice belongs to. |
|
668 | Returns the series that this slice belongs to. | |
659 |
|
669 | |||
660 | \sa QPieSeries::append() |
|
670 | \sa QPieSeries::append() | |
661 | */ |
|
671 | */ | |
662 | QPieSeries *QPieSlice::series() const |
|
672 | QPieSeries *QPieSlice::series() const | |
663 | { |
|
673 | { | |
664 | return d_ptr->m_series; |
|
674 | return d_ptr->m_series; | |
665 | } |
|
675 | } | |
666 |
|
676 | |||
667 | QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent) |
|
677 | QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent) | |
668 | :QObject(parent), |
|
678 | :QObject(parent), | |
669 | q_ptr(parent), |
|
679 | q_ptr(parent), | |
670 | m_series(0) |
|
680 | m_series(0) | |
671 | { |
|
681 | { | |
672 |
|
682 | |||
673 | } |
|
683 | } | |
674 |
|
684 | |||
675 | QPieSlicePrivate::~QPieSlicePrivate() |
|
685 | QPieSlicePrivate::~QPieSlicePrivate() | |
676 | { |
|
686 | { | |
677 |
|
687 | |||
678 | } |
|
688 | } | |
679 |
|
689 | |||
680 | QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice) |
|
690 | QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice) | |
681 | { |
|
691 | { | |
682 | return slice->d_func(); |
|
692 | return slice->d_func(); | |
683 | } |
|
693 | } | |
684 |
|
694 | |||
685 | void QPieSlicePrivate::setPen(const QPen &pen, bool themed) |
|
695 | void QPieSlicePrivate::setPen(const QPen &pen, bool themed) | |
686 | { |
|
696 | { | |
687 | if (m_data.m_slicePen != pen) { |
|
697 | if (m_data.m_slicePen != pen) { | |
688 |
|
698 | |||
689 | QPen oldPen = m_data.m_slicePen; |
|
699 | QPen oldPen = m_data.m_slicePen; | |
690 |
|
700 | |||
691 | m_data.m_slicePen = pen; |
|
701 | m_data.m_slicePen = pen; | |
692 | m_data.m_slicePen.setThemed(themed); |
|
702 | m_data.m_slicePen.setThemed(themed); | |
693 |
|
703 | |||
694 | emit q_ptr->penChanged(); |
|
704 | emit q_ptr->penChanged(); | |
695 | if (oldPen.color() != pen.color()) |
|
705 | if (oldPen.color() != pen.color()) | |
696 | emit q_ptr->borderColorChanged(); |
|
706 | emit q_ptr->borderColorChanged(); | |
697 | if (oldPen.width() != pen.width()) |
|
707 | if (oldPen.width() != pen.width()) | |
698 | emit q_ptr->borderWidthChanged(); |
|
708 | emit q_ptr->borderWidthChanged(); | |
699 | } |
|
709 | } | |
700 | } |
|
710 | } | |
701 |
|
711 | |||
702 | void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed) |
|
712 | void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed) | |
703 | { |
|
713 | { | |
704 | if (m_data.m_sliceBrush != brush) { |
|
714 | if (m_data.m_sliceBrush != brush) { | |
705 |
|
715 | |||
706 | QBrush oldBrush = m_data.m_sliceBrush; |
|
716 | QBrush oldBrush = m_data.m_sliceBrush; | |
707 |
|
717 | |||
708 | m_data.m_sliceBrush = brush; |
|
718 | m_data.m_sliceBrush = brush; | |
709 | m_data.m_sliceBrush.setThemed(themed); |
|
719 | m_data.m_sliceBrush.setThemed(themed); | |
710 |
|
720 | |||
711 | emit q_ptr->brushChanged(); |
|
721 | emit q_ptr->brushChanged(); | |
712 | if (oldBrush.color() != brush.color()) |
|
722 | if (oldBrush.color() != brush.color()) | |
713 | emit q_ptr->colorChanged(); |
|
723 | emit q_ptr->colorChanged(); | |
714 | } |
|
724 | } | |
715 | } |
|
725 | } | |
716 |
|
726 | |||
717 | void QPieSlicePrivate::setLabelBrush(const QBrush &brush, bool themed) |
|
727 | void QPieSlicePrivate::setLabelBrush(const QBrush &brush, bool themed) | |
718 | { |
|
728 | { | |
719 | if (m_data.m_labelBrush != brush) { |
|
729 | if (m_data.m_labelBrush != brush) { | |
720 |
|
730 | |||
721 | QBrush oldBrush = m_data.m_labelBrush; |
|
731 | QBrush oldBrush = m_data.m_labelBrush; | |
722 |
|
732 | |||
723 | m_data.m_labelBrush = brush; |
|
733 | m_data.m_labelBrush = brush; | |
724 | m_data.m_labelBrush.setThemed(themed); |
|
734 | m_data.m_labelBrush.setThemed(themed); | |
725 |
|
735 | |||
726 | emit q_ptr->labelBrushChanged(); |
|
736 | emit q_ptr->labelBrushChanged(); | |
727 | if (oldBrush.color() != brush.color()) |
|
737 | if (oldBrush.color() != brush.color()) | |
728 | emit q_ptr->labelColorChanged(); |
|
738 | emit q_ptr->labelColorChanged(); | |
729 | } |
|
739 | } | |
730 | } |
|
740 | } | |
731 |
|
741 | |||
732 | void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed) |
|
742 | void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed) | |
733 | { |
|
743 | { | |
734 | if (m_data.m_labelFont != font) { |
|
744 | if (m_data.m_labelFont != font) { | |
735 | m_data.m_labelFont = font; |
|
745 | m_data.m_labelFont = font; | |
736 | m_data.m_labelFont.setThemed(themed); |
|
746 | m_data.m_labelFont.setThemed(themed); | |
737 | emit q_ptr->labelFontChanged(); |
|
747 | emit q_ptr->labelFontChanged(); | |
738 | } |
|
748 | } | |
739 | } |
|
749 | } | |
740 |
|
750 | |||
741 | void QPieSlicePrivate::setPercentage(qreal percentage) |
|
751 | void QPieSlicePrivate::setPercentage(qreal percentage) | |
742 | { |
|
752 | { | |
743 | if (!qFuzzyIsNull(m_data.m_percentage - percentage)) { |
|
753 | if (!qFuzzyIsNull(m_data.m_percentage - percentage)) { | |
744 | m_data.m_percentage = percentage; |
|
754 | m_data.m_percentage = percentage; | |
745 | emit q_ptr->percentageChanged(); |
|
755 | emit q_ptr->percentageChanged(); | |
746 | } |
|
756 | } | |
747 | } |
|
757 | } | |
748 |
|
758 | |||
749 | void QPieSlicePrivate::setStartAngle(qreal angle) |
|
759 | void QPieSlicePrivate::setStartAngle(qreal angle) | |
750 | { |
|
760 | { | |
751 | if (!qFuzzyIsNull(m_data.m_startAngle - angle)) { |
|
761 | if (!qFuzzyIsNull(m_data.m_startAngle - angle)) { | |
752 | m_data.m_startAngle = angle; |
|
762 | m_data.m_startAngle = angle; | |
753 | emit q_ptr->startAngleChanged(); |
|
763 | emit q_ptr->startAngleChanged(); | |
754 | } |
|
764 | } | |
755 | } |
|
765 | } | |
756 |
|
766 | |||
757 | void QPieSlicePrivate::setAngleSpan(qreal span) |
|
767 | void QPieSlicePrivate::setAngleSpan(qreal span) | |
758 | { |
|
768 | { | |
759 | if (!qFuzzyIsNull(m_data.m_angleSpan - span)) { |
|
769 | if (!qFuzzyIsNull(m_data.m_angleSpan - span)) { | |
760 | m_data.m_angleSpan = span; |
|
770 | m_data.m_angleSpan = span; | |
761 | emit q_ptr->angleSpanChanged(); |
|
771 | emit q_ptr->angleSpanChanged(); | |
762 | } |
|
772 | } | |
763 | } |
|
773 | } | |
764 |
|
774 | |||
765 | QTCOMMERCIALCHART_END_NAMESPACE |
|
775 | QTCOMMERCIALCHART_END_NAMESPACE | |
766 |
|
776 | |||
767 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
777 | QTCOMMERCIALCHART_USE_NAMESPACE | |
768 | #include "moc_qpieslice.cpp" |
|
778 | #include "moc_qpieslice.cpp" | |
769 | #include "moc_qpieslice_p.cpp" |
|
779 | #include "moc_qpieslice_p.cpp" |
General Comments 0
You need to be logged in to leave comments.
Login now