signal when a drag starts so that qml items can take the necessary steps

This commit is contained in:
Aaron Seigo 2012-05-04 14:08:50 +02:00
parent a4e83dde8e
commit a60b7b83c9
2 changed files with 7 additions and 3 deletions

View File

@ -65,6 +65,7 @@ QDeclarativeComponent* DeclarativeDragArea::delegate() const
{ {
return m_delegate; return m_delegate;
} }
void DeclarativeDragArea::setDelegate(QDeclarativeComponent *delegate) void DeclarativeDragArea::setDelegate(QDeclarativeComponent *delegate)
{ {
if (m_delegate != delegate) { if (m_delegate != delegate) {
@ -85,6 +86,7 @@ QDeclarativeItem* DeclarativeDragArea::source() const
{ {
return m_source; return m_source;
} }
void DeclarativeDragArea::setSource(QDeclarativeItem* source) void DeclarativeDragArea::setSource(QDeclarativeItem* source)
{ {
if (m_source != source) { if (m_source != source) {
@ -92,6 +94,7 @@ void DeclarativeDragArea::setSource(QDeclarativeItem* source)
emit sourceChanged(); emit sourceChanged();
} }
} }
void DeclarativeDragArea::resetSource() void DeclarativeDragArea::resetSource()
{ {
setSource(0); setSource(0);
@ -194,6 +197,8 @@ void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
return; return;
} }
emit dragStarted();
QDrag *drag = new QDrag(event->widget()); QDrag *drag = new QDrag(event->widget());
DeclarativeMimeData* dataCopy = new DeclarativeMimeData(m_data); //Qt will take ownership of this copy and delete it. DeclarativeMimeData* dataCopy = new DeclarativeMimeData(m_data); //Qt will take ownership of this copy and delete it.
drag->setMimeData(dataCopy); drag->setMimeData(dataCopy);
@ -201,9 +206,7 @@ void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (!m_delegateImage.isNull()) { if (!m_delegateImage.isNull()) {
drag->setPixmap(QPixmap::fromImage(m_delegateImage)); drag->setPixmap(QPixmap::fromImage(m_delegateImage));
} else if (m_delegate) { } else if (m_delegate) {
// Render the delegate to a Pixmap // Render the delegate to a Pixmap
QDeclarativeItem* item = qobject_cast<QDeclarativeItem *>(m_delegate->create()); QDeclarativeItem* item = qobject_cast<QDeclarativeItem *>(m_delegate->create());
QGraphicsScene scene; QGraphicsScene scene;

View File

@ -117,6 +117,7 @@ public:
DeclarativeMimeData* mimeData() const; DeclarativeMimeData* mimeData() const;
signals: signals:
void dragStarted();
void delegateChanged(); void delegateChanged();
void sourceChanged(); void sourceChanged();
void targetChanged(); void targetChanged();