manage also mouse moves of children
This commit is contained in:
parent
d52cb2a57b
commit
32b9547634
@ -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.
|
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);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
|
setFiltersChildEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeclarativeDragArea::~DeclarativeDragArea()
|
DeclarativeDragArea::~DeclarativeDragArea()
|
||||||
@ -184,3 +185,18 @@ void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
Qt::DropAction action = drag->exec(m_supportedActions, m_defaultAction);
|
Qt::DropAction action = drag->exec(m_supportedActions, m_defaultAction);
|
||||||
emit drop(action);
|
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);
|
||||||
|
}
|
@ -81,6 +81,7 @@ protected:
|
|||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *) {}
|
void mousePressEvent(QGraphicsSceneMouseEvent *) {}
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) {}
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) {}
|
||||||
|
bool sceneEventFilter(QGraphicsItem *item, QEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDeclarativeComponent* m_delegate;
|
QDeclarativeComponent* m_delegate;
|
||||||
|
Loading…
Reference in New Issue
Block a user