Commit b39be67c authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.dragAndDrop: fix

This is just a hotfix. We have to find a way to properly
sync with the out of process node instances.
parent 5ab2b734
......@@ -42,13 +42,24 @@
#include <QGraphicsSceneMouseEvent>
#include <QtDebug>
#include <QMessageBox>
#include <QTimer>
namespace QmlDesigner {
namespace Internal {
void TimerHandler::clearMoveDelay()
{
m_dragTool->clearMoveDelay();
}
}
DragTool::DragTool(FormEditorView *editorView)
: AbstractFormEditorTool(editorView),
m_moveManipulator(editorView->scene()->manipulatorLayerItem(), editorView),
m_selectionIndicator(editorView->scene()->manipulatorLayerItem())
m_selectionIndicator(editorView->scene()->manipulatorLayerItem()),
m_timerHandler(new Internal::TimerHandler(this)),
m_blockMove(false)
{
// view()->setCursor(Qt::SizeAllCursor);
}
......@@ -197,6 +208,12 @@ void DragTool::formEditorItemsChanged(const QList<FormEditorItem*> & itemList)
}
}
void DragTool::clearMoveDelay()
{
m_blockMove = false;
if (m_dragNode.isValid())
beginWithPoint(m_dragNode.instanceBoundingRect().topLeft());
}
void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event)
{
......@@ -260,6 +277,8 @@ static ItemLibraryEntry itemLibraryEntryFromData(const QByteArray &data)
void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
{
if (m_blockMove)
return;
if (event->mimeData()->hasFormat("application/vnd.bauhaus.itemlibraryinfo") ||
event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
event->accept();
......@@ -283,7 +302,7 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
FormEditorItem *parentItem = calculateContainer(event->scenePos());
if (!parentItem)
return;
QmlItemNode parentNode; //get possible container parentNode
QmlItemNode parentNode;
if (parentItem)
parentNode = parentItem->qmlItemNode();
......@@ -296,8 +315,9 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
QString imageName = QString::fromLatin1((event->mimeData()->data("application/vnd.bauhaus.libraryresource")));
createQmlItemNodeFromImage(imageName, parentNode, event->scenePos());
} else Q_ASSERT(false);
if (m_dragNode.isValid())
beginWithPoint(event->scenePos());
m_blockMove = true;
QTimer::singleShot(50, m_timerHandler.data(), SLOT(clearMoveDelay()));
}
}
if (event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
......
......@@ -36,10 +36,29 @@
#include "resizeindicator.h"
#include <QHash>
#include <QObject>
#include <QScopedPointer>
namespace QmlDesigner {
class DragTool;
namespace Internal {
class TimerHandler : public QObject
{
Q_OBJECT
public:
TimerHandler(DragTool *tool) : QObject(), m_dragTool(tool) {}
public slots:
void clearMoveDelay();
private:
DragTool *m_dragTool;
};
};
class DragTool : public AbstractFormEditorTool
{
......@@ -81,6 +100,8 @@ public:
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList);
void clearMoveDelay();
protected:
......@@ -99,7 +120,10 @@ private:
QWeakPointer<FormEditorItem> m_movingItem;
RewriterTransaction m_rewriterTransaction;
QmlItemNode m_dragNode;
QScopedPointer<Internal::TimerHandler> m_timerHandler;
bool m_blockMove;
};
}
#endif // DRAGTOOL_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment