manage also mouse moves of children

This commit is contained in:
Marco Martin 2011-12-15 18:45:15 +01:00
parent d52cb2a57b
commit 32b9547634
2 changed files with 17 additions and 0 deletions

View File

@ -46,6 +46,7 @@ DeclarativeDragArea::DeclarativeDragArea(QDeclarativeItem *parent)
m_data(new DeclarativeMimeData()) // m_data is owned by us, and we shouldn't pass it to Qt directly as it will automatically delete it after the drag and drop.
{
setAcceptedMouseButtons(Qt::LeftButton);
setFiltersChildEvents(true);
}
DeclarativeDragArea::~DeclarativeDragArea()
@ -184,3 +185,18 @@ void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Qt::DropAction action = drag->exec(m_supportedActions, m_defaultAction);
emit drop(action);
}
bool DeclarativeDragArea::sceneEventFilter(QGraphicsItem *item, QEvent *event)
{
if (!isEnabled()) {
return false;
}
if (event->type() == QEvent::GraphicsSceneMouseMove) {
QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent *>(event);
mouseMoveEvent(me);
}
return QDeclarativeItem::sceneEventFilter(item, event);
}

View File

@ -81,6 +81,7 @@ protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *) {}
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) {}
bool sceneEventFilter(QGraphicsItem *item, QEvent *event);
private:
QDeclarativeComponent* m_delegate;