@@ -1,307 +1,296 | |||||
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 "qcategoriesaxis.h" |
|
21 | #include "qcategoriesaxis.h" | |
22 | #include "qcategoriesaxis_p.h" |
|
22 | #include "qcategoriesaxis_p.h" | |
23 | #include "chartcategoriesaxisx_p.h" |
|
23 | #include "chartcategoriesaxisx_p.h" | |
24 | #include "chartcategoriesaxisy_p.h" |
|
24 | #include "chartcategoriesaxisy_p.h" | |
25 | #include <qmath.h> |
|
25 | #include <qmath.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | QCategoriesAxis::QCategoriesAxis(QObject *parent): |
|
29 | QCategoriesAxis::QCategoriesAxis(QObject *parent): | |
30 | QAbstractAxis(*new QCategoriesAxisPrivate(this),parent) |
|
30 | QAbstractAxis(*new QCategoriesAxisPrivate(this),parent) | |
31 | { |
|
31 | { | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | QCategoriesAxis::~QCategoriesAxis() |
|
34 | QCategoriesAxis::~QCategoriesAxis() | |
35 | { |
|
35 | { | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | QCategoriesAxis::QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent) |
|
38 | QCategoriesAxis::QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent) | |
39 | { |
|
39 | { | |
40 |
|
40 | |||
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | /*! |
|
43 | /*! | |
44 | Appends \a categories to axis |
|
44 | Appends \a categories to axis | |
45 | */ |
|
45 | */ | |
46 | void QCategoriesAxis::append(const QStringList &categories) |
|
46 | void QCategoriesAxis::append(const QStringList &categories) | |
47 | { |
|
47 | { | |
48 | Q_D(QCategoriesAxis); |
|
48 | Q_D(QCategoriesAxis); | |
|
49 | if (d->m_categories.isEmpty()) { | |||
|
50 | d->m_minCategory = categories.first(); | |||
|
51 | d->m_maxCategory = categories.last(); | |||
|
52 | } | |||
|
53 | ||||
49 | d->m_categories.append(categories); |
|
54 | d->m_categories.append(categories); | |
50 | emit categoriesChanged(); |
|
55 | emit categoriesChanged(); | |
51 | } |
|
56 | } | |
52 |
|
57 | |||
53 | /*! |
|
58 | /*! | |
54 | Appends \a category to axis |
|
59 | Appends \a category to axis | |
55 | */ |
|
60 | */ | |
56 | void QCategoriesAxis::append(const QString &category) |
|
61 | void QCategoriesAxis::append(const QString &category) | |
57 | { |
|
62 | { | |
58 | Q_D(QCategoriesAxis); |
|
63 | Q_D(QCategoriesAxis); | |
|
64 | if (d->m_categories.isEmpty()) { | |||
|
65 | d->m_minCategory = category; | |||
|
66 | d->m_maxCategory = category; | |||
|
67 | } | |||
|
68 | ||||
59 | d->m_categories.append(category); |
|
69 | d->m_categories.append(category); | |
60 | emit categoriesChanged(); |
|
70 | emit categoriesChanged(); | |
61 | } |
|
71 | } | |
62 |
|
72 | |||
63 | /*! |
|
73 | /*! | |
64 | Removes \a category from axis |
|
74 | Removes \a category from axis | |
65 | */ |
|
75 | */ | |
66 | void QCategoriesAxis::remove(const QString &category) |
|
76 | void QCategoriesAxis::remove(const QString &category) | |
67 | { |
|
77 | { | |
68 | Q_D(QCategoriesAxis); |
|
78 | Q_D(QCategoriesAxis); | |
69 | if (d->m_categories.contains(category)) { |
|
79 | if (d->m_categories.contains(category)) { | |
70 | d->m_categories.removeAt(d->m_categories.indexOf(category)); |
|
80 | d->m_categories.removeAt(d->m_categories.indexOf(category)); | |
|
81 | d->m_minCategory = d->m_categories.first(); | |||
|
82 | d->m_maxCategory = d->m_categories.last(); | |||
71 | emit categoriesChanged(); |
|
83 | emit categoriesChanged(); | |
72 | } |
|
84 | } | |
73 | } |
|
85 | } | |
74 |
|
86 | |||
75 | /*! |
|
87 | /*! | |
76 | Inserts \a category to axis at \a index |
|
88 | Inserts \a category to axis at \a index | |
77 | */ |
|
89 | */ | |
78 | void QCategoriesAxis::insert(int index, const QString &category) |
|
90 | void QCategoriesAxis::insert(int index, const QString &category) | |
79 | { |
|
91 | { | |
80 | Q_D(QCategoriesAxis); |
|
92 | Q_D(QCategoriesAxis); | |
|
93 | if (d->m_categories.isEmpty()) { | |||
|
94 | d->m_minCategory = category; | |||
|
95 | d->m_maxCategory = category; | |||
|
96 | } | |||
81 | d->m_categories.insert(index,category); |
|
97 | d->m_categories.insert(index,category); | |
82 | emit categoriesChanged(); |
|
98 | emit categoriesChanged(); | |
83 | } |
|
99 | } | |
84 |
|
100 | |||
85 | /*! |
|
101 | /*! | |
86 | Removes all categories. |
|
102 | Removes all categories. | |
87 | */ |
|
103 | */ | |
88 | void QCategoriesAxis::clear() |
|
104 | void QCategoriesAxis::clear() | |
89 | { |
|
105 | { | |
90 | Q_D(QCategoriesAxis); |
|
106 | Q_D(QCategoriesAxis); | |
91 | d->m_categories.clear(); |
|
107 | d->m_categories.clear(); | |
|
108 | d->m_minCategory.clear(); | |||
|
109 | d->m_maxCategory.clear(); | |||
92 | emit categoriesChanged(); |
|
110 | emit categoriesChanged(); | |
93 | } |
|
111 | } | |
94 |
|
112 | |||
95 | void QCategoriesAxis::setCategories(const QStringList &categories) |
|
113 | void QCategoriesAxis::setCategories(const QStringList &categories) | |
96 | { |
|
114 | { | |
97 | Q_D(QCategoriesAxis); |
|
115 | Q_D(QCategoriesAxis); | |
98 | d->m_categories = categories; |
|
116 | d->m_categories = categories; | |
|
117 | d->m_minCategory = categories.first(); | |||
|
118 | d->m_maxCategory = categories.last(); | |||
99 | emit categoriesChanged(); |
|
119 | emit categoriesChanged(); | |
100 | } |
|
120 | } | |
101 |
|
121 | |||
102 | QStringList QCategoriesAxis::categories() |
|
122 | QStringList QCategoriesAxis::categories() | |
103 | { |
|
123 | { | |
104 | Q_D(QCategoriesAxis); |
|
124 | Q_D(QCategoriesAxis); | |
105 | return d->m_categories; |
|
125 | return d->m_categories; | |
106 | } |
|
126 | } | |
107 |
|
127 | |||
108 | /*! |
|
128 | /*! | |
109 | Returns number of categories. |
|
129 | Returns number of categories. | |
110 | */ |
|
130 | */ | |
111 | int QCategoriesAxis::count() const |
|
131 | int QCategoriesAxis::count() const | |
112 | { |
|
132 | { | |
113 | Q_D(const QCategoriesAxis); |
|
133 | Q_D(const QCategoriesAxis); | |
114 | return d->m_categories.count(); |
|
134 | return d->m_categories.count(); | |
115 | } |
|
135 | } | |
116 |
|
136 | |||
117 | /*! |
|
137 | /*! | |
118 | Returns category at \a index. Index must be valid. |
|
138 | Returns category at \a index. Index must be valid. | |
119 | */ |
|
139 | */ | |
120 | QString QCategoriesAxis::at(int index) const |
|
140 | QString QCategoriesAxis::at(int index) const | |
121 | { |
|
141 | { | |
122 | Q_D(const QCategoriesAxis); |
|
142 | Q_D(const QCategoriesAxis); | |
123 | return d->m_categories.at(index); |
|
143 | return d->m_categories.at(index); | |
124 | } |
|
144 | } | |
125 |
|
145 | |||
126 | /*! |
|
146 | /*! | |
127 |
Sets minimum category to \a min |
|
147 | Sets minimum category to \a min. | |
128 | */ |
|
148 | */ | |
129 |
void QCategoriesAxis::setMin |
|
149 | void QCategoriesAxis::setMin(const QString& min) | |
130 | { |
|
150 | { | |
131 | Q_D(QCategoriesAxis); |
|
151 | Q_D(QCategoriesAxis); | |
132 |
d-> |
|
152 | setRange(min,d->m_maxCategory); | |
133 | } |
|
153 | } | |
134 |
|
154 | |||
135 | /*! |
|
155 | /*! | |
136 | Returns minimum category. |
|
156 | Returns minimum category. | |
137 | */ |
|
157 | */ | |
138 |
QString QCategoriesAxis::min |
|
158 | QString QCategoriesAxis::min() const | |
139 | { |
|
159 | { | |
140 | Q_D(const QCategoriesAxis); |
|
160 | Q_D(const QCategoriesAxis); | |
141 | return d->m_minCategory; |
|
161 | return d->m_minCategory; | |
142 | } |
|
162 | } | |
143 |
|
163 | |||
144 | /*! |
|
164 | /*! | |
145 |
Sets maximum category to \a max |
|
165 | Sets maximum category to \a max. | |
146 | */ |
|
166 | */ | |
147 |
void QCategoriesAxis::setMax |
|
167 | void QCategoriesAxis::setMax(const QString& max) | |
148 | { |
|
168 | { | |
149 | Q_D(QCategoriesAxis); |
|
169 | Q_D(QCategoriesAxis); | |
150 | d->setMaxCategory(maxCategory); |
|
170 | setRange(d->m_minCategory,max); | |
151 | } |
|
171 | } | |
152 |
|
172 | |||
153 | /*! |
|
173 | /*! | |
154 | Returns maximum category |
|
174 | Returns maximum category | |
155 | */ |
|
175 | */ | |
156 |
QString QCategoriesAxis::max |
|
176 | QString QCategoriesAxis::max() const | |
157 | { |
|
177 | { | |
158 | Q_D(const QCategoriesAxis); |
|
178 | Q_D(const QCategoriesAxis); | |
159 | return d->m_maxCategory; |
|
179 | return d->m_maxCategory; | |
160 | } |
|
180 | } | |
161 |
|
181 | |||
162 | /*! |
|
182 | /*! | |
163 | Sets range from \a minCategory to \a maxCategory |
|
183 | Sets range from \a minCategory to \a maxCategory | |
164 | */ |
|
184 | */ | |
165 |
void QCategoriesAxis::set |
|
185 | void QCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) | |
166 | { |
|
186 | { | |
167 | Q_D(QCategoriesAxis); |
|
187 | Q_D(QCategoriesAxis); | |
168 | d->setRangeCategory(minCategory,maxCategory); |
|
188 | ||
|
189 | int minIndex = d->m_categories.indexOf(minCategory); | |||
|
190 | if (minIndex == -1) { | |||
|
191 | return; | |||
|
192 | } | |||
|
193 | int maxIndex = d->m_categories.indexOf(maxCategory); | |||
|
194 | if (maxIndex == -1) { | |||
|
195 | return; | |||
|
196 | } | |||
|
197 | ||||
|
198 | if (maxIndex <= minIndex) { | |||
|
199 | // max must be greater than min | |||
|
200 | return; | |||
|
201 | } | |||
|
202 | ||||
|
203 | d->m_minCategory = minCategory; | |||
|
204 | d->m_maxCategory = maxCategory; | |||
|
205 | ||||
|
206 | bool changed = false; | |||
|
207 | if (!qFuzzyIsNull(d->m_min - (minIndex))) { | |||
|
208 | d->m_min = minIndex; | |||
|
209 | changed = true; | |||
|
210 | } | |||
|
211 | ||||
|
212 | if (!qFuzzyIsNull(d->m_max - (maxIndex))) { | |||
|
213 | d->m_max = maxIndex; | |||
|
214 | changed = true; | |||
|
215 | } | |||
|
216 | ||||
|
217 | if ((changed)) { | |||
|
218 | if(!signalsBlocked()){ | |||
|
219 | emit d->changed(d->m_min -0.5, d->m_max +0.5, qCeil(d->m_max + 0.5) -qCeil(d->m_min - 0.5) +1, false); | |||
|
220 | } | |||
|
221 | emit categoriesChanged(); | |||
|
222 | } | |||
169 | } |
|
223 | } | |
170 |
|
224 | |||
171 | /*! |
|
225 | /*! | |
172 | Returns the type of axis. |
|
226 | Returns the type of axis. | |
173 | */ |
|
227 | */ | |
174 | QAbstractAxis::AxisType QCategoriesAxis::type() const |
|
228 | QAbstractAxis::AxisType QCategoriesAxis::type() const | |
175 | { |
|
229 | { | |
176 | return AxisTypeCategories; |
|
230 | return AxisTypeCategories; | |
177 | } |
|
231 | } | |
178 |
|
232 | |||
179 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
233 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
180 |
|
234 | |||
181 | QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q): |
|
235 | QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q): | |
182 | QAbstractAxisPrivate(q) |
|
236 | QAbstractAxisPrivate(q) | |
183 | { |
|
237 | { | |
184 |
|
238 | |||
185 | } |
|
239 | } | |
186 |
|
240 | |||
187 | QCategoriesAxisPrivate::~QCategoriesAxisPrivate() |
|
241 | QCategoriesAxisPrivate::~QCategoriesAxisPrivate() | |
188 | { |
|
242 | { | |
189 |
|
243 | |||
190 | } |
|
244 | } | |
191 |
|
245 | |||
192 | void QCategoriesAxisPrivate::setMinCategory(const QString& minCategory) |
|
|||
193 | { |
|
|||
194 | // Convert the category to value |
|
|||
195 | int minIndex = m_categories.indexOf(minCategory); |
|
|||
196 | if (minIndex == -1) { |
|
|||
197 | return; |
|
|||
198 | } |
|
|||
199 |
|
||||
200 | int maxIndex = qFloor(m_max); |
|
|||
201 | if (minIndex > maxIndex) { |
|
|||
202 | maxIndex = m_categories.count()-1; |
|
|||
203 | } |
|
|||
204 | setRange(minIndex - 0.5, maxIndex + 0.5); |
|
|||
205 | } |
|
|||
206 |
|
||||
207 | void QCategoriesAxisPrivate::setMaxCategory(const QString& maxCategory) |
|
|||
208 | { |
|
|||
209 | // Convert the category to value |
|
|||
210 | int maxIndex = m_categories.indexOf(maxCategory); |
|
|||
211 | if (maxIndex == -1) { |
|
|||
212 | return; |
|
|||
213 | } |
|
|||
214 |
|
||||
215 | int minIndex = qCeil(m_min); |
|
|||
216 | if (maxIndex < minIndex) { |
|
|||
217 | minIndex = 0; |
|
|||
218 | } |
|
|||
219 | setRange(minIndex - 0.5, maxIndex + 0.5); |
|
|||
220 | } |
|
|||
221 |
|
||||
222 | void QCategoriesAxisPrivate::setRangeCategory(const QString& minCategory, const QString& maxCategory) |
|
|||
223 | { |
|
|||
224 | // TODO: |
|
|||
225 | int minIndex = m_categories.indexOf(minCategory); |
|
|||
226 | if (minIndex == -1) { |
|
|||
227 | return; |
|
|||
228 | } |
|
|||
229 | int maxIndex = m_categories.indexOf(maxCategory); |
|
|||
230 | if (maxIndex == -1) { |
|
|||
231 | return; |
|
|||
232 | } |
|
|||
233 | setRange(minIndex -0.5, maxIndex + 0.5); |
|
|||
234 | } |
|
|||
235 |
|
||||
236 | void QCategoriesAxisPrivate::setMin(const QVariant &min) |
|
246 | void QCategoriesAxisPrivate::setMin(const QVariant &min) | |
237 | { |
|
247 | { | |
238 | setRange(min,m_max); |
|
248 | setRange(min,m_maxCategory); | |
239 | } |
|
249 | } | |
240 |
|
250 | |||
241 | void QCategoriesAxisPrivate::setMax(const QVariant &max) |
|
251 | void QCategoriesAxisPrivate::setMax(const QVariant &max) | |
242 | { |
|
252 | { | |
243 | setRange(m_min,max); |
|
253 | setRange(m_minCategory,max); | |
244 | } |
|
254 | } | |
245 |
|
255 | |||
246 | void QCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max, bool force) |
|
256 | void QCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max, bool force) | |
247 | { |
|
257 | { | |
248 | Q_UNUSED(min); |
|
258 | Q_UNUSED(force); // TODO: use this? | |
249 | Q_UNUSED(max); |
|
|||
250 | Q_UNUSED(force); |
|
|||
251 | // TODO: refactor |
|
|||
252 | /* |
|
|||
253 | if (max <= min) { |
|
|||
254 | // max must be greater than min |
|
|||
255 | return; |
|
|||
256 | } |
|
|||
257 | Q_Q(QCategoriesAxis); |
|
259 | Q_Q(QCategoriesAxis); | |
258 | bool changed = false; |
|
260 | QString value1 = min.toString(); | |
259 | if (!qFuzzyIsNull(m_min - min)) { |
|
261 | QString value2 = max.toString(); | |
260 | m_min = min; |
|
262 | q->setRange(value1,value2); | |
261 | changed = true; |
|
|||
262 | } |
|
|||
263 |
|
||||
264 | if (!qFuzzyIsNull(m_max - max)) { |
|
|||
265 | m_max = max; |
|
|||
266 | changed = true; |
|
|||
267 | } |
|
|||
268 |
|
||||
269 | if ((changed) ||(force)) { |
|
|||
270 | emit this->changed(m_min, m_max, qCeil(m_max) -qCeil(m_min) +1, false); |
|
|||
271 | emit q->categoriesChanged(); |
|
|||
272 | } |
|
|||
273 | */ |
|
|||
274 | } |
|
263 | } | |
275 |
|
264 | |||
276 | int QCategoriesAxisPrivate::ticksCount() const |
|
265 | int QCategoriesAxisPrivate::ticksCount() const | |
277 | { |
|
266 | { | |
278 | return m_categories.count()+1; |
|
267 | return m_categories.count()+1; | |
279 | } |
|
268 | } | |
280 |
|
269 | |||
281 | void QCategoriesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
270 | void QCategoriesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
282 | { |
|
271 | { | |
283 | m_min = min; |
|
272 | m_min = min; | |
284 | m_max = max; |
|
273 | m_max = max; | |
285 | m_ticksCount = count; |
|
274 | m_ticksCount = count; | |
286 | } |
|
275 | } | |
287 |
|
276 | |||
288 | ChartAxis* QCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
277 | ChartAxis* QCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) | |
289 | { |
|
278 | { | |
290 | Q_Q( QCategoriesAxis); |
|
279 | Q_Q( QCategoriesAxis); | |
291 | if(m_orientation == Qt::Vertical){ |
|
280 | if(m_orientation == Qt::Vertical){ | |
292 | return new ChartCategoriesAxisY(q,presenter); |
|
281 | return new ChartCategoriesAxisY(q,presenter); | |
293 | }else{ |
|
282 | }else{ | |
294 | return new ChartCategoriesAxisX(q,presenter); |
|
283 | return new ChartCategoriesAxisX(q,presenter); | |
295 | } |
|
284 | } | |
296 | } |
|
285 | } | |
297 |
|
286 | |||
298 | void QCategoriesAxisPrivate::updateRange() |
|
287 | void QCategoriesAxisPrivate::updateRange() | |
299 | { |
|
288 | { | |
300 | setRange(m_min,m_max,true); |
|
289 | setRange(m_min,m_max,true); | |
301 | } |
|
290 | } | |
302 |
|
291 | |||
303 |
|
292 | |||
304 | #include "moc_qcategoriesaxis.cpp" |
|
293 | #include "moc_qcategoriesaxis.cpp" | |
305 | #include "moc_qcategoriesaxis_p.cpp" |
|
294 | #include "moc_qcategoriesaxis_p.cpp" | |
306 |
|
295 | |||
307 | QTCOMMERCIALCHART_END_NAMESPACE |
|
296 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,76 +1,71 | |||||
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 QCATEGORIESAXIS_H |
|
21 | #ifndef QCATEGORIESAXIS_H | |
22 | #define QCATEGORIESAXIS_H |
|
22 | #define QCATEGORIESAXIS_H | |
23 |
|
23 | |||
24 | #include "qabstractaxis.h" |
|
24 | #include "qabstractaxis.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | class QCategoriesAxisPrivate; |
|
28 | class QCategoriesAxisPrivate; | |
29 |
|
29 | |||
30 | class QTCOMMERCIALCHART_EXPORT QCategoriesAxis : public QAbstractAxis |
|
30 | class QTCOMMERCIALCHART_EXPORT QCategoriesAxis : public QAbstractAxis | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) |
|
33 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) | |
34 |
|
34 | |||
35 | public: |
|
35 | public: | |
36 | explicit QCategoriesAxis(QObject *parent = 0); |
|
36 | explicit QCategoriesAxis(QObject *parent = 0); | |
37 | ~QCategoriesAxis(); |
|
37 | ~QCategoriesAxis(); | |
38 |
|
38 | |||
39 | protected: |
|
39 | protected: | |
40 | QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent = 0); |
|
40 | QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent = 0); | |
41 |
|
41 | |||
42 | public: |
|
42 | public: | |
43 | AxisType type() const; |
|
43 | AxisType type() const; | |
44 | void append(const QStringList &categories); |
|
44 | void append(const QStringList &categories); | |
45 | void append(const QString &category); |
|
45 | void append(const QString &category); | |
46 | void remove(const QString &category); |
|
46 | void remove(const QString &category); | |
47 | void insert(int index, const QString &category); |
|
47 | void insert(int index, const QString &category); | |
48 | void clear(); |
|
48 | void clear(); | |
49 | void setCategories(const QStringList &categories); |
|
49 | void setCategories(const QStringList &categories); | |
50 | QStringList categories(); |
|
50 | QStringList categories(); | |
51 | int count() const; |
|
51 | int count() const; | |
52 |
|
||||
53 | QString at(int index) const; |
|
52 | QString at(int index) const; | |
54 |
|
53 | |||
55 |
//range handling |
|
54 | //range handling | |
56 |
void setMin |
|
55 | void setMin(const QString& minCategory); | |
57 |
QString min |
|
56 | QString min() const; | |
58 |
void setMax |
|
57 | void setMax(const QString& maxCategory); | |
59 |
QString max |
|
58 | QString max() const; | |
60 |
void set |
|
59 | void setRange(const QString& minCategory, const QString& maxCategory); | |
61 |
|
||||
62 | void setMin(const QVariant &min); |
|
|||
63 | void setMax(const QVariant &max); |
|
|||
64 | void setRange(const QVariant &min, const QVariant &max); |
|
|||
65 |
|
60 | |||
66 | Q_SIGNALS: |
|
61 | Q_SIGNALS: | |
67 | void categoriesChanged(); |
|
62 | void categoriesChanged(); | |
68 |
|
63 | |||
69 | private: |
|
64 | private: | |
70 | Q_DECLARE_PRIVATE(QCategoriesAxis) |
|
65 | Q_DECLARE_PRIVATE(QCategoriesAxis) | |
71 | Q_DISABLE_COPY(QCategoriesAxis) |
|
66 | Q_DISABLE_COPY(QCategoriesAxis) | |
72 | }; |
|
67 | }; | |
73 |
|
68 | |||
74 | QTCOMMERCIALCHART_END_NAMESPACE |
|
69 | QTCOMMERCIALCHART_END_NAMESPACE | |
75 |
|
70 | |||
76 | #endif // QCATEGORIESAXIS_H |
|
71 | #endif // QCATEGORIESAXIS_H |
@@ -1,78 +1,74 | |||||
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 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QCATEGORIESAXIS_P_H |
|
30 | #ifndef QCATEGORIESAXIS_P_H | |
31 | #define QCATEGORIESAXIS_P_H |
|
31 | #define QCATEGORIESAXIS_P_H | |
32 |
|
32 | |||
33 | #include "qcategoriesaxis.h" |
|
33 | #include "qcategoriesaxis.h" | |
34 | #include "qabstractaxis_p.h" |
|
34 | #include "qabstractaxis_p.h" | |
35 |
|
35 | |||
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QCategoriesAxisPrivate : public QAbstractAxisPrivate |
|
38 | class QCategoriesAxisPrivate : public QAbstractAxisPrivate | |
39 | { |
|
39 | { | |
40 | Q_OBJECT |
|
40 | Q_OBJECT | |
41 |
|
41 | |||
42 | public: |
|
42 | public: | |
43 | QCategoriesAxisPrivate(QCategoriesAxis *q); |
|
43 | QCategoriesAxisPrivate(QCategoriesAxis *q); | |
44 | ~QCategoriesAxisPrivate(); |
|
44 | ~QCategoriesAxisPrivate(); | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
47 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
48 | void updateRange(); |
|
48 | void updateRange(); | |
49 |
|
49 | |||
50 | private: |
|
50 | private: | |
51 | void setMinCategory(const QString& minCategory); |
|
|||
52 | void setMaxCategory(const QString& maxCategory); |
|
|||
53 | void setRangeCategory(const QString& minCategory, const QString& maxCategory); |
|
|||
54 |
|
||||
55 | //range handling |
|
51 | //range handling | |
56 | void setMin(const QVariant &min); |
|
52 | void setMin(const QVariant &min); | |
57 | void setMax(const QVariant &max); |
|
53 | void setMax(const QVariant &max); | |
58 | void setRange(const QVariant &min, const QVariant &max, bool force = false); |
|
54 | void setRange(const QVariant &min, const QVariant &max, bool force = false); | |
59 | int ticksCount() const; |
|
55 | int ticksCount() const; | |
60 |
|
56 | |||
61 | Q_SIGNALS: |
|
57 | Q_SIGNALS: | |
62 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); |
|
58 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); | |
63 |
|
59 | |||
64 | public Q_SLOTS: |
|
60 | public Q_SLOTS: | |
65 | void handleAxisRangeChanged(qreal min, qreal max,int count); |
|
61 | void handleAxisRangeChanged(qreal min, qreal max,int count); | |
66 |
|
62 | |||
67 | private: |
|
63 | private: | |
68 | QStringList m_categories; |
|
64 | QStringList m_categories; | |
69 | QString m_minCategory; |
|
65 | QString m_minCategory; | |
70 | QString m_maxCategory; |
|
66 | QString m_maxCategory; | |
71 |
|
67 | |||
72 | private: |
|
68 | private: | |
73 | Q_DECLARE_PUBLIC(QCategoriesAxis) |
|
69 | Q_DECLARE_PUBLIC(QCategoriesAxis) | |
74 | }; |
|
70 | }; | |
75 |
|
71 | |||
76 | QTCOMMERCIALCHART_END_NAMESPACE |
|
72 | QTCOMMERCIALCHART_END_NAMESPACE | |
77 |
|
73 | |||
78 | #endif // QCATEGORIESAXIS_P_H |
|
74 | #endif // QCATEGORIESAXIS_P_H |
General Comments 0
You need to be logged in to leave comments.
Login now