Commit 786bd921 authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Use the selection instead of the passing a node to the custom tool



Change-Id: I69d6d3cf9d35378ef80e9d232123cb5f4b1fa8cb
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 9a0abef1
......@@ -213,8 +213,10 @@ void AbstractFormEditorTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> &
{
if (event->button() == Qt::LeftButton) {
FormEditorItem *formEditorItem = topFormEditorItem(itemList);
if (formEditorItem)
view()->changeToCustomTool(formEditorItem->qmlItemNode().modelNode());
if (formEditorItem) {
view()->setSelectedModelNode(formEditorItem->qmlItemNode().modelNode());
view()->changeToCustomTool();
}
}
}
......
......@@ -413,25 +413,29 @@ void FormEditorView::changeToTransformTools()
changeToSelectionTool();
}
void FormEditorView::changeToCustomTool(const ModelNode &modelNode)
void FormEditorView::changeToCustomTool()
{
int handlingRank = 0;
AbstractCustomTool *selectedCustomTool;
if (hasSelectedModelNodes()) {
int handlingRank = 0;
AbstractCustomTool *selectedCustomTool;
foreach (AbstractCustomTool *customTool, m_customToolList) {
if (customTool->wantHandleItem(modelNode) > handlingRank) {
handlingRank = customTool->wantHandleItem(modelNode);
selectedCustomTool = customTool;
}
ModelNode selectedModelNode = selectedModelNodes().first();
}
foreach (AbstractCustomTool *customTool, m_customToolList) {
if (customTool->wantHandleItem(selectedModelNode) > handlingRank) {
handlingRank = customTool->wantHandleItem(selectedModelNode);
selectedCustomTool = customTool;
}
if (handlingRank > 0) {
m_scene->updateAllFormEditorItems();
m_currentTool->clear();
m_currentTool = selectedCustomTool;
m_currentTool->clear();
m_currentTool->setItems(scene()->itemsForQmlItemNodes(selectedQmlItemNodes()));
}
if (handlingRank > 0) {
m_scene->updateAllFormEditorItems();
m_currentTool->clear();
m_currentTool = selectedCustomTool;
m_currentTool->clear();
m_currentTool->setItems(scene()->itemsForQmlItemNodes(selectedQmlItemNodes()));
}
}
}
......
......@@ -100,7 +100,7 @@ public:
void changeToSelectionTool(QGraphicsSceneMouseEvent *event);
void changeToResizeTool();
void changeToTransformTools();
void changeToCustomTool(const ModelNode &modelNode);
void changeToCustomTool();
void changeToCustomTool(AbstractCustomTool *customTool);
void registerTool(AbstractCustomTool *tool);
......
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