aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorTasuku Suzuki <tasuku.suzuki@nokia.com>2012-06-20 10:31:52 +0900
committerQt by Nokia <qt-info@nokia.com>2012-06-24 20:36:11 +0200
commit010398c9b013fdad0580fcebd61c42aa73a6b346 (patch)
tree98da96fc2ebc8c4e7f00fc71b8a884497dd868a0 /src/quick
parentb970267ea4c182b4627e95024d7b4891141019ed (diff)
Make qtdeclarative compile with QT_NO_DRAGANDDROP
Change-Id: Ie92455495979b065b574f013d95fac17739fa40e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Jeremy Katz <jeremy.katz@nokia.com>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquickcanvas.cpp6
-rw-r--r--src/quick/items/qquickcanvas_p.h4
-rw-r--r--src/quick/items/qquickdrag.cpp4
-rw-r--r--src/quick/items/qquickdrag_p.h3
-rw-r--r--src/quick/items/qquickdroparea.cpp3
-rw-r--r--src/quick/items/qquickdroparea_p.h4
-rw-r--r--src/quick/items/qquickitem.cpp4
-rw-r--r--src/quick/items/qquickitem.h2
-rw-r--r--src/quick/items/qquickitem_p.h2
-rw-r--r--src/quick/items/qquickitemsmodule.cpp2
-rw-r--r--src/quick/items/qquickmousearea.cpp38
-rw-r--r--src/quick/items/qquickmousearea_p.h13
-rw-r--r--src/quick/items/qquickmousearea_p_p.h2
13 files changed, 84 insertions, 3 deletions
diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp
index 82fabd047b..7c59a9df9e 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 29c0d51b60..d01b5fa9cf 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 2357e3a7db..80dbf2b6db 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 720946924f..4ed98fa08c 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 6c178c5c1f..1f5d98cb9a 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 e207787198..082c3dadb9 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 00e01828be..ab942f6489 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 69122bdbcd..c0fd01fb7e 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 bbff26089d..0b4b2bd855 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 bb1305545e..380354c57d 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 f114292ad7..bf949e8c4d 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 177d2839f1..aee780981d 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 d73fb121f9..4e4b9a8d56 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;