summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
authorTasuku Suzuki <tasuku.suzuki@nokia.com>2011-03-21 14:13:16 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-03-21 14:13:16 (GMT)
commit84a342eea111f0a1da8fd0c417362aae2b851e56 (patch)
tree9ca77440d6503412408b5111d293dea088b8ffda /src/gui/util
parent55650943492ff00d086bc76039212ce8438ee203 (diff)
downloadQt-84a342eea111f0a1da8fd0c417362aae2b851e56.zip
Qt-84a342eea111f0a1da8fd0c417362aae2b851e56.tar.gz
Qt-84a342eea111f0a1da8fd0c417362aae2b851e56.tar.bz2
Fix compilation with QT_NO_
Merge-request: 1132 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'src/gui/util')
-rw-r--r--src/gui/util/qflickgesture.cpp44
-rw-r--r--src/gui/util/qscroller.cpp33
-rw-r--r--src/gui/util/qscroller.h6
-rw-r--r--src/gui/util/qscroller_p.h9
4 files changed, 86 insertions, 6 deletions
diff --git a/src/gui/util/qflickgesture.cpp b/src/gui/util/qflickgesture.cpp
index 8baca07..fdd2a95 100644
--- a/src/gui/util/qflickgesture.cpp
+++ b/src/gui/util/qflickgesture.cpp
@@ -75,6 +75,7 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
QMouseEvent *me = static_cast<QMouseEvent *>(e);
return new QMouseEvent(me->type(), QPoint(0, 0), me->globalPos(), me->button(), me->buttons(), me->modifiers());
}
+#ifndef QT_NO_GRAPHICSVIEW
case QEvent::GraphicsSceneMousePress:
case QEvent::GraphicsSceneMouseRelease:
case QEvent::GraphicsSceneMouseMove: {
@@ -103,6 +104,7 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
return copy;
#endif
}
+#endif // QT_NO_GRAPHICSVIEW
default:
return 0;
}
@@ -265,6 +267,7 @@ protected:
if (mouseTarget) {
sendingEvent = true;
+#ifndef QT_NO_GRAPHICSVIEW
QGraphicsItem *grabber = 0;
if (mouseTarget->parentWidget()) {
if (QGraphicsView *gv = qobject_cast<QGraphicsView *>(mouseTarget->parentWidget())) {
@@ -281,12 +284,14 @@ protected:
qFGDebug() << "QFG: ungrabbing" << grabber;
grabber->ungrabMouse();
}
+#endif // QT_NO_GRAPHICSVIEW
if (me) {
QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()), me->globalPos(), me->button(), me->buttons(), me->modifiers());
qt_sendSpontaneousEvent(mouseTarget, &copy);
}
+#ifndef QT_NO_GRAPHICSVIEW
if (grabber && (flags & RegrabMouseAfterwards)) {
// GraphicsView Mouse Handling Workaround #2:
// we need to re-grab the mouse after sending a faked mouse
@@ -296,6 +301,7 @@ protected:
qFGDebug() << "QFG: re-grabbing" << grabber;
grabber->grabMouse();
}
+#endif
sendingEvent = false;
}
}
@@ -357,10 +363,12 @@ QFlickGestureRecognizer::QFlickGestureRecognizer(Qt::MouseButton button)
*/
QGesture *QFlickGestureRecognizer::create(QObject *target)
{
+#ifndef QT_NO_GRAPHICSVIEW
QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target);
if (go && button == Qt::NoButton) {
go->setAcceptTouchEvents(true);
}
+#endif
return new QFlickGesture(target, button);
}
@@ -389,7 +397,9 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
return Ignore; // nothing to do without a scroller?
QWidget *receiverWidget = qobject_cast<QWidget *>(d->receiver);
+#ifndef QT_NO_GRAPHICSVIEW
QGraphicsObject *receiverGraphicsObject = qobject_cast<QGraphicsObject *>(d->receiver);
+#endif
// this is only set for events that we inject into the event loop via sendEvent()
if (PressDelayHandler::instance()->shouldEventBeIgnored(event)) {
@@ -398,7 +408,9 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
}
const QMouseEvent *me = 0;
+#ifndef QT_NO_GRAPHICSVIEW
const QGraphicsSceneMouseEvent *gsme = 0;
+#endif
const QTouchEvent *te = 0;
QPoint globalPos;
@@ -415,6 +427,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
globalPos = me->globalPos();
}
break;
+#ifndef QT_NO_GRAPHICSVIEW
case QEvent::GraphicsSceneMousePress:
case QEvent::GraphicsSceneMouseRelease:
case QEvent::GraphicsSceneMouseMove:
@@ -425,6 +438,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
globalPos = gsme->screenPos();
}
break;
+#endif
case QEvent::TouchBegin:
case QEvent::TouchEnd:
case QEvent::TouchUpdate:
@@ -466,7 +480,11 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
break;
}
- if (!me && !gsme && !te) // Neither mouse nor touch
+ if (!me
+#ifndef QT_NO_GRAPHICSVIEW
+ && !gsme
+#endif
+ && !te) // Neither mouse nor touch
return Ignore;
// get the current pointer position in local coordinates.
@@ -502,6 +520,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
}
break;
+#ifndef QT_NO_GRAPHICSVIEW
case QEvent::GraphicsSceneMousePress:
if (gsme && gsme->button() == button && gsme->buttons() == button) {
point = gsme->scenePos();
@@ -529,6 +548,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
inputType = QScroller::InputMove;
}
break;
+#endif
case QEvent::TouchBegin:
inputType = QScroller::InputPress;
@@ -568,12 +588,14 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
if (QWidget *w = qobject_cast<QWidget *>(as->target())) {
scrollerRegion = QRect(w->mapToGlobal(QPoint(0, 0)), w->size());
+#ifndef QT_NO_GRAPHICSVIEW
} else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(as->target())) {
if (go->scene() && !go->scene()->views().isEmpty()) {
foreach (QGraphicsView *gv, go->scene()->views())
scrollerRegion |= gv->mapFromScene(go->mapToScene(go->boundingRect()))
.translated(gv->mapToGlobal(QPoint(0, 0)));
}
+#endif
}
// active scrollers always have priority
if (scrollerRegion.contains(globalPos))
@@ -588,8 +610,10 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
if (inputType) {
if (QWidget *w = qobject_cast<QWidget *>(d->receiver))
point = w->mapFromGlobal(point.toPoint());
+#ifndef QT_NO_GRAPHICSVIEW
else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->receiver))
point = go->mapFromScene(point);
+#endif
// inform the scroller about the new event
scroller->handleInput(inputType, point, monotonicTimer.elapsed());
@@ -602,7 +626,11 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
// Consume all mouse events while dragging or scrolling to avoid nasty
// side effects with Qt's standard widgets.
- if ((me || gsme) && scrollerIsActive)
+ if ((me
+#ifndef QT_NO_GRAPHICSVIEW
+ || gsme
+#endif
+ ) && scrollerIsActive)
result |= ConsumeEventHint;
// The only problem with this approach is that we consume the
@@ -610,7 +638,11 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
// have to fake a MouseRelease "somewhere" to not mess with the internal
// states of Qt's widgets (a QPushButton would stay in 'pressed' state
// forever, if it doesn't receive a MouseRelease).
- if (me || gsme) {
+ if (me
+#ifndef QT_NO_GRAPHICSVIEW
+ || gsme
+#endif
+ ) {
if (!scrollerWasDragging && !scrollerWasScrolling && scrollerIsActive)
PressDelayHandler::instance()->scrollerBecameActive();
else if (scrollerWasScrolling && (scroller->state() == QScroller::Dragging || scroller->state() == QScroller::Inactive))
@@ -622,7 +654,9 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
} else {
switch (event->type()) {
case QEvent::MouseButtonPress:
+#ifndef QT_NO_GRAPHICSVIEW
case QEvent::GraphicsSceneMousePress:
+#endif
if (scroller->state() == QScroller::Pressed) {
int pressDelay = int(1000 * scroller->scrollerProperties().scrollMetric(QScrollerProperties::MousePressEventDelay).toReal());
if (pressDelay > 0) {
@@ -639,7 +673,9 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
break;
case QEvent::MouseMove:
+#ifndef QT_NO_GRAPHICSVIEW
case QEvent::GraphicsSceneMouseMove:
+#endif
if (PressDelayHandler::instance()->isDelaying())
result |= ConsumeEventHint;
// fall through
@@ -647,7 +683,9 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
result |= scrollerIsActive ? TriggerGesture : Ignore;
break;
+#ifndef QT_NO_GRAPHICSVIEW
case QEvent::GraphicsSceneMouseRelease:
+#endif
case QEvent::MouseButtonRelease:
if (PressDelayHandler::instance()->released(event, scrollerWasDragging || scrollerWasScrolling, scrollerIsActive))
result |= ConsumeEventHint;
diff --git a/src/gui/util/qscroller.cpp b/src/gui/util/qscroller.cpp
index ac5607c..9c2d24d 100644
--- a/src/gui/util/qscroller.cpp
+++ b/src/gui/util/qscroller.cpp
@@ -192,6 +192,7 @@ static qreal progressForValue(const QEasingCurve &curve, qreal value)
}
+#ifndef QT_NO_ANIMATION
class QScrollTimer : public QAbstractAnimation
{
public:
@@ -230,6 +231,7 @@ private:
bool ignoreUpdate;
int skip;
};
+#endif // QT_NO_ANIMATION
/*!
\class QScroller
@@ -376,6 +378,7 @@ void QScroller::setScrollerProperties(const QScrollerProperties &sp)
}
}
+#ifndef QT_NO_GESTURES
/*!
Registers a custom scroll gesture recognizer, grabs it for the \a
@@ -426,11 +429,12 @@ Qt::GestureType QScroller::grabGesture(QObject *target, ScrollerGestureType scro
widget->grabGesture(sp->recognizerType);
if (scrollGestureType == TouchGesture)
widget->setAttribute(Qt::WA_AcceptTouchEvents);
-
+#ifndef QT_NO_GRAPHICSVIEW
} else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) {
if (scrollGestureType == TouchGesture)
go->setAcceptTouchEvents(true);
go->grabGesture(sp->recognizerType);
+#endif // QT_NO_GRAPHICSVIEW
}
return sp->recognizerType;
}
@@ -469,9 +473,10 @@ void QScroller::ungrabGesture(QObject *target)
if (target->isWidgetType()) {
QWidget *widget = static_cast<QWidget *>(target);
widget->ungrabGesture(sp->recognizerType);
-
+#ifndef QT_NO_GRAPHICSVIEW
} else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) {
go->ungrabGesture(sp->recognizerType);
+#endif
}
QGestureRecognizer::unregisterRecognizer(sp->recognizerType);
@@ -479,6 +484,8 @@ void QScroller::ungrabGesture(QObject *target)
sp->recognizer = 0;
}
+#endif // QT_NO_GESTURES
+
/*!
\internal
*/
@@ -496,9 +503,11 @@ QScroller::QScroller(QObject *target)
QScroller::~QScroller()
{
Q_D(QScroller);
+#ifndef QT_NO_GESTURES
QGestureRecognizer::unregisterRecognizer(d->recognizerType);
// do not delete the recognizer. The QGestureManager is doing this.
d->recognizer = 0;
+#endif
QScrollerPrivate::allScrollers.remove(d->target);
QScrollerPrivate::activeScrollers.remove(this);
@@ -562,6 +571,7 @@ QPointF QScroller::pixelPerMeter() const
Q_D(const QScroller);
QPointF ppm = d->pixelPerMeter;
+#ifndef QT_NO_GRAPHICSVIEW
if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->target)) {
QTransform viewtr;
//TODO: the first view isn't really correct - maybe use an additional field in the prepare event?
@@ -576,6 +586,7 @@ QPointF QScroller::pixelPerMeter() const
ppm.ry() /= QLineF(p0, py).length();
}
}
+#endif // QT_NO_GRAPHICSVIEW
return ppm;
}
@@ -869,8 +880,10 @@ void QScroller::setSnapPositionsY(qreal first, qreal interval)
QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target)
: target(_target)
+#ifndef QT_NO_GESTURES
, recognizer(0)
, recognizerType(Qt::CustomGesture)
+#endif
, state(QScroller::Inactive)
, firstScroll(true)
, pressTimestamp(0)
@@ -879,7 +892,9 @@ QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target)
, snapIntervalX(0.0)
, snapFirstY(-1.0)
, snapIntervalY(0.0)
+#ifndef QT_NO_ANIMATION
, scrollTimer(new QScrollTimer(this))
+#endif
, q_ptr(q)
{
connect(target, SIGNAL(destroyed(QObject*)), this, SLOT(targetDestroyed()));
@@ -919,7 +934,9 @@ const char *QScrollerPrivate::inputName(QScroller::Input input)
void QScrollerPrivate::targetDestroyed()
{
+#ifndef QT_NO_ANIMATION
scrollTimer->stop();
+#endif
delete q_ptr;
}
@@ -945,7 +962,9 @@ void QScrollerPrivate::timerTick()
}
}
+#ifndef QT_NO_ANIMATION
scrollTimer->stop();
+#endif
}
/*!
@@ -1436,11 +1455,13 @@ bool QScrollerPrivate::prepareScrolling(const QPointF &position)
if (QWidget *w = qobject_cast<QWidget *>(target))
setDpiFromWidget(w);
+#ifndef QT_NO_GRAPHICSVIEW
if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(target)) {
//TODO: the first view isn't really correct - maybe use an additional field in the prepare event?
if (go->scene() && !go->scene()->views().isEmpty())
setDpiFromWidget(go->scene()->views().first());
}
+#endif
if (state == QScroller::Scrolling) {
recalcScrollingSegments();
@@ -1690,7 +1711,9 @@ void QScrollerPrivate::setState(QScroller::State newstate)
switch (newstate) {
case QScroller::Inactive:
+#ifndef QT_NO_ANIMATION
scrollTimer->stop();
+#endif
// send the last scroll event (but only after the current state change was finished)
if (!firstScroll)
@@ -1700,7 +1723,9 @@ void QScrollerPrivate::setState(QScroller::State newstate)
break;
case QScroller::Pressed:
+#ifndef QT_NO_ANIMATION
scrollTimer->stop();
+#endif
oldVelocity = releaseVelocity;
releaseVelocity = QPointF(0, 0);
@@ -1708,12 +1733,16 @@ void QScrollerPrivate::setState(QScroller::State newstate)
case QScroller::Dragging:
dragDistance = QPointF(0, 0);
+#ifndef QT_NO_ANIMATION
if (state == QScroller::Pressed)
scrollTimer->start();
+#endif
break;
case QScroller::Scrolling:
+#ifndef QT_NO_ANIMATION
scrollTimer->start();
+#endif
break;
}
diff --git a/src/gui/util/qscroller.h b/src/gui/util/qscroller.h
index a026be4..1599c7d 100644
--- a/src/gui/util/qscroller.h
+++ b/src/gui/util/qscroller.h
@@ -55,8 +55,10 @@ QT_MODULE(Gui)
class QWidget;
class QScrollerPrivate;
class QScrollerProperties;
+#ifndef QT_NO_GESTURES
class QFlickGestureRecognizer;
class QMouseFlickGestureRecognizer;
+#endif
class Q_GUI_EXPORT QScroller : public QObject
{
@@ -94,9 +96,11 @@ public:
static QScroller *scroller(QObject *target);
static const QScroller *scroller(const QObject *target);
+#ifndef QT_NO_GESTURES
static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType = TouchGesture);
static Qt::GestureType grabbedGesture(QObject *target);
static void ungrabGesture(QObject *target);
+#endif
static QList<QScroller *> activeScrollers();
@@ -139,7 +143,9 @@ private:
Q_DISABLE_COPY(QScroller)
Q_DECLARE_PRIVATE(QScroller)
+#ifndef QT_NO_GESTURES
friend class QFlickGestureRecognizer;
+#endif
};
QT_END_NAMESPACE
diff --git a/src/gui/util/qscroller_p.h b/src/gui/util/qscroller_p.h
index fb2b257..8c5f2e7 100644
--- a/src/gui/util/qscroller_p.h
+++ b/src/gui/util/qscroller_p.h
@@ -69,10 +69,13 @@
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_GESTURES
class QFlickGestureRecognizer;
+#endif
+#ifndef QT_NO_ANIMATION
class QScrollTimer;
-
+#endif
class QScrollerPrivate : public QObject
{
Q_OBJECT
@@ -152,8 +155,10 @@ public:
// non static
QObject *target;
QScrollerProperties properties;
+#ifndef QT_NO_GESTURES
QFlickGestureRecognizer *recognizer;
Qt::GestureType recognizerType;
+#endif
// scroller state:
@@ -194,7 +199,9 @@ public:
QElapsedTimer monotonicTimer;
QPointF releaseVelocity; // the starting velocity of the scrolling state
+#ifndef QT_NO_ANIMATION
QScrollTimer *scrollTimer;
+#endif
QScroller *q_ptr;
};