Make qtdeclarative compile with QT_NO_DRAGANDDROP
authorTasuku Suzuki <tasuku.suzuki@nokia.com>
Wed, 20 Jun 2012 01:31:52 +0000 (10:31 +0900)
committerQt by Nokia <qt-info@nokia.com>
Sun, 24 Jun 2012 18:36:11 +0000 (20:36 +0200)
Change-Id: Ie92455495979b065b574f013d95fac17739fa40e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Jeremy Katz <jeremy.katz@nokia.com>
13 files changed:
src/quick/items/qquickcanvas.cpp
src/quick/items/qquickcanvas_p.h
src/quick/items/qquickdrag.cpp
src/quick/items/qquickdrag_p.h
src/quick/items/qquickdroparea.cpp
src/quick/items/qquickdroparea_p.h
src/quick/items/qquickitem.cpp
src/quick/items/qquickitem.h
src/quick/items/qquickitem_p.h
src/quick/items/qquickitemsmodule.cpp
src/quick/items/qquickmousearea.cpp
src/quick/items/qquickmousearea_p.h
src/quick/items/qquickmousearea_p_p.h

index 82fabd0..7c59a9d 100644 (file)
@@ -1062,12 +1062,14 @@ bool QQuickCanvas::event(QEvent *e)
         d->clearHover();
         d->lastMousePosition = QPoint();
         break;
+#ifndef QT_NO_DRAGANDDROP
     case QEvent::DragEnter:
     case QEvent::DragLeave:
     case QEvent::DragMove:
     case QEvent::Drop:
         d->deliverDragEvent(&d->dragGrabber, e);
         break;
+#endif
     case QEvent::WindowDeactivate:
         rootItem()->windowDeactivateEvent();
         break;
@@ -1578,6 +1580,7 @@ bool QQuickCanvasPrivate::deliverTouchPoints(QQuickItem *item, QTouchEvent *even
     return false;
 }
 
+#ifndef QT_NO_DRAGANDDROP
 void QQuickCanvasPrivate::deliverDragEvent(QQuickDragGrabber *grabber, QEvent *event)
 {
     Q_Q(QQuickCanvas);
@@ -1697,6 +1700,7 @@ bool QQuickCanvasPrivate::deliverDragEvent(QQuickDragGrabber *grabber, QQuickIte
 
     return accepted;
 }
+#endif // QT_NO_DRAGANDDROP
 
 bool QQuickCanvasPrivate::sendFilteredMouseEvent(QQuickItem *target, QQuickItem *item, QEvent *event)
 {
@@ -1792,12 +1796,14 @@ bool QQuickCanvas::sendEvent(QQuickItem *item, QEvent *e)
             QQuickItemPrivate::get(item)->deliverTouchEvent(static_cast<QTouchEvent *>(e));
         }
         break;
+#ifndef QT_NO_DRAGANDDROP
     case QEvent::DragEnter:
     case QEvent::DragMove:
     case QEvent::DragLeave:
     case QEvent::Drop:
         QQuickItemPrivate::get(item)->deliverDragEvent(e);
         break;
+#endif
     default:
         break;
     }
index 29c0d51..d01b5fa 100644 (file)
@@ -112,7 +112,9 @@ public:
 
     QQuickItem *activeFocusItem;
     QQuickItem *mouseGrabberItem;
+#ifndef QT_NO_DRAGANDDROP
     QQuickDragGrabber dragGrabber;
+#endif
     int touchMouseId;
     ulong touchMousePressTimestamp;
 
@@ -132,8 +134,10 @@ public:
     bool sendHoverEvent(QEvent::Type, QQuickItem *, const QPointF &scenePos, const QPointF &lastScenePos,
                         Qt::KeyboardModifiers modifiers, bool accepted);
     bool clearHover();
+#ifndef QT_NO_DRAGANDDROP
     void deliverDragEvent(QQuickDragGrabber *, QEvent *);
     bool deliverDragEvent(QQuickDragGrabber *, QQuickItem *, QDragMoveEvent *);
+#endif
 
     QList<QQuickItem*> hoverItems;
     enum FocusOption {
index 2357e3a..80dbf2b 100644 (file)
@@ -49,6 +49,8 @@
 #include <QtQml/qqmlinfo.h>
 #include <QtGui/qevent.h>
 
+#ifndef QT_NO_DRAGANDDROP
+
 QT_BEGIN_NAMESPACE
 
 class QQuickDragAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener
@@ -614,3 +616,5 @@ void QQuickDragAttached::cancel()
 }
 
 QT_END_NAMESPACE
+
+#endif // QT_NO_DRAGANDDROP
index 7209469..4ed98fa 100644 (file)
@@ -49,6 +49,7 @@
 #include <QtCore/qmimedata.h>
 #include <QtCore/qstringlist.h>
 
+#ifndef QT_NO_DRAGANDDROP
 
 QT_BEGIN_HEADER
 
@@ -206,4 +207,6 @@ QT_END_NAMESPACE
 
 QT_END_HEADER
 
+#endif // QT_NO_DRAGANDDROP
+
 #endif
index 6c178c5..1f5d98c 100644 (file)
@@ -46,6 +46,8 @@
 
 #include <private/qqmlengine_p.h>
 
+#ifndef QT_NO_DRAGANDDROP
+
 QT_BEGIN_NAMESPACE
 
 QQuickDropAreaDrag::QQuickDropAreaDrag(QQuickDropAreaPrivate *d, QObject *parent)
@@ -429,3 +431,4 @@ void QQuickDropEvent::accept(QQmlV8Function *args)
 
 QT_END_NAMESPACE
 
+#endif // QT_NO_DRAGANDDROP
index e207787..082c3da 100644 (file)
@@ -49,6 +49,8 @@
 
 #include <QtGui/qevent.h>
 
+#ifndef QT_NO_DRAGANDDROP
+
 QT_BEGIN_HEADER
 
 QT_BEGIN_NAMESPACE
@@ -162,4 +164,6 @@ QML_DECLARE_TYPE(QQuickDropArea)
 
 QT_END_HEADER
 
+#endif // QT_NO_DRAGANDDROP
+
 #endif // QQUICKDROPAREA_P_H
index 00e0182..ab942f6 100644 (file)
@@ -3254,6 +3254,7 @@ void QQuickItem::hoverLeaveEvent(QHoverEvent *event)
     Q_UNUSED(event);
 }
 
+#ifndef QT_NO_DRAGANDDROP
 void QQuickItem::dragEnterEvent(QDragEnterEvent *event)
 {
     Q_UNUSED(event);
@@ -3275,6 +3276,7 @@ void QQuickItem::dropEvent(QDropEvent *event)
 {
     Q_UNUSED(event);
 }
+#endif // QT_NO_DRAGANDDROP
 
 bool QQuickItem::childMouseEventFilter(QQuickItem *, QEvent *)
 {
@@ -3860,6 +3862,7 @@ void QQuickItemPrivate::deliverHoverEvent(QHoverEvent *e)
     }
 }
 
+#ifndef QT_NO_DRAGANDDROP
 void QQuickItemPrivate::deliverDragEvent(QEvent *e)
 {
     Q_Q(QQuickItem);
@@ -3880,6 +3883,7 @@ void QQuickItemPrivate::deliverDragEvent(QEvent *e)
         break;
     }
 }
+#endif // QT_NO_DRAGANDDROP
 
 void QQuickItem::itemChange(ItemChange change, const ItemChangeData &value)
 {
index 69122bd..c0fd01f 100644 (file)
@@ -384,10 +384,12 @@ protected:
     virtual void hoverEnterEvent(QHoverEvent *event);
     virtual void hoverMoveEvent(QHoverEvent *event);
     virtual void hoverLeaveEvent(QHoverEvent *event);
+#ifndef QT_NO_DRAGANDDROP
     virtual void dragEnterEvent(QDragEnterEvent *);
     virtual void dragMoveEvent(QDragMoveEvent *);
     virtual void dragLeaveEvent(QDragLeaveEvent *);
     virtual void dropEvent(QDropEvent *);
+#endif
     virtual bool childMouseEventFilter(QQuickItem *, QEvent *);
     virtual void windowDeactivateEvent();
 
index bbff260..0b4b2bd 100644 (file)
@@ -532,7 +532,9 @@ public:
     void deliverWheelEvent(QWheelEvent *);
     void deliverTouchEvent(QTouchEvent *);
     void deliverHoverEvent(QHoverEvent *);
+#ifndef QT_NO_DRAGANDDROP
     void deliverDragEvent(QEvent *);
+#endif
 
     bool calcEffectiveVisible() const;
     bool setEffectiveVisibleRecur(bool);
index bb13055..380354c 100644 (file)
@@ -214,10 +214,12 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
     qmlRegisterType<QQuickPathAnimation>("QtQuick",2,0,"PathAnimation");
     qmlRegisterType<QQuickPathInterpolator>("QtQuick",2,0,"PathInterpolator");
 
+#ifndef QT_NO_DRAGANDDROP
     qmlRegisterType<QQuickDropArea>("QtQuick", 2, 0, "DropArea");
     qmlRegisterType<QQuickDropEvent>();
     qmlRegisterType<QQuickDropAreaDrag>();
     qmlRegisterUncreatableType<QQuickDrag>("QtQuick", 2, 0, "Drag", QQuickDragAttached::tr("Drag is only available via attached properties"));
+#endif
 
     qmlRegisterType<QQuickMultiPointTouchArea>("QtQuick", 2, 0, "MultiPointTouchArea");
     qmlRegisterType<QQuickTouchPoint>("QtQuick", 2, 0, "TouchPoint");
index f114292..bf949e8 100644 (file)
@@ -59,6 +59,8 @@ DEFINE_BOOL_CONFIG_OPTION(qmlVisualTouchDebugging, QML_VISUAL_TOUCH_DEBUGGING)
 
 static const int PressAndHoldDelay = 800;
 
+#ifndef QT_NO_DRAGANDDROP
+
 QQuickDrag::QQuickDrag(QObject *parent)
 : QObject(parent), _target(0), _axis(XandYAxis), _xmin(-FLT_MAX),
 _xmax(FLT_MAX), _ymin(-FLT_MAX), _ymax(FLT_MAX), _active(false), _filterChildren(false)
@@ -186,16 +188,23 @@ QQuickDragAttached *QQuickDrag::qmlAttachedProperties(QObject *obj)
     return new QQuickDragAttached(obj);
 }
 
+#endif // QT_NO_DRAGANDDROP
+
 QQuickMouseAreaPrivate::QQuickMouseAreaPrivate()
 : enabled(true), hovered(false), pressed(false), longPress(false),
   moved(false), dragX(true), dragY(true), stealMouse(false), doubleClick(false), preventStealing(false),
-  propagateComposedEvents(false), drag(0)
+  propagateComposedEvents(false)
+#ifndef QT_NO_DRAGANDDROP
+  , drag(0)
+#endif
 {
 }
 
 QQuickMouseAreaPrivate::~QQuickMouseAreaPrivate()
 {
+#ifndef QT_NO_DRAGANDDROP
     delete drag;
+#endif
 }
 
 void QQuickMouseAreaPrivate::init()
@@ -696,18 +705,22 @@ void QQuickMouseArea::mousePressEvent(QMouseEvent *event)
     else {
         d->longPress = false;
         d->saveEvent(event);
+#ifndef QT_NO_DRAGANDDROP
         if (d->drag)
             d->drag->setActive(false);
+#endif
         setHovered(true);
         d->startScene = event->windowPos();
         d->pressAndHoldTimer.start(PressAndHoldDelay, this);
         setKeepMouseGrab(d->stealMouse);
         event->setAccepted(setPressed(true));
 
+#ifndef QT_NO_DRAGANDDROP
         if (d->drag) {
             d->dragX = drag()->axis() & QQuickDrag::XAxis;
             d->dragY = drag()->axis() & QQuickDrag::YAxis;
         }
+#endif
     }
 }
 
@@ -729,6 +742,7 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event)
     else if (!d->hovered && isInside)
         setHovered(true);
 
+#ifndef QT_NO_DRAGANDDROP
     if (d->drag && d->drag->target()) {
         if (!d->moved) {
             d->targetStartPos = d->drag->target()->parentItem()
@@ -789,6 +803,8 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event)
 
         d->moved = true;
     }
+#endif
+
     QQuickMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
     emit mouseXChanged(&me);
     me.setPosition(d->lastPos);
@@ -806,8 +822,10 @@ void QQuickMouseArea::mouseReleaseEvent(QMouseEvent *event)
     } else {
         d->saveEvent(event);
         setPressed(false);
+#ifndef QT_NO_DRAGANDDROP
         if (d->drag)
             d->drag->setActive(false);
+#endif
         // If we don't accept hover, we need to reset containsMouse.
         if (!acceptHoverEvents())
             setHovered(false);
@@ -969,7 +987,13 @@ bool QQuickMouseArea::sendMouseEvent(QMouseEvent *event)
 bool QQuickMouseArea::childMouseEventFilter(QQuickItem *i, QEvent *e)
 {
     Q_D(QQuickMouseArea);
-    if (!d->pressed && (!d->enabled || !isVisible() || !d->drag || !d->drag->filterChildren()))
+    if (!d->pressed &&
+            (!d->enabled || !isVisible()
+#ifndef QT_NO_DRAGANDDROP
+             || !d->drag || !d->drag->filterChildren()
+#endif
+            )
+       )
         return QQuickItem::childMouseEventFilter(i, e);
     switch (e->type()) {
     case QEvent::MouseButtonPress:
@@ -988,7 +1012,11 @@ void QQuickMouseArea::timerEvent(QTimerEvent *event)
     Q_D(QQuickMouseArea);
     if (event->timerId() == d->pressAndHoldTimer.timerId()) {
         d->pressAndHoldTimer.stop();
+#ifndef QT_NO_DRAGANDDROP
         bool dragged = d->drag && d->drag->active();
+#else
+        bool dragged = false;
+#endif
         if (d->pressed && dragged == false && d->hovered == true) {
             d->longPress = true;
             QQuickMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
@@ -1129,7 +1157,11 @@ void QQuickMouseArea::setAcceptedButtons(Qt::MouseButtons buttons)
 bool QQuickMouseArea::setPressed(bool p)
 {
     Q_D(QQuickMouseArea);
+#ifndef QT_NO_DRAGANDDROP
     bool dragged = d->drag && d->drag->active();
+#else
+    bool dragged = false;
+#endif
     bool isclick = d->pressed == true && p == false && dragged == false && d->hovered == true;
 
     if (d->pressed != p) {
@@ -1197,6 +1229,7 @@ bool QQuickMouseArea::setPressed(bool p)
 
 */
 
+#ifndef QT_NO_DRAGANDDROP
 QQuickDrag *QQuickMouseArea::drag()
 {
     Q_D(QQuickMouseArea);
@@ -1204,6 +1237,7 @@ QQuickDrag *QQuickMouseArea::drag()
         d->drag = new QQuickDrag;
     return d->drag;
 }
+#endif
 
 QSGNode *QQuickMouseArea::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
 {
index 177d283..aee7809 100644 (file)
@@ -50,8 +50,11 @@ QT_BEGIN_HEADER
 
 QT_BEGIN_NAMESPACE
 
-class QQuickDragAttached;
 class QQuickMouseEvent;
+
+#ifndef QT_NO_DRAGANDDROP
+
+class QQuickDragAttached;
 class Q_AUTOTEST_EXPORT QQuickDrag : public QObject
 {
     Q_OBJECT
@@ -118,6 +121,8 @@ private:
     Q_DISABLE_COPY(QQuickDrag)
 };
 
+#endif // QT_NO_DRAGANDDROP
+
 class QQuickMouseAreaPrivate;
 class QQuickWheelEvent;
 // used in QtLocation
@@ -133,7 +138,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickMouseArea : public QQuickItem
     Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
     Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
     Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
+#ifndef QT_NO_DRAGANDDROP
     Q_PROPERTY(QQuickDrag *drag READ drag CONSTANT) //### add flicking to QQuickDrag or add a QQuickFlick ???
+#endif
     Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
     Q_PROPERTY(bool propagateComposedEvents READ propagateComposedEvents WRITE setPropagateComposedEvents NOTIFY propagateComposedEventsChanged)
 
@@ -158,7 +165,9 @@ public:
     bool hoverEnabled() const;
     void setHoverEnabled(bool h);
 
+#ifndef QT_NO_DRAGANDDROP
     QQuickDrag *drag();
+#endif
 
     bool preventStealing() const;
     void setPreventStealing(bool prevent);
@@ -223,8 +232,10 @@ private:
 
 QT_END_NAMESPACE
 
+#ifndef QT_NO_DRAGANDDROP
 QML_DECLARE_TYPE(QQuickDrag)
 QML_DECLARE_TYPEINFO(QQuickDrag, QML_HAS_ATTACHED_PROPERTIES)
+#endif
 QML_DECLARE_TYPE(QQuickMouseArea)
 
 QT_END_HEADER
index d73fb12..4e4b9a8 100644 (file)
@@ -96,7 +96,9 @@ public:
     bool doubleClick : 1;
     bool preventStealing : 1;
     bool propagateComposedEvents : 1;
+#ifndef QT_NO_DRAGANDDROP
     QQuickDrag *drag;
+#endif
     QPointF startScene;
     QPointF targetStartPos;
     QPointF lastPos;