From ac90f1e7a4f06749f93b2b593fbf1b993d8af4c5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 19 Jan 2010 10:30:53 +1000 Subject: Try again to make it compile on Symbian. --- .../graphicsitems/qmlgraphicspathview.cpp | 34 +++++++++++++++------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp index 2fc0dfb..112eda2 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp @@ -56,6 +56,18 @@ QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(Qt,4,6,PathView,QmlGraphicsPathView) + +inline qreal qmlMod(qreal x, qreal y) +{ +#ifdef QT_USE_MATH_H_FLOATS + if(sizeof(qreal) == sizeof(float)) + return fmodf(float(x), float(y)); + else +#endif + return fmod(x, y); +} + + class QmlGraphicsPathViewAttached : public QObject { Q_OBJECT @@ -250,7 +262,7 @@ void QmlGraphicsPathViewPrivate::setOffset(qreal o) { Q_Q(QmlGraphicsPathView); if (_offset != o) { - _offset = fmod(o, qreal(100.0)); + _offset = qmlMod(o, qreal(100.0)); if (_offset < 0) _offset = 100.0 + _offset; q->refill(); @@ -450,8 +462,8 @@ void QmlGraphicsPathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *) velocity = 100; else if (velocity < -100) velocity = -100; - qreal inc = fmod(d->_offset - d->snapPos, qreal(100.0 / d->model->count())); - qreal dist = qAbs(velocity/2 - fmod(velocity/2, qreal(100.0 / d->model->count()) - inc)); + qreal inc = qmlMod(d->_offset - d->snapPos, qreal(100.0 / d->model->count())); + qreal dist = qAbs(velocity/2 - qmlMod(velocity/2, qreal(100.0 / d->model->count()) - inc)); d->moveOffset.setValue(d->_offset); d->tl.accel(d->moveOffset, velocity, 10, dist); d->tl.execute(d->fixupOffsetEvent); @@ -542,7 +554,7 @@ void QmlGraphicsPathView::componentComplete() itemIndex += d->pathOffset; itemIndex %= d->items.count(); - qreal targetOffset = fmod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0)); + qreal targetOffset = qmlMod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0)); if (targetOffset < 0) targetOffset = 100.0 + targetOffset; @@ -609,7 +621,7 @@ void QmlGraphicsPathView::refill() for (int i=0; iitems.count(); i++){ qreal percent = i * (100. / d->items.count()); percent = percent + d->_offset; - percent = fmod(percent, qreal(100.0)); + percent = qmlMod(percent, qreal(100.0)); positions << qAbs(percent/100.0); } @@ -696,7 +708,7 @@ void QmlGraphicsPathView::itemsInserted(int modelIndex, int count) int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count(); itemIndex += d->pathOffset; itemIndex %= d->items.count(); - qreal targetOffset = fmod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0)); + qreal targetOffset = qmlMod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0)); if (targetOffset < 0) targetOffset = 100.0 + targetOffset; @@ -733,7 +745,7 @@ void QmlGraphicsPathView::itemsRemoved(int modelIndex, int count) int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count(); itemIndex += d->pathOffset; itemIndex %= d->items.count(); - qreal targetOffset = fmod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0)); + qreal targetOffset = qmlMod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), qreal(100.0)); if (targetOffset < 0) targetOffset = 100.0 + targetOffset; @@ -766,12 +778,12 @@ int QmlGraphicsPathViewPrivate::calcCurrentIndex() { int current = -1; if (model && items.count()) { - _offset = fmod(_offset, qreal(100.0)); + _offset = qmlMod(_offset, qreal(100.0)); if (_offset < 0) _offset += 100.0; if (pathItems == -1) { - qreal delta = fmod(_offset - snapPos, qreal(100.0)); + qreal delta = qmlMod(_offset - snapPos, qreal(100.0)); if (delta < 0) delta = 100.0 + delta; int ii = model->count() - qRound(delta * model->count() / 100); @@ -784,7 +796,7 @@ int QmlGraphicsPathViewPrivate::calcCurrentIndex() for (int i=0; i