diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp index 82fabd047bf408b82971af688a0756df09352e4d..7c59a9df9ed7b9966776ae5bb7b13a5605b19f2b 100644 --- a/src/quick/items/qquickcanvas.cpp +++ b/src/quick/items/qquickcanvas.cpp @@ -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; } diff --git a/src/quick/items/qquickcanvas_p.h b/src/quick/items/qquickcanvas_p.h index 29c0d51b60702b9faa81a61dd6c6f4ad48f10794..d01b5fa9cf13883139fe87d70e7a0df3d4221d19 100644 --- a/src/quick/items/qquickcanvas_p.h +++ b/src/quick/items/qquickcanvas_p.h @@ -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 { diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp index 2357e3a7dbca9c070e6aebf299598991b1d1306d..80dbf2b6dba0dbde73b13001a3ba7b98c301bdbf 100644 --- a/src/quick/items/qquickdrag.cpp +++ b/src/quick/items/qquickdrag.cpp @@ -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 diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h index 720946924ff726a75ec71691f1389e3da20ca8fb..4ed98fa08c94ba385a4fee921c544bf496bdff77 100644 --- a/src/quick/items/qquickdrag_p.h +++ b/src/quick/items/qquickdrag_p.h @@ -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 diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp index 6c178c5c1f573d8d5b2d7fbeb5557d46adf25231..1f5d98cb9a154c1e6ebfacd73670b965cd6a9eae 100644 --- a/src/quick/items/qquickdroparea.cpp +++ b/src/quick/items/qquickdroparea.cpp @@ -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 diff --git a/src/quick/items/qquickdroparea_p.h b/src/quick/items/qquickdroparea_p.h index e207787198950c3d44e6f10ba60dbb4600078bc5..082c3dadb98e542dcf8dc20be434a02b55183fb1 100644 --- a/src/quick/items/qquickdroparea_p.h +++ b/src/quick/items/qquickdroparea_p.h @@ -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 diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 00e01828bef5708bc8e8ed3305da90d3373b3419..ab942f648961313babe5361fee8fc509b88c3089 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -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) { diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h index 69122bdbcdb96c5316b04a47281586e49da42015..c0fd01fb7e8d59928ba8a243091815cf1ff82bc3 100644 --- a/src/quick/items/qquickitem.h +++ b/src/quick/items/qquickitem.h @@ -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(); diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index bbff26089db5ef18606e715341c6973de3635c70..0b4b2bd855b336001dc241afa1734b7d7f4baa2a 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -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); diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index bb1305545e47a1e31b1e70cd2693cbdc15e3487b..380354c57d455d62159d7135da20b3575ae1f5ee 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -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"); diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index f114292ad7096908879a898881004b56e7a1a17f..bf949e8c4d025aa1eb4e2325025dd960fe337959 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -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) { diff --git a/src/quick/items/qquickmousearea_p.h b/src/quick/items/qquickmousearea_p.h index 177d2839f116cf4cccbf059c2c681d3b196c7073..aee780981d83df2e35431f2665029ad401edac10 100644 --- a/src/quick/items/qquickmousearea_p.h +++ b/src/quick/items/qquickmousearea_p.h @@ -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 diff --git a/src/quick/items/qquickmousearea_p_p.h b/src/quick/items/qquickmousearea_p_p.h index d73fb121f9544c9a8009724bc22fec9ad035f088..4e4b9a8d565568349b0da39a6465fc17a657ad77 100644 --- a/src/quick/items/qquickmousearea_p_p.h +++ b/src/quick/items/qquickmousearea_p_p.h @@ -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;