forked from qt-creator/qt-creator
QmlDesigner.dragAndDrop: fix
This is just a hotfix. We have to find a way to properly sync with the out of process node instances.
This commit is contained in:
@@ -42,13 +42,24 @@
|
|||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
void TimerHandler::clearMoveDelay()
|
||||||
|
{
|
||||||
|
m_dragTool->clearMoveDelay();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
DragTool::DragTool(FormEditorView *editorView)
|
DragTool::DragTool(FormEditorView *editorView)
|
||||||
: AbstractFormEditorTool(editorView),
|
: AbstractFormEditorTool(editorView),
|
||||||
m_moveManipulator(editorView->scene()->manipulatorLayerItem(), 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);
|
// 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)
|
void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event)
|
||||||
{
|
{
|
||||||
@@ -260,6 +277,8 @@ static ItemLibraryEntry itemLibraryEntryFromData(const QByteArray &data)
|
|||||||
|
|
||||||
void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
|
void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
|
||||||
{
|
{
|
||||||
|
if (m_blockMove)
|
||||||
|
return;
|
||||||
if (event->mimeData()->hasFormat("application/vnd.bauhaus.itemlibraryinfo") ||
|
if (event->mimeData()->hasFormat("application/vnd.bauhaus.itemlibraryinfo") ||
|
||||||
event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
||||||
event->accept();
|
event->accept();
|
||||||
@@ -283,7 +302,7 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
|
|||||||
FormEditorItem *parentItem = calculateContainer(event->scenePos());
|
FormEditorItem *parentItem = calculateContainer(event->scenePos());
|
||||||
if (!parentItem)
|
if (!parentItem)
|
||||||
return;
|
return;
|
||||||
QmlItemNode parentNode; //get possible container parentNode
|
QmlItemNode parentNode;
|
||||||
if (parentItem)
|
if (parentItem)
|
||||||
parentNode = parentItem->qmlItemNode();
|
parentNode = parentItem->qmlItemNode();
|
||||||
|
|
||||||
@@ -296,8 +315,9 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
|
|||||||
QString imageName = QString::fromLatin1((event->mimeData()->data("application/vnd.bauhaus.libraryresource")));
|
QString imageName = QString::fromLatin1((event->mimeData()->data("application/vnd.bauhaus.libraryresource")));
|
||||||
createQmlItemNodeFromImage(imageName, parentNode, event->scenePos());
|
createQmlItemNodeFromImage(imageName, parentNode, event->scenePos());
|
||||||
} else Q_ASSERT(false);
|
} else Q_ASSERT(false);
|
||||||
if (m_dragNode.isValid())
|
m_blockMove = true;
|
||||||
beginWithPoint(event->scenePos());
|
QTimer::singleShot(50, m_timerHandler.data(), SLOT(clearMoveDelay()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
if (event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
||||||
|
|||||||
@@ -36,10 +36,29 @@
|
|||||||
#include "resizeindicator.h"
|
#include "resizeindicator.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
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
|
class DragTool : public AbstractFormEditorTool
|
||||||
{
|
{
|
||||||
@@ -81,6 +100,8 @@ public:
|
|||||||
|
|
||||||
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList);
|
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList);
|
||||||
|
|
||||||
|
void clearMoveDelay();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
@@ -99,7 +120,10 @@ private:
|
|||||||
QWeakPointer<FormEditorItem> m_movingItem;
|
QWeakPointer<FormEditorItem> m_movingItem;
|
||||||
RewriterTransaction m_rewriterTransaction;
|
RewriterTransaction m_rewriterTransaction;
|
||||||
QmlItemNode m_dragNode;
|
QmlItemNode m_dragNode;
|
||||||
|
QScopedPointer<Internal::TimerHandler> m_timerHandler;
|
||||||
|
bool m_blockMove;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif // DRAGTOOL_H
|
#endif // DRAGTOOL_H
|
||||||
|
|||||||
Reference in New Issue
Block a user