##// END OF EJS Templates
Fixes nicenumbers missing update issue
Michal Klocek -
r1738:0029a831c085
parent child
Show More
@@ -180,13 +180,16 qreal QValuesAxis::max() const
180 */
180 */
181 void QValuesAxis::setRange(qreal min, qreal max)
181 void QValuesAxis::setRange(qreal min, qreal max)
182 {
182 {
183 if(max<min) return;
184
185 Q_D(QValuesAxis);
183 Q_D(QValuesAxis);
186 bool changed = false;
184 bool changed = false;
187
185
188 if (min > max)
186 if (min > max) return;
189 return;
187
188 if(d->m_niceNumbers) {
189 int ticks = d->m_tickCount;
190 d->looseNiceNumbers(min, max, ticks);
191 if(ticks!=d->m_tickCount) setTicksCount(ticks);
192 }
190
193
191 if (!qFuzzyIsNull(d->m_min - min)) {
194 if (!qFuzzyIsNull(d->m_min - min)) {
192 d->m_min = min;
195 d->m_min = min;
@@ -200,10 +203,8 void QValuesAxis::setRange(qreal min, qreal max)
200 emit maxChanged(max);
203 emit maxChanged(max);
201 }
204 }
202
205
203 if(d->m_niceNumbers) d->looseNiceNumbers(d->m_min, d->m_max, d->m_tickCount);
204
205 if (changed) {
206 if (changed) {
206 emit rangeChanged(d->m_min,d->m_max);
207 emit rangeChanged(min,max);
207 d->emitUpdated();
208 d->emitUpdated();
208 }
209 }
209 }
210 }
@@ -235,7 +236,9 void QValuesAxis::setNiceNumbersEnabled(bool enable)
235 Q_D(QValuesAxis);
236 Q_D(QValuesAxis);
236 if (d->m_niceNumbers != enable){
237 if (d->m_niceNumbers != enable){
237 d->m_niceNumbers = enable;
238 d->m_niceNumbers = enable;
238 if(enable && !qFuzzyIsNull(d->m_max - d->m_min)) setRange(d->min(),d->max());
239 if(enable && !qFuzzyIsNull(d->m_max - d->m_min)) {
240 setRange(d->m_min,d->m_max);
241 }
239 }
242 }
240 }
243 }
241
244
@@ -329,8 +329,20 void ChartDataSet::blockAxisSignals(bool enabled)
329 i.next();
329 i.next();
330 QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key());
330 QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key());
331 QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key());
331 QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key());
332 if(axisX) axisX->d_ptr->blockSignals(enabled);
332 if(axisX) {
333 if(axisY) axisY->d_ptr->blockSignals(enabled);
333 axisX->d_ptr->blockSignals(enabled);
334 if(!enabled) {
335 axisX->d_ptr->setDirty(false);
336 axisX->d_ptr->emitUpdated();
337 }
338 }
339 if(axisY) {
340 axisY->d_ptr->blockSignals(enabled);
341 if(!enabled) {
342 axisY->d_ptr->setDirty(false);
343 axisY->d_ptr->emitUpdated();
344 }
345 }
334 }
346 }
335 }
347 }
336
348
@@ -242,6 +242,12 void tst_QValuesAxis::niceNumbersEnabled()
242 QFETCH(qreal, expectedMax);
242 QFETCH(qreal, expectedMax);
243 QFETCH(int, expectedTicks);
243 QFETCH(int, expectedTicks);
244
244
245 m_valuesaxis->setRange(min, max);
246 m_valuesaxis->setTicksCount(ticks);
247
248 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal");
249 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal");
250
245 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
251 QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal)));
246 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
252 QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal)));
247 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
253 QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal)));
@@ -249,20 +255,17 void tst_QValuesAxis::niceNumbersEnabled()
249 m_valuesaxis->setNiceNumbersEnabled(niceNumbersEnabled);
255 m_valuesaxis->setNiceNumbersEnabled(niceNumbersEnabled);
250 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), niceNumbersEnabled);
256 QCOMPARE(m_valuesaxis->niceNumbersEnabled(), niceNumbersEnabled);
251
257
252 QCOMPARE(spy0.count(), 0);
258 if(!qFuzzyIsNull(expectedMin - min))
253 QCOMPARE(spy1.count(), 0);
259 QCOMPARE(spy1.count(), 1);
254 QCOMPARE(spy2.count(), 0);
260 if(!qFuzzyIsNull(expectedMax - max))
261 QCOMPARE(spy0.count(), 1);
262 if((!qFuzzyIsNull(expectedMin - min)) || (!qFuzzyIsNull(expectedMax - max)))
263 QCOMPARE(spy2.count(), 1);
255
264
256 m_valuesaxis->setTicksCount(ticks);
257 m_valuesaxis->setRange(min, max);
258 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal");
265 QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal");
259 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal");
266 QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal");
260 QCOMPARE(m_valuesaxis->ticksCount(), expectedTicks);
267 QCOMPARE(m_valuesaxis->ticksCount(), expectedTicks);
261
268
262 QCOMPARE(spy0.count(), 1);
263 QCOMPARE(spy1.count(), 1);
264 QCOMPARE(spy2.count(), 1);
265
266 }
269 }
267
270
268 void tst_QValuesAxis::range_raw_data()
271 void tst_QValuesAxis::range_raw_data()
General Comments 0
You need to be logged in to leave comments. Login now