##// END OF EJS Templates
QAbstractAxis: renamed Arrow and Axis to line in methods names
Marek Rosa -
r1844:691cce09e051
parent child
Show More
@@ -1,121 +1,121
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include <QApplication>
22 22 #include <QMainWindow>
23 23 #include <QChartView>
24 24 #include <QLineSeries>
25 25 #include <QCategoryAxis>
26 26
27 27 QTCOMMERCIALCHART_USE_NAMESPACE
28 28
29 29 int main(int argc, char *argv[])
30 30 {
31 31 QApplication a(argc, argv);
32 32
33 33 //![1]
34 34 QLineSeries* series = new QLineSeries();
35 35 *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(29, 26);
36 36 QChart* chart = new QChart();
37 37 chart->legend()->hide();
38 38 chart->addSeries(series);
39 39 //![1]
40 40
41 41 //![2]
42 42 // Customize series
43 43 QPen pen(QRgb(0xfdb157));
44 44 pen.setWidth(5);
45 45 series->setPen(pen);
46 46
47 47 // Customize chart title
48 48 QFont font;
49 49 font.setPixelSize(18);
50 50 chart->setTitleFont(font);
51 51 chart->setTitleBrush(QBrush(Qt::white));
52 52 chart->setTitle("Customchart example");
53 53
54 54 // Customize chart background
55 55 QLinearGradient backgroundGradient;
56 56 backgroundGradient.setStart(QPointF(0,0));
57 57 backgroundGradient.setFinalStop(QPointF(0,1));
58 58 backgroundGradient.setColorAt(0.0, QRgb(0xd2d0d1));
59 59 backgroundGradient.setColorAt(1.0, QRgb(0x4c4547));
60 60 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
61 61 chart->setBackgroundBrush(backgroundGradient);
62 62 //![2]
63 63
64 64 //![3]
65 65 QCategoryAxis* axisX = new QCategoryAxis();
66 66 QCategoryAxis* axisY = new QCategoryAxis();
67 67
68 68 // Customize axis label font
69 69 QFont labelsFont;
70 70 labelsFont.setPixelSize(12);
71 71 axisX->setLabelsFont(labelsFont);
72 72 axisY->setLabelsFont(labelsFont);
73 73
74 74 // Customize axis colors
75 75 QPen axisPen(QRgb(0xd18952));
76 76 axisPen.setWidth(2);
77 axisX->setAxisPen(axisPen);
78 axisY->setAxisPen(axisPen);
77 axisX->setLinePen(axisPen);
78 axisY->setLinePen(axisPen);
79 79
80 80 // Customize axis label colors
81 81 QBrush axisBrush(Qt::white);
82 82 axisX->setLabelsBrush(axisBrush);
83 83 axisY->setLabelsBrush(axisBrush);
84 84
85 85 // Customize grid lines and shades
86 86 axisX->setGridLineVisible(false);
87 87 axisY->setGridLineVisible(false);
88 88 axisY->setShadesPen(Qt::NoPen);
89 89 axisY->setShadesBrush(QBrush(QRgb(0xa5a2a3)));
90 90 axisY->setShadesVisible(true);
91 91 //![3]
92 92
93 93 //![4]
94 94 axisX->append("low", 10);
95 95 axisX->append("optimal", 20);
96 96 axisX->append("high", 30);
97 97 axisX->setRange(0, 30);
98 98
99 99 axisY->append("slow", 10);
100 100 axisY->append("med", 20);
101 101 axisY->append("fast", 30);
102 102 axisY->setRange(0, 30);
103 103
104 104 chart->setAxisX(axisX, series);
105 105 chart->setAxisY(axisY, series);
106 106 //![4]
107 107
108 108 //![5]
109 109 QChartView* chartView = new QChartView(chart);
110 110 chartView->setRenderHint(QPainter::Antialiasing);
111 111 //![5]
112 112
113 113 //![6]
114 114 QMainWindow window;
115 115 window.setCentralWidget(chartView);
116 116 window.resize(400, 300);
117 117 window.show();
118 118 //![6]
119 119
120 120 return a.exec();
121 121 }
@@ -1,371 +1,371
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "chartaxis_p.h"
22 22 #include "qabstractaxis.h"
23 23 #include "qabstractaxis_p.h"
24 24 #include "chartpresenter_p.h"
25 25 #include "domain_p.h"
26 26 #include <qmath.h>
27 27 #include <QDateTime>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : ChartElement(presenter),
32 32 m_chartAxis(axis),
33 33 m_labelsAngle(0),
34 34 m_grid(new QGraphicsItemGroup(presenter->rootItem())),
35 35 m_shades(new QGraphicsItemGroup(presenter->rootItem())),
36 36 m_labels(new QGraphicsItemGroup(presenter->rootItem())),
37 37 m_arrow(new QGraphicsItemGroup(presenter->rootItem())),
38 38 m_min(0),
39 39 m_max(0),
40 40 m_animation(0),
41 41 m_minWidth(0),
42 42 m_minHeight(0)
43 43 {
44 44 //initial initialization
45 45 m_arrow->setZValue(ChartPresenter::AxisZValue);
46 46 m_arrow->setHandlesChildEvents(false);
47 47 m_labels->setZValue(ChartPresenter::AxisZValue);
48 48 m_shades->setZValue(ChartPresenter::ShadesZValue);
49 49 m_grid->setZValue(ChartPresenter::GridZValue);
50 50
51 51 QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated()));
52 52
53 53 QGraphicsSimpleTextItem item;
54 54 m_font = item.font();
55 55
56 56 }
57 57
58 58 ChartAxis::~ChartAxis()
59 59 {
60 60 }
61 61
62 62 void ChartAxis::setAnimation(AxisAnimation* animation)
63 63 {
64 64 m_animation=animation;
65 65 }
66 66
67 67 void ChartAxis::setLayout(QVector<qreal> &layout)
68 68 {
69 69 m_layoutVector=layout;
70 70 }
71 71
72 72 void ChartAxis::createItems(int count)
73 73 {
74 74 if (m_arrow->children().size() == 0)
75 75 m_arrow->addToGroup(new AxisItem(this,presenter()->rootItem()));
76 76 for (int i = 0; i < count; ++i) {
77 77 m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem()));
78 78 m_labels->addToGroup(new QGraphicsSimpleTextItem(presenter()->rootItem()));
79 79 m_arrow->addToGroup(new QGraphicsLineItem(presenter()->rootItem()));
80 80 if ((m_grid->childItems().size())%2 && m_grid->childItems().size()>2) m_shades->addToGroup(new QGraphicsRectItem(presenter()->rootItem()));
81 81 }
82 82 }
83 83
84 84 void ChartAxis::deleteItems(int count)
85 85 {
86 86 QList<QGraphicsItem *> lines = m_grid->childItems();
87 87 QList<QGraphicsItem *> labels = m_labels->childItems();
88 88 QList<QGraphicsItem *> shades = m_shades->childItems();
89 89 QList<QGraphicsItem *> axis = m_arrow->childItems();
90 90
91 91 for (int i = 0; i < count; ++i) {
92 92 if (lines.size()%2 && lines.size() > 1) delete(shades.takeLast());
93 93 delete(lines.takeLast());
94 94 delete(labels.takeLast());
95 95 delete(axis.takeLast());
96 96 }
97 97 }
98 98
99 99 void ChartAxis::updateLayout(QVector<qreal> &layout)
100 100 {
101 101 int diff = m_layoutVector.size() - layout.size();
102 102
103 103 if (diff>0) {
104 104 deleteItems(diff);
105 105 }
106 106 else if (diff<0) {
107 107 createItems(-diff);
108 108 }
109 109
110 110 if(diff<0) handleAxisUpdated();
111 111
112 112 if (m_animation) {
113 113 switch(presenter()->state()){
114 114 case ChartPresenter::ZoomInState:
115 115 m_animation->setAnimationType(AxisAnimation::ZoomInAnimation);
116 116 m_animation->setAnimationPoint(presenter()->statePoint());
117 117 break;
118 118 case ChartPresenter::ZoomOutState:
119 119 m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation);
120 120 m_animation->setAnimationPoint(presenter()->statePoint());
121 121 break;
122 122 case ChartPresenter::ScrollUpState:
123 123 case ChartPresenter::ScrollLeftState:
124 124 m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation);
125 125 break;
126 126 case ChartPresenter::ScrollDownState:
127 127 case ChartPresenter::ScrollRightState:
128 128 m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation);
129 129 break;
130 130 case ChartPresenter::ShowState:
131 131 m_animation->setAnimationType(AxisAnimation::DefaultAnimation);
132 132 break;
133 133 }
134 134 m_animation->setValues(m_layoutVector,layout);
135 135 presenter()->startAnimation(m_animation);
136 136 }
137 137 else {
138 138 setLayout(layout);
139 139 updateGeometry();
140 140 }
141 141 }
142 142
143 143 void ChartAxis::setArrowOpacity(qreal opacity)
144 144 {
145 145 m_arrow->setOpacity(opacity);
146 146 }
147 147
148 148 qreal ChartAxis::arrowOpacity() const
149 149 {
150 150 return m_arrow->opacity();
151 151 }
152 152
153 153 void ChartAxis::setArrowVisibility(bool visible)
154 154 {
155 155 m_arrow->setOpacity(visible);
156 156 }
157 157
158 158 void ChartAxis::setGridOpacity(qreal opacity)
159 159 {
160 160 m_grid->setOpacity(opacity);
161 161 }
162 162
163 163 qreal ChartAxis::gridOpacity() const
164 164 {
165 165 return m_grid->opacity();
166 166 }
167 167
168 168 void ChartAxis::setGridVisibility(bool visible)
169 169 {
170 170 m_grid->setOpacity(visible);
171 171 }
172 172
173 173 void ChartAxis::setLabelsOpacity(qreal opacity)
174 174 {
175 175 m_labels->setOpacity(opacity);
176 176 }
177 177
178 178 qreal ChartAxis::labelsOpacity() const
179 179 {
180 180 return m_labels->opacity();
181 181 }
182 182
183 183 void ChartAxis::setLabelsVisibility(bool visible)
184 184 {
185 185 m_labels->setOpacity(visible);
186 186 }
187 187
188 188 void ChartAxis::setShadesOpacity(qreal opacity)
189 189 {
190 190 m_shades->setOpacity(opacity);
191 191 }
192 192
193 193 qreal ChartAxis::shadesOpacity() const
194 194 {
195 195 return m_shades->opacity();
196 196 }
197 197
198 198 void ChartAxis::setShadesVisibility(bool visible)
199 199 {
200 200 m_shades->setVisible(visible);
201 201 }
202 202
203 203 void ChartAxis::setLabelsAngle(int angle)
204 204 {
205 205 foreach(QGraphicsItem* item , m_labels->childItems()) {
206 206 item->setRotation(angle);
207 207 }
208 208
209 209 m_labelsAngle=angle;
210 210 }
211 211
212 212 void ChartAxis::setLabelsPen(const QPen &pen)
213 213 {
214 214 foreach(QGraphicsItem* item , m_labels->childItems()) {
215 215 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
216 216 }
217 217 }
218 218
219 219 void ChartAxis::setLabelsBrush(const QBrush &brush)
220 220 {
221 221 foreach(QGraphicsItem* item , m_labels->childItems()) {
222 222 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
223 223 }
224 224 }
225 225
226 226 void ChartAxis::setLabelsFont(const QFont &font)
227 227 {
228 228 foreach(QGraphicsItem* item , m_labels->childItems()) {
229 229 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
230 230 }
231 231 m_font = font;
232 232 }
233 233
234 234 void ChartAxis::setShadesBrush(const QBrush &brush)
235 235 {
236 236 foreach(QGraphicsItem* item , m_shades->childItems()) {
237 237 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
238 238 }
239 239 }
240 240
241 241 void ChartAxis::setShadesPen(const QPen &pen)
242 242 {
243 243 foreach(QGraphicsItem* item , m_shades->childItems()) {
244 244 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
245 245 }
246 246 }
247 247
248 248 void ChartAxis::setArrowPen(const QPen &pen)
249 249 {
250 250 foreach(QGraphicsItem* item , m_arrow->childItems()) {
251 251 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
252 252 }
253 253 }
254 254
255 255 void ChartAxis::setGridPen(const QPen &pen)
256 256 {
257 257 foreach(QGraphicsItem* item , m_grid->childItems()) {
258 258 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
259 259 }
260 260 }
261 261
262 262 bool ChartAxis::isEmpty()
263 263 {
264 264 return m_rect.isEmpty() || qFuzzyIsNull(m_min - m_max);
265 265 }
266 266
267 267 void ChartAxis::handleDomainUpdated()
268 268 {
269 269 Domain* domain = qobject_cast<Domain*>(sender());
270 270 qreal min(0);
271 271 qreal max(0);
272 272
273 273 if(m_chartAxis->orientation()==Qt::Horizontal) {
274 274 min = domain->minX();
275 275 max = domain->maxX();
276 276 }
277 277 else if (m_chartAxis->orientation()==Qt::Vertical)
278 278 {
279 279 min = domain->minY();
280 280 max = domain->maxY();
281 281 }
282 282
283 283 if (!qFuzzyIsNull(m_min - min) || !qFuzzyIsNull(m_max - max))
284 284 {
285 285 m_min = min;
286 286 m_max = max;
287 287
288 288 if (!isEmpty()) {
289 289 QVector<qreal> layout = calculateLayout();
290 290 updateLayout(layout);
291 291 }
292 292 }
293 293 }
294 294
295 295 void ChartAxis::handleAxisUpdated()
296 296 {
297 297 if(isEmpty()) return;
298 298
299 299
300 300 bool visible = m_chartAxis->isVisible();
301 301
302 setArrowVisibility(visible && m_chartAxis->isArrowVisible());
302 setArrowVisibility(visible && m_chartAxis->isLineVisible());
303 303 setGridVisibility(visible && m_chartAxis->isGridLineVisible());
304 304 setLabelsVisibility(visible && m_chartAxis->labelsVisible());
305 305 setShadesVisibility(visible && m_chartAxis->shadesVisible());
306 306 setLabelsAngle(m_chartAxis->labelsAngle());
307 setArrowPen(m_chartAxis->axisPen());
307 setArrowPen(m_chartAxis->linePen());
308 308 setLabelsPen(m_chartAxis->labelsPen());
309 309 setLabelsBrush(m_chartAxis->labelsBrush());
310 310 setLabelsFont(m_chartAxis->labelsFont());
311 311 setGridPen(m_chartAxis->gridLinePen());
312 312 setShadesPen(m_chartAxis->shadesPen());
313 313 setShadesBrush(m_chartAxis->shadesBrush());
314 314
315 315 }
316 316
317 317 void ChartAxis::hide()
318 318 {
319 319 setArrowVisibility(false);
320 320 setGridVisibility(false);
321 321 setLabelsVisibility(false);
322 322 setShadesVisibility(false);
323 323 }
324 324
325 325 void ChartAxis::handleGeometryChanged(const QRectF &rect)
326 326 {
327 327 if(m_rect != rect)
328 328 {
329 329 m_rect = rect;
330 330 if (isEmpty()) return;
331 331 QVector<qreal> layout = calculateLayout();
332 332 updateLayout(layout);
333 333 }
334 334 }
335 335
336 336
337 337 qreal ChartAxis::minimumWidth()
338 338 {
339 339 if(m_minWidth == 0) updateGeometry();
340 340 return m_minWidth;
341 341 }
342 342
343 343 qreal ChartAxis::minimumHeight()
344 344 {
345 345 if(m_minHeight == 0) updateGeometry();
346 346 return m_minHeight;
347 347 }
348 348
349 349
350 350 void ChartAxis::axisSelected()
351 351 {
352 352 qDebug()<<"TODO: axis clicked";
353 353 }
354 354
355 355
356 356 void ChartAxis::createNumberLabels(QStringList &labels,qreal min, qreal max, int ticks) const
357 357 {
358 358 Q_ASSERT(max>min);
359 359 Q_ASSERT(ticks>1);
360 360
361 361 int n = qMax(int(-qFloor(log10((max-min)/(ticks-1)))),0);
362 362 n++;
363 363 for (int i=0; i< ticks; i++) {
364 364 qreal value = min + (i * (max - min)/ (ticks-1));
365 365 labels << QString::number(value,'f',n);
366 366 }
367 367 }
368 368
369 369 #include "moc_chartaxis_p.cpp"
370 370
371 371 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,658 +1,658
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qabstractaxis.h"
22 22 #include "qabstractaxis_p.h"
23 23
24 24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 25
26 26 /*!
27 27 \class QAbstractAxis
28 28 \brief The QAbstractAxis class is used for manipulating chart's axis.
29 29 \mainclass
30 30
31 31 There is only one x Axis visible at the time, however there can be multiple y axes.
32 32 Each chart series can be bound to exactly one Y axis and the shared common X axis.
33 33 Axis can be setup to show axis line with tick marks, grid lines and shades.
34 34 */
35 35
36 36 /*!
37 37 \qmlclass AbstractAxis QAbstractAxis
38 38 \brief The Axis element is used for manipulating chart's axes
39 39
40 40 There is only one x Axis visible at the time, however there can be multiple y axes on a ChartView.
41 41 Each chart series can be bound to exactly one Y axis and the shared common X axis.
42 42 Axis can be setup to show axis line with tick marks, grid lines and shades.
43 43
44 44 To access Axes you can use ChartView API. For example:
45 45 \code
46 46 ChartView {
47 47 axisX.min: 0
48 48 axisX.max: 3
49 49 axisX.ticksCount: 4
50 50 axisY.min: 0
51 51 axisY.max: 4
52 52 // Add a few series...
53 53 }
54 54 \endcode
55 55 */
56 56
57 57 /*!
58 58 \enum QAbstractAxis::AxisType
59 59
60 60 The type of the series object.
61 61
62 62 \value AxisTypeNoAxis
63 63 \value AxisTypeValue
64 64 \value AxisTypeBarCategory
65 65 \value AxisTypeCategory
66 66 \value AxisTypeDateTime
67 67 */
68 68
69 69 /*!
70 70 *\fn void QAbstractAxis::type() const
71 71 Returns the type of the axis
72 72 */
73 73
74 74 /*!
75 75 \property QAbstractAxis::arrowVisible
76 76 The visibility of the axis arrow
77 77 */
78 78 /*!
79 79 \qmlproperty bool AbstractAxis::arrrowVisible
80 80 The visibility of the axis arrow
81 81 */
82 82
83 83 /*!
84 84 \property QAbstractAxis::labelsVisible
85 85 Defines if axis labels are visible.
86 86 */
87 87 /*!
88 88 \qmlproperty bool AbstractAxis::labelsVisible
89 89 Defines if axis labels are visible.
90 90 */
91 91
92 92 /*!
93 93 \property QAbstractAxis::visible
94 94 The visibility of the axis.
95 95 */
96 96 /*!
97 97 \qmlproperty bool AbstractAxis::visible
98 98 The visibility of the axis.
99 99 */
100 100
101 101 /*!
102 102 \property QAbstractAxis::gridVisible
103 103 The visibility of the grid lines.
104 104 */
105 105 /*!
106 106 \qmlproperty bool AbstractAxis::gridVisible
107 107 The visibility of the grid lines.
108 108 */
109 109
110 110 /*!
111 111 \property QAbstractAxis::color
112 112 The color of the axis and ticks.
113 113 */
114 114 /*!
115 115 \qmlproperty color AbstractAxis::color
116 116 The color of the axis and ticks.
117 117 */
118 118
119 119 /*!
120 120 \property QAbstractAxis::labelsFont
121 121 The font of the axis labels.
122 122 */
123 123
124 124 /*!
125 125 \qmlproperty Font AbstractAxis::labelsFont
126 126 The font of the axis labels.
127 127
128 128 See the \l {Font} {QML Font Element} for detailed documentation.
129 129 */
130 130
131 131 /*!
132 132 \property QAbstractAxis::labelsColor
133 133 The color of the axis labels.
134 134 */
135 135 /*!
136 136 \qmlproperty color AbstractAxis::labelsColor
137 137 The color of the axis labels.
138 138 */
139 139
140 140 /*!
141 141 \property QAbstractAxis::labelsAngle
142 142 The angle of the axis labels in degrees.
143 143 */
144 144 /*!
145 145 \qmlproperty int AbstractAxis::labelsAngle
146 146 The angle of the axis labels in degrees.
147 147 */
148 148
149 149 /*!
150 150 \property QAbstractAxis::shadesVisible
151 151 The visibility of the axis shades.
152 152 */
153 153 /*!
154 154 \qmlproperty bool AbstractAxis::shadesVisible
155 155 The visibility of the axis shades.
156 156 */
157 157
158 158 /*!
159 159 \property QAbstractAxis::shadesColor
160 160 The fill (brush) color of the axis shades.
161 161 */
162 162 /*!
163 163 \qmlproperty color AbstractAxis::shadesColor
164 164 The fill (brush) color of the axis shades.
165 165 */
166 166
167 167 /*!
168 168 \property QAbstractAxis::shadesBorderColor
169 169 The border (pen) color of the axis shades.
170 170 */
171 171 /*!
172 172 \qmlproperty color AbstractAxis::shadesBorderColor
173 173 The border (pen) color of the axis shades.
174 174 */
175 175
176 176 /*!
177 177 \fn void QAbstractAxis::visibleChanged(bool visible)
178 178 Visiblity of the axis has changed to \a visible.
179 179 */
180 180 /*!
181 181 \qmlsignal AbstractAxis::onVisibleChanged(bool visible)
182 182 Visiblity of the axis has changed to \a visible.
183 183 */
184 184
185 185 /*!
186 186 \fn void QAbstractAxis::arrowVisibleChanged(bool visible)
187 187 Visiblity of the axis arrow has changed to \a visible.
188 188 */
189 189 /*!
190 190 \qmlsignal AbstractAxis::onArrowVisibleChanged(bool visible)
191 191 Visiblity of the axis arrow has changed to \a visible.
192 192 */
193 193
194 194 /*!
195 195 \fn void QAbstractAxis::labelsVisibleChanged(bool visible)
196 196 Visiblity of the labels of the axis has changed to \a visible.
197 197 */
198 198 /*!
199 199 \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible)
200 200 Visiblity of the labels of the axis has changed to \a visible.
201 201 */
202 202
203 203 /*!
204 204 \fn void QAbstractAxis::gridVisibleChanged(bool visible)
205 205 Visiblity of the grid lines of the axis has changed to \a visible.
206 206 */
207 207 /*!
208 208 \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible)
209 209 Visiblity of the grid lines of the axis has changed to \a visible.
210 210 */
211 211
212 212 /*!
213 213 \fn void QAbstractAxis::colorChanged(QColor color)
214 214 Emitted if the \a color of the axis is changed.
215 215 */
216 216 /*!
217 217 \qmlsignal AbstractAxis::onColorChanged(QColor color)
218 218 Emitted if the \a color of the axis is changed.
219 219 */
220 220
221 221 /*!
222 222 \fn void QAbstractAxis::labelsColorChanged(QColor color)
223 223 Emitted if the \a color of the axis labels is changed.
224 224 */
225 225 /*!
226 226 \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color)
227 227 Emitted if the \a color of the axis labels is changed.
228 228 */
229 229
230 230 /*!
231 231 \fn void QAbstractAxis::shadesVisibleChanged(bool)
232 232 Emitted if the visibility of the axis shades is changed to \a visible.
233 233 */
234 234 /*!
235 235 \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible)
236 236 Emitted if the visibility of the axis shades is changed to \a visible.
237 237 */
238 238
239 239 /*!
240 240 \fn void QAbstractAxis::shadesColorChanged(QColor color)
241 241 Emitted if the \a color of the axis shades is changed.
242 242 */
243 243 /*!
244 244 \qmlsignal AbstractAxis::onShadesColorChanged(QColor color)
245 245 Emitted if the \a color of the axis shades is changed.
246 246 */
247 247
248 248 /*!
249 249 \fn void QAbstractAxis::shadesBorderColorChanged(QColor)
250 250 Emitted if the border \a color of the axis shades is changed.
251 251 */
252 252 /*!
253 253 \qmlsignal AbstractAxis::onBorderColorChanged(QColor color)
254 254 Emitted if the border \a color of the axis shades is changed.
255 255 */
256 256
257 257 /*!
258 258 \internal
259 259 Constructs new axis object which is a child of \a parent. Ownership is taken by
260 260 QChart when axis added.
261 261 */
262 262
263 263 QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) :
264 264 QObject(parent),
265 265 d_ptr(&d)
266 266 {
267 267 }
268 268
269 269 /*!
270 270 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
271 271 */
272 272
273 273 QAbstractAxis::~QAbstractAxis()
274 274 {
275 275 if(d_ptr->m_dataset) qFatal("Still binded axis detected !");
276 276 }
277 277
278 278 /*!
279 279 Sets \a pen used to draw axis line and ticks.
280 280 */
281 void QAbstractAxis::setAxisPen(const QPen &pen)
281 void QAbstractAxis::setLinePen(const QPen &pen)
282 282 {
283 283 if (d_ptr->m_axisPen!=pen) {
284 284 d_ptr->m_axisPen = pen;
285 285 d_ptr->emitUpdated();
286 286 }
287 287 }
288 288
289 289 /*!
290 290 Returns pen used to draw axis and ticks.
291 291 */
292 QPen QAbstractAxis::axisPen() const
292 QPen QAbstractAxis::linePen() const
293 293 {
294 294 return d_ptr->m_axisPen;
295 295 }
296 296
297 void QAbstractAxis::setAxisPenColor(QColor color)
297 void QAbstractAxis::setLinePenColor(QColor color)
298 298 {
299 299 QPen p = d_ptr->m_axisPen;
300 300 if (p.color() != color) {
301 301 p.setColor(color);
302 setAxisPen(p);
302 setLinePen(p);
303 303 emit colorChanged(color);
304 304 }
305 305 }
306 306
307 QColor QAbstractAxis::axisPenColor() const
307 QColor QAbstractAxis::linePenColor() const
308 308 {
309 309 return d_ptr->m_axisPen.color();
310 310 }
311 311
312 312 /*!
313 313 Sets if axis and ticks are \a visible.
314 314 */
315 void QAbstractAxis::setArrowVisible(bool visible)
315 void QAbstractAxis::setLineVisible(bool visible)
316 316 {
317 317 if (d_ptr->m_arrowVisible != visible) {
318 318 d_ptr->m_arrowVisible = visible;
319 319 d_ptr->emitUpdated();
320 emit arrowVisibleChanged(visible);
320 emit lineVisibleChanged(visible);
321 321 }
322 322 }
323 323
324 bool QAbstractAxis::isArrowVisible() const
324 bool QAbstractAxis::isLineVisible() const
325 325 {
326 326 return d_ptr->m_arrowVisible;
327 327 }
328 328
329 329 void QAbstractAxis::setGridLineVisible(bool visible)
330 330 {
331 331 if (d_ptr->m_gridLineVisible != visible) {
332 332 d_ptr->m_gridLineVisible = visible;
333 333 d_ptr->emitUpdated();
334 334 emit gridVisibleChanged(visible);
335 335 }
336 336 }
337 337
338 338 bool QAbstractAxis::isGridLineVisible() const
339 339 {
340 340 return d_ptr->m_gridLineVisible;
341 341 }
342 342
343 343 /*!
344 344 Sets \a pen used to draw grid line.
345 345 */
346 346 void QAbstractAxis::setGridLinePen(const QPen &pen)
347 347 {
348 348 if (d_ptr->m_gridLinePen != pen) {
349 349 d_ptr->m_gridLinePen = pen;
350 350 d_ptr->emitUpdated();
351 351 }
352 352 }
353 353
354 354 /*!
355 355 Returns pen used to draw grid.
356 356 */
357 357 QPen QAbstractAxis::gridLinePen() const
358 358 {
359 359 return d_ptr->m_gridLinePen;
360 360 }
361 361
362 362 void QAbstractAxis::setLabelsVisible(bool visible)
363 363 {
364 364 if (d_ptr->m_labelsVisible != visible) {
365 365 d_ptr->m_labelsVisible = visible;
366 366 d_ptr->emitUpdated();
367 367 emit labelsVisibleChanged(visible);
368 368 }
369 369 }
370 370
371 371 bool QAbstractAxis::labelsVisible() const
372 372 {
373 373 return d_ptr->m_labelsVisible;
374 374 }
375 375
376 376 /*!
377 377 Sets \a pen used to draw labels.
378 378 */
379 379 void QAbstractAxis::setLabelsPen(const QPen &pen)
380 380 {
381 381 if (d_ptr->m_labelsPen != pen) {
382 382 d_ptr->m_labelsPen = pen;
383 383 d_ptr->emitUpdated();
384 384 }
385 385 }
386 386
387 387 /*!
388 388 Returns the pen used to labels.
389 389 */
390 390 QPen QAbstractAxis::labelsPen() const
391 391 {
392 392 return d_ptr->m_labelsPen;
393 393 }
394 394
395 395 /*!
396 396 Sets \a brush used to draw labels.
397 397 */
398 398 void QAbstractAxis::setLabelsBrush(const QBrush &brush)
399 399 {
400 400 if (d_ptr->m_labelsBrush != brush) {
401 401 d_ptr->m_labelsBrush = brush;
402 402 d_ptr->emitUpdated();
403 403 }
404 404 }
405 405
406 406 /*!
407 407 Returns brush used to draw labels.
408 408 */
409 409 QBrush QAbstractAxis::labelsBrush() const
410 410 {
411 411 return d_ptr->m_labelsBrush;
412 412 }
413 413
414 414 /*!
415 415 Sets \a font used to draw labels.
416 416 */
417 417 void QAbstractAxis::setLabelsFont(const QFont &font)
418 418 {
419 419 if (d_ptr->m_labelsFont != font) {
420 420 d_ptr->m_labelsFont = font;
421 421 d_ptr->emitUpdated();
422 422 }
423 423 }
424 424
425 425 /*!
426 426 Returns font used to draw labels.
427 427 */
428 428 QFont QAbstractAxis::labelsFont() const
429 429 {
430 430 return d_ptr->m_labelsFont;
431 431 }
432 432
433 433 void QAbstractAxis::setLabelsAngle(int angle)
434 434 {
435 435 if (d_ptr->m_labelsAngle != angle) {
436 436 d_ptr->m_labelsAngle = angle;
437 437 d_ptr->emitUpdated();
438 438 }
439 439 }
440 440
441 441 int QAbstractAxis::labelsAngle() const
442 442 {
443 443 return d_ptr->m_labelsAngle;
444 444 }
445 445
446 446 void QAbstractAxis::setLabelsColor(QColor color)
447 447 {
448 448 QBrush b = d_ptr->m_labelsBrush;
449 449 if (b.color() != color) {
450 450 b.setColor(color);
451 451 setLabelsBrush(b);
452 452 emit labelsColorChanged(color);
453 453 }
454 454 }
455 455
456 456 QColor QAbstractAxis::labelsColor() const
457 457 {
458 458 return d_ptr->m_labelsBrush.color();
459 459 }
460 460
461 461 void QAbstractAxis::setShadesVisible(bool visible)
462 462 {
463 463 if (d_ptr->m_shadesVisible != visible) {
464 464 d_ptr->m_shadesVisible = visible;
465 465 d_ptr->emitUpdated();
466 466 emit shadesVisibleChanged(visible);
467 467 }
468 468 }
469 469
470 470 bool QAbstractAxis::shadesVisible() const
471 471 {
472 472 return d_ptr->m_shadesVisible;
473 473 }
474 474
475 475 /*!
476 476 Sets \a pen used to draw shades.
477 477 */
478 478 void QAbstractAxis::setShadesPen(const QPen &pen)
479 479 {
480 480 if (d_ptr->m_shadesPen != pen) {
481 481 d_ptr->m_shadesPen = pen;
482 482 d_ptr->emitUpdated();
483 483 }
484 484 }
485 485
486 486 /*!
487 487 Returns pen used to draw shades.
488 488 */
489 489 QPen QAbstractAxis::shadesPen() const
490 490 {
491 491 return d_ptr->m_shadesPen;
492 492 }
493 493
494 494 /*!
495 495 Sets \a brush used to draw shades.
496 496 */
497 497 void QAbstractAxis::setShadesBrush(const QBrush &brush)
498 498 {
499 499 if (d_ptr->m_shadesBrush != brush) {
500 500 d_ptr->m_shadesBrush = brush;
501 501 d_ptr->emitUpdated();
502 502 emit shadesColorChanged(brush.color());
503 503 }
504 504 }
505 505
506 506 /*!
507 507 Returns brush used to draw shades.
508 508 */
509 509 QBrush QAbstractAxis::shadesBrush() const
510 510 {
511 511 return d_ptr->m_shadesBrush;
512 512 }
513 513
514 514 void QAbstractAxis::setShadesColor(QColor color)
515 515 {
516 516 QBrush b = d_ptr->m_shadesBrush;
517 517 b.setColor(color);
518 518 setShadesBrush(b);
519 519 }
520 520
521 521 QColor QAbstractAxis::shadesColor() const
522 522 {
523 523 return d_ptr->m_shadesBrush.color();
524 524 }
525 525
526 526 void QAbstractAxis::setShadesBorderColor(QColor color)
527 527 {
528 528 QPen p = d_ptr->m_shadesPen;
529 529 p.setColor(color);
530 530 setShadesPen(p);
531 531 }
532 532
533 533 QColor QAbstractAxis::shadesBorderColor() const
534 534 {
535 535 return d_ptr->m_shadesPen.color();
536 536 }
537 537
538 538
539 539 bool QAbstractAxis::isVisible() const
540 540 {
541 541 return d_ptr->m_visible;
542 542 }
543 543
544 544 /*!
545 545 Sets axis, shades, labels and grid lines to be visible.
546 546 */
547 547 void QAbstractAxis::setVisible(bool visible)
548 548 {
549 549 if(d_ptr->m_visible!=visible){
550 550 d_ptr->m_visible=visible;
551 551 d_ptr->emitUpdated();
552 552 emit visibleChanged(visible);
553 553 }
554 554 }
555 555
556 556
557 557 /*!
558 558 Sets axis, shades, labels and grid lines to be visible.
559 559 */
560 560 void QAbstractAxis::show()
561 561 {
562 562 setVisible(true);
563 563 }
564 564
565 565 /*!
566 566 Sets axis, shades, labels and grid lines to not be visible.
567 567 */
568 568 void QAbstractAxis::hide()
569 569 {
570 570 setVisible(false);
571 571 }
572 572
573 573 /*!
574 574 Sets the minimum value shown on the axis.
575 575 Depending on the actual axis type the \a min paramter is converted to appropriate type.
576 576 If the conversion is impossible then the function call does nothing
577 577 */
578 578 void QAbstractAxis::setMin(const QVariant &min)
579 579 {
580 580 d_ptr->setMin(min);
581 581 }
582 582
583 583 /*!
584 584 Sets the maximum value shown on the axis.
585 585 Depending on the actual axis type the \a max paramter is converted to appropriate type.
586 586 If the conversion is impossible then the function call does nothing
587 587 */
588 588 void QAbstractAxis::setMax(const QVariant &max)
589 589 {
590 590 d_ptr->setMax(max);
591 591 }
592 592
593 593 /*!
594 594 Sets the range shown on the axis.
595 595 Depending on the actual axis type the \a min and \a max paramters are converted to appropriate types.
596 596 If the conversion is impossible then the function call does nothing.
597 597 */
598 598 void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
599 599 {
600 600 d_ptr->setRange(min,max);
601 601 }
602 602
603 603
604 604 /*!
605 605 Returns the orientation in which the axis is being used (Vertical or Horizontal)
606 606 */
607 607 Qt::Orientation QAbstractAxis::orientation()
608 608 {
609 609 return d_ptr->m_orientation;
610 610 }
611 611
612 612 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
613 613
614 614 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q):
615 615 q_ptr(q),
616 616 m_orientation(Qt::Orientation(0)),
617 617 m_dataset(0),
618 618 m_visible(false),
619 619 m_arrowVisible(true),
620 620 m_gridLineVisible(true),
621 621 m_labelsVisible(true),
622 622 m_labelsAngle(0),
623 623 m_shadesVisible(false),
624 624 m_shadesBrush(Qt::SolidPattern),
625 625 m_shadesOpacity(1.0),
626 626 m_dirty(false)
627 627 {
628 628
629 629 }
630 630
631 631 QAbstractAxisPrivate::~QAbstractAxisPrivate()
632 632 {
633 633
634 634 }
635 635
636 636 void QAbstractAxisPrivate::emitUpdated()
637 637 {
638 638 if(!m_dirty){
639 639 m_dirty=true;
640 640 emit updated();
641 641 }
642 642 }
643 643
644 644 void QAbstractAxisPrivate::setDirty(bool dirty)
645 645 {
646 646 m_dirty=dirty;
647 647 }
648 648
649 649 void QAbstractAxisPrivate::setOrientation(Qt::Orientation orientation)
650 650 {
651 651 m_orientation=orientation;
652 652 }
653 653
654 654
655 655 #include "moc_qabstractaxis.cpp"
656 656 #include "moc_qabstractaxis_p.cpp"
657 657
658 658 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,143 +1,143
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef QABSTRACTAXIS_H
22 22 #define QABSTRACTAXIS_H
23 23
24 24 #include <qchartglobal.h>
25 25 #include <QPen>
26 26 #include <QFont>
27 27 #include <QVariant>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 class QAbstractAxisPrivate;
32 32
33 33 class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject
34 34 {
35 35 Q_OBJECT
36 36 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
37 Q_PROPERTY(bool arrowVisible READ isArrowVisible WRITE setArrowVisible NOTIFY arrowVisibleChanged)
38 Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged)
37 Q_PROPERTY(bool arrowVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged)
38 Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged)
39 39 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
40 40 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle)
41 41 Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont)
42 42 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
43 43 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
44 44 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
45 45 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
46 46 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
47 47
48 48 public:
49 49
50 50 enum AxisType {
51 51 AxisTypeNoAxis = 0x0,
52 52 AxisTypeValue = 0x1,
53 53 AxisTypeBarCategory = 0x2,
54 54 AxisTypeCategory = 0x3,
55 55 AxisTypeDateTime = 0x4
56 56 };
57 57
58 58 Q_DECLARE_FLAGS(AxisTypes, AxisType)
59 59
60 60 protected:
61 61 explicit QAbstractAxis(QAbstractAxisPrivate &d,QObject *parent = 0);
62 62
63 63 public:
64 64 ~QAbstractAxis();
65 65
66 66 virtual AxisType type() const = 0;
67 67
68 68 //visibilty hadnling
69 69 bool isVisible() const;
70 70 void setVisible(bool visible = true);
71 71
72 72
73 73 //axis handling
74 bool isArrowVisible() const;
75 void setArrowVisible(bool visible = true);
76 void setAxisPen(const QPen &pen);
77 QPen axisPen() const;
78 void setAxisPenColor(QColor color);
79 QColor axisPenColor() const;
74 bool isLineVisible() const;
75 void setLineVisible(bool visible = true);
76 void setLinePen(const QPen &pen);
77 QPen linePen() const;
78 void setLinePenColor(QColor color);
79 QColor linePenColor() const;
80 80
81 81 //grid handling
82 82 bool isGridLineVisible() const;
83 83 void setGridLineVisible(bool visible = true);
84 84 void setGridLinePen(const QPen &pen);
85 85 QPen gridLinePen() const;
86 86
87 87 //labels handling
88 88 bool labelsVisible() const;
89 89 void setLabelsVisible(bool visible = true);
90 90 void setLabelsPen(const QPen &pen);
91 91 QPen labelsPen() const;
92 92 void setLabelsBrush(const QBrush &brush);
93 93 QBrush labelsBrush() const;
94 94 void setLabelsFont(const QFont &font);
95 95 QFont labelsFont() const;
96 96 void setLabelsAngle(int angle);
97 97 int labelsAngle() const;
98 98 void setLabelsColor(QColor color);
99 99 QColor labelsColor() const;
100 100
101 101 //shades handling
102 102 bool shadesVisible() const;
103 103 void setShadesVisible(bool visible = true);
104 104 void setShadesPen(const QPen &pen);
105 105 QPen shadesPen() const;
106 106 void setShadesBrush(const QBrush &brush);
107 107 QBrush shadesBrush() const;
108 108 void setShadesColor(QColor color);
109 109 QColor shadesColor() const;
110 110 void setShadesBorderColor(QColor color);
111 111 QColor shadesBorderColor() const;
112 112
113 113 Qt::Orientation orientation();
114 114
115 115 //range handling
116 116 void setMin(const QVariant &min);
117 117 void setMax(const QVariant &max);
118 118 void setRange(const QVariant &min, const QVariant &max);
119 119
120 120 void show();
121 121 void hide();
122 122
123 123 Q_SIGNALS:
124 124 void visibleChanged(bool visible);
125 void arrowVisibleChanged(bool visible);
125 void lineVisibleChanged(bool visible);
126 126 void labelsVisibleChanged(bool visible);
127 127 void gridVisibleChanged(bool visible);
128 128 void colorChanged(QColor color);
129 129 void labelsColorChanged(QColor color);
130 130 void shadesVisibleChanged(bool visible);
131 131 void shadesColorChanged(QColor color);
132 132 void shadesBorderColorChanged(QColor color);
133 133
134 134 protected:
135 135 QScopedPointer<QAbstractAxisPrivate> d_ptr;
136 136 Q_DISABLE_COPY(QAbstractAxis)
137 137 friend class ChartDataSet;
138 138 friend class ChartAxis;
139 139 friend class ChartPresenter;
140 140 };
141 141
142 142 QTCOMMERCIALCHART_END_NAMESPACE
143 143 #endif
@@ -1,393 +1,393
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "charttheme_p.h"
22 22 #include "qchart.h"
23 23 #include "qchart_p.h"
24 24 #include "qchartview.h"
25 25 #include "qlegend.h"
26 26 #include "qabstractaxis.h"
27 27 #include <QTime>
28 28
29 29 //series
30 30 #include "qbarset.h"
31 31 #include "qabstractbarseries.h"
32 32 #include "qstackedbarseries.h"
33 33 #include "qpercentbarseries.h"
34 34 #include "qlineseries.h"
35 35 #include "qareaseries.h"
36 36 #include "qscatterseries.h"
37 37 #include "qpieseries.h"
38 38 #include "qpieslice.h"
39 39 #include "qpieslice_p.h"
40 40 #include "qsplineseries.h"
41 41
42 42 //items
43 43 #include "chartaxis_p.h"
44 44 #include "abstractbarchartitem_p.h"
45 45 #include "stackedbarchartitem_p.h"
46 46 #include "percentbarchartitem_p.h"
47 47 #include "linechartitem_p.h"
48 48 #include "areachartitem_p.h"
49 49 #include "scatterchartitem_p.h"
50 50 #include "piechartitem_p.h"
51 51 #include "splinechartitem_p.h"
52 52
53 53 //themes
54 54 #include "chartthemesystem_p.h"
55 55 #include "chartthemelight_p.h"
56 56 #include "chartthemebluecerulean_p.h"
57 57 #include "chartthemedark_p.h"
58 58 #include "chartthemebrownsand_p.h"
59 59 #include "chartthemebluencs_p.h"
60 60 #include "chartthemehighcontrast_p.h"
61 61 #include "chartthemeblueicy_p.h"
62 62
63 63 QTCOMMERCIALCHART_BEGIN_NAMESPACE
64 64
65 65 ChartTheme::ChartTheme(QChart::ChartTheme id) :
66 66 m_masterFont(QFont("arial", 14)),
67 67 m_labelFont(QFont("arial", 10)),
68 68 m_labelBrush(QColor(QRgb(0x000000))),
69 69 m_axisLinePen(QPen(QRgb(0x000000))),
70 70 m_backgroundShadesPen(Qt::NoPen),
71 71 m_backgroundShadesBrush(Qt::NoBrush),
72 72 m_backgroundShades(BackgroundShadesNone),
73 73 m_backgroundDropShadowEnabled(false),
74 74 m_gridLinePen(QPen(QRgb(0x000000))),
75 75 m_force(false)
76 76 {
77 77 m_id = id;
78 78 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
79 79 }
80 80
81 81
82 82 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
83 83 {
84 84 switch(theme) {
85 85 case QChart::ChartThemeLight:
86 86 return new ChartThemeLight();
87 87 case QChart::ChartThemeBlueCerulean:
88 88 return new ChartThemeBlueCerulean();
89 89 case QChart::ChartThemeDark:
90 90 return new ChartThemeDark();
91 91 case QChart::ChartThemeBrownSand:
92 92 return new ChartThemeBrownSand();
93 93 case QChart::ChartThemeBlueNcs:
94 94 return new ChartThemeBlueNcs();
95 95 case QChart::ChartThemeHighContrast:
96 96 return new ChartThemeHighContrast();
97 97 case QChart::ChartThemeBlueIcy:
98 98 return new ChartThemeBlueIcy();
99 99 default:
100 100 return new ChartThemeSystem();
101 101 }
102 102 }
103 103
104 104 void ChartTheme::decorate(QChart *chart)
105 105 {
106 106 QBrush brush;
107 107
108 108 if(m_force || brush == chart->backgroundBrush())
109 109 chart->setBackgroundBrush(m_chartBackgroundGradient);
110 110 chart->setTitleFont(m_masterFont);
111 111 chart->setTitleBrush(m_labelBrush);
112 112 chart->setDropShadowEnabled(m_backgroundDropShadowEnabled);
113 113 }
114 114
115 115 void ChartTheme::decorate(QLegend *legend)
116 116 {
117 117 QPen pen;
118 118 QBrush brush;
119 119 QFont font;
120 120
121 121 if (m_force || pen == legend->pen())
122 122 legend->setPen(m_axisLinePen);
123 123
124 124 if (m_force || brush == legend->brush())
125 125 legend->setBrush(m_chartBackgroundGradient);
126 126
127 127 if (m_force || font == legend->font())
128 128 legend->setFont(m_labelFont);
129 129
130 130 if (m_force || brush == legend->labelBrush())
131 131 legend->setLabelBrush(m_labelBrush);
132 132 }
133 133
134 134 void ChartTheme::decorate(QAreaSeries *series, int index)
135 135 {
136 136 QPen pen;
137 137 QBrush brush;
138 138
139 139 if (m_force || pen == series->pen()){
140 140 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
141 141 pen.setWidthF(2);
142 142 series->setPen(pen);
143 143 }
144 144
145 145 if (m_force || brush == series->brush()) {
146 146 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
147 147 series->setBrush(brush);
148 148 }
149 149 }
150 150
151 151
152 152 void ChartTheme::decorate(QLineSeries *series,int index)
153 153 {
154 154 QPen pen;
155 155 if(m_force || pen == series->pen()){
156 156 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
157 157 pen.setWidthF(2);
158 158 series->setPen(pen);
159 159 }
160 160 }
161 161
162 162 void ChartTheme::decorate(QAbstractBarSeries *series, int index)
163 163 {
164 164 QBrush brush;
165 165 QPen pen;
166 166 QList<QBarSet *> sets = series->barSets();
167 167
168 168 qreal takeAtPos = 0.5;
169 169 qreal step = 0.2;
170 170 if (sets.count() > 1 ) {
171 171 step = 1.0 / (qreal) sets.count();
172 172 if (sets.count() % m_seriesGradients.count())
173 173 step *= m_seriesGradients.count();
174 174 else
175 175 step *= (m_seriesGradients.count() - 1);
176 176 }
177 177
178 178 for (int i(0); i < sets.count(); i++) {
179 179 int colorIndex = (index + i) % m_seriesGradients.count();
180 180 if (i > 0 && i % m_seriesGradients.count() == 0) {
181 181 // There is no dedicated base color for each sets, generate more colors
182 182 takeAtPos += step;
183 183 if (takeAtPos == 1.0)
184 184 takeAtPos += step;
185 185 takeAtPos -= (int) takeAtPos;
186 186 }
187 187 if (m_force || brush == sets.at(i)->brush())
188 188 sets.at(i)->setBrush(colorAt(m_seriesGradients.at(colorIndex), takeAtPos));
189 189
190 190 // Pick label color from the opposite end of the gradient.
191 191 // 0.3 as a boundary seems to work well.
192 192 if (m_force || brush == sets.at(i)->labelBrush()) {
193 193 if (takeAtPos < 0.3)
194 194 sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1));
195 195 else
196 196 sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0));
197 197 }
198 198
199 199 if (m_force || pen == sets.at(i)->pen()) {
200 200 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
201 201 sets.at(i)->setPen(c);
202 202 }
203 203 }
204 204 }
205 205
206 206 void ChartTheme::decorate(QScatterSeries *series, int index)
207 207 {
208 208 QPen pen;
209 209 QBrush brush;
210 210
211 211 if (m_force || pen == series->pen()) {
212 212 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
213 213 pen.setWidthF(2);
214 214 series->setPen(pen);
215 215 }
216 216
217 217 if (m_force || brush == series->brush()) {
218 218 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
219 219 series->setBrush(brush);
220 220 }
221 221 }
222 222
223 223 void ChartTheme::decorate(QPieSeries *series, int index)
224 224 {
225 225
226 226 for (int i(0); i < series->slices().count(); i++) {
227 227
228 228 QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
229 229
230 230 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
231 231 qreal pos = (qreal) (i + 1) / (qreal) series->count();
232 232 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
233 233
234 234 QPieSlice *s = series->slices().at(i);
235 235 QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s);
236 236
237 237 if (m_force || d->m_data.m_slicePen.isThemed())
238 238 d->setPen(penColor, true);
239 239
240 240 if (m_force || d->m_data.m_sliceBrush.isThemed())
241 241 d->setBrush(brushColor, true);
242 242
243 243 if (m_force || d->m_data.m_labelBrush.isThemed())
244 244 d->setLabelBrush(m_labelBrush.color(), true);
245 245
246 246 if (m_force || d->m_data.m_labelFont.isThemed())
247 247 d->setLabelFont(m_labelFont, true);
248 248 }
249 249 }
250 250
251 251 void ChartTheme::decorate(QSplineSeries *series, int index)
252 252 {
253 253 QPen pen;
254 254 if(m_force || pen == series->pen()){
255 255 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
256 256 pen.setWidthF(2);
257 257 series->setPen(pen);
258 258 }
259 259 }
260 260
261 261 void ChartTheme::decorate(QAbstractAxis *axis)
262 262 {
263 263 QPen pen;
264 264 QBrush brush;
265 265 QFont font;
266 266
267 267 bool axisX = axis->orientation()== Qt::Horizontal;
268 268
269 if (axis->isArrowVisible()) {
269 if (axis->isLineVisible()) {
270 270
271 271 if(m_force || brush == axis->labelsBrush()){
272 272 axis->setLabelsBrush(m_labelBrush);
273 273 }
274 274 if(m_force || pen == axis->labelsPen()){
275 275 axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
276 276 }
277 277
278 278
279 279 if (m_force || axis->shadesVisible()) {
280 280
281 281 if(m_force || brush == axis->shadesBrush()){
282 282 axis->setShadesBrush(m_backgroundShadesBrush);
283 283 }
284 284
285 285 if(m_force || pen == axis->shadesPen()){
286 286 axis->setShadesPen(m_backgroundShadesPen);
287 287 }
288 288
289 289 if( m_force && (m_backgroundShades == BackgroundShadesBoth
290 290 || (m_backgroundShades == BackgroundShadesVertical && axisX)
291 291 || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){
292 292 axis->setShadesVisible(true);
293 293
294 294 }
295 295 }
296 296
297 if(m_force || pen == axis->axisPen()){
298 axis->setAxisPen(m_axisLinePen);
297 if(m_force || pen == axis->linePen()){
298 axis->setLinePen(m_axisLinePen);
299 299 }
300 300
301 301 if(m_force || pen == axis->gridLinePen()){
302 302 axis->setGridLinePen(m_gridLinePen);
303 303 }
304 304
305 305 if(m_force || font == axis->labelsFont()){
306 306 axis->setLabelsFont(m_labelFont);
307 307 }
308 308 }
309 309 }
310 310
311 311 void ChartTheme::generateSeriesGradients()
312 312 {
313 313 // Generate gradients in HSV color space
314 314 foreach (const QColor& color, m_seriesColors) {
315 315 QLinearGradient g;
316 316 qreal h = color.hsvHueF();
317 317 qreal s = color.hsvSaturationF();
318 318
319 319 // TODO: tune the algorithm to give nice results with most base colors defined in
320 320 // most themes. The rest of the gradients we can define manually in theme specific
321 321 // implementation.
322 322 QColor start = color;
323 323 start.setHsvF(h, 0.0, 1.0);
324 324 g.setColorAt(0.0, start);
325 325
326 326 g.setColorAt(0.5, color);
327 327
328 328 QColor end = color;
329 329 end.setHsvF(h, s, 0.25);
330 330 g.setColorAt(1.0, end);
331 331
332 332 m_seriesGradients << g;
333 333 }
334 334 }
335 335
336 336
337 337 QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos)
338 338 {
339 339 Q_ASSERT(pos >= 0.0 && pos <= 1.0);
340 340 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
341 341 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
342 342 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
343 343 QColor c;
344 344 c.setRgbF(r, g, b);
345 345 return c;
346 346 }
347 347
348 348 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
349 349 {
350 350 Q_ASSERT(pos >= 0 && pos <= 1.0);
351 351
352 352 QGradientStops stops = gradient.stops();
353 353 int count = stops.count();
354 354
355 355 // find previous stop relative to position
356 356 QGradientStop prev = stops.first();
357 357 for (int i = 0; i < count; i++) {
358 358 QGradientStop stop = stops.at(i);
359 359 if (pos > stop.first)
360 360 prev = stop;
361 361
362 362 // given position is actually a stop position?
363 363 if (pos == stop.first) {
364 364 //qDebug() << "stop color" << pos;
365 365 return stop.second;
366 366 }
367 367 }
368 368
369 369 // find next stop relative to position
370 370 QGradientStop next = stops.last();
371 371 for (int i = count - 1; i >= 0; i--) {
372 372 QGradientStop stop = stops.at(i);
373 373 if (pos < stop.first)
374 374 next = stop;
375 375 }
376 376
377 377 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
378 378
379 379 qreal range = next.first - prev.first;
380 380 qreal posDelta = pos - prev.first;
381 381 qreal relativePos = posDelta / range;
382 382
383 383 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
384 384
385 385 return colorAt(prev.second, next.second, relativePos);
386 386 }
387 387
388 388 void ChartTheme::setForced(bool enabled)
389 389 {
390 390 m_force = enabled;
391 391 }
392 392
393 393 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,847 +1,847
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "tst_qabstractaxis.h"
22 22
23 23 Q_DECLARE_METATYPE(QPen)
24 24 Q_DECLARE_METATYPE(Qt::Orientation)
25 25
26 26 void tst_QAbstractAxis::initTestCase()
27 27 {
28 28 }
29 29
30 30 void tst_QAbstractAxis::cleanupTestCase()
31 31 {
32 32 }
33 33
34 34 void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series)
35 35 {
36 36 m_axis = axis;
37 37 m_series = series;
38 38 m_view = new QChartView(new QChart());
39 39 m_chart = m_view->chart();
40 40 }
41 41
42 42 void tst_QAbstractAxis::cleanup()
43 43 {
44 44 delete m_view;
45 45 m_view = 0;
46 46 m_chart = 0;
47 47 m_axis = 0;
48 48 }
49 49
50 50 void tst_QAbstractAxis::qabstractaxis()
51 51 {
52 QCOMPARE(m_axis->axisPen(), QPen());
52 QCOMPARE(m_axis->linePen(), QPen());
53 53 //TODO QCOMPARE(m_axis->axisPenColor(), QColor());
54 54 QCOMPARE(m_axis->gridLinePen(), QPen());
55 QCOMPARE(m_axis->isArrowVisible(), true);
55 QCOMPARE(m_axis->isLineVisible(), true);
56 56 QCOMPARE(m_axis->isGridLineVisible(), true);
57 57 QCOMPARE(m_axis->isVisible(), false);
58 58 QCOMPARE(m_axis->labelsAngle(), 0);
59 59 QCOMPARE(m_axis->labelsBrush(), QBrush());
60 60 //TODO QCOMPARE(m_axis->labelsColor(), QColor());
61 61 QCOMPARE(m_axis->labelsFont(), QFont());
62 62 QCOMPARE(m_axis->labelsPen(), QPen());
63 63 QCOMPARE(m_axis->labelsVisible(), true);
64 64 QCOMPARE(m_axis->orientation(), Qt::Orientation(0));
65 m_axis->setArrowVisible(false);
66 m_axis->setAxisPen(QPen());
67 m_axis->setAxisPenColor(QColor());
65 m_axis->setLineVisible(false);
66 m_axis->setLinePen(QPen());
67 m_axis->setLinePenColor(QColor());
68 68 m_axis->setGridLinePen(QPen());
69 69 m_axis->setGridLineVisible(false);
70 70 m_axis->setLabelsAngle(-1);
71 71 m_axis->setLabelsBrush(QBrush());
72 72 m_axis->setLabelsColor(QColor());
73 73 m_axis->setLabelsFont(QFont());
74 74 m_axis->setLabelsPen(QPen());
75 75 m_axis->setLabelsVisible(false);
76 76 m_axis->setMax(QVariant());
77 77 m_axis->setMin(QVariant());
78 78 m_axis->setRange(QVariant(), QVariant());
79 79 m_axis->setShadesBorderColor(QColor());
80 80 m_axis->setShadesBrush(QBrush());
81 81 m_axis->setShadesColor(QColor());
82 82 m_axis->setShadesPen(QPen());
83 83 m_axis->setShadesVisible(false);
84 84 m_axis->setVisible(false);
85 85 //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor());
86 86 //TODO QCOMPARE(m_axis->shadesBrush(), QBrush());
87 87 //TODO QCOMPARE(m_axis->shadesColor(), QColor());
88 88 QCOMPARE(m_axis->shadesPen(), QPen());
89 89 QCOMPARE(m_axis->shadesVisible(), false);
90 90 m_axis->show();
91 91 m_axis->hide();
92 92 }
93 93
94 94 void tst_QAbstractAxis::axisPen_data()
95 95 {
96 96 QTest::addColumn<QPen>("axisPen");
97 97 QTest::newRow("null") << QPen();
98 98 QTest::newRow("blue") << QPen(Qt::blue);
99 99 QTest::newRow("black") << QPen(Qt::black);
100 100 QTest::newRow("red") << QPen(Qt::red);
101 101 }
102 102
103 103 void tst_QAbstractAxis::axisPen()
104 104 {
105 105 QFETCH(QPen, axisPen);
106 106
107 107 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
108 108 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
109 109 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
110 110 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
111 111 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
112 112 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
113 113 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
114 114 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
115 115 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
116 116
117 m_axis->setAxisPen(axisPen);
118 QCOMPARE(m_axis->axisPen(), axisPen);
117 m_axis->setLinePen(axisPen);
118 QCOMPARE(m_axis->linePen(), axisPen);
119 119
120 120 QCOMPARE(spy0.count(), 0);
121 121 QCOMPARE(spy1.count(), 0);
122 122 QCOMPARE(spy2.count(), 0);
123 123 QCOMPARE(spy3.count(), 0);
124 124 QCOMPARE(spy4.count(), 0);
125 125 QCOMPARE(spy5.count(), 0);
126 126 QCOMPARE(spy6.count(), 0);
127 127 QCOMPARE(spy7.count(), 0);
128 128 QCOMPARE(spy8.count(), 0);
129 129
130 130 m_chart->setAxisX(m_axis, m_series);
131 131 m_view->show();
132 132 QTest::qWaitForWindowShown(m_view);
133 133 //TODO QCOMPARE(m_axis->axisPen(), axisPen);
134 134 }
135 135
136 136 void tst_QAbstractAxis::axisPenColor_data()
137 137 {
138 138 }
139 139
140 140 void tst_QAbstractAxis::axisPenColor()
141 141 {
142 142 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
143 143 }
144 144
145 145 void tst_QAbstractAxis::gridLinePen_data()
146 146 {
147 147
148 148 QTest::addColumn<QPen>("gridLinePen");
149 149 QTest::newRow("null") << QPen();
150 150 QTest::newRow("blue") << QPen(Qt::blue);
151 151 QTest::newRow("black") << QPen(Qt::black);
152 152 QTest::newRow("red") << QPen(Qt::red);
153 153
154 154 }
155 155
156 156 void tst_QAbstractAxis::gridLinePen()
157 157 {
158 158 QFETCH(QPen, gridLinePen);
159 159
160 160 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
161 161 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
162 162 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
163 163 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
164 164 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
165 165 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
166 166 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
167 167 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
168 168 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
169 169
170 170 m_axis->setGridLinePen(gridLinePen);
171 171 QCOMPARE(m_axis->gridLinePen(), gridLinePen);
172 172
173 173 QCOMPARE(spy0.count(), 0);
174 174 QCOMPARE(spy1.count(), 0);
175 175 QCOMPARE(spy2.count(), 0);
176 176 QCOMPARE(spy3.count(), 0);
177 177 QCOMPARE(spy4.count(), 0);
178 178 QCOMPARE(spy5.count(), 0);
179 179 QCOMPARE(spy6.count(), 0);
180 180 QCOMPARE(spy7.count(), 0);
181 181 QCOMPARE(spy8.count(), 0);
182 182
183 183 m_chart->setAxisX(m_axis, m_series);
184 184 m_view->show();
185 185 QTest::qWaitForWindowShown(m_view);
186 186 //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen);
187 187 }
188 188
189 189 void tst_QAbstractAxis::arrowVisible_data()
190 190 {
191 191 QTest::addColumn<bool>("arrowVisible");
192 192 QTest::newRow("true") << true;
193 193 QTest::newRow("false") << false;
194 194 }
195 195
196 196 void tst_QAbstractAxis::arrowVisible()
197 197 {
198 198 QFETCH(bool, arrowVisible);
199 199
200 m_axis->setArrowVisible(!arrowVisible);
200 m_axis->setLineVisible(!arrowVisible);
201 201
202 202 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
203 203 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
204 204 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
205 205 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
206 206 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
207 207 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
208 208 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
209 209 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
210 210 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
211 211
212 m_axis->setArrowVisible(arrowVisible);
213 QCOMPARE(m_axis->isArrowVisible(), arrowVisible);
212 m_axis->setLineVisible(arrowVisible);
213 QCOMPARE(m_axis->isLineVisible(), arrowVisible);
214 214
215 215 QCOMPARE(spy0.count(), 1);
216 216 QCOMPARE(spy1.count(), 0);
217 217 QCOMPARE(spy2.count(), 0);
218 218 QCOMPARE(spy3.count(), 0);
219 219 QCOMPARE(spy4.count(), 0);
220 220 QCOMPARE(spy5.count(), 0);
221 221 QCOMPARE(spy6.count(), 0);
222 222 QCOMPARE(spy7.count(), 0);
223 223 QCOMPARE(spy8.count(), 0);
224 224
225 225 m_chart->setAxisX(m_axis, m_series);
226 226 m_view->show();
227 227 QTest::qWaitForWindowShown(m_view);
228 QCOMPARE(m_axis->isArrowVisible(), arrowVisible);
228 QCOMPARE(m_axis->isLineVisible(), arrowVisible);
229 229 }
230 230
231 231 void tst_QAbstractAxis::gridLineVisible_data()
232 232 {
233 233 QTest::addColumn<bool>("gridLineVisible");
234 234 QTest::newRow("true") << true;
235 235 QTest::newRow("false") << false;
236 236 }
237 237
238 238 void tst_QAbstractAxis::gridLineVisible()
239 239 {
240 240 QFETCH(bool, gridLineVisible);
241 241
242 242 m_axis->setGridLineVisible(!gridLineVisible);
243 243
244 244 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
245 245 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
246 246 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
247 247 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
248 248 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
249 249 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
250 250 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
251 251 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
252 252 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
253 253
254 254 m_axis->setGridLineVisible(gridLineVisible);
255 255 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
256 256
257 257 QCOMPARE(spy0.count(), 0);
258 258 QCOMPARE(spy1.count(), 0);
259 259 QCOMPARE(spy2.count(), 1);
260 260 QCOMPARE(spy3.count(), 0);
261 261 QCOMPARE(spy4.count(), 0);
262 262 QCOMPARE(spy5.count(), 0);
263 263 QCOMPARE(spy6.count(), 0);
264 264 QCOMPARE(spy7.count(), 0);
265 265 QCOMPARE(spy8.count(), 0);
266 266
267 267 m_chart->setAxisX(m_axis, m_series);
268 268 m_view->show();
269 269 QTest::qWaitForWindowShown(m_view);
270 270 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
271 271
272 272 }
273 273
274 274 void tst_QAbstractAxis::visible_data()
275 275 {
276 276 QTest::addColumn<bool>("visible");
277 277 QTest::newRow("true") << true;
278 278 QTest::newRow("false") << false;
279 279 }
280 280
281 281 void tst_QAbstractAxis::visible()
282 282 {
283 283 QFETCH(bool, visible);
284 284
285 285 m_axis->setVisible(!visible);
286 286
287 287 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
288 288 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
289 289 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
290 290 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
291 291 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
292 292 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
293 293 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
294 294 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
295 295 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
296 296
297 297 m_axis->setVisible(visible);
298 298 QCOMPARE(m_axis->isVisible(), visible);
299 299
300 300 QCOMPARE(spy0.count(), 0);
301 301 QCOMPARE(spy1.count(), 0);
302 302 QCOMPARE(spy2.count(), 0);
303 303 QCOMPARE(spy3.count(), 0);
304 304 QCOMPARE(spy4.count(), 0);
305 305 QCOMPARE(spy5.count(), 0);
306 306 QCOMPARE(spy6.count(), 0);
307 307 QCOMPARE(spy7.count(), 0);
308 308 QCOMPARE(spy8.count(), 1);
309 309
310 310 m_chart->setAxisX(m_axis, m_series);
311 311 m_view->show();
312 312 QTest::qWaitForWindowShown(m_view);
313 313 QCOMPARE(m_axis->isVisible(), true);
314 314 }
315 315
316 316 void tst_QAbstractAxis::labelsAngle_data()
317 317 {
318 318 QTest::addColumn<int>("labelsAngle");
319 319 QTest::newRow("0") << 0;
320 320 QTest::newRow("45") << 45;
321 321 QTest::newRow("90") << 90;
322 322 }
323 323
324 324 void tst_QAbstractAxis::labelsAngle()
325 325 {
326 326 QFETCH(int, labelsAngle);
327 327
328 328 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
329 329 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
330 330 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
331 331 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
332 332 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
333 333 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
334 334 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
335 335 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
336 336 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
337 337
338 338 m_axis->setLabelsAngle(labelsAngle);
339 339 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
340 340
341 341 QCOMPARE(spy0.count(), 0);
342 342 QCOMPARE(spy1.count(), 0);
343 343 QCOMPARE(spy2.count(), 0);
344 344 QCOMPARE(spy3.count(), 0);
345 345 QCOMPARE(spy4.count(), 0);
346 346 QCOMPARE(spy5.count(), 0);
347 347 QCOMPARE(spy6.count(), 0);
348 348 QCOMPARE(spy7.count(), 0);
349 349 QCOMPARE(spy8.count(), 0);
350 350
351 351 m_chart->setAxisX(m_axis, m_series);
352 352 m_view->show();
353 353 QTest::qWaitForWindowShown(m_view);
354 354 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
355 355 }
356 356
357 357 void tst_QAbstractAxis::labelsBrush_data()
358 358 {
359 359 QTest::addColumn<QBrush>("labelsBrush");
360 360 QTest::newRow("null") << QBrush();
361 361 QTest::newRow("blue") << QBrush(Qt::blue);
362 362 QTest::newRow("black") << QBrush(Qt::black);
363 363
364 364 }
365 365
366 366 void tst_QAbstractAxis::labelsBrush()
367 367 {
368 368
369 369 QFETCH(QBrush, labelsBrush);
370 370
371 371 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
372 372 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
373 373 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
374 374 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
375 375 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
376 376 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
377 377 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
378 378 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
379 379 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
380 380
381 381 m_axis->setLabelsBrush(labelsBrush);
382 382 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
383 383
384 384 QCOMPARE(spy0.count(), 0);
385 385 QCOMPARE(spy1.count(), 0);
386 386 QCOMPARE(spy2.count(), 0);
387 387 QCOMPARE(spy3.count(), 0);
388 388 QCOMPARE(spy4.count(), 0);
389 389 QCOMPARE(spy5.count(), 0);
390 390 //TODO QCOMPARE(spy6.count(), 0);
391 391 QCOMPARE(spy7.count(), 0);
392 392 QCOMPARE(spy8.count(), 0);
393 393
394 394 m_view->show();
395 395 QTest::qWaitForWindowShown(m_view);
396 396 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
397 397
398 398 }
399 399
400 400 void tst_QAbstractAxis::labelsColor_data()
401 401 {
402 402
403 403 }
404 404
405 405 void tst_QAbstractAxis::labelsColor()
406 406 {
407 407 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
408 408 }
409 409
410 410 void tst_QAbstractAxis::labelsFont_data()
411 411 {
412 412 QTest::addColumn<QFont>("labelsFont");
413 413 QTest::newRow("null") << QFont();
414 414 QTest::newRow("serif") << QFont("SansSerif");
415 415 }
416 416
417 417 void tst_QAbstractAxis::labelsFont()
418 418 {
419 419
420 420 QFETCH(QFont, labelsFont);
421 421
422 422 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
423 423 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
424 424 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
425 425 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
426 426 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
427 427 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
428 428 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
429 429 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
430 430 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
431 431
432 432 m_axis->setLabelsFont(labelsFont);
433 433 QCOMPARE(m_axis->labelsFont(), labelsFont);
434 434
435 435 QCOMPARE(spy0.count(), 0);
436 436 QCOMPARE(spy1.count(), 0);
437 437 QCOMPARE(spy2.count(), 0);
438 438 QCOMPARE(spy3.count(), 0);
439 439 QCOMPARE(spy4.count(), 0);
440 440 QCOMPARE(spy5.count(), 0);
441 441 QCOMPARE(spy6.count(), 0);
442 442 QCOMPARE(spy7.count(), 0);
443 443 QCOMPARE(spy8.count(), 0);
444 444
445 445 m_view->show();
446 446 QTest::qWaitForWindowShown(m_view);
447 447 QCOMPARE(m_axis->labelsFont(), labelsFont);
448 448
449 449 }
450 450
451 451 void tst_QAbstractAxis::labelsPen_data()
452 452 {
453 453 QTest::addColumn<QPen>("labelsPen");
454 454 QTest::newRow("null") << QPen();
455 455 QTest::newRow("blue") << QPen(Qt::blue);
456 456 QTest::newRow("black") << QPen(Qt::black);
457 457 QTest::newRow("red") << QPen(Qt::red);
458 458 }
459 459
460 460 void tst_QAbstractAxis::labelsPen()
461 461 {
462 462 QFETCH(QPen, labelsPen);
463 463
464 464 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
465 465 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
466 466 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
467 467 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
468 468 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
469 469 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
470 470 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
471 471 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
472 472 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
473 473
474 474 m_axis->setLabelsPen(labelsPen);
475 475 QCOMPARE(m_axis->labelsPen(), labelsPen);
476 476
477 477 QCOMPARE(spy0.count(), 0);
478 478 QCOMPARE(spy1.count(), 0);
479 479 QCOMPARE(spy2.count(), 0);
480 480 QCOMPARE(spy3.count(), 0);
481 481 QCOMPARE(spy4.count(), 0);
482 482 QCOMPARE(spy5.count(), 0);
483 483 QCOMPARE(spy6.count(), 0);
484 484 QCOMPARE(spy7.count(), 0);
485 485 QCOMPARE(spy8.count(), 0);
486 486
487 487 m_chart->setAxisX(m_axis, m_series);
488 488 m_view->show();
489 489 QTest::qWaitForWindowShown(m_view);
490 490 //TODO QCOMPARE(m_axis->labelsPen(), labelsPen);
491 491 }
492 492
493 493 void tst_QAbstractAxis::labelsVisible_data()
494 494 {
495 495 QTest::addColumn<bool>("labelsVisible");
496 496 QTest::newRow("true") << true;
497 497 QTest::newRow("false") << false;
498 498 }
499 499
500 500 void tst_QAbstractAxis::labelsVisible()
501 501 {
502 502 QFETCH(bool, labelsVisible);
503 503
504 504 m_axis->setLabelsVisible(!labelsVisible);
505 505
506 506 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
507 507 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
508 508 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
509 509 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
510 510 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
511 511 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
512 512 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
513 513 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
514 514 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
515 515
516 516 m_axis->setLabelsVisible(labelsVisible);
517 517 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
518 518
519 519 QCOMPARE(spy0.count(), 0);
520 520 QCOMPARE(spy1.count(), 0);
521 521 QCOMPARE(spy2.count(), 0);
522 522 QCOMPARE(spy3.count(), 0);
523 523 QCOMPARE(spy4.count(), 1);
524 524 QCOMPARE(spy5.count(), 0);
525 525 QCOMPARE(spy6.count(), 0);
526 526 QCOMPARE(spy7.count(), 0);
527 527 QCOMPARE(spy8.count(), 0);
528 528
529 529 m_chart->setAxisX(m_axis, m_series);
530 530 m_view->show();
531 531 QTest::qWaitForWindowShown(m_view);
532 532 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
533 533 }
534 534
535 535 void tst_QAbstractAxis::orientation_data()
536 536 {
537 537 QTest::addColumn<Qt::Orientation>("orientation");
538 538 QTest::newRow("Vertical") << Qt::Vertical;
539 539 QTest::newRow("Horizontal") << Qt::Horizontal;
540 540 }
541 541
542 542 void tst_QAbstractAxis::orientation()
543 543 {
544 544 QFETCH(Qt::Orientation, orientation);
545 545
546 546 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
547 547 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
548 548 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
549 549 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
550 550 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
551 551 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
552 552 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
553 553 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
554 554 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
555 555
556 556 if(orientation==Qt::Vertical){
557 557 m_chart->setAxisY(m_axis,m_series);
558 558 }else{
559 559 m_chart->setAxisX(m_axis,m_series);
560 560 }
561 561 QCOMPARE(m_axis->orientation(), orientation);
562 562
563 563 QCOMPARE(spy0.count(), 0);
564 564 QCOMPARE(spy1.count(), 0);
565 565 QCOMPARE(spy2.count(), 0);
566 566 QCOMPARE(spy3.count(), 0);
567 567 QCOMPARE(spy4.count(), 0);
568 568 QCOMPARE(spy5.count(), 0);
569 569 QCOMPARE(spy6.count(), 0);
570 570 QCOMPARE(spy7.count(), 0);
571 571 QCOMPARE(spy8.count(), 1);
572 572
573 573 m_view->show();
574 574 QTest::qWaitForWindowShown(m_view);
575 575 QCOMPARE(m_axis->orientation(), orientation);
576 576 }
577 577
578 578 void tst_QAbstractAxis::setMax_data()
579 579 {
580 580 //just check if it does not crash
581 581 QTest::addColumn<QVariant>("max");
582 582 QTest::newRow("something") << QVariant("something");
583 583 QTest::newRow("1.0") << QVariant(1.0);
584 584 }
585 585
586 586 void tst_QAbstractAxis::setMax()
587 587 {
588 588 QFETCH(QVariant, max);
589 589 m_axis->setMax(max);
590 590 }
591 591
592 592 void tst_QAbstractAxis::setMin_data()
593 593 {
594 594 //just check if it does not crash
595 595 QTest::addColumn<QVariant>("min");
596 596 QTest::newRow("something") << QVariant("something");
597 597 QTest::newRow("1.0") << QVariant(1.0);
598 598 }
599 599
600 600 // public void setMin(QVariant const& min)
601 601 void tst_QAbstractAxis::setMin()
602 602 {
603 603 QFETCH(QVariant, min);
604 604 m_axis->setMin(min);
605 605 }
606 606
607 607 void tst_QAbstractAxis::setRange_data()
608 608 {
609 609 //just check if it does not crash
610 610 QTest::addColumn<QVariant>("min");
611 611 QTest::addColumn<QVariant>("max");
612 612 QTest::newRow("something") << QVariant("something0") << QVariant("something1");
613 613 QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0);
614 614 }
615 615
616 616 // public void setRange(QVariant const& min, QVariant const& max)
617 617 void tst_QAbstractAxis::setRange()
618 618 {
619 619
620 620 QFETCH(QVariant, min);
621 621 QFETCH(QVariant, max);
622 622 m_axis->setRange(min,max);
623 623 }
624 624
625 625 void tst_QAbstractAxis::shadesBorderColor_data()
626 626 {
627 627
628 628 }
629 629
630 630 void tst_QAbstractAxis::shadesBorderColor()
631 631 {
632 632 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
633 633 }
634 634
635 635 void tst_QAbstractAxis::shadesBrush_data()
636 636 {
637 637 QTest::addColumn<QBrush>("shadesBrush");
638 638 QTest::newRow("null") << QBrush();
639 639 QTest::newRow("blue") << QBrush(Qt::blue);
640 640 QTest::newRow("black") << QBrush(Qt::black);
641 641 }
642 642
643 643 void tst_QAbstractAxis::shadesBrush()
644 644 {
645 645 QFETCH(QBrush, shadesBrush);
646 646
647 647 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
648 648 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
649 649 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
650 650 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
651 651 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
652 652 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
653 653 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
654 654 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
655 655 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
656 656
657 657 m_axis->setShadesBrush(shadesBrush);
658 658 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
659 659
660 660 QCOMPARE(spy0.count(), 0);
661 661 QCOMPARE(spy1.count(), 0);
662 662 QCOMPARE(spy2.count(), 0);
663 663 QCOMPARE(spy3.count(), 0);
664 664 QCOMPARE(spy4.count(), 0);
665 665 QCOMPARE(spy5.count(), 0);
666 666 //TODO QCOMPARE(spy6.count(), 0);
667 667 QCOMPARE(spy7.count(), 0);
668 668 QCOMPARE(spy8.count(), 0);
669 669
670 670 m_view->show();
671 671 QTest::qWaitForWindowShown(m_view);
672 672 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
673 673 }
674 674
675 675 void tst_QAbstractAxis::shadesColor_data()
676 676 {
677 677 }
678 678
679 679 // public QColor shadesColor() const
680 680 void tst_QAbstractAxis::shadesColor()
681 681 {
682 682 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
683 683 }
684 684
685 685 void tst_QAbstractAxis::shadesPen_data()
686 686 {
687 687 QTest::addColumn<QPen>("shadesPen");
688 688 QTest::newRow("null") << QPen();
689 689 QTest::newRow("blue") << QPen(Qt::blue);
690 690 QTest::newRow("black") << QPen(Qt::black);
691 691 QTest::newRow("red") << QPen(Qt::red);
692 692 }
693 693
694 694 void tst_QAbstractAxis::shadesPen()
695 695 {
696 696 QFETCH(QPen, shadesPen);
697 697
698 698 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
699 699 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
700 700 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
701 701 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
702 702 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
703 703 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
704 704 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
705 705 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
706 706 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
707 707
708 708 m_axis->setShadesPen(shadesPen);
709 709 QCOMPARE(m_axis->shadesPen(), shadesPen);
710 710
711 711 QCOMPARE(spy0.count(), 0);
712 712 QCOMPARE(spy1.count(), 0);
713 713 QCOMPARE(spy2.count(), 0);
714 714 QCOMPARE(spy3.count(), 0);
715 715 QCOMPARE(spy4.count(), 0);
716 716 QCOMPARE(spy5.count(), 0);
717 717 QCOMPARE(spy6.count(), 0);
718 718 QCOMPARE(spy7.count(), 0);
719 719 QCOMPARE(spy8.count(), 0);
720 720
721 721 m_chart->setAxisX(m_axis, m_series);
722 722 m_view->show();
723 723 QTest::qWaitForWindowShown(m_view);
724 724 QCOMPARE(m_axis->shadesPen(), shadesPen);
725 725 }
726 726
727 727 void tst_QAbstractAxis::shadesVisible_data()
728 728 {
729 729 QTest::addColumn<bool>("shadesVisible");
730 730 QTest::newRow("true") << true;
731 731 QTest::newRow("false") << false;
732 732 }
733 733
734 734 void tst_QAbstractAxis::shadesVisible()
735 735 {
736 736 QFETCH(bool, shadesVisible);
737 737
738 738 m_axis->setShadesVisible(!shadesVisible);
739 739
740 740 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
741 741 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
742 742 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
743 743 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
744 744 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
745 745 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
746 746 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
747 747 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
748 748 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
749 749
750 750 m_axis->setShadesVisible(shadesVisible);
751 751 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
752 752
753 753 QCOMPARE(spy0.count(), 0);
754 754 QCOMPARE(spy1.count(), 0);
755 755 QCOMPARE(spy2.count(), 0);
756 756 QCOMPARE(spy3.count(), 0);
757 757 QCOMPARE(spy4.count(), 0);
758 758 QCOMPARE(spy5.count(), 0);
759 759 QCOMPARE(spy6.count(), 0);
760 760 QCOMPARE(spy7.count(), 1);
761 761 QCOMPARE(spy8.count(), 0);
762 762
763 763 m_chart->setAxisX(m_axis, m_series);
764 764 m_view->show();
765 765 QTest::qWaitForWindowShown(m_view);
766 766 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
767 767 }
768 768
769 769 void tst_QAbstractAxis::show_data()
770 770 {
771 771
772 772 }
773 773
774 774 void tst_QAbstractAxis::show()
775 775 {
776 776 m_axis->hide();
777 777 QCOMPARE(m_axis->isVisible(), false);
778 778
779 779 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
780 780 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
781 781 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
782 782 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
783 783 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
784 784 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
785 785 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
786 786 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
787 787 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
788 788
789 789 m_axis->show();
790 790
791 791 QCOMPARE(spy0.count(), 0);
792 792 QCOMPARE(spy1.count(), 0);
793 793 QCOMPARE(spy2.count(), 0);
794 794 QCOMPARE(spy3.count(), 0);
795 795 QCOMPARE(spy4.count(), 0);
796 796 QCOMPARE(spy5.count(), 0);
797 797 QCOMPARE(spy6.count(), 0);
798 798 QCOMPARE(spy7.count(), 0);
799 799 QCOMPARE(spy8.count(), 1);
800 800 QCOMPARE(m_axis->isVisible(), true);
801 801 }
802 802
803 803 void tst_QAbstractAxis::hide_data()
804 804 {
805 805
806 806 }
807 807
808 808 void tst_QAbstractAxis::hide()
809 809 {
810 810 m_axis->show();
811 811 QCOMPARE(m_axis->isVisible(),true);
812 812
813 813 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
814 814 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
815 815 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
816 816 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
817 817 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
818 818 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
819 819 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
820 820 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
821 821 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
822 822
823 823 m_axis->hide();
824 824
825 825 QCOMPARE(spy0.count(), 0);
826 826 QCOMPARE(spy1.count(), 0);
827 827 QCOMPARE(spy2.count(), 0);
828 828 QCOMPARE(spy3.count(), 0);
829 829 QCOMPARE(spy4.count(), 0);
830 830 QCOMPARE(spy5.count(), 0);
831 831 QCOMPARE(spy6.count(), 0);
832 832 QCOMPARE(spy7.count(), 0);
833 833 QCOMPARE(spy8.count(), 1);
834 834 QCOMPARE(m_axis->isVisible(),false);
835 835 }
836 836
837 837
838 838
839 839
840 840
841 841
842 842
843 843
844 844
845 845
846 846
847 847
General Comments 0
You need to be logged in to leave comments. Login now