signal when a drag starts so that qml items can take the necessary steps
This commit is contained in:
parent
a4e83dde8e
commit
a60b7b83c9
@ -65,6 +65,7 @@ QDeclarativeComponent* DeclarativeDragArea::delegate() const
|
||||
{
|
||||
return m_delegate;
|
||||
}
|
||||
|
||||
void DeclarativeDragArea::setDelegate(QDeclarativeComponent *delegate)
|
||||
{
|
||||
if (m_delegate != delegate) {
|
||||
@ -85,6 +86,7 @@ QDeclarativeItem* DeclarativeDragArea::source() const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
void DeclarativeDragArea::setSource(QDeclarativeItem* source)
|
||||
{
|
||||
if (m_source != source) {
|
||||
@ -92,6 +94,7 @@ void DeclarativeDragArea::setSource(QDeclarativeItem* source)
|
||||
emit sourceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void DeclarativeDragArea::resetSource()
|
||||
{
|
||||
setSource(0);
|
||||
@ -194,6 +197,8 @@ void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
emit dragStarted();
|
||||
|
||||
QDrag *drag = new QDrag(event->widget());
|
||||
DeclarativeMimeData* dataCopy = new DeclarativeMimeData(m_data); //Qt will take ownership of this copy and delete it.
|
||||
drag->setMimeData(dataCopy);
|
||||
@ -201,9 +206,7 @@ void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
if (!m_delegateImage.isNull()) {
|
||||
drag->setPixmap(QPixmap::fromImage(m_delegateImage));
|
||||
} else if (m_delegate) {
|
||||
|
||||
// Render the delegate to a Pixmap
|
||||
|
||||
QDeclarativeItem* item = qobject_cast<QDeclarativeItem *>(m_delegate->create());
|
||||
|
||||
QGraphicsScene scene;
|
||||
@ -240,4 +243,4 @@ bool DeclarativeDragArea::sceneEventFilter(QGraphicsItem *item, QEvent *event)
|
||||
}
|
||||
|
||||
return QDeclarativeItem::sceneEventFilter(item, event);
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,7 @@ public:
|
||||
DeclarativeMimeData* mimeData() const;
|
||||
|
||||
signals:
|
||||
void dragStarted();
|
||||
void delegateChanged();
|
||||
void sourceChanged();
|
||||
void targetChanged();
|
||||
|
Loading…
x
Reference in New Issue
Block a user