QmlDesigner.dragAndDrop: optimize drag and drop behaivour

We select now after the drop event.
Some fixes for the out of process stuff.
This commit is contained in:
Thomas Hartmann
2010-12-08 16:10:32 +01:00
parent c0ebc47ef2
commit de96223b76
2 changed files with 9 additions and 7 deletions

View File

@@ -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
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()
{ {
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)
} 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)
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")) {

View File

@@ -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:
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;
}; };