@@ -47,7 +47,7 Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags): | |||
|
47 | 47 | addSeries(m_series); |
|
48 | 48 | createDefaultAxes(); |
|
49 | 49 | setAxisX(m_axis,m_series); |
|
50 |
m_axis->setTick |
|
|
50 | m_axis->setTickCount(5); | |
|
51 | 51 | axisX()->setRange(0, 10); |
|
52 | 52 | axisY()->setRange(-5, 10); |
|
53 | 53 | |
@@ -61,8 +61,8 Chart::~Chart() | |||
|
61 | 61 | |
|
62 | 62 | void Chart::handleTimeout() |
|
63 | 63 | { |
|
64 |
qreal x = plotArea().width()/m_axis->tick |
|
|
65 |
qreal y =(m_axis->max() - m_axis->min())/m_axis->tick |
|
|
64 | qreal x = plotArea().width()/m_axis->tickCount(); | |
|
65 | qreal y =(m_axis->max() - m_axis->min())/m_axis->tickCount(); | |
|
66 | 66 | m_x += y; |
|
67 | 67 | m_y = qrand() % 5 - 2.5; |
|
68 | 68 | m_series->append(m_x, m_y); |
@@ -113,7 +113,7 void ChartValueAxisX::handleAxisUpdated() | |||
|
113 | 113 | { |
|
114 | 114 | //TODO:: fix this |
|
115 | 115 | QValueAxis* axis = qobject_cast<QValueAxis*>(m_chartAxis); |
|
116 |
m_tickCount = axis->tick |
|
|
116 | m_tickCount = axis->tickCount(); | |
|
117 | 117 | ChartAxis::handleAxisUpdated(); |
|
118 | 118 | } |
|
119 | 119 |
@@ -118,7 +118,7 void ChartValueAxisY::handleAxisUpdated() | |||
|
118 | 118 | { |
|
119 | 119 | //TODO:: fix this |
|
120 | 120 | QValueAxis* axis = qobject_cast<QValueAxis*>(m_chartAxis); |
|
121 |
m_tickCount = axis->tick |
|
|
121 | m_tickCount = axis->tickCount(); | |
|
122 | 122 | ChartAxis::handleAxisUpdated(); |
|
123 | 123 | } |
|
124 | 124 |
@@ -188,7 +188,7 void QValueAxis::setRange(qreal min, qreal max) | |||
|
188 | 188 | if(d->m_niceNumbers) { |
|
189 | 189 | int ticks = d->m_tickCount; |
|
190 | 190 | d->looseNiceNumbers(min, max, ticks); |
|
191 |
if(ticks!=d->m_tickCount) setTick |
|
|
191 | if(ticks!=d->m_tickCount) setTickCount(ticks); | |
|
192 | 192 | } |
|
193 | 193 | |
|
194 | 194 | if (!qFuzzyIsNull(d->m_min - min)) { |
@@ -212,7 +212,7 void QValueAxis::setRange(qreal min, qreal max) | |||
|
212 | 212 | /*! |
|
213 | 213 | Sets \a count for ticks on the axis. |
|
214 | 214 | */ |
|
215 |
void QValueAxis::setTick |
|
|
215 | void QValueAxis::setTickCount(int count) | |
|
216 | 216 | { |
|
217 | 217 | Q_D(QValueAxis); |
|
218 | 218 | if (d->m_tickCount != count && count >=2) { |
@@ -225,7 +225,7 void QValueAxis::setTicksCount(int count) | |||
|
225 | 225 | \fn int QValueAxis::ticksCount() const |
|
226 | 226 | Return number of ticks on the axis |
|
227 | 227 | */ |
|
228 |
int QValueAxis::tick |
|
|
228 | int QValueAxis::tickCount() const | |
|
229 | 229 | { |
|
230 | 230 | Q_D(const QValueAxis); |
|
231 | 231 | return d->m_tickCount; |
@@ -30,7 +30,7 class QValueAxisPrivate; | |||
|
30 | 30 | class QTCOMMERCIALCHART_EXPORT QValueAxis : public QAbstractAxis |
|
31 | 31 | { |
|
32 | 32 | Q_OBJECT |
|
33 |
Q_PROPERTY(int tick |
|
|
33 | Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount) | |
|
34 | 34 | Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled) |
|
35 | 35 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) |
|
36 | 36 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) |
@@ -53,8 +53,8 public: | |||
|
53 | 53 | void setRange(qreal min, qreal max); |
|
54 | 54 | |
|
55 | 55 | //ticks handling |
|
56 |
void setTick |
|
|
57 |
int tick |
|
|
56 | void setTickCount(int count); | |
|
57 | int tickCount() const; | |
|
58 | 58 | |
|
59 | 59 | void setNiceNumbersEnabled(bool enable = true); |
|
60 | 60 | bool niceNumbersEnabled() const; |
@@ -105,7 +105,7 void tst_QValueAxis::qvalueaxis() | |||
|
105 | 105 | QVERIFY(qFuzzyIsNull(m_valuesaxis->max())); |
|
106 | 106 | QVERIFY(qFuzzyIsNull(m_valuesaxis->min())); |
|
107 | 107 | QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false); |
|
108 |
QCOMPARE(m_valuesaxis->tick |
|
|
108 | QCOMPARE(m_valuesaxis->tickCount(), 5); | |
|
109 | 109 | QCOMPARE(m_valuesaxis->type(), QAbstractAxis::AxisTypeValues); |
|
110 | 110 | |
|
111 | 111 | m_chart->setAxisX(m_valuesaxis, m_series); |
@@ -115,7 +115,7 void tst_QValueAxis::qvalueaxis() | |||
|
115 | 115 | QVERIFY(!qFuzzyIsNull(m_valuesaxis->max())); |
|
116 | 116 | QVERIFY(!qFuzzyIsNull(m_valuesaxis->min())); |
|
117 | 117 | QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false); |
|
118 |
QCOMPARE(m_valuesaxis->tick |
|
|
118 | QCOMPARE(m_valuesaxis->tickCount(), 5); | |
|
119 | 119 | } |
|
120 | 120 | |
|
121 | 121 | void tst_QValueAxis::max_raw_data() |
@@ -243,7 +243,7 void tst_QValueAxis::niceNumbersEnabled() | |||
|
243 | 243 | QFETCH(int, expectedTicks); |
|
244 | 244 | |
|
245 | 245 | m_valuesaxis->setRange(min, max); |
|
246 |
m_valuesaxis->setTick |
|
|
246 | m_valuesaxis->setTickCount(ticks); | |
|
247 | 247 | |
|
248 | 248 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); |
|
249 | 249 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); |
@@ -264,7 +264,7 void tst_QValueAxis::niceNumbersEnabled() | |||
|
264 | 264 | |
|
265 | 265 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal"); |
|
266 | 266 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal"); |
|
267 |
QCOMPARE(m_valuesaxis->tick |
|
|
267 | QCOMPARE(m_valuesaxis->tickCount(), expectedTicks); | |
|
268 | 268 | |
|
269 | 269 | } |
|
270 | 270 | |
@@ -338,8 +338,8 void tst_QValueAxis::ticksCount() | |||
|
338 | 338 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); |
|
339 | 339 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); |
|
340 | 340 | |
|
341 |
m_valuesaxis->setTick |
|
|
342 |
QCOMPARE(m_valuesaxis->tick |
|
|
341 | m_valuesaxis->setTickCount(ticksCount); | |
|
342 | QCOMPARE(m_valuesaxis->tickCount(), ticksCount); | |
|
343 | 343 | |
|
344 | 344 | QCOMPARE(spy0.count(), 0); |
|
345 | 345 | QCOMPARE(spy1.count(), 0); |
@@ -349,7 +349,7 void tst_QValueAxis::ticksCount() | |||
|
349 | 349 | m_view->show(); |
|
350 | 350 | QTest::qWaitForWindowShown(m_view); |
|
351 | 351 | |
|
352 |
QCOMPARE(m_valuesaxis->tick |
|
|
352 | QCOMPARE(m_valuesaxis->tickCount(), ticksCount); | |
|
353 | 353 | } |
|
354 | 354 | |
|
355 | 355 | void tst_QValueAxis::noautoscale_data() |
General Comments 0
You need to be logged in to leave comments.
Login now