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

QmlDesigner.dragAndDrop: optimize drag and drop behaivour

We select now after the drop event.
Some fixes for the out of process stuff.
parent c0ebc47e
...@@ -157,8 +157,7 @@ void DragTool::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlIt ...@@ -157,8 +157,7 @@ void DragTool::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlIt
Q_ASSERT(m_dragNode.modelNode().isValid()); Q_ASSERT(m_dragNode.modelNode().isValid());
QList<QmlItemNode> nodeList; QList<QmlItemNode> nodeList;
nodeList.append(m_dragNode); nodeList.append(m_dragNode);
view()->setSelectedQmlItemNodes(nodeList);
m_selectionIndicator.setItems(scene()->itemsForQmlItemNodes(nodeList)); m_selectionIndicator.setItems(scene()->itemsForQmlItemNodes(nodeList));
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::hide(); QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::hide();
...@@ -178,7 +177,6 @@ void DragTool::createQmlItemNodeFromImage(const QString &imageName, QmlItemNode ...@@ -178,7 +177,6 @@ void DragTool::createQmlItemNodeFromImage(const QString &imageName, QmlItemNode
QList<QmlItemNode> nodeList; QList<QmlItemNode> nodeList;
nodeList.append(m_dragNode); nodeList.append(m_dragNode);
view()->setSelectedQmlItemNodes(nodeList);
m_selectionIndicator.setItems(scene()->itemsForQmlItemNodes(nodeList)); m_selectionIndicator.setItems(scene()->itemsForQmlItemNodes(nodeList));
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::hide(); QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::hide();
...@@ -212,7 +210,7 @@ void DragTool::clearMoveDelay() ...@@ -212,7 +210,7 @@ void DragTool::clearMoveDelay()
{ {
m_blockMove = false; m_blockMove = false;
if (m_dragNode.isValid()) if (m_dragNode.isValid())
beginWithPoint(m_dragNode.instanceBoundingRect().topLeft()); beginWithPoint(m_startPoint);
} }
void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event) void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event)
...@@ -227,6 +225,9 @@ void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event) ...@@ -227,6 +225,9 @@ void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event)
} catch (RewritingException &e) { } catch (RewritingException &e) {
QMessageBox::warning(0, "Error", e.description()); QMessageBox::warning(0, "Error", e.description());
} }
QList<QmlItemNode> nodeList;
nodeList.append(m_dragNode);
view()->setSelectedQmlItemNodes(nodeList);
m_dragNode = ModelNode(); m_dragNode = ModelNode();
view()->changeToSelectionTool(); view()->changeToSelectionTool();
} }
...@@ -316,8 +317,8 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event) ...@@ -316,8 +317,8 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
createQmlItemNodeFromImage(imageName, parentNode, event->scenePos()); createQmlItemNodeFromImage(imageName, parentNode, event->scenePos());
} else Q_ASSERT(false); } else Q_ASSERT(false);
m_blockMove = true; m_blockMove = true;
QTimer::singleShot(50, m_timerHandler.data(), SLOT(clearMoveDelay())); m_startPoint = event->scenePos();
QTimer::singleShot(100, m_timerHandler.data(), SLOT(clearMoveDelay()));
} }
} }
if (event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) { if (event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
......
...@@ -64,7 +64,7 @@ class DragTool : public AbstractFormEditorTool ...@@ -64,7 +64,7 @@ class DragTool : public AbstractFormEditorTool
{ {
public: public:
DragTool(FormEditorView* editorView); DragTool(FormEditorView* editorView);
~DragTool(); virtual ~DragTool();
void mousePressEvent(const QList<QGraphicsItem*> &itemList, void mousePressEvent(const QList<QGraphicsItem*> &itemList,
QGraphicsSceneMouseEvent *event); QGraphicsSceneMouseEvent *event);
...@@ -122,6 +122,7 @@ private: ...@@ -122,6 +122,7 @@ private:
QmlItemNode m_dragNode; QmlItemNode m_dragNode;
QScopedPointer<Internal::TimerHandler> m_timerHandler; QScopedPointer<Internal::TimerHandler> m_timerHandler;
bool m_blockMove; bool m_blockMove;
QPointF m_startPoint;
}; };
......
Supports Markdown
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